mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 05:11:20 +08:00
Allow plugins to ship custom styles only for mobile
- adds another :mobile-flag to register_assets - adds test for plugin registering of assets - load plugins when on desktop and plugins_mobile when on mobile
This commit is contained in:
@ -5,7 +5,8 @@ require_dependency 'plugin/auth_provider'
|
||||
|
||||
class Plugin::Instance
|
||||
|
||||
attr_reader :auth_providers, :assets
|
||||
attr_reader :auth_providers, :assets, :admin_javascripts,
|
||||
:server_side_javascripts, :styles, :mobile_styles
|
||||
attr_accessor :path, :metadata
|
||||
|
||||
def self.find_all(parent_path)
|
||||
@ -93,11 +94,14 @@ class Plugin::Instance
|
||||
@javascripts << js
|
||||
end
|
||||
|
||||
def register_asset(file,opts=nil)
|
||||
def register_asset(file, opts=nil)
|
||||
full_path = File.dirname(path) << "/assets/" << file
|
||||
if opts == :admin
|
||||
@admin_javascripts ||= []
|
||||
@admin_javascripts << full_path
|
||||
elsif opts == :mobile
|
||||
@mobile_styles ||= []
|
||||
@mobile_styles << full_path
|
||||
else
|
||||
assets << full_path
|
||||
end
|
||||
@ -178,6 +182,12 @@ class Plugin::Instance
|
||||
end
|
||||
end
|
||||
|
||||
if @mobile_styles
|
||||
@mobile_styles.each do |style|
|
||||
DiscoursePluginRegistry.mobile_stylesheets << style
|
||||
end
|
||||
end
|
||||
|
||||
if @server_side_javascripts
|
||||
@server_side_javascripts.each do |js|
|
||||
DiscoursePluginRegistry.server_side_javascripts << js
|
||||
|
Reference in New Issue
Block a user