Jekyll custom placeholders - jekyll

I am trying to set up a jekyll site that sources its pages from github repository. I can "bring" that repository using the git submodule command so that works just fine.
The URL I want to have is:
https://example.ld/:version/:language/:page-name
For the :page-name I can use the :title global placeholder.
My folder structure is:
posts
posts/1.0
posts/1.0/en
posts/1.0/en/about.md
....
posts/1.0/fr
posts/1.0/fr/about.md
....
I tried playing around with the permalink option in the configuration but cannot find the right combination to do what I need since :language of course does not exist as a placeholder or does :version.
Is there a way to define those so that my users can visit the site and view https://example.ld/1.0/en/about?
Should I move the docs folder under the _posts folder?
Any pointers are more than appreciated. Thank you.

Related

Is conditional template overriding part of the Jekyll framework?

I'm interested in using Jekyll to host a dozen business websites that share a lot of information and web interfaces in common. Hence, I'm curious if what I'm about to ask is easily supported by Jekyll.
If this were another website platform like WordPress, Magento, etc.. etc... I might set up default templates for my website like this:
tpl/default/header.html
tpl/default/footer.html
tpl/default/privacy-policy.html
tpl/default/pricing.html
tpl/default/contact/map.html
tpl/default/contact/form.html
Then for each business that signs up with me, I will set up a folder for them called tpl/<businessname>/. Then, the platform will create a website using all the html files in the tpl/<businessname>/ directory. Whenever a template does not exist in the tpl/<businessname> directory, then the platform will use the corresponding template in the tpl/default/ directory.
As an example, let's say Bicycle Shop wants a website from me. I go ahead and create this:
tpl/bicycyle-shop/contact/map.html
Then in my layout files, I might make calls like this:
<?php
define('ORG','bicycle-shop');
put_tmpl('contact/form.html'); // this will use tpl/default/contact/form.html
put_tmpl('contact/map.html'); // this will use tpl/bicycle-shop/contact/map.html
function put_tmpl($tplname) {
if(file_exists('tpl/'.ORG.'/'.$tplname))
include('tpl/'.ORG'.'/'.$tplname);
else
include('tpl/default/'.explode('/',$tplname)[count(explode('/',$tplname))-1]);
}
?>
I'm curious how a behaviour like this is achieved in Jekyll?
ADDITIONAL
One way that just occurred to me was to have a _config.yml that has variables like:
tmpl:
home: tpl/default/header.html
pricing: tpl/default/pricing.html
...etc...
Then each business has _config<businessname>.yml that overrides the appropriate tmpl variables. Would that be the Jekyll convention? Or is there something out of the box with Jekyll that does this better?
There are themes... you just install a theme as a gem in your config. When you need to override a theme file, you just put that file in your _layouts or _includes directory.
Super simple.

A badge in GitHub template repository that will refer to clones' build status, not the template repo's build status

I'm new to GitHub's template repositories. We've created a template repo for our course's code labs. Let's say it's on GitHub under myorg/labX. The students are using GitHub Classroom, which clones the template repo for each student under myorg/labX-studentlogin. We've got actions to run some tests against their code using GitHub's own CI, and I want to include badges in the repo's README.md to see the test results at a glance. So I know that
![](https://github.com/myorg/labX/workflows/task1/badge.svg)
will include the badge, but this is the status of the template repo, not student repos. Is there a way to automate this so that when the students get their clone, it will contain a README with the URL that refers to the status of their own repo?
Turns out there is a simple solution, but only for GitHub's own Actions status badges. We've changed the image URL in our README.mds to relative.
The only minor thing is GitHub will insert /blob/<branch>/ into relative links when rendering the readmes.
For example, workflows/task1/badge.svg will become https://github.com/myorg/labX/blob/master/workflows/task1/badge.svg), which won't render. So we had to prepend '../../' to fool it.
TLDR: in repo's README.md, use
![](../../workflows/<workflowname>/badge.svg)
to get a badge for an Action status in this repo. This way, each student will get a badge referring to his own repo, not the template repo.
However, still looking for a way to use an external badge service like shields.io in a way relative to the repo.
I agree it would be a great feature to have.
It looks like at this point, GitHub Template Repositories do not support variable substitution, which is what would make it possible.
I see it is discussed briefly here:
Variable substitution for GitHub Template Repository Usage
Perhaps you should join the discussion and/or cast your Kudo.

How to use docson widget with Sphinx on ReadTheDocs

I'm working on the documentation (https://global-coffee-data-standard.readthedocs.io) of my JSON schema (https://raw.githubusercontent.com/andrejellema/GlobalCoffeeDataStandard/master/schema/global-coffee-data-standard.schema.json)
The basics I have working (thanks to a lot of help from this forum) but now I would like to include the docson widget to show my code more beautiful (https://global-coffee-data-standard.readthedocs.io/en/latest/explanation.html#id13)
I've read this page https://threesixtygiving-standard.readthedocs.io/en/latest/_static/docson/README/ and I'm wondering how to install docson locally but more important on ReadTheDocs.
Do I need to run npm i docson localy? If so which files do I commit to my _static folder so ReadTheDocs can work with it as well?
Or can I put some magic in conf.py to let Sphinx handle it?
EDIT
I tried adding the docson files to my _static folder and it seems to work when I add this code to my ReST file:
<script src="_static/docson/js/widget.js" data-schema="https://raw.githubusercontent.com/andrejellema/GlobalCoffeeDataStandard/master/schema/global-unique-id.json"></script>
But only when I add just one docson widget. When I add more I get this error in the console:
only one instance of babel-polyfill is allowed.
So I'm assuming this is not the correct workflow.
What is the correct workflow to add multiple docson widgets to my page.

Create versioned documentation archive

I am in the process of rebuilding a API documentation site for an open source project where we want to keep an archive of previous releases. I am wondering how I can configure Jekyll to generate the right hierarchy?
We have the following directory layout in our current /docs folder (which we would like to reuse in Jekyll somehow):
current/
v1/
v2/
v3/
Whenever we release a new version the current folder gets copied to a new folder (say v4). The contents of each folder is something like this:
introduction.md
testing.md
api-foo.md
api-bar.md
I'd like these to be available under the url domain.com/v3/testing/, domain.com/current/testing/, etc. I see that I could probably employ collections to do this, having one collection per version. To do this I see myself auto-updating the _config.yml as part of a build script (I made an example doing this here), but I am not sure how to progress from here, or if using collections for this is the wrong approach ...
This is too brief of an update to be of real quality, but thought I would mention that we solved this in the end in the Sinon project. Check out the repo at GitHub sinonjs/sinon and see the docs folder as well as the scripts called from package.json.
Feel free to improve on this answer by editing it and adding content and links.

How to add a new page based on page.html (similar to /groups or /dataset)

I have installed and configured one CKAN 2.0.1 instance.
You can check it out here: http://www.caceresabierto.es; as you can see it is still very basic.
My problem is the following, I want to create the page http://www.caceresabierto.es/aplicaciones. I understand that there should be a method to heritage the layout and the basic theming from the main template (if I am not wrong is "base.html" or "page.html" in the 'templates' folder).
The point is: I have figured out how to modify www.caceresabierto.es/dataset or www.caceresabierto.es/groups. But I don't know how to add a new route like www.caceresabierto.es/aplicaciones that heritage from "page.html".
I suppose I will need to create a new HTML file in the 'template' folder and maybe modify setup.py or plugins.py...But I need some help to do it.
Any feedback would be great. Thank you.
Jesús Redondo.
Apologies for cross-posting.
You need to upload a new aplicaciones.html file to your public_html folder and then it will work. I don't think modifying any python files will be necessary.
If you want much of the page to look the same, you can start work on your new aplicaciones.html file by saving your old index.html file with a new name and modifying the relevant information.