changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > werc / changeset: Move form templates to where they blong.

changeset 368: 48fe4da79385
parent 367: f5ec36e93858
child 369: b1112b957e36
author: uriel@engel.se.cat-v.org
date: Mon, 26 Jan 2009 04:10:02 +0100
files: lib/_apps/blagh/atom.tpl lib/_apps/blagh/rss20.tpl lib/_apps/brag/post_form.tpl lib/_apps/dirdir/edit.tpl
description: Move form templates to where they blong.
     1.1--- a/lib/_apps/blagh/atom.tpl	Mon Jan 26 04:09:23 2009 +0100
     1.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3@@ -1,140 +0,0 @@
     1.4-Content-Type: application/atom+xml
     1.5-
     1.6-<?xml version="1.0" encoding="utf-8"?>
     1.7-
     1.8-<!-- TODO: See for more info:http://www.tbray.org/ongoing/When/200x/2005/07/27/Atomic-RSS  -->
     1.9-%{
    1.10-fn statpost {
    1.11-    f = $1
    1.12-
    1.13-    updated = `{/bin/date --rfc-3339'=seconds' -r $f |tr ' ' 'T'} 
    1.14-    post_uri=$base_url^`{cleanname `{echo $f | sed -e 's!^'$sitedir'!!' -e 's/\.(md|tpl)$//g'}}
    1.15-    title=`{read $f/index.md}
    1.16-    # Not used: date=`{/bin/date -Rd `{basename $f |sed 's/(^[0-9\-]*).*/\1/; s/-[0-9]$//'}}
    1.17-    # TODO: use mtime(1) and ls(1) instead of lunix's stat(1)
    1.18-    stat=`{stat -c '%Y %U' $f}
    1.19-    #mdate=`{/bin/date -Rd `{mtime $f|awk '{print $1}' }} # Not used because it is unreliable
    1.20-    by=$stat(2)
    1.21-    ifs=() { summary=`{cat $f/index.md | crop_text 512 ... | $formatter } }
    1.22-}
    1.23-updated = `{/bin/date --rfc-3339'=seconds' |sed 's/ /T/'} 
    1.24-%}
    1.25-
    1.26-<feed xmlns="http://www.w3.org/2005/Atom"
    1.27-    xmlns:thr="http://purl.org/syndication/thread/1.0">
    1.28-
    1.29-    <link rel="self" href="%($req_path%)"/>
    1.30-    <id>%($req_path%)</id>
    1.31-    <icon>/favicon.ico</icon>
    1.32-
    1.33-    <title>%($siteTitle%)</title>
    1.34-    <subtitle>%($siteSubTitle%)</subtitle>
    1.35-
    1.36-    <!-- <updated>2008-09-24T12:47:00-04:00</updated> -->
    1.37-    <updated>%($updated%)</updated>
    1.38-    <link href="."/>
    1.39-
    1.40-%{
    1.41-        for(f in `{get_post_list $blagh_root$blagh_dirs}) {
    1.42-            statpost $f
    1.43-%}
    1.44-    <entry>
    1.45-        <!-- Maybe we should be smarter, see: http://diveintomark.org/archives/2004/05/28/howto-atom-id, example: <id>tag:intertwingly.net,2004:2899</id>  -->
    1.46-        <id>%($post_uri%)</id>
    1.47-        <link href="%($post_uri%)"/>
    1.48-        <title>%($title%)</title>
    1.49-        <!-- <link rel="replies" href="2899.atom" thr:count="0"/> -->
    1.50-        <author>
    1.51-            <name>%($by%)</name>
    1.52-        </author>
    1.53-
    1.54-
    1.55-        <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    1.56-            %($summary%)
    1.57-        </div></content>
    1.58-
    1.59-        <updated>%($updated%)</updated>
    1.60-    </entry>
    1.61-
    1.62-
    1.63-%        }
    1.64-
    1.65-</feed>
    1.66-
    1.67-% exit 
    1.68-
    1.69-<feed xmlns="http://www.w3.org/2005/Atom"
    1.70-  xmlns:thr="http://purl.org/syndication/thread/1.0">
    1.71-  <link rel="self" href="http://intertwingly.net/blog/index.atom"/>
    1.72-  <id>http://intertwingly.net/blog/index.atom</id>
    1.73-  <icon>../favicon.ico</icon>
    1.74-
    1.75-  <title>Sam Ruby</title>
    1.76-  <subtitle>It’s just data</subtitle>
    1.77-  <author>
    1.78-    <name>Sam Ruby</name>
    1.79-    <email>rubys@intertwingly.net</email>
    1.80-    <uri>/blog/</uri>
    1.81-  </author>
    1.82-  <updated>2008-09-24T12:47:00-04:00</updated>
    1.83-  <link href="/blog/"/>
    1.84-  <link rel="license" href="http://creativecommons.org/licenses/BSD/"/>
    1.85-
    1.86-  <entry>
    1.87-    <id>tag:intertwingly.net,2004:2899</id>
    1.88-    <link href="/blog/2008/09/11/RubyConf-2008"/>
    1.89-    <link rel="replies" href="2899.atom" thr:count="0"/>
    1.90-    <title>RubyConf 2008</title>
    1.91-    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    1.92-    
    1.93-<p>My <a href="http://www.rubyconf.org/talks/14">proposal</a> has been accepted for <a href="http://www.rubyconf.org/talks">RubyConf 2008</a>.  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 <a href="http://intertwingly.net/blog/2008/07/24/Ruby-1-9-What-to-Expect">OSCON</a>, that there will be members of the audience who know way more about this subject than I do.</p>
    1.94-<p>I had originally requested a slot on Saturday.  My current slot requires me to shave a day off of <a href="http://us.apachecon.com/c/acus2008/">ApacheCon</a>.  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.</p>
    1.95-
    1.96-    </div></content>
    1.97-    <updated>2008-09-11T06:51:36-04:00</updated>
    1.98-  </entry>
    1.99-
   1.100-  <entry>
   1.101-    <id>tag:intertwingly.net,2004:2898</id>
   1.102-    <link href="/blog/2008/09/10/Small-Updates"/>
   1.103-    <link rel="replies" href="2898.atom" thr:count="8" thr:updated="2008-09-10T15:31:05-04:00"/>
   1.104-    <title>Small Updates</title>
   1.105-    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
   1.106-    
   1.107-    <p><a href="http://hublog.hubmed.org/archives/001744.html">Alf Eaton</a>: <em>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).</em></p>
   1.108-<p>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 <a href="http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.updated">atom:updated</a> as specified in RFC 4287.</p>
   1.109-
   1.110-    </div></summary>
   1.111-    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
   1.112-
   1.113-<p><a href="http://hublog.hubmed.org/archives/001744.html"><cite>Alf Eaton</cite></a>: <em>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).</em></p>
   1.114-<p>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 <a href="http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.updated">atom:updated</a> as specified in RFC 4287.</p>
   1.115-<p>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 <a href="http://blog.ciarang.com/posts/wp-minor-edit/">plugin</a> to provide a simple checkbox for indicating that the change constitutes a minor edit.</p>
   1.116-
   1.117-    </div></content>
   1.118-    <updated>2008-09-10T10:18:47-04:00</updated>
   1.119-  </entry>
   1.120-
   1.121-  <entry>
   1.122-    <id>tag:intertwingly.net,2004:2897</id>
   1.123-    <link href="/blog/2008/09/07/SVG-via-CSS"/>
   1.124-    <link rel="replies" href="2897.atom" thr:count="10" thr:updated="2008-09-12T02:21:21-04:00"/>
   1.125-    <title>SVG via CSS</title>
   1.126-    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
   1.127-    
   1.128-    <p>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 <a href="http://dev.opera.com/articles/view/new-development-techniques-using-opera-k/">used to provide the same effect</a>.  My Nav Bar on <a href="http://rails.intertwingly.net/blog/">my test site</a> now employs this technique, and it requires two separate images: <a href="http://rails.intertwingly.net/stylesheets/rc-039-CCD.svg">039 on CCD</a> and <a href="http://rails.intertwingly.net/stylesheets/rc-CCD-FFF.svg">CCD on FFF</a>.</p>
   1.129-<p>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 <a href="http://www.cssjuice.com/25-rounded-corners-techniques-with-css/">other techniques</a> don’t share.</p>
   1.130-
   1.131-    </div></summary>
   1.132-
   1.133-    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
   1.134-    
   1.135-<p>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 <a href="http://dev.opera.com/articles/view/new-development-techniques-using-opera-k/">used to provide the same effect</a>.  My Nav Bar on <a href="http://rails.intertwingly.net/blog/">my test site</a> now employs this technique, and it requires two separate images: <a href="http://rails.intertwingly.net/stylesheets/rc-039-CCD.svg">039 on CCD</a> and <a href="http://rails.intertwingly.net/stylesheets/rc-CCD-FFF.svg">CCD on FFF</a>.</p>
   1.136-<p>Meanwhile, Robert O’Callahan has been exploring <a href="http://weblogs.mozillazine.org/roc/archives/2008/06/applying_svg_ef.html">other ways</a> to integrate these technologies.</p>
   1.137-
   1.138-    </div></content>
   1.139-    <updated>2008-09-07T11:12:29-04:00</updated>
   1.140-  </entry>
   1.141-
   1.142-</feed>
   1.143-
     2.1--- a/lib/_apps/blagh/rss20.tpl	Mon Jan 26 04:09:23 2009 +0100
     2.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3@@ -1,62 +0,0 @@
     2.4-Content-Type: text/xml; charset=utf-8
     2.5-
     2.6-<?xml version="1.0" encoding="UTF-8"?>
     2.7-
     2.8-%{
     2.9-fn statpost {
    2.10-	f = $1
    2.11-
    2.12-	post_uri = `{echo $f | sed 's,^'$sitedir',,'}
    2.13-	title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' }
    2.14-	date=`{/bin/date -Rd `{echo $f|sed 's,.*/([0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9])/.*,\1,'}}
    2.15-	# TODO: use mtime(1) and ls(1) instead of lunix's stat(1)
    2.16-	stat=`{stat -c '%Y %U' $f}
    2.17-	#mdate=`{/bin/date -Rd $stat(1)} # Not used because it is unreliable
    2.18-	post_uri=$base_url^`{cleanname `{echo -n $post_uri | sed 's/\.(md|tpl)//g'}}
    2.19-	by=$stat(2)
    2.20-	ifs=() {
    2.21-		summary=`{awk -v max'='1024 '{
    2.22-			nc += 1 + length;
    2.23-			if(nc > max) {
    2.24-				print substr($0, 1, nc - max) "..."
    2.25-				exit
    2.26-			}
    2.27-			print
    2.28-		}' $f/index.md |fmt -j| sed 's/\]\]>/Fucking goddamn XML garbage/g'}
    2.29-	}
    2.30-}
    2.31-
    2.32-%}
    2.33-
    2.34-<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    2.35-	<channel>
    2.36-		<atom:link href="%('http://'$site^$req_path%)" rel="self" type="application/rss+xml" />
    2.37-		<title>%($siteTitle%)</title>
    2.38-		<link>%($req_path%)</link>
    2.39-		<description>%($blogDesc%)</description>
    2.40-		<language>en-us</language>
    2.41-		<generator>Tom Duff's rc, and Kris Maglione's clever hackery</generator>
    2.42-%{
    2.43-		# <webMaster>uriel99+rss@gmail.com (Uriel)</webMaster>
    2.44-        for(f in `{get_post_list $blagh_root$blagh_dirs}) {
    2.45-			statpost $f
    2.46-			# Hack to aproximate the last build date 
    2.47-			#(use the mdate from last posted item)
    2.48-			# Commented out for now because maybe a wrong value is worse than no value
    2.49-			#if(~ $#last_build_date 0) {
    2.50-				#last_build_date='<lastBuildDate>'^$"mdate'</lastBuildDate>'
    2.51-				#echo $last_build_date
    2.52-			#}
    2.53-%}
    2.54-		<item>
    2.55-			<title>%($title%)</title>
    2.56-			<author>%($by%)@noreply.cat-v.org (%($by%))</author>
    2.57-			<link>%($uri%)</link>
    2.58-                        <guid isPermaLink="true">%($uri%)</guid>
    2.59-			<pubDate>%($date%)</pubDate>
    2.60-			<description><![CDATA[<pre>%($summary%)</pre>]]></description>
    2.61-		</item>
    2.62-%		}
    2.63-
    2.64-	</channel>
    2.65-</rss>
     3.1--- a/lib/_apps/brag/post_form.tpl	Mon Jan 26 04:09:23 2009 +0100
     3.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3@@ -1,26 +0,0 @@
     3.4-%{
     3.5-get_post_args target_blog_dir post_title post_body
     3.6-
     3.7-if(~ $REQUEST_METHOD POST && ! ~ $#target_blog_dir 0 && ! ~ $#post_title 0) {
     3.8-
     3.9-    # XXX Need a generic way to load the complete config hierarchy for a given path
    3.10-    if(test -f $sitedir/$target_blog_dir/_werc/config)
    3.11-        . $sitedir/$target_blog_dir/_werc/config
    3.12-
    3.13-    if(~ $#blog_editors_group 0)
    3.14-        echo Cant post to $target_blog_dir, no editors group set.
    3.15-    if not if(! check_user $blog_editors_group)
    3.16-        echo Post to $target_blog_dir denied, user $logged_user not in group $blog_editors_group
    3.17-    if not if(! make_blog_post $target_blog_dir $post_title $post_body)
    3.18-        echo Posting to $target_blog_dir failed: $status
    3.19-    if not
    3.20-        echo Posted to $target_blog_dir.
    3.21-}
    3.22-%}
    3.23-<form method="POST">
    3.24-    Submit a new blog post
    3.25-    Post title: <input type="text" name="post_title" /><br />
    3.26-    <textarea name="post_body"></textarea><br />
    3.27-    <input type="text" name="target_blog_dir" value="%($target_blog_dir%)" /><br />
    3.28-    <input type="submit" value="Post" />
    3.29-</form>
     4.1--- a/lib/_apps/dirdir/edit.tpl	Mon Jan 26 04:09:23 2009 +0100
     4.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3@@ -1,56 +0,0 @@
     4.4-%{
     4.5-# XXX This should be moved to apps/dirdir/, and we should bail out if not called from a dir with $enable_wiki set.
     4.6-
     4.7-get_post_args edit_wiki_page edit_text edit_preview edit_save
     4.8-
     4.9-# XXX SECURITY HOLE! should sanitize form input and make sure we only edit files we are allowed
    4.10-# This is a start, but should be way more careful
    4.11-edit_file = `{echo $sitedir/$edit_wiki_page.md|sed 's/\.\.*/./g'}
    4.12-
    4.13-if (~ $"edit_save '') {
    4.14-%}
    4.15-<div>
    4.16-    <h1>Editing %($edit_wiki_page%)</h1>
    4.17-    <br />
    4.18-    <form action="/_apps/dirdir/edit" method="post">
    4.19-        <input type="hidden" name="edit_wiki_page" value="%($edit_wiki_page%)"
    4.20-        <textarea name="edit_text" id="edit_text" cols="80" rows="43">%{
    4.21-
    4.22-if(~ $#edit_text 0 && test -f $edit_file)
    4.23-    cat $edit_file | escape_html
    4.24-if not
    4.25-    echo $edit_text | escape_html
    4.26-
    4.27-        %}</textarea>
    4.28-        <br />
    4.29-        <input type="submit" name="edit_save" value="Save"/>
    4.30-        <input type="submit" name="edit_preview" value="Preview" />
    4.31-        <small>DirDir documents are written using <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a>.</small>
    4.32-    </form>
    4.33-</div>
    4.34-% }
    4.35-
    4.36-% if(! ~ $"edit_preview '') {
    4.37-            <H2>Preview:</H2>
    4.38-            <div id="preview">
    4.39-%               echo $edit_text | $formatter
    4.40-            </div>
    4.41-            <hr /><hr />
    4.42-% }
    4.43-% if not if(! ~ $"edit_save '') {
    4.44-%{
    4.45-    dirdir_dir = $edit_file^'_werc/dirdir/'
    4.46-
    4.47-    if(! test -d  $dirdir_dir)
    4.48-        mkdir -p $dirdir_dir
    4.49-
    4.50-    dirdir_verdir = $dirdir_dir/`{date -n}^/
    4.51-    mkdir $dirdir_verdir
    4.52-
    4.53-    echo $loggin_user > $dirdir_verdir/author
    4.54-    echo $edit_text > $dirdir_verdir/data 
    4.55-    echo $edit_text > $edit_file
    4.56-%}
    4.57-<h1>Saved <a href="%($edit_wiki_page%)">%($edit_wiki_page%)!</a></h1>
    4.58-% }
    4.59-