Posts about nikola (old posts, page 2)

2012-06-29 22:01

A Simple Nikola Link Checker

One of the most important things when you are building a static site generator like Nikola is that your site should not be broken. So, I really should have done this earlier ;-)

This is a very simple link checker that ensures the pages Nikola generates have no broken links. I will make it part of Nikola proper once it's more polished and doit supports getting a list of targets

To try it, get it and run it from the same place where you have your conf.py, right after you run doit.

import os
import urllib
from urlparse import urlparse

import lxml.html

def analyze(filename):
    try:
        # Use LXML to parse the HTML
        d = lxml.html.fromstring(open(filename).read())
        for l in d.iterlinks():
            # Get the target link
            target = l[0].attrib[l[1]]
            if target == "#":  # These are always valid
                continue
            parsed = urlparse(target)
            # We only handle relative links.
            # TODO: check if the URL points to inside the generated
            # site and check it anyway
            if parsed.scheme:
                continue
            # Ignore the fragment, since the link will still work
            # TODO: check that the fragment is valid
            if parsed.fragment:
                target = target.split('#')[0]
            # Calculate what file or folder this points to
            target_filename = os.path.abspath(
                os.path.join(os.path.dirname(filename), urllib.unquote(target)))
            # Check if it exists, or report it
            if not os.path.exists(target_filename):
                print "In %s broken link: " % filename, target
    except Exception as exc:
        # Something bad happened, report
        print "Error with:", filename, exc

# This is hackish: we use doit to get a list of all
# generated files. Minor modifications would let you check
# the non-generated files as well.

for task in os.popen('doit list --all', 'r').readlines():
    task = task.strip()
    if task.split(':')[0] in (
        'render_tags',
        'render_archive',
        'render_galleries',
        'render_indexes',
        'render_pages',
        'render_site') and '.html' in task:
            # It looks like a generated HTML file
            analyze(task.split(":")[-1])

2012-06-15 22:37

Nikola 3.0.1 Available for Testing

I have merged a bunch of patches from Kay Hayen and Kadefor:

  • disqus_developer is gone
  • addthis buttons are optional (controlled by a new option)
  • You can have more than one static files folder to be merged into output.
  • Image galleries support uppercase extensions.
  • Templates can not link to CSS that is empty/missing
  • Better Google Sitemaps
  • Preserve (some) metadata when copying files, like timestamps
  • Don't overwrite existing posts with doit new_post
  • Generate valid URLs from unicode titles

So, if you want to try it out:

https://github.com/ralsina/nikola/zipball/3.0.1

I will make it a real release if nothing bad shows up before sunday or monday.

2012-06-14 22:25

Now that's a nice theme.

I have been flooded by awesome patches for Nikola by different contributors, so there will be a new release very soon. In the meantime, see what happens if someone with design skills does a theme for it:

//ralsina.me/galleries/random/k4y.thumbnail.png

The author says he's polishing it and will be done in a few days.

2012-06-12 12:09

Nikola is FAST.

A fast-loading site is a good thing. Your site's speed matters. Which is why creating fast sites is one of Nikola's design goals.

Sure, it's not meant to create e-commerce sites, but if you are doing just a simple corporate site, or a personal blog, why would you not make it as fast as possible anyway?

So, here's one data point, from Kay Hayen

http://www.nuitka.net/posts/images/nikola-speed-improvements.png

Guess when Kay switched to Nikola.

But you don't have to just believe that graph. Here's Yahoo's YSlow report on this blog, which is hosted in a $5 VPS (as are other sites, BTW. The same VPS. As is a bunch of services. And my Quassel core)

http://ubuntuone.com/6Xsg1blhiJK7nEcnhPFOM7

It scores 94 on that test. That's 94 out of 100 possible points in the "Small Site or Blog" ruleset.

How much server tuning was needed? I added one line to the Apache config:

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css

That makes it compress those files before sending it to the user and improved the third item from F to A.

So, when I say Nikola makes your site fast, don't take my word for it, just check it out.

2012-06-10 18:38

Nikola 3 is out and it is good.

It's a major release, there is hardly any code from the previous version that was not moved, prodded, broken or fixed!

The main features of Nikola:

  • Blogs, with tags, feeds, archives, comments, etc.
  • Themable
  • Fast builds, thanks to doit
  • Flexible
  • Small codebase (programmers can understand all of Nikola in a few hours)
  • reStructuredText and Markdown as input languages
  • Easy image galleries (just drop files in a folder!)
  • Syntax highlighting for almost any programming language or markup
  • Multilingual sites
  • Doesn't reinvent wheels, leverages existing tools.

