Skip to main content

NoN: News, changes and release

Watch Knights of Ni grow up.

Versions'n'distros

Nikola v8

If you have not done yet you should read the upgrade guide to Nikola v8. NoN works with v7 and v8 nonetheless.

Runs on Archlinux and Ubuntu

I fiddled around until I got NoN working on a fresh Ubuntu 18.04 LTS installation. First install some dependencies:

$ sudo apt-get install gir1.2-webkit2-4.0 python3-pip

and then in lack of a package in the repositories install Nikola via pip:

$ pip3 install Nikola[extras]

If you are on (a) Archlinux (derivate) you can install Nikola from the repos:

$ sudo pacman -S nikola python-yaml

This is new since last release

Install/uninstall via setuptools

NoN is basically a Python script with a GtkBuilder GUI so in general you can get it running by executing non.py.

As an alternative you can now install or uninstall the application using setuptools which will also install a desktop entry so you can start the application from the menu:

# install for current user
python setup.py install --user
# install system-wide
sudo python setup.py install

Use the uninstall command to revert installation.

Config in YAML format

The configuration is stored in easy readable YAML format. As of now there are only bookmarks and the last working directory stored.

Editing or removing bookmarks can only be done here (GUI solution is on the roadmap).

Site data stored in JSON file

Application has been sped up by storing the sites (meta) data in a JSON formatted file. If a conf.py and the corresponding site is loaded into the application for the first time the data will be indexed. This initial task can take some time. On every next refresh/start this data will only be checked for changes and updated.

Optimized window space

I rearraged some elements to save some vertical space:

image1

is now

image2

Summary tab

The main window's notebook now has a new tab showing a HTML page with collected information about the current website:

  • disk usage

  • status (nikola status)

  • broken internal links (nikola check -l)

  • themes

  • plugins and

  • custom shortcodes

The CSS used is imitates GitHub style, credit goes to sindresorhus/github-markdown-css.

The summary is generated when initially indexing the site. Choose the menu item to generate a new report.

/images/non/non_summary.png

Summary tab

Localization support

There is now a translation template file (POT) waiting for translation. In case you have German localization, don't be irritated, there are only some strings translated yet.

Create posts/pages in Markdown

The default input format of Nikola is reStructuredText but it supports various other formats. You can now create new posts or pages in Markdown. This option is only available if "markdown" is set in the conf.py's COMPILERS variable.

You must also configure the POSTS and PAGES dictionaries, NoN does not check for this and will not throw an error message if not set.

/images/non/non_md.png

Markdown format checkbutton

Get help

The 'Help' button now contains a submenu with links to the Nikola handbook and to reStructuredText and Markdown syntax references so I...ehm you don't have to google them time and time again.

Thing left do do

Issues

  • icon not shown under Wayland

  • running application not marked at dock launcher (favorite), separate icon

Roadmap

  • preferences dialog/window

  • article templates (make use of nikola new_post --import...)

  • editor tab for quick editing

  • option to pull/push drafts from/to Git

Widget-Änderungen in GTK+ 2.20+

Auch wenn die Entwicklung von GTK+ 4 weit fortgeschritten ist, gibt es immer noch Änderungen in der 3er Version

Das GUI-Programm Glade wurde erst kürzlich modernisiert, in der Anwendung von Widgets sind mir einige Neuerungen aufgefallen. Dies fällt in der Regel durch entsprechende DeprecationWarnings in der Konsole auf, die Programme selbst funktionieren noch wie gewünscht.

Das heißt, die Artikel der Tutorial-Reihe bleiben vorerst unverändert (über eine gute Lösung muss ich noch nachdenken).

Es folgt eine nicht auf Vollständigkeit ausgelegte und bei Bedarf ergänzte Liste der Änderungen:

set_wm_class

Programmname in Panel und Dock anzeigen

Alt: Gtk.Window.set_wmclass(wmclass_name, wmclass_class)

Neu: GLib.set_prgname(wmclass_name) (in .desktop-Datei StartupWMClass=wmclass_name erforderlich)

widget.new_from_stock

Alt: Gtk.Button.new_from_stock(Gtk.STOCK_OK)

Neu: Gtk.Button.new_with_label("OK")

Labels bekommen nur noch eine Bezeichnung durch einen String.

Gilt auch für ToggleButton und Image (hier: image.new_from_icon_name() verwenden)

set_alignment

Alt: Gtk.Misc.set_alignment(x, y), z.B. bei Labels

