diff --git a/picoblogger/blog/index.html b/picoblogger/blog/index.html
index 3152c2d..59c13d5 100644
--- a/picoblogger/blog/index.html
+++ b/picoblogger/blog/index.html
@@ -35,56 +35,70 @@
Artikel
- The fifth article
+
- Autor
- homer77
- - Erstellt am
- 03/07/15 12:00:55
- - Zuletzt geändert
- 03/07/15 11:03:18
+ - Erstellt am
- 07.03.2015 um 23:08 Uhr
+ - Zuletzt geändert
- 07.03.2015 um 22:15 Uhr
+
+
+ My current idea regarding permalinking blog's articles is using seconds since epoche as a unique id which is defined at files creation.
+
+
+
+
+
+
+ - Autor
- homer77
+ - Erstellt am
- 07.03.2015 um 12:00 Uhr
+ - Zuletzt geändert
- 07.03.2015 um 22:36 Uhr
This article is directly published!
Without drafting and publishing.
- Fourth Article
+
- Autor
- homer77
- - Erstellt am
- 03/07/15 11:06:07
- - Zuletzt geändert
- 03/07/15 10:10:50
+ - Erstellt am
- 07.03.2015 um 11:06 Uhr
+ - Zuletzt geändert
- 07.03.2015 um 22:36 Uhr
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.
This article is ought to test if a newly created will work as intended.
- Third Article
+
- Autor
- homer77
- - Erstellt am
- 03/01/15 19:35:06
- - Zuletzt geändert
- 03/01/15 18:37:35
+ - Erstellt am
- 01.03.2015 um 19:35 Uhr
+ - Zuletzt geändert
- 07.03.2015 um 22:35 Uhr
What about publication order?
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.
- Second Article
+
- Autor
- homer77
- - Erstellt am
- 03/01/15 19:26:35
- - Zuletzt geändert
- 03/01/15 18:34:20
+ - Erstellt am
- 01.03.2015 um 19:26 Uhr
+ - Zuletzt geändert
- 07.03.2015 um 22:35 Uhr
This is the second article.
@@ -129,22 +143,22 @@
situation
- This is the first article
+
- Autor
- homer77
- - Erstellt am
- 03/01/15 19:21:24
- - Zuletzt geändert
- 03/01/15 18:24:21
+ - Erstellt am
- 01.03.2015 um 19:21 Uhr
+ - Zuletzt geändert
- 07.03.2015 um 22:35 Uhr
This is the first article in this blog. picoblogger supports basic features of markdown as tested on another instance.
Unfortunately it does not seem to work with list - neither ordererd nor unordered. But links actually do work fine.
@@ -153,7 +167,7 @@
Übrigens ...
Letzte Artikel
diff --git a/picoblogger/blog/pb.conf b/picoblogger/blog/pb.conf
index a096a3d..5e6b19c 100644
--- a/picoblogger/blog/pb.conf
+++ b/picoblogger/blog/pb.conf
@@ -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
diff --git a/picoblogger/blog/style.css b/picoblogger/blog/style.css
index eae5dde..5c12dd5 100644
--- a/picoblogger/blog/style.css
+++ b/picoblogger/blog/style.css
@@ -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;
+}
diff --git a/picoblogger/blog/templates/article.htm b/picoblogger/blog/templates/article.htm
index 71782d7..fd0b4e6 100644
--- a/picoblogger/blog/templates/article.htm
+++ b/picoblogger/blog/templates/article.htm
@@ -1,6 +1,6 @@
- ${ARTICLE_TITLE}
+
- ${TEMPLATE_ARTICLE_AUTHOR}
- ${ARTICLE_AUTHOR}
- ${TEMPLATE_ARTICLE_CREATED}
- ${ARTICLE_CREATED_DATE} ${ARTICLE_CREATED_TIME}
diff --git a/picoblogger/blog/templates/article.tpl b/picoblogger/blog/templates/article.tpl
index d0a2fc7..d58d364 100644
--- a/picoblogger/blog/templates/article.tpl
+++ b/picoblogger/blog/templates/article.tpl
@@ -1,5 +1,6 @@
# HEADER_BEGIN
+ID : ${ID}
DATE : ${DATE}
TIME : ${TIME}
AUTHOR : ${AUTHOR}
diff --git a/picoblogger/main.py b/picoblogger/main.py
index 03b26e8..13a67a3 100755
--- a/picoblogger/main.py
+++ b/picoblogger/main.py
@@ -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 = '#${TAG} '
+ 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 = '
${ARTICLE_TITLE}'
+
+ # 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
}