Class: Comable::Admin::ThemesController
Instance Method Summary
collapse
#current_ability, #respond_to_export_with
Instance Method Details
#create ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 23
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
44
45
46
47
48
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 44
def destroy
@theme.destroy
@theme.dir.rmtree if @theme.dir.exist?
redirect_to comable.admin_themes_path, notice: Comable.t('successful')
end
|
#edit ⇒ Object
32
33
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 32
def edit
end
|
#index ⇒ Object
8
9
10
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 8
def index
@themes = @themes.by_newest
end
|
#new ⇒ Object
16
17
18
19
20
21
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 16
def new
@theme.attributes = {
version: @theme.default_version,
author: current_comable_user.bill_full_name || current_comable_user.email
}
end
|
#show ⇒ Object
12
13
14
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 12
def show
render :edit
end
|
#show_file ⇒ Object
54
55
56
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 54
def show_file
@code = filepath.read if filepath.try(:file?)
end
|
#tree ⇒ Object
50
51
52
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 50
def tree
render :show_file
end
|
#update ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 35
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
58
59
60
61
62
63
64
65
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 58
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
67
68
69
70
|
# File 'app/controllers/comable/admin/themes_controller.rb', line 67
def use
current_store.update_attributes!(theme: @theme)
redirect_to :back, notice: Comable.t('successful')
end
|