add Permalinks support for vBulletin bulk import script

This commit is contained in:
Arpit Jalan 2017-08-04 12:23:11 +05:30
parent 40fc6c429a
commit 687b05750b
1 changed files with 24 additions and 1 deletions

View File

@ -432,7 +432,7 @@ end
task "import:create_phpbb_permalinks" => :environment do
log 'Creating Permalinks...'
# /[^\/]+\/.*-t(\d+).html
# /[^\/]+\/.*-t(\d+).html/
SiteSetting.permalink_normalizations = '/[^\/]+\/.*-t(\d+).html/thread/\1'
Topic.listable_topics.find_each do |topic|
@ -444,3 +444,26 @@ task "import:create_phpbb_permalinks" => :environment do
log "Done!"
end
task "import:create_vbulletin_permalinks" => :environment do
log 'Creating Permalinks...'
# /showthread.php\?t=(\d+).*/
SiteSetting.permalink_normalizations = '/showthread.php\?t=(\d+).*/showthread.php?t=\1'
Topic.listable_topics.find_each do |topic|
tcf = topic.custom_fields
if tcf && tcf["import_id"]
Permalink.create(url: "showthread.php?t=#{tcf["import_id"]}", topic_id: topic.id) rescue nil
end
end
Category.find_each do |cat|
ccf = cat.custom_fields
if ccf && ccf["import_id"]
Permalink.create(url: "forumdisplay.php?f=#{ccf["import_id"]}", category_id: cat.id) rescue nil
end
end
log "Done!"
end