* Work on archive and single article view.

Currently not working.
This commit is contained in:
maste9 2015-03-08 20:17:29 +01:00 committed by Homer S
parent 71729d322c
commit 6aa2f3af4f
4 changed files with 185 additions and 108 deletions

View File

@ -0,0 +1,127 @@
<!DOCTYPE html />
<html lang="de">
<head>
<title>Mein Blog</title>
<meta name="author" content="${BLOG_AUTHOR}" />
<meta name="generator" content="picoblogger 0.1" />
<meta charset="utf-8" />
<meta name="keywords" content="${BLOG_KEYWORDS}" />
<meta name="description" content="${BLOG_DESCRIPTION}" />
<meta name="language" content="de" />
<meta name="robots" content="index,follow" />
<!-- <link rel="stylesheet" href="css/print.css" media="print" /> -->
<link rel="stylesheet" href="style.css" media="all" />
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="alternate" type="application/rss+xml"
title="RSS" href="feed.xml" />
<link rel="shortcut icon" href="images/favicon.ico" type="images/vnd.microsoft.icon" />
</head>
<body>
<header>
<h1>Mein Blog</h1><h2>Meine Worte, Meine Meinung ... </h2>
</header>
<nav>
<h1>Navigation</h1>
<ul>
<li><a href="index.html" class="home">Aktuell</a></li>
<li><a href="archive.html">Archiv</a></li>
</ul>
</nav>
<div id="flex-container">
<main class="flex-item">
<h1>Artikel</h1>
<article>
<header>
<h1 id="2"><a href="#2">Das ist der zweite Artikel</a></h1>
<dl>
<dt>Autor</dt><dd>homer77</dd>
<dt>Erstellt am</dt><dd>24.02.2015 um 21:19 Uhr</dd>
<dt>Zuletzt geändert</dt><dd>08.03.2015 um 13:47 Uhr</dd>
</dl>
</header>
<p>Dies ist der zweite Test.
Ich schreibe verschiedene Zeilen Text und teste damit <strong>Markdown</strong></p>
<p>Ist das jetzt ein neuer <em>Absatz</em>?</p>
<p>Und wie kann ich Code-Blöcke wie <code>apt-get install</code> einfügen? Funktioniert das mit 3 oder 4 Backticks?</p>
<p><code>Gehen auch
mehrere
Code-zeilen?</code></p>
<p>Und was ist mit Listen?
- Erster Eintrag
- Zweiter Eintrag
- Erster Untereintrag
- Dritter Eintrag</p>
<footer>
<p><a href="tags/lustig.html" class="tag">#lustig</a> <a href="tags/langweilig.html" class="tag">#langweilig</a> <a href="tags/blabla.html" class="tag">#blabla</a> </p>
</footer>
</article>
<article>
<header>
<h1 id="3"><a href="#3">Ein zweiter Test!</a></h1>
<dl>
<dt>Autor</dt><dd>homer77</dd>
<dt>Erstellt am</dt><dd>15.02.2015 um 23:18 Uhr</dd>
<dt>Zuletzt geändert</dt><dd>08.03.2015 um 13:46 Uhr</dd>
</dl>
</header>
<h1>Das ist ein weiter Testartikel</h1>
<h2>Ich muss das abschließen für heute</h2>
<p><a href="https://example.org">Klick mich</a></p>
<footer>
<p></p>
</footer>
</article>
<article>
<header>
<h1 id="1"><a href="#1">Dies ist ein Test</a></h1>
<dl>
<dt>Autor</dt><dd>homer77</dd>
<dt>Erstellt am</dt><dd>15.02.2015 um 23:16 Uhr</dd>
<dt>Zuletzt geändert</dt><dd>08.03.2015 um 13:47 Uhr</dd>
</dl>
</header>
<h1>Type your article <em>right here</em>.</h1>
<p>You may use <em>Markdown</em> to format.</p>
<footer>
<p><a href="tags/test.html" class="tag">#test</a> <a href="tags/picoblogger.html" class="tag">#picoblogger</a> <a href="tags/coden.html" class="tag">#coden</a> </p>
</footer>
</article>
</main>
<aside class="flex-item">
<h1>Übrigens ...</h1>
<h2>Letzte Artikel</h2>
<ul>
<li><a href="#2" title="24.02.2015 um 21:19 Uhr">Das ist der zweite Artikel</a></li><li><a href="#3" title="15.02.2015 um 23:18 Uhr">Ein zweiter Test!</a></li><li><a href="#1" title="15.02.2015 um 23:16 Uhr">Dies ist ein Test</a></li>
</ul>
<h2>Kontakt</h2>
<dl class="contact">
<dt>E-Mail</dt>
<dd>any@mail.address.org</dd>
<dt>Diaspora</dt>
<dd>youraccount@anypod.org</dd>
</dl>
</aside>
</div>
<footer>
<h1>Appendix</h1>
<dl>
<dt>powered with:</dt>
<dd>
<ul>
<li><a href="https://github.com/maste9/picoblogger">picoblogger</a></li>
</ul>
</dd>
</dl>
</footer>
</body>
</html>

