summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolderpunk <solderpunk@sdf.org>2020-03-17 21:19:28 +0100
committerSolderpunk <solderpunk@sdf.org>2020-03-17 21:19:28 +0100
commit56cff3febb8423d36d55d0f71469c74fc4b7b7a3 (patch)
tree737ed88e5dd5f1f596bdf151d56a3e9a3cb616c0
parent44d0e7139d1acc1be5ef8258ef962784c4697853 (diff)
Fix another default feed name bug!
-rw-r--r--gemfeed.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/gemfeed.py b/gemfeed.py
index c724c65..a80711d 100644
--- a/gemfeed.py
+++ b/gemfeed.py
@@ -35,7 +35,13 @@ def get_feed_title(directory):
the content of the first heading line in the file, otherwise return a
default feed title.
"""
- default = os.path.basename(directory)
+ # By default, use the deepest directory name as a feed title
+ # This needs a little care, as os.path.basename will return an empty
+ # string if `directory` ends in a trailing slash...
+ head, default = os.path.split(directory)
+ if not default:
+ default = os.path.basename(head)
+ # Check for index files which may override the default
for index_file in ("index.gmi", "index.gemini"):
index_file = os.path.join(directory, index_file)
if os.path.exists(index_file) and is_world_readable(index_file):