This is a better way of detecting frontends

This commit is contained in:
kibigo! 2017-06-22 21:10:02 -07:00
parent ed82421870
commit da2b6dda6a
2 changed files with 8 additions and 1 deletions

View File

@ -9,7 +9,7 @@ class HomeController < ApplicationController
@web_settings = Web::Setting.find_by(user: current_user)&.data || {}
@admin = Account.find_local(Setting.site_contact_username)
@streaming_api_base_url = Rails.configuration.x.streaming_api_base_url
@frontend = (params[:frontend] and Rails.root.join('app', 'javascript', 'packs', 'frontends', '#{params[:frontend]}.js')) ? params[:frontend] : 'mastodon'
@frontend = (params[:frontend] and Rails.configuration.x.available_frontends.include? params[:frontend] + '.js') ? params[:frontend] : 'mastodon'
end
private

View File

@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
Rails.application.configure do
frontends = []
Rails.root.join('app', 'javascript', 'packs', 'frontends').each_child(false) { |f| frontends.push f.to_s }
config.x.available_frontends = frontends
end