2009-02-07 17:22:46 -07:00
|
|
|
fn conf_enable_wiki {
|
|
|
|
enable_wiki=yes
|
2009-02-26 03:50:18 -07:00
|
|
|
wiki_editors_groups=$*
|
2009-02-07 17:22:46 -07:00
|
|
|
conf_enable_app dirdir
|
|
|
|
}
|
|
|
|
|
2009-01-16 19:43:36 -07:00
|
|
|
fn dirdir_init {
|
2009-03-03 19:12:54 -07:00
|
|
|
if(! ~ $#enable_wiki 0 && check_user $wiki_editors_groups) {
|
2009-09-22 09:12:34 -06:00
|
|
|
lp=$local_path
|
2016-02-04 13:05:05 -07:00
|
|
|
# werc.rc doesn't append /index when $local_path doesn't exist
|
2009-09-22 09:12:34 -06:00
|
|
|
# maybe it should, but for now we can fix it up here.
|
|
|
|
if(~ $lp */)
|
|
|
|
lp=$lp^'index'
|
|
|
|
dirdir_file=$lp.md
|
2009-02-26 03:50:18 -07:00
|
|
|
dirdir_dir=$dirdir_file^'_werc/dirdir/'
|
2009-03-14 07:25:54 -06:00
|
|
|
|
|
|
|
if(~ 1 $#post_arg_dirdir_edit $#post_arg_dirdir_preview)
|
|
|
|
handler_body_main=(tpl_handler `{get_lib_file dirdir/edit.tpl apps/dirdir/edit.tpl})
|
2009-02-26 03:50:18 -07:00
|
|
|
|
2009-03-14 07:25:54 -06:00
|
|
|
if not if(! ~ '' $"post_arg_dirdir_save $"post_arg_edit_text)
|
2009-03-03 19:12:54 -07:00
|
|
|
save_page
|
2009-01-25 19:37:47 -07:00
|
|
|
|
2009-03-14 07:25:54 -06:00
|
|
|
if not if(~ $"handler_body_main '' || {~ $REQUEST_METHOD GET && test -f $local_path.md})
|
|
|
|
ll_add handlers_bar_left tpl_handler apps/dirdir/sidebar_controls.tpl
|
2009-01-25 19:37:47 -07:00
|
|
|
}
|
2009-01-16 19:43:36 -07:00
|
|
|
}
|
2009-03-03 19:12:54 -07:00
|
|
|
|
|
|
|
fn save_page {
|
|
|
|
dirdir_verdir=$dirdir_dir/^`{date -n}^/
|
|
|
|
mkdir -p $dirdir_verdir
|
2009-03-16 19:02:35 -06:00
|
|
|
umask 002
|
2009-03-03 19:12:54 -07:00
|
|
|
|
|
|
|
# XXX Use a tmp file and mv(1) to ensure updates are atomic?
|
|
|
|
echo $logged_user > $dirdir_verdir/author
|
|
|
|
echo $post_arg_edit_text > $dirdir_verdir/data
|
|
|
|
echo $post_arg_edit_text > $dirdir_file
|
|
|
|
|
|
|
|
post_redirect $base_url^$req_path
|
|
|
|
#notify_notes='Saved <a href="'$"req_path'">'$"req_path'</a>!'
|
|
|
|
}
|