Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Собирает фиды в OPML-файлы и деплоит на сайт #9

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0975f0e
First try to autogen OPML and MD
jag-k Apr 19, 2021
c3acc58
Add GH Action to create release with OPML-file
jag-k Apr 19, 2021
25c1723
Update package-lock.json
jag-k Apr 19, 2021
809643a
Update package-lock.json again
jag-k Apr 19, 2021
18d8f8f
Removed mv deps and add path module
jag-k Apr 19, 2021
6824684
Add auto-update README.md
jag-k Apr 19, 2021
b838aeb
Fix release-opml.yaml
jag-k Apr 19, 2021
b98cb43
Update release-opml.yml
jag-k Apr 19, 2021
8957a31
Added artifacts
jag-k Apr 19, 2021
137fef7
Fix action
jag-k Apr 19, 2021
78b5d5d
Added link in README to download feeds.opml
jag-k Apr 19, 2021
1c7c447
Update at 2021.04.19
jag-k Apr 19, 2021
e68e219
Fix OPML-creator
jag-k Apr 26, 2021
25de366
Merge branch 'main' of https://github.com/jag-k/indie-list into main
jag-k Apr 26, 2021
22023e7
Update feeds.opml
jag-k Apr 26, 2021
bbffc56
Deleted YAML feeds
jag-k Apr 30, 2021
0f1e7e9
Сильно упрощает package.json
Apr 30, 2021
3698fa4
Откатывает лок-файл до v1
Apr 30, 2021
a04dc31
Добавляет зависимость
Apr 30, 2021
1ba2138
Added langs and flat OPML files
jag-k May 3, 2021
e570fa2
Update Action
jag-k May 4, 2021
268c125
Fix bug with Russian list
jag-k May 8, 2021
bca3e15
Update at 2021.05.08
jag-k May 8, 2021
c30125c
Update .gitignore
jag-k May 16, 2021
54207dc
Update `.editorconfig`
jag-k May 16, 2021
913210c
Update `README.md`
jag-k May 16, 2021
4a6bbcd
Merge pull request #1 from web-standards-ru/main
jag-k May 16, 2021
ed5e02b
Updated feeds
jag-k May 16, 2021
3f4017a
Merge branch 'web-standards-ru:main' into main
jag-k May 31, 2021
b1c116f
Update at 2021.05.31
jag-k May 31, 2021
8b00d03
Чистит .gitignore
May 31, 2021
b43a6bb
Игнорирует OPML
May 31, 2021
a0c534d
Убирает артефакты
May 31, 2021
c4ece40
Переносит ссылки выше
May 31, 2021
f42b0b9
Меняет сборку и добавляет деплой
May 31, 2021
e9e0090
Удаление "плоского" OMPL файла
jag-k May 31, 2021
f4961b9
Merge branch 'web-standards-ru:main' into main
jag-k Nov 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
# Настройка ключа
- name: Key
run: |
set -eu
mkdir "$HOME/.ssh"
echo "${{ secrets.KEY }}" > "$HOME/.ssh/key"
chmod 600 "$HOME/.ssh/key"
# Установка и сборка
- name: Install
run: npm ci
- name: Build
run: npm run build
# Деплой
- name: Deploy
run: rsync -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" --archive --compress --delete *.opml [email protected]:/var/www/web-standards.ru/indie/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*.opml
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

Инди — это _independent,_ то есть независимый. Значит не компания, не проект и даже не сообщество, а сам автор как есть. Цель этого списка — поддержать независимых авторов на их собственных платформах, познакомить их с новыми читателями и подчеркнуть важность их работы для фронтенда. Поэтому в каждом названии имя автора, а в списке не хватает многих хороших проектов, которые сложно назвать инди.

## Как подписаться

Импортируйте в ваш RSS-клиент OPML-файл:

- [Все фиды](https://web-standards.ru/indie/feeds.opml)
- [Только русскоязычные](https://web-standards.ru/indie/feeds-ru.opml)
- [Только англоязычные](https://web-standards.ru/indie/feeds-en.opml)

## Как добавить

Условия для добавления:

- Личный блог на своём домене.
Expand Down
111 changes: 111 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
const xml = require("xml");
const fs = require('fs-extra');

const ENCODING = 'UTF-8';
const DATA_PATH = 'README.md'
const FEEDS_PATH = 'feeds.opml'
const FEEDS_LANG_PATH = (lang) => `feeds.${lang}.opml`

const RE = {
GROUP_LANG: /## ([\wа-яё]+)/gmi,
FEED: /^- \[(?<name>.+)\]\((?<url>.+)\), \[RSS\]\((?<rss>.+)\)$/gm,
}

const TEMPLATES = {
FEED: (data, lang) => {
return {
outline: [
{
_attr: {
title: data.name,
lang: lang,
htmlUrl: data.url,
xmlUrl: data.rss,
category: lang,
type: 'rss',
}
},
]
};
},

LANG: (data, lang) => {
return {
outline: [
{ _attr: { text: lang, category: lang, } },
...data
]
};

},

MAIN: (data) => xml([{
opml: [
{ _attr: { version: '2.0' } },
{
head: [
{ title: 'Список инди-сайтов сообщества "Веб-стандарты"' },
{ dateCreated: (new Date(2021, 3, 13, 1, 46, 34)).toISOString() },
{ dateModified: (new Date()).toISOString() },
{ ownerName: "web-standarts" },
{ ownerEmail: "[email protected]" },
],
},
{ body: data }
]
}], { declaration: true })
}

const LANGUAGES = {
'Русскоязычные': "ru",
'Англоязычные': "en",
default: "undefined"
}

function getAllByRegexp(string, regexp) {
let m;
const res = [];
while ((m = regexp.exec(string)) !== null) {
if (m.index === regexp.lastIndex) {
regexp.lastIndex++;
}
if (m) res.push(m)
}
return res;
}

async function main() {
const readme = await fs.readFile(DATA_PATH, ENCODING);
const regex = RE.GROUP_LANG
let langs = getAllByRegexp(readme, regex);
const result = [];
let raw_text = readme.split(RE.GROUP_LANG).slice(1)
let rawData = []
console.log(raw_text);

for (let i = 0; i < raw_text.length; i += 2) {
rawData.push({
lang: LANGUAGES[raw_text[i]],
normalLang: raw_text[i],
text: raw_text[i + 1].trim(),
})
}

for (let data of rawData) {
let {lang, normalLang, text} = data

feeds = getAllByRegexp(text, RE.FEED).map(data => TEMPLATES.FEED(data.groups, lang));
console.log(feeds);
result.push(TEMPLATES.LANG(feeds, normalLang));
let path = FEEDS_LANG_PATH(lang)
await fs.writeFile(path, TEMPLATES.MAIN(feeds), { encoding: ENCODING })
console.log(`Saved '${lang}' to '${path}'`);
}

await fs.writeFile(FEEDS_PATH, TEMPLATES.MAIN(result), { encoding: ENCODING })
console.log('Saved default feeds');
};

main()
.then((data) => { console.log("Done!"); })
.catch((err) => { console.error("FAIL!"); throw err });
52 changes: 52 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"private": true,
"main": "build.js",
"scripts": {
"build": "node build.js",
"deploy": "rsync --archive --compress --delete *.opml [email protected]:/var/www/web-standards.ru/indie/"
},
"devDependencies": {
"fs-extra": "^9.1.0",
"xml": "^1.0.1"
}
}