Sha256: 0449a4841f57bb0f25df732cd9b877614c06f61e0add7328c9a8a6443fb633dd
Contents?: true
Size: 1.85 KB
Versions: 6
Compression:
Stored size: 1.85 KB
Contents
class Admin::ThemesController < Admin::BaseController def index @themes = Theme.find_all @themes.each do |theme| theme.description_html = TextFilter.filter_text(this_blog, theme.description, nil, [:markdown,:smartypants]) end @active = this_blog.current_theme end def preview send_file "#{Theme.themes_root}/#{params[:theme]}/preview.png", :type => 'image/png', :disposition => 'inline', :stream => false end def switchto this_blog.theme = params[:theme] this_blog.save redirect_to :action => 'index' zap_theme_caches end def editor case params[:type].to_s when "stylesheet" path = this_blog.current_theme.path + "/stylesheets/" if params[:file] =~ /css$/ filename = params[:file] else flash[:error] = "You are not authorized to open this file" return end when "layout" path = this_blog.current_theme.path + "/layouts/" if params[:file] =~ /rhtml$|erb$/ filename = params[:file] else flash[:error] = "You are not authorized to open this file" return end end if path and filename if File.exists? path + filename if File.writable? path + filename case request.method when :post theme = File.new(path + filename, "r+") theme.write(params[:theme_body]) theme.close flash[:notice] = "File saved successfully" zap_theme_caches end else flash[:notice] = "Unable to write file" end @file = "" file = File.readlines(path + filename, "r") file.each do |line| @file << line end end end end protected def zap_theme_caches FileUtils.rm_rf(%w{stylesheets javascript images}.collect{|v| page_cache_directory + "/#{v}/theme"}) end end
Version data entries
6 entries across 6 versions & 1 rubygems