Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Updated IPB import script

Carsten Brandt921e2213b8dd
diff --git a/script/import_scripts/ipboard.rb b/script/import_scripts/ipboard.rb
index f1b10b6a5b6..316aa983bea 100644
--- a/script/import_scripts/ipboard.rb
+++ b/script/import_scripts/ipboard.rb
@@ -788,6 +788,10 @@ EOM
raw.gsub!(/'/, "'")
raw.gsub!(/\[url="(.+?)"\]http.+?\[\/url\]/, "\\1\n")
raw.gsub!(/\[media\](.+?)\[\/media\]/, "\n\\1\n\n")
+ raw.gsub!(/\[php\](.+?)\[\/php\]/m) { |m| "\n\n```php\n\n" + @htmlentities.decode($1.gsub(/\n\n/, "\n")) + "\n\n```\n\n" }
+ raw.gsub!(/\[code\](.+?)\[\/code\]/m) { |m| "\n\n```\n\n" + @htmlentities.decode($1.gsub(/\n\n/, "\n")) + "\n\n```\n\n" }
+ raw.gsub!(/\[list\](.+?)\[\/list\]/m) { |m| "\n" + $1.gsub(/\[\*\]/, "\n- ") + "\n\n" }
+ raw.gsub!(/\[quote\]/, "\n[quote]\n")
raw.gsub!(/\[\/quote\]/, "\n[/quote]\n")
raw.gsub!(/date=\'(.+?)\'/, '')
raw.gsub!(/timestamp=\'(.+?)\' /, '')
@@ -829,9 +833,16 @@ EOM
puts "Attachment #{attach_id} not found."
attach_string = "Attachment #{attach_id} not found."
else
- attach_string = "#{attach_id}\n\n![#{attachments.first['filename']}](#{UPLOADS}/#{attachments.first['loc']})\n"
+ attach_url = "#{UPLOADS}/#{attachments.first['loc'].gsub(' ', '%20')}"
+ if attachments.first['filename'].match(/(png|jpg|jpeg|gif)$/)
+ # images are rendered as a link that contains the image
+ attach_string = "#{attach_id}\n\n[![#{attachments.first['filename']}](#{attach_url})](#{attach_url})\n"
+ else
+ # other attachments are simple download links
+ attach_string = "#{attach_id}\n\n[#{attachments.first['filename']}](#{attach_url})\n"
+ end
end
- raw.gsub!(attach_regex, attach_string)
+ raw.sub!(attach_regex, attach_string)
end
raw