bengillies.net

a blog by Ben Gillies

Comments

Extension - *.Comments

Template

{% set comment_root = root_vars['tiddler'] %}
<h2><a name="comments">Comments</a></h2>
<div class="comments">
	<div class="comment_new">
		<form method="POST" action="{{prefix}}/bags/comments/tiddlers?redirect={{prefix}}/recipes/sitecontent/tiddlers/{{comment_root}}#comments">
			<table>
				<tbody>
					<tr>
						<td>name:</td>
						<td><input type="text" name="creator" value="" /><br></td>
					</tr>
					<tr>
						<td valign="top">comment:</td>
						<td><textarea name="text" cols="40" rows="5"></textarea></td>
					</tr>
					<tr>
						<td></td>
						<td><script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6LdDVQkAAAAAABqr4f5rcHyQBTsDlKDk_mXV32nE"></script>
						<noscript>
						   <iframe src="http://api.recaptcha.net/noscript?k=6LdDVQkAAAAAABqr4f5rcHyQBTsDlKDk_mXV32nE" height="300" width="500" frameborder="0"></iframe><br>
						   <textarea name="recaptcha_challenge_field" rows="3" cols="40">
						   </textarea>
						   <input type="hidden" name="recaptcha_response_field" value="manual_challenge">
						</noscript></td>
					</tr>
					<tr>
						<td>
							<input type="hidden" name="root" value="{{comment_root}}" />
							<input type="hidden" name="daddy" value="{{comment_root}}" />
						</td>
						<td><input type="submit" value="Post comment"></td>
					</tr>
				</tbody>
			</table>
		</form>
	</div>
	{% for tiddler in base %}
		<div class="comment">
			<div class="comment_body">
				{{tiddler.text|replace("\n","<br>")}}
			</div>
			{% if 'creator' in tiddler.fields %}
				{% set comment_owner = tiddler.fields['creator'] %}
			{% else %}
				{% set comment_owner = 'Anonymous Coward' %}
			{% endif %}
			<div class="comment_info">by {{comment_owner}}</div>
		</div>
	{% endfor %}
</div>
    

ContentHead

Extension - *.ContentHead

Template

{{extra['Heading']}}
<div class="side_content">
    {{extra['MenuBar']}}
    {% include "Search" %}
</div>
    

ContentIframe

Extension - *.ContentIframe
Sub-Template (name: recipe) - Heading: heading

Template

{{extra['Heading']}}
<div class="main_body">
	<div class="main_body_items">
		{% include "IframeIt" %}
	</div>
</div>
    

ContentList

Extension - *.ContentList
Default Page Title: Ben Gillies - {{ bag }}
Sub-Template (name: recipe) - Heading: heading
Sub-Template (name: recipe) - MenuBar: menu

Template

{% include "ContentHead" %}
<div class="main_body">
	<div class="main_body_items">
		{% include "PagedList" %}
	</div>
</div>
    

ContentSingle

Extension - *.ContentSingle
Default Page Title: Ben Gillies - {{ tiddler }}
Sub-Template (name: recipe) - Heading: heading
Sub-Template (name: recipe) - Comments: comments?sort=modified
Sub-Template (name: recipe) - MenuBar: menu

Template

{% include "ContentHead" %}
<div class="main_body">
	<div class="main_body_items">
		<div class="main_body_item">
			{% if base|count %}
				{% set tiddler = base[0] %}
				{% include "SingleTiddler" %}
				{{extra['Comments']}}
			{% endif %}
		</div>
	</div>
</div>
    

ContentSummary

Extension - *.ContentSummary
Default Page Title: Ben Gillies - {{ recipe }}
Sub-Template (name: recipe) - ExtraSummary: summary
Sub-Template (name: recipe) - Heading: heading
Sub-Template (name: recipe) - MenuBar: menu

Template

{% set shorten_by = 1000 %}
{% include "ContentHead" %}
<div class="main_body">
	<div class="main_body_item">
		{{extra['ExtraSummary']}}
		<div class="item_content">
			<ul>
				{% for tiddler in base %}
					<li class="summaries">
						{% set wikified_text = tiddler.text|wikified('sitecontent') %}
						<a class="summary_list" href="{{prefix}}/recipes/sitecontent/tiddlers/{{tiddler.title}}">{{tiddler.title}}</a></b> - {{wikified_text|shorten(shorten_by)}}<br>
					 	{% if wikified_text|length > shorten_by %}
							...<a href="{{prefix}}/recipes/sitecontent/tiddlers/{{tiddler.title}}">More</a>
						{% endif %}
				    </li>
				{% endfor %}
			</ul>
		</div>
	</div>
