Skip to content
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
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,21 @@ Use the included `new_contribs.sh` script:

## Building

To ensure consistency across development setups, we use a [Docker](https://www.docker.com) container-based
workflow for building the website and email newsletter. Similarly, we use a `makefile` to ensure you have Docker installed on your system if
you intend to build the website or email newsletter.
To ensure consistency across development setups, we use a
[Docker](https://www.docker.com) container-based workflow for building the
website and email newsletter. Similarly, we use [Just](https://just.systems/) to
ensure you have Docker installed on your system if you intend to build the
website or email newsletter.

### Install Just

To install Just you have
[many options](https://just.systems/man/en/packages.html); we recommend using
Cargo:

```sh
cargo install just
```

### Building the website

Expand All @@ -207,7 +219,7 @@ cd publishing
- Run the Docker build and website local-host command:

```sh
make website
just website
```

- View the website locally at default
Expand Down Expand Up @@ -237,7 +249,7 @@ cd publishing
- Run the Docker build and website local-host command:

```sh
make email
just email
```

- View the email newsletter formatting of specific posts at
Expand Down
4 changes: 2 additions & 2 deletions publishing/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.8.16-slim

# Must run from base `twir` directory... Makefile takes care of this.
# Must run from base `twir` directory... justfile takes care of this.
WORKDIR /usr/twir

# Install deps and set locales
Expand Down Expand Up @@ -35,7 +35,7 @@ COPY plugins plugins
COPY themes themes
COPY pelicanconf.py pelicanconf.py

# make build && make generate-website && make host-website needs these scripts
# just website && just email needs these scripts
COPY publishing/*.sh .
RUN chmod +x *.sh

Expand Down
63 changes: 40 additions & 23 deletions publishing/Makefile → publishing/justfile
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/bin/sh

# This Week in Rust - Publishing Tools
# TODO: Make sure running from latest "main" branch commit

# Show available recipes
help:
@just --list

# Typical flows:
#
# 1. `make website`
# 1. `just website`
# The first workflow will generate the desired website, landing
# the end contents in the local "output-website/" directory. This is the
# the end contents in the local "output-website/" directory. This is the
# equivalent of running `pelican --delete-output-directory content`
# from a properly instantantiated environment.
#
Expand All @@ -16,62 +19,76 @@
#
# Output: `output-website/`
#
# 2. `make copy-website-contents`
# 2. `just copy-website-contents`
# This workflow will sync the `output-website/` directory from above, and sync
# it with the directory passed to it. Used for syncing state with
# this-week-in-rust.github.io repo.
#
# 3. `make email`
# 3. `just email`
# This workflow will generate the desired email template, landing
# the end contents in the local "email/" directory. This is the
# the end contents in the local "email/" directory. This is the
# equivalent of running `USE_EMAIL_THEME=1 pelican --delete-output-directory content`
# from a properly instantantiated environment, and running
# `juice --web-resources-images false /juice/in.html /juice/out.html` on the latest content post.
#
#
# $ build clean generate-email optimize-email
#
# Output: `email/<NUMBER>-<YEAR>-<MONTH>-<DAY>-email.html`
#

# Generate and host website locally
website: generate-website host-website

# Copy website contents to this-week-in-rust.github.io repo
copy-website-contents:
@./copy_website_content_to_repo.sh
./copy_website_content_to_repo.sh

# Generate and optimize email template
email: generate-email optimize-email

build:
# Build Docker image
docker-build:
cd .. && docker build -t twir -f publishing/Dockerfile . && cd -

# Clean website output directories
clean-website:
@rm -rf output/ && rm -rf output-website/ && rm -rf juice/
rm -rf output/ output-website/ juice/

# Clean email output directories
clean-email:
@rm -rf output/ && rm -rf output-email-format/ && rm -rf email/ && rm -rf juice/
rm -rf output/ output-email-format/ email/ juice/

generate-website: build clean-website
# Generate website content
generate-website: docker-build clean-website
@echo "Generating website..."
@docker run -it \
-v $(shell pwd)/output-website:/usr/twir/output \
twir:latest
docker run -it \
-v {{justfile_directory()}}/output-website:/usr/twir/output \
twir:latest
@echo "Finished generating website."

# Host website locally on port 8000
host-website:
@echo "Hosting website..."
@docker run -it \
docker run -it \
-p 8000:8000 \
-v $(shell pwd)/output-website:/usr/twir/output:ro \
-v {{justfile_directory()}}/output-website:/usr/twir/output:ro \
-it \
twir:latest \
bash run_server.sh
@echo "Finished hosting website."
@echo ""
@echo "To sync contents with your local 'this-week-in-rust.github.io' repo, run \033[1;33m'make copy-website-contents'\033[0m"
@echo "To sync contents with your local 'this-week-in-rust.github.io' repo, run 'just copy-website-contents'"

generate-email: build clean-email
# Generate email content
generate-email: docker-build clean-email
@echo "Generating email..."
@docker run -it \
mkdir -p output-email-format
docker run -it \
-e USE_EMAIL_THEME=1 \
-v $(shell pwd)/output-email-format:/usr/twir/output \
-v {{justfile_directory()}}/output-email-format:/usr/twir/output \
twir:latest

# Optimize email HTML for delivery
optimize-email:
@echo "Generating optimized email..."
@OUTPUT_PREFIX=output-email-format ./create_optimized_email.sh
OUTPUT_PREFIX=output-email-format ./create_optimized_email.sh