aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cgit/cgitrc3
-rwxr-xr-xcgit/filters/html-transform.py16
2 files changed, 13 insertions, 6 deletions
diff --git a/cgit/cgitrc b/cgit/cgitrc
index 4e2521a..d4297f5 100644
--- a/cgit/cgitrc
+++ b/cgit/cgitrc
@@ -78,7 +78,8 @@ enable-html-serving=1
enable-blame=1
snapshots=tar.gz zip
remove-suffix=1
-repository-sort=age
+repository-sort=name # age
+section-sort=1
max-repo-count=50
max-blob-size=512
max-commit-count=20
diff --git a/cgit/filters/html-transform.py b/cgit/filters/html-transform.py
index e12ffda..51b3538 100755
--- a/cgit/filters/html-transform.py
+++ b/cgit/filters/html-transform.py
@@ -41,12 +41,18 @@ class LinkRewriter(HTMLParser):
else:
value = "../" + urljoin("plain/", value)
attr_map[name] = value
- # Open in new tab
- if tag == "a" and name == "href" and is_absolute_url(value):
- if not 'target' in attr_map: attr_map['target'] = '_blank _parent'
- if not 'rel' in attr_map: attr_map['rel'] = 'noopener'
- attr_str = "".join(
+ # Open in new tab
+ if tag == 'a' and 'href' in attr_map and is_absolute_url(attr_map['href']):
+ if not 'target' in attr_map: attr_map['target'] = '_blank _parent'
+ if not 'rel' in attr_map: attr_map['rel'] = 'noopener'
+
+ # Image tag lazy loading
+ if tag == 'img':
+ attr_map['loading'] = 'lazy'
+ attr_map['decoding'] = 'async'
+
+ attr_str = ''.join(
f' {name}="{html.escape(value, quote=True)}"' if value is not None else f" {name}"
for name, value in attr_map.items()
)