Calmdevelopment

Keep calm and code. Or do some other stuff.


lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux bullseye/sid
Release:        testing
Codename:       bullseye

Opensuse Kubic project ersetzt Ubuntu projectatomic repository

Die letzte Version von podman im projectatomic repository ist 1.6.3. Siehe https://launchpad.net/~projectatomic/+archive/ubuntu/ppa.

Die neueste Version von podman ist 1.8.2.

Es gibt eine Anleitung zur Installation für Debian.

Dieser bin ich gefolgt und habe nun die aktuellste Version von podman.

Was ist mit einem offiziellen Debian repository?

Daran wird gearbeitet. Kann man das auch der Installationsanleitung für Debian entnehmen.

Hier noch ein ergänzender Link https://wiki.debian.org/Podman

Repo hinzufügen

Das projectatomic repository habe ich rausgeworfen und das opensuse kubic repo statt dessen hinzugefügt.

echo 'deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_Testing/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_Testing/Release.key | sudo apt-key add -

podman installieren

sudo apt update
sudo apt install podman

Es kam zu Konflikten mit einer Bibliothek. Diese habe ich folgendermaßen behoben:

apt --fix-broken install
apt install
Updated: 05.05.2019

lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux buster/sid
Release:        testing
Codename:       buster

Ubuntu projectatomic repository hinzufügen

In den offiziellen repositories von Debian ist podman nicht enthalten. Dafür lässt sich das projectatomic ubuntu repository verwenden.

Repo hinzufügen

sudo add-apt-repository "deb http://ppa.launchpad.net/projectatomic/ppa/ubuntu bionic main"

Signatur key hinzufügen

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8BECF1637AD8C79D
Ausgabe nach Ausführung
Executing: /tmp/apt-key-gpghome.3JoLjtvYdG/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8BECF1637AD8C79D
gpg: Schlüssel 8BECF1637AD8C79D: Öffentlicher Schlüssel "Launchpad PPA for Project Atomic" importiert
gpg: Anzahl insgesamt bearbeiteter Schlüssel: 1
gpg:                              importiert: 1

podman installieren

sudo apt update
sudo apt install podman

user namespaces aktivieren

Folgender Fehler begrüßte mich beim ersten Ausführen von podman

podman
cannot clone: Operation not permitted
user namespaces are not enabled in /proc/sys/kernel/unprivileged_userns_clone

Unter Debian muss man diese Option erst aktivieren.

echo 'kernel.unprivileged_userns_clone=1' > /etc/sysctl.d/00-local-userns.conf
service procps restart

registry konfigurieren

Man kann verschiedene container registries konfigurieren. Nach einer frischen Installation muss man docker.io noch zu den registries hinzufügen, um images von docker herunterladen zu können. Anderenfalls muss man die komplette registry url mit angeben.

z.B.: podman search docker.io/alpine vs podman search alpine

/etc/containers/registries.conf
[registries.search]
registries = ['docker.io']

A little example how to handle custom dates with jbake, using groovy MarkupTemplateEngine, to generate a valid sitemap and atom feed.

Show the world you updated a post

Lets say you wrote a blog post a while ago, maybe September 2016, but you want to update a detail you have missed.

Introduce a new Property

So you open your post update it and add a new jbake Property to your header.

Frank Becker
2016-09-21
:jbake-updated: 16.10.2016 (1)
:jbake-type: post
:jbake-language: en
:jbake-tags: jbake,asciidoctor,asciidoctor-diagram
:jbake-status: published
:jbake-description: How to use asciidoctor-diagram with jbake
:jbake-users-question: https://groups.google.com/d/msg/jbake-user/qjS_ojssKF0/hz60cvI-EgAJ
:bintray-gradle-plugin: https://bintray.com/calmdev/gradle-plugins/jbake-gradle-plugin
:github-pull: https://github.com/jbake-org/jbake/pull/269
:asciidoctor-diagram: https://github.com/asciidoctor/asciidoctor-diagram
:jbake-gradle-plugin: https://github.com/jbake-org/jbake-gradle-plugin
1 A Property called updated with a date String dd.MM.yyyy

Use the property to render the date

Extend your template to show when the post was updated.

A subtemplate representing a post (src/jbake/templates/bricks/post-brick.tpl)
import java.text.SimpleDateFormat

div(class:"row"){
    div(class:"small-12 middle-12 large-12 columns"){
        article(class:"wrap"){
            header{
                div(class:"row"){
                    div(class:"small-3 medium-1 large-1 columns"){
                        include template: 'bricks/date.tpl'
                    }

                    div(class:"small-9 medium-11 large-11 columns"){
                        include template: 'bricks/post-title.tpl'
                    }
                }
                div(class:'row') {
                    div(class:"small-offset-3 medium-offset-1 large-offset-1 small-6 medium-6 large-6 columns") {
                        model.put('tagList',post.tags)
                        include template: 'bricks/tags.tpl'
                    }
                    div(class:"small-3 medium-3 large-3 columns text-right") {
                        if( post.updated ){ (1)
                            strong('Updated: ')
                            yield post.updated
                        }
                    }
                }
                hr()
            }

            div(class:"row"){
                div(class:"columns"){
                    yieldUnescaped post.body
                }
            }
        }
    }
}
1 Render updated property only if set in the post

