From f5ec071692060b116f18edd3ec4461b387a364e9 Mon Sep 17 00:00:00 2001 From: Homer Date: Sat, 7 Mar 2015 17:30:26 +0100 Subject: [PATCH] articles are in order and now can be created immediately without drafting. Footer and aside region are now templated which made templating a bit more complicated. At this moment I'm not sure how to deal with the 'recent' feature which could link to most recent articles. One could show last 5, only the last created and the last modified etc. But as the blog is not dynamic linking could be tricky ... I could use anchors to jump to certain articles but this doesn't solve that there will be no permalink ... Have to rethink this ... --- picoblogger/blog/index.html | 142 +++++++++++++++++++------ picoblogger/blog/l10n/de/static.conf | 9 ++ picoblogger/blog/pb.conf | 3 + picoblogger/blog/templates/aside.htm | 5 +- picoblogger/blog/templates/contact.htm | 7 ++ picoblogger/blog/templates/footer.htm | 10 +- picoblogger/blog/templates/recent.htm | 4 + picoblogger/main.py | 47 ++++++-- 8 files changed, 186 insertions(+), 41 deletions(-) create mode 100644 picoblogger/blog/templates/contact.htm create mode 100644 picoblogger/blog/templates/recent.htm diff --git a/picoblogger/blog/index.html b/picoblogger/blog/index.html index 4325770..3152c2d 100644 --- a/picoblogger/blog/index.html +++ b/picoblogger/blog/index.html @@ -35,69 +35,149 @@

Artikel

-

Das ist der zweite Artikel

+

The fifth article

Autor
homer77
-
Erstellt am
02/24/15 21:19:45
-
Zuletzt geändert
02/24/15 20:57:37
+
Erstellt am
03/07/15 12:00:55
+
Zuletzt geändert
03/07/15 11:03:18
-

Dies ist der zweite Test. -Ich schreibe verschiedene Zeilen Text und teste damit Markdown

-

Ist das jetzt ein neuer Absatz?

-

Und wie kann ich Code-Blöcke wie apt-get install einfügen? Funktioniert das mit 3 oder 4 Backticks?

-

Gehen auch -mehrere -Code-zeilen?

-

Und was ist mit Listen? -- Erster Eintrag -- Zweiter Eintrag -- Erster Untereintrag -- Dritter Eintrag

+

This article is directly published!

+

Without drafting and publishing.

-

lustig,langweilig,blabla

+

direct,article,nodraft

-

Ein zweiter Test!

+

Fourth Article

Autor
homer77
-
Erstellt am
02/15/15 23:18:22
-
Zuletzt geändert
02/15/15 22:19:30
+
Erstellt am
03/07/15 11:06:07
+
Zuletzt geändert
03/07/15 10:10:50
-

Das ist ein weiter Testartikel

-

Ich muss das abschließen für heute

-

Klick mich

+

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.

-

+

bug,date,templating

-

Dies ist ein Test

+

Third Article

Autor
homer77
-
Erstellt am
02/15/15 23:16:34
-
Zuletzt geändert
02/15/15 22:18:03
+
Erstellt am
03/01/15 19:35:06
+
Zuletzt geändert
03/01/15 18:37:35
-

Type your article right here.

-

You may use Markdown to format.

+

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.

-

test,picoblogger,coden

+

order, feature, bug

+
+
+
+
+

Second Article

+
+
Autor
homer77
+
Erstellt am
03/01/15 19:26:35
+
Zuletzt geändert
03/01/15 18:34:20
+
+
+

This is the second article.

+

How-To

+

Make a list

+ +

Wuow! How come that it works now?!

+ +

