summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Micay <daniel.micay@grapheneos.org>2024-06-02 09:58:54 -0400
committerDaniel Micay <daniel.micay@grapheneos.org>2024-06-02 09:58:54 -0400
commit4b599c242140cbc9d35d98b9f15f2ad13051b45e (patch)
treee74bf7eb79086f7e4cf320846591c728f9c8e2fc
parentda0717613cfc2db9150891dfa90d01c15a7e0640 (diff)
run indexnow script automatically
-rwxr-xr-xdeploy-static6
-rwxr-xr-xgenerate-sitemap3
-rwxr-xr-xindexnow1
3 files changed, 9 insertions, 1 deletions
diff --git a/deploy-static b/deploy-static
index 64086281..6afdedad 100755
--- a/deploy-static
+++ b/deploy-static
@@ -24,7 +24,7 @@ rsync -rpcv --chmod=D755,F644 --delete --fsync --preallocate static-tmp/ static-
for f in static-production/**.*(br|gz); do
touch -r "${f%.*}" "$f"
done
-./generate-sitemap
+changed="$(./generate-sitemap)"
xmllint --noblanks static-tmp/sitemap.xml --output static-tmp/sitemap.xml
brotli -f static-tmp/sitemap.xml
zopfli static-tmp/sitemap.xml
@@ -58,3 +58,7 @@ for server in ${servers[@]}; do
echo active is now $target
echo
done
+
+if [[ -n "$changed" ]]; then
+ ./indexnow <<< "$changed"
+fi
diff --git a/generate-sitemap b/generate-sitemap
index 4deaafd0..449f3c5f 100755
--- a/generate-sitemap
+++ b/generate-sitemap
@@ -35,6 +35,7 @@ pages = [
["/usage", 1.0]
]
+base_mtime = getmtime("static-tmp")
entries = []
for page in pages:
@@ -47,6 +48,8 @@ for page in pages:
filepath += ".html"
mtime = getmtime(filepath)
+ if mtime > base_mtime:
+ print(loc)
lastmod = datetime.fromtimestamp(mtime, timezone.utc).strftime("%Y-%m-%dT%H:%M:%S%:z")
priority = page[1]
entries.append(f"""
diff --git a/indexnow b/indexnow
index 19580784..dbd98b4c 100755
--- a/indexnow
+++ b/indexnow
@@ -24,6 +24,7 @@ with open("indexnow-key.txt") as keyfile:
key = keyfile.read().strip()
def submit(urls):
+ print(urls)
data = {
"host": host,
"key": key,