Fix multiple backlinks

This commit is contained in:
Nicolas Stepien 2011-05-09 18:21:21 +02:00
parent 68ffc27a72
commit ee2c5000c2
2 changed files with 31 additions and 7 deletions

View File

@ -1681,16 +1681,35 @@
return g.callbacks.push(quoteBacklink.node); return g.callbacks.push(quoteBacklink.node);
}, },
node: function(root) { node: function(root) {
var el, id, link, quote, _i, _len, _ref, _results; var backlink, el, id, link, nogood, quote, _i, _len, _ref, _results;
_ref = $$('a.quotelink', root); _ref = $$('a.quotelink', root);
_results = []; _results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote = _ref[_i]; quote = _ref[_i];
_results.push((el = d.getElementById(quote.textContent.slice(2))) ? (id = quote.parentNode.parentNode.parentNode.id, link = $.el('a', { _results.push((function() {
href: '#' + id, var _j, _len2, _ref2;
className: 'backlink', if (el = d.getElementById(quote.textContent.slice(2))) {
textContent: '>>' + id id = quote.parentNode.parentNode.parentNode.id;
}), el.className !== 'op' ? $.before($('br, blockquote', el), link) : void 0) : void 0); link = $.el('a', {
href: '#' + id,
className: 'backlink',
textContent: '>>' + id
});
if (el.className !== 'op') {
nogood = 0;
_ref2 = $$('a.backlink', el);
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
backlink = _ref2[_j];
if (backlink.textContent === '>>' + id) {
nogood = 1;
}
}
if (!nogood) {
return $.before($('br, blockquote', el), link);
}
}
}
})());
} }
return _results; return _results;
} }

View File

@ -1353,7 +1353,12 @@ quoteBacklink =
className: 'backlink' className: 'backlink'
textContent: '>>'+id textContent: '>>'+id
unless el.className is 'op' unless el.className is 'op'
$.before $('br, blockquote', el), link nogood = 0
for backlink in $$ 'a.backlink', el
if backlink.textContent is '>>'+id
nogood = 1
unless nogood
$.before $('br, blockquote', el), link
quotePreview = quotePreview =
init: -> init: ->