From e8cd9a19782fbc1d6c83565e967c73dfda165338 Mon Sep 17 00:00:00 2001 From: Uriel Date: Mon, 1 Jun 2009 07:00:11 +0200 Subject: [PATCH 01/15] Optimization: avoid using a temporary file to calculate the hash in md_handler. --- bin/corehandlers.rc | 2 +- bin/fltr_cache.rc | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/corehandlers.rc b/bin/corehandlers.rc index e72b20f..4deeaec 100644 --- a/bin/corehandlers.rc +++ b/bin/corehandlers.rc @@ -47,7 +47,7 @@ fn link_bar { echo '' } -fn md_handler { $formatter < $1 } +fn md_handler { $formatter $1 } fn tpl_handler { template $* } diff --git a/bin/fltr_cache.rc b/bin/fltr_cache.rc index f09c963..67e82bd 100755 --- a/bin/fltr_cache.rc +++ b/bin/fltr_cache.rc @@ -19,8 +19,10 @@ fn fltr_cache { a=$f f=/dev/null } - if not + if not { score=`{sha1sum $f || exit 1} + score=$score(1) + } } cachedir=/tmp/fltr_cache/$score mkdir -p $cachedir >[2]/dev/null From 9d87478586bfa1921f52381d8a03168ce4b881d2 Mon Sep 17 00:00:00 2001 From: Uriel Date: Sat, 6 Jun 2009 16:15:56 +0200 Subject: [PATCH 02/15] Add a simple wrapper to log stderr in broken http servers. --- bin/werc_errlog_wrap.rc | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 bin/werc_errlog_wrap.rc diff --git a/bin/werc_errlog_wrap.rc b/bin/werc_errlog_wrap.rc new file mode 100755 index 0000000..8a803cc --- /dev/null +++ b/bin/werc_errlog_wrap.rc @@ -0,0 +1,5 @@ +#!/usr/local/plan9/bin/rc + +# This is a wrapper script for broken http servers like recent lighttpd versions which throw away cgi's stderr. + +./werc.rc >>[2]/tmp/wlog.txt From e91609e301bde858319a17d692ca57954873f828 Mon Sep 17 00:00:00 2001 From: Uriel Date: Sat, 6 Jun 2009 16:20:02 +0200 Subject: [PATCH 03/15] Move shared .tpl files to tpl/ from lib/, this fixes a DoS vulneravility where master_template.tpl could be accessed as a standalone .tpl file that recursively called itself. --- bin/corehandlers.rc | 2 +- {lib => tpl}/_debug.tpl | 0 {lib => tpl}/_users/login.tpl | 0 {lib => tpl}/sitemap.tpl | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename {lib => tpl}/_debug.tpl (100%) rename {lib => tpl}/_users/login.tpl (100%) rename {lib => tpl}/sitemap.tpl (100%) diff --git a/bin/corehandlers.rc b/bin/corehandlers.rc index 4deeaec..091d40e 100644 --- a/bin/corehandlers.rc +++ b/bin/corehandlers.rc @@ -92,7 +92,7 @@ fn setup_handlers { if not if(test -f $local_path.html) handler_body_main=(html_handler $local_path.html) # Global tpl (eg sitemap.tpl), should take precedence over txt handler! - if not if(test -f lib^$req_path^.tpl) + if not if(test -f tpl^$req_path^.tpl) handler_body_main=(tpl_handler lib^$req_path^.tpl) if not if(test -f $local_path.txt) handler_body_main=(txt_handler $local_path.txt) diff --git a/lib/_debug.tpl b/tpl/_debug.tpl similarity index 100% rename from lib/_debug.tpl rename to tpl/_debug.tpl diff --git a/lib/_users/login.tpl b/tpl/_users/login.tpl similarity index 100% rename from lib/_users/login.tpl rename to tpl/_users/login.tpl diff --git a/lib/sitemap.tpl b/tpl/sitemap.tpl similarity index 100% rename from lib/sitemap.tpl rename to tpl/sitemap.tpl From c0689e595ad82f42c3b7f0666aede80a452cb098 Mon Sep 17 00:00:00 2001 From: Uriel Date: Sun, 7 Jun 2009 10:40:35 +0200 Subject: [PATCH 04/15] I'm a retard, fix brown paper bag bug from the last commit. --- bin/corehandlers.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/corehandlers.rc b/bin/corehandlers.rc index 091d40e..ddcf8a9 100644 --- a/bin/corehandlers.rc +++ b/bin/corehandlers.rc @@ -93,7 +93,7 @@ fn setup_handlers { handler_body_main=(html_handler $local_path.html) # Global tpl (eg sitemap.tpl), should take precedence over txt handler! if not if(test -f tpl^$req_path^.tpl) - handler_body_main=(tpl_handler lib^$req_path^.tpl) + handler_body_main=(tpl_handler tpl^$req_path^.tpl) if not if(test -f $local_path.txt) handler_body_main=(txt_handler $local_path.txt) From 0b05539176849b4f034d3a400df3082f9fa5e79e Mon Sep 17 00:00:00 2001 From: Uriel Date: Wed, 10 Jun 2009 02:58:36 +0200 Subject: [PATCH 05/15] Urldecode '_' (ie., %5F) in request paths to make stackoverflow.com links happy. --- bin/werc.rc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/werc.rc b/bin/werc.rc index d1cfe6c..08ea7cc 100755 --- a/bin/werc.rc +++ b/bin/werc.rc @@ -41,7 +41,9 @@ fn werc_exec_request { current_date_time=`{date} # Note: $REQUEST_URI is not officially in CGI 1.1, but seems to be de-facto - req_path=`{echo -n $REQUEST_URI | sed 's/\?.*//; s!//+!/!g; s/'^$forbidden_uri_chars^'//g; s/\.\.*/./g; 1q'} + # Note: We only urldecode %5F->'_' because some sites (stackoverflow.com?) urlencode it in their links, + # perhaps we should completel urldecode the whole url. + req_path=`{echo -n $REQUEST_URI | sed 's/\?.*//; s!//+!/!g; s/%5[Ff]/_/g; s/'^$forbidden_uri_chars^'//g; s/\.\.*/./g; 1q'} req_url=$base_url^$req_path local_path=$sitedir$req_path ifs='/' { args=`{echo -n $req_path} } From 646e181bcd9beb15553ba47159f56fa778f374d7 Mon Sep 17 00:00:00 2001 From: Uriel Date: Wed, 10 Jun 2009 04:23:16 +0200 Subject: [PATCH 06/15] New release From a4d8f71e371e25d62335c3b53605b244d6e9771c Mon Sep 17 00:00:00 2001 From: Uriel Date: Wed, 10 Jun 2009 04:23:16 +0200 Subject: [PATCH 07/15] Added tag LATEST-RELEASE for changeset 9fc8f17498d1 From 6eee7a07aaa92050873f16e498335522847c41b0 Mon Sep 17 00:00:00 2001 From: Uriel Date: Fri, 12 Jun 2009 23:44:21 +0200 Subject: [PATCH 08/15] New configuration variable for blagh: conf_max_posts_per_page sets the maximum numbers to display in a blog feed, default is 32. Note that this also affects rss feeds. --- apps/blagh/app.rc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/blagh/app.rc b/apps/blagh/app.rc index 8ae26fa..f652eae 100644 --- a/apps/blagh/app.rc +++ b/apps/blagh/app.rc @@ -6,6 +6,7 @@ fn conf_enable_blog { conf_enable_app blagh } conf_blog_editors=blog-editors +conf_max_posts_per_page=32 fn blagh_init { if(~ $#blagh_dirs 0 && ~ $req_path */[bB]log/*) { @@ -76,7 +77,7 @@ fn blagh_body { fn get_post_list { # /./->/|/ done to sort -t| and order by date # Note: $paths in blagh_dirs should not contain '/./' or '|' - ls -F $*^/./[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/ >[2]/dev/null | sed -n '/'^$forbidden_uri_chars^'/d; s,/\./,/|/,; /\/$/p' | sort -r '-t|' +1 | sed 's,/+\|/+,/,' + ls -F $*^/./[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/ >[2]/dev/null | sed -n '/'^$forbidden_uri_chars^'/d; s,/\./,/|/,; /\/$/p' | sort -r '-t|' +1 | sed -e 's,/+\|/+,/,' -e $conf_max_posts_per_page^'q' } fn mkbpost { From e197bfb743217c5777bbc5c6f4d3040cd9bea44d Mon Sep 17 00:00:00 2001 From: Uriel Date: Fri, 12 Jun 2009 23:56:48 +0200 Subject: [PATCH 09/15] Optimization/fix to only pass the content of all blog posts at once to $formatter This seems to some how fix a strange bug I have seen on my test setup, need to investigate more. --- apps/blagh/app.rc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/blagh/app.rc b/apps/blagh/app.rc index f652eae..95f4a35 100644 --- a/apps/blagh/app.rc +++ b/apps/blagh/app.rc @@ -68,9 +68,11 @@ fn blagh_body { echo '' + { # XXX Not sure why this fixes issues with blog setup, probably bug in fltr_cache! for(p in `{get_post_list $blagh_root^$blagh_dirs}) { l=`{echo -n $p|sed 's!'$sitedir^'/?(.*)([0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9])(/[^/]+/)!\2 /\1\2\3!'} sed '1s!.*![&]('^$l(2)^') ('^$l(1)^')!' < $p/index.md + } } | $formatter } From a1c0c70f36cf5126aefe30aaa98e3865258650d5 Mon Sep 17 00:00:00 2001 From: Uriel Date: Fri, 12 Jun 2009 23:59:47 +0200 Subject: [PATCH 10/15] Allo to set blagh conf_ options from initrc.local as well. --- apps/blagh/app.rc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/blagh/app.rc b/apps/blagh/app.rc index 95f4a35..18309e8 100644 --- a/apps/blagh/app.rc +++ b/apps/blagh/app.rc @@ -4,9 +4,13 @@ fn conf_enable_blog { 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 } -conf_blog_editors=blog-editors -conf_max_posts_per_page=32 fn blagh_init { if(~ $#blagh_dirs 0 && ~ $req_path */[bB]log/*) { From f01bfb63ec8087f6b325595b140d2945203d339f Mon Sep 17 00:00:00 2001 From: Uriel Date: Sat, 13 Jun 2009 06:28:12 +0200 Subject: [PATCH 11/15] Remove the obsolete feed templates, they were moved to apps/blagh/ a while ago. --- lib/feeds/atom.tpl | 141 -------------------------------------------- lib/feeds/html.tpl | 22 ------- lib/feeds/rss20.tpl | 61 ------------------- 3 files changed, 224 deletions(-) delete mode 100644 lib/feeds/atom.tpl delete mode 100644 lib/feeds/html.tpl delete mode 100644 lib/feeds/rss20.tpl diff --git a/lib/feeds/atom.tpl b/lib/feeds/atom.tpl deleted file mode 100644 index 42add06..0000000 --- a/lib/feeds/atom.tpl +++ /dev/null @@ -1,141 +0,0 @@ -Content-Type: application/atom+xml - - - - -%{ -fn statpost { - f = $1 - - updated = `{/bin/date --rfc-3339'=seconds' -r $f |sed 's/ /T/'} - # XXX $post_uri is broken produces output that includes full file path (eg., /gsoc/www/...) - post_uri=$baseuri^`{cleanname `{echo $f | sed -e 's,^'$sitedir',,' -e 's/\.(md|tpl)$//g'}} - title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' } - # Not used: date=`{/bin/date -Rd `{basename $f |sed 's/(^[0-9\-]*).*/\1/; s/-[0-9]$//'}} - # TODO: use mtime(1) and ls(1) instead of lunix's stat(1) - stat=`{stat -c '%Y %U' $f} - #mdate=`{/bin/date -Rd `{mtime $f|awk '{print $1}' }} # Not used because it is unreliable - by=$stat(2) - ifs=() { summary=`{cat $f | crop_text 512 ... | $formatter } } -} -updated = `{/bin/date --rfc-3339'=seconds' |sed 's/ /T/'} -%} - - - - - %($uri%) - /favicon.ico - - %($siteTitle%) - %($siteSubTitle%) - - - %($updated%) - - -%{ - for(f in `{sortedBlogPostList $blogDirs}) { - statpost $f -%} - - - %($post_uri%) - - %($title%) - - - %($by%) - - - -
- %($summary%) -
- - %($updated%) -
- - -% } - -
- -% exit - - - - http://intertwingly.net/blog/index.atom - ../favicon.ico - - Sam Ruby - It’s just data - - Sam Ruby - rubys@intertwingly.net - /blog/ - - 2008-09-24T12:47:00-04:00 - - - - - tag:intertwingly.net,2004:2899 - - - RubyConf 2008 -
- -

