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'
{ card }
'
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' ' + f"{my_file}
"
else:
image_html = f' '
mycard = f'{image_html}
'
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'''
{card_1}
{card_2}
{card_3}
{card_4}
{card_5}
{card_6}
{card_7}
{card_8}
'''
pages.append(page_html)
#print(page_html)
#print(pages)
pages_string = "\n".join(pages)
html_template = f'''
Document
info
print
my notebooks
online notebooks generator
{pages_string}
'''
#print(html_template)
for i in range(10):
with open(f'notebooks{i}.html', 'w') as out:
out.write(html_template)