diff --git a/src/kitaab-public/asset/style.css b/src/kitaab-public/asset/style.css new file mode 100644 index 0000000..fa79cd3 --- /dev/null +++ b/src/kitaab-public/asset/style.css @@ -0,0 +1,84 @@ +body {font-family: Tahoma, Geneva, sans-serif; margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;max-width:50rem;margin:auto;background:#252525;color:darkgray;padding-bottom:10rem;} +h1, h2, h3, h4, h5, h6 {font-family: Trebuchet MS, Helvetica, sans-serif; font-weight: bold; line-height:100%; margin-top: 1.5em; margin-bottom: 0.5em;} +h1 {font-size: 2.6em; color: #909090;} +h2 {font-size: 2.2em; color: #909090;} +h3 {font-size: 1.8em; color: #909090;} +h4 {font-size: 1.4em; color: #909090;} +h5 {font-size: 1.3em; color: #989898;} +h6 {font-size: 1.2em; color: #9c9c9c;} +p, pre, blockquote, table, ul, ol, dl {margin-top: 1em; margin-bottom: 1em;} +strong {color: orangered;} +ul ul, ul ol, ol ol, ol ul {margin-top: 0.5em; margin-bottom: 0.5em;} +li {margin: 0.3em auto;} +ul {margin-left: 2em; padding-left: 0.5em;} +dt {font-weight: bold;} +a {color: #3296c8;text-decoration: none;} +img {border: none;} +pre {padding: 0.5em 1rem;box-shadow: 0px 0px 1px 0px rgba(0,0,0,0.75);} +.codehilite, pre {border-radius:1%}; +blockquote {padding: 0.4em; background-color: #f6f5eb;} +th, td {border: 1px solid #ccc; padding: 0.3em;} +th {background-color: #f0f0f0;} +hr {border: none; border-top: 1px solid #ccc; width: 100%;} +del {text-decoration: line-through; color: #777777;} +.toc li {list-style-type: none;} +.todo {font-weight: bold; background-color: #f0ece8; color: #a03020;} +.justleft {text-align: left;} +.justright {text-align: right;} +.justcenter {text-align: center;} +.center {margin-left: auto; margin-right: auto;} +.tag {background-color: #eeeeee; font-family: monospace; padding: 2px;} + +/* classes for items of todo lists */ +.rejected { + /* list-style: none; */ + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAMAAAAMCGV4AAAACXBIWXMAAADFAAAAxQEdzbqoAAAAB3RJTUUH4QgEFhAtuWgv9wAAAPZQTFRFmpqam5iYnJaWnJeXnpSUn5OTopCQpoqKpouLp4iIqIiIrYCAt3V1vW1tv2xsmZmZmpeXnpKS/x4e/x8f/yAg/yIi/yQk/yUl/yYm/ygo/ykp/yws/zAw/zIy/zMz/zQ0/zU1/zY2/zw8/0BA/0ZG/0pK/1FR/1JS/1NT/1RU/1VV/1ZW/1dX/1pa/15e/19f/2Zm/2lp/21t/25u/3R0/3p6/4CA/4GB/4SE/4iI/46O/4+P/52d/6am/6ur/66u/7Oz/7S0/7e3/87O/9fX/9zc/93d/+Dg/+vr/+3t/+/v//Dw//Ly//X1//f3//n5//z8////gzaKowAAAA90Uk5T/Pz8/Pz8/Pz8/Pz8/f39ppQKWQAAAAFiS0dEEnu8bAAAAACuSURBVAhbPY9ZF4FQFEZPSKbIMmWep4gMGTKLkIv6/3/GPbfF97b3w17rA0kQOPgvAeHW6uJ6+5h7HqLdwowgOzejXRXBdx6UdSru216xuOMBHHNU0clTzeSUA6EhF8V8kqroluMiU6HKcuf4phGPr1o2q9kYZWwNq1qfRRmTaXpqsyjj17KkWCxKBUBgXWueHIyiAIg18gsse4KHkLF5IKIY10WQgv7fOy4ST34BRiopZ8WLNrgAAAAASUVORK5CYII=); + background-repeat: no-repeat; + background-position: 0 .2em; + padding-left: 1.5em; +} +.done0 { + /* list-style: none; */ + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAA7SURBVCiR7dMxEgAgCANBI3yVRzF5KxNbW6wsuH7LQ2YKQK1mkswBVERYF5Os3UV3gwd/jF2SkXy66gAZkxS6BniubAAAAABJRU5ErkJggg==); + background-repeat: no-repeat; + background-position: 0 .2em; + padding-left: 1.5em; +} +.done1 { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABtSURBVCiR1ZO7DYAwDER9BDmTeZQMFXmUbGYpOjrEryA0wOvO8itOslFrJYAug5BMM4BeSkmjsrv3aVTa8p48Xw1JSkSsWVUFwD05IqS1tmYzk5zzae9jnVVVzGyXb8sALjse+euRkEzu/uirFomVIdDGOLjuAAAAAElFTkSuQmCC); + background-repeat: no-repeat; + background-position: 0 .15em; + padding-left: 1.5em; +} +.done2 { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAB1SURBVCiRzdO5DcAgDAVQGxjAYgTvxlDIu1FTIRYAp8qlFISkSH7l5kk+ZIwxKiI2mIyqWoeILYRgZ7GINDOLjnmF3VqklKCUMgTee2DmM661Qs55iI3Zm/1u5h9sm4ig9z4ERHTFzLyd4G4+nFlVrYg8+qoF/c0kdpeMsmcAAAAASUVORK5CYII=); + background-repeat: no-repeat; + background-position: 0 .15em; + padding-left: 1.5em; +} +.done3 { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABoSURBVCiR7dOxDcAgDATA/0DtUdiKoZC3YhLkHjkVKF3idJHiztKfvrHZWnOSE8Fx95RJzlprimJVnXktvXeY2S0SEZRSAAAbmxnGGKH2I5T+8VfxPhIReQSuuY3XyYWa3T2p6quvOgGrvSFGlewuUAAAAABJRU5ErkJggg==); + background-repeat: no-repeat; + background-position: 0 .15em; + padding-left: 1.5em; +} +.done4 { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAQCAYAAAAbBi9cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAzgAAAM4BlP6ToAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAIISURBVDiNnZQ9SFtRFMd/773kpTaGJoQk1im4VDpWQcTNODhkFBcVTCNCF0NWyeDiIIiCm82QoIMIUkHUxcFBg1SEQoZszSat6cdTn1qNue92CMbEr9Sey+XC/Z/zu+f8h6ukUil3sVg0+M+4cFxk42/jH2wAqqqKSCSiPQdwcHHAnDHH9s/tN1h8V28ETdP+eU8fT9Nt62ancYdIPvJNtsu87bmjrJlrTDVM4RROJs1JrHPrD4Bar7A6cpc54iKOaTdJXCUI2UMVrQZ0Js7YPN18ECKkYNQcJe/OE/4dZsw7VqNXQMvHy3QZXQypQ6ycrtwDjf8aJ+PNEDSCzLpn7+m2pD8ZKHlKarYhy6XjEoCYGcN95qansQeA3fNdki+SaJZGTMQIOoL3W/Z89rxv+tokubNajlvk/vm+LFpF2XnUKZHI0I+QrI7Dw0OZTqdzUkpsM7mZTyfy5OPGyw1tK7AFSvmB/Ks8w8YwbUYbe6/3QEKv0vugfxWPnMLJun+d/kI/WLdizpNjMbAIKrhMF4OuwadBALqqs+RfInwUvuNi+fBd+wjogfogAFVRmffO02q01mZZ0HHdgXIzdz0QQLPezIQygX6llxNKKgOFARYCC49CqhoHIUTlss/Vx2phlYwjw8j1CAlfAiwQiJpiy7o1VHnsG5FISkoJu7Q/2YmmaV+i0ei7v38L2CBguSi5AAAAAElFTkSuQmCC); + background-repeat: no-repeat; + background-position: 0 .15em; + padding-left: 1.5em; +} + +code { + font-family: Monaco,"Courier New","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace; + -webkit-border-radius: 1px; + -moz-border-radius: 1px; + border-radius: 1px; + -moz-background-clip: padding; + -webkit-background-clip: padding-box; + background-clip: padding-box; + padding: 0px 3px; + display: inline-block; + color: #e8e8e8; +} + diff --git a/src/kitaab-public/build/build.py b/src/kitaab-public/build/build.py index 72e366e..44c2950 100644 --- a/src/kitaab-public/build/build.py +++ b/src/kitaab-public/build/build.py @@ -58,20 +58,30 @@ def generate_index_pages(template=config.template_index, template_nav=config.tem template = template all_tags = TagHelper.getAllTags() index_tags = config.nav_tags + metaIndexSubPages = [] for index in all_tags.keys(): pages = all_tags[index] pages = add_file_path(pages, config.content_folder[0]) entries = create_entries(pages) - subPages = generate_sub_pages(entries, len(entries), 'raw', False) - # TODO use jinja2... + subPages = generate_sub_pages(entries, len(entries), config.content_folder[0], False) + metaIndexSubPages.append(generate_sub_pages(entries, 5, config.content_folder[0], True, index)) + # Build the files by filling out the template file_loader = FileSystemLoader('') env = Environment(loader=file_loader) template = env.get_template(template) current_index_template = template.render(page_body=subPages, page_date=None, page_tags=None, page_navigation=generate_navigation(template_nav), page_title='index', config=config) slugfile = config.build_folder + index + '_index.html' - print(slugfile) with open(slugfile, 'w', encoding=encoding) as fobj: fobj.write(current_index_template) + # build the metaIndex page + file_loader = FileSystemLoader('') + env = Environment(loader=file_loader) + template = env.get_template(template) + current_index_template = template.render(page_body="".join(metaIndexSubPages), page_date=None, page_tags=None, page_navigation=generate_navigation(template_nav), page_title='index', config=config) + slugfile = config.build_folder + 'tag_index.html' + with open(slugfile, 'w', encoding=encoding) as fobj: + fobj.write(current_index_template) + # Generates html files in the site folder, using the entries and the template. def generate_html_pages(site_folder, entries, template, sub_pages_list, template_nav): @@ -84,7 +94,6 @@ def generate_html_pages(site_folder, entries, template, sub_pages_list, template env = Environment(loader=file_loader) template = env.get_template(template) page_template = template.render(page_body=entry['pageContent'], page_date="%s"%entry['date'], page_tags=entry['tags'], naem_of_site="Kitaab", page_navigation=nav_html, page_title=entry['title'], build_url=entry['parent_text'], config=config) - print(page_template) # Checking if content folder exists folderExists = os.path.exists(site_folder+entry['folder']) @@ -113,16 +122,15 @@ def get_entry_title(page): if '%title' in textContent: textContent = textContent.replace('%title','') else: - if 'index' not in page: - textContent = page.split('/')[1].rstrip('.wiki') + textContent = page.split('/')[1].rstrip('.wiki') except FileNotFoundError: - print(f"Page not found, but present in tags: {page}") + #print(f"Page not found, but present in tags: {page}") return None except UnicodeDecodeError: print(f"Page could not be read: {page}") return None except IndexError as e: - print(f"{page} could not be parsed: {e}") + print(f"{page} probably was'nt grabbed, cannot read file") return textContent @@ -148,7 +156,7 @@ def style_iframes(page): # Get a list of the tags in the page def get_tags(page): - regex = r":.*:" + regex = r":[a-zA-Z:]*:" matches = re.finditer(regex, page, re.MULTILINE) ret = [] @@ -203,11 +211,9 @@ def fix_wiki_links(page, path): def remove_tags(page): try: - textContent = page.splitlines() - tags = textContent[1] - if ':' in tags: - textContent = [textContent[0]] + textContent[2:] - return '\n'.join(textContent) + regex = r":[a-zA-Z:]*:" + page = re.sub(regex, '', page) + return page except: print(f'Unexpected error in removing tags in {page}') return page @@ -260,7 +266,6 @@ def create_entries(pages): path = clean_path(page) title = get_entry_title(page) if title is None: - print(f'Did not find title for {page}') noTitle.append(page) continue @@ -372,11 +377,11 @@ def clean_path(path): if config.flat_build == False: path_items["slug"] = path_items["folder"] + "/" + path_items["slug"] + # TODO weird special case if "index" in path_items["file"]: path_items["parent_url"] = "" path_items["parent_text"] = config.home_name - if config.flat_build: - path_items["slug"] = path_items["folder"] + ".html" + path_items["slug"] = "created_index" + ".html" else: if config.flat_build: path_items["parent_url"] = path_items["folder"] + ".html" @@ -390,7 +395,7 @@ def clean_path(path): # Generate the list of sub pages for each section -def generate_sub_pages(entries, num, folder, title): +def generate_sub_pages(entries, num, folder, title, title_name=""): # Sort entries by date using the iso_date format entries.sort(key=lambda x: x["iso_date"], reverse=True) @@ -406,22 +411,24 @@ def generate_sub_pages(entries, num, folder, title): else: link_url = entry["file"] + ".html" +# TODO there's a comma being generated here somewhere in metaIndexSubPages that I'm trying to get rid of if entry["file"] != "index": - entry_string = "
  • " + entry["title"] + "

    {}

    {}
  • \n".format(entry['date'], entry["tags"]) + entry_string = "
  • " + entry["title"] + \ + "

    {}

    {}
  • ".format(entry['date'], entry["tags"]) sub_page_list += entry_string sub_page_list += "" # If a title is necessary, use the folder name + # This only gets applied for metaIndexSubPages in the generate_index_pages function if title: - title = "

    %s

    " % folder.capitalize() + title = f"

    {title_name.capitalize()}

    " sub_page_list = title + sub_page_list if config.flat_build: - sub_page_link = build_url + folder + ".html" + sub_page_link = build_url + title_name + "_index.html" else: sub_page_link = build_url + folder - sub_page_link_html = "" % sub_page_link + config.see_all + "" - sub_page_list += sub_page_link_html return sub_page_list diff --git a/src/kitaab-public/partial/main.html b/src/kitaab-public/partial/main.html index b784008..3d5eae9 100644 --- a/src/kitaab-public/partial/main.html +++ b/src/kitaab-public/partial/main.html @@ -4,7 +4,7 @@ - page_title | config.name_of_site + {{page_title}} | {{config.name_of_site}} +