summary refs log blame commit diff stats
path: root/src/fe-gtk/fe-gtk.vcxproj
blob: 0c1499281ee396c63f3a81a5feb31afb4604db59 (plain) (tree)
generated by cgit-pink 1.4.1 (git 2.36.1) at 2025-01-05 01:00:57 +0000
# permalinked, sorry. if linkname == "index.html": linkname = str(t.id) + "_index.html" quoted = quote(linkname, safe='') link = linkpath / linkname if isinstance(obj, pygit2.Blob): blobmeta = todoblobs.setdefault(obj, []) blobmeta += [(obj.filemode, obj.name)] tree = gen_dir / "blobs" / str(obj.id) linktarget = get_relative(path, tree) link.symlink_to(linktarget, target_is_directory=True) # FIXME html-escape f.write("<li><a href=\"./{}\">{}</a></li>".format(quoted, quoted)) elif isinstance(obj, pygit2.Tree): todotrees.add(obj) tree = gen_dir / "trees" / str(obj.id) linktarget = get_relative(path, tree) link.symlink_to(linktarget, target_is_directory=True) # FIXME html-escape f.write("<li><a href=\"./{}\">{}</a></li>".format(quoted, quoted)) else: # TODO not implemented, sorry. altho apparently submodules use # commits in trees? raise TypeError f.write("</ul></body></html>") print("generating blobs") # build blobs while todoblobs: (b, meta) = todoblobs.popitem() path = gen_dir / "blobs" / str(b.id) path.mkdir(parents=True,exist_ok=True) index = path / "index.html" try: f = index.open("x") except FileExistsError: # check if we've already visited this tree continue with f: f.write("<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>blob</title><body>") f.write("<a href=\"./raw.bin\">view raw</a>") try: text = b.data.decode("utf-8", errors="strict") lex = find_lexer(text, meta) if lex is not None: f.write(highlight(text, lex, HtmlFormatter())) else: # TODO maybe just write `text` (html escaped)? pass except UnicodeError: pass f.write("</body></html>") raw = path / "raw.bin" with raw.open("wb") as f: f.write(b) # create index.html path = gen_dir / "index.html" with path.open("w") as f: f.write("<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>index</title><body><ul>") if not repo.head_is_unborn: ref = repo.head quoted = quote(ref.name, safe='/') # FIXME html-escape f.write("<li><a href=\"./{}\">{}</a></li>".format(quoted, quoted)) for ref in repo.references: ref = repo.references.get(ref) quoted = quote(ref.name, safe='/') # FIXME html-escape f.write("<li><a href=\"./{}\">{}</a></li>".format(quoted, quoted)) f.write("</ul></body></html>") print("running soupault") # run soupault on it. note that soupault currently follows symlinks, but we # workaround it. subprocess.run( [ soupault, "--site-dir", gen_dir, "--build-dir", build_dir, ], cwd=pathlib.Path(CONFIG_HOME), env={ **os.environ, 'SOUPAULT_CONFIG': '/dev/fd/{}'.format(soupault_config.fileno()) }, check=True, pass_fds=[soupault_config.fileno()] ) print("copying to output") # CANNOT use shutil.copytree - it is broken. # also need to be aware of copying into a directory, so we just always make it # a directory. browse = pathlib.Path.cwd() / "browse" browse.mkdir(parents=True,exist_ok=True) subprocess.run(["cp", "-R", "-P", *build_dir.glob("*"), browse], check=True) # └── gen # ├── blobs # │   └── e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 # │   ├── index.html # │   └── raw.bin # ├── commits # │   ├── 21177a2933b1a9d21d8437159405c5bc68b4d32e # │   │   ├── index.html # │   │   └── tree -> ../../trees/1663be45d5f6b9f092c4b98d44cf7992b427172f # │   └── 3ea9318f6271ece3c7560f18d0b22f50bd3cefe5 # │   ├── index.html # │   └── tree -> ../../trees/17d6338b3a3dc189bdc3bea8481fe5f32fd388c8 # ├── refs # │   └── heads # │   └── default # │   ├── index.html # │   └── tree -> ../../../trees/1663be45d5f6b9f092c4b98d44cf7992b427172f # └── trees # ├── 1663be45d5f6b9f092c4b98d44cf7992b427172f # │   ├── bar -> ../../blobs/e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 # │   ├── baz -> ../29ba47b07d262ad717095f2d94ec771194c4c083 # │   ├── deleteme -> ../../blobs/e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 # │   ├── foo -> ../../blobs/e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 # │   └── index.html # ├── 17d6338b3a3dc189bdc3bea8481fe5f32fd388c8 # │   ├── bar -> ../../blobs/e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 # │   ├── baz -> ../29ba47b07d262ad717095f2d94ec771194c4c083 # │   ├── foo -> ../../blobs/e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 # │   └── index.html # └── 29ba47b07d262ad717095f2d94ec771194c4c083 # ├── index.html # └── qux -> ../../blobs/e69de29bb2d1d6434b8b29ae775ad8c2e48c5391