-
Notifications
You must be signed in to change notification settings - Fork 119
Session cover pages #54
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
Conversation
|
||
## [Odkaz na feedback] | ||
|
||
[Odkaz na feedback]: http://s.quickmeme.com/img/a8/a8022006b463b5ed9be5a62f1bdbac43b4f3dbd5c6b3bb44707fe5f5e26635b0.jpg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naucse/routes.py
Outdated
nxt_link = str(next) | ||
nxt_title = next.title | ||
|
||
return prv_link, prv_title, nxt_link, nxt_title |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a class to group (link, title). Something like a tooltip might be added in the future.
Could you use a namedtuple
or SimpleNamespace
instead of two variables for each link?
naucse/routes.py
Outdated
for prev, current, next in zip([None] + lessons, | ||
lessons, | ||
lessons[1:] + [None]): | ||
if current.slug == lesson.slug: | ||
if prev: | ||
prev = prev.index_page | ||
prv_link = str(prev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't return the text representation of a page, but an URL. The text representation is a human-readable string that might easily change in the future.
Make prv_next_teller
take the subpage_url
function as argument if necessary.
naucse/templates/lesson.html
Outdated
<div class="col text-right"> | ||
<a href="{{ lesson_url(nxt.lesson, page=nxt.slug) }}">{{ nxt.title }} →</a> | ||
<a href="{{ lesson_url(('/').join(nxt_link.split('/')[:2])) }}">{{ nxt_title }} →</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL manipulation should be left to the URL converters and @app.route()
. Avoid having logic involving /
elsewhere – you're making too many assumptions about the structure of the object's str()
representation.
naucse/templates/session.html
Outdated
</div> | ||
{% endif %} | ||
</div> | ||
{% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be made into a macro. Could you start a template file with utility macros? Docs are here.
naucse/routes.py
Outdated
|
||
md_content = Markup(convert_markdown(content)) | ||
|
||
return render_template('session.html', content=md_content, page=page) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A separate render_session
function is not necessary. Its functionality is not that well separated from what should be in session_page
.
This is unlike session_template_or_404
, which has a clear purpose.
It's also unlike render_page
, which exists as a separate function because it's called for both the "just a lesson" URL and for lessons in a run – the common code is in a shared function rather than repeated. But render_session
is only called from one place.
naucse/routes.py
Outdated
|
||
def session_template_or_404(run, session, page): | ||
env = app.jinja_env.overlay(loader=session_template_loader) | ||
run_link = str(run).split(" - ")[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't parse the string representation of objects – what if someone decides to make it more useful and puts more info into it?
Use the individual properties. (Look into Run.__str__
for their names.)
naucse/routes.py
Outdated
|
||
def session_url(session): | ||
"""Link to the specific lesson.""" | ||
return url_for('session_page', run=run, session=session, page=page) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this session_url
function used?
Last time, I made fairly big changes to make the code look the way I wanted, to make everything ready in time. I'd like to avoid that from now on, and merge as soon as the content for current runs (PyLadies and Python's Libraries) is good to go. I've marked issues for that as blockers. The pages that aren't linked from current runs are a playground now. Let's iterate on making it as good as it can be, but the iterations can take longer. I'll be happy to merge if non-blocker issues are remaining – that's why there's a red warning on the site, after all. With that, please consider the points below. Set your priorities. And, don't make a change just because it's here – if you're not convinced, let's discuss. Page issues
Possible technical debtHere are things that won't affect the result, but might make the code more pleasant to work with in the future.
|
In this pull request it has the next link to install-editor. When you click on some link in this lesson, it's subpage. When you go through lessons with arrows, you look at index install page, choose subpage and install something or you realize you have already installed these, so you can directly continue to the next page.
Again, not in this pull request. Subpage links to the next lesson. Maybe the session link should be replaced with link to chapter (install).
What you mean by "won't show up properly"? I don't see any problem. But if there is a serious problem on small screens, is can be replaced by just arrows ←↑ → there.
What you consider as the first page here?
Which common code? |
OK, that does make sense here.
On "Install Python for Linux", the links should be:
The point is that the
If you can you make it work for all sizes, that would be great!
The cover page at the beginning of the session.
Mainly in the template. |
if (page.subpages != None and page.slug in page.subpages.keys() | ||
and "prev" in page.subpages[page.slug].keys() and "next" in page.subpages[page.slug].keys()) : | ||
prev_segments = page.subpages[page.slug]["prev"].split(':') | ||
next_segments = page.subpages[page.slug]["next"].split(':') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading correctly, this way the title of the link can't have a colon in it. Is that a reasonable limitation?
The configuration already comes from YAML. Why invent a special format for this field?
prev_segments.append("index") | ||
|
||
kwargs['prv'] = models.Navigation(prev_segments[0], prev_segments[1], prev_segments[2]) | ||
kwargs['nxt'] = models.Navigation(next_segments[0], next_segments[1], next_segments[2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the code to create a Navigation
is duplicated twice here. Is there a better place for initialization code to go?
|
||
Arguments: | ||
title the title of the link location | ||
url <lesson_type>/<lesson> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really a URL.
[Ostrava] Feedback for classes
Uh oh!
There was an error while loading. Please reload this page.