Compare commits

...

2 commits

Author SHA1 Message Date
Daoud Clarke cfe18162f1 Blacklist another domain 2023-11-21 11:24:48 +00:00
Daoud Clarke b868b6284b Encode URLs properly 2023-11-21 10:45:50 +00:00
2 changed files with 9 additions and 8 deletions

View file

@ -32,7 +32,7 @@ SCORE_FOR_SAME_DOMAIN = 0.01
EXTRA_LINK_MULTIPLIER = 0.001
UNKNOWN_DOMAIN_MULTIPLIER = 0.001
EXCLUDED_DOMAINS = {'web.archive.org', 'forums.giantitp.com', 'www.crutchfield.com', 'plus.google.com'}
DOMAIN_BLACKLIST_REGEX = re.compile(r"porn|xxx|jksu\.org|lwhyl\.org$|rgcd\.cn$|hzqwyou\.cn$")
DOMAIN_BLACKLIST_REGEX = re.compile(r"porn|xxx|jksu\.org|lwhyl\.org$|rgcd\.cn$|hzqwyou\.cn$|omgoat\.org$")
CORE_DOMAINS = {
'github.com',
'en.wikipedia.org',

View file

@ -1,7 +1,7 @@
from dataclasses import dataclass
from datetime import datetime
from itertools import groupby
from urllib.parse import urlparse, parse_qs
from urllib.parse import urlparse, parse_qs, urlencode, urlunparse, ParseResult
import justext
import requests
@ -66,12 +66,13 @@ def home_fragment(request):
"query": query,
"activity": activity,
})
current_url = request.htmx.current_url
# Replace query string with new query
stripped_url = current_url[:current_url.index("?")] if "?" in current_url else current_url
query_string = "?q=" + query if len(query) > 0 else ""
new_url = stripped_url + query_string
# Set the htmx replace header
# Encode the new query string
if query:
new_query_string = urlencode({"q": query}, doseq=True)
new_url = "/?" + new_query_string
else:
new_url = "/"
response["HX-Replace-Url"] = new_url
return response