Skip to content

Commit 1fb5bce

Browse files
authored
Merge pull request #3527 from andrewpollack/adding-publish-automation
Adding publish automation
2 parents 8b015ef + 523b2f3 commit 1fb5bce

File tree

6 files changed

+119
-4
lines changed

6 files changed

+119
-4
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ output
77
cache
88
.sass-cache
99
**/.idea
10+
.DS_Store
11+
12+
# Publishing creations...
13+
publishing/output
14+
publishing/juice

publishing/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM ubuntu:20.04
2+
3+
# Must run from base TWIR directory... makefile takes care of this.
4+
WORKDIR /usr/twir
5+
6+
RUN apt-get update
7+
RUN apt-get install -qq -y curl python3.8 python3-pip language-pack-en
8+
9+
# pelican+friends
10+
ENV LANG='en_US.UTF-8'
11+
ENV LC_ALL='en_US.UTF-8'
12+
RUN ln -s /usr/bin/python3.8 /usr/bin/python
13+
COPY requirements.txt .
14+
RUN pip3 install -r requirements.txt
15+
16+
# sass/juice
17+
RUN apt-get install -y curl
18+
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
19+
RUN apt-get install -y nodejs
20+
RUN npm install -g sass
21+
RUN npm install -g juice
22+
23+
# pelican setup
24+
COPY content content
25+
COPY plugins plugins
26+
COPY themes themes
27+
COPY pelicanconf.py pelicanconf.py
28+
29+
COPY publishing/run_server.sh run_server.sh
30+
RUN chmod 777 run_server.sh
31+
COPY publishing/create_html_friendly_page.sh create_html_friendly_page.sh
32+
RUN chmod 777 create_html_friendly_page.sh
33+
34+
CMD ["pelican", "--delete-output-directory", "content"]

publishing/Makefile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/sh
2+
3+
# Typical flows:
4+
#
5+
# 1. The first workflow will generate the desired website, landing
6+
# the end contents in the local "output/" directory. This is the
7+
# equivalent of running `pelican --delete-output-directory content`
8+
# from a properly instantantiated environment.
9+
#
10+
# $ make build && make generate-website && make host-content
11+
#
12+
# Then, visit "http://127.0.0.1:8000/blog" from a browser to verify.
13+
#
14+
# 2. This workflow will generate the desired email template, landing
15+
# the end contents in the local "output/" directory. This is the
16+
# equivalent of running `TWIR_NEWSLETTER_THEME=1 pelican --delete-output-directory content`
17+
# from a properly instantantiated environment.
18+
#
19+
# $ make build && make generate-email && make host-content
20+
#
21+
# Then, visit "http://127.0.0.1:8000/blog" from a browser to verify.
22+
# Once verified, one can adjust the "BLOG_DOWNLOAD" variable below, and
23+
# create an email-friendly HTML version of the "BLOG_DOWNLOAD" page.
24+
# This is the equivalent of running `juice --web-resources-images false /tmp/in.html /tmp/out.html`
25+
#
26+
# $ make optimize-email
27+
#
28+
# This results in the desired email-friendly HTML version: "juice/out.html".
29+
30+
# CHANGE ME! vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
31+
BLOG_DOWNLOAD=http://127.0.0.1:8000/blog/2022/08/10/this-week-in-rust-455/
32+
33+
build:
34+
cd .. && docker build -t twir -f publishing/Dockerfile . && cd -
35+
36+
clean:
37+
rm -rf output/
38+
39+
generate-website: clean
40+
docker run -it \
41+
-v $(shell pwd)/output:/usr/twir/output \
42+
twir:latest
43+
44+
generate-email: clean
45+
docker run -it \
46+
-e TWIR_NEWSLETTER_THEME=1 \
47+
-v $(shell pwd)/output:/usr/twir/output \
48+
twir:latest
49+
50+
host-content:
51+
docker run -it \
52+
-p 8000:8000 \
53+
-v $(shell pwd)/output:/usr/twir/output:ro \
54+
-it \
55+
twir:latest \
56+
bash run_server.sh
57+
58+
optimize-email:
59+
@echo -n "Is this '${BLOG_DOWNLOAD}' your desired blog? [y/N] " && read ans && [ $${ans:-N} = y ]
60+
rm -rf juice
61+
mkdir juice
62+
curl ${BLOG_DOWNLOAD} > juice/in.html
63+
docker run \
64+
-v $(shell pwd)/juice:/usr/twir/juice \
65+
-e BLOG_DOWNLOAD=${BLOG_DOWNLOAD} \
66+
twir:latest \
67+
bash create_html_friendly_page.sh
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
juice --web-resources-images false juice/in.html juice/out.html
4+
rm juice/in.html

publishing/run_server.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
cd output
4+
python3 -m http.server

requirements.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
Markdown==3.3.6
2-
pelican==4.7.1
3-
feedgenerator==2.0
4-
pelican-webassets==2.0.0
51
cssmin==0.2.0
2+
feedgenerator==2.0
63
jinja2==2.11.3
74
libsass==0.21.0
5+
Markdown==3.3.6
6+
markupsafe==2.0.1
7+
pelican==4.7.1
8+
pelican-webassets==2.0.0

0 commit comments

Comments
 (0)