add pretty css, fix some more stuff, getting closer
This commit is contained in:
parent
920fd42f6a
commit
9cb1aa61e3
84
src/kitaab-public/asset/style.css
Normal file
84
src/kitaab-public/asset/style.css
Normal file
|
@ -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;
|
||||
}
|
||||
|
|
@ -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="<date>%s</date>"%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 = "<li><div style='overflow: hidden;'><h3 style='float:left;'><a href='" + link_url + \
|
||||
"'>" + entry["title"] + "</a> </h3><p style='float:right;'> {} </p> </div> {} </li>\n".format(entry['date'], entry["tags"])
|
||||
entry_string = "<li><div style='overflow: hidden;'><h3 style='float:left;'><a href='" + \
|
||||
link_url + \
|
||||
"'>" + entry["title"] + \
|
||||
"</a> </h3><p style='float:right;'> {} </p> </div> {} </li>".format(entry['date'], entry["tags"])
|
||||
sub_page_list += entry_string
|
||||
sub_page_list += "</ul>"
|
||||
|
||||
# If a title is necessary, use the folder name
|
||||
# This only gets applied for metaIndexSubPages in the generate_index_pages function
|
||||
if title:
|
||||
title = "<h2>%s</h2>" % folder.capitalize()
|
||||
title = f"<h2><a href={title_name}_index.html>{title_name.capitalize()}</h2>"
|
||||
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 = "<small><a href='%s'>" % sub_page_link + config.see_all + "</a></small>"
|
||||
sub_page_list += sub_page_link_html
|
||||
|
||||
return sub_page_list
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>page_title | config.name_of_site</title>
|
||||
<title>{{page_title}} | {{config.name_of_site}}</title>
|
||||
<meta property="og:title" content="{{page_title}} | {{config.name_of_site}}">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:description"
|
||||
|
@ -15,6 +15,8 @@
|
|||
<meta property="og:image:height" content="300">
|
||||
<meta property="og:image:width" content="300">
|
||||
<meta property="og:image:type" content="image/jpeg">
|
||||
<link rel="stylesheet" href="asset/style.css" type="text/css"
|
||||
media="screen" title="no title" charset="utf-8">
|
||||
<!-- Mastodon stuff should go here
|
||||
<meta name="twitter:site" content="config.twitter_name">
|
||||
<meta name="twitter:title" content="page_title | config.name_of_site">
|
||||
|
@ -38,12 +40,12 @@
|
|||
<meta name="msapplication-TileImage" content="build_urlassets/ms-icon-144x144.png">
|
||||
<meta name="theme-color" content="#5927e0">
|
||||
<link rel="canonical" href="{{build_url}}">
|
||||
<link rel="stylesheet" href="{{build_url}}assets/main.css">
|
||||
<link rel="stylesheet" href="assets/main.css">
|
||||
</head>
|
||||
|
||||
<body class="flow-large container">
|
||||
<header>
|
||||
<a href="index.html" aria-label="{{page_title}}">{{config.name_of_site}}</a>
|
||||
<a href="home.html" aria-label="{{page_title}}">{{config.name_of_site}}</a>
|
||||
</header>
|
||||
<main>
|
||||
{{ page_navigation }}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<div id='navigation' style="float: right;">
|
||||
<nav>
|
||||
<h2> <a href='raw.html'> Index </a> </h2>
|
||||
<h2> <a href='tag_index.html'> Index </a> </h2>
|
||||
<ul>
|
||||
<li> <a href='recents.html'>recents</a></li>
|
||||
{% for link_url in index_urls %}
|
||||
<li> <a href='{{link_url}}_index.html'>{{link_url}}</a></li>
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in a new issue