Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add latest_news_item() template function.

  • Loading branch information...
commit 72fe4e751f22df4acb0752d722bb123ee85b7874 1 parent 6d71ada
catseye authored
10 data/exhibits.yaml
@@ -23,6 +23,16 @@
23 23 only two kilobytes of code! These days you can't even sneeze in less
24 24 than a megabyte.
25 25
  26 +'Super Wumpus Land (HTML5)':
  27 + type: Online Installation
  28 + exhibit: Digital Art Exhibit
  29 + interactive: true
  30 + animated: true
  31 + medium: HTML5
  32 + description: |
  33 + [[Super Wumpus Land]] playable online in an HTML5 canvas simulating a
  34 + text terminal.
  35 +
26 36 ### Esolangs ###
27 37
28 38 'yoob (Applet)':
2  data/news.yaml
@@ -4,6 +4,8 @@
4 4 authors:
5 5 - Chris Pressey
6 6 publication-date: Wed, 20 Mar 2013 14:59:21 GMT
  7 + blurb: |
  8 + Oops, I just turned [[Chrysoberyl]] into a blogging platform.
7 9 description: |
8 10 I'm not much of a blogger. I've considered starting a blog a few times,
9 11 but the thing is, most blogs are either about trends or opinions
12 src/chrysoberyl/renderer.py
@@ -376,6 +376,18 @@ def articles():
376 376 key=lambda x: self.data[x]['publication-date']))
377 377
378 378 @expose
  379 + def latest_news_item():
  380 + latest = None
  381 + latest_date = None
  382 + for thing in self.data:
  383 + node = self.data[thing]
  384 + if node['type'] == 'Article':
  385 + if latest_date is None or node['publication-date'] > latest_date:
  386 + latest_date = node['publication-date']
  387 + latest = node
  388 + return latest
  389 +
  390 + @expose
379 391 def strftime(date, fmt):
380 392 return date.strftime(fmt)
381 393
6 src/chrysoberyl/transformer.py
@@ -73,8 +73,12 @@ def convert_chrysoberyl_data(data):
73 73 for field in node.keys():
74 74 new_fields[field.replace('-', '_')] = node[field]
75 75 node.update(new_fields)
76   - for field in ('summary', 'description', 'commentary'):
  76 + for field in ('summary', 'description', 'commentary', 'blurb'):
77 77 node[field + '_html'] = markdown_field(data, node, field)
  78 + if node['blurb_html'] is not None:
  79 + match = re.match(r'^\s*\<p\>(.*?)\<\/p\>\s*$', node['blurb_html'])
  80 + if match:
  81 + node['blurb_html'] = match.group(1)
78 82 for sample_key in ('sample', 'sample_input', 'sample_output'):
79 83 if sample_key in node:
80 84 sample_md = '\n'.join(
2  templates/Chrysoberyl.html
@@ -21,7 +21,7 @@
21 21 <h2>Metanodes</h2>
22 22 <ul>
23 23 {%- for thing in data.keys()|sort -%}
24   - {%- if data[thing].type == 'Metanode' -%}
  24 + {%- if data[thing].type == 'Metanode' and not data[thing].hidden -%}
25 25 <li>
26 26 {{ link(thing) }}
27 27 </li>

0 comments on commit 72fe4e7

Please sign in to comment.
Something went wrong with that request. Please try again.