Compare commits
No commits in common. '85eeb3e5c031433c5e6900f5de1b863fff57049e' and '1823db0bc3dbc97e6dd26a0f627029d9cd72dc3f' have entirely different histories.
85eeb3e5c0
...
1823db0bc3
File diff suppressed because one or more lines are too long
@ -1,22 +0,0 @@
|
|||||||
from string import ascii_uppercase
|
|
||||||
|
|
||||||
def generate_grid(word, origin, direction):
|
|
||||||
|
|
||||||
start = (
|
|
||||||
ascii_uppercase.index(origin[0]),
|
|
||||||
int(origin[1:]),
|
|
||||||
)
|
|
||||||
|
|
||||||
cells = []
|
|
||||||
for i in range(len(word)):
|
|
||||||
if direction == "H":
|
|
||||||
# increase number
|
|
||||||
start_f = f"{ascii_uppercase[start[0]]}{start[1] + i}"
|
|
||||||
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# increase letter
|
|
||||||
start_f = f"{ascii_uppercase[start[0] + i]}{start[1]}"
|
|
||||||
pass
|
|
||||||
cells.append(start_f)
|
|
||||||
return cells
|
|
@ -1,107 +1,133 @@
|
|||||||
import json
|
import json
|
||||||
import frontmatter
|
import frontmatter
|
||||||
import os
|
import os
|
||||||
from . import crossword
|
import string
|
||||||
|
|
||||||
|
|
||||||
def dump(order=None):
|
def dump(order=None):
|
||||||
|
# list all the folders
|
||||||
|
path = "postit/static/contents"
|
||||||
|
|
||||||
# The function can receive an optional order for the contents
|
|
||||||
# in the form of a list of folder like
|
|
||||||
# ['intro','what-is-a-loot-box', 'crosswords', 'one-sentence-game-ideas', 'nim', 'mimic', 'unfinished-thoughts', 'the-leader', 'connect-less', 'xquisite', 'katamari', 'life-hacks', 'karaoke', 'outro']
|
|
||||||
|
|
||||||
folders = order
|
folders = order
|
||||||
path = "postit/static/contents"
|
|
||||||
|
|
||||||
if folders == None:
|
if folders == None:
|
||||||
# If no order is passed, list all the folders in the contents directory
|
|
||||||
folders = [f.name for f in os.scandir(path) if f.is_dir()]
|
folders = [f.name for f in os.scandir(path) if f.is_dir()]
|
||||||
|
|
||||||
# Total number of postit
|
|
||||||
total = 0
|
|
||||||
|
|
||||||
# Dictionary to fill with the contributions
|
|
||||||
contents = {}
|
contents = {}
|
||||||
|
total = 0
|
||||||
|
|
||||||
|
|
||||||
for folder in folders:
|
for folder in folders:
|
||||||
# Initialize the contribution as an empty list of postit
|
|
||||||
contribution = []
|
contribution = []
|
||||||
try:
|
try:
|
||||||
# Load the file from a contents.md file
|
|
||||||
# (we are intrested only in the yaml metadata tho)
|
|
||||||
with open(f"{path}/{folder}/contents.md", "r", encoding="utf8") as f:
|
with open(f"{path}/{folder}/contents.md", "r", encoding="utf8") as f:
|
||||||
metadata, body = frontmatter.parse(f.read())
|
metadata, body = frontmatter.parse(f.read())
|
||||||
|
|
||||||
for content in metadata["contents"]:
|
for content in metadata["contents"]:
|
||||||
|
|
||||||
# For each entry in the contents list create a default postit dictionary
|
|
||||||
# with the title of the contribution
|
|
||||||
postit = {
|
|
||||||
'title' : metadata['title']
|
|
||||||
}
|
|
||||||
|
|
||||||
# We have basically 2 types of postit:
|
|
||||||
# 1. Simple postit with just a string of text
|
|
||||||
# 2. Complex postit with different informations
|
|
||||||
|
|
||||||
# ii) We start from this second kind, that is loaded as a dictionary
|
|
||||||
if type(content) == dict:
|
if type(content) == dict:
|
||||||
|
|
||||||
# Pass all the properties from the yaml object to the post-it dictionary
|
|
||||||
for key in content:
|
|
||||||
postit[key] = content[key]
|
|
||||||
|
|
||||||
# --------------------------
|
|
||||||
# Custom post-it generation
|
|
||||||
# Add here the function for generate dynamic postit
|
|
||||||
# (such as the crossword imaginary grid)
|
|
||||||
|
|
||||||
# Generate the Imaginary Grid for the Crossword game
|
if "img" in content:
|
||||||
# (Only for the Loot Box category)
|
postit = {
|
||||||
if "word" in content and content['category'] != 'Loot Box':
|
"title": metadata["title"],
|
||||||
|
"description": content["alt"],
|
||||||
|
"img": content["img"],
|
||||||
|
"slug": folder,
|
||||||
|
}
|
||||||
|
|
||||||
|
# this is temporary, sorry
|
||||||
|
elif "type" in content:
|
||||||
|
if content["type"] == 'mimic-colophon':
|
||||||
|
postit = {
|
||||||
|
"title": metadata['title'],
|
||||||
|
"type": content['type'],
|
||||||
|
"original": content['original'],
|
||||||
|
"original-credits": content['original-credits'],
|
||||||
|
"original-action": content['original-action'],
|
||||||
|
"original-date": content['original-date'],
|
||||||
|
"current": content['current'],
|
||||||
|
'current-credits': content['current-credits'],
|
||||||
|
"current-action": content['current-action'],
|
||||||
|
"current-date": content['current-date'],
|
||||||
|
"slug": folder,
|
||||||
|
}
|
||||||
|
|
||||||
|
elif "card" in content:
|
||||||
|
postit = {
|
||||||
|
"title": metadata["title"],
|
||||||
|
"card": content["card"],
|
||||||
|
"quote": content["quote"],
|
||||||
|
"motivation": content["motivation"],
|
||||||
|
"vision": content["vision"],
|
||||||
|
"empathy": content["empathy"],
|
||||||
|
"positivity": content["positivity"],
|
||||||
|
"slug": folder,
|
||||||
|
}
|
||||||
|
|
||||||
|
elif any(position in ['nw','ne','sw','se'] for position in content):
|
||||||
|
postit = {
|
||||||
|
"title": metadata["title"],
|
||||||
|
"slug": folder,
|
||||||
|
}
|
||||||
|
for position in content:
|
||||||
|
postit[position] = content[position]
|
||||||
|
|
||||||
|
elif "word" in content and content['category'] != 'Loot Box':
|
||||||
continue
|
continue
|
||||||
elif "word" in content:
|
elif "word" in content:
|
||||||
|
postit = {
|
||||||
|
"title": metadata["title"],
|
||||||
|
"definition": content["definition"],
|
||||||
|
"category": content["category"],
|
||||||
|
"start": content["start"],
|
||||||
|
"word": content["word"],
|
||||||
|
"direction": content["direction"],
|
||||||
|
"slug": folder,
|
||||||
|
}
|
||||||
if content["word"]:
|
if content["word"]:
|
||||||
# Generate a postit for each letter in the word
|
start = (
|
||||||
for cell in crossword.generate_grid(content['word'], content["start"], content["direction"]):
|
string.ascii_uppercase.index(content["start"][0]),
|
||||||
|
int(content["start"][1:]),
|
||||||
|
)
|
||||||
|
# print(start)
|
||||||
|
for i in range(len(content["word"])):
|
||||||
|
if content["direction"] == "H":
|
||||||
|
# increase number
|
||||||
|
start_f = f"{string.ascii_uppercase[start[0]]}{start[1] + i}"
|
||||||
|
# print(start_f)
|
||||||
|
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# increase letter
|
||||||
|
start_f = f"{string.ascii_uppercase[start[0] + i]}{start[1]}"
|
||||||
|
# print(start_f)
|
||||||
|
pass
|
||||||
contribution.append(
|
contribution.append(
|
||||||
{
|
{
|
||||||
"title": metadata["title"],
|
"title": metadata["title"],
|
||||||
"definition": " ",
|
"definition": " ",
|
||||||
"category": content["category"],
|
"category": content["category"],
|
||||||
"start": cell,
|
"start": start_f,
|
||||||
})
|
"word": content["word"],
|
||||||
|
"direction": content["direction"],
|
||||||
|
"slug": folder,
|
||||||
#----------------------------
|
}
|
||||||
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# i) Simple string postit
|
postit = {
|
||||||
postit["description"] = content
|
"title": metadata["title"],
|
||||||
|
"description": content,
|
||||||
# Add the postit to the contribution
|
"slug": folder,
|
||||||
|
}
|
||||||
contribution.append(postit)
|
contribution.append(postit)
|
||||||
|
|
||||||
# Log the amount of postit for the current contribution
|
|
||||||
amount = len(contribution)
|
amount = len(contribution)
|
||||||
print(f"{amount:03} - {folder}")
|
print(f"{amount:03} - {folder}")
|
||||||
|
|
||||||
# Add the contribution to the total amount
|
|
||||||
total = total + amount
|
total = total + amount
|
||||||
|
|
||||||
# Add the contribution to the contents object
|
|
||||||
contents[folder] = contribution
|
contents[folder] = contribution
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# If a markdown file is broken print the error and move on
|
|
||||||
# without breaking everything
|
|
||||||
print(f"{folder} has an error!")
|
print(f"{folder} has an error!")
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
print(f'Total: {total}')
|
print(f'Total: {total}')
|
||||||
|
|
||||||
# Store the postit in a JSON file
|
|
||||||
# in order to avoid repeating this process everytime we want the postit.
|
|
||||||
with open("postit/contents.json", "w") as f:
|
with open("postit/contents.json", "w") as f:
|
||||||
f.write(json.dumps(contents))
|
f.write(json.dumps(contents))
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
from flask import Blueprint, render_template
|
from flask import Blueprint, render_template, request, url_for
|
||||||
# import os
|
import os
|
||||||
|
|
||||||
bp = Blueprint("home", __name__, url_prefix="/")
|
bp = Blueprint("home", __name__, url_prefix="/")
|
||||||
|
|
||||||
|
index = ['intro','what-is-a-loot-box', 'crosswords', 'one-sentence-game-ideas', 'nim', 'mimic', 'unfinished-thoughts', 'the-leader', 'connect-less', 'xquisite', 'katamari', 'life-hacks', 'karaoke', 'outro']
|
||||||
|
|
||||||
pages = ['intro','what-is-a-loot-box', 'crosswords', 'one-sentence-game-ideas', 'nim', 'mimic', 'unfinished-thoughts', 'the-leader', 'connect-less', 'xquisite', 'katamari', 'life-hacks', 'karaoke', 'outro']
|
|
||||||
|
|
||||||
@bp.route("/")
|
@bp.route("/")
|
||||||
def home():
|
def home():
|
||||||
|
|
||||||
# path = "postit/static/contents"
|
# path = "postit/static/contents"
|
||||||
# pages = [f.name for f in os.scandir(path) if f.is_dir()]
|
# pages = [f.name for f in os.scandir(path) if f.is_dir()]
|
||||||
|
|
||||||
return render_template("home.html", pages=pages)
|
return render_template("home.html", pages=index)
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 08d68b497fb2fa47d7d9f74c86600a0b01b7566b
|
Subproject commit 1691c432b0126c3adc4c292e66c6efd9032f14f5
|
@ -1,22 +0,0 @@
|
|||||||
:root {
|
|
||||||
--color: var(--purple);
|
|
||||||
--background: var(--purple-bg);
|
|
||||||
|
|
||||||
--alt: var(--orange);
|
|
||||||
--alt-bg: var(--orange-bg);
|
|
||||||
|
|
||||||
--orange: #ff5416;
|
|
||||||
--orange-bg: #ffb58d;
|
|
||||||
--purple: #7d50ff;
|
|
||||||
--purple-bg: #cec6ff;
|
|
||||||
}
|
|
||||||
|
|
||||||
html,
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
color: var(--color);
|
|
||||||
}
|
|
||||||
|
|
||||||
* {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
body {
|
|
||||||
font-family: Arial, Helvetica, sans-serif;
|
|
||||||
font-size: 24px;
|
|
||||||
line-height: 1.4;
|
|
||||||
color: var(--color);
|
|
||||||
padding: 32px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: currentColor;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1,
|
|
||||||
h2,
|
|
||||||
h3 {
|
|
||||||
font-size: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
font-weight: normal;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ol {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
button#color {
|
|
||||||
position: absolute;
|
|
||||||
right: 32px;
|
|
||||||
top: 52px;
|
|
||||||
display: inline-block;
|
|
||||||
width: 24px;
|
|
||||||
height: 24px;
|
|
||||||
border-radius: 0;
|
|
||||||
border: none;
|
|
||||||
background-color: var(--alt-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
button#color:hover {
|
|
||||||
transition: transform 0.1s ease-out;
|
|
||||||
transform: scale(1.05);
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
// I really don't like this code but it's ok for now...
|
|
||||||
|
|
||||||
let main = true;
|
|
||||||
|
|
||||||
// Set a reference in the localStorage with the main color
|
|
||||||
window.addEventListener("load", () => {
|
|
||||||
color = getCookie("color");
|
|
||||||
|
|
||||||
if (color == "purple" || color == "") {
|
|
||||||
document.documentElement.style.setProperty("--color", "var(--purple)");
|
|
||||||
document.documentElement.style.setProperty("--background", "var(--purple-bg)");
|
|
||||||
document.documentElement.style.setProperty("--alt", "var(--orange)");
|
|
||||||
document.documentElement.style.setProperty("--alt-bg", "var(--orange-bg)");
|
|
||||||
setCookie("color", "purple", 7);
|
|
||||||
main = true;
|
|
||||||
} else {
|
|
||||||
document.documentElement.style.setProperty("--color", "var(--orange)");
|
|
||||||
document.documentElement.style.setProperty("--background", "var(--orange-bg)");
|
|
||||||
document.documentElement.style.setProperty("--alt", "var(--purple)");
|
|
||||||
document.documentElement.style.setProperty("--alt-bg", "var(--purple-bg)");
|
|
||||||
setCookie("color", "orange", 7);
|
|
||||||
main = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Toggle color button
|
|
||||||
const colorButton = document.getElementById("color");
|
|
||||||
colorButton.addEventListener("click", () => {
|
|
||||||
toggleColor();
|
|
||||||
});
|
|
||||||
|
|
||||||
function toggleColor() {
|
|
||||||
var style = getComputedStyle(document.body);
|
|
||||||
|
|
||||||
// get the current palette
|
|
||||||
currentColor = style.getPropertyValue("--color");
|
|
||||||
currentBg = style.getPropertyValue("--background");
|
|
||||||
altColor = style.getPropertyValue("--alt");
|
|
||||||
altBg = style.getPropertyValue("--alt-bg");
|
|
||||||
|
|
||||||
// and swap the order
|
|
||||||
document.documentElement.style.setProperty("--color", altColor);
|
|
||||||
document.documentElement.style.setProperty("--background", altBg);
|
|
||||||
document.documentElement.style.setProperty("--alt", currentColor);
|
|
||||||
document.documentElement.style.setProperty("--alt-bg", currentBg);
|
|
||||||
|
|
||||||
// set a reference in a cookie to share it with the generator page
|
|
||||||
main = !main;
|
|
||||||
setCookie("color", main ? "purple" : "orange", 7);
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
function setCookie(name, value, days) {
|
|
||||||
var expires = "";
|
|
||||||
if (days) {
|
|
||||||
var date = new Date();
|
|
||||||
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
||||||
expires = "; expires=" + date.toUTCString();
|
|
||||||
}
|
|
||||||
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
|
||||||
}
|
|
||||||
function getCookie(name) {
|
|
||||||
var nameEQ = name + "=";
|
|
||||||
var ca = document.cookie.split(";");
|
|
||||||
for (var i = 0; i < ca.length; i++) {
|
|
||||||
var c = ca[i];
|
|
||||||
while (c.charAt(0) == " ") c = c.substring(1, c.length);
|
|
||||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
function eraseCookie(name) {
|
|
||||||
document.cookie = name + "=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;";
|
|
||||||
}
|
|
Loading…
Reference in New Issue