🛠 Content updates and build trigger

This commit is contained in:
Dennis Reimann
2020-10-07 09:04:53 +02:00
parent f5297788ee
commit 5eb10060d9
10 changed files with 366 additions and 6025 deletions

View File

@@ -1,12 +1,18 @@
name: build
on:
# Run the build for pushes and pull requests targeting master
push:
branches:
- master
pull_request:
branches:
- master
# Used to trigger the build for Anchor feed updates. Can by kicked off via:
# curl -X POST -H "Authorization: token $GH_PAT" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" https://api.github.com/repos/Einundzwanzig-Podcast/einundzwanzig.space/dispatches --data '{"event_type": "build_docs"}'
repository_dispatch:
types:
- anchor_update
jobs:
build:

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
/generated
/log
/node_modules
/tasks/.check-feed

View File

@@ -11,5 +11,16 @@
"appleUrl": "https://podcasts.apple.com/de/podcast/einundzwanzig-der-bitcoin-podcast/id1488229907",
"overcastUrl": "https://overcast.fm/itunes1488229907/einundzwanzig-der-bitcoin-podcast",
"anchorUrl": "https://anchor.fm/einundzwanzig",
"feedUrl": "https://anchor.fm/s/d8d3c38/podcast/rss"
"feedUrl": "https://anchor.fm/s/d8d3c38/podcast/rss",
"ticker": [
"Sende uns einen Shout-Out: 50.000 Sats und du bist dabei",
"\"Hosp oder top!\" ist Spiel des Jahres 2020",
"Sei kein Holger, lass einen Fullnode laufen!",
"Sei kein Vollknoten, komm in die Gruppe!",
"Markus ist bester Mann des Monats",
"Heute ist ein guter Tag um Sats zu stapeln",
"Besseres Geld, bessere Welt",
"Inflation ist eine versteckte Steuer",
"Neues Specter Desktop Update veröffentlicht"
]
}

6280
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,21 +11,21 @@
"scripts": {
"clean": "rm -rf dist generated && mkdir -p dist generated",
"fetch": "node tasks/fetch_feed.js",
"start": "npm-run-all clean fetch -p build:static start:*",
"copy": "cp -r static/* dist && cp node_modules/amplitudejs/dist/amplitude.min.js dist/js/amplitude.js",
"init": "npm-run-all clean -p fetch copy build:data",
"start": "npm-run-all init -p start:*",
"start:data": "onchange -k 'content/**/*' -- npm run build:data",
"start:pages": "onchange -i -k 'pug.config.js' 'markdown.js' 'content/**' 'generated/**' 'src/**/*.pug' 'src/**/*.svg' 'tasks/generate_pages.js' -- npm run build:pages",
"start:styles": "onchange -i -k 'src/**/*.css' -- npm run build:styles",
"start:data": "onchange -i -k 'content/**/*' -- npm run build:data",
"start:serve": "browser-sync start --config browser-sync.config.js --watch",
"build": "npm-run-all clean fetch -p build:*",
"build:static": "cp -r static/* dist && cp node_modules/amplitudejs/dist/amplitude.min.js dist/js/amplitude.js",
"build": "npm-run-all init -p build:*",
"build:data": "node tasks/generate_site_data.js",
"build:pages": "node tasks/generate_pages.js",
"build:styles": "postcss src/css/main.css --output dist/css/main.css",
"optimize": "npm-run-all -p optimize:* -s rev",
"optimize:styles": "csso dist/css/main.css --output dist/css/main.css",
"rev": "node-file-rev --manifest=generated/rev.json --root=dist dist/css/* dist/js/* dist/img/*.svg dist/img/cover/*.png dist/img/team/*.jpg dist/img/team/*.png",
"prod": "npm-run-all build optimize -s build:pages",
"images": "node tasks/optimize_images.js"
"prod": "npm-run-all build optimize -s build:pages"
},
"dependencies": {
"amplitudejs": "5.2.0"
@@ -47,13 +47,7 @@
"postcss-media-variables": "2.0.1",
"postcss-nesting": "7.0.1",
"pug-cli": "1.0.0-alpha6",
"rss-parser": "3.9.0"
},
"optionalDependencies": {
"compress-images": "1.9.5",
"gifsicle": "5.1.0",
"mozjpeg": "7.0.0",
"pngquant-bin": "6.0.0",
"svgo": "1.3.2"
"rss-parser": "3.9.0",
"sync-request": "6.1.0"
}
}

