werc-1.5.0-tweaks

Tweaks for the werc website builder created by the mad architect Uriel
Log | Files | Refs | README

app.rc (1327B)


      1 fn conf_enable_wiki {
      2     enable_wiki=yes
      3     wiki_editors_groups=$* 
      4     conf_enable_app dirdir
      5 }
      6 
      7 fn dirdir_init {
      8     if(! ~ $#enable_wiki 0 && check_user $wiki_editors_groups) {
      9         lp=$local_path
     10         # werc.rc doesn't append /index when $local_path doesn't exist
     11         # maybe it should, but for now we can fix it up here.
     12         if(~ $lp */) 
     13             lp=$lp^'index'
     14         dirdir_file=$lp.md
     15         dirdir_dir=$dirdir_file^'_werc/dirdir/'
     16  
     17         if(~ 1 $#post_arg_dirdir_edit $#post_arg_dirdir_preview)
     18             handler_body_main=(tpl_handler `{get_lib_file dirdir/edit.tpl apps/dirdir/edit.tpl})
     19 
     20         if not if(! ~ '' $"post_arg_dirdir_save $"post_arg_edit_text)
     21             save_page
     22 
     23         if not if(~ $"handler_body_main  '' || {~ $REQUEST_METHOD GET && test -f $local_path.md})
     24             ll_add handlers_bar_left tpl_handler apps/dirdir/sidebar_controls.tpl
     25     }
     26 }
     27 
     28 fn save_page {
     29     dirdir_verdir=$dirdir_dir/^`{date -n}^/
     30     mkdir -p $dirdir_verdir
     31     umask 002
     32 
     33     # XXX Use a tmp file and  mv(1) to ensure updates are atomic?
     34     echo $logged_user > $dirdir_verdir/author
     35     echo $post_arg_edit_text > $dirdir_verdir/data 
     36     echo $post_arg_edit_text > $dirdir_file
     37 
     38     post_redirect $base_url^$req_path
     39     #notify_notes='Saved <a href="'$"req_path'">'$"req_path'</a>!'
     40 }