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

SlideShow: use url_for() #1748

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/moin/apps/frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,7 @@ def slide_item(item_name, rev):
if isinstance(item, NonExistent):
abort(404, item_name)
data_rendered = Markup(item.content._render_data_slide())
return render_template(
"slideshow.html", item_name=item.name, full_name=fqname.fullname, data_rendered=data_rendered
)
return render_template("slideshow.html", item_name=item.name, data_rendered=data_rendered)


@presenter("get")
Expand Down
4 changes: 3 additions & 1 deletion src/moin/macros/SlideShow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create link to start a SlideShow for the current item
"""

from flask import url_for
from moin.i18n import _
from moin.utils.tree import moin_page, xlink
from moin.macros._base import MacroInlineBase
Expand All @@ -14,5 +15,6 @@ class Macro(MacroInlineBase):
def macro(self, content, arguments, page_url, alternative):
attrib = {moin_page.class_: "fa-regular fa-circle-play"}
children = [moin_page.span(attrib=attrib), _(" Start SlideShow")]
result = moin_page.a(attrib={xlink.href: f"/+slideshow{page_url.path}"}, children=children)
url = url_for("frontend.slide_item", item_name=page_url.path[1:])
result = moin_page.a(attrib={xlink.href: url}, children=children)
return result
7 changes: 5 additions & 2 deletions src/moin/templates/slideshow.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
<!-- navigation to first or last slide or exit slideshow -->
<div class="navi-container">
<span class="slide-nav" onclick="showSlide(1)" title="First slide"><i class="fa-solid fa-backward-fast"></i></span>
<span class="slide-nav"><a class="slide-nav" title="Exit slideshow" href="/{{full_name}}">
<i class="fa-solid fa-right-from-bracket"></i></a></span>
<span class="slide-nav">
<a class="slide-nav" title="Exit slideshow" href="{{ url_for('frontend.show_item', item_name=item_name) }}">
<i class="fa-solid fa-right-from-bracket"></i>
</a>
</span>
<span class="slide-nav" onclick="lastSlide()" title="Last slide"><i class="fa-solid fa-forward-fast"></i></span>
</div>

Expand Down