From d9ae9febd9668f89c8694b66d7a0323027d416b2 Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Tue, 14 Oct 2014 01:22:31 +0200 Subject: redo website using bupa, ReST, and jinja templates --- Makefile | 22 +++++++--- partials/footer.html | 24 ----------- partials/meta.html | 8 ---- partials/nav.html | 7 ---- resources/glider.png | Bin 724 -> 0 bytes scripts/bupa | 93 +++++++++++++++++++++++++++++++++++++++++++ src/about.html | 44 -------------------- src/about.rst | 36 +++++++++++++++++ src/index.html | 26 ------------ src/index.rst | 9 +++++ src/journal.html | 56 -------------------------- src/journal/1-blogpost.rst | 16 ++++++++ src/journal/2-jellefant.rst | 11 +++++ src/journal/3-halosghost.rst | 11 +++++ src/resources/glider.png | Bin 0 -> 724 bytes src/style.css | 22 +++++----- src/templates/journal.html | 33 +++++++++++++++ src/templates/layout.html | 36 +++++++++++++++++ src/templates/nav.html | 7 ++++ src/templates/page.html | 17 ++++++++ 20 files changed, 297 insertions(+), 181 deletions(-) delete mode 100644 partials/footer.html delete mode 100644 partials/meta.html delete mode 100644 partials/nav.html delete mode 100644 resources/glider.png create mode 100755 scripts/bupa delete mode 100644 src/about.html create mode 100644 src/about.rst delete mode 100644 src/index.html create mode 100644 src/index.rst delete mode 100644 src/journal.html create mode 100644 src/journal/1-blogpost.rst create mode 100644 src/journal/2-jellefant.rst create mode 100644 src/journal/3-halosghost.rst create mode 100644 src/resources/glider.png create mode 100644 src/templates/journal.html create mode 100644 src/templates/layout.html create mode 100644 src/templates/nav.html create mode 100644 src/templates/page.html diff --git a/Makefile b/Makefile index d64c7e7..9deb502 100644 --- a/Makefile +++ b/Makefile @@ -12,24 +12,36 @@ site: $(addprefix build/, $(FILES)) clean: -rm $(addprefix build/, $(FILES)) +build/index.html: src/index.rst + @./scripts/bupa index.html + @echo Built index.html + +build/about.html: src/about.rst + @./scripts/bupa about.html + @echo Built about.html + +build/journal.html: $(shell find src/journal) + @./scripts/bupa journal.html + @echo Built journal + build/%.html: src/%.html $(PARTIALS) @./scripts/awink $< $@ @echo Compiled $< → $@ build/%.css: src/%.css @install -Dm644 $< $@ - @echo Compiled $< → $@ + @echo Copied $< → $@ -build/resources/%: resources/% +build/resources/%: src/resources/% @install -Dm644 $< $@ - @echo Compiled $< → $@ + @echo Copied $< → $@ build/sitemap.xml: src/sitemap.xml @install -Dm644 $< $@ - @echo Compiled $< → $@ + @echo Copied $< → $@ build/pgp-key.txt: src/pgp-key.txt @install -Dm644 $< $@ - @echo Compiled $< → $@ + @echo Copied $< → $@ partials/%: diff --git a/partials/footer.html b/partials/footer.html deleted file mode 100644 index cb16f70..0000000 --- a/partials/footer.html +++ /dev/null @@ -1,24 +0,0 @@ - diff --git a/partials/meta.html b/partials/meta.html deleted file mode 100644 index 71b20ad..0000000 --- a/partials/meta.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - diff --git a/partials/nav.html b/partials/nav.html deleted file mode 100644 index e40b4ed..0000000 --- a/partials/nav.html +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/resources/glider.png b/resources/glider.png deleted file mode 100644 index fd3a86f..0000000 Binary files a/resources/glider.png and /dev/null differ diff --git a/scripts/bupa b/scripts/bupa new file mode 100755 index 0000000..eca289a --- /dev/null +++ b/scripts/bupa @@ -0,0 +1,93 @@ +#!/usr/bin/env python +"""Usage: bupa + +Options: + -h --help Show this screen. +""" +from jinja2 import Environment, FileSystemLoader +import os, yaml, docopt + +from docutils import core +from docutils.writers.html4css1 import Writer + +def reST_to_html(s): + return core.publish_parts(s, writer_name='html4css1')['html_body'] + +def filename_to_id(file_name): + return int(file_name.split('/')[-1]. + split('-')[0]. + split('.')[0]) + +class Entry(object): + def __init__(self, entry_dict): + self.id = None + self.title = entry_dict['title'] + self.date = entry_dict['date'] + self.author = entry_dict['author'] + if 'author_link' in entry_dict: + self.author_link = entry_dict['author_link'] + self.body = entry_dict['body'][0] + +def parse(filename): + with open(filename, 'r') as file: + data = file.read() + + frontmatter, *body = data.split('\n\n', 1) + frontmatter = frontmatter.partition('\n')[2] + frontmatter = yaml.load(frontmatter) + + entry_dict = frontmatter.copy() + entry_dict['body'] = body + + entry = Entry(entry_dict) + return entry + +def build_journal(env): + template = env.get_template('journal.html') + + files = os.listdir('src/journal') + files.sort(key=filename_to_id, reverse=True) + + entries = [] + for file in files: + entry = parse('src/journal/' + file) + entry.body = reST_to_html(entry.body) + entry.id = filename_to_id(file) + entries += [entry] + + with open('build/journal.html', 'w') as file: + file.write(template.render(entries=entries, title='~/journal')) + +def build_index(env): + template = env.get_template('page.html') + + page = parse('src/index.rst') + page.body = reST_to_html(page.body) + page.article_id = 'index' + + with open('build/index.html', 'w') as file: + file.write(template.render(page=page, title=page.title)) + +def build_about(env): + template = env.get_template('page.html') + + page = parse('src/about.rst') + page.body = reST_to_html(page.body) + page.article_id = 'about' + + with open('build/about.html', 'w') as file: + file.write(template.render(page=page, title='~/about')) + +def main(): + arguments = docopt.docopt(__doc__) + env = Environment(loader=FileSystemLoader('src/templates')) + + if arguments[''] == 'journal.html': + build_journal(env) + elif arguments[''] == 'index.html': + build_index(env) + elif arguments[''] == 'about.html': + build_about(env) + +if __name__ == '__main__': + main() diff --git a/src/about.html b/src/about.html deleted file mode 100644 index c90458f..0000000 --- a/src/about.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - ~/about -%include partials/meta.html - - -
-%include partials/nav.html -

