summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormjfernez <mjf@mjfer.net>2023-12-24 12:41:02 -0500
committermjfernez <mjf@mjfer.net>2023-12-24 12:41:02 -0500
commit2495b97b0ba33f3e7bf96e09d4a6c8dc7ac5107e (patch)
tree6ca0ebc918e53f9e74152559f81d18d794dfb960
parentad7a378b801b0071182ef3205867d55a7697f775 (diff)
Update SEO, grab meta descriptions from .desc
Keyword tags are outdated so those have been removed. Descriptions are more important that SEO. The description of the parent directory is used
-rw-r--r--templates/base.html10
-rw-r--r--view_functions.py9
-rw-r--r--views.py13
3 files changed, 20 insertions, 12 deletions
diff --git a/templates/base.html b/templates/base.html
index d1d0c08..a4e8a5d 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -4,15 +4,7 @@
<head>
<base target="_blank">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <meta name="description" content="a homepage run by an idiot,
- full of sound and fury, signifying nothing."/>
- <meta name="keywords" content="HTML, web, servers, linux, bsd,
- hacking, forensics, tor, anonymity, internet, society, luddite,
- futurism, lulz, fun, poetry, games, vidya, thoughts, random,
- homepage, email server, web server, sound, fury, shakespeare,
- nothing, writing, audio, classical music, video game music,
- mjfernez, mjfernet, mike, fernez, mikefernez, michael, Fernez,
- Mike, Mike Fernez, Michael Fernez"/>
+ <meta name="description" content="{{ description }}"/>
<meta name="author" content="mjfernez">
<!--<meta name="viewport" content="width=device-width,
initial-scale=1.0"/> -->
diff --git a/view_functions.py b/view_functions.py
index 4163c2e..b2e0720 100644
--- a/view_functions.py
+++ b/view_functions.py
@@ -81,3 +81,12 @@ def is_hidden_path(path):
if d.startswith('.'):
return True
return False
+
+
+def load_description(parent_dir):
+ description = None
+ description_file = parent_dir + '/' + siteconfig.DESC_FILE
+ if os.path.isfile(description_file):
+ with open(description_file, "r") as f:
+ description = f.read().strip()
+ return description
diff --git a/views.py b/views.py
index fda6152..aabe2a8 100644
--- a/views.py
+++ b/views.py
@@ -29,7 +29,11 @@ def home():
"""
context = default_context()
context.update(
- {'title': app.config['HOME_TITLE'], 'parent_dir': None}
+ {
+ 'title': app.config['HOME_TITLE'],
+ 'parent_dir': None,
+ 'description': load_description(siteconfig.BASE_DIR)
+ }
)
return render_template("site/home.html", **context)
@@ -49,13 +53,16 @@ def render_file(path):
abort(404)
abs_path = siteconfig.BASE_DIR + path
+ parent_dir = '/' + '/'.join(path.split('/')[:-1])
context = default_context()
if os.path.isfile(abs_path):
+ description = load_description(siteconfig.BASE_DIR + parent_dir)
context.update(
{
'title': path.split('.')[0].upper(),
- 'parent_dir': '/' + '/'.join(path.split('/')[:-1]),
+ 'parent_dir': parent_dir,
'last_update': file_last_modified(path),
+ 'description': description
}
)
if abs_path.endswith('.html'):
@@ -81,7 +88,7 @@ def render_file(path):
context.update(
{
'title': path.split('.')[0].upper(),
- 'parent_dir': '/' + '/'.join(path.split('/')[:-1]),
+ 'parent_dir': parent_dir,
'cur_path': path,
'cur_dir': path.split('/')[-1] + '/',
'dirs': dirs,