Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about python (old posts, page 85)

Creating a Theme for Nikola From Scratch (almost)

There is some doc­u­men­ta­tion about cre­at­ing themes for Niko­la, but maybe a tu­to­ri­al is al­so a use­ful way to ex­plain it. So, here it is. I'll ex­plain how to cre­ate a theme (al­most) from scratch. Al­ter­na­tive­ly, you can take an ex­ist­ing theme and mod­i­fy on­ly parts of it via in­her­i­tance, but that's for an­oth­er doc­u­men­t.

I will try to cre­ate a theme that looks like Vini­cius Mas­suchet­to's Monospace Theme.

Read more…

Nikola Feature-by-request: tag cloud!

I asked for fea­ture re­quests for Niko­la my stat­ic site gen­er­a­tor. I got some. One was from long-­time us­er Kay Hayen, so I just could­n't say no.

He asked for tag cloud­s. Look:

Any­thing in here will be re­placed on browsers that sup­port the can­vas el­e­ment

Cute, is­n't it? And it's re­al, ac­tu­al tag da­ta from this very site. With links!

How it's done:

Niko­la gen­er­ates a JSON file that has the cloud da­ta (tag name, size, link), and that's pro­cessed by JQuery and tag­Can­vas and ... well, it work­s.

You have to add jquery.tagcanvas.min.js somewhere and embed a whole pile of raw HTML (see here for details) but hey, it works.

Hope you are hap­py, Kay, you made me code javascript, dude ;-)

It's prob­a­bly rather "easy" to make it use any of these in­stead of tag­Can­vas if any­one is so in­clined.

Why Use Something Else?

I wrote a stat­ic site gen­er­a­tor, called Niko­la a while ago, and it's start­ing to get some adop­tion and con­tri­bu­tion­s.

I think it's a fair­ly nice piece of code, to be hon­est, and it pret­ty much does ev­ery­thing I need. On the oth­er hand, it's fun to code with.

So, if you are us­ing an­oth­er stat­ic site gen­er­a­tor, or are re­search­ing in­to it, or just have opin­ions about it... what's miss­ing? What should it have that it does­n't have now?

No fea­ture too smal­l, no idea too crazy, please share! I prom­ise to make a good ef­fort to im­ple­ment any that seem like a good idea :-)

New in Nikola Master: Interactive Console

In­spired by Djan­go's in­ter­ac­tive con­sole, I added one to Niko­la, my stat­ic site gen­er­a­tor so that if you want to play with its in­ter­nal­s, you can do it eas­i­ly. Here's an ex­am­ple ses­sion:

$ nikola init pepe
A new site with some sample data has been created at pepe.
See README.txt in that folder for more information.
$ cd pepe
$ nikola console
Scanning posts
.
.
done!
You can now access your configuration as conf and your site engine as SITE
>>> [p.title('en') for p in SITE.timeline]
[u'Listings Demo', u'Nikola: it generates static', u'Welcome to Nikola',
u'A reStructuredText Primer', u'A reStructuredText Reference', u'Sample
Nikola Config File', u'The Nikola Handbook', u'Theming Nikola']

Have fun!

Nikola Wordpress Importer Improvements

Thanks to hav­ing users try­ing to ac­tu­al­ly im­port da­ta from word­press, the word­press im­porter plug­in for Niko­la, my stat­ic site gen­er­a­tor got a cou­ple of new fea­tures.

  • It will try to main­­tain your URLs via redi­rects

    If your post was in /2012/1/2/a-­­post/ and now it will be in /post­s/a-­­post.html it will cre­ate a re­di­rect from the for­mer to the lat­ter.

  • url_map for com­­ment mi­­gra­­tion

    It will cre­ate a CSV file con­­tain­ing the old,new full URLs so that you can move your dis­­qus threads to the right places.

Al­so, mas­ter works with do­cu­tils 0.10 which broke in the last re­lease.

For these rea­son­s, there will be a 5.0.1 re­lease to­day or to­mor­row.

PS: if you want to see a few sites us­ing Niko­la, now you can.


Contents © 2000-2020 Roberto Alsina