My proposal has been accepted for RubyConf 2008.  Because of the presence of Ruby implementers, this is going to be a bit challenging as it will likely turn into two talks at once.  One sharing experiences with fellow developers concerning things they may need to watch out for, and another with language designers about the impact of their changes.  It also is likely to be true, as it was at OSCON, that there will be members of the audience who know way more about this subject than I do.

-

I had originally requested a slot on Saturday.  My current slot requires me to shave a day off of ApacheCon.  I’ve again asked that the slot be changed, but even if it doesn’t move, I can manage this.  At least we are only talking about a short hop from New Orleans to Orlando.

- -
- 2008-09-11T06:51:36-04:00 -
- - - tag:intertwingly.net,2004:2898 - - - Small Updates -
- -

Alf Eaton: Aside: if you’re reading a Planet that contains HubLog, those posts will all jump to the top - sorry! (I wish Planets dealt better with small updates so I didn’t have to worry about it).

-

I don’t know what publishing software you use, but I see you provide an Atom feed, and Planet 2.0 and Venus both implement atom:updated as specified in RFC 4287.

- -
-
- -

Alf Eaton: Aside: if you’re reading a Planet that contains HubLog, those posts will all jump to the top - sorry! (I wish Planets dealt better with small updates so I didn’t have to worry about it).

