Skip to content

Adding improvements for publishing automation #3550

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 1 commit into from
Aug 18, 2022
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
6 changes: 2 additions & 4 deletions publishing/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ 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
COPY publishing/*.sh .
RUN chmod 777 *.sh

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

# TODO: Make sure running from latest "main" branch commit
# TODO: Remove `BLOG_DOWNLOAD` variable requirement. Adjust "email" logic to:
# - Run generate container
# - Curl website
# - Run HTML-friendly container

# Typical flows:
#
# 1. The first workflow will generate the desired website, landing
Expand All @@ -9,7 +15,7 @@
#
# $ make build && make generate-website && make host-content
#
# Then, visit "http://127.0.0.1:8000/blog" from a browser to verify.
# Then, visit the printed URL 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
Expand All @@ -18,18 +24,27 @@
#
# $ 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`
# Then, visit the printed URL from a browser to verify.
# Once verified, one can adjust the "BLOG_DOWNLOAD" variable below, and
# we can create an email-friendly HTML version of the latest Blog page.
# **While the above container is still running**, open another terminal.
# This is the equivalent of running
# `curl ${BLOG_DOWNLOAD} > juice/in.html && juice --web-resources-images false /juice/in.html /juice/out.html`
#
# $ make optimize-email
#
# This results in the desired email-friendly HTML version: "juice/out.html".

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

website-workflow: build clean generate-website host-content

email-workflow-1: build clean generate-email host-content
email-workflow-2: optimize-email

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

Expand Down Expand Up @@ -62,6 +77,5 @@ optimize-email:
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
9 changes: 9 additions & 0 deletions publishing/form_latest_url.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
LATEST_YEAR=$(ls output/blog/ | sort | tail -2 | head -1)
LATEST_MONTH=$(ls output/blog/${LATEST_YEAR} | sort | tail -1)
LATEST_DAY=$(ls output/blog/${LATEST_YEAR}/${LATEST_MONTH} | sort | tail -1)
LATEST_ISSUE=$(ls output/blog/${LATEST_YEAR}/${LATEST_MONTH}/${LATEST_DAY}/)
LATEST_BLOG_URL="http://127.0.0.1:8000/blog/${LATEST_YEAR}/${LATEST_MONTH}/${LATEST_DAY}/${LATEST_ISSUE}/"
YELLOW_FONT='\033[1;32m'
CYAN_FONT='\033[0;36m'
PURPLE_FONT='\033[1;35m'
NC='\033[0m' # No Color
12 changes: 12 additions & 0 deletions publishing/run_server.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
#!/bin/sh

source form_latest_url.sh

printf "\n\n${CYAN_FONT}*****${PURPLE_FONT}*****${CYAN_FONT}*****${PURPLE_FONT}*****${NC}"
printf "\n${CYAN_FONT}*****${PURPLE_FONT}*****${CYAN_FONT}*****${PURPLE_FONT}*****${NC}"
printf "\n${CYAN_FONT}*****${PURPLE_FONT}*****${CYAN_FONT}*****${PURPLE_FONT}*****${NC}"
printf "\nHEY TWiR PUBLISHER..."
printf "\nLatest blog found at: ${YELLOW_FONT}'${LATEST_BLOG_URL}'${NC}"
printf "\nIf publishing for email, copy the blog into the ${YELLOW_FONT}BLOG_DOWNLOAD${NC} variable in the Makefile!"
printf "\n${CYAN_FONT}*****${PURPLE_FONT}*****${CYAN_FONT}*****${PURPLE_FONT}*****${NC}"
printf "\n${CYAN_FONT}*****${PURPLE_FONT}*****${CYAN_FONT}*****${PURPLE_FONT}*****${NC}"
printf "\n${CYAN_FONT}*****${PURPLE_FONT}*****${CYAN_FONT}*****${PURPLE_FONT}*****${NC}\n\n"

cd output
python3 -m http.server