feat: allow publishing posts without indexing them
This commit is contained in:
parent
38d59de6c0
commit
36e46f8cfd
2 changed files with 6 additions and 1 deletions
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
||||||
.PHONY: help bump publish
|
.PHONY: help bump publish
|
||||||
VERSION = 1.9.12
|
VERSION = 1.9.15
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||||
|
|
|
@ -5,6 +5,8 @@ from urllib.parse import urlparse
|
||||||
from base.indexnow import get_key
|
from base.indexnow import get_key
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
from blog.models import BlogPage
|
||||||
|
|
||||||
|
|
||||||
@hooks.register('after_publish_page')
|
@hooks.register('after_publish_page')
|
||||||
def after_publish_page(request, page):
|
def after_publish_page(request, page):
|
||||||
|
@ -14,6 +16,9 @@ def after_publish_page(request, page):
|
||||||
if urlparse(page_url).hostname == "localhost":
|
if urlparse(page_url).hostname == "localhost":
|
||||||
print("not notifying indexnow for localhost" + get_key() + ", page url: " + page_url)
|
print("not notifying indexnow for localhost" + get_key() + ", page url: " + page_url)
|
||||||
return
|
return
|
||||||
|
if urlparse(page_url).path.endswith("--priv") or urlparse(page_url).path.endswith("--priv/"):
|
||||||
|
print("not notifying indexnow for blog page --priv")
|
||||||
|
return
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
session.post(
|
session.post(
|
||||||
"https://api.indexnow.org/indexnow",
|
"https://api.indexnow.org/indexnow",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue