redimp / otterwiki

A minimalistic wiki powered by python, markdown and git.
https://otterwiki.com
MIT License
252 stars 23 forks source link

Fixes #85 - adds support for case sensitive page names #88

Closed weaversam8 closed 7 months ago

weaversam8 commented 7 months ago

See discussion in #85. This adds the ability for page names to resolve case-sensitively, but only when the RAW_PAGE_NAMES configuration option is set.

weaversam8 commented 7 months ago

Open to suggestions here - I do think that passing a raw_page_names argument into those utility functions all over the place does get a bit inconvenient, but I'm not sure of a better way to do it without creating a circular import.

redimp commented 7 months ago

Thank you for the work! From the first read through I have to say it looks good.

Will look into the details on Friday (unfortunately got a full day today and tomorrow).

redimp commented 7 months ago

I have adopted your commits and worked a little on them. Please double check that the branch feature/retain-page-name-case does what you want and solves #85 for you.

Details: With moving the functions get_filename, get_attachment_directoryname and get_pagename into otterwiki.helper they can access app.config and don't need the extra argument anymore.

I've renamed the config setting to RETAIN_PAGE_NAME_CASE .. this sounds less "raw" to me.

weaversam8 commented 7 months ago

Hi @redimp - this looks great, much cleaner! Almost ready to merge your branch - only one thing: you forgot to update the preference page to reflect the name change. Here's the patch for your branch:

From 47c60f948833b8cf5c2dd607c7b7ec7409971565 Mon Sep 17 00:00:00 2001
From: Sam Weaver <sweaver@relaypro.com>
Date: Mon, 26 Feb 2024 17:20:07 -0500
Subject: [PATCH] redimp/otterwiki#88 - Update preferences page to reflect new
 preference name

---
 otterwiki/preferences.py       | 2 +-
 otterwiki/templates/admin.html | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/otterwiki/preferences.py b/otterwiki/preferences.py
index 6e1a8db..131481a 100644
--- a/otterwiki/preferences.py
+++ b/otterwiki/preferences.py
@@ -82,7 +82,7 @@ def handle_app_preferences(form):
         "email_needs_confirmation",
         "notify_admins_on_register",
         "notify_user_on_approval",
-        "raw_page_names",
+        "retain_page_name_case",
     ]:
         _update_preference(checkbox.upper(),form.get(checkbox, "False"))
     # commit changes to the database
diff --git a/otterwiki/templates/admin.html b/otterwiki/templates/admin.html
index 5901f88..cf8d82e 100644
--- a/otterwiki/templates/admin.html
+++ b/otterwiki/templates/admin.html
@@ -223,9 +223,10 @@ selected="selected"
 {##}
     <div class="form-group">
       <div class="custom-checkbox">
-        <input {%if config.RETAIN_PAGE_NAME_CASE %}checked{% endif %} type="checkbox" id="raw_page_names" name="raw_page_names"
+        <input {%if config.RETAIN_PAGE_NAME_CASE %}checked{% endif %} type="checkbox" id="retain_page_name_case"
+          name="retain_page_name_case"
           value="True">
-        <label for="raw_page_names">Retain page name case.</label>
+        <label for="retain_page_name_case">Retain page name case.</label>
         <div class="mt-5">
             Enable this to retain upper and lower case of the page name in the filename used for storing the page.
         </div>
-- 
2.35.1
redimp commented 7 months ago

Thanks for double checking and for providing the patch.

Will add this to the next release (this week).

(I forgot to send this yesterday)