Neu: Gtk.Widget-Alignment :halign und :valign verwenden

Vte-Terminal

Befehl übergeben

Alt: Vte.Terminal.feed_child(cmd, len(cmd)) (cmd ist das zu übergebene Kommando)

Neu: Vte.Terminal.feed_child(cmd.encode()) (seit v2.91)

Start

Alt: Vte.Terminal.spawn_sync(args)

Neu: GLib.spawn_async oder Vte.Pty.spawn_async (Details unbekannt)

FileChooserDialog

Alt:

dialog = Gtk.FileChooserDialog("Choose a folder",
                                app.obj("window"),
                                Gtk.FileChooserAction.SELECT_FOLDER,
                                (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                                Gtk.STOCK_APPLY, Gtk.ResponseType.OK))

'

Neu: Argumente werden namentlich übergeben, Buttons separat hinzugefügt:

dialog = Gtk.FileChooserDialog(title="Choose a folder",
                               parent=app.obj("window"),
                               action=Gtk.FileChooserAction.SELECT_FOLDER,
                               )
dialog.add_buttons("Cancel", Gtk.ResponseType.CANCEL,
                   "OK", Gtk.ResponseType.OK)

Embed Mastodon toots with Nikola

Reading the post Mastodon Embed Shortcode for hugo I became envious and thought 'We Nikola users might want that, too'. The Nikola handbook plainly admits to have 'adopted' the shortcode feature from Hugo so how hard can it be?

Here are three ways of embedding toots in your Nikola site using reStructuredText.

The raw directive

This directive enables you to pass content to the output without being processed. See reStructuredText Directives documentation for details.

raw.txt (Source)

.. raw:: html

    <iframe src="https://mastodon.social/@kevingimbel/100745593232538751/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="600" height="333"</iframe>

The raw shortcode

This is part of the built-in shortcodes. It works like the directive, you only need to use shortcode tags.

raw.txt (Source)

{{% raw %}}
<iframe src="https://mastodon.social/@kevingimbel/100745593232538751/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="600" height="333"</iframe>
{{% /raw %}}

Create your own shortcode

A separate shortcode can easily be realized with a template-based shortcode.

All you have to do is create a template and save it as your_shortcode_name.tmpl in the shortcodes folder of your Nikola site. If you do not use any custom shortcodes yet you will probably have to create the folder.

Depending on the template engine used by your theme you have to provide shortcode templates for Jinja2 or Mako:

The shortcode can be used as intended, pass a status and optionally width and height.

raw.txt (Source)