-

I don’t know what publishing software you use, but I see you provide an Atom feed, and Planet 2.0 and Venus both implement atom:updated as specified in RFC 4287.

-

More specifically, if you have a minor update and leave the updated date alone, the posts will not jump to the top.  The next release of WordPress, for example, will contain the necessary hooks for a plugin to provide a simple checkbox for indicating that the change constitutes a minor edit.

- -
- 2008-09-10T10:18:47-04:00 -
- - - tag:intertwingly.net,2004:2897 - - - SVG via CSS -
- -

Now that I have my weblog looking reasonably consistent between Gecko and WebKit based browsers, I’ve taken another look at Opera.  Opera doesn’t have support for border-radius, but does have support for background images in SVG, which can be used to provide the same effect.  My Nav Bar on my test site now employs this technique, and it requires two separate images: 039 on CCD and CCD on FFF.

-

Frankly, my first reaction to this was mixed.  The pluses for SVG in CSS is that it doesn’t require either adjusting your markup or JavaScript to achieve these effects, a desirable characteristic that generally the other techniques don’t share.

- -
- -
- -

Now that I have my weblog looking reasonably consistent between Gecko and WebKit based browsers, I’ve taken another look at Opera.  Opera doesn’t have support for border-radius, but does have support for background images in SVG, which can be used to provide the same effect.  My Nav Bar on my test site now employs this technique, and it requires two separate images: 039 on CCD and CCD on FFF.

