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

Remove .html from internal URL() links. #846

Closed
hyanwong opened this issue May 4, 2024 · 2 comments · Fixed by #849
Closed

Remove .html from internal URL() links. #846

hyanwong opened this issue May 4, 2024 · 2 comments · Fixed by #849

Comments

@hyanwong
Copy link
Member

hyanwong commented May 4, 2024

@davidebbo pointed out a problem with accessing URLs using https://www.onezoom.org/life.html, instead of just https://www.onezoom.org/life (no extension): #843.

The search bug is now fixed but he also (very reasonably) said:

We should fix all internal links to not have the extension, if only for consistency. e.g. it doesn't have it from the home page (if you click on popular places...), but does have it from https://www.onezoom.org/introduction.html

We need to take a little care, because web2py can add e.g. a .load ending to {{=URL('default','life')}} if the view is itself access from a .load page (see http://web2py.com/books/default/chapter/29/04#Dispatching). Therefore I suggest, if we really mean the URL to be to a .html file, but don't want the extension to appear in the link, that we use

{{=URL('default','life',extension=False)}}

Since there is no life.load file in views/treeviewer (which is where default/life is redirected to in the controller), then we can quite reasonably do this for all instances of life.html, I think. These are the relevant files:

OZtree % grep -l 'life\.html' views/*/* controllers/*
views/default/FAQ.html
views/default/data_sources.load
views/default/endorsements.html
views/default/introduction.html
views/default/spl_maintenance.html
views/default/sponsor.html
views/default/sponsor_leaf.load
views/default/terms.load
views/default/treecards.html
views/education/educational_materials.html
views/manage/SHOW_EMAILS.html
grep: views/tour/tourstop: Is a directory
views/treeviewer/layout.html
controllers/default.py
@lentinj
Copy link
Collaborator

lentinj commented May 4, 2024

The menu is also a good target, e.g:

OZtree/models/menu.py

Lines 33 to 40 in fa65779

(T('For Everyone'), False, None , [ #need to set url_encode=False to avoid web2py quoting the @ sign
(T('A view of all known life'), False, URL('default', 'introduction', url_encode=False)),
(T('Your name on the tree'), False, URL('default' , 'sponsor.html')),
(T('Send a tr-eCard'), False, URL('default' , 'treecards.html')),
(T('Act for biodiversity'), False, URL('default' , 'otop_intro.html')),
(T('Full user guide'), False, URL('default' , 'full_guide.html')),
(T('My sponsorships'), False, URL('default' , 'sponsor_user_manage.html')),
]),

You could probably sort most of them with a regex find-replace.

@hyanwong
Copy link
Member Author

hyanwong commented May 4, 2024

OZtree/models/menu.py

I notice this also has the following. Presumably we should just remove anything below line 69? We don't use a developer menu, even in management mode.

DEVELOPMENT_MENU = False

#########################################################################
## provide shortcuts for development. remove in production
#########################################################################

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

Successfully merging a pull request may close this issue.

2 participants