Short URLs to fix long export calendar URLs#9383
Short URLs to fix long export calendar URLs#9383andreslucena merged 8 commits intodecidim:developfrom
Conversation
This is because the map initialization can cause JavaScript errors in the test environment when the map is displayed but not properly configured.
|
Some reasoning for some of the technical decisions:
In short, if you want to create short links in any view:
<p>Link to the current component (when within a component):</p>
<p><%= short_url %></p>
<p>Link to custom resource route with parameters:</p>
<p><%= short_url(route_name: "custom_route", params: { decidim: "is", pretty: "neat" }) %></p>Both keyword arguments are optional and have the following meanings:
If you don't provide the
If you want to create a short URL to a specific resource in Decidim, such as a static page, a meeting, etc. you can also do that as follows: # Link to a Decidim::StaticPage
static_page_short_url = Decidim::ShortLink.to(Decidim::StaticPage.first, "decidim").short_url
# Link to a Decidim::Meetings::Meeting within a participatory space
meeting = Decidim::Meetings::Meeting.first
meeting_short_url = Decidim::ShortLink.to(meeting, meeting.component.mounted_engine).short_urlOr alternatively, you could do the following from within the view: <p>Link to a static page (from the static page itself):</p>
<p><%= short_url(route_name: "static_page", params: { id: @page.slug }) %></p>
<p>Link to a meeting (from the single meeting page):</p>
<p><%= short_url(route_name: "meeting", params: { id: meeting.id }) %></p>
<p>Link to the meetings calendar URL (from the meetings component):</p>
<p><%= short_url(route_name: "calendar", params: { filter: { some: "filter" } }) %></p> |
|
@andreslucena This is ready for review. |
andreslucena
left a comment
There was a problem hiding this comment.
I really like the approach of having a ShortLink API.
As I've mentioned, this was talked about some years ago, but we never found time to do it. Now it makes sense to solve the problem with the Calendar URLs, and I'm sure that this will be used on other places too.
About the implementation itself, not much to say: the code is clean and there are lots of comments explaining in detail what's happening 💯 . I've found just two tiny comments to change and for me, we're good to go.
I also tried it locally with the Calendar URL export to check that it works as expected (it does!). Couldn't try it yet with Google Calendar, but as we've seen at #9115 this should work.
|
Regarding the labels, this is a weird case where for fixing a bug we needed to implement a new feature, so I though "why no both?" 🤷🏽♂️ |
|
@andreslucena Thanks for the review, typos fixed in the code comments. |
* Base implementation for the short links * Add specs for short link and the related engine resolver * Improve linking to resources with slugs and IDs with the short links * Improve the short link testing to specific resources * Improve short links testing for the controller and helper * Initialize the share calendar URL modal before inititializing the map This is because the map initialization can cause JavaScript errors in the test environment when the map is displayed but not properly configured. * Add short link testing for the meetings index and meetings directory * Fix few typos in the short link helper comments
* Base implementation for the short links * Add specs for short link and the related engine resolver * Improve linking to resources with slugs and IDs with the short links * Improve the short link testing to specific resources * Improve short links testing for the controller and helper * Initialize the share calendar URL modal before inititializing the map This is because the map initialization can cause JavaScript errors in the test environment when the map is displayed but not properly configured. * Add short link testing for the meetings index and meetings directory * Fix few typos in the short link helper comments
🎩 What? Why?
Some calendar programs do not accept long URLs and this causes the export calendar URLs not to work properly always.
See further details from: #9116
📌 Related Issues
Testing
Paste the short calendar URL to your calendar program and see if it works correctly.
Also see the related comments at #9115.
📋 Checklist
docs/.📷 Screenshots