diff options
Diffstat (limited to 'rss.py')
-rw-r--r-- | rss.py | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -26,12 +26,6 @@ def render_template(cwd, template_path, context): | |||
26 | return env.get_template(template_path).render(context) | 26 | return env.get_template(template_path).render(context) |
27 | 27 | ||
28 | 28 | ||
29 | def _remove_attrs(soup): | ||
30 | for tag in soup.findAll(True): | ||
31 | tag.attrs = None | ||
32 | return soup | ||
33 | |||
34 | |||
35 | def main(): | 29 | def main(): |
36 | 30 | ||
37 | filenames = glob.glob("./_build/html/_posts/*/*/*.html") | 31 | filenames = glob.glob("./_build/html/_posts/*/*/*.html") |
@@ -41,11 +35,12 @@ def main(): | |||
41 | 35 | ||
42 | for p in filenames: | 36 | for p in filenames: |
43 | soup = BeautifulSoup(open(p), "html5lib") | 37 | soup = BeautifulSoup(open(p), "html5lib") |
44 | body = soup.find_all("div", class_="body") | 38 | body = soup.find_all("div", class_="body")[0].text |
39 | |||
45 | posts.append({ | 40 | posts.append({ |
46 | "title": soup.title.string, | 41 | "title": soup.title.string, |
47 | "body": body[0].text, | 42 | "body": body, |
48 | "date_rss": "", | 43 | "date_rss": body[body.find("Publish Date:")+13:body.find("Publish Date:")+23], |
49 | "permalink": "/".join(p.split("/")[3:]) | 44 | "permalink": "/".join(p.split("/")[3:]) |
50 | }) | 45 | }) |
51 | 46 | ||
@@ -53,7 +48,7 @@ def main(): | |||
53 | "site": { | 48 | "site": { |
54 | "name": "Hello World", | 49 | "name": "Hello World", |
55 | "url": "https://blog.jinwei.me", | 50 | "url": "https://blog.jinwei.me", |
56 | "tagline": "Freedom is my birthright and I shall have it." | 51 | "tagline": "Freedom is my birth right and I shall have it." |
57 | }, | 52 | }, |
58 | "posts": posts | 53 | "posts": posts |
59 | } | 54 | } |