Unstyled example content.

This commit is contained in:
Andrey Petrov
2013-08-01 22:21:47 -07:00
parent 36f6b44063
commit 2f77206586
7 changed files with 90 additions and 17 deletions
+6 -4
View File
@@ -24,14 +24,16 @@ endif
## Composer
index.json: indexer.py templates/
content: templates/
index.json: indexer.py content
python indexer.py > index.json
build: index.json
composer build index.json
build: requirements index.json
composer build indexer:UntaritIndex
serve: requirements index.json
composer serve indexer:UntaritIndexer
composer serve indexer:UntaritIndex
deploy: build
s3cmd sync build/ s3://untar.it/
+8 -6
View File
@@ -2,9 +2,7 @@
"routes": [
{
"url": "/",
"context": {
"title": "Hello"
},
"context": {},
"filters": [
"mako"
],
@@ -13,7 +11,7 @@
{
"url": "/tar.gz/",
"context": {
"title": "Hello"
"filetype": "tar.gz"
},
"filters": [
"filetype"
@@ -23,7 +21,7 @@
{
"url": "/tar.bz2/",
"context": {
"title": "Hello"
"filetype": "tar.bz2"
},
"filters": [
"filetype"
@@ -40,7 +38,11 @@
"filters": {
"mako": {
"class": "composer.filters:Mako",
"kwargs": {}
"kwargs": {
"directories": [
"templates"
]
}
},
"filetype": {
"class": "composer.filters:MakoContainer",
+13 -6
View File
@@ -1,25 +1,32 @@
#!/usr/bin/env python
from composer.index import Index, Route, Static
from composer.filters import MakoContainer
from composer.filters import Mako, MakoContainer
class UntaritIndex(Index):
def _register_filters(self):
self.register_filter('mako', Mako, {'directories': ['templates']})
self.register_filter('filetype', MakoContainer, {'directories': ['templates'], 'template': 'filetype.mako'})
def _generate_static(self):
yield Static('/static', 'static')
def _generate_routes(self):
context = {'title': 'Hello'}
yield Route('/', 'templates/index.mako', filters=['mako'], context=context)
# TODO: Pull this from a yaml file or something
for filetype in ['tar.gz', 'tar.bz2']:
known_types = ['tar.gz', 'tar.bz2']
yield Route('/', 'templates/index.mako', filters=['mako'], context={
'known_types': known_types,
})
for filetype in known_types:
url = self.absolute_url(filetype + '/')
context = {
'filetype': filetype,
'known_types': known_types,
}
yield Route(url, 'templates/filetype.mako', filters=['filetype'], context=context)
+1
View File
@@ -3,3 +3,4 @@ mako
markdown
mdx_smartypants
PyYaml
werkzeug
+41
View File
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><%block name="title">Untar.it</%block></title>
<link href="/static/css/base.css" media="screen" rel="stylesheet" type="text/css" />
<link rel="icon" type="image/png" href="/static/images/icon.png" />
<%block name="extra_head" />
</head>
<body>
${next.body()}
<footer>
Created by
<a href="http://kennethreitz.org">kennethreitz</a> and
<a href="http://shazow.net/">shazow</a>.
</footer>
<script type="text/javascript">
var _gaq = _gaq || [];
// TODO:
// _gaq.push(['_setAccount', 'XXX']);
// _gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<%block name="tail">
</%block>
</body>
</html>
+8
View File
@@ -0,0 +1,8 @@
<%inherit file="base.mako" />
<%block name="title">How to untar a .${route.context['filetype']} file</%block>
<h1>${route.context['filetype']}</h1>
<p>
Filetype-specific content goes here.
</p>
+13 -1
View File
@@ -1 +1,13 @@
foo
<%inherit file="base.mako" />
<h1>Untar.it</h1>
<p>
What kind of file do you need to open?
</p>
<ul>
% for filetype in route.context['known_types']:
<li><a href="/${filetype}/">${filetype}</a></li>
% endfor
</ul>