From b24c921ac8924a50b052d9e101d161060916628f Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Wed, 25 Jan 2023 15:25:55 -0500 Subject: [PATCH] Add a preview page generator --- .github/workflows/create-preview-page.py | 37 ++++++++++++++++++++++++ .github/workflows/previews.yml | 25 ++++++++++++++++ PREVIEW.md | 16 ++++++++++ 3 files changed, 78 insertions(+) create mode 100644 .github/workflows/create-preview-page.py create mode 100644 .github/workflows/previews.yml create mode 100644 PREVIEW.md diff --git a/.github/workflows/create-preview-page.py b/.github/workflows/create-preview-page.py new file mode 100644 index 0000000..5b9abe5 --- /dev/null +++ b/.github/workflows/create-preview-page.py @@ -0,0 +1,37 @@ +""" +Creates a preview page for all SVGs in /themes/*.svg, of the form: + +| | | | | +|---|---|---|---| +| ![](example.svg) [Theme Name](Theme Link) | ... + +etc +""" + +import pathlib + +COLUMN_COUNT = 4 +OUT_PATH = "PREVIEW.md" + + +def main(): + themes = pathlib.Path("themes") + theme_files = themes.glob("*.svg") + theme_names = [theme.stem for theme in theme_files] + theme_names.sort() + + with open(OUT_PATH, "w") as readme: + readme.write("# Theme Previews\n\n") + readme.write("| | | | |\n") + readme.write("|---|---|---|---|\n") + for i in range(0, len(theme_names), COLUMN_COUNT): + row = theme_names[i : i + COLUMN_COUNT] + row = [ + f"![]({themes / (theme + '.svg')})
**[{theme}]({themes / (theme + '.svg')})**" + for theme in row + ] + readme.write("| " + " | ".join(row) + " |\n") + + +if __name__ == "__main__": + main() diff --git a/.github/workflows/previews.yml b/.github/workflows/previews.yml new file mode 100644 index 0000000..79c40da --- /dev/null +++ b/.github/workflows/previews.yml @@ -0,0 +1,25 @@ +# A GitHub action to create a "PREVIEWS.md" file automatically with +# a table of all of the themes from /themes/*.svg, sorted by name. + +name: Create-Preview + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + # Call .github/workflows/create-preview-page.py + - name: Create Preview + run: python3 .github/workflows/create-preview-page.py + - name: Commit changes + uses: EndBug/add-and-commit@v4 + with: + message: "Update PREVIEWS.md" + add: "PREVIEWS.md" + + \ No newline at end of file diff --git a/PREVIEW.md b/PREVIEW.md new file mode 100644 index 0000000..ff873d6 --- /dev/null +++ b/PREVIEW.md @@ -0,0 +1,16 @@ +# Themes + +| | | | | +|---|---|---|---| +| ![](themes/apollo.svg)
**[apollo](themes/apollo.svg)** | ![](themes/battlestation.svg)
**[battlestation](themes/battlestation.svg)** | ![](themes/berry.svg)
**[berry](themes/berry.svg)** | ![](themes/bigtime.svg)
**[bigtime](themes/bigtime.svg)** | +| ![](themes/boysenberry.svg)
**[boysenberry](themes/boysenberry.svg)** | ![](themes/coal.svg)
**[coal](themes/coal.svg)** | ![](themes/cobalt.svg)
**[cobalt](themes/cobalt.svg)** | ![](themes/commodore.svg)
**[commodore](themes/commodore.svg)** | +| ![](themes/forestlawn.svg)
**[forestlawn](themes/forestlawn.svg)** | ![](themes/frameio.svg)
**[frameio](themes/frameio.svg)** | ![](themes/gameboy.svg)
**[gameboy](themes/gameboy.svg)** | ![](themes/garden.svg)
**[garden](themes/garden.svg)** | +| ![](themes/gotham.svg)
**[gotham](themes/gotham.svg)** | ![](themes/haxe.svg)
**[haxe](themes/haxe.svg)** | ![](themes/isotope.svg)
**[isotope](themes/isotope.svg)** | ![](themes/kawaii.svg)
**[kawaii](themes/kawaii.svg)** | +| ![](themes/laundry.svg)
**[laundry](themes/laundry.svg)** | ![](themes/lotus.svg)
**[lotus](themes/lotus.svg)** | ![](themes/mahou.svg)
**[mahou](themes/mahou.svg)** | ![](themes/marble.svg)
**[marble](themes/marble.svg)** | +| ![](themes/murata.svg)
**[murata](themes/murata.svg)** | ![](themes/muzieca.svg)
**[muzieca](themes/muzieca.svg)** | ![](themes/nightowl.svg)
**[nightowl](themes/nightowl.svg)** | ![](themes/ninetynine.svg)
**[ninetynine](themes/ninetynine.svg)** | +| ![](themes/noir.svg)
**[noir](themes/noir.svg)** | ![](themes/nord.svg)
**[nord](themes/nord.svg)** | ![](themes/obsidian.svg)
**[obsidian](themes/obsidian.svg)** | ![](themes/op-1.svg)
**[op-1](themes/op-1.svg)** | +| ![](themes/orca.svg)
**[orca](themes/orca.svg)** | ![](themes/pawbin.svg)
**[pawbin](themes/pawbin.svg)** | ![](themes/pico8.svg)
**[pico8](themes/pico8.svg)** | ![](themes/polivoks.svg)
**[polivoks](themes/polivoks.svg)** | +| ![](themes/rainonwires.svg)
**[rainonwires](themes/rainonwires.svg)** | ![](themes/roguelight.svg)
**[roguelight](themes/roguelight.svg)** | ![](themes/sk.svg)
**[sk](themes/sk.svg)** | ![](themes/snow.svg)
**[snow](themes/snow.svg)** | +| ![](themes/solarised.dark.svg)
**[solarised.dark](themes/solarised.dark.svg)** | ![](themes/solarised.light.svg)
**[solarised.light](themes/solarised.light.svg)** | ![](themes/sonicpi.svg)
**[sonicpi](themes/sonicpi.svg)** | ![](themes/soyuz.svg)
**[soyuz](themes/soyuz.svg)** | +| ![](themes/tape.svg)
**[tape](themes/tape.svg)** | ![](themes/teenage.svg)
**[teenage](themes/teenage.svg)** | ![](themes/teletext.svg)
**[teletext](themes/teletext.svg)** | ![](themes/vacuui.svg)
**[vacuui](themes/vacuui.svg)** | +| ![](themes/zenburn.svg)
**[zenburn](themes/zenburn.svg)** |