stagit

static git page generator  https://git.ce9e.org
git clone https://git.ce9e.org/stagit.git

commit
5f4be9680178be9547b675a386669ba5c9145373
parent
acf71cc52765723a4ea49218b4a75ed094d90079
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-09-05 10:09
gitolite: add json index

Diffstat

M gitolite/stagit.py 14 ++++++++++++++

1 files changed, 14 insertions, 0 deletions


diff --git a/gitolite/stagit.py b/gitolite/stagit.py

@@ -1,4 +1,5 @@
    1     1 import configparser
   -1     2 import json
    2     3 import os
    3     4 import shutil
    4     5 import subprocess
@@ -109,6 +110,18 @@ def render_index():
  109   110         fh.write('</main>\n</body>\n</html>\n')
  110   111 
  111   112 
   -1   113 def render_json_index():
   -1   114     with open(WWW_DIR / 'index.json', 'w') as fh:
   -1   115         json.dump([
   -1   116             {
   -1   117                 'name': repo,
   -1   118                 'description': config.get(repo, 'desc'),
   -1   119             }
   -1   120             for repo in config.iter_repos()
   -1   121             if config.getboolean(repo, 'http')
   -1   122         ], fh)
   -1   123 
   -1   124 
  112   125 def render_repo(repo):
  113   126     print(f'Generating HTML for {repo}…')
  114   127     target_dir = WWW_DIR / repo
@@ -127,6 +140,7 @@ def render_all():
  127   140         if config.getboolean(repo, 'http'):
  128   141             render_repo(repo)
  129   142     render_index()
   -1   143     render_json_index()
  130   144 
  131   145 
  132   146 if __name__ == '__main__':