How do I get Lazybones to process sub-templates? - lazybones

Playing with Lazybones for the first time. I've put together a simple project which attempts to include a single sub-template.
Here is the project structure:
.
├── build.gradle
├── gradlew
├── gradlew.bat
├── README.md
└── templates
├── groovy-lambda
│   ├── build.gradle
│   ├── lazybones.groovy
│   ├── README.md
│   ├── src
│   │   ├── main
│   │   │   ├── groovy
│   │   │   │   └── .retain
│   │   │   └── resources
│   │   │   └── .retain
│   │   └── test
│   │   ├── groovy
│   │   │   └── .retain
│   │   └── resources
│   │   └── .retain
│   └── VERSION
└── subtmpl-groovy-lambda-main-class
├── GroovyLambdaMainClass.groovy
├── lazybones.groovy
└── VERSION
And I'm including the sub-template like so
lazybones {
template "groovy-lambda" includes "groovy-lambda-main-class"
}
The sub-template gets packaged in the main artefact archive:
.
├── build.gradle
├── .lazybones
│   ├── groovy-lambda-main-class-template-1.0-SNAPSHOT.zip
│   └── stored-params.properties
├── README.md
└── src
├── main
│   ├── groovy
│   └── resources
└── test
├── groovy
└── resources
However the sub-template never gets processed at template execution time i.e. the sub-templates lazybones.groovy script doesn't seem to get run.
The whole project is available here on GitHub. To reproduce the issue do:
git#github.com:eddgrant/lazybones-template-aws-groovy-lambda.git
cd lazybones-template-aws-groovy-lambda.git
./gradlew installAllTemplates
cd /tmp
lazybones --verbose create groovy-lambda 1.0-SNAPSHOT groovy-lambda
I'm probably missing something trivial but can't quite figure it out. Most grateful for any pointers.

Everything is working as expected. Sub templates are only used by the lazybones generate command, which in turn works only once you have created a Lazybones-based project.
The classic example is something like a Grails or Rails project in which you would use the generate command to create new controllers or domain classes.

Related

Converting multiple Markdown files with multiple CSS files to PDF as one single page, using wkhtmltopdf and Pandoc