View File

@ -26,7 +26,7 @@
<h1>Navigation</h1> <h1>Navigation</h1>
<ul> <ul>
<li><a href="index.html" class="home">Aktuell</a></li> <li><a href="index.html" class="home">Aktuell</a></li>
<li><a href="archive/">Archiv</a></li> <li><a href="archive.html">Archiv</a></li>
</ul> </ul>
</nav> </nav>
@ -35,130 +35,58 @@
<h1>Artikel</h1> <h1>Artikel</h1>
<article> <article>
<header> <header>
<h1 id="1425766116"><a href="#1425766116">Using Seconds since Epoch as Unique ID for Permalinking</a></h1> <h1 id="2"><a href="#2">Das ist der zweite Artikel</a></h1>
<dl> <dl>
<dt>Autor</dt><dd>homer77</dd> <dt>Autor</dt><dd>homer77</dd>
<dt>Erstellt am</dt><dd>07.03.2015 um 23:08 Uhr</dd> <dt>Erstellt am</dt><dd>24.02.2015 um 21:19 Uhr</dd>
<dt>Zuletzt geändert</dt><dd>07.03.2015 um 22:15 Uhr</dd> <dt>Zuletzt geändert</dt><dd>08.03.2015 um 13:47 Uhr</dd>
</dl> </dl>
</header> </header>
<p>My current idea regarding permalinking blog's articles is using seconds since epoche as a unique id which is defined at files creation.</p> <p>Dies ist der zweite Test.
Ich schreibe verschiedene Zeilen Text und teste damit <strong>Markdown</strong></p>
<p>Ist das jetzt ein neuer <em>Absatz</em>?</p>
<p>Und wie kann ich Code-Blöcke wie <code>apt-get install</code> einfügen? Funktioniert das mit 3 oder 4 Backticks?</p>
<p><code>Gehen auch
mehrere
Code-zeilen?</code></p>
<p>Und was ist mit Listen?
- Erster Eintrag
- Zweiter Eintrag
- Erster Untereintrag
- Dritter Eintrag</p>
<footer> <footer>
<p><a href="tags/uid.html" class="tag">#uid</a> <a href="tags/timestamp.html" class="tag">#timestamp</a> <a href="tags/permalink.html" class="tag">#permalink</a> </p> <p><a href="tags/lustig.html" class="tag">#lustig</a> <a href="tags/langweilig.html" class="tag">#langweilig</a> <a href="tags/blabla.html" class="tag">#blabla</a> </p>
</footer> </footer>
</article> </article>
<article> <article>
<header> <header>
<h1 id="5"><a href="#5">The fifth article</a></h1> <h1 id="3"><a href="#3">Ein zweiter Test!</a></h1>
<dl> <dl>
<dt>Autor</dt><dd>homer77</dd> <dt>Autor</dt><dd>homer77</dd>
<dt>Erstellt am</dt><dd>07.03.2015 um 12:00 Uhr</dd> <dt>Erstellt am</dt><dd>15.02.2015 um 23:18 Uhr</dd>
<dt>Zuletzt geändert</dt><dd>07.03.2015 um 22:36 Uhr</dd> <dt>Zuletzt geändert</dt><dd>08.03.2015 um 13:46 Uhr</dd>
</dl> </dl>
</header> </header>
<h2>This article is directly published!</h2> <h1>Das ist ein weiter Testartikel</h1>
<p>Without drafting and publishing.</p> <h2>Ich muss das abschließen für heute</h2>
<p><a href="https://example.org">Klick mich</a></p>
<footer> <footer>
<p><a href="tags/direct.html" class="tag">#direct</a> <a href="tags/article.html" class="tag">#article</a> <a href="tags/nodraft.html" class="tag">#nodraft</a> </p> <p></p>
</footer> </footer>
</article> </article>
<article> <article>
<header> <header>
<h1 id="4"><a href="#4">Fourth Article</a></h1> <h1 id="1"><a href="#1">Dies ist ein Test</a></h1>
<dl> <dl>
<dt>Autor</dt><dd>homer77</dd> <dt>Autor</dt><dd>homer77</dd>
<dt>Erstellt am</dt><dd>07.03.2015 um 11:06 Uhr</dd> <dt>Erstellt am</dt><dd>15.02.2015 um 23:16 Uhr</dd>
<dt>Zuletzt geändert</dt><dd>07.03.2015 um 22:36 Uhr</dd> <dt>Zuletzt geändert</dt><dd>08.03.2015 um 13:47 Uhr</dd>
</dl> </dl>
</header> </header>
<p>That's odd. While on my other machine everything was in order now on the other one some variables are not substituted. Concretely dates and time are not displayed.</p> <h1>Type your article <em>right here</em>.</h1>
<p><strong>This</strong> article is ought to test if a newly created will work as intended.</p> <p>You may use <em>Markdown</em> to format.</p>
<footer> <footer>
<p><a href="tags/bug.html" class="tag">#bug</a> <a href="tags/date.html" class="tag">#date</a> <a href="tags/templating.html" class="tag">#templating</a> </p> <p><a href="tags/test.html" class="tag">#test</a> <a href="tags/picoblogger.html" class="tag">#picoblogger</a> <a href="tags/coden.html" class="tag">#coden</a> </p>
</footer>
</article>
<article>
<header>
<h1 id="3"><a href="#3">Third Article</a></h1>
<dl>
<dt>Autor</dt><dd>homer77</dd>
<dt>Erstellt am</dt><dd>01.03.2015 um 19:35 Uhr</dd>
<dt>Zuletzt geändert</dt><dd>07.03.2015 um 22:35 Uhr</dd>
</dl>
</header>
<h2>What about publication order?</h2>
<p>I didn't care about pubdate yet ... nor the html5-tag neither the order of articles on this site. It should be ordered by date of creation - not by date of modification nor alphabetically.</p>
<footer>
<p><a href="tags/order.html" class="tag">#order</a> <a href="tags/ feature.html" class="tag"># feature</a> <a href="tags/ bug.html" class="tag"># bug</a> </p>
</footer>
</article>
<article>
<header>
<h1 id="2"><a href="#2">Second Article</a></h1>
<dl>
<dt>Autor</dt><dd>homer77</dd>
<dt>Erstellt am</dt><dd>01.03.2015 um 19:26 Uhr</dd>
<dt>Zuletzt geändert</dt><dd>07.03.2015 um 22:35 Uhr</dd>
</dl>
</header>
<p>This is the second article.</p>
<h2>How-To</h2>
<h3>Make a list</h3>
<ul>
<li>is this a list?</li>
<li>
<p>or this?</p>
<ul>
<li>or this?</li>
<li>or that?</li>
</ul>
</li>
<li>
<p>or must</p>
</li>
<li>indention be like this?</li>
</ul>
<p>Wuow! How come that it works now?!</p>
<ul>
<li>nobody knows</li>
<li>
<p>I see trouble</p>
</li>
<li>
<p>nobody knows</p>
</li>
<li>but Jesus.</li>
</ul>
<p>That`s unbelievable!</p>
<ol>
<li>Maybe the paragraph was missing?</li>
<li>
<p>Or there's sth wrong with the encoding?
2.1. Could it covariate with the fresh install of markdown?</p>
</li>
<li>
<p>This is</p>
</li>
<li>a strange</li>
<li>situation</li>
</ol>
<footer>
<p><a href="tags/picoblogger.html" class="tag">#picoblogger</a> <a href="tags/ test.html" class="tag"># test</a> <a href="tags/ how-to.html" class="tag"># how-to</a> </p>
</footer>
</article>
<article>
<header>
<h1 id="1"><a href="#1">This is the first article</a></h1>
<dl>
<dt>Autor</dt><dd>homer77</dd>
<dt>Erstellt am</dt><dd>01.03.2015 um 19:21 Uhr</dd>
<dt>Zuletzt geändert</dt><dd>07.03.2015 um 22:35 Uhr</dd>
</dl>
</header>
<p>This is the <em>first article</em> in this blog. <strong>picoblogger</strong> supports basic features of markdown as tested on another instance.</p>
<p>Unfortunately it does not seem to work with list - neither ordererd nor unordered. But <a href="http://localhost">links</a> actually do work fine.</p>
<footer>
<p><a href="tags/notags.html" class="tag">#notags</a> </p>
</footer> </footer>
</article> </article>
@ -167,7 +95,7 @@
<h1>Übrigens ...</h1> <h1>Übrigens ...</h1>
<h2>Letzte Artikel</h2> <h2>Letzte Artikel</h2>
<ul> <ul>
<li><a href="#1425766116" title="07.03.2015 um 23:08 Uhr">Using Seconds since Epoch as Unique ID for Permalinking</a></li><li><a href="#5" title="07.03.2015 um 12:00 Uhr">The fifth article</a></li><li><a href="#4" title="07.03.2015 um 11:06 Uhr">Fourth Article</a></li><li><a href="#3" title="01.03.2015 um 19:35 Uhr">Third Article</a></li><li><a href="#2" title="01.03.2015 um 19:26 Uhr">Second Article</a></li> <li><a href="#2" title="24.02.2015 um 21:19 Uhr">Das ist der zweite Artikel</a></li><li><a href="#3" title="15.02.2015 um 23:18 Uhr">Ein zweiter Test!</a></li><li><a href="#1" title="15.02.2015 um 23:16 Uhr">Dies ist ein Test</a></li>
</ul> </ul>

View File

@ -1,4 +1,4 @@
<ul> <ul>
<li><a href="index.html" class="home">${HOME_BUTTON}</a></li> <li><a href="index.html" class="home">${HOME_BUTTON}</a></li>
<li><a href="archive/">${ARCHIVE_BUTTON}</a></li> <li><a href="archive.html">${ARCHIVE_BUTTON}</a></li>
</ul> </ul>

View File

@ -79,6 +79,9 @@ tplDir = os.path.join(blog_dir,"templates")
# path to drafts # path to drafts
draftDir = os.path.join(blog_dir,"drafts") draftDir = os.path.join(blog_dir,"drafts")
# path to articles
articleDir = os.path.join(blog_dir,"articles")
# paths to configs # paths to configs
pbconfpath = os.path.join("/","etc","picoblogger","pb.conf") # global config pbconfpath = os.path.join("/","etc","picoblogger","pb.conf") # global config
blogconfpath = os.path.join(blog_dir,"pb.conf") # local config blogconfpath = os.path.join(blog_dir,"pb.conf") # local config
@ -160,8 +163,10 @@ def tags_to_html(tags):
tag_list = tags.split(",") tag_list = tags.split(",")
html_tags = "" html_tags = ""
sTAG = '<a href="tags/${TAG}.html" class="tag">#${TAG}</a> ' sTAG = '<a href="tags/${TAG}.html" class="tag">#${TAG}</a> '
for tag in tag_list:
html_tags += Template(sTAG).safe_substitute({'TAG':tag}) if len(tag_list) > 0 and len(tag_list[0]) > 1:
for tag in tag_list:
html_tags += Template(sTAG).safe_substitute({'TAG':tag})
return html_tags return html_tags
@ -244,7 +249,8 @@ def recent_articles(amount):
dates_of_creation = [float(value) for value in articles_dict.keys()] dates_of_creation = [float(value) for value in articles_dict.keys()]
dates_of_creation.sort(key=None,reverse=True) dates_of_creation.sort(key=None,reverse=True)
for i in range(0,amount): for i in range(0,amount):
joined_html += recent_to_html(articles_dict[str(time.strftime(str(dates_of_creation[i])))]) if i < len(dates_of_creation):
joined_html += recent_to_html(articles_dict[str(time.strftime(str(dates_of_creation[i])))])
return joined_html return joined_html
@ -255,6 +261,8 @@ def update_blog(subsection):
tplIndex = os.path.join(tplDir,"index.htm") tplIndex = os.path.join(tplDir,"index.htm")
blogIndex = os.path.join(blog_dir,"index.html") blogIndex = os.path.join(blog_dir,"index.html")
blogArchive = os.path.join(blog_dir,"archive.html")
tpl = Template(open(tplIndex,'r').read()) tpl = Template(open(tplIndex,'r').read())
sNAV = open(os.path.join(tplDir,"nav.htm")).read() sNAV = open(os.path.join(tplDir,"nav.htm")).read()
@ -262,6 +270,7 @@ def update_blog(subsection):
# sMAIN = open(os.path.join(tplDir,"main.htm")).read() # sMAIN = open(os.path.join(tplDir,"main.htm")).read()
# sMAIN = Template(sMAIN).safe_substitute(join_articles()) # sMAIN = Template(sMAIN).safe_substitute(join_articles())
sMAIN = join_articles() sMAIN = join_articles()
sARCHIVE = join_articles()
sASIDE = open(os.path.join(tplDir,"aside.htm")).read() sASIDE = open(os.path.join(tplDir,"aside.htm")).read()
sRECENT = open(os.path.join(tplDir,"recent.htm")).read() sRECENT = open(os.path.join(tplDir,"recent.htm")).read()
@ -302,6 +311,17 @@ def update_blog(subsection):
with open(blogIndex,"w", encoding=l10nconf['BLOG_CHARSET']) as f: with open(blogIndex,"w", encoding=l10nconf['BLOG_CHARSET']) as f:
print(tmpIndex, file=f) print(tmpIndex, file=f)
tplSub['TEMPLATE_MAIN'] = sARCHIVE
tmpIndex = Template(tmpIndex).safe_substitute(tplSub)
with open(blogArchive,"w", encoding=l10nconf['BLOG_CHARSET']) as f:
print(tmpIndex, file=f)
# def article_to_html(name): # def article_to_html(name):
# article = os.path.join(blog_dir,"articles",name + ".txt") # article = os.path.join(blog_dir,"articles",name + ".txt")
# txt = open(article).read() # txt = open(article).read()
@ -417,8 +437,10 @@ if vars(args)['target'] == 'article':
## list articles ## list articles
if vars(args)['action'] == 'list': if vars(args)['action'] == 'list':
pass [print(item) for item in [os.path.splitext(item)[0] for item in os.listdir(articleDir) if not "~" in item]]
## edit article ## edit article