diff --git a/README.md b/README.md index 7861033..4cee553 100644 --- a/README.md +++ b/README.md @@ -7,42 +7,46 @@ Fediverse Fanzine For template engine [bash-tpl](https://github.com/TekWizely/bash-tpl) is used. Bash-tpl template engine allows for bash injections into templates. I hope that most of options required are displayed in the example, since I have no idea what kind of design is coveted for fedizine. Templating is split into 3 stages. -0. Template and files preparation -1. Template script generation +0. Template and structure preparation +1. Data population 2. Template population -### Template and files preparation -As an example a file [fedizine_template_example.html](fedizine_template_example.html) is provided. For now there's nothing fancy, it is just a modified index.html page. +### 0. Template and structure preparation +Curently there are two monthly templates: [fedizine_monthly_template.html](fedizine_monthly_template.html) and [fedizine_monthly_template.md](fedizine_monthly_template.md). Those desribe a montly edition of fedizine. -The template expects a folder named "contestants" in the same directory as itself. Contestants folder would hold a bunch of other directories, one per contestant. Names of those folders are not used in templating, but imagine you'd want something readable. +First action to be done is to call `generate_templates.sh`. -Every contestant folder should contain a `bio.txt` file. File's full name would be `contestants\%some_folder%\bio.txt`. - -Such file should have following lines in following order: -1. Contestant name -2. Contestant bio written in a single line (no line breaks allowed); sorry it is scuffed for the first version -3. A line describing an artwork -4. A line describing an artwork -5. A line describint an artwork -6. .... - -An amount of artworks isn't actually limited to just two. -`A line describing an artwork` would be broken up by `"` delimiter. Which means it sould look somewhat like this: `"ref1.webp" "Short description" "Alt text"` -1. First entry is file name. **Note that the file not listed in bio.txt will not be displayed in the final html** -2. Second entry is short visible description. It will be written next to the file. -3. Third entry is the image alt text. - -### Template script generation -Once template file is sufficiently prepared, you can create a generation script with this command: ``` -./bash-tpl fedizie_template.html > fedizine_generate.sh && chmod +x fedizine_generate.sh +generate_templates.sh april 6 ``` -This script doesn't require `bash-tpl` or template file and can be transferred elsewhere at will. +`generate_templates.sh` expects two arguments: folder name and amount of contestants. +After calling the script folder `april` will be created with proper folder structure inside. There would be two template scripts and a `template_data` folder. + +**Note that running generate_templates.sh on an already created folder structure whould not destroy edits in generated files** + +### 1. Data population +After folder structure is created, head to `template_data` and edit `title.txt`. It contains overall data for this months edition of fedizine. +Next step is to descend into `contestants` folder. It contains folders named `contestant_1...n`. Each describes one of the fedizine authors. Note that you can rename those folders however you like. +Descend into `contestant_...` folder. It would contain a `bio.txt` which holds contestant name and small one liner description. Then it also contains two folders: `wholesome` and `lewd`. Wholesome folder should contain **SFW** works while lewd is designated for **NSFW**. + +Do not hesitate to leave folders open or delete them. I left checks in place. ### Template population -Once folder structure and data are prepared and template script is generated, put template script in the same directory where `contestants` folder would be and execute command: +Once all data put in it's respective places, run `generate_files.sh`. + ``` -./fedizine_generate.sh > generated.html +generate_files.sh april ``` -This will create `generated.html` file which should be served to the end user. \ No newline at end of file +This will parse `april` folder and create 4 files in `april`: +- fedizine.html +- fedizine.md +- fedizine-html.pdf +- fedizine-md.pdf + +fedizine.html - contains html template presumable for a web server +fedizine.md - contains markdown, used mainly for pdf generation +fedizine-html.pdf - a pdf file generated from fedizine.html +fedizine-md.pdf - a pdf file generated from fedizine.md + +**Note! Pandoc does not crunch .webp format. If any of the images are .webp, pdf generation WILL fail.** \ No newline at end of file diff --git a/contestants/contestant1/bio.txt b/contestants/contestant1/bio.txt deleted file mode 100644 index 1aea1d3..0000000 --- a/contestants/contestant1/bio.txt +++ /dev/null @@ -1,4 +0,0 @@ -Contestant name -Contestant bio written in a signle string without any line breaks. -ref1.webp"Short description" "Alt text" -ref2.webp"Short description 2" "Alt text 2" diff --git a/contestants/contestant1/ref1.webp b/contestants/contestant1/ref1.webp deleted file mode 100644 index 8970573..0000000 Binary files a/contestants/contestant1/ref1.webp and /dev/null differ diff --git a/contestants/contestant1/ref2.webp b/contestants/contestant1/ref2.webp deleted file mode 100644 index ba69643..0000000 Binary files a/contestants/contestant1/ref2.webp and /dev/null differ diff --git a/contestants/contestant2/bio.txt b/contestants/contestant2/bio.txt deleted file mode 100644 index 24a2661..0000000 --- a/contestants/contestant2/bio.txt +++ /dev/null @@ -1,4 +0,0 @@ -Contestant name -Contestant bio written in a signle string without any line breaks. -ref3.webp "Short description" "Alt text" -ref4.webp "Short description 2" "Alt text 2" diff --git a/contestants/contestant2/ref3.webp b/contestants/contestant2/ref3.webp deleted file mode 100644 index 6836fdb..0000000 Binary files a/contestants/contestant2/ref3.webp and /dev/null differ diff --git a/contestants/contestant2/ref4.webp b/contestants/contestant2/ref4.webp deleted file mode 100644 index 84eb67a..0000000 Binary files a/contestants/contestant2/ref4.webp and /dev/null differ diff --git a/fedizine_monthly_template.html b/fedizine_monthly_template.html new file mode 100644 index 0000000..18926be --- /dev/null +++ b/fedizine_monthly_template.html @@ -0,0 +1,98 @@ + + +% + TITLE_PATH="./template_data/title.txt" + readarray -t FEDIZINE_TITLE < ${TITLE_PATH} +% + + + + <% ${FEDIZINE_TITLE[0]} %> + + + +

<% ${FEDIZINE_TITLE[1]} %>

+

<% ${FEDIZINE_TITLE[2]} %>

+ +

This month submissions

+ % + CONTESTANT_DIR="./template_data/contestants" + CONTESTANT_DIRECTORY="./template_data/contestants/*" + if [ "$(ls -A $CONTESTANT_DIR)" ]; then + for CONTESTANT in $CONTESTANT_DIRECTORY + do + % +
+ % + CONTESTANT_BIO="${CONTESTANT}/bio.txt" + readarray -t CONTESTANT_DATA < ${CONTESTANT_BIO} + % +
+

<% ${CONTESTANT_DATA[0]} %>

+ <% ${CONTESTANT_DATA[1]} %> +
+ % + CONTESTANT_WHOLESOME_DIR="${CONTESTANT}/wholesome" + CONTESTANT_WHOLESOME_PATH="${CONTESTANT}/wholesome/*" + if [ -d "$CONTESTANT_WHOLESOME_DIR" ]; then + if [ "$(ls -A $CONTESTANT_WHOLESOME_DIR)" ]; then + for WHOLESOME_IMAGE in $CONTESTANT_WHOLESOME_PATH + do + % +
+ +
+ % + done + fi + fi + % +
+
+ % + CONTESTANT_LEWD_DIR="${CONTESTANT}/lewd" + CONTESTANT_LEWD_PATH="${CONTESTANT}/lewd/*" + if [ -d "$CONTESTANT_LEWD_DIR" ]; then + if [ "$(ls -A $CONTESTANT_LEWD_DIR)" ]; then + for LEWD_IMAGE in $CONTESTANT_LEWD_PATH + do + % +
+ +
+ % + done; + fi + fi + % +
+

+
+ % + done; + fi + % + +

Contact

+

Email: waifuism@tutanota.com
+ Misskey: @waifu@mai.waifuism.life

+ + + + diff --git a/fedizine_monthly_template.md b/fedizine_monthly_template.md new file mode 100644 index 0000000..4d71116 --- /dev/null +++ b/fedizine_monthly_template.md @@ -0,0 +1,55 @@ +% + TITLE_PATH="./template_data/title.txt" + readarray -t FEDIZINE_TITLE < ${TITLE_PATH} +% + +# <% ${FEDIZINE_TITLE[1]} %> +<% ${FEDIZINE_TITLE[2]} %> + +## This month submissions + +% + CONTESTANT_DIR="./template_data/contestants" + CONTESTANT_DIRECTORY="./template_data/contestants/*" + if [ "$(ls -A $CONTESTANT_DIR)" ]; then + for CONTESTANT in $CONTESTANT_DIRECTORY + do + CONTESTANT_BIO="${CONTESTANT}/bio.txt" + readarray -t CONTESTANT_DATA < ${CONTESTANT_BIO} +% + +### <% ${CONTESTANT_DATA[0]} %> +<% ${CONTESTANT_DATA[1]} %> + +% + CONTESTANT_WHOLESOME_DIR="${CONTESTANT}/wholesome" + CONTESTANT_WHOLESOME_PATH="${CONTESTANT}/wholesome/*" + if [ -d "$CONTESTANT_WHOLESOME_DIR" ]; then + if [ "$(ls -A $CONTESTANT_WHOLESOME_DIR)" ]; then + for WHOLESOME_IMAGE in $CONTESTANT_WHOLESOME_PATH + do +% +![wholesome](<% $WHOLESOME_IMAGE %>) +% + done; + fi + fi + CONTESTANT_LEWD_DIR="${CONTESTANT}/lewd" + CONTESTANT_LEWD_PATH="${CONTESTANT}/lewd/*" + if [ -d "$CONTESTANT_LEWD_DIR" ]; then + if [ "$(ls -A $CONTESTANT_LEWD_DIR)" ]; then + for LEWD_IMAGE in $CONTESTANT_LEWD_PATH + do +% +![lewd](<% $LEWD_IMAGE %>) +% + done; + fi + fi + done; + fi +% + +# Contact +**Email:** waifuism@tutanota.com +**Misskey:** [@waifu@mai.waifuism.life](https://mai.waifuism.life/@waifu) diff --git a/fedizine_template_example.html b/fedizine_template_example.html deleted file mode 100644 index 60f38a1..0000000 --- a/fedizine_template_example.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - Fedizine - A Fanzine on the Fediverse - - - -

Fedizine

-

A monthly multi‑page fanzine made on the fedi and for the fedi.

- -

How It Works

- -

Status

-

If you're interested in participating, reach out before starting to draw, and share your ideas. Release date is TBD, but you'll have a few weeks to work. More updates will be posted soon.

-

September Theme

-

A foxgirl milf Pleroma‑tan

- -

Attempt at making a template

- % - CONTESTANT_DIRECTORY="./contestants/*" - for CONTESTANT in $CONTESTANT_DIRECTORY - do - % -
- % - CONTESTANT_BIO="${CONTESTANT}/bio.txt" - readarray -t CONTESTANT_DATA < ${CONTESTANT_BIO} - % -
-

<% ${CONTESTANT_DATA[0]} %>

- <% ${CONTESTANT_DATA[1]} %> - % - CONTESTANT_DATA_LENGTH=${#CONTESTANT_DATA[@]} - for (( j=2; j<${CONTESTANT_DATA_LENGTH}; j++ )); - do - readarray -t IMAGE_LINES < <( sed -r 's/"+ *"?/\n/g' <<< ${CONTESTANT_DATA[$j]} | sed -r '/^\s*$/d' | sed -r '/^ +/d' ) - IMAGE_PATH="$CONTESTANT/${IMAGE_LINES[0]}" - IMAGE_ALT="${IMAGE_LINES[2]}" - IMAGE_DESCRIPTION="${IMAGE_LINES[1]}" - % -
- <% $IMAGE_ALT %> - <% $IMAGE_DESCRIPTION %> -
- % - done; - % -

-
- Reference 4 - % - done; - % - - -

Guidelines

- -

Attempts to get around these rules will be ignored.

- -

Specs

-

Page size: A4 (210 × 297 mm)
- Resolution: 300 ppi
- 2552 × 3578 px
- Preferred format: PNG

- -

Contact

-

Email: waifuism@tutanota.com
- Misskey: @waifu@mai.waifuism.life

- - - - diff --git a/generate_files.sh b/generate_files.sh new file mode 100755 index 0000000..d7c9bfb --- /dev/null +++ b/generate_files.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +FEDIZINE_DIR="$1" + +cd $FEDIZINE_DIR +./fedizine_html.sh > "fedizine.html" +./fedizine_md.sh > "fedizine.md" +pandoc fedizine.md -o fedizine-md.pdf +pandoc fedizine.html -o fedizine-html.pdf \ No newline at end of file diff --git a/generate_templates.sh b/generate_templates.sh new file mode 100755 index 0000000..c7caeb8 --- /dev/null +++ b/generate_templates.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +FEDIZINE_DIR="$1" +FEDIZINE_DATA_DIR="$FEDIZINE_DIR/template_data" +CONTESTANT_AMOUNT="$2" + +function dump_title +{ + DIR=$1 + + if [ -f "$DIR/title.txt" ]; then + echo "Title exists" + return; + fi + echo "Dumping $DIR/title.txt" + touch "$DIR/title.txt" + echo "Fedizine Title (html only)" >> "$DIR/title.txt" + echo "Fedizine Header" >> "$DIR/title.txt" + echo "Fedizine Prompt" >> "$DIR/title.txt" +} + +function dump_bio +{ + BIO_PATH=$1 + i=$2 + + + + BIO_FILE="$BIO_PATH/bio.txt" + if [ -f $BIO_FILE ]; then + echo "$BIO_FILE exists" + return; + fi + echo "Dumping $BIO_FILE" + touch "$BIO_FILE" + echo "Contestant $i" >> "$BIO_FILE" + echo "Contestant bio in single string" >> "$BIO_FILE" +} + +function create_templates +{ + TEMPLATE_PATH=$1 + HTML_TEMPLATE_FILE="fedizine_html.sh" + MD_TEMPLATE_FILE="fedizine_md.sh" + + echo "Creating templates" + ./bash-tpl fedizine_monthly_template.html > "$TEMPLATE_PATH/$HTML_TEMPLATE_FILE" && chmod +x "$TEMPLATE_PATH/$HTML_TEMPLATE_FILE" + ./bash-tpl fedizine_monthly_template.md > "$TEMPLATE_PATH/$MD_TEMPLATE_FILE" && chmod +x "$TEMPLATE_PATH/$MD_TEMPLATE_FILE" +} + + +echo "Creating $FEDIZINE_DATA_DIR" +mkdir $FEDIZINE_DATA_DIR -p +dump_title $FEDIZINE_DATA_DIR + +for ((i=1;i<=$CONTESTANT_AMOUNT;++i)) do + mkdir "$FEDIZINE_DATA_DIR/contestants/contestant_$i/wholesome" -p + mkdir "$FEDIZINE_DATA_DIR/contestants/contestant_$i/lewd" -p + dump_bio "$FEDIZINE_DATA_DIR/contestants/contestant_$i" $i +done + +create_templates $FEDIZINE_DIR +