Class: Landable::Api::TemplatesController
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/templates_controller.rb', line 10
def create
template = Template.new(template_params)
template.save!
respond_with template, status: :created, location: template_url(template)
end
|
#destroy ⇒ Object
17
18
19
20
21
22
|
# File 'app/controllers/landable/api/templates_controller.rb', line 17
def destroy
@template.temp_author = current_author
@template.try(:deactivate)
respond_with @template
end
|
#index ⇒ Object
24
25
26
|
# File 'app/controllers/landable/api/templates_controller.rb', line 24
def index
respond_with Template.all
end
|
#preview ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'app/controllers/landable/api/templates_controller.rb', line 52
def preview
template = Template.new(template_params)
theme = Theme.most_used_on_pages
page = Page.example(theme: theme, body: template.body)
content = generate_preview_for(page)
respond_to do |format|
format.html do
render text: content, layout: false, content_type: 'text/html'
end
format.json do
render json: { template: { preview: content } }
end
end
end
|
#publish ⇒ Object
39
40
41
42
43
|
# File 'app/controllers/landable/api/templates_controller.rb', line 39
def publish
@template.publish! author_id: current_author.id, notes: params[:notes], is_minor: !!params[:is_minor]
respond_with @template
end
|
#reactivate ⇒ Object
45
46
47
48
49
|
# File 'app/controllers/landable/api/templates_controller.rb', line 45
def reactivate
@template.try(:reactivate)
respond_with @template
end
|
#show ⇒ Object
28
29
30
|
# File 'app/controllers/landable/api/templates_controller.rb', line 28
def show
respond_with @template
end
|
#update ⇒ Object
32
33
34
35
36
|
# File 'app/controllers/landable/api/templates_controller.rb', line 32
def update
@template.update_attributes!(template_params)
respond_with @template
end
|