Skip to content

Managing content/navigation in a more elegant way #2391

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

Open
karlcow opened this issue Apr 12, 2018 · 3 comments
Open

Managing content/navigation in a more elegant way #2391

karlcow opened this issue Apr 12, 2018 · 3 comments

Comments

@karlcow
Copy link
Member

karlcow commented Apr 12, 2018

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

  • The tight coupling in between the views and the templates for navigation
  • The number of views necessary for content which are basically doing nothing except doing the same thing. :) returning the templates.

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

  • hierarchy the content is part of
  • the prose reference or the prose itself.
  • titles, etc.
  • anything…

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
Copy link
Member Author

karlcow commented Apr 12, 2018

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

@karlcow
Copy link
Member Author

karlcow commented Apr 13, 2018

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
Copy link
Member

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.

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

No branches or pull requests

3 participants