Allow specifying an editor as well as/instead of an author
authorAlex Chan <alex@alexwlchan.net>
Fri, 5 Mar 2021 09:12:34 +0000 (09:12 +0000)
committerAlex Chan <alex@alexwlchan.net>
Fri, 5 Mar 2021 09:12:34 +0000 (09:12 +0000)
scripts/render_html.py
templates/_review_entry.html
templates/review.html

index c5f96da..048a7fc 100755 (executable)
@@ -70,8 +70,11 @@ def set_git_timestamps():
 class Book:
     slug = attr.ib()
     title = attr.ib()
 class Book:
     slug = attr.ib()
     title = attr.ib()
-    author = attr.ib()
     publication_year = attr.ib()
     publication_year = attr.ib()
+
+    author = attr.ib(default="")
+    editor = attr.ib(default="")
+
     cover_image = attr.ib(default="")
     cover_desc = attr.ib(default="")
 
     cover_image = attr.ib(default="")
     cover_desc = attr.ib(default="")
 
index b405a10..c4635f4 100644 (file)
@@ -18,7 +18,17 @@ id="review_preview_{{ review_entry.book.slug }}">
       <p class="title">{{ review_entry.book.title | smartypants | safe }}</p>
       <p>
         <small>
       <p class="title">{{ review_entry.book.title | smartypants | safe }}</p>
       <p>
         <small>
-          by {{ review_entry.book.author }}
+          {% if review_entry.book.author %}
+            by {{ review_entry.book.author }}
+            {%- if review_entry.book.editor -%}
+            ,
+            {% endif %}
+          {% endif %}
+
+          {% if review_entry.book.editor %}
+          edited by {{ review_entry.book.editor }}
+          {% endif %}
+
           {%- if review_entry.book.publication_year %}
             ({{ review_entry.book.publication_year}})
           {%- endif -%}
           {%- if review_entry.book.publication_year %}
             ({{ review_entry.book.publication_year}})
           {%- endif -%}
index b35e255..7b5a7b5 100644 (file)
   <h1><span class="book-title">{{ review_entry.book.title | smartypants | safe }}</span></h1>
 
   <table class="book_metadata">
   <h1><span class="book-title">{{ review_entry.book.title | smartypants | safe }}</span></h1>
 
   <table class="book_metadata">
-    <tr>
-      <td>author{% if "and" in review_entry.book.author or ", " in review_entry.book.author or " & " in review_entry.book.author %}s{% endif %}:</td>
-      <th>{{ review_entry.book.author }}
-        {%- if review_entry.book.publication_year %}
-          ({{ review_entry.book.publication_year}})
-        {%- endif -%}
-      </th>
-    </tr>
+    {% if review_entry.book.author %}
+      <tr>
+        <td>author{% if "and" in review_entry.book.author or ", " in review_entry.book.author or " & " in review_entry.book.author %}s{% endif %}:</td>
+        <th>{{ review_entry.book.author }}
+          {%- if review_entry.book.publication_year %}
+            ({{ review_entry.book.publication_year}})
+          {%- endif -%}
+        </th>
+      </tr>
+    {% endif %}
+    {% if review_entry.book.editor %}
+      <tr>
+        <td>editor{% if "and" in review_entry.book.editor or ", " in review_entry.book.editor or " & " in review_entry.book.editor %}s{% endif %}:</td>
+        <th>{{ review_entry.book.editor }}
+          {%- if review_entry.book.publication_year %}
+            ({{ review_entry.book.publication_year}})
+          {%- endif -%}
+        </th>
+      </tr>
+    {% endif %}
     {% if review_entry.review.date_read %}
     <tr>
       <td>date read:</td>
     {% if review_entry.review.date_read %}
     <tr>
       <td>date read:</td>