Right so, does this work?
I'm using Hugo now. It's been... a bit of work. But the whole thing renders
in 1.4 seconds, as opposed to the old Jekyll site which took 22.
While I was at this, I did some more moderninzing.
Little changes:
- Post timestamps changed
- Posts are now using the HTML <article> element, complete with the
<header>, <main>, and <footer> sections.
- Navigation bar uses the HTML <nav> element
- Tag list now uses <ul> and <li>
- I've changed to using the CSS ::after
pseudo-element to put the bracketry around the menu items and the items in tag
lists. Why? It sure makes the HTML look cleaner.
- Many pages which used files ending in .html no longer do, I guess this is
what Hugo calls "pretty" URLs. Sure, why not.
Bug fixes:
- The first month in the archive sections is not duplicated like the Jekyll site
did
- The main image in the gallery isn't pushed up into the menu
To do still:
- Make the gallery's filmstrip scroll to keep the current selection visible -
good idea Rachyl!
So in an earlier post I mentioned I’d be rebuilding all of
my dynamically generated website stuff with a static generator. Still doing that, but now
I’m using Jekyll.
Mostly, I decided I just wouldn’t re-invent the wheel.
Some tricks
The posts tree
That tree on the left there - that’s generated with a method similar to
in this blog post, and uses
jquery.treeview at the moment
(must get around to updating that).
Also on the left, the tags list is auto-generated. Individual tag pages are automatically
generated using jekyll-tagging.
Instagram collection
On the right, we’ve got posts pulled from my Instagram account, using their
soon-to-be-deprecated Instagram API.
I have a script which basically generates a
Jekyll Collection from the available
posts, and then I render that with a simple bit of Liquid.
Probably I’m going to have to do some really annoying
data scraping if I want to keep
having this work in the future.
Concerns
Plugins are done in Ruby. I don’t like Ruby.
Also, a lot of the URLs have changed, but I’m not sure just how much I care
about that. I mean, who would be linking to this site?
Recently I decided it’s about time to retire the ancient server that has been
running my website (and mail and dns and a bunch of other things) -
It’s a Northwood
Pentium 4 Xeon
from 2002, the kind with Hyperthreading. Running Linux 3.7.10. 32-bit.
Yes, that’s old.
Rather than upgrade, I’m probably moving all of this somewhere else, likely a
cheap VPS somewhere… and since there’s a whole bunch of really old Perl
running things here… I’ve been doing some rewriting.
Static webpage generation
The original website I put on this current server used a backend based on some
unspeakable perl, but the most recent was using
Pylons… and by “recent” I mean circa 2010.
So yeah, that’s got to be redone. I pondered another web application, but
decided that rather than doing on-the-fly content generation from templates,
why not just pre-generate it?
So that’s what I’m doing. I’ve started building a bunch of Python scripts
using, Jinja templates, and
Markdown for blog
content. Naturally, all run by Makefiles.
Let’s Encrypt
Since I’m doing it all new, I’m finally going to go full SSL, via Let’s
Encrypt. Yeah, about time.
So yeah. Stay tuned.
December 21, 2012 @ 12:45
So I’m doing some REST stuff with SQLAlchemy classes, and I needed a simple way
to dump the objects to JSON. This base class will convert an object to a dict,
and has some options for funny fields and such.
You may (will) want to use a custom JSON encoder (see simplejson docs) to
convert some of the data types, like datetime.datetime in particular.
It’s certainly not ideal, in particular the isinstance() call, but it works
at the moment for what I’m doing.
class JsonObject(object):
def __to_json__(self, exclude_fields = []):
d = {}
for prop in dir(self):
if prop.startswith('_') or prop in exclude_fields:
continue
val = getattr(self, prop)
# we want standard data, not instance methods and such
if callable(val):
continue
if isinstance(val, (sqlalchemy.schema.MetaData, JsonObject)):
continue
# you can define a custom formatter for this data
if hasattr(self, '__formatters__') and prop in self.__formatters__:
d[prop] = self.__formatters__[prop](data)
else:
d[prop] = val
return d
I’ve been messing with building REST APIs in
Pyramid, and one thing that lacking was the
ability to send HTTP error messages to the client as JSON objects. Pyramid only
had support for HTML or plain text, neither of which is easy to parse when
you’re writing a JavaScript client.
So…. this commit
to the Pyramid project ought to take care of things nicely.
Hopefully they’ll accept my pull request. If not, I can always just maintain my
own fork.
So I’m testing out a new blogging enigne I’ve written in Python.
It’s based on Pylons and MongoDB, with a few nice extras, Genshi, WTForms,
jQuery, Markdown, the usual stuff. I did this mostly as a playground for using
these new technologies in various work and not-work projects.