From 9cce9ff8c1efea7ec8c96975b41ff9da88e67932 Mon Sep 17 00:00:00 2001
From: Lorenz Schmid
Date: Sat, 14 Nov 2020 09:04:23 +0100
Subject: [PATCH] Add option to easily remove generated files set to be hidden
---
README.md | 14 ++++++++++++++
_layouts/delete_hidden.html | 25 +++++++++++++++++++++++++
_layouts/room.html | 9 ++++++---
_layouts/speaker.html | 8 +++++---
_layouts/talk.html | 8 +++++---
workflow-example.yml | 4 ++++
6 files changed, 59 insertions(+), 9 deletions(-)
create mode 100644 _layouts/delete_hidden.html
diff --git a/README.md b/README.md
index 2d839aa3..53bd4480 100644
--- a/README.md
+++ b/README.md
@@ -91,6 +91,8 @@ The actual schedule defining when and in which room a talk takes place is stored
:warning: Please note that the generated website can be quite large containing many unnecessary whitespaces. It is recommended to minimize the generated output files before uploading them to a server (e.g. with [minify](https://github.com/tdewolff/minify)).
+### Jump Start
+
In order to be up and running simply use the default content of this repository as an initial base for your new website. After having setup a new Jekyll website copy the following files and folders into the website's folder:
- `_config.example.yml` -> `_config.yml`
@@ -104,12 +106,24 @@ In order to be up and running simply use the default content of this repository
- `speakers/`
- `talks/`
+### Automatic Import
+
There exists a Python file in this repository, `create_entries.py`, which can be used to import content from a [frab](https://github.com/frab/frab/wiki/Manual#introduction) compatible JSON file or a CSV table and generate the different talk, speakers and room files automatically based on it. Just open your terminal and type `python create_entries.py --help` to show the help and get started.
+### Automatic Build
+
In case you do not want to install the entire Ruby/Jekyll toolchain on your machine you can make use of [GitHub Actions](https://github.com/features/actions), Github's continuous integration platform. This repository contains an example Github Action configuration file which automatically builds and minimizes the website upon adding a new tag. It then attaches the generated website as package to a release for easy downloading. Simply copy the following file to your repository and adapt it to your needs:
- `workflow-example.yml` -> `.github/workflows/main.yml`
+Hidden rooms, speakers, or talks are automatically generated in way containing no content. In order to remove these empty files simply add a file called `delete_hidden.sh` to the root with the following content. It will automatically called by the Github Action workflow to delete the files.
+
+```markdown
+---
+layout: delete_hidden
+---
+```
+
## Configuration
diff --git a/_layouts/delete_hidden.html b/_layouts/delete_hidden.html
new file mode 100644
index 00000000..68794cf4
--- /dev/null
+++ b/_layouts/delete_hidden.html
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+
+{% if site.conference.location.hide -%}
+rm -r rooms
+rm -r {{ site.conference.location.url | default: "location" }}
+{% else -%}
+{%- for room in site.rooms -%}
+{%- if room.hide -%}
+rm -r {{ room.url | slice: 1, room.url.size }}
+{% endif -%}
+{%- endfor -%}
+{%- endif -%}
+
+{%- for speaker in site.speakers -%}
+{%- if speaker.hide -%}
+rm -r {{ speaker.url | slice: 1, speaker.url.size }}
+{% endif -%}
+{%- endfor -%}
+
+{%- for talk in site.talks -%}
+{%- if talk.hide -%}
+rm -r {{ talk.url | slice: 1, talk.url.size }}
+{% endif -%}
+{%- endfor %}
+rm delete_hidden.sh
diff --git a/_layouts/room.html b/_layouts/room.html
index 50d3c49b..2223ae1e 100644
--- a/_layouts/room.html
+++ b/_layouts/room.html
@@ -1,4 +1,7 @@
-{% include partials/header.html %}
+{%- assign this_room = page -%}
+
+{%- unless this_room.hide or site.conference.location.hide -%}
+ {%- include partials/header.html -%}
@@ -10,7 +13,6 @@
{{ site.data.lang[site.conference.lang].location.title | default: "Location" }}
- {% assign this_room = page %}
{% include partials/navbar_rooms.html %}
{{ content }}
@@ -60,4 +62,5 @@
-{% include partials/footer.html %}
+ {%- include partials/footer.html -%}
+{%- endunless -%}
diff --git a/_layouts/speaker.html b/_layouts/speaker.html
index d5e2a217..63a5a32e 100644
--- a/_layouts/speaker.html
+++ b/_layouts/speaker.html
@@ -1,6 +1,7 @@
-{% include partials/header.html %}
+{%- assign speaker = page -%}
- {% assign speaker = page %}
+{%- unless speaker.hide -%}
+ {%- include partials/header.html -%}
{{ site.data.lang[site.conference.lang].speaker.title | default: "Speaker" }}
@@ -104,4 +105,5 @@
{{ site.data.lang[site.conference.lang].speaker.talks | de
-{% include partials/footer.html %}
+ {%- include partials/footer.html -%}
+{%- endunless -%}
diff --git a/_layouts/talk.html b/_layouts/talk.html
index 04e7c286..5b617450 100644
--- a/_layouts/talk.html
+++ b/_layouts/talk.html
@@ -1,6 +1,7 @@
-{% include partials/header.html %}
+{%- assign talk = page -%}
- {% assign talk = page %}
+{%- unless talk.hide -%}
+ {%- include partials/header.html -%}
@@ -119,4 +120,5 @@
{{ site.data.lang[site.conference.lang].more_information |
-{% include partials/footer.html %}
+ {%- include partials/footer.html -%}
+{%- endunless -%}
diff --git a/workflow-example.yml b/workflow-example.yml
index cbdd2a0a..30f683d6 100644
--- a/workflow-example.yml
+++ b/workflow-example.yml
@@ -40,6 +40,10 @@ jobs:
run: |
bundle exec jekyll build -d _site/
+ - name: Remove empty files
+ run: |
+ [ -f _site/delete_hidden.sh ] || /bin/bash _site/delete_hidden.sh
+
- name: Install Minify
run: |
sudo apt-get update