thirdculture/werc/apps/cssedit/app.rc

39 lines
1.2 KiB
Text
Raw Permalink Normal View History

2024-11-11 14:52:00 -05:00
fn conf_enable_cssedit {
enable_cssedit=yes
cssedit_editors_groups=$*
conf_enable_app cssedit
css_file='_werc/style.css' # Default location, can be changed
}
fn cssedit_init {
2024-11-18 01:53:38 -05:00
if(! ~ $#enable_cssedit 0) {
css_uri=`{echo $req_path | sed 's,(([^/]*)[^/]).*,\1,'}^/
extraHeaders=$"extraHeaders ^ \
'<link rel="stylesheet" type="text/css" href="'$css_uri'_werc/style.css">'
}
if(! ~ $#enable_cssedit 0 && check_user $cssedit_editors_groups && ~ $req_path $css_uri) {
2024-11-11 14:52:00 -05:00
lp=$local_path
lp=`{echo $lp | sed 's/index$//'}
cssedit_file=$"lp$"css_file
if(~ 1 $#post_arg_cssedit_edit $#post_arg_cssedit_preview) {
handler_body_main=(tpl_handler `{get_lib_file cssedit/edit.tpl apps/cssedit/edit.tpl})
}
if not if(! ~ '' $"post_arg_cssedit_save $"post_arg_css_text) {
save_css
}
if not if(~ $"handler_body_main '' || {~ $REQUEST_METHOD GET && test -f $cssedit_file}) {
ll_add handlers_bar_left tpl_handler apps/cssedit/sidebar_controls.tpl
}
}
}
fn save_css {
umask 002
echo $post_arg_css_text > $cssedit_file
post_redirect $base_url^$req_path
}