ref: master
app/controllers/my_profile/profile_themes_controller.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
class ProfileThemesController < ThemesController needs_profile protect 'edit_appearance', :profile no_design_blocks def target @target = profile end def new if !request.xhr? id = params[:name] ? params[:name].to_slug : 'my-theme' t = Theme.new id, :name => params[:name], :owner => profile, :public => false t.save redirect_to :action => 'index' else render :action => 'new', :layout => false end end def private_edit @theme = Theme.find params[:id] if params[:commit] @theme = @theme.private_copy profile @theme.style = params[:theme][:style] @theme.save profile.theme = @theme.id profile.save redirect_to :action => :index else render :layout => false end end def edit @theme = profile.find_theme(params[:id]) @css_files = @theme.css_files end def add_css @theme = profile.find_theme(params[:id]) if request.xhr? render :action => 'add_css', :layout => false else @theme.add_css(params[:css]) redirect_to :action => 'edit', :id => @theme.id end end def css_editor @theme = profile.find_theme(params[:id]) @css = params[:css] @code = @theme.read_css(@css) render :action => 'css_editor', :layout => false end post_only :update_css def update_css @theme = profile.find_theme(params[:id]) @theme.update_css(params[:css], params[:csscode]) redirect_to :action => 'edit', :id => @theme.id end def add_image @theme = Theme.find params[:id] if request.xhr? render :action => 'add_image', :layout => false else @theme.add_image(params[:image].original_filename, params[:image].read) redirect_to :action => 'edit', :id => @theme.id end end def start_test session[:user_theme] = params[:id] redirect_to :controller => 'content_viewer', :profile => profile.identifier, :action => 'view_page' end def stop_test session[:user_theme] = nil redirect_to :action => 'index' end end |