Changes for this release (not exhaustive!):

  • New optional template argument for "nikola init"
  • New "install_theme" task
  • Optional address option for the "serve" task
  • Better looking codeblocks
  • Russian translation
  • Use markdown/reSt compiler based on post extension
  • Don't fail when there are no posts/stories/galleries/tags
  • Use configuration options as dependencies
  • Use more relative links for easier site rellocation
  • Syntax highlight for markdown
  • Better multicore builds (make the -n 2 or -n 4 options work)
  • Configurable output folder
  • Don't fail on posts with periods in the name
  • Different page names for different languages
  • Recognize (some) Mako template dependencies
  • Is now a more "normal" python package.

2012-05-15 22:05

Nikola Plans

System Message: ERROR/3 (<string>, line 1)

Document or section may not begin with a transition.

I have not stopped working on Nikola, my static site generator. Here are the plans:

  1. Finish the theme installer (so you can get a theme from the site easily)
  2. Implement a theme gallery on the site (same purpose)
  3. Fix a couple of bugs
  4. Update manual
  5. Polish a few theme bits
  6. Release version 3.x (new major number because it requires manual migration)

After that, I will push on projects Shoreham (hosted sites) and Smiljan (planet generator) and make them more public. Shoreham will become a real web app for those who don't want to have their own server. For free, hopefully!

Once I have that, I have no further feature ideas, really. So I need more people to start using it, and that means I have to start announcing it more.

So, stay tuned for version 3.x sometime next week.

Post-Nikola, I will do a rst2pdf release, and then will get back to work on a book.

2012-05-08 10:54

Changing Color Schemes and Fonts in Nikola

One of the easiest ways to personalize how your site looks is using color and typography. While Nikola's "site" theme is intended to be rather bland and neutral, it doesn't have to be that way, and it's easy to change.

//ralsina.me/galleries/random/site-theme.thumbnail.png

Bland, solid and boring.

To do these changes, you don't even need to know any CSS, HTML, or programming!

Here's the trick: Nikola is using Twitter Bootstrap to handle its styling. And they provide a handy web form to create a customized version, just for you, at their customize page.

So, if you want auvergine navigation bars and avocado backgrounds, with courier fonts all over the place, that's where you do it. Just change the value in the right variable to whatever color you want.

Once you have your bootstrap.zip, go to your site's folder, and create themes/mytheme/assets and unzip it in there, so that you have themes/mytheme/assets/css, themes/mytheme/assets/js, etc.

Create a file called themes/mytheme/parent containing the word site.

Then edit your dodo.py (or conf.py if you are using the git master) and change the THEME option "mytheme".

Rebuild your site, and voilá, all your customizations are now in place.

This awfulness, for example, was done by setting just three variables (bodyBackground, textColor, and sansFontfamily):

//ralsina.me/galleries/random/site-c64.thumbnail.png

Yes, I had a C64.

2012-04-27 18:52

Shoreham: Blogging with Ubuntu One (a teaser)

So, today, I ripped off a great service offered by http://calepin.co and implemented a prototype blog-through-Ubuntu-One web application. Of course, it's powered by Nikola,

The code is absolute nonsense, and it needs to be looked at by someone who understands Django, OAuth, OpenID, and programming in general better than I do, but hey, it does work (for a very loose definition of "work").

It's called Shoreham and no, you can't have it yet.

As a teaser, here's a video. With a pony.

In the near future I will do a better post about this explaining the code, etc.

2012-04-24 22:46

Alva

Alva is almost the opposite of Nikola. If Nikola is about making static sites, Alva is a dynamic site. However, as Hegel suggests, from the thesis and the antithesis comes the synthesis.

So, Alva is about dynamically creating static sites. If you want to have Nikola in your server instead of in your own computer, and have the convenience of an online tool, that's the niche Alva tries to fill.

So, you would install Alva, and use it like any other web-based blogging tool. Yet, behind the scenes, you would have Nikola, and all the performance and security benefits of static sites.

And maybe someday, I (or someone) will put up a multi-user version of Alva, and you will be able to get hosted blogs, knowing all the data is yours and you can leave anytime and do your own thing.

This is very very early stages. So early it does not work yet. But here's a teaser:

//ralsina.me/galleries/random/nikola-admin3.thumbnail.png

There is no firm timeframe for this, it depends on a ton of other stuff and may not even happen.

2012-04-22 21:58

Nikola Screencast

I did some work today to get Nikola properly packaged. This involves some minor changes on the workflow for site authors. I am not 100% sure I have it right yet, so here is a short video showing how it works right now in the packaging branch I am doing.

The new thing is the nikola init foldername command, the rest is all old stuff. Basically, you stop having a full copy of Nikola for each site and everything is in a centralized location.

You can still do your own themes by putting them in themes/themename and add new tasks, files, etc. The configuration dodo.py is unchanged except for the "magic bit" which is slightly different.

So, not really invasive, easy to migrate to, and enables much easier updates in the future, as long as we don't break any important stuff in a non-compatible way.

Here is the video:

Contents © 2000-2018 Roberto Alsina