Sha256: 73e0183cdf942b5f9abd5b0fe638d29073d13df429943a3ccc0a8b3e77d3035d

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require_dependency 'landable/api_controller'

module Landable
  module Api
    class PageRevisionsController < ApiController
      skip_before_filter :require_author!, if: proc { |c| c.action_name == 'show' && c.request.format == :html }

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

      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

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

      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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
landable-1.14.0 app/controllers/landable/api/page_revisions_controller.rb
landable-1.13.2 app/controllers/landable/api/page_revisions_controller.rb