* Headings of recent articles by user-defined amount
* Tags are processed as linked hash-tag * Headings of articles on index.html are linked with anchors which point to * an id build by timestamp or user-defined * some additions to default stylesheet.
This commit is contained in:
parent
f5ec071692
commit
71729d322c
|
@ -35,56 +35,70 @@
|
|||
<h1>Artikel</h1>
|
||||
<article>
|
||||
<header>
|
||||
<h1>The fifth article</h1>
|
||||
<h1 id="1425766116"><a href="#1425766116">Using Seconds since Epoch as Unique ID for Permalinking</a></h1>
|
||||
<dl>
|
||||
<dt>Autor</dt><dd>homer77</dd>
|
||||
<dt>Erstellt am</dt><dd>03/07/15 12:00:55</dd>
|
||||
<dt>Zuletzt geändert</dt><dd>03/07/15 11:03:18</dd>
|
||||
<dt>Erstellt am</dt><dd>07.03.2015 um 23:08 Uhr</dd>
|
||||
<dt>Zuletzt geändert</dt><dd>07.03.2015 um 22:15 Uhr</dd>
|
||||
</dl>
|
||||
</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>
|
||||
<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>
|
||||
</footer>
|
||||
</article>
|
||||
<article>
|
||||
<header>
|
||||
<h1 id="5"><a href="#5">The fifth article</a></h1>
|
||||
<dl>
|
||||
<dt>Autor</dt><dd>homer77</dd>
|
||||
<dt>Erstellt am</dt><dd>07.03.2015 um 12:00 Uhr</dd>
|
||||
<dt>Zuletzt geändert</dt><dd>07.03.2015 um 22:36 Uhr</dd>
|
||||
</dl>
|
||||
</header>
|
||||
<h2>This article is directly published!</h2>
|
||||
<p>Without drafting and publishing.</p>
|
||||
<footer>
|
||||
<p>direct,article,nodraft</p>
|
||||
<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>
|
||||
</footer>
|
||||
</article>
|
||||
<article>
|
||||
<header>
|
||||
<h1>Fourth Article</h1>
|
||||
<h1 id="4"><a href="#4">Fourth Article</a></h1>
|
||||
<dl>
|
||||
<dt>Autor</dt><dd>homer77</dd>
|
||||
<dt>Erstellt am</dt><dd>03/07/15 11:06:07</dd>
|
||||
<dt>Zuletzt geändert</dt><dd>03/07/15 10:10:50</dd>
|
||||
<dt>Erstellt am</dt><dd>07.03.2015 um 11:06 Uhr</dd>
|
||||
<dt>Zuletzt geändert</dt><dd>07.03.2015 um 22:36 Uhr</dd>
|
||||
</dl>
|
||||
</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>
|
||||
<p><strong>This</strong> article is ought to test if a newly created will work as intended.</p>
|
||||
<footer>
|
||||
<p>bug,date,templating</p>
|
||||
<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>
|
||||
</footer>
|
||||
</article>
|
||||
<article>
|
||||
<header>
|
||||
<h1>Third Article</h1>
|
||||
<h1 id="3"><a href="#3">Third Article</a></h1>
|
||||
<dl>
|
||||
<dt>Autor</dt><dd>homer77</dd>
|
||||
<dt>Erstellt am</dt><dd>03/01/15 19:35:06</dd>
|
||||
<dt>Zuletzt geändert</dt><dd>03/01/15 18:37:35</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>order, feature, bug</p>
|
||||
<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>Second Article</h1>
|
||||
<h1 id="2"><a href="#2">Second Article</a></h1>
|
||||
<dl>
|
||||
<dt>Autor</dt><dd>homer77</dd>
|
||||
<dt>Erstellt am</dt><dd>03/01/15 19:26:35</dd>
|
||||
<dt>Zuletzt geändert</dt><dd>03/01/15 18:34:20</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>
|
||||
|
@ -129,22 +143,22 @@
|
|||
<li>situation</li>
|
||||
</ol>
|
||||
<footer>
|
||||
<p>picoblogger, test, how-to</p>
|
||||
<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>This is the first article</h1>
|
||||
<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>03/01/15 19:21:24</dd>
|
||||
<dt>Zuletzt geändert</dt><dd>03/01/15 18:24:21</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>notags</p>
|
||||
<p><a href="tags/notags.html" class="tag">#notags</a> </p>
|
||||
</footer>
|
||||
</article>
|
||||
|
||||
|
@ -153,7 +167,7 @@
|
|||
<h1>Übrigens ...</h1>
|
||||
<h2>Letzte Artikel</h2>
|
||||
<ul>
|
||||
${RECENT_ARTICLES}
|
||||
<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>
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
BLOG_TITLE = Mein Blog
|
||||
BLOG_SUBTITLE = Meine Worte, Meine Meinung ... # Das ist ein Kommentar zum Testen
|
||||
BLOG_LANG = de
|
||||
BLOG_DATE_FORMAT = %d.%m.%Y
|
||||
BLOG_TIME_FORMAT = um %H:%M Uhr
|
||||
|
||||
CONTACT_MAIL_ADDRESS = any@mail.address.org
|
||||
CONTACT_SOCIAL_ADDRESS = youraccount@anypod.org
|
||||
|
||||
RECENT_AMOUNT = 5
|
||||
|
|
|
@ -5,6 +5,11 @@ body {
|
|||
background:#000;
|
||||
}
|
||||
|
||||
a {
|
||||
color:#999;
|
||||
}
|
||||
|
||||
|
||||
header *, nav *, footer *, div#flex-container {
|
||||
margin:0; padding:0;
|
||||
}
|
||||
|
@ -12,7 +17,7 @@ header *, nav *, footer *, div#flex-container {
|
|||
body > header {
|
||||
padding:0.5em 0.25em 0 0.25em;
|
||||
display:block;
|
||||
width:100%;
|
||||
width:99%;
|
||||
height:4em;
|
||||
background: #000;
|
||||
}
|
||||
|
@ -21,8 +26,8 @@ body > header h1 {
|
|||
font-family:"URW Gothic L";
|
||||
font-weight:lighter;
|
||||
padding:0.5em 0.5em 0 0;
|
||||
color:#fff;
|
||||
text-shadow:#999 0.2em -0.2em 0.1em;
|
||||
color:#aaa;
|
||||
text-shadow:#666 0.2em -0.2em 0.1em;
|
||||
float:right;
|
||||
}
|
||||
|
||||
|
@ -44,7 +49,7 @@ nav {
|
|||
font-family:"URW Gothic L";
|
||||
font-weight:lighter;
|
||||
padding:0.5em 0 0 0.5em;
|
||||
width:100%; height:1.75em;
|
||||
width:99%; height:1.75em;
|
||||
background:#999;
|
||||
font-size:0.8em;
|
||||
}
|
||||
|
@ -125,6 +130,11 @@ main > article > header {
|
|||
clear:both;
|
||||
}
|
||||
|
||||
main > article > header a {
|
||||
color:#999;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
main > article > header > h1 {
|
||||
width:100%;
|
||||
}
|
||||
|
@ -162,6 +172,11 @@ main > article > h2 { }
|
|||
main > article > h3 { }
|
||||
main > article > h4 { }
|
||||
|
||||
main > article > footer { }
|
||||
main > article > footer a {
|
||||
color:#999;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -179,17 +194,25 @@ aside {
|
|||
min-height:40em;
|
||||
}
|
||||
|
||||
aside h1 {
|
||||
text-align:center;
|
||||
aside h1, aside h2 {
|
||||
font-family:"URW Gothic L";
|
||||
font-weight:lighter;
|
||||
}
|
||||
|
||||
aside ul {
|
||||
list-style-type:none;
|
||||
}
|
||||
|
||||
aside ul li a, aside dl dd {
|
||||
color:#999;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
|
||||
footer {
|
||||
padding:0.5em 0.25em 0 0.25em;
|
||||
display:block;
|
||||
width:100%;
|
||||
width:99%;
|
||||
height:3.5em;
|
||||
background: #000;
|
||||
color:#999;
|
||||
|
@ -205,3 +228,8 @@ footer h1 {
|
|||
margin:0em 11em 0 0;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
footer ul li a, footer dl dd {
|
||||
color:#999;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<article>
|
||||
<header>
|
||||
<h1>${ARTICLE_TITLE}</h1>
|
||||
<h1 id="${ARTICLE_ID}"><a href="#${ARTICLE_ID}">${ARTICLE_TITLE}</a></h1>
|
||||
<dl>
|
||||
<dt>${TEMPLATE_ARTICLE_AUTHOR}</dt><dd>${ARTICLE_AUTHOR}</dd>
|
||||
<dt>${TEMPLATE_ARTICLE_CREATED}</dt><dd>${ARTICLE_CREATED_DATE} ${ARTICLE_CREATED_TIME}</dd>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# HEADER_BEGIN
|
||||
|
||||
ID : ${ID}
|
||||
DATE : ${DATE}
|
||||
TIME : ${TIME}
|
||||
AUTHOR : ${AUTHOR}
|
||||
|
|
|
@ -123,6 +123,9 @@ except:
|
|||
try:
|
||||
if os.path.isfile(blogconfpath):
|
||||
blogconf = parse_conf(blogconfpath)
|
||||
dateFormat = blogconf['BLOG_DATE_FORMAT']
|
||||
timeFormat = blogconf['BLOG_TIME_FORMAT']
|
||||
amountRecent = int(blogconf['RECENT_AMOUNT'])
|
||||
|
||||
except:
|
||||
print("Couldn't parse blog's local configuration (%s)."%blogconfpath)
|
||||
|
@ -148,18 +151,33 @@ def parse_article(path):
|
|||
body = markdown.markdown(article.split("HEADER_END")[1])
|
||||
article_dict = parse_conf(header)
|
||||
article_dict['BODY'] = body
|
||||
article_dict['MODIFIED_DATE'] = time.strftime("%x",time.gmtime(os.stat(path).st_mtime))
|
||||
article_dict['MODIFIED_TIME'] = time.strftime("%H:%M:%S",time.gmtime(os.stat(path).st_mtime))
|
||||
article_dict['MODIFIED_DATE'] = time.strftime(dateFormat,time.gmtime(os.stat(path).st_mtime))
|
||||
article_dict['MODIFIED_TIME'] = time.strftime(timeFormat,time.gmtime(os.stat(path).st_mtime))
|
||||
|
||||
return article_dict
|
||||
|
||||
def tags_to_html(tags):
|
||||
tag_list = tags.split(",")
|
||||
html_tags = ""
|
||||
sTAG = '<a href="tags/${TAG}.html" class="tag">#${TAG}</a> '
|
||||
for tag in tag_list:
|
||||
html_tags += Template(sTAG).safe_substitute({'TAG':tag})
|
||||
|
||||
return html_tags
|
||||
|
||||
|
||||
def article_to_html(article_dict):
|
||||
sARTICLE = open(os.path.join(tplDir,"article.htm")).read()
|
||||
sARTICLE = Template(sARTICLE).safe_substitute(l10nconf)
|
||||
|
||||
# Read out article txt file
|
||||
|
||||
article_dict['DATE'] = time.strftime(dateFormat, time.strptime(article_dict['DATE'],"%x"))
|
||||
article_dict['TIME'] = time.strftime(timeFormat, time.strptime(article_dict['TIME'],"%X"))
|
||||
article_dict['TAGS'] = tags_to_html(article_dict['TAGS'])
|
||||
|
||||
tplSub = {
|
||||
"ARTICLE_ID":article_dict['ID'],
|
||||
"ARTICLE_TITLE":article_dict['TITLE'],
|
||||
"ARTICLE_AUTHOR":article_dict['AUTHOR'],
|
||||
"ARTICLE_CREATED_DATE":article_dict['DATE'],
|
||||
|
@ -180,7 +198,7 @@ def join_articles():
|
|||
for name in [os.path.splitext(item)[0] for item in os.listdir(artDir) if not "\~" in item]:
|
||||
article = (parse_article(os.path.join(artDir, name + ".txt")))
|
||||
# Bring articles into chronological order
|
||||
t = time.mktime(time.strptime(article['DATE'] + " " + article['TIME'],"%m/%d/%y %H:%M:%S"))
|
||||
t = time.mktime(time.strptime(article['DATE'] + " " + article['TIME'], "%m/%d/%y %H:%M:%S"))
|
||||
articles_dict[str(t)] = article
|
||||
dates_of_creation = [float(value) for value in articles_dict.keys()]
|
||||
dates_of_creation.sort(key=None,reverse=True)
|
||||
|
@ -189,6 +207,47 @@ def join_articles():
|
|||
|
||||
return joined_html
|
||||
|
||||
def recent_to_html(article_dict):
|
||||
sLINK = '<li><a href="#${ARTICLE_ID}" title="${ARTICLE_CREATED_DATE} ${ARTICLE_CREATED_TIME}">${ARTICLE_TITLE}</a></li>'
|
||||
|
||||
# Read out article txt file
|
||||
|
||||
article_dict['DATE'] = time.strftime(dateFormat, time.strptime(article_dict['DATE'],"%x"))
|
||||
article_dict['TIME'] = time.strftime(timeFormat, time.strptime(article_dict['TIME'],"%X"))
|
||||
article_dict['TAGS'] = tags_to_html(article_dict['TAGS'])
|
||||
|
||||
tplSub = {
|
||||
"ARTICLE_ID":article_dict['ID'],
|
||||
"ARTICLE_TITLE":article_dict['TITLE'],
|
||||
"ARTICLE_AUTHOR":article_dict['AUTHOR'],
|
||||
"ARTICLE_CREATED_DATE":article_dict['DATE'],
|
||||
"ARTICLE_CREATED_TIME":article_dict['TIME'],
|
||||
"ARTICLE_MODIFIED_DATE":article_dict['MODIFIED_DATE'],
|
||||
"ARTICLE_MODIFIED_TIME":article_dict['MODIFIED_TIME'],
|
||||
"ARTICLE_BODY":article_dict['BODY'],
|
||||
"ARTICLE_TAGS":article_dict['TAGS']
|
||||
}
|
||||
|
||||
sLINK = Template(sLINK).safe_substitute(tplSub)
|
||||
return sLINK
|
||||
|
||||
|
||||
def recent_articles(amount):
|
||||
artDir = os.path.join(blog_dir,"articles")
|
||||
joined_html = ""
|
||||
articles_dict = {}
|
||||
for name in [os.path.splitext(item)[0] for item in os.listdir(artDir) if not "\~" in item]:
|
||||
article = (parse_article(os.path.join(artDir, name + ".txt")))
|
||||
# Bring articles into chronological order
|
||||
t = time.mktime(time.strptime(article['DATE'] + " " + article['TIME'], "%m/%d/%y %H:%M:%S"))
|
||||
articles_dict[str(t)] = article
|
||||
dates_of_creation = [float(value) for value in articles_dict.keys()]
|
||||
dates_of_creation.sort(key=None,reverse=True)
|
||||
for i in range(0,amount):
|
||||
joined_html += recent_to_html(articles_dict[str(time.strftime(str(dates_of_creation[i])))])
|
||||
|
||||
return joined_html
|
||||
|
||||
|
||||
def update_blog(subsection):
|
||||
# Joins config defined variables into templates
|
||||
|
@ -228,7 +287,7 @@ def update_blog(subsection):
|
|||
sRECENT = Template(sRECENT).safe_substitute(pbconf)
|
||||
sFOOTER = Template(sFOOTER).safe_substitute(pbconf)
|
||||
|
||||
|
||||
sRECENT = Template(sRECENT).safe_substitute({"RECENT_ARTICLES":recent_articles(amountRecent)})
|
||||
sASIDE = Template(sASIDE).safe_substitute({"ASIDE_RECENT":sRECENT, "ASIDE_CONTACT":sCONTACT})
|
||||
|
||||
tplSub = {
|
||||
|
@ -295,7 +354,7 @@ if vars(args)['target'] == 'draft':
|
|||
draft = os.path.join(blog_dir,"drafts",vars(args)['name'] + ".txt")
|
||||
tpl = os.path.join(tplDir,"article.tpl")
|
||||
sTpl = open(tpl).read()
|
||||
subs = {"DATE" : time.strftime("%x",time.localtime()), "TIME" : time.strftime("%X",time.localtime()),
|
||||
subs = {"ID":int(time.mktime(time.localtime())), "DATE" : time.strftime("%x",time.localtime()), "TIME" : time.strftime("%X",time.localtime()),
|
||||
"AUTHOR" : user
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue