commit d221259ba4e1b482df47c40de41f66baec90a534 Author: kam (from the studio) Date: Tue Mar 8 19:21:47 2022 +0100 first commit! template and generate! diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..a3c7304 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..88315da --- /dev/null +++ b/.gitignore @@ -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/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6a0d52f --- /dev/null +++ b/README.md @@ -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: `. + +In this way: + +```yaml +contents: + - type: image + src: +``` + +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. diff --git a/lootbox/contents.md b/lootbox/contents.md new file mode 100644 index 0000000..1f35faa --- /dev/null +++ b/lootbox/contents.md @@ -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. +--- diff --git a/lootbox/img.png b/lootbox/img.png new file mode 100644 index 0000000..571ad8f Binary files /dev/null and b/lootbox/img.png differ diff --git a/lootbox/index.html b/lootbox/index.html new file mode 100644 index 0000000..916860a --- /dev/null +++ b/lootbox/index.html @@ -0,0 +1,650 @@ + + + + + + + document + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
But the loot box in its more recent and exploitative version is getting purchased with real money from a player.
+ + +
+ + +
But the loot box in its more recent and exploitative version is getting purchased with real money from a player.
+ + +
+ + +
But the loot box in its more recent and exploitative version is getting purchased with real money from a player.
+ + +
+ + +
But the loot box in its more recent and exploitative version is getting purchased with real money from a player.
+ + +
+ + +
But the loot box in its more recent and exploitative version is getting purchased with real money from a player.
+ + +
+ + +
But the loot box in its more recent and exploitative version is getting purchased with real money from a player.
+ + +
+ + +
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.
+ + +
+ + +
The player never knows what is inside of it.
+ + +
+ + +
The player never knows what is inside of it.
+ + +
+ + +
The player never knows what is inside of it.
+ + +
+ + +
The player never knows what is inside of it.
+ + +
+ + +
The player never knows what is inside of it.
+ + +
+ + +
The player never knows what is inside of it.
+ + +
+ + +
The player never knows what is inside of it.
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
But they know that there is a chance of getting some items that they desire.
+ + +
+ + +
But they know that there is a chance of getting some items that they desire.
+ + +
+ + +
But they know that there is a chance of getting some items that they desire.
+ + +
+ + +
But they know that there is a chance of getting some items that they desire.
+ + +
+ + +
But they know that there is a chance of getting some items that they desire.
+ + +
+ + +
But they know that there is a chance of getting some items that they desire.
+ + +
+ + +
But they know that there is a chance of getting some items that they desire.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+ + +
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.
+ + +
+
+ + + \ No newline at end of file diff --git a/onesentencegames/.DS_Store b/onesentencegames/.DS_Store new file mode 100644 index 0000000..803793b Binary files /dev/null and b/onesentencegames/.DS_Store differ diff --git a/onesentencegames/contents.md b/onesentencegames/contents.md new file mode 100644 index 0000000..28f1700 --- /dev/null +++ b/onesentencegames/contents.md @@ -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 +--- diff --git a/onesentencegames/goose.png b/onesentencegames/goose.png new file mode 100644 index 0000000..571b0e8 Binary files /dev/null and b/onesentencegames/goose.png differ diff --git a/onesentencegames/snake.png b/onesentencegames/snake.png new file mode 100644 index 0000000..1767d79 Binary files /dev/null and b/onesentencegames/snake.png differ diff --git a/postit/.DS_Store b/postit/.DS_Store new file mode 100644 index 0000000..30b59c7 Binary files /dev/null and b/postit/.DS_Store differ diff --git a/postit/__init__.py b/postit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/postit/generate.py b/postit/generate.py new file mode 100644 index 0000000..d7e6ce4 --- /dev/null +++ b/postit/generate.py @@ -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 ') + sys.exit(2) + for opt, arg in opts: + if opt == '-h': + print('generate.py -f ') + 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:]) \ No newline at end of file diff --git a/postit/template.py b/postit/template.py new file mode 100644 index 0000000..8ea2f9d --- /dev/null +++ b/postit/template.py @@ -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 ') + sys.exit(2) + for opt, arg in opts: + if opt == '-h': + print('template.py -f ') + 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:]) \ No newline at end of file diff --git a/postit/templates/table.html b/postit/templates/table.html new file mode 100644 index 0000000..7f3eba4 --- /dev/null +++ b/postit/templates/table.html @@ -0,0 +1,83 @@ + + + + + + + document + + + + + {% for content in contents %} + + {%for row in range(page['rows'])%} + + {%for col in range(page['cols'])%} + + {%endfor%} + + {%endfor%} +
+ {%if content['type'] %} + + + {%else%} + +
{{content}}
+ + {%endif%} +
+
+ {%endfor%} + + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..4b15f6b --- /dev/null +++ b/setup.py @@ -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', + ], +) diff --git a/venv/pyvenv.cfg b/venv/pyvenv.cfg new file mode 100644 index 0000000..10427d2 --- /dev/null +++ b/venv/pyvenv.cfg @@ -0,0 +1,3 @@ +home = /Library/Developer/CommandLineTools/usr/bin +include-system-site-packages = false +version = 3.8.2