Quote markers.

This commit is contained in:
Mayhem 2014-02-08 18:05:33 +01:00
parent a072d67a8a
commit f6f1126130
11 changed files with 77 additions and 98 deletions

View File

@ -1,3 +1,8 @@
- New setting: `Quote Markers`, enabled by default
- This merges `Mark Quotes of You`, `Mark OP Quotes` and `Mark Cross-thread Quotes` into one feature.
- Backlinks now also get these markers.
- Multiple markers are now more compact, for example `>>123 (You/OP)` instead of `>>123 (You) (OP)`.
### 3.16.5 - *2014-02-07*
- Added `Archive link` to the Custom Board Navigation Rice

View File

@ -73,9 +73,7 @@ Config =
'Quote Previewing': [true, 'Show quoted post on hover.']
'Quote Highlighting': [true, 'Highlight the previewed post.']
'Resurrect Quotes': [true, 'Link dead quotes to the archives.']
'Mark Quotes of You': [true, 'Add \'(You)\' to quotes linking to your posts.']
'Mark OP Quotes': [true, 'Add \'(OP)\' to OP quotes.']
'Mark Cross-thread Quotes': [true, 'Add \'(Cross-thread)\' to cross-threads quotes.']
'Quote Markers': [true, 'Add "(You)", "(OP)", "(Cross-thread)", "(Dead)" markers to quote links.']
imageExpansion:
'Fit width': [true, '']
'Fit height': [false, '']

View File

@ -96,9 +96,7 @@ Main =
initFeature 'Quote Inlining', QuoteInline
initFeature 'Quote Previewing', QuotePreview
initFeature 'Quote Backlinks', QuoteBacklink
initFeature 'Mark Quotes of You', QuoteYou
initFeature 'Mark OP Quotes', QuoteOP
initFeature 'Mark Cross-thread Quotes', QuoteCT
initFeature 'Quote Markers', QuoteMarkers
initFeature 'Anonymize', Anonymize
initFeature 'Color User IDs', IDColor
initFeature 'Time Formatting', Time

View File

@ -177,8 +177,11 @@ class Post
# Get quotelinks/backlinks to this post
# and paint them (Dead).
for quotelink in Get.allQuotelinksLinkingTo @ when not $.hasClass quotelink, 'deadlink'
$.add quotelink, $.tn '\u00A0(Dead)'
$.addClass quotelink, 'deadlink'
continue unless Conf['Quote Markers']
post = Get.postFromNode quotelink
{board, thread} = if post.isClone then post.context else post
QuoteMarkers.parseQuotelink board, thread, post, quotelink, true
return
# XXX tmp fix for 4chan's racing condition
# giving us false-positive dead posts.
@ -197,10 +200,12 @@ class Post
for clone in @clones
clone.resurrect()
for quotelink in Get.allQuotelinksLinkingTo @
if $.hasClass quotelink, 'deadlink'
quotelink.textContent = quotelink.textContent.replace '\u00A0(Dead)', ''
$.rmClass quotelink, 'deadlink'
for quotelink in Get.allQuotelinksLinkingTo @ when $.hasClass quotelink, 'deadlink'
$.rmClass quotelink, 'deadlink'
continue unless Conf['Quote Markers']
post = Get.postFromNode quotelink
{board, thread} = if post.isClone then post.context else post
QuoteMarkers.parseQuotelink board, thread, post, quotelink, true
return
collect: ->

View File

@ -192,8 +192,8 @@ Settings =
'Remember QR size': ''
'Quote Inline': 'Quote Inlining'
'Quote Preview': 'Quote Previewing'
'Indicate OP quote': 'Mark OP Quotes'
'Indicate Cross-thread Quotes': 'Mark Cross-thread Quotes'
'Indicate OP quote': ''
'Indicate Cross-thread Quotes': ''
# filter
'uniqueid': 'uniqueID'
'mod': 'capcode'

View File

@ -24,10 +24,17 @@ QuoteBacklink =
cb: @secondNode
firstNode: ->
return if @isClone or !@quotes.length
text = QuoteBacklink.funk @ID
a = $.el 'a',
href: "/#{@board}/res/#{@thread}#p#{@}"
className: if @isHidden then 'filtered backlink' else 'backlink'
textContent: QuoteBacklink.funk @ID
className: 'backlink'
textContent: text
if @isHidden
$.addClass a, 'filtered'
if @isDead
$.addClass a, 'deadlink'
if Conf['Quote Markers']
QuoteMarkers.parseQuotelink @board, @thread, @, a, false, text
for quote in @quotes
containers = [QuoteBacklink.getContainer quote]
if (post = g.posts[quote]) and post.nodes.backlinkContainer

View File

