Permalink
Browse files

Add latest_news_item() template function.

  • Loading branch information...
1 parent 6d71ada commit 72fe4e751f22df4acb0752d722bb123ee85b7874 @cpressey cpressey committed Mar 24, 2013
Showing with 30 additions and 2 deletions.
  1. +10 −0 data/exhibits.yaml
  2. +2 −0 data/news.yaml
  3. +12 −0 src/chrysoberyl/renderer.py
  4. +5 −1 src/chrysoberyl/transformer.py
  5. +1 −1 templates/Chrysoberyl.html
View
@@ -23,6 +23,16 @@
only two kilobytes of code! These days you can't even sneeze in less
than a megabyte.
+'Super Wumpus Land (HTML5)':
+ type: Online Installation
+ exhibit: Digital Art Exhibit
+ interactive: true
+ animated: true
+ medium: HTML5
+ description: |
+ [[Super Wumpus Land]] playable online in an HTML5 canvas simulating a
+ text terminal.
+
### Esolangs ###
'yoob (Applet)':
View
@@ -4,6 +4,8 @@
authors:
- Chris Pressey
publication-date: Wed, 20 Mar 2013 14:59:21 GMT
+ blurb: |
+ Oops, I just turned [[Chrysoberyl]] into a blogging platform.
description: |
I'm not much of a blogger. I've considered starting a blog a few times,
but the thing is, most blogs are either about trends or opinions
@@ -376,6 +376,18 @@ def articles():
key=lambda x: self.data[x]['publication-date']))
@expose
+ def latest_news_item():
+ latest = None
+ latest_date = None
+ for thing in self.data:
+ node = self.data[thing]
+ if node['type'] == 'Article':
+ if latest_date is None or node['publication-date'] > latest_date:
+ latest_date = node['publication-date']
+ latest = node
+ return latest
+
+ @expose
def strftime(date, fmt):
return date.strftime(fmt)
@@ -73,8 +73,12 @@ def convert_chrysoberyl_data(data):
for field in node.keys():
new_fields[field.replace('-', '_')] = node[field]
node.update(new_fields)
- for field in ('summary', 'description', 'commentary'):
+ for field in ('summary', 'description', 'commentary', 'blurb'):
node[field + '_html'] = markdown_field(data, node, field)
+ if node['blurb_html'] is not None:
+ match = re.match(r'^\s*\<p\>(.*?)\<\/p\>\s*$', node['blurb_html'])
+ if match:
+ node['blurb_html'] = match.group(1)
for sample_key in ('sample', 'sample_input', 'sample_output'):
if sample_key in node:
sample_md = '\n'.join(
@@ -21,7 +21,7 @@
<h2>Metanodes</h2>
<ul>
{%- for thing in data.keys()|sort -%}
- {%- if data[thing].type == 'Metanode' -%}
+ {%- if data[thing].type == 'Metanode' and not data[thing].hidden -%}
<li>
{{ link(thing) }}
</li>

0 comments on commit 72fe4e7

Please sign in to comment.