fn conf_enable_blog {
blagh_uri=$conf_wd
blagh_dirs=$*
if(~ $#blagh_dirs 0)
blagh_dirs=( . )
conf_enable_app blagh
if(~ $"conf_blog_editors '')
conf_blog_editors=blog-editors
if(~ $"conf_max_posts_per_page '')
conf_max_posts_per_page=32
}
fn blagh_init {
if(~ $#blagh_dirs 0 && ~ $req_path */[bB]log/*) {
blagh_uri=`{echo $req_path | sed 's,(/[bB]log/).*,\1,'}
blagh_dirs=( . )
}
# Should not match sub-dirs!
if(! ~ $#blagh_dirs 0) {
# && test -d / `{echo '-a -d '^$blagh_root^$blagh_dirs}
blagh_url=$base_url^$blagh_uri
blagh_root=$sitedir^$blagh_uri
if(check_user $conf_blog_editors) {
editor_mode=on
if(~ $"post_arg_date '')
post_date=`{datei|sed 's,-,/,g'}
if not
post_date=$post_arg_date
ll_add handlers_bar_left echo 'Make a new post'
}
if(~ $req_path $blagh_uri) {
handler_body_main=blagh_body
u=$blagh_uri'index'
extraHeaders=$"extraHeaders ^ \
'
'
}
if not if(~ $req_path $blagh_uri^index.atom)
blagh_setup_feed_handlers atom.tpl 'application/atom+xml'
if not if(~ $req_path $blagh_uri^index.rss)
blagh_setup_feed_handlers rss20.tpl 'text/xml; charset=utf-8'
if not if(~ $req_path $blagh_uri^feed.json)
blagh_setup_feed_handlers jsonfeed.tpl 'application/json; charset=utf-8'
if not if(~ $req_path $blagh_uri^new_post && ! ~ $#editor_mode 0) {
handler_body_main=( tpl_handler `{get_lib_file blagh/new_post.tpl apps/blagh/new_post.tpl} )
if(~ $REQUEST_METHOD POST) {
if(mkbpost $"post_arg_body $"post_date $"post_arg_title $post_arg_id)
post_redirect $blagh_uri
if not
notify_errors=$status
}
}
if not if (~ $req_path $blagh_uri^*){
echo 1
}
}
}
fn blagh_setup_feed_handlers {
handler_body_main=NOT_USED_by_blagh_feeds
res_tail=()
http_content_type=$2
headers=()
master_template=apps/blagh/$1 # Should we allow tempalte override?
}
fn blagh_body {
if (! ~ $"blogTitle '')
echo '
'$"blogTitle'
'
# Direct links to feeds are disabled because they are not very useful, add clutter and might waste pagerank.
# An user can add this on their own using handlers_body_head anyway.
if (! ~ $base_url 'https://gartzea.com')
# echo '
'
# ⇒
# ➡
# https://www.smashingmagazine.com/2009/07/designing-read-more-and-continue-reading-links/
# cat $p/index.md | sed '1s!.*![&]('^$l(2)^') ('^$l(1)^')!' | sed -n '/^.\{15\}/p' | echo
echo # Needed extra \n so markdown doesn't mess up the formatting, probably can be done in sed.
echo #
} | head -n 12 | $formatter | sed 's/h[2-9]/i/g'| sed 's/h1/h3/g'
# HTML posts
for(p in `{get_post_list $blagh_root^$blagh_dirs}) {
cat < $p/index.html
echo # Needed extra \n so markdown doesn't mess up the formatting, probably can be done in sed.
} | sed 's/h[2-9]/i/g' | sed 's/h1/h3/g' | head -n 5
# XXX BUG! Markdown [references] break because multiple markdown documents are merged. Should format each blog post independently.
# TODO: use fltr_cache directly, that can fix the previous bug plus provide a perf boost by caching title generation.
echo '