Sfoglia il codice sorgente

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

Thomas Buck 3 anni fa
parent
commit
e2062a28d8
2 ha cambiato i file con 7 aggiunte e 3 eliminazioni
  1. 6
    2
      macros.py
  2. 1
    1
      page.html

+ 6
- 2
macros.py Vedi File

@@ -212,14 +212,18 @@ _RSS_ITEM = """
212 212
 
213 213
 def hook_postconvert_rss():
214 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 216
     posts.sort(key=lambda p: p.date, reverse=True)
217 217
     posts = posts[:10]
218 218
     for p in posts:
219
-        title = p.post
219
+        title = p.title
220
+        if "post" in p:
221
+            title = p.post
220 222
         link = "%s/%s" % (BASE_URL, p.url)
221 223
         desc = p.html.replace("href=\"img", "%s%s%s" % ("href=\"", BASE_URL, "/img"))
222 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 227
         desc = htmlspecialchars(desc)
224 228
         date = time.mktime(time.strptime("%s 12" % p.date, "%Y-%m-%d %H"))
225 229
         date = email.utils.formatdate(date)

+ 1
- 1
page.html Vedi File

@@ -13,7 +13,7 @@ else:
13 13
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
14 14
     <link rel="author" href="xythobuz@xythobuz.de" />
15 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 17
     <link type="text/css" rel="stylesheet" href="css/style.css" />
18 18
     <link type="text/css" rel="stylesheet" href="css/print.css" media="print" />
19 19
     <link type="text/css" rel="stylesheet" href="css/sh_bright.min.css" />

Loading…
Annulla
Salva