diff options
author | Rob Austein <sra@hactrn.net> | 2021-07-24 01:00:09 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2021-07-24 01:01:01 +0000 |
commit | 6e916e6715b10627ac34b4439397308e5be2109a (patch) | |
tree | ceec03301adeab2a5c114e1a1e271c5d506cafb9 /kludge-cgit-urls.py | |
parent | 4ce647bd96d624b10a4bd19c4c6104fea601b6a4 (diff) |
Clean up more links, convert to m.css theme (no JavaScript!)
Diffstat (limited to 'kludge-cgit-urls.py')
-rwxr-xr-x | kludge-cgit-urls.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/kludge-cgit-urls.py b/kludge-cgit-urls.py index 9d9feed..4867fed 100755 --- a/kludge-cgit-urls.py +++ b/kludge-cgit-urls.py @@ -9,6 +9,8 @@ with open("repositories.json") as f: plain = "](https://git.cryptech.is" export = "](export:/" +browser = "https://trac.cryptech.is/browser/" +gitrepositories = "GitRepositories/" regexp = re.compile(r"(\(https://git\.cryptech\.is/(?:" + repo_or + "))([(/)])") for root, dirs, files in os.walk("pelican/content"): @@ -18,11 +20,21 @@ for root, dirs, files in os.walk("pelican/content"): fn = os.path.join(root, fn) with open(fn) as f: lines = f.readlines() - if not any(plain in line or export in line for line in lines): + if not any(any(pattern in line for pattern in (plain, export, browser, gitrepositories)) + for line in lines): continue changes = 0 for i, line in enumerate(lines): - if export in line: + if browser in line: + changes = 1 + line = line.replace(browser, "https://git.cryptech.is/") + elif gitrepositories in line: + changes = 1 + line = line \ + .replace("[GitRepositories/", "[") \ + .replace("(GitRepositories/", "(https://git.cryptech.is/") \ + .replace("({filename}GitRepositories/", "(https://git.cryptech.is/") + elif export in line: changes = 1 line = line.replace(export, "](https://git.cryptech.is/") elif plain not in line: |