Browse Source

Properly URL-encode tag links.

master
Ben Kurtovic 10 years ago
parent
commit
c041caed51
2 changed files with 10 additions and 3 deletions
  1. +1
    -1
      _layouts/post.html
  2. +9
    -2
      static/main.js

+ 1
- 1
_layouts/post.html View File

@@ -7,7 +7,7 @@ layout: base
<ul id="post-info">
<li><span><i class="fa fa-tag"></i> Tags:</span>
{% for tag in page.tags %}
<a href="/#{{tag}}" class="post-tag">{{tag}}</a>
<a href="/#{{ tag }}" class="post-tag">{{ tag }}</a>
{% endfor %}
<li><span><i class="fa fa-clock-o"></i> Date:</span> {{ page.date | date: "%B %-d, %Y" }}</li>
<li><span><i class="fa fa-comments"></i></span> <a href="#disqus_thread">Jump to comments</a></li>


+ 9
- 2
static/main.js View File

@@ -1,3 +1,9 @@
function fix_tag_links() {
$("#post-info").find("a").attr("href", function() {
return "/#" + encodeURIComponent($(this).text());
});
}

function load_tag_filters() {
var filter_posts = function(filter) {
var num_selected = $(".tag-selected").length;
@@ -18,7 +24,7 @@ function load_tag_filters() {
}

if (window.location.hash) {
var tags = window.location.hash.substr(1).split("|");
var tags = decodeURIComponent(window.location.hash.substr(1)).split("|");
$(".tag").each(function() {
if ($.inArray($(this).text(), tags) != -1)
$(this).toggleClass("tag-selected");
@@ -34,7 +40,7 @@ function load_tag_filters() {
tags.push($(this).text())
});
if (tags.length > 0)
window.location.hash = tags.join("|");
window.location.hash = encodeURIComponent(tags.join("|"));
else
history.pushState("", "", window.location.pathname);
filter_posts(tags);
@@ -53,6 +59,7 @@ function load_paragraph_links() {
}

$(document).ready(function() {
fix_tag_links();
load_tag_filters();
load_paragraph_links();
});

Loading…
Cancel
Save