Commit 60b578d0 authored by Frank Bergmann's avatar Frank Bergmann

- Upgrade to OpenACS 5.6

parent 17c2bf24
ad_returnredirect ..
<master>
<formtemplate id="css-edit"></formtemplate>
\ No newline at end of file
#
ad_page_contract {
Edit and write the CSS file
@author Malte Sussdorff (malte.sussdorff@cognovis.de)
@creation-date 2007-09-29
@cvs-id $Id$
} {
{file_location}
{css_location}
{revision_id ""}
{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 "<a href='$css_location'>$css_location</a>"
if {$revision_id eq ""} {
set fp [open "$file_location" "r"]
} else {
set fp [open [content::revision::get_cr_file_path -revision_id $revision_id] "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 "<ol>"
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 "<b>that's live!</b>"
} else {
set return_url_2 [ad_return_url]
set make_live "<a href=\"[export_vars -base "css-make-live" -url {revision_id return_url_2 file_location}]\">make live!</a>"
}
set return_url ""
set revision_url [export_vars -base "css-edit" {revision_id file_location css_location}]
append revision_html "<li><a href='$revision_url'>$publish_date</a> \[$make_live\]: [string range $description 0 50]</li>"
}
append revision_html "</ol>"
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]
#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 "<em>no revisions yet</em>"
}
} -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 -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
}
<master>
<multiple name="css_multirow">
<a href="@css_multirow.css_location;noquote@">@css_multirow.file_location;noquote@</a> || <a href="@css_multirow.edit_url;noquote@">Edit</a><br>
</multiple>
\ No newline at end of file
#
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$
} {
{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
}
#
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$
} {
{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
<master>
<property name="title">Edit and code links</property>
<property name="context">editlocal</property>
<p>
The <u>e</u> and <u>c</u> links in the bottom profiling pane display when ds is enabled
and the profiling is running for page renders. The <u>c</u> link sends the body of the cached compiled code
and the <u>e</u> link sends the filename with a mimetype of application/x-editlocal which you can
have run a script which will start an editor session on a local copy of that file
(or potentially a <a href="http://www.fifi.org/doc/tramp/tramp-emacs.html">tramp</a> or Ange-FTP session in
emacs).
<p>
<p>
An example <a href="editlocal.sh.txt">editlocal.sh</a> script would look something
like:
<pre>
#!/bin/sh
# an example editlocal script. To use tell your browser to use
# it to open files with mimetype application/x-editlocal
#
SERVERROOT=/web/head
for a in `cat $1`
do
if [ -f "$a" ]
then
emacsclient -n "$a"
elif [ -f "$SERVERROOT/$a" ]
then
emacsclient -n "$SERVERROOT/$a"
fi
done
</pre>
\ No newline at end of file
#!/bin/sh
# an example editlocal script. To use tell your browser to use
# it to open files with mimetype application/x-editlocal
#
SERVERROOT=/web/head
for a in `cat $1`
do
if [ -f "$a" ]
then
emacsclient -n "$a"
elif [ -f "$SERVERROOT/$a" ]
then
emacsclient -n "$SERVERROOT/$a"
fi
done
#developer-toolbar {
font-size: 85%;
background-color: #616093;
color: white;
padding: 2px 8px;
}
#developer-toolbar form {
margin: -3px 0 0 0;
padding: 0;
}
#developer-toolbar tr {
border-top: 4px solid #616093;
}
#developer-toolbar td a {
border: solid 1px grey;
padding: 0 2px;
text-align: center;
color: white;
text-decoration: none;
}
#developer-toolbar td a:hover {
text-decoration: none;
background-color: #999999;
border: solid 1px #cccccc;
}
#developer-toolbar #developer-search {
color: white;
}
#developer-toolbar #developer-search input {
padding: 0;
font-size: 85%;
}
#developer-toolbar td a.on {
background-color: #888888;
border: solid 1px #cccccc;
}
#developer-toolbar td a:hover.on {
background-color: #666666;
border: solid 1px #999999;
}
#developer-toolbar .actions {
padding: 0;
margin: 0;
}
#developer-toolbar .actions ul {
margin: 0;
padding: 0;
display: inline;
border: none;
}
#developer-toolbar .actions ul li {
margin: 0;
padding: 0;
border: none;
list-style: none;
display: inline;
}
/* ADP Reveal mode */
div.developer-support-adp-box-on {
background-color: #fcc;
border-style: solid;
border-color: #f33;
border-width: 1px;
}
div.developer-support-adp-box-off {
background-color: inherit;
border-width: 0px;
}
span.developer-support-adp-file-on {
font-size: 80%;
line-height: 1.3em;
margin-left: 1em;
font-weight: bold;
}
span.developer-support-adp-file-off {
display: none;
}
div.developer-support-adp-output-on {
background-color: #fff;
border-style: solid;
border-color: #777;
border-width: 1px 0px 0px 0px;
padding: 3px;
line-height: 1.2em;
}
div.developer-support-adp-output-off {
background-color: inherit;
border-width: 0px;
padding: 0px;
}
/* Developer-support footer */
.developer-support-footer {
clear: both;
padding: 6px;
border: solid 1px gray;
background-color: #e1e1e1;
text-align: left;
}
.developer-support-footer-off {
display: none;
}
/* Debug tags normally display: none */
div.developer-support-debug {
display: block;
border: 1px solid red;
}
span.developer-support-debug {
display: inline;
color: red;
}
<master>
<property name="title">Search</property>
<property name="context">@context;noquote@</property>
<p>
<form name="searchfrags" action="search">
<input type="hidden" name="request" value="@request@">
<input type="text" name="expression" value="@expression@">
<input type="submit" name="search" value="Search">
</form>
</p>
<if @gone_p@ false>
<if @matches:rowcount@ gt 0>
<multiple name="matches">
<div style="border-bottom: 1px solid black;"><p>@matches.file_links;noquote@ <b>@matches.page@</b> @matches.size@ bytes</p><pre>@matches.excerpt;noquote@</pre></div>
</multiple>
</if>
<else>
<p>No match</p>
</else>
</if>
<else>
<p>That request is invalid or has expired from the cache.</p>
</else>
\ No newline at end of file
ad_page_contract {
return x-editlocal or the code for the compiled function
@author Jeff Davis <davis@xarg.net>
@creation-date 2005-02-02
@cvs-id $Id$
} {
request:integer,notnull
expression:notnull
}
set context [list [list request-info?request=$request "request $request"] search]
if {![ns_cache get ds_page_bits $request pages]} {
set gone_p 1
} else {
set gone_p 0
multirow create matches page excerpt file_links size
foreach page $pages {
if {![info exists matched($page)]
&& [ns_cache get ds_page_bits $request:$page content]} {
if {[regexp -indices $expression $content offset]} {
set file_links "<a href=\"send?fname=[ns_urlencode $page]\" title=\"edit\">e</a>"
append file_links " <a href=\"send?code=[ns_urlencode $page]\" title=\"compiled code\">c</a>"
append file_links " <a href=\"send?output=$request:[ns_urlencode $page]\" title=\"output\">o</a>"
set size [string length $content]
set highlight "...[ad_quotehtml [string trimleft [string range $content [expr [lindex $offset 0] - 50] [expr [lindex $offset 0] - 1]]]]<b>[ad_quotehtml [string range $content [lindex $offset 0] [lindex $offset 1]]]</b>[ad_quotehtml [string trimright [string range $content [expr [lindex $offset 1] + 1] [expr [lindex $offset 1] + 50]]]]..."
multirow append matches $page $highlight $file_links $size
}
set matched($page) 1
}
}
}
ad_page_contract {
return x-editlocal or the code for the compiled function
} {
{fname:trim {}}
{code:trim {}}
{output:trim {}}
}
ds_require_permission [ad_conn package_id] "admin"
if {![empty_string_p $code]} {
if {[regexp {(.*)\.(adp)} $code match stub ext]} {
ns_return 200 text/plain [info body ::template::code::${ext}::$stub]
} else {
ns_returnfile 200 text/plain $code
}
} elseif {![empty_string_p $fname]} {
ns_return 200 application/x-editlocal [ns_set get [ns_conn form] fname]
} elseif {![empty_string_p $output]} {
if {[regexp {[0-9]+:error} $output]} {
if {[ns_cache get ds_page_bits $output content]} {
foreach error $content {
append out "PAGE: [lindex $error 0]\n[string repeat - 60]\n[lindex $error 1]\n\n\n"
}
ns_return 200 text/plain $out
}
} else {
if {[ns_cache get ds_page_bits $output content]} {
ns_return 200 text/plain "Size: [string length $content]\n\n------------------------------------------------------------\n$content"
} else {
ns_return 200 text/plain "Output for $output has expired"
}
}
}
ad_page_contract {
Consolidated the various toggle pages into one.
@author Lars Pind (lars@pinds.com)
@author Jeff Davis <davis@xarg.net>
@creation-date 2003-10-28
@cvs-id $Id$
} {
field
enabled_p
{return_url "."}
}
ds_require_permission [ad_conn package_id] "admin"
switch -- $field {
com {
parameter::set_value -package_id [ds_instance_id] -parameter ShowCommentsInlineP -value $enabled_p
}
adp {
ds_set_adp_reveal_enabled $enabled_p
}
db {
ds_set_database_enabled $enabled_p
}
prof {
ds_set_profiling_enabled $enabled_p
}
ds {
nsv_set ds_properties enabled_p $enabled_p
}
frag {
nsv_set ds_properties page_fragment_cache_p $enabled_p
}
user {
ds_set_user_switching_enabled $enabled_p
}
default {
ns_return 200 text/plain "bad field $field"
}
}
ad_returnredirect $return_url
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment