some improvements for importers (#5295)

* decode html entities within code blocks

* Only import users that actually participated in the bbpress part of Wordpress; import password hashes

* create permalinks for topics

* Better handling of [code] blocks
This commit is contained in:
discoursehosting
2017-11-07 17:50:43 +01:00
committed by Régis Hanol
parent faf8bba9a6
commit 4f0bdec370
2 changed files with 66 additions and 8 deletions

View File

@ -8,6 +8,7 @@ module ImportScripts::PhpBB3
@lookup = lookup
@database = database
@smiley_processor = smiley_processor
@he = HTMLEntities.new
@settings = settings
@new_site_prefix = settings.new_site_prefix
@ -25,7 +26,7 @@ module ImportScripts::PhpBB3
process_smilies(text)
process_links(text)
process_lists(text)
process_code(text)
text
end
@ -48,6 +49,9 @@ module ImportScripts::PhpBB3
# [url=https://google.com:1qh1i7ky]click here[/url:1qh1i7ky]
# [quote="cybereality":b0wtlzex]Some text.[/quote:b0wtlzex]
text.gsub!(/:(?:\w{8})\]/, ']')
# remove color tags
text.gsub!(/\[\/?color(=#[a-z0-9]*)?\]/i, "")
end
def bbcode_to_md(text)
@ -142,5 +146,12 @@ module ImportScripts::PhpBB3
@long_internal_link_regexp = Regexp.new(%Q|<!-- l --><a(?:.+)href="#{link_regex}"(?:.*)</a><!-- l -->|, Regexp::IGNORECASE)
@short_internal_link_regexp = Regexp.new(link_regex, Regexp::IGNORECASE)
end
def process_code(text)
text.gsub!(/<span class="syntax.*?>(.*?)<\/span>/) {"#{$1}"}
text.gsub!(/\[code(=[a-z]*)?\](.*?)\[\/code\]/i) { "[code]#{@he.decode($2)}[/code]" }
text.gsub!(/<br \/>/, "\n")
text
end
end
end