|
1 | 1 | #!/bin/sh |
2 | 2 |
|
3 | 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 | 4 |
|
9 | 5 | # Typical flows: |
10 | | -# |
11 | | -# 1. The first workflow will generate the desired website, landing |
12 | | -# the end contents in the local "output/" directory. This is the |
| 6 | +# |
| 7 | +# 1. `make website` |
| 8 | +# The first workflow will generate the desired website, landing |
| 9 | +# the end contents in the local "output-website/" directory. This is the |
13 | 10 | # equivalent of running `pelican --delete-output-directory content` |
14 | 11 | # from a properly instantantiated environment. |
15 | 12 | # |
16 | | -# $ make build && make generate-website && make host-content |
17 | | -# |
| 13 | +# $ generate-website host-website |
| 14 | +# |
18 | 15 | # Then, visit the printed URL from a browser to verify. |
19 | | -# |
20 | | -# 2. This workflow will generate the desired email template, landing |
21 | | -# the end contents in the local "output/" directory. This is the |
| 16 | +# |
| 17 | +# Output: `output-website/` |
| 18 | +# |
| 19 | +# 2. `make copy-website-contents` |
| 20 | +# This workflow will sync the `output-website/` directory from above, and sync |
| 21 | +# it with the directory passed to it. Used for syncing state with |
| 22 | +# this-week-in-rust.github.io repo. |
| 23 | +# |
| 24 | +# 3. `make email` |
| 25 | +# This workflow will generate the desired email template, landing |
| 26 | +# the end contents in the local "email/" directory. This is the |
22 | 27 | # equivalent of running `USE_EMAIL_THEME=1 pelican --delete-output-directory content` |
23 | | -# from a properly instantantiated environment. |
| 28 | +# from a properly instantantiated environment, and running |
| 29 | +# `juice --web-resources-images false /juice/in.html /juice/out.html` on the latest content post. |
24 | 30 | # |
25 | | -# $ make build && make generate-email && make host-content |
| 31 | +# $ build clean generate-email optimize-email |
26 | 32 | # |
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` |
33 | | -# |
34 | | -# $ make optimize-email |
| 33 | +# Output: `email/<NUMBER>-<YEAR>-<MONTH>-<DAY>-email.html` |
35 | 34 | # |
36 | | -# This results in the desired email-friendly HTML version: "juice/out.html". |
37 | | - |
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... |
40 | | -# CHANGE ME! vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv |
41 | | -BLOG_DOWNLOAD=http://localhost:8000/blog/2024/09/04/this-week-in-rust-563/ |
42 | 35 |
|
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 |
| 36 | +website: generate-website host-website |
| 37 | +copy-website-contents: |
| 38 | + @./copy_website_content_to_repo.sh |
| 39 | +email: generate-email optimize-email |
47 | 40 |
|
48 | 41 | build: |
49 | 42 | cd .. && docker build -t twir -f publishing/Dockerfile . && cd - |
50 | 43 |
|
51 | | -clean: |
52 | | - rm -rf output/ |
| 44 | +clean-website: |
| 45 | + @rm -rf output/ && rm -rf output-website/ && rm -rf juice/ |
| 46 | +clean-email: |
| 47 | + @rm -rf output/ && rm -rf output-email-format/ && rm -rf email/ && rm -rf juice/ |
53 | 48 |
|
54 | | -generate-website: clean |
55 | | - docker run -it \ |
56 | | - -v $(shell pwd)/output:/usr/twir/output \ |
| 49 | +generate-website: build clean-website |
| 50 | + @echo "Generating website..." |
| 51 | + @docker run -it \ |
| 52 | + -v $(shell pwd)/output-website:/usr/twir/output \ |
57 | 53 | twir:latest |
| 54 | + @echo "Finished generating website." |
58 | 55 |
|
59 | | -generate-email: clean |
60 | | - docker run -it \ |
61 | | - -e USE_EMAIL_THEME=1 \ |
62 | | - -v $(shell pwd)/output:/usr/twir/output \ |
63 | | - twir:latest |
64 | | - |
65 | | -host-content: |
66 | | - docker run -it \ |
| 56 | +host-website: |
| 57 | + @echo "Hosting website..." |
| 58 | + @docker run -it \ |
67 | 59 | -p 8000:8000 \ |
68 | | - -v $(shell pwd)/output:/usr/twir/output:ro \ |
| 60 | + -v $(shell pwd)/output-website:/usr/twir/output:ro \ |
69 | 61 | -it \ |
70 | 62 | twir:latest \ |
71 | 63 | bash run_server.sh |
| 64 | + @echo "Finished hosting website." |
| 65 | + @echo "" |
| 66 | + @echo "To sync contents with your local 'this-week-in-rust.github.io' repo, run \033[1;33m'make copy-website-contents'\033[0m" |
| 67 | + |
| 68 | +generate-email: build clean-email |
| 69 | + @echo "Generating email..." |
| 70 | + @docker run -it \ |
| 71 | + -e USE_EMAIL_THEME=1 \ |
| 72 | + -v $(shell pwd)/output-email-format:/usr/twir/output \ |
| 73 | + twir:latest |
72 | 74 |
|
73 | 75 | optimize-email: |
74 | | - @echo -n "Is this '${BLOG_DOWNLOAD}' your desired blog? [y/N] " && read ans && [ $${ans:-N} = y ] |
75 | | - rm -rf juice |
76 | | - mkdir juice |
77 | | - curl ${BLOG_DOWNLOAD} > juice/in.html |
78 | | - docker run \ |
79 | | - -v $(shell pwd)/juice:/usr/twir/juice \ |
80 | | - twir:latest \ |
81 | | - bash create_html_friendly_page.sh |
| 76 | + @echo "Generating optimized email..." |
| 77 | + @OUTPUT_PREFIX=output-email-format ./create_optimized_email.sh |
0 commit comments