diff --git a/app/models/theme.rb b/app/models/theme.rb index 3047bf41..0995f32a 100644 --- a/app/models/theme.rb +++ b/app/models/theme.rb @@ -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 diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index b117453c..394d08b3 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -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? diff --git a/config/late_initializers/costanza.rb b/config/late_initializers/costanza.rb index d2aba2c6..48e13832 100644 --- a/config/late_initializers/costanza.rb +++ b/config/late_initializers/costanza.rb @@ -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.