dtext links: add table for tracking links between wikis.

Add a dtext_links table for tracking links between wiki pages. This is
to allow for broken link detection and "what links here" searches, among
other uses.
This commit is contained in:
evazion
2019-10-23 14:23:03 -05:00
parent f54885b72e
commit 9f0ecf7247
7 changed files with 178 additions and 1 deletions

View File

@@ -77,6 +77,21 @@ class DText
title = WikiPage.normalize_title(title)
title
end
titles.uniq
end
def self.parse_external_links(text)
html = DTextRagel.parse(text)
fragment = Nokogiri::HTML.fragment(html)
links = fragment.css("a.dtext-external-link").map { |node| node["href"] }
links.uniq
end
def self.dtext_links_differ?(a, b)
Set.new(parse_wiki_titles(a)) != Set.new(parse_wiki_titles(b)) ||
Set.new(parse_external_links(a)) != Set.new(parse_external_links(b))
end
def self.strip_blocks(string, tag)