|
| 1 | +# kpc-sponsorship |
| 2 | + |
| 3 | +Creates a [Kiwi PyCon](https://kiwipycon.nz/) sponsorship prospectus and material specs |
| 4 | +documents for different sponsorship tiers in PDF format. |
| 5 | + |
| 6 | +The main branch has a year tag for the version that is/was used for that particular |
| 7 | +year's conference, like |
| 8 | +"[2025](https://github.com/pythonnz/kpc-sponsorship/releases/tag/2025)". |
| 9 | + |
| 10 | +## Requirements |
| 11 | + |
| 12 | +- [Roboto fonts](https://fonts.google.com/specimen/Roboto) - the font we use |
| 13 | +- [Jinja2](https://jinja.palletsprojects.com/en/stable/) (>=3.1.3) - to render the SVG |
| 14 | + templates |
| 15 | +- [Inkscape](https://inkscape.org/) - to convert SVG to PDF |
| 16 | +- [pypdf](https://pypdf.readthedocs.io/en/stable/index.html) (>=4.3.1) - to assemble PDF |
| 17 | + pages to a document |
| 18 | +- [Ghostscript](https://www.ghostscript.com/) - for PDF compression |
| 19 | + |
| 20 | +``` |
| 21 | +sudo apt install fonts-roboto |
| 22 | +sudo apt install python3-jinja2 |
| 23 | +sudo apt install inkscape |
| 24 | +sudo apt install python3-pypdf |
| 25 | +sudo apt install ghostscript |
| 26 | +``` |
| 27 | + |
| 28 | +The two Python dependencies can also be installed with pip: |
| 29 | + |
| 30 | +``` |
| 31 | +pip install -r requirements.txt |
| 32 | +``` |
| 33 | + |
| 34 | +The requirements file installs at least the versions that currently get installed by the |
| 35 | +above system packages on Ubuntu 24.10. |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +Generate all documents with: |
| 40 | + |
| 41 | +``` |
| 42 | +python3 -m generate |
| 43 | +``` |
| 44 | + |
| 45 | +This will create a `build/` directory and a `dist/` directory (both ignored by git).<br> |
| 46 | +It will produce your PDF files in the `dist/` directory (and leave some artifacts in the |
| 47 | +`build/` directory, mainly for debugging). |
| 48 | + |
| 49 | +## Structure and Workflow |
| 50 | + |
| 51 | +A total of 6 documents are generated: |
| 52 | + |
| 53 | +- Sponsorship Prospectus |
| 54 | +- Material Specs - Diamond |
| 55 | +- Material Specs - Platinum |
| 56 | +- Material Specs - Gold |
| 57 | +- Material Specs - Silver |
| 58 | +- Material Specs - Bronze |
| 59 | + |
| 60 | +A **document** is made up of **pages**.<br> Pages take their layout from **templates**, |
| 61 | +and their specific content from your **configuration**. They may also include |
| 62 | +**images**. |
| 63 | + |
| 64 | +- `templates/`<br> contains `.svg.j2` files describing the layout of a page. These are |
| 65 | + Jinja2 templates which are used to render pages in SVG format, which then gets |
| 66 | + transformed into PDF.<br> They contain placeholders for text and images.<br> You only |
| 67 | + need to work with these files if you want to make fundamental layout or branding |
| 68 | + changes. |
| 69 | + |
| 70 | +- `pages/`<br> contains one `.yml` file for each page of a document. These files |
| 71 | + describe which template to use, which image files (if any) should be used in its |
| 72 | + template, and they also define content which generally doesn't need to be |
| 73 | + configurable.<br> You only need to work with these files if you want to change text |
| 74 | + that is usually fixed, or if you want to change which images are used. |
| 75 | + |
| 76 | +- `images/`<br> contains the actual image files referenced in the `.yml` files for |
| 77 | + pages. |
| 78 | + |
| 79 | +- `config/`<br> contains the configuration of all documents. It describes which pages |
| 80 | + make up a document and in which order, and what specific content to insert. Common |
| 81 | + configuration is in `common.yml`, document-specific configuration in their respective |
| 82 | + files.<br> You will at the very least need to to adjust the year for your next |
| 83 | + conference in `common.yml`. |
| 84 | + |
| 85 | +- `generate/`<br> Contains the code for generating documents.<br> The main entry point |
| 86 | + for invoking the generator is in `__main__.py`. Common functionality is in |
| 87 | + `common.py`. Helper functions for rendering the SVGs with Jinja are in `render.py`. |
| 88 | + Each document gets its own separate module under `documents/`.<br> Documents are |
| 89 | + generated using the above framework. A top-level `build/` working directory and a |
| 90 | + `dist/` directory for the final results will be created. If they already exist they |
| 91 | + will be wiped clean.<br> In the `build/` directory, it will create individual `.svg` |
| 92 | + files for each page, convert them to `.pdf` files, and then combine them into a single |
| 93 | + `.pdf` file for each document and place them in the `dist/` directory. The prospectus |
| 94 | + PDF will also be compressed. |
| 95 | + |
| 96 | +Note: You need to follow a consistent naming convention. |
| 97 | +`generate/documents/prospectus.py` will be given the combined configuration of |
| 98 | +`config/common.yml` and `config/prospectus.yml`. It will take its pages from |
| 99 | +`pages/prospectus/`. Do the same for any new documents you may add. |
| 100 | + |
| 101 | +## Development |
| 102 | + |
| 103 | +Your changes will be rejected by github if the linters throw warnings. You should |
| 104 | +install [pre-commmit](https://pre-commit.com) and run |
| 105 | + |
| 106 | +``` |
| 107 | +pre-commit install |
| 108 | +``` |
| 109 | + |
| 110 | +inside your repo. This will ensure you run the same checks as github every time you |
| 111 | +commit. |
| 112 | + |
| 113 | +## Known Issues |
| 114 | + |
| 115 | +See [Github Issues](https://github.com/pythonnz/kpc-sponsorship/issues) for known |
| 116 | +issues. |
0 commit comments