Browse Source

Put other pages with date into rss feed, like projects, not only blog posts.

Thomas Buck 3 years ago
parent
commit
e2062a28d8
2 changed files with 7 additions and 3 deletions
  1. 6
    2
      macros.py
  2. 1
    1
      page.html

+ 6
- 2
macros.py View File

212
 
212
 
213
 def hook_postconvert_rss():
213
 def hook_postconvert_rss():
214
     items = []
214
     items = []
215
-    posts = [p for p in pages if "post" in p] # get all blog post pages
215
+    posts = [p for p in pages if "date" in p]
216
     posts.sort(key=lambda p: p.date, reverse=True)
216
     posts.sort(key=lambda p: p.date, reverse=True)
217
     posts = posts[:10]
217
     posts = posts[:10]
218
     for p in posts:
218
     for p in posts:
219
-        title = p.post
219
+        title = p.title
220
+        if "post" in p:
221
+            title = p.post
220
         link = "%s/%s" % (BASE_URL, p.url)
222
         link = "%s/%s" % (BASE_URL, p.url)
221
         desc = p.html.replace("href=\"img", "%s%s%s" % ("href=\"", BASE_URL, "/img"))
223
         desc = p.html.replace("href=\"img", "%s%s%s" % ("href=\"", BASE_URL, "/img"))
222
         desc = desc.replace("src=\"img", "%s%s%s" % ("src=\"", BASE_URL, "/img"))
224
         desc = desc.replace("src=\"img", "%s%s%s" % ("src=\"", BASE_URL, "/img"))
225
+        desc = desc.replace("href=\"/img", "%s%s%s" % ("href=\"", BASE_URL, "/img"))
226
+        desc = desc.replace("src=\"/img", "%s%s%s" % ("src=\"", BASE_URL, "/img"))
223
         desc = htmlspecialchars(desc)
227
         desc = htmlspecialchars(desc)
224
         date = time.mktime(time.strptime("%s 12" % p.date, "%Y-%m-%d %H"))
228
         date = time.mktime(time.strptime("%s 12" % p.date, "%Y-%m-%d %H"))
225
         date = email.utils.formatdate(date)
229
         date = email.utils.formatdate(date)

+ 1
- 1
page.html View File

13
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
13
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
14
     <link rel="author" href="xythobuz@xythobuz.de" />
14
     <link rel="author" href="xythobuz@xythobuz.de" />
15
     <link rel="shortcut icon" href="img/favicon.ico" />
15
     <link rel="shortcut icon" href="img/favicon.ico" />
16
-    <link rel="alternate" type="application/rss+xml" title="Blog" href="rss.xml" />
16
+    <link rel="alternate" type="application/rss+xml" title="xythobuz.de" href="rss.xml" />
17
     <link type="text/css" rel="stylesheet" href="css/style.css" />
17
     <link type="text/css" rel="stylesheet" href="css/style.css" />
18
     <link type="text/css" rel="stylesheet" href="css/print.css" media="print" />
18
     <link type="text/css" rel="stylesheet" href="css/print.css" media="print" />
19
     <link type="text/css" rel="stylesheet" href="css/sh_bright.min.css" />
19
     <link type="text/css" rel="stylesheet" href="css/sh_bright.min.css" />

Loading…
Cancel
Save