ISHYGDDT
This commit is contained in:
parent
cc8e2448eb
commit
a7c3acea76
|
@ -1,7 +1,7 @@
|
||||||
class UserController < ApplicationController
|
class UserController < ApplicationController
|
||||||
include ThemeHelper
|
include ThemeHelper
|
||||||
|
|
||||||
before_filter :authenticate_user!, only: %w(edit update edit_privacy update_privacy data)
|
before_filter :authenticate_user!, only: %w(edit update edit_privacy update_privacy edit_theme update_theme preview_theme data)
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
|
||||||
|
|
|
@ -1,14 +1,4 @@
|
||||||
module ThemeHelper
|
module ThemeHelper
|
||||||
class ThemeIO < StringIO
|
|
||||||
def content_type
|
|
||||||
'text/css'
|
|
||||||
end
|
|
||||||
|
|
||||||
def original_filename
|
|
||||||
'theme.css'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def render_theme_with_context(context = {})
|
def render_theme_with_context(context = {})
|
||||||
klass = Class.new do
|
klass = Class.new do
|
||||||
def initialize(hash = {})
|
def initialize(hash = {})
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
# I seriously hope you guys don't do this.
|
||||||
|
|
||||||
|
class Paperclip::FileCommandContentTypeDetector
|
||||||
|
alias stupid_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'
|
||||||
|
'text/css'
|
||||||
|
else
|
||||||
|
default
|
||||||
|
end
|
||||||
|
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