@ -1,22 +0,0 @@
QuoteCT =
init: ->
return if !Conf['Mark Cross-thread Quotes']
# \u00A0 is nbsp
@text = '\u00A0(Cross-thread)'
Post.callbacks.push
name: 'Mark Cross-thread Quotes'
cb: @node
node: ->
# Stop there if it's a clone of a post in the same thread.
return if @isClone and @thread is @context.thread
{board, thread} = if @isClone then @context else @
for quotelink in @nodes.quotelinks
{boardID, threadID} = Get.postDataFromLink quotelink
continue unless threadID # deadlink
if @isClone
quotelink.textContent = quotelink.textContent.replace QuoteCT.text, ''
if boardID is board.ID and threadID isnt thread.ID
$.add quotelink, $.tn QuoteCT.text
return

View File

@ -0,0 +1,39 @@
QuoteMarkers =
init: ->
return if !Conf['Quote Markers']
Post.callbacks.push
name: 'Quote Markers'
cb: @node
node: ->
{board, thread} = if @isClone then @context else @
for quotelink in @nodes.quotelinks
QuoteMarkers.parseQuotelink board, thread, @, quotelink, !!@isClone
return
parseQuotelink: (board, thread, post, quotelink, mayReset, customText) ->
markers = []
{boardID, threadID, postID} = Get.postDataFromLink quotelink
if QR.db?.get {boardID, threadID, postID}
markers.push 'You'
if board.ID is boardID
if thread.ID is postID
markers.push 'OP'
if threadID and threadID isnt thread.ID # threadID is 0 for deadlinks
markers.push 'Cross-thread'
if $.hasClass quotelink, 'deadlink'
markers.push 'Dead'
text = if customText
customText
else if boardID is post.board.ID
">>#{postID}"
else
">>>/#{boardID}/#{postID}"
if markers.length
quotelink.textContent = "#{text}\u00A0(#{markers.join '/'})"
else if mayReset
quotelink.textContent = text

View File

@ -1,29 +0,0 @@
QuoteOP =
init: ->
return if !Conf['Mark OP Quotes']
# \u00A0 is nbsp
@text = '\u00A0(OP)'
Post.callbacks.push
name: 'Mark OP Quotes'
cb: @node
node: ->
# Stop there if it's a clone of a post in the same thread.
return if @isClone and @thread is @context.thread
# Stop there if there's no quotes in that post.
return unless (quotes = @quotes).length
{quotelinks} = @nodes
# rm (OP) from cross-thread quotes.
if @isClone and @thread.fullID in quotes
for quotelink in quotelinks
quotelink.textContent = quotelink.textContent.replace QuoteOP.text, ''
{fullID} = (if @isClone then @context else @).thread
# add (OP) to quotes quoting this context's OP.
return unless fullID in quotes
for quotelink in quotelinks
{boardID, postID} = Get.postDataFromLink quotelink
if "#{boardID}.#{postID}" is fullID
$.add quotelink, $.tn QuoteOP.text
return

View File

@ -1,14 +0,0 @@
QuoteYou =
init: ->
return if !Conf['Mark Quotes of You'] or !Conf['Quick Reply']
# \u00A0 is nbsp
@text = '\u00A0(You)'
Post.callbacks.push
name: 'Mark Quotes of You'
cb: @node
node: ->
return if @isClone
for quotelink in @nodes.quotelinks when QR.db.get Get.postDataFromLink quotelink
$.add quotelink, $.tn QuoteYou.text
return

View File

@ -37,28 +37,20 @@ Quotify =
quoteID = "#{boardID}.#{postID}"
if post = g.posts[quoteID]
unless post.isDead
# Don't (Dead) when quotifying in an archived post,
# and we know the post still exists.
a = $.el 'a',
href: "/#{boardID}/res/#{post.thread}#p#{postID}"
className: 'quotelink'
textContent: quote
else
# Replace the .deadlink span if we can redirect.
a = $.el 'a',
href: "/#{boardID}/res/#{post.thread}#p#{postID}"
className: 'quotelink deadlink'
target: '_blank'
textContent: "#{quote}\u00A0(Dead)"
$.extend a.dataset, {boardID, threadID: post.thread.ID, postID}
else if redirect = Redirect.to 'thread', {boardID, threadID: 0, postID}
# Don't add 'deadlink' when quotifying in an archived post,
# and we don't know if the post died yet.
a = $.el 'a',
href: "/#{boardID}/res/#{post.thread}#p#{postID}"
className: if post.isDead then 'quotelink deadlink' else 'quotelink'
textContent: quote
$.extend a.dataset, {boardID, threadID: post.thread.ID, postID}
else if redirect = Redirect.to 'thread', {boardID, postID}
# Replace the .deadlink span if we can redirect.
a = $.el 'a',
href: redirect
className: 'deadlink'
textContent: quote
target: '_blank'
textContent: "#{quote}\u00A0(Dead)"
if Redirect.to 'post', {boardID, postID}
# Make it function as a normal quote if we can fetch the post.
$.addClass a, 'quotelink'
@ -68,7 +60,7 @@ Quotify =
@quotes.push quoteID
unless a
deadlink.textContent = "#{quote}\u00A0(Dead)"
deadlink.textContent = "#{quote}\u00A0(Dead)" if Conf['Quote Markers']
return
$.replace deadlink, a