Index: openacs-4/packages/acs-content-repository/tcl/publish-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/publish-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-content-repository/tcl/publish-procs.tcl 1 Nov 2003 08:45:36 -0000 1.5 +++ openacs-4/packages/acs-content-repository/tcl/publish-procs.tcl 3 Nov 2003 12:45:23 -0000 1.6 @@ -6,6 +6,83 @@ namespace eval handle {} } + +ad_proc -public publish::get_page_root {} { + + Get the page root. All items will be published to the + filesystem with their URLs relative to this root. + The page root is controlled by the PageRoot parameter in CMS. + A relative path is relative to [ns_info pageroot] + The default is [ns_info pageroot] + + @return The page root + + @see publish::get_template_root + @see publish::get_publish_roots + +} { + # LARS TODO: This parameter doesn't exist, it's a remnant from the CMS package + set root_path [parameter::get \ + -package_id [ad_conn package_id] \ + -parameter PageRoot] + + if { [string index $root_path 0] != "/" } { + # Relative path, prepend server_root + set root_path "[ns_info pageroot]/$root_path" + } + + return [ns_normalizepath $root_path] + +} + + +ad_proc -public publish::get_publish_roots {} { + Get a list of all page roots to which files may be published. + The publish roots are controlled by the PublishRoots parameter in CMS, + which should be a space-separated list of all the roots. Relative paths + are relative to publish::get_page_root. + The default is [list [publish::get_page_root]] + + @return A list of all the publish roots + + @see publish::get_template_root + @see publish::get_page_root + +} { + # LARS TODO: This parameter doesn't exist, it's a remnant from the CMS package + set root_paths [parameter::get \ + -package_id [ad_conn package_id] \ + -parameter PublishRoots] + + if { [llength $root_paths] == 0 } { + set root_paths [list [get_page_root]] + } + + # Resolve relative paths + set page_root [publish::get_page_root] + set absolute_paths [list] + foreach path $root_paths { + if { [string index $path 0] != "/" } { + lappend absolute_paths [ns_normalizepath "$page_root/$path"] + } else { + lappend absolute_paths $path + } + } + + return $absolute_paths +} + +ad_proc -public publish::mkdirs { path } { + Create all the directories neccessary to save the specified file + + @param path The path to the file that is about to be saved +} { + set index [string last "/" $path] + if { $index != -1 } { + file mkdir [string range $path 0 [expr $index - 1]] + } +} + ############################################### # Procs to maintain the item_id stack # main_item_id is always the id at the top of the stack @@ -205,7 +282,7 @@ set file_url [publish::write_content $revision_id \ -item_id $item_id -root_path [publish::get_publish_roots]] - + # If write_content aborted, give up if { [template::util::is_nil file_url] } { set error_msg "No URL found for revision $revision_id, item $item_id" @@ -292,11 +369,11 @@ externally. } { - template::util::get_opts $args - + + # LARS TODO: Added -no_merge, verify how this is supposed to work set html [eval publish::handle_binary_file \ - $item_id revision_id url error_msg $args] + $item_id revision_id url error_msg $args -no_merge] # If an error happened, abort if { ![template::util::is_nil error_msg] } { @@ -321,7 +398,7 @@ set have_alt 0 } - set html "