Dan Neumann wrote:
Some parts of Discourse source realllllly want there to be an Uncategorized category.
Good example in app/models/category_list.rb (all of this in the #initialize method). I simplified the code to summarize relevant bits.
# This code is run on the categories page to populate the @categories collection # that's looped through in the template. # So first we get all of the categories @categories = Category.all # and then we get the topics that belong to no category: uncategorized_topics = Topic.where(category_id: nil) if uncategorized_topics.present? # Tally up the years/months/week topic counts as if it's a real category. totals = Topic.exec_sql("SELECT SUM(…) …") # Initialize a new category so that we can pretend like we have an # Uncategorized category. uncategorized = Category.new({name: SiteSetting.uncategorized_name, slug: Slug.for(SiteSetting.uncategorized_name), featured_topics: uncategorized_topics}.merge(totals)) # (but we're really just spinning a *web of lies*.) # Insert our fake category into the list of real categories @categories.insert(insert_at || @categories.size, uncategorized) end
There are some places in Discourse source that would benefit considerably from creating an Uncategorized category.
Topics with no target category simply get added to it.
Users can already set the uncategorized "category" name, so an uncategorized category would of course abide by that option.
Posts: 5
Participants: 4