Posts about python (old posts, page 47)

Nicoletta: Nikola's little sister

Last night I saw this post by James Harding explaining how to make a simple static blog using Flask.

It got me thinking... how hard would it be, and how much code would it take, to write the same functionality with as few dependencies as possible?

So, instead of breakfast and lunch I got a coffee and a sandwich, and you guys get Nicoletta a minimalistic static blog generator.

The dependencies are:

And how much code was it? I had guessed 25 lines, and was off by a lot, it's 40. I could cheat a little and bring it down to 25, but hey, what's the point?

The code is up at github and should be self explanatory. If it's not, just ask here in the comments.

Nikola 6.0.0 released

Finally! This took a while because there was a lot of work done, but release 6.0.0 of Nikola my static site and blog generator is out.

Details, files, etc at github

I have tried, for this release, to do things better, be more careful and document as much as possible, as well as tried to hit most things that were hard to fix in a single backwards incompatible break.

Some of the new features are described in a series of blog posts: 1 2 3 4 5

Also: brand new modern themes site: http://themes.getnikola.com and new domain http://getnikola.com among many other tweaks.

Have fun!

Magic Mystery Forum Revisited

A long time ago I wrote a hackish minimalistic forum software, which used Disqus as a backend. Just to see if it still worked after 2.5 years, I took a look... and it sort of did.

So, since I know much more about websites now than I did back then, I cleaned it up a little and deployed it at http://forum.ralsina.me

Mostly, what I have learned in those 2.5 years is that bootstrap and JQuery are cool, and here is the before/after image so you can see why.

And yes, it's still 32 lines of code. I removed a comment because Disqus works better now and the rest is all template changes, done using http://jetstrap.com

/galleries/random/before-after.thumbnail.png

New in Nikola v6 part V: LESS is more

I am planning to do a major release (version 6!) of Nikola my static blog and site generator the next weekend. It's a major version because there has been a ton of feature work done. So, I will do a quick series highlighting some of those improvements this week.

Today's Topic: LESS

Unless you are happy with your site looking like straight bootstrap (and you really should not) CSS goes a long way towards making your pages look just the way you want them to.

The bad part is that, if you have done any CSS you will know CSS is a really, really crappy "language". That's why a whole philum of tools has been created that take a more powerful syntax and output CSS.

Nikola now has support for one of these, called LESS (although adding support for others like SASS should be very easy).

So, how does it work?

  1. In your theme, put LESS files in the less/ folder.
  2. Create less/targets and put there the files that should be compiled using lessc, one per line.
  3. There is no step 3

Nikola will automatically build output/assets/css/foo.css out of theme/foo/less/foo.less and will even support the usual theme inheritance, so if there ever is a LESS-based theme out there, you can just tweaks the files you want.

I personally am not writing that hypothetical LESS-based theme, but I am more than ready to help whoever wants to do one.

New in Nikola v6 part IV: Awesome Auto Mode

I am planning to do a major release (version 6!) of Nikola my static blog and site generator the next weekend. It's a major version because there has been a ton of feature work done. So, I will do a quick series highlighting some of those improvements this week.

Today's Topic: Auto Mode

Nikola has had, since day one, a way to run in "auto mode". That means that it would rebuild the site automatically when it saw a file change. That was provided by doit the cool software that handles nikola's task tree.

The problem was that it was slightly limited, and it didn't notice configuration changes, or when you added new files. It only reacted to changes in things it already knew as dependencies.

Well, in v6, Nikola has a new auto mode courtesy of Python Livereload that fixes all that.

I think the best way to show it is with a video, so here it is (there are typos and such, just see the big picture ;-):

New in Nikola v6 III: comment alternatives

I am planning to do a major release (version 6!) of Nikola my static blog and site generator the next weekend. It's a major version because there has been a ton of feature work done. So, I will do a quick series highlighting some of those improvements this week.

Today's Topic: Comments

Nikola has supported 3rd party comment services since day one. Because it started as "something that generates my site", it supported the comment system I was using (and still am using), Disqus.

There is nothing wrong with Disqus, and it will be the default in v6, but if you want something else... we got you covered.

So Nikola v6 supports:

All with just minor changes in your config. Because of how it's done, all themes will support all comment systems with at most very minor tweaks.

If you know of any other comment systems worth supporting, just open an issue and I'll get them in.

UPDATE
Thanks to Kwpolska and punchagan now Google+ and Facebook are also supported for comments.

New in Nikola v6 part II: We Love Javascript

I am planning to do a major release (version 6!) of Nikola my static blog and site generator the next weekend. It's a major version because there has been a ton of feature work done. So, I will do a quick series highlighting some of those improvements this week.

Today's Topic: Javascript

So, Nikola builds static pages. Like I often say, that doesn't mean they have to be boring. IN this release, Nikola's templates are organized in such a way that it's easy to create complex javascript-based layouts. Let's see an example.

Read more…

New in Nikola v6 part I: Typography

I am planning to do a major release (version 6!) of Nikola my static blog and site generator the next weekend. It's a major version because there has been a ton of feature work done. So, I will do a quick series highlighting some of those improvements this week.

Today's Topic: Typography.

Nikola used to suck at this. It produced sites like most websites: absolute garbage when it came to typography. So, we fixed it.

Here is what a certain section of A Study in Scarlet looked like when built using Nikola 5.5.1 (the current release):

Read more…

The best reStructuredText directive ever. Really.

It all started quietly with an Issue in the Nikola bug tracker:

gustavodiazjaimes opened this issue 3 hours ago
oembed by micawber - feature sugestion

instead of using specific code for embed object (Youtube, Vimeo, Soundcloud) use a generic solution like https://github.com/coleifer/micawber

So, I looked at micawber. And it's awesome and I had never heard of it before. What it does is, it looks at a URL, and if it knows the site where it's pointed at, it will then gather information from it. And using that information it will create for you a HTML fragment so you can embed it in your own HTML page.

And how hard is it to turn that into a reStructuredText directive? NOT HARD AT ALL.

import micawber

class Media(Directive):
    """ Restructured text extension for inserting any sort of media using micawber."""
    has_content = False
    required_arguments = 1

    def run(self):
        providers = micawber.bootstrap_basic()
        return [nodes.raw('', micawber.parse_text(self.arguments[0], providers), format='html')]

So now, in Nikola's github master you can do this:

Read more…

New Nikola Galleries

One of the requirements I had for Nikola my static site/blog generator, was that it should build image galleries. And that it should show the images sorted by date, and that it should be functional and nice.

Well, the nice part has been lacking for a long time. But I think I have a grasp on it now.

Here's before:

Read more…