Skip to content

Commit

Permalink
Merge pull request #89 from htw-imi-showtime/semester-tools
Browse files Browse the repository at this point in the history
Added script for scaffolding new semesters
  • Loading branch information
gefei authored Jun 12, 2021
2 parents bccd99d + 04b32de commit 97e22a8
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 13 deletions.
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ The official IMI showtime website

[Preview: https://htw-imi-showtime.github.io/](https://htw-imi-showtime.github.io/)

- [IMI Showtime Website](#imi-showtime-website)
- [Adding a new project](#adding-a-new-project)
- [Updating your Fork](#updating-your-fork)
- [Including additional content](#including-additional-content)
- [Sections](#sections)
- [Images](#images)
- [Gallery](#gallery)
- [Special Case: Team Gallery](#special-case-team-gallery)
- [Videos](#videos)
- [HTW Mediathek Player](#htw-mediathek-player)
- [GitHub Gists](#github-gists)
- [Adding a new project](#adding-a-new-project)
- [Updating your Fork](#updating-your-fork)
- [Including additional content](#including-additional-content)
- [Sections](#sections)
- [Images](#images)
- [Gallery](#gallery)
- [Special Case: Team Gallery](#special-case-team-gallery)
- [Videos](#videos)
- [HTW Mediathek Player](#htw-mediathek-player)
- [GitHub Gists](#github-gists)
- [Adding a new semester](#adding-a-new-semester)

## Adding a new project
If you want to add your project to the website, please follow these steps and create a pull request when you're done:
Expand Down Expand Up @@ -167,3 +167,15 @@ Example: Embedding https://gist.github.com/Kaes3kuch3n/643befb000375fea7c5f675fb
```handlebars
{{<gist "Kaes3kuch3n" "643befb000375fea7c5f675fb180cfbd">}}
```

## Adding a new semester
This repository contains a utility script to transition the website to a new semester.
It changes the semester set in the config file (`current_semester` in `config/_default/config.toml`) and
scaffolds the folder structure for the projects of the new semester.
```shell
./new_semester.sh <semester>
```
Example: Transitioning to winter semester 2021/22
```shell
./new_semester.sh ws21
```
7 changes: 7 additions & 0 deletions archetypes/semester/bachelor/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
+++
type = "{{ .Name }}"

[cascade]
type = "Bachelor"
layout = "project"
+++
7 changes: 7 additions & 0 deletions archetypes/semester/master/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
+++
type = "{{ .Name }}"

[cascade]
type = "Master"
layout = "project"
+++
1 change: 0 additions & 1 deletion config/_default/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ theme = "showtime-theme-2021"

[params]
current_semester = "ss21"
archive_semester = "ss20"

[markup]
[markup.goldmark]
Expand Down
17 changes: 17 additions & 0 deletions new_semester.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

set -e

if [ "$#" -ne 1 ]; then
echo "Usage: ./new_semester.sh <semester>"
echo "Replace <semester> with a semester abbreviation, e.g. 'ws21' for 'winter semester 2021'"
exit 1
fi

# Check if semester is valid
(echo "$1" | grep -Eq "^(ws|ss)[0-9]{2}$") || (echo "Error: Invalid semester passed" && exit 2)

# Update the semester set in the config file
sed -e "s/ws[0-9]\{2\}/$1/;s/ss[0-9]\{2\}/$1/" -i "" config/_default/config.toml
# Create a new project folder for this semester
hugo new --kind semester $1
2 changes: 1 addition & 1 deletion themes/showtime-theme-2021

0 comments on commit 97e22a8

Please sign in to comment.