first commit! template and generate!

master
km0 3 years ago
commit d221259ba4

BIN
.DS_Store vendored

Binary file not shown.

50
.gitignore vendored

@ -0,0 +1,50 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# Rope
.ropeproject
# Django stuff:
*.log
*.pot
# Sphinx documentation
docs/_build/

@ -0,0 +1,79 @@
# POST-IT GENERATOR
~~TO AUGMENT OUR PRODUCTIVITY HERE IS A SCRIPT THAT~~
Generate post-it blocks from markdown files.
## Install
Clone the repo
`git clone https://git.xpub.nl/kamo/postit-gen.git`
Move to the cloned folder
`cd postit-gen`
Create a virtual environment
`python3 -m venv venv`
and activate it
`. venv/bin/activate`
Then you can install the repo
`pip3 install -e .`
## How to use
The package offers two scripts: `template.py` and `generate.py`.
`template.py` generate a template folder with a markdown file that can be used as a starting point for formatting the contents.
`python3 template.py -f test`
Will generate a `test` folder, with the markdown template for the contents.
The `contents.md` file has these properties:
- `title`, the title of the block
- `folder`, the base folder in which the files are
- `page_width`, the width of the page for the printing
- `page_height`, the height of the page for the printing
- `post_width`, the width of the post-it for the printing
- `post_height`, the height of the post-it for the printing
- `margin`, the margin for the page
- `unit`, the measure unit in which the measures are expressed, default is _mm_
- `background`, the color of the post-its. Accept all the format CSS specs accept. Default is _white_.
- `contents`, a list of contents to put in the post-it block. Each entry is a post-it.
All these parameters are formatted in [YAML](https://it.wikipedia.org/wiki/YAML).
After setting all the parameters to match your needs, you can fill the contents. ATM you can insert text and images, in the form of a list.
```yaml
contents:
- A flat with no floors
- Hello, where are you, what can you see from there?
- type: image
src: game.png
```
Usually each entry of the list will be considered as a string. If you want to insert an image you will need to provide a `type: image`, and a `src: <filename>`.
In this way:
```yaml
contents:
- type: image
src: <filename>
```
Once you inserted your contents, you can run the `generate.py` script, specifying the working folder from which you want to take the contents.
`python3 generate.py -f test`
It will take the contents inside the `test` folder and will generate a ready-to-print HTML file, serving it with a simple http-server at `http://localhost:8000/test`. Opening that link you can preview your post-it blocks. Each entry of the `contents` list is now a page in the document (in the print mode!)
TODO: link css file in the template to work directly on the preview.

@ -0,0 +1,20 @@
---
background: white
folder: lootbox
margin: 5
page_height: 297
page_width: 210
post_height: 70
post_width: 70
title: What is a lottbox
unit: mm
contents:
- A loot box is a virtual box inside video games that provide a player with collectibles or essential items that make them progress inside the game.
- type: image
src: img.png
- It derives from the loot, a bunch of goodies that a player can get as a reward after they conquer-win a super boss or level up.
- But the loot box in its more recent and exploitative version is getting purchased with real money from a player.
- The player never knows what is inside of it.
- But they know that there is a chance of getting some items that they desire.
- Many times a loot box appear in the gameplay and it disappears quickly in order to be exclusive and make the player buy them without thinking too much.
---

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 KiB

@ -0,0 +1,650 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>document</title>
<style>
html,
body {
margin: 0;
font-size: 0;
font-family:arial, helvetica, sans-serif;
}
* {
box-sizing: border-box;
}
hr {
page-break-after: always;
visibility: hidden;
}
table {
padding: 0;
margin: 5mm;
border-collapse: collapse;
border: 1px dashed gray;
}
td {
border: 1px dashed gray;
width: 70mm;
height: 70mm;
padding: 0;
background-color: white;
}
td img {
width: 100%;
height: 100%;
object-fit: contain;
}
.cell {
font-size: 18px;
line-height: 1.6;
text-align: center;
padding: 5mm;
}
@page { size: auto; margin: 0mm; }
</style>
</head>
<body>
<table>
<tr>
<td>
<div class="cell">A loot box is a virtual box inside video games that provide a player with collectibles or essential items that make them progress inside the game.</div>
</td>
<td>
<div class="cell">A loot box is a virtual box inside video games that provide a player with collectibles or essential items that make them progress inside the game.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">A loot box is a virtual box inside video games that provide a player with collectibles or essential items that make them progress inside the game.</div>
</td>
<td>
<div class="cell">A loot box is a virtual box inside video games that provide a player with collectibles or essential items that make them progress inside the game.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">A loot box is a virtual box inside video games that provide a player with collectibles or essential items that make them progress inside the game.</div>
</td>
<td>
<div class="cell">A loot box is a virtual box inside video games that provide a player with collectibles or essential items that make them progress inside the game.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">A loot box is a virtual box inside video games that provide a player with collectibles or essential items that make them progress inside the game.</div>
</td>
<td>
<div class="cell">A loot box is a virtual box inside video games that provide a player with collectibles or essential items that make them progress inside the game.</div>
</td>
</tr>
</table>
<hr />
<table>
<tr>
<td>
<img src="img.png" />
</td>
<td>
<img src="img.png" />
</td>
</tr>
<tr>
<td>
<img src="img.png" />
</td>
<td>
<img src="img.png" />
</td>
</tr>
<tr>
<td>
<img src="img.png" />
</td>
<td>
<img src="img.png" />
</td>
</tr>
<tr>
<td>
<img src="img.png" />
</td>
<td>
<img src="img.png" />
</td>
</tr>
</table>
<hr />
<table>
<tr>
<td>
<div class="cell">It derives from the loot, a bunch of goodies that a player can get as a reward after they conquer-win a super boss or level up.</div>
</td>
<td>
<div class="cell">It derives from the loot, a bunch of goodies that a player can get as a reward after they conquer-win a super boss or level up.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">It derives from the loot, a bunch of goodies that a player can get as a reward after they conquer-win a super boss or level up.</div>
</td>
<td>
<div class="cell">It derives from the loot, a bunch of goodies that a player can get as a reward after they conquer-win a super boss or level up.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">It derives from the loot, a bunch of goodies that a player can get as a reward after they conquer-win a super boss or level up.</div>
</td>
<td>
<div class="cell">It derives from the loot, a bunch of goodies that a player can get as a reward after they conquer-win a super boss or level up.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">It derives from the loot, a bunch of goodies that a player can get as a reward after they conquer-win a super boss or level up.</div>
</td>
<td>
<div class="cell">It derives from the loot, a bunch of goodies that a player can get as a reward after they conquer-win a super boss or level up.</div>
</td>
</tr>
</table>
<hr />
<table>
<tr>
<td>
<div class="cell">But the loot box in its more recent and exploitative version is getting purchased with real money from a player.</div>
</td>
<td>
<div class="cell">But the loot box in its more recent and exploitative version is getting purchased with real money from a player.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">But the loot box in its more recent and exploitative version is getting purchased with real money from a player.</div>
</td>
<td>
<div class="cell">But the loot box in its more recent and exploitative version is getting purchased with real money from a player.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">But the loot box in its more recent and exploitative version is getting purchased with real money from a player.</div>
</td>
<td>
<div class="cell">But the loot box in its more recent and exploitative version is getting purchased with real money from a player.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">But the loot box in its more recent and exploitative version is getting purchased with real money from a player.</div>
</td>
<td>
<div class="cell">But the loot box in its more recent and exploitative version is getting purchased with real money from a player.</div>
</td>
</tr>
</table>
<hr />
<table>
<tr>
<td>
<div class="cell">The player never knows what is inside of it.</div>
</td>
<td>
<div class="cell">The player never knows what is inside of it.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">The player never knows what is inside of it.</div>
</td>
<td>
<div class="cell">The player never knows what is inside of it.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">The player never knows what is inside of it.</div>
</td>
<td>
<div class="cell">The player never knows what is inside of it.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">The player never knows what is inside of it.</div>
</td>
<td>
<div class="cell">The player never knows what is inside of it.</div>
</td>
</tr>
</table>
<hr />
<table>
<tr>
<td>
<div class="cell">But they know that there is a chance of getting some items that they desire.</div>
</td>
<td>
<div class="cell">But they know that there is a chance of getting some items that they desire.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">But they know that there is a chance of getting some items that they desire.</div>
</td>
<td>
<div class="cell">But they know that there is a chance of getting some items that they desire.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">But they know that there is a chance of getting some items that they desire.</div>
</td>
<td>
<div class="cell">But they know that there is a chance of getting some items that they desire.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">But they know that there is a chance of getting some items that they desire.</div>
</td>
<td>
<div class="cell">But they know that there is a chance of getting some items that they desire.</div>
</td>
</tr>
</table>
<hr />
<table>
<tr>
<td>
<div class="cell">Many times a loot box appear in the gameplay and it disappears quickly in order to be exclusive and make the player buy them without thinking too much.</div>
</td>
<td>
<div class="cell">Many times a loot box appear in the gameplay and it disappears quickly in order to be exclusive and make the player buy them without thinking too much.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">Many times a loot box appear in the gameplay and it disappears quickly in order to be exclusive and make the player buy them without thinking too much.</div>
</td>
<td>
<div class="cell">Many times a loot box appear in the gameplay and it disappears quickly in order to be exclusive and make the player buy them without thinking too much.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">Many times a loot box appear in the gameplay and it disappears quickly in order to be exclusive and make the player buy them without thinking too much.</div>
</td>
<td>
<div class="cell">Many times a loot box appear in the gameplay and it disappears quickly in order to be exclusive and make the player buy them without thinking too much.</div>
</td>
</tr>
<tr>
<td>
<div class="cell">Many times a loot box appear in the gameplay and it disappears quickly in order to be exclusive and make the player buy them without thinking too much.</div>
</td>
<td>
<div class="cell">Many times a loot box appear in the gameplay and it disappears quickly in order to be exclusive and make the player buy them without thinking too much.</div>
</td>
</tr>
</table>
<hr />
</body>
</html>

Binary file not shown.

@ -0,0 +1,27 @@
---
title: One sentence game ideas
folder: onesentencegames
page_width: 210
page_height: 297
post_width: 100
post_height: 100
margin: 5
unit: mm
background: springgreen;
contents:
- type: image
src: goose.png
- you are in an empty room with 13 doors that are portals to 13 different worlds.
- 5 min slow-mo epidemics, visual transmitted
- every crisis is a simulation of another crisis / every crisis is a preparation for another crisis
- you receive a point for each moving/floating tile on the street you encounter
- you sleep and the more you sleep, the more the buildings around the bedroom collapse and the nature starts growing and invading the space
- thermoSTATE - The state where no citizen has to feel cold
- The same day is looping over and over, the goal is to figure out which decision will make you move on to the next day.
- A flat with no floors
- type: image
src: snake.png
- Hello, where are you, what can you see from there?
- you give a gift to someone else, that person gives another gift to someone else
- you meet a person in a corridor, but you're in a supermarket, in Canada<3:D
---

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 KiB

BIN
postit/.DS_Store vendored

Binary file not shown.

@ -0,0 +1,83 @@
from jinja2 import Environment, PackageLoader, select_autoescape
import frontmatter
from math import floor
import sys, getopt
import http.server
import socketserver
def main(argv):
# parse argument from commandline
folder = ''
try:
opts, args = getopt.getopt(argv,"hf:",["folder="])
except getopt.GetoptError:
print('generate.py -f <folder>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('generate.py -f <folder>')
sys.exit()
elif opt in ("-f", "--folder"):
folder = arg
# read the contents
with open(f"{folder}/contents.md", "r") as f:
metadata, body = frontmatter.parse(f.read())
contents = metadata['contents']
page = {
'folder': folder,
'post_width': 50,
'post_height': 50,
'page_width': 210,
'page_height': 297,
'background': 'white',
'margin': 5,
'unit': 'mm'
}
page.update(metadata)
page['rows']= floor((page['page_height'] - 2 * page['margin']) / page['post_height'])
page['cols']= floor((page['page_width']- 2 * page['margin']) / page['post_width'])
# generate the template
env = Environment(
loader=PackageLoader("postit"),
autoescape=select_autoescape()
)
template = env.get_template('table.html')
render = template.render(contents=contents, page=page)
with open(f'{folder}/index.html', 'w') as output:
output.write(render)
PORT = 8000
handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), handler) as httpd:
print(f"Server started at http://localhost:{str(PORT)}/{folder}")
httpd.serve_forever()
if __name__ == "__main__":
main(sys.argv[1:])

