From fae1a5b5fb1a629bc28217b13b4019b7dd6009f4 Mon Sep 17 00:00:00 2001 From: Singee Date: Tue, 3 Dec 2019 00:40:32 +0800 Subject: [PATCH] =?UTF-8?q?Github=20Action=20=E4=B8=AD=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E7=94=9F=E6=88=90=20OPML=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E8=84=9A=E6=9C=AC=20fix=20#58?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add updating feed.opml to github action * add blog.singee.me * update README and feed.opml after adding blog(s) --- .../{updateReadme.yml => updateInfo.yml} | 22 +++++++++---- README.md | 1 + blogs-original.csv | 3 +- feed.opml | 1 + opml_generator.py | 32 +++++++++++++++++++ 5 files changed, 52 insertions(+), 7 deletions(-) rename .github/workflows/{updateReadme.yml => updateInfo.yml} (54%) create mode 100644 feed.opml create mode 100644 opml_generator.py diff --git a/.github/workflows/updateReadme.yml b/.github/workflows/updateInfo.yml similarity index 54% rename from .github/workflows/updateReadme.yml rename to .github/workflows/updateInfo.yml index bccd05eea..5ea7810c1 100644 --- a/.github/workflows/updateReadme.yml +++ b/.github/workflows/updateInfo.yml @@ -1,9 +1,12 @@ -name: update readme +name: Update readme and feed.opml -on: +on: push: - paths: - - 'blogs-original.csv' + paths: + - 'blogs-original.csv' + - 'opml_generator.py' + - 'script.js' + - '.github/workflows/updateInfo.yml' jobs: build: @@ -16,16 +19,23 @@ jobs: uses: actions/setup-node@v1 with: node-version: 12.x + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 - name: update readme run: | npm install node script.js + - name: Generate feed.opml + run: | + python opml_generator.py - name: Commit files run: | git config --local user.email "actions@github.com" git config --local user.name "GitHub Action" - git add . - git commit -m "update readme after adding blog(s)" -a + git add README.md feed.opml + git commit -m "update README and feed.opml after adding blog(s)" - name: Push changes uses: ad-m/github-push-action@master with: diff --git a/README.md b/README.md index eb3fc66f7..d76e98490 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,7 @@ | [![](https://badgen.net/badge/icon/*?icon=rss&label)](https://blog.ixk.me/feed) | 青空之蓝 | https://blog.ixk.me | 编程; 随笔; Web开发; | | [![](https://badgen.net/badge/icon/*?icon=rss&label)](https://huiweishijie.com/feed.xml) | 回未视戒 | https://huiweishijie.com | 设计; 读书; 日记 | | [![](https://badgen.net/badge/icon/*?icon=rss&label)](https://zhengzexin.com/feed/) | 郑泽鑫的博客 | https://zhengzexin.com/ | 编程; 生物信息学; 生活; | +| [![](https://badgen.net/badge/icon/*?icon=rss&label)](https://blog.singee.me/atom.xml) | Origin | https://blog.singee.me/ | 编程;Python;全栈 | | [![](https://badgen.net/badge/icon/*?icon=rss&label)](http://shrekshao.github.io/feed.xml) | ShrekShao | http://shrekshao.github.io | 编程; | | [![](https://badgen.net/badge/icon/*?icon=rss&label)](https://ridiqulous.com/feed) | RidiQulous | https://ridiqulous.com | 图像处理; 乐高; | | [![](https://badgen.net/badge/icon/*?icon=rss&label)](https://vzardlloo.github.io/atom.xml) | vzard's blog | https://vzardlloo.github.io | 编程; | diff --git a/blogs-original.csv b/blogs-original.csv index 8ac6aab0e..fe477dab6 100644 --- a/blogs-original.csv +++ b/blogs-original.csv @@ -258,4 +258,5 @@ Xieisabug, https://www.xiejingyang.com/, https://www.xiejingyang.com/feed/, 编 老镭, https://www.wolone.wang/, https://www.wolone.wang/feed/, 编程; 生活; Scott Yeung's Blog, http://scottyeung.club/, http://scottyeung.club/atom.xml, 编程; 算法; 思考; WEB; 随笔; hywel前端个人博客, http://www.hywel.cn/, , 编程; 前端; WEB; 随笔; -LarsCheng, https://www.larscheng.com/, https://www.larscheng.com/atom.xml, 编程; Java; 生活; \ No newline at end of file +LarsCheng, https://www.larscheng.com/, https://www.larscheng.com/atom.xml, 编程; Java; 生活; +Origin, https://blog.singee.me/, https://blog.singee.me/atom.xml, 编程;Python;全栈 diff --git a/feed.opml b/feed.opml new file mode 100644 index 000000000..bf4a57c55 --- /dev/null +++ b/feed.opml @@ -0,0 +1 @@ +中文独立博客列表 \ No newline at end of file diff --git a/opml_generator.py b/opml_generator.py new file mode 100644 index 000000000..6f94e14f4 --- /dev/null +++ b/opml_generator.py @@ -0,0 +1,32 @@ +from xml.sax.saxutils import quoteattr + + +with open('blogs-original.csv', 'r') as f: + file_content = f.read() + +lines = file_content.split('\n') + +HEAD = '中文独立博客列表' +END = '' +ITEM = '' + +content = HEAD + +for line in lines[1:]: + line = line.strip() + if not line: + continue + + parts = line.split(',') + if len(parts) != 4: + continue + parts = [part.strip() for part in parts] + + if parts[2]: + content += ITEM.format(title=quoteattr(parts[0]), link=quoteattr(parts[1]), rss_link=quoteattr(parts[2])) + +content += END + +with open('feed.opml', 'w') as f: + f.write(content) +