Class: Landable::Api::PageRevisionsController

Inherits:
Landable::ApiController show all
Defined in:
app/controllers/landable/api/page_revisions_controller.rb

Constant Summary

Constants inherited from Landable::ApiController

Landable::ApiController::API_MEDIA_REGEX

Instance Method Summary collapse

Methods inherited from Landable::ApiController

#api_media

Instance Method Details

#indexObject



8
9
10
11
# File 'app/controllers/landable/api/page_revisions_controller.rb', line 8

def index
  page = Page.find(params[:page_id])
  respond_with page.revisions.order(:ordinal).reverse
end

#revert_toObject



22
23
24
25
26
# File 'app/controllers/landable/api/page_revisions_controller.rb', line 22

def revert_to
  revision = PageRevision.find(params[:id])
  revision.page.revert_to! revision
  respond_with revision
end

#screenshotsObject



28
29
30
31
32
33
# File 'app/controllers/landable/api/page_revisions_controller.rb', line 28

def screenshots
  Landable::ScreenshotService.call PageRevision.find(params[:id])

  # "{}" is valid json, which jquery will accept as a successful response. "" is not.
  render json: {}, status: 202
end

#showObject



13
14
15
16
17
18
19
20
# File 'app/controllers/landable/api/page_revisions_controller.rb', line 13

def show
  revision = PageRevision.find(params[:id])

  respond_to do |format|
    format.json { respond_with revision }
    format.html { respond_with revision.snapshot, responder: Landable::PageRenderResponder }
  end
end