</div>
    

Default

Extension - *.Default
Sub-Template (name: recipe) - single_tiddler: ContentSingle
Sub-Template (name: recipe) - list_tiddlers: ContentList

Template

<html>
<head>
        <title>{{title}}</title>
        <link rel="stylesheet" type="text/css" href="/css/main.css" />
        <link rel="openid.server" href="http://openid.bengillies.net" />
        <link rel="openid.delegate" href="http://openid.bengillies.net" />
        <link rel="alternate" href="http://bengillies.net/.a/feed/" type="application/rss+xml" title="RSS" />
</head>
<body>
        <script type="text/javascript" src="/js/rewrite.js"></script>
        <div class="tw_page">
                {{content}}
        </div>
        <script type="text/javascript">
            var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
            document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
        </script>
        <script type="text/javascript">
            try {
                var pageTracker = _gat._getTracker("UA-10836881-1");
                pageTracker._trackPageview();
            } catch(err) {}
        </script>
</body>
</html>
    

ExtraSummary

Extension - *.ExtraSummary
Default Page Title: Ben Gillies - {{ recipe }}

Template

{% set tiddler = tiddler or base[0] %}
<h3 class="item_heading">{{tiddler.title}}</h3>
<div class="item_content">{{tiddler.text|wikified('sitecontent')}}</div>
    

Heading

Extension - *.Heading
Sub-Template (name: recipe) - MenuBar: menu

Template

<div class="heading">
	{% set tiddler = base[0] %}
  	<h1><a href="/">{{tiddler.title}}</a></h1>
  	<h2>{{tiddler.text}}</h2>
</div>
    

IframeIt

Extension - *.IframeIt

Template

{% for tiddler in base %}
	{% for line in tiddler.text.splitlines() %}
		<div class="main_body_item">
		    {% set url, title = line.split('|',1) %}
			<iframe src="{{url}}">Your browser does not support iFrames</iframe>
		</div>
	{% endfor %}
{% endfor %}
    

MenuBar

Extension - *.MenuBar

Template

<div class="menu_bar">
    <ul class="menu_bar_list">
	{% for tiddler in base %}
		{% for line in tiddler.text.splitlines() %}
		    {% set url, title = line.split('|',1) %}
			<li class="menu_bar_list_item"><a href="{{prefix}}{{url}}">{{title}}</a></li>
		{% endfor %}
	{% endfor %}
	</ul>
</div>
    

PagedList

Extension - *.PagedList

Template

{% macro join_queries(queries) %}
	{% for query_el in queries %}
		{{query_el}}={{queries[query_el]}}&
	{% endfor %}
{% endmacro %}
{% if 'limit' in query %}
	{% set page_info = query.pop('limit').split(',') %}
	{% if page_info|length == 2 %}
		{% set index, count = (page_info[0]|int, page_info[1]|int) %}
	{% else %}
		{% set index, count = (-1, page_info[0]|int) %}
	{% endif %}
	{% set default_count = count-1 %}
{% else %}
	{% set index, default_count = (-1, 3) %}
{% endif %}
{% set base_count = base|count %}
{% for tiddler in base %}
	{% if base.index(tiddler) < base_count - 1 or base_count <= default_count or (index == -1 and base_count > default_count + 1) %}
		<div class="main_body_item">
			{% include "SingleTiddler" %}
		</div>
	{% endif %}
{% endfor %}
<div class="pagination">
	{% if index >= 0 %}
		{% if index == 0 %}
			<span class="page_prev">previous</span>
		{% elif index <= 0 + (count-1) %}
			<span class="page_prev"><a href="?{{join_queries(query)}}limit=0,{{count}}">previous</a></span>
		{% else %}
			<span class="page_prev"><a href="?{{join_queries(query)}}limit={{index-(count-1)}},{{count}}">previous</a></span>
		{% endif %}
		{% if base|length < count %}
			<span class="page_next">next</span>
		{% else %}
			<span class="page_next"><a href="?{{join_queries(query)}}limit={{index+(count-1)}},{{count}}">next</a></span>
		{% endif %}
	{% endif %} 
	{% if index == -1 and base_count == default_count + 1 %}
		<span class="page_prev">previous</span>
		<span class="page_next"><a href="?{{join_queries(query)}}limit={{default_count}},{{default_count+1}}">next</a></span>
	{% endif %}