That`s unbelievable!

+
    +
  1. Maybe the paragraph was missing?
  2. +
  3. +

    Or there's sth wrong with the encoding? +2.1. Could it covariate with the fresh install of markdown?

    +
  4. +
  5. +

    This is

    +
  6. +
  7. a strange
  8. +
  9. situation
  10. +
+
+

picoblogger, test, how-to

+
+
+
+
+

This is the first article

+
+
Autor
homer77
+
Erstellt am
03/01/15 19:21:24
+
Zuletzt geändert
03/01/15 18:24:21
+
+
+

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.

+
+

notags

diff --git a/picoblogger/blog/l10n/de/static.conf b/picoblogger/blog/l10n/de/static.conf index 6441641..f46b548 100644 --- a/picoblogger/blog/l10n/de/static.conf +++ b/picoblogger/blog/l10n/de/static.conf @@ -9,7 +9,16 @@ TEMPLATE_ARTICLE_AUTHOR = Autor TEMPLATE_ARTICLE_CREATED = Erstellt am TEMPLATE_ARTICLE_MODIFIED = Zuletzt geändert +ASIDE_TITLE = Übrigens ... +RECENT_TITLE = Letzte Artikel +CONTACT_TITLE = Kontakt +CONTACT_MAIL_TITLE = E-Mail +CONTACT_SOCIAL_TITLE = Diaspora + NAV_TITLE = Navigation HOME_BUTTON = Aktuell ARCHIVE_BUTTON = Archiv BLOG_CHARSET = utf-8 + +FOOTER_TITLE = Appendix + diff --git a/picoblogger/blog/pb.conf b/picoblogger/blog/pb.conf index 9e5f49b..a096a3d 100644 --- a/picoblogger/blog/pb.conf +++ b/picoblogger/blog/pb.conf @@ -3,3 +3,6 @@ BLOG_TITLE = Mein Blog BLOG_SUBTITLE = Meine Worte, Meine Meinung ... # Das ist ein Kommentar zum Testen BLOG_LANG = de + +CONTACT_MAIL_ADDRESS = any@mail.address.org +CONTACT_SOCIAL_ADDRESS = youraccount@anypod.org diff --git a/picoblogger/blog/templates/aside.htm b/picoblogger/blog/templates/aside.htm index 2893ba0..af7cf03 100644 --- a/picoblogger/blog/templates/aside.htm +++ b/picoblogger/blog/templates/aside.htm @@ -1 +1,4 @@ -

By the way ...

+

${ASIDE_TITLE}

+${ASIDE_RECENT} + +${ASIDE_CONTACT} diff --git a/picoblogger/blog/templates/contact.htm b/picoblogger/blog/templates/contact.htm new file mode 100644 index 0000000..261b4d5 --- /dev/null +++ b/picoblogger/blog/templates/contact.htm @@ -0,0 +1,7 @@ +

${CONTACT_TITLE}

+
+
${CONTACT_MAIL_TITLE}
+
${CONTACT_MAIL_ADDRESS}
+
${CONTACT_SOCIAL_TITLE}
+
${CONTACT_SOCIAL_ADDRESS}
+
diff --git a/picoblogger/blog/templates/footer.htm b/picoblogger/blog/templates/footer.htm index 35800d3..6220fcb 100644 --- a/picoblogger/blog/templates/footer.htm +++ b/picoblogger/blog/templates/footer.htm @@ -1 +1,9 @@ -

Das Beste zum Schluss

+

${FOOTER_TITLE}

+
+
powered with:
+
+ +
+
diff --git a/picoblogger/blog/templates/recent.htm b/picoblogger/blog/templates/recent.htm new file mode 100644 index 0000000..c876adb --- /dev/null +++ b/picoblogger/blog/templates/recent.htm @@ -0,0 +1,4 @@ +

${RECENT_TITLE}

+ diff --git a/picoblogger/main.py b/picoblogger/main.py index 1ec5bf0..03b26e8 100755 --- a/picoblogger/main.py +++ b/picoblogger/main.py @@ -177,7 +177,7 @@ def join_articles(): artDir = os.path.join(blog_dir,"articles") joined_html = "" articles_dict = {} - for name in [os.path.splitext(item)[0] for item in os.listdir(draftDir) if not "\~" in item]: + 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")) @@ -188,6 +188,7 @@ def join_articles(): joined_html += article_to_html(articles_dict[str(time.strftime(str(date)))]) return joined_html + def update_blog(subsection): # Joins config defined variables into templates @@ -196,12 +197,6 @@ def update_blog(subsection): blogIndex = os.path.join(blog_dir,"index.html") tpl = Template(open(tplIndex,'r').read()) - tmpIndex = tpl.safe_substitute(l10nconf) - - if blogconf: - tmpIndex = Template(tmpIndex).safe_substitute(blogconf) - if pbconf: - tmpIndex = Template(tmpIndex).safe_substitute(pbconf) sNAV = open(os.path.join(tplDir,"nav.htm")).read() sNAV = Template(sNAV).safe_substitute(l10nconf) @@ -209,8 +204,33 @@ def update_blog(subsection): # sMAIN = Template(sMAIN).safe_substitute(join_articles()) sMAIN = join_articles() sASIDE = open(os.path.join(tplDir,"aside.htm")).read() + + sRECENT = open(os.path.join(tplDir,"recent.htm")).read() + sCONTACT = open(os.path.join(tplDir,"contact.htm")).read() sFOOTER = open(os.path.join(tplDir,"footer.htm")).read() + tmpIndex = tpl.safe_substitute(l10nconf) + sASIDE = Template(sASIDE).safe_substitute(l10nconf) + sCONTACT = Template(sCONTACT).safe_substitute(l10nconf) + sRECENT = Template(sRECENT).safe_substitute(l10nconf) + sFOOTER = Template(sFOOTER).safe_substitute(l10nconf) + + if blogconf: + tmpIndex = Template(tmpIndex).safe_substitute(blogconf) + sASIDE = Template(sASIDE).safe_substitute(blogconf) + sCONTACT = Template(sCONTACT).safe_substitute(blogconf) + sRECENT = Template(sRECENT).safe_substitute(blogconf) + sFOOTER = Template(sFOOTER).safe_substitute(blogconf) + if pbconf: + tmpIndex = Template(tmpIndex).safe_substitute(pbconf) + sASIDE = Template(sASIDE).safe_substitute(pbconf) + sCONTACT = Template(sCONTACT).safe_substitute(pbconf) + sRECENT = Template(sRECENT).safe_substitute(pbconf) + sFOOTER = Template(sFOOTER).safe_substitute(pbconf) + + + sASIDE = Template(sASIDE).safe_substitute({"ASIDE_RECENT":sRECENT, "ASIDE_CONTACT":sCONTACT}) + tplSub = { "TEMPLATE_NAV":sNAV, "TEMPLATE_MAIN":sMAIN, @@ -322,7 +342,18 @@ if vars(args)['target'] == 'article': ## add new article if vars(args)['action'] == 'add': - pass + article = os.path.join(blog_dir,"articles",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()), + "AUTHOR" : user + } + + sTpl = Template(sTpl).safe_substitute(subs) + with open(article,"w", encoding=l10nconf['BLOG_CHARSET']) as f: + print(sTpl, file=f) + + subprocess.call(["emacs", "-nw", article]) ## list articles