Class: Landable::Api::ThemesController
Constant Summary
Landable::ApiController::API_MEDIA_REGEX
Instance Method Summary
collapse
#api_media
Instance Method Details
#create ⇒ Object
10
11
12
13
14
15
|
# File 'app/controllers/landable/api/themes_controller.rb', line 10
def create
theme = Theme.new(theme_params)
theme.save!
respond_with theme, status: :created, location: theme_url(theme)
end
|
#destroy ⇒ Object
17
18
19
20
21
|
# File 'app/controllers/landable/api/themes_controller.rb', line 17
def destroy
@theme.try(:deactivate)
respond_with @theme
end
|
#index ⇒ Object
23
24
25
|
# File 'app/controllers/landable/api/themes_controller.rb', line 23
def index
respond_with Theme.all
end
|
#preview ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'app/controllers/landable/api/themes_controller.rb', line 44
def preview
theme = Theme.new(theme_params)
page = Page.example(theme: theme)
params[:theme][:asset_ids].try(:each) do |asset_id|
theme.attachments.add Asset.find(asset_id)
end
content = render_to_string(
text: RenderService.call(page),
layout: page.theme.file || false
)
respond_to do |format|
format.html do
render text: content, layout: false, content_type: 'text/html'
end
format.json do
render json: {theme: {preview: content}}
end
end
end
|
#reactivate ⇒ Object
27
28
29
30
31
|
# File 'app/controllers/landable/api/themes_controller.rb', line 27
def reactivate
@theme.try(:reactivate)
respond_with @theme
end
|
#show ⇒ Object
33
34
35
|
# File 'app/controllers/landable/api/themes_controller.rb', line 33
def show
respond_with @theme
end
|
#update ⇒ Object
37
38
39
40
41
|
# File 'app/controllers/landable/api/themes_controller.rb', line 37
def update
@theme.update_attributes!(theme_params)
respond_with @theme
end
|