About me

-
- -
-

- I'm “kyrias”, also commonly known online as “demize”, but you can call me “Johannes Löthberg” if you’d like. Though if you ask my local government my last name doesn’t actually contain an ‘h’, which I find quite annoying. Anyway, I’m currently 18 years old, and I come from Sweden and have lived here my whole life. -

- -

- Online you can find me in various places under different names, though in almost all cases under one of the previously mentioned ones. I’m most commonly found on IRC as “demize”, and tend to hang out in the Arch Linux channels on the freenode IRC network, where I somehow ended up as a channel operator, but you will also sometimes find me in different places like on unix.SE where I go by the name kyrias. -

- -

- I also have a few Git repositories hosted on GitHub, where I go by the nick kyrias, in addition to the ones hosted on the kyriasis git hosting service, though you likely won’t find anything interesting in either place since I haven’t really made anything interesting to put up there. (yet?) -

- -

- I also maintain a couple of packages in the AUR, the Arch User Repository, which is a repository of community contributed PKGBUILDs for the Arch Linux distribution. Some of the packages are for software I use myself, others are packages that other maintainers haven’t taken care of, and the rest are packages that other people have requested to be created. -

- -

Contact

-

- You can contact me through email at johannes@kyriasis.com, through my Google+ profile, or through IRC where I tend to hang out as demize, mainly on the freenode but sometimes also on the Foonetic IRC networks. -

- Before contacting me through email consider getting my PGP key from either this link or fetching it from a keyserver using the key ID 0x50FB9B273A9D0BB5 and signing and/or encrypting your email to me. -

-

Last updated

-

