Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to customize the 404 page #197

Open
mattock opened this issue Feb 4, 2025 · 2 comments
Open

Add ability to customize the 404 page #197

mattock opened this issue Feb 4, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@mattock
Copy link

mattock commented Feb 4, 2025

Currently the 404 page is hardcoded (templates/page404.html). In our case we'd like to customize that page as we're migrating away from an old Trac wiki and wish to let people know why they may be hitting a 404 page in Otterwiki. While we can modify that file directly, it is a rather bad option as it makes Git unhappy. Two options I can think of to make this better:

Allow defining a custom 404 URL

This would default to an empty string. If it is an empty string, Otterwiki would default to its current behavior. Alternatively there could be a separate boolean to turn this on coupled with a string (HTML) field. As far as I can see, implementing this requires these steps:

  • templates/admin.html needs a new entry for custom 404 URL setting (empty by default)
  • preferences.py method handle_app_preferences() needs to be modified to commit the new 404 URL setting
  • wiki.py method exists_or_404() would need to check app.config['404_URL'] and act accordingly

Does this look correct? Is something else required, e.g. for database migrations?

Allow embedding custom HTML code snippets to page404.html

The implementation might be slightly simpler than above(?). Basically the snippet would be empty by default. If defined, it would override or get prepended/appended the default page404.html.


Any thoughts regarding this? I could take a stab at implementing this myself as it looks deceptively simple to do 😂 .

@redimp redimp added the enhancement New feature or request label Feb 4, 2025
@redimp
Copy link
Owner

redimp commented Feb 4, 2025

Hey @mattock! Great idea and for sure very useful.

I like the idea of defining a custom URL more. Because you can just point it to a Wiki Page and there you can edit it nicely.

Does this look correct? Is something else required, e.g. for database migrations?

Another thing is to add the default in the server.py here:

app.config.update(
DEBUG=False, # make sure DEBUG is off unless enabled explicitly otherwise
TESTING=False,
LOG_LEVEL="INFO",
REPOSITORY=None,
SECRET_KEY="CHANGE ME",
SITE_NAME="An Otter Wiki",
SITE_DESCRIPTION=None,
SITE_LOGO=None,
SITE_ICON=None,
HIDE_LOGO=False,
AUTH_METHOD="",
READ_ACCESS="ANONYMOUS",
WRITE_ACCESS="ANONYMOUS",
ATTACHMENT_ACCESS="ANONYMOUS",
AUTO_APPROVAL=True,
DISABLE_REGISTRATION=False,
EMAIL_NEEDS_CONFIRMATION=True,
NOTIFY_ADMINS_ON_REGISTER=False,
NOTIFY_USER_ON_APPROVAL=False,
RETAIN_PAGE_NAME_CASE=False,
SQLALCHEMY_DATABASE_URI="sqlite:///:memory:",
MAIL_DEFAULT_SENDER="[email protected]",
MAIL_SERVER="",
MAIL_PORT="",
MAIL_USERNAME="",
MAIL_PASSWORD="",
MAIL_USE_TLS=False,
MAIL_USE_SSL=False,
SQLALCHEMY_TRACK_MODIFICATIONS=False,
MINIFY_HTML=True,
SIDEBAR_MENUTREE_MODE="SORTED",
SIDEBAR_MENUTREE_IGNORE_CASE=False,
SIDEBAR_MENUTREE_MAXDEPTH="",
SIDEBAR_CUSTOM_MENU="",
COMMIT_MESSAGE="REQUIRED", # OPTIONAL DISABLED
GIT_WEB_SERVER=False,
SIDEBAR_SHORTCUTS="home pageindex createpage",
ROBOTS_TXT="allow",
WIKILINK_STYLE="",
MAX_FORM_MEMORY_SIZE=1_000_0000,
)

Any thoughts regarding this? I could take a stab at implementing this myself as it looks deceptively simple to do 😂 .

Go for it, a PR is very welcome.

@mattock
Copy link
Author

mattock commented Feb 5, 2025

Ok, I shall take a deep breath in the upcoming weeks and try to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants