changing the way tag_index gets generated, so we can include other options like untagged

main
Anish Lakhwara 2022-02-01 04:50:30 +10:00
parent b6e9d1605d
commit 541dad60b0
5 changed files with 90 additions and 11 deletions

View File

@ -68,7 +68,8 @@ def generate_index_pages(template=config.template_index, template_nav=config.tem
# Build the files by filling out the template
file_loader = FileSystemLoader('')
env = Environment(loader=file_loader)
template = env.get_template(template)
# regular index pagse use main template
template = env.get_template(config.template_file)
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'
with open(slugfile, 'w', encoding=encoding) as fobj:
@ -77,11 +78,16 @@ def generate_index_pages(template=config.template_index, template_nav=config.tem
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)
# TODO tag_index subpage is sbroken
# create this page by parsing data instead of pages, like untagged below
print(metaIndexSubPages)
current_index_template = template.render(index_urls=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)
# TODO import TagHelper.get_untagged() and make one of the indexs pages
# 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):
@ -256,11 +262,8 @@ def get_date(page):
def parse_headings(page):
try:
# TODO for some reason this one isn't being parsed by the regex
if '= Kitaab =' in page:
print(page)
page = re.sub(r'= [\[\]a-zA-Z0-9 ]* =',
lambda x: x.group().replace('=','#', 1).strip('='),
page = re.sub(r'= [\[\]a-zA-Z0-9:|+ ]* =',
lambda x: x.group().replace('=','###', 1).strip('='),
page)
return page
except Exception as e:
@ -282,6 +285,7 @@ def create_entries(pages):
continue
markdown_text = open(page, 'r').read()
markdown_text = parse_headings(markdown_text)
markdown_text = style_iframes(markdown_text)
markdown_text = fix_images_urls(markdown_text)
markdown_text = fix_wiki_links(markdown_text, path["folder"])
@ -290,7 +294,6 @@ def create_entries(pages):
markdown_text = remove_tags(markdown_text)
markdown_text = remove_title(markdown_text)
markdown_text = remove_date(markdown_text)
markdown_text = parse_headings(markdown_text)
pageContent = markdown(markdown_text)
# Create the page object with all the informations we need
@ -391,7 +394,7 @@ def clean_path(path):
path_items["slug"] = path_items["folder"] + "/" + path_items["slug"]
# TODO weird special case
if "index" in path_items["file"]:
if "index" == path_items["file"]:
path_items["parent_url"] = ""
path_items["parent_text"] = config.home_name
path_items["slug"] = "created_index" + ".html"
@ -424,7 +427,6 @@ def generate_sub_pages(entries, num, folder, title, title_name=""):
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 + \

View File

@ -8,7 +8,7 @@ assets_folder = "asset/"
medias_folder = "media/"
template_file = "partial/main.html"
template_nav = "partial/nav.html"
template_index = "partial/main.html"
template_index = "partial/index_table.html"
rss_template = "partial/rss.xml"
rss_item_template = "partial/item.xml"
name_of_site = "Kitaab"

View File

@ -43,6 +43,17 @@ def filterFiles(AllFileList):
print("Key not found: {}".format(mask))
return AllFileList - doNotTakeFiles
def untaggedFiles(AllFileList=TagHelper.getAllFiles()):
toFilter = filter + censor
tagList = TagHelper.getAllTags()
doNotTakeFiles = set()
for mask in toFilter:
try:
doNotTakeFiles.update(tagList[mask])
except KeyError:
print("Key not found: {}".format(mask))
return set.difference(AllFileList, doNotTakeFiles)
def censorNetwork(network):
# Takes network as a set
for c in censor:

View File

@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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"
content="config.site_meta_description">
<meta property="og:site_name" content="{{config.name_of_site}}">
<meta property="og:url" content="build_url">
<meta property="og:image" content="build_urlassets/social.png">
<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">
<meta name="twitter:image" content="build_urlassets/social.png">
<meta name="twitter:image:alt" content="page_title | config.name_of_site">
--!>
<link rel="apple-touch-icon" sizes="57x57" href="build_urlassets/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="build_urlassets/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="build_urlassets/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="build_urlassets/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="build_urlassets/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="build_urlassets/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="build_urlassets/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="build_urlassets/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="build_urlassets/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="build_urlassets/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="build_urlassets/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="build_urlassets/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="build_urlassets/favicon-16x16.png">
<meta name="msapplication-TileColor" content="#5927e0">
<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="assets/main.css">
</head>
<body class="flow-large container">
<header>
<div id='piles' style="float: right;">
<table style="width:100%">
{% set count = 0 %}
<tr>
{% for index_url in index_urls %}
<td>{{index_url}}</td>
{% set count = count + 1 %}
{% if count == 5 %}
</tr>
<tr>
{% endif %}
{% endfor %}
</table>
</div>
</main>
</body>
</html>

View File

@ -49,6 +49,7 @@ media="screen" title="no title" charset="utf-8">
</header>
<main>
{{ page_navigation }}
<h1> {{page_title}} </h1>
<div style='max-width:460px;'>
<article class="flow">
{{page_tags}}