-

Meanwhile, Robert O’Callahan has been exploring other ways to integrate these technologies.

- -
- 2008-09-07T11:12:29-04:00 -
- -
- diff --git a/lib/feeds/html.tpl b/lib/feeds/html.tpl deleted file mode 100644 index 31ecccc..0000000 --- a/lib/feeds/html.tpl +++ /dev/null @@ -1,22 +0,0 @@ -% if (! ~ $blogTitle '') -% echo '

'$"blogTitle'

' - - - -%{ -for (f in `{ sortedBlogPostList $blogDirs }) { - gen_blog_post_title $f - cat $f - echo ' ' # XXX I have no clue why the ' ' is needed, a echo without args breaks markdown.pl?!? -} | $formatter - -# TODO Should check if user has perms and so on -get_user -if(~ $#logged_user 1) { -%} -
- - -
-% } -
diff --git a/lib/feeds/rss20.tpl b/lib/feeds/rss20.tpl deleted file mode 100644 index 7b0ea74..0000000 --- a/lib/feeds/rss20.tpl +++ /dev/null @@ -1,61 +0,0 @@ -Content-Type: text/xml; charset=utf-8 - - - -%{ -fn statpost { - f = $1 - uri = `{echo $f | sed 's,^'$sitedir',,'} - title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' } - date=`{/bin/date -Rd `{basename $f |sed 's/(^[0-9\-]*).*/\1/; s/-[0-9]$//'}} - # TODO: use mtime(1) and ls(1) instead of lunix's stat(1) - stat=`{stat -c '%Y %U' $f} - #mdate=`{/bin/date -Rd $stat(1)} # Not used because it is unreliable - uri=$baseuri^`{cleanname `{echo -n $uri | sed 's/\.(md|tpl)//g'}} - by=$stat(2) - ifs=() { - summary=`{awk -v max'='1024 '{ - nc += 1 + length; - if(nc > max) { - print substr($0, 1, nc - max) "..." - exit - } - print - }' $f |fmt -j| sed 's/\]\]>/Fucking goddamn XML garbage/g'} - } -} - -%} - - - - - %($siteTitle%) - %($uri%) - %($blogDesc%) - en-us - Tom Duff's rc, and Kris Maglione's clever hackery -%{ - # uriel99+rss@gmail.com (Uriel) - for(f in `{sortedBlogPostList $blogDirs}) { - statpost $f - # Hack to aproximate the last build date - #(use the mdate from last posted item) - # Commented out for now because maybe a wrong value is worse than no value - #if(~ $#last_build_date 0) { - #last_build_date=''^$"mdate'' - #echo $last_build_date - #} -%} - - %($title%) - %($by%)@noreply.cat-v.org (%($by%)) - %($uri%) - %($uri%) - %($date%) - %($summary%)]]> - -% } - - - From b5800c33ef61fee16e5c44e952530096b7241480 Mon Sep 17 00:00:00 2001 From: Uriel Date: Sat, 13 Jun 2009 15:59:43 +0200 Subject: [PATCH 12/15] Strip title from rss/atom 'summary'(ie., body). This used to look really ugly in most feed readers. --- apps/blagh/app.rc | 4 ++++ apps/blagh/atom.tpl | 2 +- apps/blagh/rss20.tpl | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/blagh/app.rc b/apps/blagh/app.rc index 18309e8..0c11985 100644 --- a/apps/blagh/app.rc +++ b/apps/blagh/app.rc @@ -121,3 +121,7 @@ fn mkbpost { } status=$_status } + +fn strip_title_from_md_file { + sed '1N; /^.*\n===*$/N; /.*\n===*\n$/d' +} diff --git a/apps/blagh/atom.tpl b/apps/blagh/atom.tpl index 49ecbe1..8a5a08b 100644 --- a/apps/blagh/atom.tpl +++ b/apps/blagh/atom.tpl @@ -14,7 +14,7 @@ fn statpost { #mdate=`{/bin/date -Rd `{mtime $f|awk '{print $1}' }} # Not used because it is unreliable by=$stat(2) #ifs=() { summary=`{cat $f/index.md | crop_text 1024 ... | $formatter } } - ifs=() { summary=`{cat $f/index.md | ifs=$difs {$formatter} } } + ifs=() { summary=`{cat $f/index.md | strip_title_from_md_file | ifs=$difs {$formatter} } } } updated = `{/bin/date --rfc-3339'=seconds' |sed 's/ /T/'} %} diff --git a/apps/blagh/rss20.tpl b/apps/blagh/rss20.tpl index 141e891..6a1ed58 100644 --- a/apps/blagh/rss20.tpl +++ b/apps/blagh/rss20.tpl @@ -13,7 +13,7 @@ fn statpost { #mdate=`{/bin/date -Rd $stat(1)} # Not used because it is unreliable post_uri=$base_url^`{cleanname `{echo $f | sed -e 's!^'$sitedir'!!'}}^'/' by=$stat(2) - ifs=() {summary=`{ cat $f/index.md | ifs=$difs {$formatter | escape_html} }} + ifs=() {summary=`{ cat $f/index.md |strip_title_from_md_file| ifs=$difs {$formatter | escape_html} }} } %} From 48cbe138334560e4b4d3fece3b8994472d05e92d Mon Sep 17 00:00:00 2001 From: Uriel Date: Sun, 14 Jun 2009 20:21:17 +0200 Subject: [PATCH 13/15] New release From babb2cfe0310b21ce952cd987fb00e1767d015a6 Mon Sep 17 00:00:00 2001 From: Uriel Date: Sun, 14 Jun 2009 20:21:17 +0200 Subject: [PATCH 14/15] Added tag LATEST-RELEASE for changeset d57a4b0d249e From 9a87f888f67ef0166872c18949c897ae594ceb0b Mon Sep 17 00:00:00 2001 From: Uriel Date: Sat, 20 Jun 2009 11:55:26 +0200 Subject: [PATCH 15/15] Fix two typos, thanks echoline! --- apps/bridge/app.rc | 2 +- apps/bridge/foot.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/bridge/app.rc b/apps/bridge/app.rc index a1b4921..7348e59 100644 --- a/apps/bridge/app.rc +++ b/apps/bridge/app.rc @@ -73,7 +73,7 @@ fn mk_new_comment { if not if(check_user $groups_allowed_comments) u=$logged_user if not - _status='You are not a memeber of a group allowed to comment.' + _status='You are not a member of a group allowed to comment.' if(~ $#_status 0) { umask 002 diff --git a/apps/bridge/foot.tpl b/apps/bridge/foot.tpl index 20e6c1c..84d9b81 100644 --- a/apps/bridge/foot.tpl +++ b/apps/bridge/foot.tpl @@ -19,7 +19,7 @@
- Enter your desired user name/password and after your comment has been reviewed by an addmin it will be posted and your account will be enabled. If you are already registered please login before posting. + Enter your desired user name/password and after your comment has been reviewed by an admin it will be posted and your account will be enabled. If you are already registered please login before posting.
% }