@ -0,0 +1,49 @@
import frontmatter, os, sys, getopt
from io import BytesIO
def main(argv):
folder = ''
try:
opts, args = getopt.getopt(argv,"hf:",["folder="])
except getopt.GetoptError:
print('template.py -f <folder>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('template.py -f <folder>')
sys.exit()
elif opt in ("-f", "--folder"):
folder = arg
try:
os.makedirs(folder)
except OSError:
pass
with open(f"{folder}/contents.md", "w") as file:
metadata = {
'folder': folder,
'title': '',
'post_width': 75,
'post_height': 75,
'page_width': 210,
'page_height': 297,
'background': 'white',
'margin': 5,
'unit': 'mm',
'contents': ''
}
page = frontmatter.Post('', **metadata)
file.write(frontmatter.dumps(page))
if __name__ == "__main__":
main(sys.argv[1:])

@ -0,0 +1,83 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>document</title>
<style>
html,
body {
margin: 0;
font-size: 0;
font-family:arial, helvetica, sans-serif;
}
* {
box-sizing: border-box;
}
hr {
page-break-after: always;
visibility: hidden;
}
table {
padding: 0;
margin: {{page['margin']}}{{page['unit']}};
border-collapse: collapse;
border: 1px dashed gray;
}
td {
border: 1px dashed gray;
width: {{page['post_width']}}mm;
height: {{page['post_height']}}mm;
padding: 0;
background-color: {{page['background']}};
}
td img {
width: 100%;
height: 100%;
object-fit: contain;
}
.cell {
font-size: 18px;
line-height: 1.6;
text-align: center;
padding: 5mm;
}
@page { size: auto; margin: 0mm; }
</style>
</head>
<body>
{% for content in contents %}
<table>
{%for row in range(page['rows'])%}
<tr>
{%for col in range(page['cols'])%}
<td>
{%if content['type'] %}
<img src="{{content['src']}}" />
{%else%}
<div class="cell">{{content}}</div>
{%endif%}
</td>
{%endfor%}
</tr>
{%endfor%}
</table>
<hr />
{%endfor%}
</body>
</html>

@ -0,0 +1,13 @@
from setuptools import find_packages, setup
setup(
name='postit-gen',
version='1.0.0',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=[
'Jinja2',
'python-frontmatter',
],
)

@ -0,0 +1,3 @@
home = /Library/Developer/CommandLineTools/usr/bin
include-system-site-packages = false
version = 3.8.2
Loading…
Cancel
Save