related tags: fix wiki page tag extraction.
* Parse the wiki page with the actual dtext parser instead of by hand. This is so that wiki links inside things like [nodtext] or [code] blocks are handled properly. * Only include tags that exist and are nonempty. Don't include links to dead pages or blank tags.
This commit is contained in:
@@ -200,13 +200,8 @@ class WikiPage < ApplicationRecord
|
||||
end
|
||||
|
||||
def tags
|
||||
body.scan(/\[\[(.+?)\]\]/).flatten.map do |match|
|
||||
if match =~ /^(.+?)\|(.+)/
|
||||
$1
|
||||
else
|
||||
match
|
||||
end
|
||||
end.map {|x| x.mb_chars.downcase.tr(" ", "_").to_s}.uniq
|
||||
titles = DText.parse_wiki_titles(body)
|
||||
Tag.nonempty.where(name: titles.uniq).pluck(:name)
|
||||
end
|
||||
|
||||
def visible?
|
||||
|
||||
Reference in New Issue
Block a user