- -
- -%include partials/footer.html - - diff --git a/src/about.rst b/src/about.rst new file mode 100644 index 0000000..ddcde05 --- /dev/null +++ b/src/about.rst @@ -0,0 +1,36 @@ +.. frontmatter + title: About me + date: 2014-10-14 + author: Johannes Löthberg + +I'm “kyrias”, also commonly known online as “demize”, but you can call me “Johannes Löthberg” if you’d like. Though if you ask my local government my last name doesn’t actually contain an ‘h’, which I find quite annoying. Anyway, I’m currently 18 years old, and I come from Sweden and have lived here my whole life. + +Online you can find me in various places under different names, though in almost all cases under one of the previously mentioned ones. I’m most commonly found on IRC_ as “demize”, and tend to hang out in the `Arch Linux`_ channels_ on the freenode_ IRC network, where I somehow ended up as a channel operator, but you will also sometimes find me in different places like on unix.SE_ where I go by the name kyrias_. + +I also have a few Git_ repositories hosted on my `GitHub account`_ in addition to the ones hosted on the kyriasis `git hosting`_ service, though you likely won’t find anything interesting in either place since I haven’t really made anything interesting to put up there. :sup:`(yet?)` + +I also maintain a couple of packages in the AUR_, the Arch User Repository, which is a repository of community contributed PKGBUILDs for the Arch Linux distribution. Some of the packages are for software I use myself, others are packages that other maintainers haven’t taken care of, and the rest are packages that other people have requested to be created. + +Contact +------- + +You can contact me through email at `johannes@kyriasis.com`_, through my `Google+ profile`_, or through IRC where I tend to hang out as demize, mainly on the freenode_ but sometimes also on the Foonetic_ IRC networks. + +Before contacting me through email consider getting my PGP key from either `this link`_ or fetching it from a keyserver using the key ID 0x50FB9B273A9D0BB5 and signing and/or encrypting your email to me. + +.. role:: sup + +.. _IRC: http://tools.ietf.org/html/rfc1459 +.. _Arch Linux: https://archlinux.org/ +.. _channels: ircs://chat.freenode.net/archlinux +.. _freenode: https://freenode.net/ +.. _unix.SE: http://unix.stackexchange.com/ +.. _kyrias: http://unix.stackexchange.com/users/33521 +.. _Git: http://git-scm.com/ +.. _GitHub account: https://github.com/kyrias +.. _git hosting: http://git.kyriasis.com/ +.. _AUR: https://aur.archlinux.org/ +.. _johannes@kyriasis.com: mailto:johannes@kyriasis.com +.. _Google+ profile: https://plus.google.com/+JohannesLothberg +.. _Foonetic: http://foonetic.net/ +.. _this link: pgp-key.txt diff --git a/src/index.html b/src/index.html deleted file mode 100644 index a848742..0000000 --- a/src/index.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - ~kyrias/ -%include partials/meta.html - - -
-%include partials/nav.html -

~kyrias/

-
- -
-

- Hello there, welcome to my empty corner of the Internet. There isn't really anything up here yet, and there likely never will be either for that matter, but feel free to check out my journal where I guess I’m supposed to actually write entries, and my about page if you for some reason want to read more about me. -

- -

Last updated

-

- -
- -%include partials/footer.html - - diff --git a/src/index.rst b/src/index.rst new file mode 100644 index 0000000..a57a4ae --- /dev/null +++ b/src/index.rst @@ -0,0 +1,9 @@ +.. frontmatter + title: ~kyrias/ + date: 2014-10-14 + author: Johannes Löthberg + +Hello there, welcome to my empty corner of the Internet. There isn't really anything up here yet, and there likely never will be either for that matter, but feel free to check out my journal_ where I guess I’m supposed to actually write entries, and my about_ page if you for some reason want to read more about me. + +.. _journal: journal.html +.. _about: about.html diff --git a/src/journal.html b/src/journal.html deleted file mode 100644 index 65ec807..0000000 --- a/src/journal.html +++ /dev/null @@ -1,56 +0,0 @@ - - - - - ~/journal -%include partials/meta.html - - -
-%include partials/nav.html -

The lost journal

-
- - -
-

Blogpost

-
- Published on - -
- -

Developers developers developers developers developers developers - developers developers developers developers developers DEVELOPERS open - source microsoft excel. Leadership i have never honestly thrown a chair - in my life open source i don't know what a monopoly is no i do not have - an ipod most people steal music windows phone linux is a cancer. Open - source DEVELOPERS most people steal music leadership. Innovation - outlook vista windows open source bing. DEVELOPERS developers - developers developers developers developers developers developers - developers developers developers developers winning Zune programming - open source vista linux is not in the public domain innovation.

-
- -
-

jellefant

-
- Published on - -
- -

I don't actually have anything at all to write here. So why am I even making this? Who the hell knows?!

- -

Jelle is a jellefant ❤

- -

And of course dagle is a hugosaur ❤