Add format Strings to your configuration

As you want to render the date in different formats I recommend to add the format strings to your configuration.

That way you can reuse them in different templates.

Adding format strings to the gradle configuration
jbake{
  version = "2.5.1"
  asciidoctorjVersion = "1.5.4.1"
  configuration['blog.title'] = "calmdevelopment"
  configuration['blog.description'] = "'A personal Blog. Mostly about tech stuff. groovy, gradle, asciidoctor, jbake and other interesting stuff that crosses my path...'"
  configuration['db.store'] = "local"
  configuration['db.path']= "build/cache"
  configuration['site.host'] = config.server.url
  configuration['render.tags'] = true
  configuration['site.contextPath'] = config.server.contextPath
  configuration['foundation.version'] = foundationVersion
  configuration['twitter.user'] = "@knarfancho"
  configuration['asciidoctor.option.requires'] = "asciidoctor-diagram"
  configuration['asciidoctor.attributes'] = [
    "sourceDir=${projectDir}",
    "imagesdir=${config.server.contextPath}img",
    "imagesoutdir=${bake.input}/assets/img",
    "source-highlighter=highlight.js",
    "icons=font"
  ]
  configuration['feed.timestamp'] = "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'" (1)
  configuration['sitemap.format'] = 'yyyy-MM-dd' (2)
  configuration['updated.format'] = "dd.MM.yyyy" (3)
}
1 A date format for atom feeds
2 A date format for the sitemap
3 The date format I’m using for the updated property

Update sitemap template

Change the sitemap template to use the updated property to set the last modification date of your post.

The sitemap template (src/jbake/templates/sitemap.tpl)
import java.text.SimpleDateFormat (1)

xmlDeclaration()
urlset( xmlns:'http://www.sitemaps.org/schemas/sitemap/0.9'){
    published_content.each {content ->
        url {

            Date dateUpdated (2)
            if ( content.updated ) { (3)
                dateUpdated = new SimpleDateFormat(config.updated_format).parse(content.updated) (4)
            }

    	    loc("${config.site_host}${config.site_contextPath}${content.uri}")
    	    lastmod("${dateUpdated?dateUpdated.format(config.sitemap_format):content.date.format(config.sitemap_format)}") (5)
        }
    }
}
1 import SimpleDateFormat to format and parse a date string
2 declare a Date variable
3 try to convert the date string if the updated property is set
4 parse the updated date string and format with updated.format from configuration
5 ternary condition to use dateUpdated or the post date to format with sitemap.format from configuration

Update feed template

Now do the same for the feed template.

The sitemap template (src/jbake/templates/feed.tpl)
import java.text.SimpleDateFormat (1)

yieldUnescaped "<?xml version='1.0' encoding='UTF-8'?>"
newLine()
feed(xmlns:"http://www.w3.org/2005/Atom"){

    title("${config.blog_title}")
    newLine()
    link(href:"${config.site_host}${config.site_contextPath}")
    newLine()
    link(rel:"self", type:"application/atom+xml", href:"${config.site_host}${config.site_contextPath}${config.feed_file}")
    newLine()
    subtitle("${config.blog_subtitle?:""}")
    newLine()
    updated("${published_date.format(config.feed_format)}")
    newLine()
    id("tag:${config.feed_id},${published_date.format('yyyy:MM')}")
    newLine()
    published_posts.each {post ->
        entry{
          title("${post.title}")
          newLine()
          author{
              name("${post.author}")
          }
          newLine()
          link(href:"${config.site_host}${config.site_contextPath}${post.uri}")
          newLine()

          Date dateUpdated (2)
          if ( post.updated ) { (3)
              dateUpdated = new SimpleDateFormat(config.updated_format).parse(post.updated) (4)
          }

          updated("${dateUpdated?dateUpdated.format(config.feed_format):post.date.format(config.feed_format)}") (5)
          newLine()
          id("${config.site_host}${config.site_contextPath}${post.uri}")
          newLine()
          post.tags.each { tag ->
            category(term:"${tag}")
            newLine()
          }
          content(type:"html") {
            yield post.body
          }
        }
        newLine()
    }
}
1 import SimpleDateFormat to format and parse a date string
2 declare a Date variable
3 try to convert the date string if the updated property is set
4 parse the updated date string and format with updated.format from configuration
5 ternary condition to use dateUpdated or the post date to format with feed.format from configuration

That’s it!


Older post are available in the archive

2014 - 2020 | Mixed with Foundation v6.2.3 | Baked with JBake v2.6.4