webcompat / webcompat.com

Source code for webcompat.com
https://webcompat.com
360 stars 191 forks source link

Managing content/navigation in a more elegant way #2391

Open karlcow opened 6 years ago

karlcow commented 6 years ago

This issue was triggered by #2337 and exists only as a brainstorming place. It might be closed without any resolution (What we have currently is working).

Two things which are feeling itchy

There might be solution for both of them separately. And ways to thing about it.

for example, we can imagine that we have a dictionary with all the contents. OR a JSON. The dictionary can be dynamically built from static files when we start the project. Or anything. The dictionary will have the notion of

Just prototyping something. We need to find better ways.

contents = {
    'reproduce-bug': {'part_of': 'contributors', 'prose': 'reproduce.html'},
    'report-bug': {'part_of': 'contributors', 'prose': 'report.html'},
    # etc
    }

# in views.py we can have the content passed to the template and its position in the hierarchy.
# This would reduce greatly the number of files in templates.
def contributors('/contributors/<content_id>'):
    """Handles all routes for contributors section."""
    if content_id in contents['content_id']:
        page = contents['content_id']
        # the upper section it is part of
        part_of = page['part_of']
        # The text of this page, so not part anymore of the templates
        prose = get_content_file(page['prose'])
        # etc.
        return render_template('contributors', part_of=part_of, prose=prose)
    abort(404)
karlcow commented 6 years ago

Slightly related https://flask-menu.readthedocs.io/en/latest/

karlcow commented 6 years ago

Another thought. This content is mostly static.

I wonder if we need

  1. to verify the login status for this section
  2. to dynamically generate the page at each request while we could serve them as static files.
miketaylr commented 6 years ago

I think the general direction in your first comment is interesting, and worth experimenting with. views.py gets to be filled with what seems like boilerplate for those mostly static pages, which seems like the right time to simplify.