Class: Comable::Admin::ThemesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/comable/admin/themes_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability, #respond_to_export_with

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
# File 'app/controllers/comable/admin/themes_controller.rb', line 22

def create
  if @theme.save
    redirect_to comable.admin_theme_path(@theme), notice: Comable.t('successful')
  else
    flash.now[:alert] = Comable.t('failure')
    render :new
  end
end

#destroyObject



43
44
45
46
47
# File 'app/controllers/comable/admin/themes_controller.rb', line 43

def destroy
  @theme.destroy
  FileUtils.rm_rf(theme_dir)
  redirect_to comable.admin_themes_path, notice: Comable.t('successful')
end

#editObject



31
32
# File 'app/controllers/comable/admin/themes_controller.rb', line 31

def edit
end

#indexObject



8
9
# File 'app/controllers/comable/admin/themes_controller.rb', line 8

def index
end

#newObject



15
16
17
18
19
20
# File 'app/controllers/comable/admin/themes_controller.rb', line 15

def new
  @theme.attributes = {
    version: @theme.default_version,
    author: current_comable_user.bill_full_name || current_comable_user.email
  }
end

#showObject



11
12
13
# File 'app/controllers/comable/admin/themes_controller.rb', line 11

def show
  render :edit
end

#show_fileObject



53
54
55
# File 'app/controllers/comable/admin/themes_controller.rb', line 53

def show_file
  @code = File.read(filepath) if filepath && File.exist?(filepath)
end

#treeObject



49
50
51
# File 'app/controllers/comable/admin/themes_controller.rb', line 49

def tree
  render :show_file
end

#updateObject



34
35
36
37
38
39
40
41
# File 'app/controllers/comable/admin/themes_controller.rb', line 34

def update
  if @theme.update_attributes(theme_params)
    redirect_to comable.admin_theme_path(@theme), notice: Comable.t('successful')
  else
    flash.now[:alert] = Comable.t('failure')
    render :edit
  end
end

#update_fileObject



57
58
59
60
61
62
63
64
# File 'app/controllers/comable/admin/themes_controller.rb', line 57

def update_file
  save_file
  redirect_to comable.file_admin_theme_path(@theme, path: params[:path]), notice: Comable.t('successful')
rescue => e
  @code = params[:code]
  flash.now[:alert] = e.message
  render :show_file
end

#useObject



66
67
68
69
# File 'app/controllers/comable/admin/themes_controller.rb', line 66

def use
  current_store.update_attributes!(theme: @theme)
  redirect_to :back, notice: Comable.t('successful')
end