My trainings were inspired by the following (one of the questions didn't work):
Using CSS when converting Markdown to PDF with Pandoc
How to convert Markdown + CSS -> PDF?
How to compile all .md files in a directory into a single .pdf with pandoc, while preserving YAML header data?
And the tutorial:
Converting Markdown to Beautiful PDF with Pandoc
My platform:
Endeavour OS (derived of Arch Linux)
KDE Plasma
MikTeX
Terminator
I have Lua installed.
My goal is to:
convert multiple Markdown to one single PDF page (not multiple PDF pages)
include multiple CSS files;
use LaTeX macros (for example: $\LaTeX$ on Markdown file)
to preserve YAML header data
I tried to run the command:
$ cd diários
$ pandoc -s \
# Because of few LaTeX macros on one Markdown file
-f markdown \
# I need to use HTML 5, but the result warned it is not compatible with the format output (xelatex)
-t html5 \
# Accoridng to https://jdhao.github.io/2019/05/30/markdown2pdf_pandoc/
--pdf-engine=xelatex \
--self-contained \
# Multiple CSS files
--css ../assets/css/colours.css,../assets/css/fonts.css,../assets/css/global.css \
# To preserve YAML data
--lua-filter=../scripts/demote.lua \
# Multiple Markdown files
-V geometry:margin=1in \
*.md \
# Output as PDF
-o combined.pdf
Tree
.
├── assets
│   ├── css
│   │   ├── colours.css
│   │   ├── fonts.css
│   │   ├── global.css
│   ├── fonts
│   │   ├── Latin Modern
│   │   │   ├── LM-bold-italic.woff
│   │   │   ├── LM-bold-italic.woff2
│   │   │   ├── LM-bold.woff
│   │   │   ├── LM-bold.woff2
│   │   │   ├── LM-italic.woff
│   │   │   ├── LM-italic.woff2
│   │   │   ├── LM-regular.woff
│   │   │   └── LM-regular.woff2
│   │  
│   ├── images
│   │   ├── 2021-12-27-camiseta-do-hackathon-do-itau.jpeg
│   │   ├── emojis
│   │   │   ├── 32
│   │   │   │   ├── 1-emoji-excited.png
│   │   │   │   ├── 2-emoji-happy.png
│   │   │   │   ├── 3-emoji-neutral.png
│   │   │   │   ├── 4-emoji-sad.png
│   │   │   │   └── 5-emoji-down.png
│   ├── videos
│   │   └── 2021-12-27 – Comboio no temrinal em dois monitores.mp4
├── diários
│   ├── 2021-05-28.md
│   ├── 2021-12-25.md
│   ├── 2021-12-26.md
│   ├── 2021-12-27.md
│   ├── 2021-12-28.md
│   ├── 2021-12-29.md
│   ├── 2021-12-30.md
│   ├── 2021-12-31.md
│   ├── 2022-01-01.md
│   ├── 2022-01-02.md
│   ├── 2022-01-03.md
│   ├── 2022-01-04.md
│   ├── 2022-01-05.md
│   ├── 2022-01-06.md
│   ├── 2022-01-07.md
│   ├── 2022-01-10.md
│   ├── 2022-01-11.md
├── scripts
│   └── demote.lua
Errors
pdf-engine xelatex is not compatible with output format html5
And with -t html5, another error:
Error running filter ../scripts/demote.lua:
[string "--[[..."]:227: Constructor for Header failed: [string "--[[..."]:258: attempt to index a nil value (local 'x')
stack traceback:
[C]: in function 'error'
[string "--[[..."]:227: in field 'Header'
../scripts/demote.lua:11: in function 'Pandoc'
With --lua-filter=../scripts/demote.lua removed, it almost worked, but it did not capture the CSS files. I believe the problem is in the pdf-engine=xelatex.

Uploading a photo to a page in Jekyll html

I have a base jekyll directory which looks like this:
├── 404.html
├── about.markdown
├── assets
│   └── img
│   ├── mapcolor360_dbc.png
│   └── SileHuPortrait.jpg
├── _config.yml
├── favicon.ico
├── Gemfile
├── Gemfile.lock
├── group-members.html
├── _includes
│   └── footer.html
├── index.markdown
├── _layouts
├── media.md
├── openings.md
├── _posts
│   └── 2019-12-18-welcome-to-jekyll.markdown
├── publications.md
├── research.html
├── research.md
├── _sass
│   └── _variables.scss
├── _site
│   ├── 404.html
│   ├── about
│   │   └── index.html
│   ├── assets
│   │   ├── img
│   │   │   ├── mapcolor360_dbc.png
│   │   │   └── SileHuPortrait.jpg
│   │   └── style.css
│   ├── favicon.ico
│   ├── feed.xml
│   ├── group-members
│   │   └── index.html
│   ├── index.html
│   ├── jekyll
│   │   └── update
│   │   └── 2019
│   │   └── 12
│   │   └── 18
│   │   └── welcome-to-jekyll.html
│   ├── media
│   │   └── index.html
│   ├── openings
│   │   └── index.html
│   ├── publications
│   │   └── index.html
│   ├── research
│   │   └── index.html
│   └── software
│   └── index.html
└── software.md
And I want to upload a photo to the group-members page, using this line in the group-members.html file:
<img src="/home/sam/Dropbox/Documents/PhD/hellenthal-group/assets/img/SileHuPortrait.jpg">
The image definitely exists in the directory, but when I try to compile the site with bundle exec jekyll serve
It returns the error
[2020-03-20 19:36:13] ERROR `/home/sam/Dropbox/Documents/PhD/hellenthal-group/assets/img/SileHuPortrait.jpg' not found.
And the image appears as broken. Can anyone help me with this issue?
I see that SileHuPortrait.jpg is actually inside <source>/assets/img based on your directory structure.
When Jekyll builds your site, the URLs generated are assumed to be used with a web-server.
So when you have a reference like /home/sam/Dropbox/Documents/.., the webserver is looking for /home/sam/Dropbox/Documents/.. relative to your destination directory (which is the _site folder).
The error you're seeing is because the physical path /home/sam/Dropbox/Documents/PhD/hellenthal-group/_site/home/sam/Dropbox/Documents/PhD/hellenthal-group/assets/img/SileHuPortrait.jpg
doesn't exist.
The correct usage would therefore be:
<img src="/assets/img/SileHuPortrait.jpg">
(Note the leading slash)
The above while correct, isn't flexible to automatically adapt when you set baseurl: in the config file.
So, the final solution is to use the relative_url Liquid filter:
<img src="{{ 'assets/img/SileHuPortrait.jpg' | relative_url }}">

Jekyll home page corruption on github

I have a simple Jekyll web site. It works as expected on the local server, but when uploaded to github it displays differently. I am guessing that this is because bundle exec jekyll serve behaves differently on github.
This is the way it looks on the local server (I'm using the theme minima)
and on github
The extra links in the menu-bar all point to pages on the website
index.md
---
layout: home
---
Welcome to the Psionman Set. This is a series of lessons that I wrote to help me get to grips with some new (to me) technology.
(Some were done for my private use, but you can read them).
[Wx Python from scratch]({{ site.baseurl }}{% link wx_python/wxpython_from_scratch.md %})
And the tree on the local server
.
├── 404.html
├── about.markdown
├── _config.yml
├── Gemfile
├── Gemfile.lock
├── index.md
├── _posts
├── _site
│   ├── 404.html
│   ├── about
│   │   └── index.html
│   ├── assets
│   │   ├── main.css
│   │   ├── main.css.map
│   │   └── minima-social-icons.svg
│   ├── feed.xml
│   ├── index.html
│   └── wx_python
│   ├── images
│   │   ├── basic_frame.png
│   │   ├── datepicker.png
│   ├── introduction.html
│   ├── post01.html
│   ├── post02.html
│   ├── post03.html
│   ├── post04.html
│   ├── snippets
│   │   ├── basic_frame.py
│   │   ├── basic_panel.py
│   └── wxpython_from_scratch.html
└── wx_python
├── images
│   ├── basic_frame.png
│   ├── datepicker.png
├── introduction.md
├── post01.md
├── post02.md
├── snippets
│   ├── basic_frame.py
│   ├── basic_panel.py
└── wxpython_from_scratch.md
[EDIT]
It seems that the items in the menu-bar are created form a heading in the md file
## WxPython from Scratch
Github seems to pick up the first heading and place that in the menu-bar
Can someone please show me how to suppress these?
Dumped Jekyll in favour of Sphinx on Netlify

Ansible, role not found error

I try to play following playbook against localhost to provision Vagrant machine
---
- hosts: all
become: yes
roles:
- base
- jenkins
I have cloned necessary roles from github and they resides in a relative path roles/{role name}
Executing following command: ansible-playbook -i "localhost," -c local playbook.yml outputs this error:
==> default: ERROR! the role 'geerlingguy.java' was not found in /home/vagrant/provisioning/roles:/home/vagrant/provisioning:/etc/ansible/roles:/home/vagrant/provisioning/roles
==> default:
==> default: The error appears to have been in '/home/vagrant/provisioning/roles/jenkins/meta/main.yml': line 3, column 5, but may
==> default: be elsewhere in the file depending on the exact syntax problem.
==> default:
==> default: The offending line appears to be:
==> default:
==> default: dependencies:
==> default: - geerlingguy.java
==> default: ^ here
I cloned the missing dependency from github, and tried to reside it in relative path of roles/java and roles/geerlingguy/java, but either didn't solve the problem, and error stays the same.
I want to keep all roles locally in the synced provisioning folder, without using ansible-galaxy runtime, to make the provisioning method as self contained as possible.
Here is the provision folder structure as it is now
.
├── playbook.yml
└── roles
├── base
│   └── tasks
│   └── main.yml
├── java
│   ├── defaults
│   │   └── main.yml
│   ├── meta
│   │   └── main.yml
│   ├── README.md
│   ├── tasks
│   │   ├── main.yml
│   │   ├── setup-Debian.yml
│   │   ├── setup-FreeBSD.yml
│   │   └── setup-RedHat.yml
│   ├── templates
│   │   └── java_home.sh.j2
│   ├── tests
│   │   └── test.yml
│   └── vars
│   ├── Debian.yml
│   ├── Fedora.yml
│   ├── FreeBSD.yml
│   ├── RedHat.yml
│   ├── Ubuntu-12.04.yml
│   ├── Ubuntu-14.04.yml
│   └── Ubuntu-16.04.yml
└── jenkins
├── defaults
│   └── main.yml
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── README.md
├── tasks
│   ├── main.yml
│   ├── plugins.yml
│   ├── settings.yml
│   ├── setup-Debian.yml
│   └── setup-RedHat.yml
├── templates
│   └── basic-security.groovy
├── tests
│   ├── requirements.yml
│   ├── test-http-port.yml
│   ├── test-jenkins-version.yml
│   ├── test-plugins-with-pinning.yml
│   ├── test-plugins.yml
│   ├── test-prefix.yml
│   └── test.yml
└── vars
├── Debian.yml
└── RedHat.yml
You should install or clone all required roles in the /roles folder (or in the system folder)
ansible-galaxy install -p ROLES_PATH geerlingguy.java
should fix this specific problem.
However, the best practice should be the use of a requirements.yml file where you require all the needed roles and then install them with ansible-galaxy directly in your playbook.
- name: run ansible galaxy
local_action: command ansible-galaxy install -r requirements.yml --ignore-errors
Simple symbolic link works like a charm without any installations:
$ mkdir /home/USER/ansible && ln -s /home/USER/GIT/ansible-root/roles
Here is the solution: the required path for the role is roles/geerlingguy.java/, not roles/geerlingguy/java/

How can I get HTML reports that I host on Github Pages to link to stylesheets in another directory?

I'm trying to create a set of project pages using Github Pages. My main page is a copy of my project's README, which I generated through Github's auto-page generator. Under Project Health Metrics, I link to two HTML reports: one is a CodeNarc report (at health/codenarc/main.html) and the other is a Jacoco report (at health/jacoco/index.html).
The CodeNarc report renders fine, but the Jacoco report doesn't as it's not able to load the stylesheet and other resources kept in another directory. I'm keeping everything on a gh-pages branch with a directory structure that looks like this:
.
├── Gemfile
├── Gemfile.lock
├── _config.yml
├── _site
├── bin
├── build
├── build.gradle
├── config
├── docs
├── gradle.properties
├── health
├── images
├── index.html
├── javascripts
├── params.json
├── src
└── stylesheets
My health directory tree appears like this:
health
├── codenarc
│   ├── integrationTest.html
│   ├── main.html
│   └── test.html
├── html
│   └── projectHealth.html
└── jacoco
├── .resources
│   ├── branchfc.gif
│   ├── branchnc.gif
│   ├── branchpc.gif
│   ├── bundle.gif
│   ├── class.gif
│   ├── down.gif
│   ├── greenbar.gif
│   ├── group.gif
│   ├── method.gif
│   ├── package.gif
│   ├── prettify.css
│   ├── prettify.js
│   ├── redbar.gif
│   ├── report.css
│   ├── report.gif
│   ├── session.gif
│   ├── sort.gif
│   ├── sort.js
│   ├── source.gif
│   └── up.gif
├── .sessions.html
├── com.github.tagc.semver
│   ├── SemVerPlugin$_apply_closure1.html
│   ├── SemVerPlugin.groovy.html
│   ├── SemVerPlugin.html
│   ├── SemVerPluginExtension.groovy.html
│   ├── SemVerPluginExtension.html
│   ├── Version$Builder.html
│   ├── Version$Category.html
│   ├── Version$Parser.html
│   ├── Version.groovy.html
│   ├── Version.html
│   ├── index.html
│   └── index.source.html
└── index.html
If it helps, you can explore the tree and check out all the files from my Github repository.
I would like the Jacoco report to be able to access the resources in the .resources folder under health/jacoco, but it doesn't seem able to and I'm not quite sure why. I've tried playing around with this a lot on a private instance running on localhost through Jekyll.
Problem solved, thanks to help from some people in IRC and a lot of playing around.
Jekyll ignores any folders that are hidden (e.g. prepended with a dot or underscore), so it wasn't processing health/jacoco/.resources.
I got around this issue by including include: ['.resources'] in _config.yml. Don't forget to push this file to the remote gh-pages branch on Github, as Github uses this to determine what it processes as well.
The Jacoco report now renders properly because it can access the stylesheets and other resources it depends on.