aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2026-03-14 11:19:09 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2026-03-14 11:19:09 +0100
commit3cc7196d40d34be8f994bd37b8bf7a7ac6902b7f (patch)
treec7ed8b91882687af618a2373cbf4d7e2b4089959
parentcf6508f2eed048012ed6f645c0cd1e39f766d497 (diff)
downloadscratch-gallery-3cc7196d40d34be8f994bd37b8bf7a7ac6902b7f.tar.gz
scratch-gallery-3cc7196d40d34be8f994bd37b8bf7a7ac6902b7f.zip
allow to build a publishable gallery
This includes only projects that are explicitly allowed to be published.
-rwxr-xr-xgenerate-gallery.py9
-rw-r--r--sample-meta.toml7
2 files changed, 14 insertions, 2 deletions
diff --git a/generate-gallery.py b/generate-gallery.py
index 4daacad..375adbd 100755
--- a/generate-gallery.py
+++ b/generate-gallery.py
@@ -44,7 +44,7 @@ def nested_set(data_dict, key_sequence, value):
data_dict[key_sequence[-1]] = value
-def load_projects(root: str) -> dict:
+def load_projects(root: str, publishable=False) -> dict:
"""Load all game meta data from the games directory"""
projects = {}
@@ -61,6 +61,10 @@ def load_projects(root: str) -> dict:
with open(parent / 'meta.toml', 'rb') as meta_file:
game = tomllib.load(meta_file)
+
+ if publishable and not game.get('oeffentlich', False):
+ continue
+
if 'Name' not in game:
if 'Datei' in game:
game['Name'] = pathlib.Path(game['Datei']).stem
@@ -144,6 +148,7 @@ def main():
parser.add_argument('--author', default='Florian Fischer', help='author mentioned in the HTML')
parser.add_argument('--title', default='Scratch Galerie', help='title of the web page')
parser.add_argument('--projects-dir', default='projects', help='location of the projects')
+ parser.add_argument('--publish', action='store_true', help='build a publishable gallery')
parser.add_argument('--no-packaging',
action='store_true',
help='do not package all encountered scratch projects')
@@ -154,7 +159,7 @@ def main():
env = Environment(loader=FileSystemLoader('templates'), autoescape=select_autoescape())
- projects = load_projects(args.projects_dir)
+ projects = load_projects(args.projects_dir, publishable=args.publish)
prepare_outputdir(args.output_dir, projects)
diff --git a/sample-meta.toml b/sample-meta.toml
index 1e0b764..6922958 100644
--- a/sample-meta.toml
+++ b/sample-meta.toml
@@ -1,9 +1,16 @@
# Trage bitte hier die Namen aller Personen ein, die an eurem Projekt geabreitet haben.
Team = ["Person1", "Person2"]
+
# Trage den Namen eures Projekts ein.
Name = "Tolles Projekt"
+
# Wie heißt die Datei, die dein Scratch-Projekt enthält?
Datei = "Scratch-Projekt.sb3"
+
+# Darf dein Projekt außerhalb der Schule veröffentlicht werden.
+# Wenn nein, lösche einfach die Zeile unter diesem Text, die mit `oeffentlich =` anfängt.
+oeffentlich = true
+
# Dürfen andere dein Projekt, verbessern und weiterverwenden, aber dabei immer deinen
# Namen angeben. # Wenn nein, lösche einfach die Zeile unter diesem Text, die mit `Lizenz =` anfängt.
Lizenz = "CC 4.0 BY-SA-NC"