i'm about to give up
This commit is contained in:
parent
a7c3acea76
commit
010d0a327e
|
@ -25,13 +25,13 @@ class Theme < ActiveRecord::Base
|
|||
before_save do
|
||||
self.css = nil
|
||||
|
||||
style = ThemeIO.new(render_theme_with_context(self))
|
||||
style = StringIO.new(render_theme_with_context(self))
|
||||
|
||||
style.instance_variable_set '@content_type', 'text/css'
|
||||
style.class.class_eval { attr_accessor :original_filename, :content_type }
|
||||
|
||||
style.content_type = 'text/css'
|
||||
style.original_filename = 'theme.css'
|
||||
|
||||
self.css = style
|
||||
|
||||
self.css.instance_write :content_type, 'text/css'
|
||||
self.css_content_type = 'text/css'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
= javascript_include_tag 'i18n', 'data-turbolinks-track' => true
|
||||
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
|
||||
- if user_signed_in? and not current_user.theme.nil?
|
||||
%link{rel: 'stylesheet', href: current_user.theme.css.url, media: :all, 'data-turbolinks-track' => true}
|
||||
%link{rel: 'stylesheet', href: current_user.theme.css.url, media: :all, 'data-turbolinks-track' => "true"}
|
||||
- if (not @user.nil?) and (not @user.theme.nil?) and (if user_signed_in? then current_user.show_foreign_themes? else true end)
|
||||
%link{rel: 'stylesheet', href: @user.theme.css.url, media: :all, 'data-turbolinks-track' => true}
|
||||
%link{rel: 'stylesheet', href: @user.theme.css.url, media: :all, 'data-turbolinks-track' => "true"}
|
||||
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
||||
- if user_signed_in?
|
||||
- if current_user.mod?
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# I seriously hope you guys don't do this.
|
||||
|
||||
class Paperclip::FileCommandContentTypeDetector
|
||||
alias stupid_type_from_file_command type_from_file_command
|
||||
alias old_type_from_file_command type_from_file_command
|
||||
def type_from_file_command
|
||||
default = stupid_type_from_file_command
|
||||
if default == 'text/x-c' and File.extname(@filename) == '.css'
|
||||
default = old_type_from_file_command
|
||||
if default.strip == 'text/x-c' or default.strip == 'text/plain' or default.strip == 'text/stylesheet'
|
||||
'text/css'
|
||||
else
|
||||
default
|
||||
|
@ -12,30 +12,4 @@ class Paperclip::FileCommandContentTypeDetector
|
|||
end
|
||||
end
|
||||
|
||||
class ThemeIO < StringIO
|
||||
def content_type
|
||||
'text/css'
|
||||
end
|
||||
|
||||
def original_filename
|
||||
'theme.css'
|
||||
end
|
||||
end
|
||||
|
||||
class ThemeAdapter < Paperclip::StringioAdapter
|
||||
def cache_current_values
|
||||
@content_type = 'text/css'
|
||||
@original_filename = 'theme.css'
|
||||
@size = @target.size
|
||||
end
|
||||
|
||||
def extension_for(x)
|
||||
'css'
|
||||
end
|
||||
end
|
||||
|
||||
Paperclip.io_adapters.register ThemeAdapter do |target|
|
||||
ThemeIO === target
|
||||
end
|
||||
|
||||
# Here be monkey patches.
|
||||
|
|
Loading…
Reference in New Issue