Class: Refinery::Themes::Admin::ThemesController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/refinery/themes/admin/themes_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/refinery/themes/admin/themes_controller.rb', line 41

def create
  zipf = params[:zip_file]

  directory = "/tmp/uploads"
  `rm -rf "#{directory}"`
  `mkdir "#{directory}"`

  path = File.join(directory, zipf.original_filename)
  File.open(path, "wb") { |f| f.write(zipf.read) }

  FileManager.unzip_file(path)
  `rm #{path}`

  redirect_to themes_admin_root_url, :notice =>"A new theme was successfully uploaded and installed!"
end

#indexObject



6
7
8
# File 'app/controllers/refinery/themes/admin/themes_controller.rb', line 6

def index
  @themes = Refinery::Themes::Theme.all
end

#resetObject



18
19
20
21
22
# File 'app/controllers/refinery/themes/admin/themes_controller.rb', line 18

def reset
  FileUtils.rm_rf(Rails.root.join('themes', 'default')) if File.exist?(Rails.root.join('themes', 'default'))
  FileManager.unzip_file(File.join(SpreefineryThemes::Engine.root, "theme_template", "default.zip"))
  redirect_to themes_admin_root_url, :notice =>"The default theme successfully reset!"
end

#select_themeObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/refinery/themes/admin/themes_controller.rb', line 24

def select_theme
  ::Refinery::Setting.set(:current_theme, params[:key])
  @themes = Refinery::Themes::Theme.all
  FileUtils.rm_rf(Rails.root.join('themes/current'))
  FileUtils.ln_sf(Refinery::Themes::Theme.theme_path, Rails.root.join('themes/current'))

  ::Refinery::Page.expire_page_caching
  #Rails.cache.clear


  # TODO remove this hack for update current layout file.
  file = File.read(Rails.root.join('themes/current/views/layouts/site.liquid'))
  File.open(Rails.root.join('themes/current/views/layouts/site.liquid'), 'w+b'){|f| f.write(file)}

  redirect_to themes_admin_root_url
end

#settingsObject



12
# File 'app/controllers/refinery/themes/admin/themes_controller.rb', line 12

def settings; end

#updateObject



14
15
16
# File 'app/controllers/refinery/themes/admin/themes_controller.rb', line 14

def update

end

#uploadObject



10
# File 'app/controllers/refinery/themes/admin/themes_controller.rb', line 10

def upload; end