|
|
|
@ -1,6 +1,7 @@
|
|
|
|
import glob
|
|
|
|
import glob
|
|
|
|
import os.path
|
|
|
|
import os.path
|
|
|
|
import urllib.parse
|
|
|
|
import urllib.parse
|
|
|
|
|
|
|
|
from functools import lru_cache
|
|
|
|
from pathlib import Path
|
|
|
|
from pathlib import Path
|
|
|
|
from typing import Optional
|
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
|
|
|
|
@ -131,6 +132,7 @@ class ExtraNetworksPage:
|
|
|
|
"tabname": json.dumps(tabname),
|
|
|
|
"tabname": json.dumps(tabname),
|
|
|
|
"local_preview": json.dumps(item["local_preview"]),
|
|
|
|
"local_preview": json.dumps(item["local_preview"]),
|
|
|
|
"name": item["name"],
|
|
|
|
"name": item["name"],
|
|
|
|
|
|
|
|
"description": (item.get("description") or ""),
|
|
|
|
"card_clicked": onclick,
|
|
|
|
"card_clicked": onclick,
|
|
|
|
"save_card_preview": '"' + html.escape(f"""return saveCardPreview(event, {json.dumps(tabname)}, {json.dumps(item["local_preview"])})""") + '"',
|
|
|
|
"save_card_preview": '"' + html.escape(f"""return saveCardPreview(event, {json.dumps(tabname)}, {json.dumps(item["local_preview"])})""") + '"',
|
|
|
|
"search_term": item.get("search_term", ""),
|
|
|
|
"search_term": item.get("search_term", ""),
|
|
|
|
@ -147,6 +149,19 @@ class ExtraNetworksPage:
|
|
|
|
return self.link_preview(file)
|
|
|
|
return self.link_preview(file)
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@lru_cache(maxsize=512)
|
|
|
|
|
|
|
|
def _find_description(self, path: str) -> Optional[str]:
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Find and read a description file for a given path (without extension).
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
for file in [f"{path}.txt", f"{path}.description.txt"]:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
with open(file, "r", encoding="utf-8", errors="replace") as f:
|
|
|
|
|
|
|
|
return f.read()
|
|
|
|
|
|
|
|
except OSError:
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def intialize():
|
|
|
|
def intialize():
|
|
|
|
extra_pages.clear()
|
|
|
|
extra_pages.clear()
|
|
|
|
|