Class: Landable::Api::PagesController
Constant Summary
Landable::ApiController::API_MEDIA_REGEX
Instance Method Summary
collapse
#api_media
Instance Method Details
#create ⇒ Object
10
11
12
13
14
15
16
|
# File 'app/controllers/landable/api/pages_controller.rb', line 10
def create
page = Page.new page_params
page.updated_by_author = current_author
page.save!
respond_with page, status: :created, location: page_url(page)
end
|
#destroy ⇒ Object
18
19
20
21
22
23
|
# File 'app/controllers/landable/api/pages_controller.rb', line 18
def destroy
@page.updated_by_author = current_author
@page.try(:deactivate)
respond_with @page
end
|
#index ⇒ Object
25
26
27
28
29
|
# File 'app/controllers/landable/api/pages_controller.rb', line 25
def index
search = Landable::PageSearchEngine.new search_params.merge(ids: params[:ids]), limit: 100
respond_with search.results, meta: search.meta
end
|
#preview ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/controllers/landable/api/pages_controller.rb', line 55
def preview
page = Page.where(page_id: page_params[:id]).first_or_initialize
page.attributes = page_params
content = generate_preview_for(page) if page.valid?
respond_to do |format|
format.json do
render json: {
page: {
preview: content,
errors: page.errors
}
}
end
end
end
|
#publish ⇒ Object
49
50
51
52
53
|
# File 'app/controllers/landable/api/pages_controller.rb', line 49
def publish
@page.publish! author_id: current_author.id, notes: params[:notes], is_minor: !params[:is_minor].nil?
respond_with @page
end
|
#reactivate ⇒ Object
31
32
33
34
35
|
# File 'app/controllers/landable/api/pages_controller.rb', line 31
def reactivate
@page.try(:reactivate)
respond_with @page
end
|
#screenshots ⇒ Object
74
75
76
77
78
79
|
# File 'app/controllers/landable/api/pages_controller.rb', line 74
def screenshots
Landable::ScreenshotService.call Page.find(params[:id])
render json: {}, status: 202
end
|
#show ⇒ Object
37
38
39
|
# File 'app/controllers/landable/api/pages_controller.rb', line 37
def show
respond_with @page
end
|
#update ⇒ Object
41
42
43
44
45
46
|
# File 'app/controllers/landable/api/pages_controller.rb', line 41
def update
@page.updated_by_author = current_author
@page.update_attributes!(page_params)
respond_with @page
end
|