{{% mastodon status=https://mastodon.social/@kevingimbel/100745593232538751 %}}
{{% mastodon status=https://mastodon.social/@kevingimbel/100745593232538751 width=300 height=600 %}}

This is working for me but if the shortcode fails you should use the shortcode role to pass the text unaltered (consult the handbook for more information):

raw.txt (Source)

:sc:`{{% mastodon status=https://mastodon.social/@kevingimbel/100745593232538751 %}}`

You can also embed Pixelfed posts.

tfbrief - LaTeX-Briefvorlage

Manche raunen, Briefe mit LaTeX zu verfassen, wäre mit Kanonen auf Spatzen zu feuern. Die kennen die Dokumentenklasse tfbrief nicht.

tfbrief fiel mir einst vor Jahren zu und begeistert ob seiner Einfachheit nutzte ich es eifrig und verbreitete es fleißig unter Interessierten. Die Originalquelle ist inzwischen versiegt, doch ich konnte eine einsame Kopie auf GitHub ausfindig machen. Dabei stellte ich fest, dass die Dokumentenklasse quasi unverändert und weitgehend unter Ausschluss der Öffentlichkeit existierte.

Meine Änderungen:
  • obsoleten Code entfernen (fixltx2e package, tocityshort-Attribut)

  • die Option german lädt ngerman, wenn babel geladen wird

  • Typos (v.a. der Kommafehler in Abschlussformel (im Deutschen nicht vorhanden))

  • Betreffzeile serifenlos

  • eine weitere Beispieldatei

  • PDF-Outputs der Beispiele

  • ausführliche Dokumentation

Link zum Repository: GitHub: andre-lehnert/latex-letter

Packing GTK+ applications with setuptools

The only reason this page exists is to remove the links in my setup.py file.

Dependencies

from setuptools import setup

REQUIRED = ["PyGObject", ...]

setup(
    ...
    install_requires=REQUIRED,
    ...
    )

Pass the PyPI package name, for GTK+ applications you will need at least the GObject Python bindings to successfully run the import gi command.

Non-code files

from setuptools import setup

PACKAGES = ["my_package"]
PACKAGE_DIR = {"my_package": "my_package_dir"}
PACKAGE_DATA = {"my_package": ["ui/*", "logging.yaml"]}

setup(
    ...
    packages=PACKAGES,
    package_dir=PACKAGE_DIR,
    package_data=PACKAGE_DATA,
    ...
    )

The package "my_package" will be built from the files in "my_package_dir" folder into the "my_package" folder.

Non-code files like Glade files are passed as a list to the package_data option. In the example all files of the subfolder "ui" and the file "logging.yaml" are integrated into the package.

Desktop files

The locations of .desktop files and icons are defined by the Freedesktop specifications. Desktop entries for example are located in

/usr/share/applications
/usr/local/share/applications
~/.local/share/applications

While running install the suitable prefix will be identified so only relative paths are required to be passed to the data_files option.

from setuptools import setup

rel_app_path = "share/applications"
rel_icon_path = "share/icons/hicolor/scalable/apps"

DATAFILES = [
            (destination_dir, ["list", "of", "files"]),
            (rel_app_path, ["my_app.desktop"]),
            (rel_icon_path, ["my_appicon.svg"]),
            ]

setup(
    ...
    data_files=DATAFILES,
    ...
    )

This step only copies the files into the specific directories. The correct path declaration WITHIN the .desktop file has to be customized during the install command which will be accomplished by a custom function.

Customizing existing commands

The .desktop file includes information about the program to be executed as well as a corresponding icon, keywords etc. Because the target installation location may vary the file has to be adapted during the installation process.

To run own methods in existing commands you will have to create an instance of the specific command class (install, build, bdist etc.) and customize the "run" method.

In setuptools this information is passed to the cmd_class option.

from setuptools import setup
from setuptools.command.install import install

class CustomInstall(install):

    def run(self):
        self.my_function(args, go, here)
        install.run(self)

    def my_function(self, *args):
        try:
            do_some_shit()
        except:
            pass

setup(
    ...
    cmdclass={"install": CustomInstall}
    ...
    )

A list of available commands can be obtained by

$ python setup.py --help-commands

Creating new commands

Setuptools enables you to simply create your own commands. It may be useful to create an 'uninstall' command to get rid of all the files dumped to the system during installation to avoid to do that manually.

from setuptools import setup, Command

class UnInstall(Command):

    description = "description shown by setup.py --help-commands"
    user_options = [("myoption",
                     "m",
                     "myoption description shown by setup.py cmd --help")]

    def initialize_options(self):
        # method must exist
        # define all options with default value
        self.myoption = None

    def finalize_options(self):
        # method must exist
        pass

    def run(self):
        # method must exist
        # code to be executed goes here
        print("This is a custom command.")

setup(
    ...
    cmdclass={"uninstall": UnInstall}
    ...
    )

NoN: jetzt noch toller

Knights of Ni - sag niemals nie

Nach den kürzlichen Änderungen an der Oberfläche gibt es nun erfreuliche Fortschritte darunter zu vermelden.

Neuigkeiten

  1. Man kann NoN jetzt richtig (mit Hilfe von setuptools) installieren und deinstallieren.

  2. Vom Programm generierte Dateien werden nun wie üblich im eigenen Verzeichnis im Homeverzeichnis gespeichert.

  3. Der Programmablauf wurde beschleunigt und die Dateizugriffe massiv reduziert, indem die Posts-/Pages-Informationen für den wiederholten Abruf geparst und in einer JSON-Datei abgelegt werden.

Installation via setuptools

Bei der Installation via setuptools werden sowohl das Programm inklusive der UI als auch ein Desktopeintrag installiert. Nach der Installation lässt sich das Programm in GNOME also bequem über [super] + [n] (... [o] ... [n]) + [enter] starten.

Um dies alles auch wieder loszuwerden, gibt es ein zusätzliches uninstall-Kommando. Beide Kommandos sind mit der Option --user möglich:

# (De-/)Installation im lokalen Nutzerverzeichnis
$ python setup.py install --user
$ python setup.py uninstall --user

# systemweite (De-/)Installation
$ sudo python setup.py install
$ sudo python setup.py uninstall

Dateistruktur

Die Nutzerdaten liegen jetzt in ~/.non. Dort befinden sich

  1. die Konfigurationsdatei config.yaml, in der der Pfad zur aktuellen/letzten Nikola-Seite und die Bookmarks gespeichert sind,

  2. die Logdatei non.log sowie

  3. die geparsten Daten der aufgerufenen Nikola-Seiten jeweils als JSON-Datei.

Speicherung von (Meta-)Daten

Für die Anzeige im TreeStore wurden die Daten bisher sowieso intern als Dictionary gespeichert. Das Ineffiziente daran war allerdings, dass die Daten bei jedem Refresh immer neu abgerufen wurden. Dies ist nicht notwendig und mit zunehmender Größe der Seite auch sehr zäh.

Die Lösung bestand also darin, die Daten des Dictionary zum einen für den späteren Gebrauch in einer Datei zu speichern und zum anderen es nur durch eine Update-Funktion auf aktualisierte Inhalte zu überprüfen.

Auf diese Weise werden beim ersten Aufruf einer Nikola-Konfiguration alle Posts/Pages, Tags und Kategorien oder bei erneutem Aufruf die Daten aus der entsprechenden JSON-Datei eingelesen. Die Aktualisierung erfolgt über den Abgleich der letzten Dateimodifikation. Die JSON-Datei wird beim Wechsel in eine andere Nikola-Seite (z.B. über ein Bookmark) oder bei Programmende gespeichert.

Lost in the rabbit hole of Google Takeout

Backup your data. They said. All of it. They said. And then came Google Takeout

/images/import_gplus_post.png

G+ post HTML file from Takeout

I get the 4, 20 and Google+

Takeout is Google's user data archive system for numerous products. My primary target me was to download an archive of my Google+ activities.

The approach is quite simple: choose the product in Takeout and wait until the archive(s) has/have been generated. The downloadable archive will be valid for a week but you can generate new archives at any time.

Lesson 1:

Choose zip as filetype if you use umlauts, there could be encoding issues in tgz files.

I remembered that there was an import plugin for Nikola and I imagined to throw in the archive and to get a usable local site in return. At this point of the article the reader may speculate that this didn't work in the slightest way.

Unpacking presents

The first inspection reveals:

  1. All G+ posts are located in Google+ stream/Posts as HTML files. These files appear usable.

  2. Image links just point to filenames. The path is missing so only images in the same directory are shown but

  3. Images are scattered among different directories (in Posts and Photos and their subfolders). The majority of image files are stored in Photos of posts in date corresponding subfolders.

  4. There are different date formats in peaceful co-existence:

Photos of posts/
 ├── 02.06.14
 ├── 02.06.16
 ├── 22. Juli 2013
 ├── 23.01.17
 ├── 2011-08-14
 └── 2012-03-13
  1. There is a corresponding JSON file for every image but not for HTML files.

  2. Strucure of HTML files:

/images/import_gplus_inspector.thumbnail.png

Dumdidumdumdum...Inspektor Gadget

Lesson 2

You can open only single posts, there are a lot of deadlinks in image posts, but share and reaction information are displayed (public/private/collection/community post, +1, reshares and comments).

Your entry: Nikola

With low expectations I install the import plugin for Nikola and see what happens. Nothing. The posts once were provided as JSON files but not in recent days.

I brachiate through the files, importing HTML files first. The import plugin instantiates a new Nikola site, so I can just trial and error like hell. Then I care about deadlinks, then titles, it kepps getting better with every build.

The result is a static website of my Google+ stream including +1's and comments and a link to the original post.

Theming

In general the import is independent from any theme. I personally recommend hyde which even can be improved by the custom.css that is included in the archive.

Wishlist

  • local search function

  • filter posts by share status

Attention!

In case you consider a publicly accessible stream backup you have to keep in mind that the imported data also includes all privately shared posts.

Conclusion

As a long-term heavy Google+ user you are used to inconsistencies and improvementent constantly getting worse so a Takeout archive is no more than a sparring partner to train with. It is only a matter of time until my version of the import plugin will go the way of all those Google messengers before.

/images/takeout_gplus_slow.gif

static Google+ Nikola site (hyde theme)

Update

The end of Google+ has been recently announced and the issue of backing up and presentation of the data has become more relevant.

You can download the plugin now from GitHub: encarsia/gplus_nikola_import.

The associated article to the plugin: Nikola-Import-Plugin für Google+ (currently only in German but there is a detailed README file in the repository on how to get the plugin work).


Comment on

NoN: Fortschritte und Release

Knights of Ni - little release on the prairie

The GTK+ desktop client for static website generator Nikola has made some progress since mentioned last time here.

Nikola v8 will soon be released in June. I saved the current development status as a release because I cannot estimate how much effort I have to put into to make it ready for v8.

News

Headerbar

The submenu moved to the right side; on the left there is the GUI/teminal StackSwitcher; new: button that opens the Nikola handbook.

More deployment options
  • GitLab: use the "Deploy to GitHub" button, for help on configuration see this example Nikola site using GitLab.

  • Other: if there is DEPLOY_COMMANDS variable set in your conf.py the "Deploy" button will execute the 'default' preset.

GtkApplication

NoN now runs as a GtkApplication.

Desktop entry

Duckduckduckduckduck...

Open post/page in browser

Right click on an article to open it in the default webbrowser.

Bits and pieces

Bugfixes, improved logging, Python code is now conform to PEP8 (says pycodestyle).

/images/non3.thumbnail.png

Überarbeitete Oberfläche in Glade 3.22

Im Zuge der Veröffentlichung von GNOME 3.28 wurde auch Glade eine ordentliche Portion Zuwendung zuteil.

Headerbar

Das in GNOME 3.10 (Veröffentlichung 2013) eingeführte Headerbar-Widget ließ sich selbst bereits in Glade verwenden, die Anwendung selbst nutzte sie bisher nicht. Sie vereint Titelleiste, Menü, Toolbar und die Projekt-Tableiste. Durch diese Komprimierung wird viel leerer Raum eingespart (siehe Screenshots).

Arbeitsfläche

Die Dreiteilung der Oberfläche ist erhalten geblieben, es gibt aber zwei wesentliche Änderungen:

  1. Die Widgetauswahl erfolgt nicht mehr aus der linken Spalte, sondern sie ist oben auf der mittleren Arbeitsfläche als Buttonleiste mit Dropdown-Menü erreichbar.

  2. In der nun freien Spalte werden die Widgetstruktur des aktuellen Projekts angezeigt. Diese war zuvor in der oberen Hälfte der rechten Spalte zu finden.

Die Verlagerung der Widgetauswahl ermöglicht eine komplette Nutzung des vertikalen Platzes für die Anzeige der Struktur auf der linken sowie deren Eigenschaften auf der rechten Seite.

Tour

Beim ersten Aufruf der neuen Version startet ein Assistent, der etwas aufdringlich die Neuerungen anpreist. Dieser kann jederzeit über die Einstellungen in der Headerbar unter "Einführung in interaktive Benutzeroberflächen" erneut aufgerufen werden.

/images/glade322_tour.png

Tour-Wizard

Screenshots

/images/glade322.thumbnail.png

Glade 3.22

/images/01_glade.thumbnail.png

Glade 3.20

Nikola: everything zen

[UPDATE] Artikel wurde aktualisiert, keine manuelle Installation mehr notwendig

Aktualisiertes zen-Thema für Nikola

Ein Nachteil von Nikola ist meiner Meinung nach die stiefmütterliche Behandlung der Themes. Das von mir genutzte zen-Thema hatte ich bereits vor einiger Zeit auf Font Awesome 4-Icons geupdated und hier als Archiv zum Download bereitgestellt.

Inzwischen gibt es nicht nur Version 5 von Font Awesome, sondern auch einen Fork des Projektes namens Fork Awesome mit ein paar neuen Icons.

Dank eines Kommentars einer der Nikola-Devs (thx Roberto) hier habe ich mich nun durchgerungen, meine Änderungen offiziell per Pull Request einzureichen. Die zen-Familie ist nun auch im offiziellen Repository auf Font Awesome v4.7.0 geupdatet. Außerdem gibt es eine neue Variante, die die Fork Awesome-Icons nutzt. Eine manuelle Installation erübrigt sich also, sie kann direkt im Nikola-Projektordner erfolgen:

$ nikola theme -i zen-forkawesome

Anschließend muss das Thema nur noch in der conf.py aktiviert werden:

THEME = "zen-forkawesome"

Desweiteren werden die Icons nun mit "fa fa-iconname" angesprochen statt zuvor mit "icon-iconname". Dies ist auch in conf.py.sample vermerkt und wird bei der Installation des Themas angezeigt.

Die Änderungen werden natürlich erst nach dem nächsten nikola build wirksam. Da zen-forkawesome auf zen basiert, wird dieses Thema automatisch mit installiert.