Index: openacs-4/packages/acs-developer-support/lib/toolbar.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-developer-support/lib/toolbar.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/acs-developer-support/lib/toolbar.tcl 10 Sep 2007 08:31:17 -0000 1.9 +++ openacs-4/packages/acs-developer-support/lib/toolbar.tcl 5 Oct 2007 12:02:38 -0000 1.10 @@ -74,6 +74,29 @@ } } + +# Retrieve all CSS files loaded on this page +# Generate the tag multirow +variable ::template::head::links + +set css_list [list] +if {[array exists links]} { + foreach name [array names links] { + foreach {rel href type media title lang} $links($name) { + if {$type eq "text/css"} { + lappend css_list $href + } + } + } +} + +if {$css_list ne ""} { + multirow append ds_buttons CSS \ + "Show CSS" \ + [export_vars -base "/ds/css-list" { css_list { return_url [ad_return_url] } }] \ + off +} + set rm_package_id [apm_package_id_from_key xotcl-request-monitor] if {$rm_package_id > 0} { set rm_url [apm_package_url_from_id $rm_package_id] Index: openacs-4/packages/acs-developer-support/www/css-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-developer-support/www/css-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-developer-support/www/css-edit.adp 5 Oct 2007 12:02:38 -0000 1.1 @@ -0,0 +1,2 @@ + + \ No newline at end of file Index: openacs-4/packages/acs-developer-support/www/css-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-developer-support/www/css-edit.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-developer-support/www/css-edit.tcl 5 Oct 2007 12:02:38 -0000 1.1 @@ -0,0 +1,103 @@ +# + +ad_page_contract { + + Edit and write the CSS file + + @author Malte Sussdorff (malte.sussdorff@cognovis.de) + @creation-date 2007-09-29 + @cvs-id $Id: css-edit.tcl,v 1.1 2007/10/05 12:02:38 maltes Exp $ +} { + {file_location} + {css_location} + {return_url "/"} +} -properties { +} -validate { +} -errors { +} + + +if {[file exists $file_location] && [file extension $file_location] eq ".css"} { + + + ad_form -name css-edit -export {file_location css_location} -form { + {css_path:text(inform)} + {revision_html:text(inform)} + {css_content:text(textarea) + {html {rows 40 cols 80}} + } + {css_description:text(text),optional } + } -on_request { + + set package_id [ad_conn package_id] + set css_path "$css_location" + set fp [open "$file_location" "r"] + set css_content "" + while { [gets $fp line] >= 0 } { + append css_content "$line \n" + } + close $fp + + set item_id [content::item::get_id_by_name -name $file_location -parent_id $package_id] + set revision_html "" + if {$item_id ne ""} { + append revision_html "
    " + db_foreach revision {select revision_id, publish_date, description from cr_revisions where item_id = :item_id order by publish_date desc} { + if { [content::revision::is_live -revision_id $revision_id] eq "t" } { + set make_live "that's live!" + } else { + set return_url_2 [ad_return_url] + set make_live "make live!" + } + set return_url "" + append revision_html "
  1. $publish_date \[$make_live\]: [string range $description 0 50]
  2. " + } + append revision_html "
" + file stat $file_location file_stat_arr + # mcordova: ugly things until I figure out how to do that in a + # better way... + set item_id [content::item::get_id_by_name -name $file_location -parent_id $package_id] + ns_log Notice " * * * the file $file_location (cr_item_id: $item_id) has that modif time: \[$file_stat_arr(mtime)\]" + #todo compare file mtime with live revision time + ## if they are not the same date, show user a warning + # recommening to make a new revision... + } else { + append revision_html "no revisions yet" + + } + } -on_submit { + + set package_id [ad_conn package_id] + + # Create new item if necessary + set item_id [content::item::get_id_by_name -name $file_location -parent_id $package_id] + if {$item_id eq ""} { + + # Get the old version to initialize the item with + set fp [open "$file_location" "r"] + set old_css_content "" + while { [gets $fp line] >= 0 } { + append old_css_content "$line \n" + } + close $fp + + set item_id [content::item::new -name $file_location -parent_id $package_id -content_type "css_file" -title "$css_location" -description "First revision" -text $old_css_content] + } + + + # Write the new content to the file + if {[file exists $file_location] && [file extension $file_location] eq ".css"} { + set fp [open "${file_location}" "w"] + puts $fp "$css_content" + close $fp + } + + # Store the new revision in the CR + content::revision::new -item_id $item_id -title $css_location -description $css_description -is_live "t" -content $css_content + + } -after_submit { + ad_returnredirect $return_url + } -cancel_url $return_url +} else { + ad_returnredirect $return_url +} \ No newline at end of file Index: openacs-4/packages/acs-developer-support/www/css-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-developer-support/www/css-list.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-developer-support/www/css-list.adp 5 Oct 2007 12:02:38 -0000 1.1 @@ -0,0 +1,4 @@ + + + @css_multirow.file_location;noquote@ || Edit
+
\ No newline at end of file Index: openacs-4/packages/acs-developer-support/www/css-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-developer-support/www/css-list.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-developer-support/www/css-list.tcl 5 Oct 2007 12:02:38 -0000 1.1 @@ -0,0 +1,35 @@ +# + +ad_page_contract { + + List of all CSS files in the system + + @author Malte Sussdorff (malte.sussdorff@cognovis.de) + @creation-date 2007-09-29 + @cvs-id $Id: css-list.tcl,v 1.1 2007/10/05 12:02:38 maltes Exp $ +} { + {return_url ""} + {css_list} +} -properties { +} -validate { +} -errors { +} + +template::multirow create css_multirow css_location file_location edit_url +foreach css $css_list { + set css_path_list [split $css "/"] + set path_root [lindex $css_path_list 1] + if { $path_root eq "resources"} { + set file_location "[acs_package_root_dir [lindex $css_path_list 2]]/www/resources/[join [lrange $css_path_list 3 end] /]" + set edit_location [export_vars -base "css-edit" -url {file_location return_url {css_location $css}}] + } elseif {[apm_version_id_from_package_key $path_root] ne ""} { + # THis is a package key, but not resources directory + set package_key $path_root + set file_location "[acs_package_root_dir $package_key]/www/[join [lrange $css_path_list 2 end] /]" + set edit_location [export_vars -base "css-edit" -url {file_location return_url {css_location $css}}] + } else { + set file_location $css + set edit_location "" + } + template::multirow append css_multirow $css $file_location $edit_location +} Index: openacs-4/packages/acs-developer-support/www/css-make-live.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-developer-support/www/css-make-live.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-developer-support/www/css-make-live.tcl 5 Oct 2007 12:02:38 -0000 1.1 @@ -0,0 +1,30 @@ +# + +ad_page_contract { + + make a css revision the live one + + @author Malte Sussdorff (malte.sussdorff@cognovis.de) + @creation-date 2007-09-30 + @cvs-id $Id: css-make-live.tcl,v 1.1 2007/10/05 12:02:38 maltes Exp $ +} { + {revision_id:integer} + {file_location } + {return_url_2 "/"} +} -properties { +} -validate { +} -errors { +} + + +content::item::set_live_revision -revision_id $revision_id + +set item_id [content::revision::item_id -revision_id $revision_id] +#set target [content::item::get_name -item_id $item_id] +set target $file_location +set source [content::revision::get_cr_file_path -revision_id $revision_id] + +#todo check if files are stored in db +file copy -force $source $target + +ad_returnredirect $return_url_2