diff options
-rw-r--r-- | Dockerfile | 2 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | _posts/2017/12/movies.rst (renamed from _posts/2017/movies.rst) | 4 | ||||
-rw-r--r-- | all.rss.xml | 18 | ||||
-rw-r--r-- | blog.iml | 9 | ||||
-rw-r--r-- | rss.py | 64 | ||||
-rw-r--r-- | rss.xml | 94 |
7 files changed, 184 insertions, 12 deletions
@@ -14,7 +14,7 @@ ADD . /app | |||
14 | 14 | ||
15 | WORKDIR /app | 15 | WORKDIR /app |
16 | 16 | ||
17 | RUN /bin/bash -c "source /app/.venv/bin/activate && make html" | 17 | RUN /bin/bash -c "source /app/.venv/bin/activate && make html && make rss" |
18 | 18 | ||
19 | 19 | ||
20 | FROM alpine:latest | 20 | FROM alpine:latest |
@@ -12,9 +12,12 @@ BUILDDIR = _build | |||
12 | help: | 12 | help: |
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
14 | 14 | ||
15 | rss: | ||
16 | python rss.py > rss.xml | ||
17 | |||
15 | .PHONY: help Makefile | 18 | .PHONY: help Makefile |
16 | 19 | ||
17 | # Catch-all target: route all unknown targets to Sphinx using the new | 20 | # Catch-all target: route all unknown targets to Sphinx using the new |
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | 21 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). |
19 | %: Makefile | 22 | %: Makefile |
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file | 23 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
diff --git a/_posts/2017/movies.rst b/_posts/2017/12/movies.rst index 10fcbc3..6be761d 100644 --- a/_posts/2017/movies.rst +++ b/_posts/2017/12/movies.rst | |||
@@ -2,9 +2,11 @@ | |||
2 | 2 | ||
3 | .. _2017movie: | 3 | .. _2017movie: |
4 | 4 | ||
5 | |||
5 | 2017观影记录 | 6 | 2017观影记录 |
6 | =================== | 7 | =================== |
7 | 8 | ||
9 | :Publish Date: 2017-12-30 | ||
8 | 10 | ||
9 | 2017年马上就结束了。掐指一算,2017年看了好多电影。包括线上和线下电影院的。 | 11 | 2017年马上就结束了。掐指一算,2017年看了好多电影。包括线上和线下电影院的。 |
10 | 12 | ||
@@ -67,7 +69,7 @@ | |||
67 | 69 | ||
68 | 简单分析了一下,线下观影的统计 | 70 | 简单分析了一下,线下观影的统计 |
69 | 71 | ||
70 | .. image:: ../../_static/img/2017movie.png | 72 | .. image:: ../../../_static/img/2017movie.png |
71 | :alt: 2017movie | 73 | :alt: 2017movie |
72 | :align: center | 74 | :align: center |
73 | 75 | ||
diff --git a/all.rss.xml b/all.rss.xml new file mode 100644 index 0000000..cafc7fd --- /dev/null +++ b/all.rss.xml | |||
@@ -0,0 +1,18 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> | ||
3 | <channel> | ||
4 | <title>{{ site.name }}</title> | ||
5 | <link>{{ site.url }}</link> | ||
6 | <description>{{ site.tagline }}</description> | ||
7 | <atom:link href="{{ site.url }}/rss" rel="self" type="application/rss+xml" /> | ||
8 | {% for post in posts[:20] %} | ||
9 | <item> | ||
10 | <title>{{ post.title | e }}</title> | ||
11 | <description>{{ post.body | e }}</description> | ||
12 | <pubDate>{{ post.date_rss }}</pubDate> | ||
13 | <link>{{ site.url }}/{{ post.permalink }}</link> | ||
14 | <guid isPermaLink="true">{{ site.url }}/{{ post.permalink }}</guid> | ||
15 | </item> | ||
16 | {% endfor %} | ||
17 | </channel> | ||
18 | </rss> | ||
diff --git a/blog.iml b/blog.iml deleted file mode 100644 index ad3c0a3..0000000 --- a/blog.iml +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <module type="PYTHON_MODULE" version="4"> | ||
3 | <component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
4 | <exclude-output /> | ||
5 | <content url="file://$MODULE_DIR$" /> | ||
6 | <orderEntry type="inheritedJdk" /> | ||
7 | <orderEntry type="sourceFolder" forTests="false" /> | ||
8 | </component> | ||
9 | </module> \ No newline at end of file | ||
@@ -0,0 +1,64 @@ | |||
1 | import os | ||
2 | import jinja2 | ||
3 | |||
4 | import glob | ||
5 | from bs4 import BeautifulSoup | ||
6 | |||
7 | |||
8 | class FilePathLoader(jinja2.BaseLoader): | ||
9 | def __init__(self, cwd): | ||
10 | self.cwd = cwd | ||
11 | |||
12 | def get_source(self, environment, template): | ||
13 | filename = os.path.join(self.cwd, template) | ||
14 | |||
15 | try: | ||
16 | with open(filename, 'r') as f: | ||
17 | contents = f.read() | ||
18 | except IOError: | ||
19 | raise jinja2.TemplateNotFound(filename) | ||
20 | |||
21 | return contents, filename, lambda: False | ||
22 | |||
23 | |||
24 | def render_template(cwd, template_path, context): | ||
25 | env = jinja2.Environment(loader=FilePathLoader(cwd)) | ||
26 | return env.get_template(template_path).render(context) | ||
27 | |||
28 | |||
29 | def main(): | ||
30 | |||
31 | filenames = glob.glob("./_build/html/_posts/*/*/*.html") | ||
32 | print(filenames) | ||
33 | |||
34 | posts = [] | ||
35 | |||
36 | for p in filenames: | ||
37 | soup = BeautifulSoup(open(p), "html5lib") | ||
38 | body = soup.find_all("div", class_="body")[0].text | ||
39 | |||
40 | posts.append({ | ||
41 | "title": soup.title.string, | ||
42 | "body": body, | ||
43 | "date_rss": body[body.find("Publish Date:")+13:body.find("Publish Date:")+23], | ||
44 | "permalink": "/".join(p.split("/")[3:]) | ||
45 | }) | ||
46 | |||
47 | context = { | ||
48 | "site": { | ||
49 | "name": "Hello World", | ||
50 | "url": "https://blog.jinwei.me", | ||
51 | "tagline": "Freedom is my birth right and I shall have it." | ||
52 | }, | ||
53 | "posts": posts | ||
54 | } | ||
55 | |||
56 | return render_template( | ||
57 | ".", | ||
58 | "all.rss.xml", | ||
59 | context | ||
60 | ) | ||
61 | |||
62 | |||
63 | if __name__ == '__main__': | ||
64 | print(main()) | ||
@@ -0,0 +1,94 @@ | |||
1 | ['./_build/html/_posts/2017/12/movies.html'] | ||
2 | <?xml version="1.0" encoding="UTF-8"?> | ||
3 | <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> | ||
4 | <channel> | ||
5 | <title>Hello World</title> | ||
6 | <link>https://blog.jinwei.me</link> | ||
7 | <description>Freedom is my birth right and I shall have it.</description> | ||
8 | <atom:link href="https://blog.jinwei.me/rss" rel="self" type="application/rss+xml" /> | ||
9 | |||
10 | <item> | ||
11 | <title>2017观影记录 — Hello World</title> | ||
12 | <description> | ||
13 | |||
14 | |||
15 | 2017观影记录¶ | ||
16 | |||
17 | |||
18 | |||
19 | |||
20 | Publish Date:2010-01-01 | ||
21 | |||
22 | |||
23 | |||
24 | 2017年马上就结束了。掐指一算,2017年看了好多电影。包括线上和线下电影院的。 | ||
25 | 线下电影院观影记录(按时间顺序,以中国大陆上映时的片名为准): | ||
26 | |||
27 | 星球大战外传:侠盗一号 (Rogue One: A Star Wars Story) | ||
28 | 太空旅客 (Passengers) | ||
29 | 降临 (Arrival) | ||
30 | 极限特工:终极回归 (xXx: The Return of Xander Cage) | ||
31 | 生化危机6:终章 (Resident Evil: The Final Chapter) | ||
32 | 金刚狼3:殊死一战 (Logan) | ||
33 | 攻壳机动队 (Ghost in the Shell) | ||
34 | 速度与激情8 (The Fate of the Furious) | ||
35 | 拆弹专家 | ||
36 | 大护法 | ||
37 | 战狼2 | ||
38 | 星际特工:千星之城 (Valérian et la Cité des mille planètes) | ||
39 | 看不见的客人 (Contratiempo) | ||
40 | 英伦对决 (The Foreigner) | ||
41 | 天才枪手 (ฉลาดเกมส์โกง) | ||
42 | 王牌特工2:黄金圈 (Kingsman: The Golden Circle) | ||
43 | 全球风暴 (Geostorm) | ||
44 | 东方快车谋杀案 (Murder on the Orient Express) | ||
45 | 雷神3:诸神黄昏 (Thor: Ragnarok) | ||
46 | 追捕 | ||
47 | 至暗时刻 (Darkest Hour) | ||
48 | 寻梦环游记 (Coco) | ||
49 | 至爱梵高·星空之谜 (Loving Vincent) | ||
50 | 芳华 | ||
51 | |||
52 | 线上观影记录(包括BT下载以及Netflix,包括电影/纪录片/部分美剧,不完全): | ||
53 | |||
54 | Blade Runner (1982) | ||
55 | Blade Runner 2049 | ||
56 | Love Actually | ||
57 | World War Z | ||
58 | Dunkirk | ||
59 | Everst | ||
60 | 霸王别姬 | ||
61 | Titanic | ||
62 | 隧道 (터널) | ||
63 | London Has Fallen | ||
64 | 出租车司机 (택시운전사) | ||
65 | Ocean’s Eleven | ||
66 | Ocean’s Twelve | ||
67 | Shooter | ||
68 | Knight Day | ||
69 | 2001: A Space Odyssey | ||
70 | Minority Report | ||
71 | Deep Impact | ||
72 | Area 51 | ||
73 | San Andreas | ||
74 | I, Origin | ||
75 | Particle Fever | ||
76 | City 40 | ||
77 | Stranger Things | ||
78 | House Of Cards, Season 1 | ||
79 | |||
80 | 现在回忆一下,很多电影的质量其实很一般,属于看完之后走出电影院差不多就能忘记剧情的那种。这种电影很多都是所谓的「商业大片」,追求特效和画面,完全不考虑剧情的质量和观众的观影感受。 | ||
81 | 简单分析了一下,线下观影的统计 | ||
82 | |||
83 | 6月居然一部都没看,是因为工作太饱和了还是因为没有好看的电影呢? | ||
84 | |||
85 | |||
86 | |||
87 | </description> | ||
88 | <pubDate>2010-01-01</pubDate> | ||
89 | <link>https://blog.jinwei.me/_posts/2017/12/movies.html</link> | ||
90 | <guid isPermaLink="true">https://blog.jinwei.me/_posts/2017/12/movies.html</guid> | ||
91 | </item> | ||
92 | |||
93 | </channel> | ||
94 | </rss> | ||