1. Cat's Eye Technologies
  2. Chrysoberyl

Commits

catseye  committed 3e0808c

A terrible news page, but one that will serve as a news page.

  • Participants
  • Parent commits a5cd64e
  • Branches default

Comments (0)

Files changed (4)

File TODO.markdown

View file
  • Ignore whitespace
 higher priority
 ---------------
 
-News template, with news items inline, sorted by date, and
-with anchors, that the links in the feed match up with.
-
-News page: same as the News Item index, but sorted by date.
-
-Render images.  (LED-386, Mildred, games...)
+Some replacement for project page.  (Featured?)
 
 Render documentation to a separate directory and link to it.
 
-Some replacement for project page.  (Featured?)
-
-For (in theory) any item, show all lists that it is present in.
+As part of that: put images inline.  (LED-386, Mildred, games...)
 
 styling
 -------
 
 `in-distributions`, a list.
 
+For (in theory) any item, show all lists that it is present in.
+
 templates
 ---------
 

File data/metanodes.yaml

View file
  • Ignore whitespace
   description: |
     This page allows you to perform an advanced query on the contents
     of [[Chrysoberyl]].  (Well, not all that advanced yet, but it has potential.)
+News:
+  type: Metanode
+  description: |
+    The latest news from [[Cat's Eye Technologies]].
+Project Matrix:
+  type: Metanode
+  description: |
+    A bunch of projects that [[Cat's Eye Technologies]] has worked on.

File src/chrysoberyl/renderer.py

View file
  • Ignore whitespace
                     languages.append(thing)
             return sorted(languages, key=lambda x: self.data[x]['inception-date'])
 
+        def news_items():
+            """Bespoke function, because we want to sort them by news-date"""
+            items = []
+            for thing in self.data:
+                node = self.data[thing]
+                if node['type'] == 'News Item':
+                    items.append(thing)
+            return reversed(sorted(items, key=lambda x: self.data[x]['news-date']))
+
         # functions
         context['filekey'] = filekey
         context['related'] = related
         context['link_lower'] = link_lower
         context['linked_list'] = linked_list
         context['lingography'] = lingography
+        context['news_items'] = news_items
 
         template = self.get_template(key)
         filename = os.path.join(self.output_dir, filekey(key))

File templates/News.html

View file
  • Ignore whitespace
+{% extends "base.html" %}
+
+{% block heading %}
+  <hgroup id="heading">
+    <h1>News</h1>
+  </hgroup>
+{% endblock %}
+
+{% block content %}
+
+<ul>
+{%- for thing in news_items() -%}
+  <li>
+      {{ data[thing].news_date }}: <a href="{{ filekey(thing) }}">{{ thing }}</a>
+  </li>
+{%- endfor -%}
+</ul>
+
+{% endblock content %}