Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve the link handling * Improve further the link handling * More iterations * Another iteration * Enforce http or https protocols * Temporary commit * Running linters * Refactor the links controller * Apply review recommendations * Add handling for invalid url * Further improve the controller
- Loading branch information
Showing
8 changed files
with
151 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
decidim-core/app/views/decidim/links/_invalid_url_modal.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<%= decidim_modal id: "external-domain-warning" do %> | ||
<div data-dialog-container> | ||
<%= icon "external-link-line" %> | ||
<h2 id="dialog-title-external-domain-warning" tabindex="-1" data-dialog-title><%= t("decidim.links.warning.title") %></h2> | ||
<div> | ||
|
||
<code class="mt-5 block break-all text-alert"> | ||
<%= flash[:alert] %> | ||
</code> | ||
</div> | ||
</div> | ||
<div data-dialog-actions> | ||
<button class="button button__lg button__transparent-secondary" data-dialog-close="external-domain-warning"> | ||
<%= t("decidim.links.warning.cancel") %> | ||
</button> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(function() { | ||
const create = (selector) => { | ||
const element = document.createElement("div") | ||
element.id = selector | ||
document.body.append(element) | ||
return element | ||
} | ||
|
||
const selector = "external-domain-warning" | ||
const selectorContainer = `${selector}-container` | ||
|
||
// if the container does not exist in the DOM, it creates a new one, otherwise, replace the content | ||
const externalDomainWarning = document.getElementById(selectorContainer) || create(selectorContainer) | ||
|
||
externalDomainWarning.innerHTML = '' | ||
externalDomainWarning.innerHTML = '<%= j(render partial: "invalid_url_modal").strip.html_safe %>' | ||
|
||
new window.Decidim.Dialogs(`#${selector}`, { | ||
closingSelector: `[data-dialog-close="${selector}"]`, | ||
backdropSelector: `[data-dialog="${selector}"]`, | ||
labelledby: `dialog-title-${selector}`, | ||
describedby: `dialog-desc-${selector}` | ||
}).open() | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters