Skip to content

Commit 902be92

Browse files
authored
Merge pull request #3550 from andrewpollack/upgrade-publishing
Adding improvements for publishing automation
2 parents 23b7a6d + 66b1809 commit 902be92

File tree

4 files changed

+43
-10
lines changed

4 files changed

+43
-10
lines changed

publishing/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ COPY plugins plugins
2626
COPY themes themes
2727
COPY pelicanconf.py pelicanconf.py
2828

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
29+
COPY publishing/*.sh .
30+
RUN chmod 777 *.sh
3331

3432
CMD ["pelican", "--delete-output-directory", "content"]

publishing/Makefile

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/sh
22

3+
# TODO: Make sure running from latest "main" branch commit
4+
# TODO: Remove `BLOG_DOWNLOAD` variable requirement. Adjust "email" logic to:
5+
# - Run generate container
6+
# - Curl website
7+
# - Run HTML-friendly container
8+
39
# Typical flows:
410
#
511
# 1. The first workflow will generate the desired website, landing
@@ -9,7 +15,7 @@
915
#
1016
# $ make build && make generate-website && make host-content
1117
#
12-
# Then, visit "http://127.0.0.1:8000/blog" from a browser to verify.
18+
# Then, visit the printed URL from a browser to verify.
1319
#
1420
# 2. This workflow will generate the desired email template, landing
1521
# the end contents in the local "output/" directory. This is the
@@ -18,18 +24,27 @@
1824
#
1925
# $ make build && make generate-email && make host-content
2026
#
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`
27+
# Then, visit the printed URL from a browser to verify.
28+
# Once verified, one can adjust the "BLOG_DOWNLOAD" variable below, and
29+
# we can create an email-friendly HTML version of the latest Blog page.
30+
# **While the above container is still running**, open another terminal.
31+
# This is the equivalent of running
32+
# `curl ${BLOG_DOWNLOAD} > juice/in.html && juice --web-resources-images false /juice/in.html /juice/out.html`
2533
#
2634
# $ make optimize-email
2735
#
2836
# This results in the desired email-friendly HTML version: "juice/out.html".
2937

38+
# TODO: The BLOG_DOWNLOAD is only needed because one dockerfile will have to communicate
39+
# with another, and I don't want to deal with building out the networking logic... yet...
3040
# CHANGE ME! vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
3141
BLOG_DOWNLOAD=http://127.0.0.1:8000/blog/2022/08/10/this-week-in-rust-455/
3242

43+
website-workflow: build clean generate-website host-content
44+
45+
email-workflow-1: build clean generate-email host-content
46+
email-workflow-2: optimize-email
47+
3348
build:
3449
cd .. && docker build -t twir -f publishing/Dockerfile . && cd -
3550

@@ -62,6 +77,5 @@ optimize-email:
6277
curl ${BLOG_DOWNLOAD} > juice/in.html
6378
docker run \
6479
-v $(shell pwd)/juice:/usr/twir/juice \
65-
-e BLOG_DOWNLOAD=${BLOG_DOWNLOAD} \
6680
twir:latest \
6781
bash create_html_friendly_page.sh

publishing/form_latest_url.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
LATEST_YEAR=$(ls output/blog/ | sort | tail -2 | head -1)
2+
LATEST_MONTH=$(ls output/blog/${LATEST_YEAR} | sort | tail -1)
3+
LATEST_DAY=$(ls output/blog/${LATEST_YEAR}/${LATEST_MONTH} | sort | tail -1)
4+
LATEST_ISSUE=$(ls output/blog/${LATEST_YEAR}/${LATEST_MONTH}/${LATEST_DAY}/)
5+
LATEST_BLOG_URL="http://127.0.0.1:8000/blog/${LATEST_YEAR}/${LATEST_MONTH}/${LATEST_DAY}/${LATEST_ISSUE}/"
6+
YELLOW_FONT='\033[1;32m'
7+
CYAN_FONT='\033[0;36m'
8+
PURPLE_FONT='\033[1;35m'
9+
NC='\033[0m' # No Color

publishing/run_server.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
#!/bin/sh
22

3+
source form_latest_url.sh
4+
5+
printf "\n\n${CYAN_FONT}*****${PURPLE_FONT}*****${CYAN_FONT}*****${PURPLE_FONT}*****${NC}"
6+
printf "\n${CYAN_FONT}*****${PURPLE_FONT}*****${CYAN_FONT}*****${PURPLE_FONT}*****${NC}"
7+
printf "\n${CYAN_FONT}*****${PURPLE_FONT}*****${CYAN_FONT}*****${PURPLE_FONT}*****${NC}"
8+
printf "\nHEY TWiR PUBLISHER..."
9+
printf "\nLatest blog found at: ${YELLOW_FONT}'${LATEST_BLOG_URL}'${NC}"
10+
printf "\nIf publishing for email, copy the blog into the ${YELLOW_FONT}BLOG_DOWNLOAD${NC} variable in the Makefile!"
11+
printf "\n${CYAN_FONT}*****${PURPLE_FONT}*****${CYAN_FONT}*****${PURPLE_FONT}*****${NC}"
12+
printf "\n${CYAN_FONT}*****${PURPLE_FONT}*****${CYAN_FONT}*****${PURPLE_FONT}*****${NC}"
13+
printf "\n${CYAN_FONT}*****${PURPLE_FONT}*****${CYAN_FONT}*****${PURPLE_FONT}*****${NC}\n\n"
14+
315
cd output
416
python3 -m http.server

0 commit comments

Comments
 (0)