Class: Comable::Admin::ThemesController
Instance Method Summary
collapse
#current_ability, #respond_to_export_with
Instance Method Details
#create ⇒ Object
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
|
#destroy ⇒ Object
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
|
#edit ⇒ Object
31
32
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 31
def edit
end
|
#index ⇒ Object
8
9
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 8
def index
end
|
#new ⇒ Object
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
|
#show ⇒ Object
11
12
13
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 11
def show
render :edit
end
|
#show_file ⇒ Object
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
|
#tree ⇒ Object
49
50
51
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 49
def tree
render :show_file
end
|
#update ⇒ Object
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_file ⇒ Object
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
|
#use ⇒ Object
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
|