mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 09:46:12 +00:00
Escape special HTML characters on the events page
This commit is contained in:
parent
701dfd35a2
commit
4bdca82894
3 changed files with 19 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "Inside Bitcoins London"
|
title: "Inside Bitcoins London"
|
||||||
venue: "The Grange"
|
venue: "Grange St Paul's Hotel"
|
||||||
address: "10 Godliman St"
|
address: "10 Godliman St"
|
||||||
city: "London"
|
city: "London"
|
||||||
country: "England"
|
country: "England"
|
||||||
|
|
16
_plugins/htmlescape.rb
Normal file
16
_plugins/htmlescape.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#htmlescape espaces special html characters. This is a replacement for
|
||||||
|
#CGI::escapeHTML, which has an inconsistent behavior with single quotes
|
||||||
|
#on different ruby versions ( 1.9 and 2.0 ).
|
||||||
|
|
||||||
|
#Example:
|
||||||
|
# {{ page.title | htmlescape }}
|
||||||
|
|
||||||
|
module Entities
|
||||||
|
|
||||||
|
def htmlescape(input)
|
||||||
|
input.gsub(/['&\"<>]/, { "'" => ''', '&' => '&', '"' => '"', '<' => '<', '>' => '>' })
|
||||||
|
end
|
||||||
|
|
||||||
|
Liquid::Template.register_filter self
|
||||||
|
|
||||||
|
end
|
|
@ -23,7 +23,7 @@ L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
|
|
||||||
var markers = new L.MarkerClusterGroup({showCoverageOnHover: false, maxClusterRadius: 20});
|
var markers = new L.MarkerClusterGroup({showCoverageOnHover: false, maxClusterRadius: 20});
|
||||||
{% filter_for p in site.pages sort_by:date category:event %}{% if p.geoloc != 'false' %}
|
{% filter_for p in site.pages sort_by:date category:event %}{% if p.geoloc != 'false' %}
|
||||||
L.marker([{{ p.geoloc }}]).bindPopup('<b><a href="{{ p.link }}">{{ p.title }}</a></b><br>{{ p.date }}<br>{{ p.venue }}<br>{{ p.address }}<br>{{ p.city }}, {{ p.country }}').addTo(markers);
|
L.marker([{{ p.geoloc }}]).bindPopup('<b><a href="{{ p.link | htmlescape }}">{{ p.title | htmlescape }}</a></b><br>{{ p.date }}<br>{{ p.venue | htmlescape }}<br>{{ p.address | htmlescape }}<br>{{ p.city | htmlescape }}, {{ p.country | htmlescape }}').addTo(markers);
|
||||||
{% endif %}{% endfilter_for %}
|
{% endif %}{% endfilter_for %}
|
||||||
map.addLayer(markers);
|
map.addLayer(markers);
|
||||||
</script>
|
</script>
|
||||||
|
@ -31,7 +31,7 @@ map.addLayer(markers);
|
||||||
<ul>
|
<ul>
|
||||||
{% filter_for p in site.pages sort_by:date category:event %}
|
{% filter_for p in site.pages sort_by:date category:event %}
|
||||||
<li>
|
<li>
|
||||||
{{ p.date | date:"%Y-%m-%d" }} - <a href="{{ p.link }}">{{ p.title }}</a> - {{ p.city }}, {{ p.country }}
|
{{ p.date | date:"%Y-%m-%d" }} - <a href="{{ p.link | htmlescape }}">{{ p.title | htmlescape }}</a> - {{ p.city | htmlescape }}, {{ p.country | htmlescape }}
|
||||||
</li>
|
</li>
|
||||||
{% endfilter_for %}
|
{% endfilter_for %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue