mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Groundwork for user-selectable theme components
* Phase 0 for user-selectable theme components - Drops `key` column from the `themes` table - Drops `theme_key` column from the `user_options` table - Adds `theme_ids` (array of ints default []) column to the `user_options` table and migrates data from `theme_key` to the new column. - Removes the `default_theme_key` site setting and adds `default_theme_id` instead. - Replaces `theme_key` cookie with a new one called `theme_ids` - no longer need Theme.settings_for_client
This commit is contained in:
@@ -65,13 +65,14 @@ module Middleware
|
||||
end
|
||||
|
||||
def cache_key
|
||||
@cache_key ||= "ANON_CACHE_#{@env["HTTP_ACCEPT"]}_#{@env["HTTP_HOST"]}#{@env["REQUEST_URI"]}|m=#{is_mobile?}|c=#{is_crawler?}|b=#{has_brotli?}|t=#{theme_key}"
|
||||
@cache_key ||= "ANON_CACHE_#{@env["HTTP_ACCEPT"]}_#{@env["HTTP_HOST"]}#{@env["REQUEST_URI"]}|m=#{is_mobile?}|c=#{is_crawler?}|b=#{has_brotli?}|t=#{theme_id}"
|
||||
end
|
||||
|
||||
def theme_key
|
||||
key, _ = @request.cookies['theme_key']&.split(',')
|
||||
if key && Guardian.new.allow_theme?(key)
|
||||
key
|
||||
def theme_id
|
||||
ids, _ = @request.cookies['theme_ids']&.split('|')
|
||||
ids = ids&.split(",")&.map(&:to_i)
|
||||
if ids && Guardian.new.allow_themes?(ids)
|
||||
ids.first
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
Reference in New Issue
Block a user