-
- -%include partials/footer.html - - diff --git a/src/journal/1-blogpost.rst b/src/journal/1-blogpost.rst new file mode 100644 index 0000000..014fb21 --- /dev/null +++ b/src/journal/1-blogpost.rst @@ -0,0 +1,16 @@ +.. frontmatter + title: Blogpost + date: 2014-08-22 + author: Johannes Löthberg + author_link: about.html + +Developers developers developers developers developers developers +developers developers developers developers developers DEVELOPERS open +source microsoft excel. Leadership i have never honestly thrown a chair +in my life open source i don't know what a monopoly is no i do not have +an ipod most people steal music windows phone linux is a cancer. Open +source DEVELOPERS most people steal music leadership. Innovation +outlook vista windows open source bing. DEVELOPERS developers +developers developers developers developers developers developers +developers developers developers developers winning Zune programming +open source vista linux is no diff --git a/src/journal/2-jellefant.rst b/src/journal/2-jellefant.rst new file mode 100644 index 0000000..e64e58c --- /dev/null +++ b/src/journal/2-jellefant.rst @@ -0,0 +1,11 @@ +.. frontmatter + title: jellefant + date: 2014-10-10 + author: Johannes Löthberg + authorUrl: https://theos.kyriasis.com/~kyrias/about.html + +I don't actually have anything at all to write here. So why am I even making this? Who the hell knows?! + +Jelle is a jellefant ❤ + +And of course dagle is a hugosaur ❤ diff --git a/src/journal/3-halosghost.rst b/src/journal/3-halosghost.rst new file mode 100644 index 0000000..068160d --- /dev/null +++ b/src/journal/3-halosghost.rst @@ -0,0 +1,11 @@ +.. frontmatter + title: Halosghostsomething + date: 2014-10-13 + author: Johannes Löthberg + author_link: about.html + +Wooh, halosghost_ is awesome and stuff and some other things... I need something better to do than trying to come up with fake entries. “ I am awesome.” + +Somethingsomethingsomething + +.. _halosghost: http://halosgho.st diff --git a/src/resources/glider.png b/src/resources/glider.png new file mode 100644 index 0000000..fd3a86f Binary files /dev/null and b/src/resources/glider.png differ diff --git a/src/style.css b/src/style.css index ad71adc..1784d6f 100644 --- a/src/style.css +++ b/src/style.css @@ -48,30 +48,30 @@ header h1 { margin: 0; } -.post, .botborder { +.entry, .botborder { margin-bottom: 1rem; border-bottom: 0.15rem; border-bottom-style: dotted; border-bottom-color: #bbb; } -.post { +.entry { color: #222; } -.post .title { +.entry .title { font-size: 1.4rem; - margin-top: 0; + margin-top: 0.3rem; margin-bottom: 0.3rem; } -.post .info { +.entry .info { font-size: 0.9rem; color: #505050; margin-bottom: -0.4rem; } -.post > p:first-of-type:first-letter { +.entry div > p:first-of-type:first-letter { float: left; color: #903; - font-size: 3rem; + font-size: 2.8rem; line-height: 2rem; padding-top: 0.4rem; padding-right: 0.4rem; @@ -79,24 +79,24 @@ header h1 { font-family: 'Georgia'; } @media (max-width: 767px) { - .post > p:first-of-type:first-letter { + .entry div > p:first-of-type:first-letter { padding-top: 0.3rem; padding-right: 0.2rem; font-size: 2.7rem; } } -#about { +#index, #about { padding-bottom: 0.5rem; color: #222; } -#about p#last-upd { +p#last-upd { font-size: 14px; text-align: right; margin: 0; } -#about p#author { +p#author { font-size: 14px; text-align: right; margin: 0; diff --git a/src/templates/journal.html b/src/templates/journal.html new file mode 100644 index 0000000..0269d2e --- /dev/null +++ b/src/templates/journal.html @@ -0,0 +1,33 @@ +{% extends 'layout.html' %} + +{% block content %} +
+{% include 'nav.html' %} +

The lost journal

+
+ +{% for entry in entries %} +
+ +

{{ entry.title }}

+ +
+ Published on + + + +
+ + {{ entry.body }} +
+{% endfor %} +{% endblock content %} diff --git a/src/templates/layout.html b/src/templates/layout.html new file mode 100644 index 0000000..45ab99d --- /dev/null +++ b/src/templates/layout.html @@ -0,0 +1,36 @@ + + + + + {{ title }} + + + + + + +{% block content %}{% endblock %} + + + diff --git a/src/templates/nav.html b/src/templates/nav.html new file mode 100644 index 0000000..e40b4ed --- /dev/null +++ b/src/templates/nav.html @@ -0,0 +1,7 @@ + diff --git a/src/templates/page.html b/src/templates/page.html new file mode 100644 index 0000000..9e0dddc --- /dev/null +++ b/src/templates/page.html @@ -0,0 +1,17 @@ +{% extends 'layout.html' %} + +{% block content %} +
+{% include 'nav.html' %} +

{{ page.title }}

+
+ + +{% endblock content %} -- cgit v1.2.3-70-g09d2