Skip to content
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

GitHub actions fix #3

Merged
merged 11 commits into from
Jul 13, 2021
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
7 changes: 2 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:


build:
name: Publish binaries
name: Publish pdfs
runs-on: ubuntu-latest

steps:
Expand All @@ -22,13 +22,10 @@ jobs:
- name: Install LaTex
run: sudo apt-get install -y texlive-base texlive-xetex

- name: Install zip command
run: sudo apt-get install -y zip

- name: Run generate_release.sh
id: generate_release
run: |
./create_release.sh ${{ github.ref }}
source ./create_release.sh ${{ github.ref }}
echo "::set-output name=ZIP_NAME::$zipname"

# This step reads a file from repo and use it for body of the release
Expand Down
63 changes: 62 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,62 @@
# PrintablePaper
<div align="center">

<img src="https://raw.githubusercontent.com/twihno/PrintablePaper/main/branding/logo.svg" alt="PrintablePaper" width="500"/>


[![Release](https://img.shields.io/github/v/release/twihno/PrintablePaper)](https://github.com/twihno/PrintablePaper/releases)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/twihno/PrintablePaper/blob/main/LICENSE)
[![Compile](https://github.com/twihno/PrintablePaper/actions/workflows/compile.yml/badge.svg?branch=main)](https://github.com/twihno/PrintablePaper/actions/workflows/compile.yml)
[![Last Commit](https://img.shields.io/github/last-commit/twihno/PrintablePaper)](https://github.com/twihno/PrintablePaper/commits)
[![Open Issues](https://img.shields.io/github/issues-raw/twihno/PrintablePaper)](https://github.com/twihno/PrintablePaper/issues)

---

<div align="center">

[![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/twihno/PrintablePaper)

</div>


</div>

## About this project
The goal of this project is to deliver high quality and free to use print templates for various page sizes.

To achieve this goal it uses LaTex (XeLaTex) and Jinja2 which results in standard pdf files.

The pdf files are auto-generated and [released]((https://github.com/twihno/PrintablePaper/releases)) on GitHub.

## Contributing

Thank you for your interest! Everyone is invited to add their own templates.

The code was developed and tested on Ubuntu.
It should run on every Linux distribution with XeLaTex and Python 3 support.

### Project structure

Every template needs its own folder and three files:

- ```compile_template.py``` (this file generates the differnet latex files for the various page sizes)
- ```printablepaperlib.json``` (this file contains the name, the version and the supported paper sizes and orientations of the template)
- ```template.latex_template``` (this file contains the the latex (jinja template) file used to generate the pdf files)

When implementing a new template you can reference ```templates/din_a/graph_paper/5mm```

New templates are automatically picked up by the build process.

## Build scripts

### ```build.sh```
- (re)creates the output directory
- creates the paper libraries (paperlib.json) which includes the measurements of all available paper formats
- creates the pdf files by calling ```generate_pdf.py```

### ```create_release.sh```
- calls ```build.sh```
- creates the release notes/README file
- bundles the pdf files in a zip archive

### GitHub Actions
- used to compile and build the releases
118 changes: 118 additions & 0 deletions branding/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion create_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ print_return_value () {
# Create pdf files
echo -e "\n\e[32m\e[1m*** Run build.sh ***\e[0m"
./build.sh
build_return=$?
echo "--------------------"
print_return_value $?
echo "⬆ Run build.sh"
print_return_value $build_return

# Create release notes
echo -e "\n\e[32m\e[1m*** Create release notes ***\e[0m"
Expand All @@ -32,4 +34,7 @@ print_return_value $?
echo -e "\n\e[32m\e[1m*** Move zip file ***\e[0m"
mv "$zipname" ..
print_return_value $?
echo "Current path: $PWD"
echo "File: $zipname"
cd ..
echo "New path: $PWD"
6 changes: 0 additions & 6 deletions generate_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,17 @@ def generate_pdf_files():
last_subdir = ""

for subdir, dirs, files in os.walk(TEMPLATE_DIR):
#print("PATH", subdir, files, dirs)
#print("SUBDIR0", os.path.abspath(subdir))
for file in files:
#print("SUBDIR1", os.path.abspath(subdir))
ext = os.path.splitext(file)[-1].lower()
if ext == '.latex':
if last_subdir != subdir:
last_subdir = subdir
os.chdir(os.path.abspath(subdir))
#print("SUBDIR2", os.path.abspath(subdir))
for i in range(0, 2):
return_value = os.system("xelatex -interaction=batchmode --halt-on-error \"" +
str(file) + "\"")
if return_value != 0:
sys.exit(1)
#print("xelatex \"" +
#str(file) + "\"")


def move_pdf_files():
Expand Down
3 changes: 2 additions & 1 deletion generate_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
printablepaperlib_dict = json.load(j)
f.write(
"- {} (v{})\n".format(
printablepaperlib_dict["template_name"],
printablepaperlib_dict["template_name"].replace(
"_", "\\_"),
printablepaperlib_dict["version"]
))
5 changes: 3 additions & 2 deletions templates/din_a/create_din_a_paper_lib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Creates the metric paperlib.json"""
"""Creates the din a paperlib.json"""

import json
import math
Expand Down Expand Up @@ -26,7 +26,8 @@
"height": round(width_i, DIGITS),
"width": round(height_i, DIGITS),
},
"area": area_i
"area": area_i,
"displayname": "a" + str(i)
}

paperdict_json = json.dumps(paperdict, indent=4)
Expand Down
4 changes: 2 additions & 2 deletions templates/din_a/graph_paper/5mm/compile_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@

# printablepaperlib specific code

for page_size, page_size_name in parameters["page_sizes"]:
for page_size in parameters["page_sizes"]:
page_size_name = paperlib[page_size]["displayname"]
for orientation in parameters["orientations"]:
#print(page_size, page_size_name, orientation)
filename = "{}_{}_{}.latex".format(
parameters["template_name"],
page_size_name,
Expand Down
20 changes: 4 additions & 16 deletions templates/din_a/graph_paper/5mm/printablepaperlib.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,10 @@
"template_name": "graph_paper_5mm",
"version": "1.0.0",
"page_sizes": [
[
"a4paper",
"a4"
],
[
"a3paper",
"a3"
],
[
"a2paper",
"a2"
],
[
"a1paper",
"a1"
]
"a4paper",
"a3paper",
"a2paper",
"a1paper"
],
"orientations": [
"landscape",
Expand Down