Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about nikola (old posts, page 6)

Nikola: New Tag Index Pages

Short and sweet:

In Niko­la my stat­ic site/blog gen­er­a­tor, the Tag pages used to just be a big list of ti­tles link­ing to the posts in the tag. Now they can (op­tion­al­ly) look just like the blog does, but fil­tered. Check it out.

Mi­nor tweaks still need­ed (like, men­tion­ing the tag some­where in the ti­tle), but the ba­sic func­tion­al­i­ty (fil­ter­ing, pag­i­na­tion, lay­out, etc) is com­plete.

To enable it in your site, just use master from git and enable TAG_PAGES_ARE_INDEXES = True in your conf.py.

Nikola 4 Released

I have just up­load­ed re­lease 4 of Niko­la my stat­ic blog/site gen­er­a­tor. Here are some of the changes in this ver­sion:

Features

  • Pre­vi­ous/Next post links

  • Teas­er sup­­port

  • Sup­­port posts with HTML "sources"

  • Site check­­ing script (niko­la_check)

  • Max­i­­mum im­age size in gal­­leries

  • Im­age de­scrip­­tions in gal­­leries

  • Im­age ex­­clu­­sion in gal­­leries

  • Spe­­cial "draft" tag

  • Pret­­ty code list­ings ("­­code gal­­leries")

  • Page de­scrip­­tions

  • Easy theme tun­ing via Bootswatch

  • Sup­­port for We­bAs­sets bun­­dles

  • "Fil­ter­s" for pow­er­­ful file post-pro­cess­ing

Bugfixes

  • Im­proved HTML out­­put

  • Sup­­port mul­ti­­ple time for­­mats in post meta­­da­­ta

  • Slugi­­fy tag names for URLs

  • Ar­chive path and file­­name con­­fig­urable

  • Gal­­leries sort­ed by date (sup­­ports EX­IF)

  • Ro­­tate gallery thum­b­­nails (EX­IF)

  • Tag feeds in tag pages

  • Col­or­box sup­­port in re­struc­­tured text fig­ures

  • Fix for con­­tent dis­­­play­ing too wide

  • Changel­og

As usu­al, you can dis­cuss bugs or make fea­ture re­quests at the niko­la-dis­cuss group and I love to know of sites us­ing Niko­la.

Hope you like it!

Nikola: Filters & Bundles

Two up­com­ing fea­tures for the next re­lease of Niko­la, my stat­ic site gen­er­a­tor, due some­time in Au­gust.

Filters

Fil­ters let you post­pro­cess your out­put. Think of it like in­sta­gram for web­sites, but use­ful. You can con­fig­ure per file ex­ten­sion a se­ries of python func­tions or shell com­mand­s, which will be ap­plied in place to the out­put file.

For ex­am­ple, sup­pose you want to ap­ply yui-­com­pres­sor to your CSS and JS files:

FILTERS = {
    ".css": [filters.yui_compressor],
    ".js": [filters.yui_compressor],
}

There, filters.yui_compressor is a simple wrapper around the command so that it applies in-place to the output files.

If you use strings there (untest­ed), they are tak­en as com­mand­s. The "%s" will be re­placed by the file­name, the usu­al crazy shell quot­ing rules ap­ply:

FILTERS = {
    ".jpg": ["jpegoptim '%s'"],
    ".png": ["pngoptim '%s'"],
}

Keep in mind that the fil­ters mod­i­fy the out­put of Niko­la, not the in­put, so your im­ages, CSS, and JS files will not be touched in any way. And of course chang­ing the fil­ters ap­plied to a file will force a re­build, so you can ex­per­i­ment freely.

Bundles

Hav­ing many sep­a­rate CSS or JS files is usu­al­ly a nono for per­for­mance rea­sons be­cause each one may in­volve a sep­a­rate HTTP trans­ac­tion. The so­lu­tion is to "bundle" those files in a sin­gle, larg­er file.

The rea­son not to do that is that usu­al­ly it means hav­ing a huge, un­com­fort­able thing to han­dle. So Niko­la tries to give you the best of both world­s, by let­ting you have sep­a­rate files, and bundling them (or not) on build.

There is a new option, USE_BUNDLES that defaults to False, and there are some changes in the theme templates so that it uses the bundled version when needed.

This was on­ly pos­si­ble thanks to We­bas­sets. How­ev­er, if you don't have We­bas­sets in­stalled, or you don't en­able USE_BUNDLES, this should cause no changes in the out­put.

Conclusion

These new fea­tures will al­low Niko­la users to im­prove their site's per­for­mance with min­i­mal tweak­ing, which is al­ways a good thing.

Nikola-as-a-service demo

One of the things I hacked at dur­ing this Py­Camp is try­ing to fig­ure out a nice work­flow for Niko­la, some­thing that will en­able users that are not so tech­ni­cal, to use it.

One first step is Niko­la-as-a-ser­vice, which is meant for tech­ni­cal users any­way but lays down the in­fra­struc­ture for this to work semi-nice­ly.

In the video be­low, you will see me do this:

  • Go to GitHub

  • Take a starter's blog I pro­vid­ed, and do a clone

  • Go to the niko­la-as-a-ser­vice site, and lo­­gin (via twit­ter)

  • Cre­ate a site us­ing my fork's re­po URL

  • Get a "we­b­hook" URL, and add it to my fork's ad­min as a post-­­com­mit hook

  • Ed­it a file in github's web UI and com­mit it (y­ou can of course just push from any github clien­t)

  • Au­­to­­mat­i­­cal­­ly, the site niko­la-as-a-ser­vice pub­­lish­es gets up­­­dat­ed.

Please don't try to use this ser­vice yet be­cause:

  1. It's run­n­ing in a $4.50/­­month serv­er

  2. It's the same serv­er my own blog us­es

  3. I will turn it of­f, delete ev­ery­thing, etc. ev­ery once in a while

  4. I am ed­it­ing the code on the server, so no guar­an­­tees it will not just stop work­ing.

So, here's the video:


Contents © 2000-2024 Roberto Alsina