|
|
|
import os
|
|
|
|
import markdown
|
|
|
|
from random import choice
|
|
|
|
|
|
|
|
# Get the directory path of the script
|
|
|
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
|
|
|
materials = ['1_situation', '2_binding', '3_paperformat', '4_add_ons']
|
|
|
|
|
|
|
|
cards = {
|
|
|
|
'1_situation' : {
|
|
|
|
'content' : [],
|
|
|
|
'make-a-notebook-that' : []
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
'2_binding' : {
|
|
|
|
'content' : [],
|
|
|
|
'make-a-notebook-that' : []
|
|
|
|
},
|
|
|
|
|
|
|
|
'3_paperformat' : {
|
|
|
|
'content' : [],
|
|
|
|
'make-a-notebook-that' : []
|
|
|
|
},
|
|
|
|
|
|
|
|
'4_add_ons' : {
|
|
|
|
'content' : [],
|
|
|
|
'make-a-notebook-that' : []
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for folder in materials:
|
|
|
|
material_folder_path = os.path.join(script_dir, folder)
|
|
|
|
card_folders = os.listdir(material_folder_path)
|
|
|
|
#print(material_folder_path)
|
|
|
|
for card_folder in card_folders:
|
|
|
|
card_folder_path = os.path.join(material_folder_path, card_folder)
|
|
|
|
#print(card_folder_path) #these are content and make a notebook that folders paths
|
|
|
|
my_files = os.listdir(card_folder_path)
|
|
|
|
#print(my_files)
|
|
|
|
for my_file in my_files:
|
|
|
|
file_path = os.path.join(card_folder_path, my_file)
|
|
|
|
relative_file_path = os.path.relpath(file_path, os.path.dirname(__file__))
|
|
|
|
#image_path =
|
|
|
|
#print(file_path)
|
|
|
|
#print(relative_file_path)
|
|
|
|
|
|
|
|
if my_file.endswith(('.md', '.markdown')):
|
|
|
|
with open(file_path, 'r') as file:
|
|
|
|
md = file.read()
|
|
|
|
card = markdown.markdown(md)
|
|
|
|
#print(card) # the print of all the md files
|
|
|
|
card = f'<div class="card text">{ card }</div>'
|
|
|
|
cards[folder][card_folder].append(card)
|
|
|
|
elif my_file.endswith(('.jpg', '.jpeg', '.png')):
|
|
|
|
if 'prototype_' in my_file:
|
|
|
|
my_file= my_file.replace('.jpg', '').replace('.jpeg', '').replace('.png', '').replace('prototype_', '').replace('_', ' ')
|
|
|
|
image_html = f'<img src="{relative_file_path}" alt="{my_file}" />' + f"<div class='image_titles'>{my_file}</div>"
|
|
|
|
else:
|
|
|
|
image_html = f'<img src="{relative_file_path}" alt="{my_file}" />'
|
|
|
|
mycard = f'<div class="card img" style="background-image: url(\'{relative_file_path}\');">{image_html}</div> '
|
|
|
|
cards[folder][card_folder].append(mycard)
|
|
|
|
# print(mycard)
|
|
|
|
|
|
|
|
#print(card_folder)
|
|
|
|
#print(file_path)
|
|
|
|
|
|
|
|
|
|
|
|
number_pages = 32
|
|
|
|
pages = []
|
|
|
|
|
|
|
|
|
|
|
|
for page in range(number_pages):
|
|
|
|
|
|
|
|
|
|
|
|
card_1= choice(cards["1_situation"]["content"])
|
|
|
|
cards["1_situation"]["content"].remove(card_1)
|
|
|
|
card_2= choice(cards["1_situation"]["make-a-notebook-that"])
|
|
|
|
cards["1_situation"]["make-a-notebook-that"].remove(card_2)
|
|
|
|
|
|
|
|
card_3= choice(cards["2_binding"]["content"])
|
|
|
|
cards["2_binding"]["content"].remove(card_3)
|
|
|
|
card_4= choice(cards["2_binding"]["make-a-notebook-that"])
|
|
|
|
cards["2_binding"]["make-a-notebook-that"].remove(card_4)
|
|
|
|
|
|
|
|
card_5= choice(cards["3_paperformat"]["content"])
|
|
|
|
cards["3_paperformat"]["content"].remove(card_5)
|
|
|
|
card_6= choice(cards["3_paperformat"]["make-a-notebook-that"])
|
|
|
|
cards["3_paperformat"]["make-a-notebook-that"].remove(card_6)
|
|
|
|
|
|
|
|
card_7= choice(cards["4_add_ons"]["content"])
|
|
|
|
cards["4_add_ons"]["content"].remove(card_7)
|
|
|
|
card_8= choice(cards["4_add_ons"]["make-a-notebook-that"])
|
|
|
|
cards["4_add_ons"]["make-a-notebook-that"].remove(card_8)
|
|
|
|
|
|
|
|
page_html = f'''
|
|
|
|
|
|
|
|
<div class="page">
|
|
|
|
{card_1}
|
|
|
|
{card_2}
|
|
|
|
{card_3}
|
|
|
|
{card_4}
|
|
|
|
{card_5}
|
|
|
|
{card_6}
|
|
|
|
{card_7}
|
|
|
|
{card_8}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
pages.append(page_html)
|
|
|
|
#print(page_html)
|
|
|
|
|
|
|
|
|
|
|
|
#print(pages)
|
|
|
|
pages_string = "\n".join(pages)
|
|
|
|
|
|
|
|
html_template = f'''
|
|
|
|
<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>
|
|
|
|
<link rel="stylesheet" href="style.css">
|
|
|
|
<link href="https://fonts.cdnfonts.com/css/fjord" rel="stylesheet">
|
|
|
|
<link href="https://fonts.cdnfonts.com/css/notcouriersans" rel="stylesheet">
|
|
|
|
<link href='https://fonts.googleapis.com/css?family=Catamaran' rel='stylesheet'>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<nav><button class="btn infobutton">info</button>
|
|
|
|
<button class="btn print" onclick="window.print()">print</button>
|
|
|
|
<button class="btn mynotebooks"> my notebooks</button>
|
|
|
|
<button class="btn generator">online notebooks generator</button>
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
|
|
{pages_string}
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
#print(html_template)
|
|
|
|
for i in range(10):
|
|
|
|
with open(f'notebooks{i}.html', 'w') as out:
|
|
|
|
out.write(html_template)
|