</div>
    

Search

Extension - *.Search
Default Page Title: Search

Template

<div class="search_box">
    <form action="{{prefix}}/search" method="GET">
        <input type="text" name="q" value="Search..." onblur="this.value=(this.value=='') ? 'Search...' : this.value;" onfocus="this.value=(this.value=='Search...') ? '' : this.value;"/>
    </form>
</div>
    

SingleTiddler

Extension - *.SingleTiddler

Template

{% macro tag_list(tags) %}
	{% for tag in tags %}
		<a href="{{prefix}}/recipes/sitecontent/tiddlers?select=tag:{{tag}}">{{tag}}</a> 
	{% endfor %}
{% endmacro %}
{% set tiddler = tiddler or base[0] %}
{% if tiddler.bag == 'templates' %}
    {% include "SingleTemplate" %}
{% elif tiddler.bag == 'urls' %}
    {% include "SingleURL" %}
{% else %}
    {% if tiddler.type and 'image/' in tiddler.type %}
            <h3 class="item_heading"><a href="{{prefix}}/bags/{{tiddler.bag}}/tiddlers/{{tiddler.title}}">{{tiddler.title}}</a></h3>
    		<div class="item_content"><img src="{{prefix}}/bags/{{tiddler.bag}}/tiddlers/{{tiddler.title}}" /></div>
    {% else %}
            <h3 class="item_heading"><a href="{{prefix}}/recipes/sitecontent/tiddlers/{{tiddler.title}}">{{tiddler.title}}</a></h3>
    		<div class="item_content">{{tiddler.text|wikified('sitecontent')}}</div>
    		<div class="item_extra">
    			<div class="comments_link"><a href="{{prefix}}/recipes/sitecontent/tiddlers/{{tiddler.title}}#comments">Comments</a></div>
    			<div class="tags">tags: {{tag_list(tiddler.tags)}}</div>
    		</div>
    {% endif %}
{% endif %}
    

SingleTemplate

Extension - *.SingleTemplate

Template

{% set reserved_fields = {'page_title': 'Default Page Title', 'mime_type': 'Default MIME Type'} %}
{% set tiddler = tiddler or base[0] %}
<h3 class="item_heading"><a href="{{prefix}}/bags/templates/tiddlers/{{tiddler.title}}.txt">{{tiddler.title}}</a></h3>
<div class="item_content">
    <div class="twp_field"><b>Extension</b> - *.{{tiddler.title}}</div>
    {% for reserved_id, reserved_title in reserved_fields.iteritems() %}
        {% if reserved_id in tiddler.fields %}
            <div class="twp_field"><b>{{reserved_title}}</b>: {{tiddler.fields[reserved_id]}}</div>
        {% endif %}
    {% endfor %}
    <div class="twp_sub_template">
        {% for sub_template, recipe in tiddler.fields.iteritems() %}
            {% if sub_template not in reserved_fields %}
                <div class="twp_field">
                    <b>Sub-Template</b> <i>(name: recipe)</i> - {{sub_template}}: {{recipe}}
                </div>
            {% endif %}
        {% endfor %}
    </div>
    <h2>Template</h2><pre class="twp_code_block">
{{tiddler.text|e}}
    </pre>
</div>
    

SingleURL

Extension - *.SingleURL

Template

{% set tiddler = tiddler or base[0] %}
<h3 class="item_heading"><a href="{{prefix}}/bags/urls/tiddlers/{{tiddler.title}}.txt">{{tiddler.title}}</a></h3>
<div class="item_content">
    <div class="twp_field"><b>Page Title</b> - {{tiddler.title}}</div>
    <div class="twp_field"><b>Recipe</b> - {{tiddler.fields['recipe_name']}}</div>
    <div class="twp_field"><b>Template</b> - {{tiddler.fields['template']}}</div>
    <h2>URL</h2>
    Please Note that URLs are stored in pattern format. Anything enclosed by {braces} represents a pattern that can be replaced by meaningful text. Anything enclosed by [square brackets] is optional.
    <pre class="twp_code_block" >  
{{tiddler.text}}
    </pre>
</div>