Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about nikola (old posts, page 12)

The Password Is Password (follow the link to see what I mean)

I think this is a first in the world of stat­ic site gen­er­a­tors :-)

Now Niko­la sup­ports pass­word-pro­tect­ed pages. How does it work?

If you add a pass­word meta­da­ta field, then it will "Just Work". Like this:

I think this is a first in the world of stat­ic site gen­er­a­tors :-) And the re­sult is what you are see­ing now.

How is it im­ple­ment­ed? Niko­la will en­crypt the con­tent us­ing RC4, then wrap it in a <di­v>, and tack a form at the end that trig­gers Javascript code to de­crypt it, and show it.

Is it se­cure? Well, I am not a cryp­tog­ra­pher, so as­sume no. Specif­i­cal­ly, while RC4 is con­sid­ered se­cure, I am not dis­card­ing the be­gin­ning of they keystream, and the im­ple­men­ta­tions I am us­ing are not au­dit­ed.

So, don't use this for any­thing that could get you in trou­ble. Have fun!

UP­DATE Re­mem­ber when I asked "Is it se­cure?" well, re­al­ly, no it's not. It's not stupid in the sense that de­cod­ing what's writ­ten in the post will re­quire at least a mod­icum of ef­fort by who­ev­er is so in­ter­est­ed in read­ing what you are post­ing in your site, but peo­ple with cryp­to chops will crack it like a WEP-se­cured AP, mm­mmkay? It's al­so stupid­ly easy to brute­force this, so be smart about pass­word­s.

OTO­H, it's more se­cure than HTTP sim­ple au­th, since you can't sniff it (not that sim­ple auth is se­cure) and it can hide a piece of the page, which us­ing server-based auth can't.

I may do a more se­cure ver­sion even­tu­al­ly, but this is not it. There­fore, use for fun stuff, not to hide im­por­tan­t/il­le­gal stuff.

Nikola Internals Doc

Since Niko­la, my stat­ic blog/web­site gen­er­a­tor is get­ting a sub­stan­tial amount of code from oth­er­s, I thought it may be a good idea to rough­ly doc­u­ment how it works in­ter­nal­ly. So, here is Niko­la in­ter­nals which is very much a work in progress.

Migrating from Wordpress to Nikola

Sev­er­al peo­ple have mi­grat­ed from Word­press in­to Niko­la, and here are some of their de­scrip­tions of the pro­cess:

In gen­er­al, it seems to be work­ing, but there's some work still to be done. Word­press sup­ports many dif­fer­ent plug­ins and ex­ten­sions which re­act to markup in their pages, and sup­port­ing that's al­most an in­fi­nite task. Cur­rent­ly Niko­la's im­porter han­dles a few of the more com­mon. But if you try to im­port your blog and get less than ide­al re­sult­s, please file a bug and I'll do my best to fix it.

Usu­al­ly the fix­es are rather sim­ple, it's just that I have nev­er seen that spe­cif­ic thing ;-)

Have fun!

Standalone Search in Nikola

This has been in the mas­ter branch of Niko­la for a while but on­ly now have I tried to ful­ly in­te­grate it, and pol­ish all (most) of the rough edges.

By de­fault, Niko­la comes with sup­port for search forms us­ing Google and Duck­duck­go. Some peo­ple dis­ap­prove of them for dif­fer­ent rea­sons [1] so there was a re­quest about sup­port­ing a stand­alone search en­gine.

The best of breed of those things seems to be Tipue so that's what I sup­port­ed.

To use this, you need to en­able a plug­in, and do some con­fig­u­ra­tion changes.

The plugin is called task_localsearch and you can find it in the Nikola source tree

Suppose your site is in a folder called mysite then to enable this plugin you need to create mysite/plugins and then copy task_localsearch.plugin and task_localsearch in there.

Then, in your site's conf.py find these options and change them accordingly:

SEARCH_FORM = """
<span class="navbar-form pull-left">
<input type="text" id="tipue_search_input">
</span>"""

ANALYTICS = """
<script type="text/javascript" src="/assets/js/tipuesearch_set.js"></script>
<script type="text/javascript" src="/assets/js/tipuesearch.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('#tipue_search_input').tipuesearch({
        'mode': 'json',
        'contentLocation': '/assets/js/tipuesearch_content.json',
        'showUrl': false
    });
});
</script>
"""

EXTRA_HEAD_DATA = """
<link rel="stylesheet" type="text/css" href="/assets/css/tipuesearch.css">
<div id="tipue_search_content" style="margin-left: auto; margin-right: auto; padding: 20px;"></div>
"""

How does it work? Here's a de­mo site for you to try!

I would not rec­om­mend do­ing this for a big site, since it may load a mul­ti­-megabyte javascript file when you search, but for small to medi­um sites, it may be ok.


Contents © 2000-2024 Roberto Alsina