Nodebb importer: add permalinks, exclude disabled categories
This commit is contained in:
parent
4020c87680
commit
b6a7b851c7
|
@ -73,7 +73,7 @@ class ImportScripts::NodeBB < ImportScripts::Base
|
||||||
category_ids = category_map.keys
|
category_ids = category_map.keys
|
||||||
categories = category_map.values
|
categories = category_map.values
|
||||||
|
|
||||||
top_level_categories = categories.select { |c| c["parentCid"] == "0" }
|
top_level_categories = categories.select { |c| c["parentCid"] == "0" && c["disabled"] != "1" }
|
||||||
|
|
||||||
create_categories(top_level_categories) do |category|
|
create_categories(top_level_categories) do |category|
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,7 @@ class ImportScripts::NodeBB < ImportScripts::Base
|
||||||
|
|
||||||
puts "", "importing child categories..."
|
puts "", "importing child categories..."
|
||||||
|
|
||||||
children_categories = categories.select { |c| c["parentCid"] != "0" }
|
children_categories = categories.select { |c| c["parentCid"] != "0" && c["disabled"] != "1" }
|
||||||
top_level_category_ids = Set.new(top_level_categories.map { |c| c["cid"] })
|
top_level_category_ids = Set.new(top_level_categories.map { |c| c["cid"] })
|
||||||
|
|
||||||
# cut down the tree to only 2 levels of categories
|
# cut down the tree to only 2 levels of categories
|
||||||
|
@ -105,6 +105,12 @@ class ImportScripts::NodeBB < ImportScripts::Base
|
||||||
parent_category_id: category_id_from_imported_category_id(category["parentCid"])
|
parent_category_id: category_id_from_imported_category_id(category["parentCid"])
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
categories.each do |source_category|
|
||||||
|
cid = category_id_from_imported_category_id(source_category['cid'])
|
||||||
|
Permalink.create(url: "/category/#{source_category['slug']}", category_id: cid) rescue nil
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_users
|
def import_users
|
||||||
|
@ -357,6 +363,11 @@ class ImportScripts::NodeBB < ImportScripts::Base
|
||||||
|
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
topics.each do |import_topic|
|
||||||
|
topic = topic_lookup_from_imported_post_id("t#{import_topic["tid"]}")
|
||||||
|
Permalink.create(url: "/topic/#{import_topic['slug']}", topic_id: topic[:topic_id]) rescue nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue