Small adjustments in backlinking.

This commit is contained in:
Nicolas Stepien 2012-09-02 01:22:52 +02:00
parent 012d3ea332
commit 320cb1269c
2 changed files with 27 additions and 23 deletions

View File

@ -665,8 +665,7 @@
post: post, post: post,
info: info, info: info,
comment: $('.postMessage', post), comment: $('.postMessage', post),
quotelinks: [], quotelinks: []
backlinks: info.getElementsByClassName('backlink')
}; };
this.info = {}; this.info = {};
if (subject = $('.subject', info)) { if (subject = $('.subject', info)) {
@ -772,6 +771,7 @@
function Clone(origin) { function Clone(origin) {
var file, index, info, key, nodes, post, quotelink, root, val, _i, _j, _len, _len1, _ref, _ref1, _ref2; var file, index, info, key, nodes, post, quotelink, root, val, _i, _j, _len, _len1, _ref, _ref1, _ref2;
this.origin = origin;
_ref = ['ID', 'board', 'thread', 'info', 'quotes', 'isReply']; _ref = ['ID', 'board', 'thread', 'info', 'quotes', 'isReply'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
key = _ref[_i]; key = _ref[_i];
@ -786,8 +786,7 @@
post: post, post: post,
info: info, info: info,
comment: $('.postMessage', post), comment: $('.postMessage', post),
quotelinks: [], quotelinks: []
backlinks: info.getElementsByClassName('backlinks')
}; };
if (nodes.subject) { if (nodes.subject) {
this.nodes.subject = $('.subject', info); this.nodes.subject = $('.subject', info);
@ -813,9 +812,6 @@
if (nodes.date) { if (nodes.date) {
this.nodes.date = $('.dateTime', info); this.nodes.date = $('.dateTime', info);
} }
if (nodes.backlinkContainer) {
this.nodes.backlinkContainer = $('.container', info);
}
_ref1 = $$('.quotelink', this.nodes.comment); _ref1 = $$('.quotelink', this.nodes.comment);
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
quotelink = _ref1[_j]; quotelink = _ref1[_j];
@ -1093,11 +1089,18 @@
}, },
secondNode: function() { secondNode: function() {
var container; var container;
if (this.isClone || !(Conf['OP Backlinks'] || this.isReply)) { if (this.isClone && this.origin.nodes.backlinkContainer) {
container = $('.container', this.nodes.info);
this.nodes.backlinkContainer = container;
this.nodes.backlinks = container.getElementsByClassName('backlinks');
return;
}
if (!(Conf['OP Backlinks'] || this.isReply)) {
return; return;
} }
container = QuoteBacklink.getContainer("" + this.board + "." + this); container = QuoteBacklink.getContainer("" + this.board + "." + this);
this.nodes.backlinkContainer = container; this.nodes.backlinkContainer = container;
this.nodes.backlinks = container.getElementsByClassName('backlinks');
return $.add(this.nodes.info, container); return $.add(this.nodes.info, container);
}, },
getContainer: function(id) { getContainer: function(id) {

View File

@ -512,7 +512,6 @@ class Post
info: info info: info
comment: $ '.postMessage', post comment: $ '.postMessage', post
quotelinks: [] quotelinks: []
backlinks: info.getElementsByClassName 'backlink'
@info = {} @info = {}
if subject = $ '.subject', info if subject = $ '.subject', info
@ -602,7 +601,7 @@ class Post
$.rm clone.nodes.root $.rm clone.nodes.root
class Clone extends Post class Clone extends Post
constructor: (origin) -> constructor: (@origin) ->
for key in ['ID', 'board', 'thread', 'info', 'quotes', 'isReply'] for key in ['ID', 'board', 'thread', 'info', 'quotes', 'isReply']
# Copy or point to the origin's key value. # Copy or point to the origin's key value.
@[key] = origin[key] @[key] = origin[key]
@ -617,26 +616,23 @@ class Clone extends Post
info: info info: info
comment: $ '.postMessage', post comment: $ '.postMessage', post
quotelinks: [] quotelinks: []
backlinks: info.getElementsByClassName 'backlinks'
if nodes.subject if nodes.subject
@nodes.subject = $ '.subject', info @nodes.subject = $ '.subject', info
if nodes.name if nodes.name
@nodes.name = $ '.name', info @nodes.name = $ '.name', info
if nodes.email if nodes.email
@nodes.email = $ '.useremail', info @nodes.email = $ '.useremail', info
if nodes.tripcode if nodes.tripcode
@nodes.tripcode = $ '.postertrip', info @nodes.tripcode = $ '.postertrip', info
if nodes.uniqueID if nodes.uniqueID
@nodes.uniqueID = $ '.posteruid', info @nodes.uniqueID = $ '.posteruid', info
if nodes.capcode if nodes.capcode
@nodes.capcode = $ '.capcode', info @nodes.capcode = $ '.capcode', info
if nodes.flag if nodes.flag
@nodes.flag = $ '.countryFlag', info @nodes.flag = $ '.countryFlag', info
if nodes.date if nodes.date
@nodes.date = $ '.dateTime', info @nodes.date = $ '.dateTime', info
if nodes.backlinkContainer
@nodes.backlinkContainer = $ '.container', info
for quotelink in $$ '.quotelink', @nodes.comment for quotelink in $$ '.quotelink', @nodes.comment
# See comments in Post's constructor. # See comments in Post's constructor.
@ -916,7 +912,6 @@ QuoteBacklink =
# - newly fetched posts. # - newly fetched posts.
# - in copies. # - in copies.
# XXX what about order for fetched posts? # XXX what about order for fetched posts?
# XXX need to work on post copying first before appending inside copies too
# #
# First callback creates backlinks and add them to relevant containers. # First callback creates backlinks and add them to relevant containers.
# Second callback adds relevant containers into posts. # Second callback adds relevant containers into posts.
@ -956,10 +951,16 @@ QuoteBacklink =
$.add container, [$.tn(' '), link] $.add container, [$.tn(' '), link]
return return
secondNode: -> secondNode: ->
if @isClone and @origin.nodes.backlinkContainer
container = $ '.container', @nodes.info
@nodes.backlinkContainer = container
@nodes.backlinks = container.getElementsByClassName 'backlinks'
return
# Don't backlink the OP. # Don't backlink the OP.
return if @isClone or !(Conf['OP Backlinks'] or @isReply) return unless Conf['OP Backlinks'] or @isReply
container = QuoteBacklink.getContainer "#{@board}.#{@}" container = QuoteBacklink.getContainer "#{@board}.#{@}"
@nodes.backlinkContainer = container @nodes.backlinkContainer = container
@nodes.backlinks = container.getElementsByClassName 'backlinks'
$.add @nodes.info, container $.add @nodes.info, container
getContainer: (id) -> getContainer: (id) ->
@containers[id] or= @containers[id] or=