Index: openacs-4/packages/xowf/tcl/xowf-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/tcl/xowf-procs.tcl,v diff -u -r1.28.2.64 -r1.28.2.65 --- openacs-4/packages/xowf/tcl/xowf-procs.tcl 9 Jan 2022 20:46:52 -0000 1.28.2.64 +++ openacs-4/packages/xowf/tcl/xowf-procs.tcl 19 Jan 2022 20:04:26 -0000 1.28.2.65 @@ -2011,18 +2011,22 @@ #:log "after allocate lookup of $lang:$stripped_name returned $id, default-lang(${:name})=$default_lang [:nls_language]" if {$id != 0} { # - # The instance exists already. Either use method "m" (if - # provided) or redirect to the item. + # The instance exists already. Either call method "m" + # directly (if provided) or redirect to the item. # if {$m eq ""} { + set base [$package pretty_link -parent_id $parent_id $lang:$stripped_name] + ns_log notice "AFTER ALLOCATE www-create-or-use exists already\n[export_vars -no_base_encode \ + -base $base {return_url template_file}]" + return [$package returnredirect \ [export_vars -no_base_encode \ -base [$package pretty_link -parent_id $parent_id $lang:$stripped_name] \ {return_url template_file}]] } else { set item [::xo::db::CrClass get_instance_from_db -item_id $id] # missing: policy check. - return [$item $m] + return [$item www-$m] } } else { if {$lang ne $default_lang} { @@ -2032,6 +2036,7 @@ } #:msg "We want to create $lang:$stripped_name" set name $lang:$stripped_name + ns_log notice "AFTER ALLOCATE www-create-or-use wanna create $lang:$stripped_name" } } } Index: openacs-4/packages/xowf/tcl/test/test-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/tcl/test/test-item-procs.tcl,v diff -u -r1.1.2.22 -r1.1.2.23 --- openacs-4/packages/xowf/tcl/test/test-item-procs.tcl 19 Jan 2022 18:23:47 -0000 1.1.2.22 +++ openacs-4/packages/xowf/tcl/test/test-item-procs.tcl 19 Jan 2022 20:04:26 -0000 1.1.2.23 @@ -473,8 +473,8 @@ question.points 4 question.interaction.text {Given a text with a file filled out for the page [[file:somefile]] and some unresolved link [[file:unresolved]] - and as an image [[image:sample_text_0_image.png|Some image1]] - and a SELF image [[.SELF./file:sample_text_0_image2.png|Some image2]].} + and as an image [[image:sample_text_0_image1.png|Some image1]] + and a SELF image [[.SELF./image:sample_text_0_image2.png|Some image2]].} }] # # When the text interaction is opened with preview, and a @@ -496,30 +496,21 @@ $::acs::rootdir/packages/xowf/tcl/test/test-item-procs.tcl $file_object save_new - set image_object [::xowiki::File new \ - -destroy_on_cleanup \ - -title "sample_text_0_image.png" \ - -name file:sample_text_0_image.png \ - -parent_id [$text_page item_id] \ - -mime_type image/png \ - -package_id $package_id \ - -creation_user [dict get $user_info user_id]] - $image_object set import_file \ - $::acs::rootdir/packages/acs-subsite/www/resources/attach.png - $image_object save_new + foreach img {image1.png image2.png} { + aa_section "Create image 'file:sample_text_0_$img' as child of '[$text_page name]' [$text_page item_id]" + set image_object [::xowiki::File new \ + -destroy_on_cleanup \ + -title "sample_text_0_$img" \ + -name file:sample_text_0_$img \ + -parent_id [$text_page item_id] \ + -mime_type image/png \ + -package_id $package_id \ + -creation_user [dict get $user_info user_id]] + $image_object set import_file \ + $::acs::rootdir/packages/acs-subsite/www/resources/attach.png + $image_object save_new + } - set image_object [::xowiki::File new \ - -destroy_on_cleanup \ - -title "sample_text_0_image2.png" \ - -name file:sample_text_0_image2.png \ - -parent_id [$text_page item_id] \ - -mime_type image/png \ - -package_id $package_id \ - -creation_user [dict get $user_info user_id]] - $image_object set import_file \ - $::acs::rootdir/packages/acs-subsite/www/resources/attach.png - $image_object save_new - ############################################################# aa_section "Call preview workflow for '[$text_page name]'" @@ -541,12 +532,16 @@ acs::test::dom_html root [dict get $d body] { set resolved [lmap p [$root selectNodes {//a[@class='file']/@href}] {file tail [lindex $p 1]}] set unresolved [lmap p [$root selectNodes {//a[@class='missing']/@href}] {file tail [lindex $p 1]}] + set images [lmap p [$root selectNodes {//img[@class='image']/@src}] {file tail [lindex $p 1]}] } aa_log "RESOLVED='$resolved'" aa_log "UNRESOLVED='$unresolved'" + aa_log "IMAGES='$images'" aa_true "link 'somefile' is resolved" {"somefile" in $resolved} aa_true "link 'unresolved' is not resolved" [string match "*file:unresolved*" $unresolved] + aa_true "image 'sample_text_0_image1' is resolved" {"sample_text_0_image1.png" in $images} + aa_true "image 'sample_text_0_image2' is resolved" {"sample_text_0_image2.png" in $images} ########################################################################################## aa_section "create composite page 'sample_composite_0'" @@ -566,7 +561,7 @@ question.twocol f question.interaction.text { Given a text with an [[file:otherfile]] - img [[image:sample_composite_0_image.png|Some image]] + img [[image:sample_composite_0_image1.png|Some image]] SELF img [[.SELF./image:sample_composite_0_image2.png|Some image2-self]].} question.interaction.selection .testfolder/en:sample_text_0 }] @@ -586,17 +581,19 @@ $::acs::rootdir/packages/xowf/tcl/test/test-item-procs.tcl $file_object save_new - set image_object [::xowiki::File new \ - -destroy_on_cleanup \ - -title "sample_composite_0_image2.png" \ - -name file:sample_composite_0_image2.png \ - -parent_id [$composite_page item_id] \ - -mime_type image/png \ - -package_id $package_id \ - -creation_user [dict get $user_info user_id]] - $image_object set import_file \ - $::acs::rootdir/packages/acs-subsite/www/resources/attach.png - $image_object save_new + foreach img {image1.png image2.png} { + set image_object [::xowiki::File new \ + -destroy_on_cleanup \ + -title "sample_composite_0_$img" \ + -name file:sample_composite_0_$img \ + -parent_id [$composite_page item_id] \ + -mime_type image/png \ + -package_id $package_id \ + -creation_user [dict get $user_info user_id]] + $image_object set import_file \ + $::acs::rootdir/packages/acs-subsite/www/resources/attach.png + $image_object save_new + } ############################################################# aa_section "Call preview workflow for '[$composite_page name]'" @@ -629,9 +626,9 @@ aa_true "link 'otherfile' is resolved" {"otherfile" in $resolved} foreach filename { - sample_text_0_image.png - sample_text_0_image_2.png - sample_composite_0_image.png + sample_text_0_image1.png + sample_text_0_image2.png + sample_composite_0_image1.png sample_composite_0_image2.png } { aa_true "image '$filename' is resolved" {$filename in $images}