From e577cfecf29e649bd59f11848e71186d77905ef0 Mon Sep 17 00:00:00 2001
From: Bernardo Innocenti
Date: Sat, 22 Mar 2008 17:25:44 +0100
Subject: [PATCH] Make permalinks more search engine friendly
---
geekigeeki.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/geekigeeki.py b/geekigeeki.py
index 7688860..3b66445 100755
--- a/geekigeeki.py
+++ b/geekigeeki.py
@@ -70,8 +70,10 @@ def relative_url(pathname, privileged=False):
pathname = url + '/' + pathname
return pathname
-# Formatting stuff --------------------------------------------------
+def permalink(s):
+ return re.sub(' ', '-', re.sub('[^a-z0-9_ ]', '', s.lower()).strip())
+# Formatting stuff --------------------------------------------------
def emit_header(mime_type="text/html"):
print "Content-type: " + mime_type + "; charset=utf-8\n"
@@ -360,8 +362,8 @@ class PageFormatter:
self.h_level = 0
else:
self.h_level = len(word) - 1
- abridged = re.sub('[^A-Za-z0-9_]', '', self.line).lower()
- result = '\n
¶ ' % (self.h_level, abridged, abridged)
+ link = permalink(self.line)
+ result = '\n¶ ' % (self.h_level, link, link)
return result
def _br_repl(self, word):
--
2.25.1