A platform for community discussion. Free, open, simple.
Nodebb importer: add permalinks, exclude disabled categories
Penar Musarajb6a7b851c77c
diff --git a/script/import_scripts/nodebb/nodebb.rb b/script/import_scripts/nodebb/nodebb.rbindex 45078de4239..2397c5a9936 100644--- a/script/import_scripts/nodebb/nodebb.rb+++ b/script/import_scripts/nodebb/nodebb.rb@@ -73,7 +73,7 @@ class ImportScripts::NodeBB < ImportScripts::Basecategory_ids = category_map.keyscategories = 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|{@@ -86,7 +86,7 @@ class ImportScripts::NodeBB < ImportScripts::Baseputs "", "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"] })# cut down the tree to only 2 levels of categories@@ -105,6 +105,12 @@ class ImportScripts::NodeBB < ImportScripts::Baseparent_category_id: category_id_from_imported_category_id(category["parentCid"])}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+enddef import_users@@ -357,6 +363,11 @@ class ImportScripts::NodeBB < ImportScripts::Basedataend++ 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+ endendend