Skip to content

Adding publish automation #3527

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ output
cache
.sass-cache
**/.idea
.DS_Store

# Publishing creations...
publishing/output
publishing/juice
34 changes: 34 additions & 0 deletions publishing/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM ubuntu:20.04

# Must run from base TWIR directory... makefile takes care of this.
WORKDIR /usr/twir

RUN apt-get update
RUN apt-get install -qq -y curl python3.8 python3-pip language-pack-en

# pelican+friends
ENV LANG='en_US.UTF-8'
ENV LC_ALL='en_US.UTF-8'
RUN ln -s /usr/bin/python3.8 /usr/bin/python
COPY requirements.txt .
RUN pip3 install -r requirements.txt

# sass/juice
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y nodejs
RUN npm install -g sass
RUN npm install -g juice

# pelican setup
COPY content content
COPY plugins plugins
COPY themes themes
COPY pelicanconf.py pelicanconf.py

COPY publishing/run_server.sh run_server.sh
RUN chmod 777 run_server.sh
COPY publishing/create_html_friendly_page.sh create_html_friendly_page.sh
RUN chmod 777 create_html_friendly_page.sh

CMD ["pelican", "--delete-output-directory", "content"]
67 changes: 67 additions & 0 deletions publishing/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh

# Typical flows:
#
# 1. The first workflow will generate the desired website, landing
# the end contents in the local "output/" directory. This is the
# equivalent of running `pelican --delete-output-directory content`
# from a properly instantantiated environment.
#
# $ make build && make generate-website && make host-content
#
# Then, visit "http://127.0.0.1:8000/blog" from a browser to verify.
#
# 2. This workflow will generate the desired email template, landing
# the end contents in the local "output/" directory. This is the
# equivalent of running `TWIR_NEWSLETTER_THEME=1 pelican --delete-output-directory content`
# from a properly instantantiated environment.
#
# $ make build && make generate-email && make host-content
#
# Then, visit "http://127.0.0.1:8000/blog" from a browser to verify.
# Once verified, one can adjust the "BLOG_DOWNLOAD" variable below, and
# create an email-friendly HTML version of the "BLOG_DOWNLOAD" page.
# This is the equivalent of running `juice --web-resources-images false /tmp/in.html /tmp/out.html`
#
# $ make optimize-email
#
# This results in the desired email-friendly HTML version: "juice/out.html".

# CHANGE ME! vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
BLOG_DOWNLOAD=http://127.0.0.1:8000/blog/2022/08/10/this-week-in-rust-455/

build:
cd .. && docker build -t twir -f publishing/Dockerfile . && cd -

clean:
rm -rf output/

generate-website: clean
docker run -it \
-v $(shell pwd)/output:/usr/twir/output \
twir:latest

generate-email: clean
docker run -it \
-e TWIR_NEWSLETTER_THEME=1 \
-v $(shell pwd)/output:/usr/twir/output \
twir:latest

host-content:
docker run -it \
-p 8000:8000 \
-v $(shell pwd)/output:/usr/twir/output:ro \
-it \
twir:latest \
bash run_server.sh

optimize-email:
@echo -n "Is this '${BLOG_DOWNLOAD}' your desired blog? [y/N] " && read ans && [ $${ans:-N} = y ]
rm -rf juice
mkdir juice
curl ${BLOG_DOWNLOAD} > juice/in.html
docker run \
-v $(shell pwd)/juice:/usr/twir/juice \
-e BLOG_DOWNLOAD=${BLOG_DOWNLOAD} \
twir:latest \
bash create_html_friendly_page.sh
4 changes: 4 additions & 0 deletions publishing/create_html_friendly_page.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

juice --web-resources-images false juice/in.html juice/out.html
rm juice/in.html
4 changes: 4 additions & 0 deletions publishing/run_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

cd output
python3 -m http.server
9 changes: 5 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Markdown==3.3.6
pelican==4.7.1
feedgenerator==2.0
pelican-webassets==2.0.0
cssmin==0.2.0
feedgenerator==2.0
jinja2==2.11.3
libsass==0.21.0
Markdown==3.3.6
markupsafe==2.0.1
pelican==4.7.1
pelican-webassets==2.0.0