View File

@@ -77,7 +77,15 @@ html(lang="en")
= " und "
a(href=site.meta.telegramUrl target="_blank") komm in die Gruppe
|!
if site.block
p
| Aktualisiert um
= " "
a(href=`https://www.blockstream.info/block-height/${site.block}`)
time(datetime=site.date)= site.block
|.
p
| Made with 💛 by
= " "
a(href="https://d11n.net" target="_blank") d11n.
a(href="https://d11n.net" target="_blank") d11n
|.

View File

@@ -1,12 +1,11 @@
extends /template.pug
block main
- const ticker = "Toximalistisches Infotainment für bullishe Bitcoiner +++ Sende uns einen Shout-Out: 50.000 Sats und du bist dabei +++ Alpenzitadelle läuft, wir spielen Hosp oder top! +++ Sei kein Holger, lass einen Vollknoten laufen! +++ Sei kein Vollknoten, komm in die Gruppe ! +++ Markus, ist bester Mann des Monats +++ "
- const ticker = shuffle(site.meta.ticker).join(" +++ ") + " +++ "
.ticker
.inner
pre= ticker
pre= ticker
pre= ticker
.wrap
section

30
tasks/check-feed.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
dir=$(dirname "$0")
log="$dir/check-feed.log"
file="$dir/.check-feed"
prev=$(cat $file)
feed=$(curl -s https://anchor.fm/s/d8d3c38/podcast/rss)
date=$(echo "$feed" | awk 'BEGIN { FS="<|>"; RS="\n" }; { if ($0 ~ /lastBuildDate/) print $3}')
if [[ ! -z "$date" ]]; then
echo "Latest build: $prev"
echo "Last updated: $date"
if [[ "$date" != "$prev" ]]; then
if [[ ! -z "$GH_PAT" ]]; then
echo "-> Triggering new build"
curl -X POST https://api.github.com/repos/Einundzwanzig-Podcast/einundzwanzig.space/dispatches \
-H "Authorization: token $GH_PAT" \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Content-Type: application/json" \
--data '{"event_type": "anchor_update"}'
echo $date >> $log
else
echo "Missing GH_PAT environment variable!"
fi
fi
echo $date > $file
fi

View File

@@ -1,12 +1,22 @@
const { writeFileSync } = require('fs')
const { join, resolve } = require('path')
const request = require('sync-request')
const meta = require('../content/meta.json')
const dir = resolve(__dirname, '..', 'generated')
const dst = join(dir, 'site-data.json')
let recentBlocks = []
try {
const jsonBody = request('GET', 'https://mempool.observer/api/recentBlocks').getBody('utf8')
recentBlocks = JSON.parse(jsonBody)
} catch (err) {
console.error('Could not load recent blocks:', err)
}
const block = recentBlocks.length && recentBlocks[0].height
const date = (new Date()).toJSON().split('T')[0]
const data = { date, meta }
const data = { date, block, meta }
writeFileSync(dst, JSON.stringify(data, null, 2))

View File

@@ -1,14 +0,0 @@
const compress_images = require('compress-images')
const input = 'compress/*.{jpg,png,svg,gif}'
const output = 'compress/out/'
compress_images(input, output, { compress_force: true, statistic: true, autoupdate: false }, false,
{ jpg: { engine: "mozjpeg", command: ["-quality", "60"] } },
{ png: { engine: "pngquant", command: ["--quality=20-50", "-o"] } },
{ svg: { engine: "svgo", command: "--multipass" } },
{ gif: { engine: "gifsicle", command: ["--colors", "64", "--use-col=web"] } },
(error, completed, statistic) => {
if (error) console.error(error)
if (statistic) console.log(statistic)
}
)