Sha256: 80e8008b320f4826a1205e15a945223fdecaa8b1c37125b69751bddf1e5c9fe6

Contents?: true

Size: 1.18 KB

Versions: 24

Compression:

Stored size: 1.18 KB

Contents

module RailsConnector

  class TimeMachineController < ApplicationController

    protect_from_forgery :except => :set_preview_time

    before_filter :only_available_in_editor_mode

    def index
      @language = params[:language] || 'de'
      @preview_time = session[:preview_time] || Time.now
    end

    # Set the preview time to the Time as specified by the parameter <tt>:preview_time</tt>.
    def set_preview_time
      if preview_time = params[:preview_time]
        pt = Time.from_iso(preview_time)
        pt = nil if pt <= Time.now
        handle_request pt
      end
    end

    # Resets the preview time, so <tt>Time::now</tt> will be used as preview time afterwards.
    def reset_preview_time
      handle_request nil
    end

  private

    def handle_request(preview_time)
      session[:preview_time] = preview_time
      if request.xhr?
        render :js => "window.location.reload();"
      else
        render :nothing => true
      end
    end

    def only_available_in_editor_mode
      unless Configuration.editor_interface_enabled?
        render :template => 'errors/403_forbidden', :status => 403, :content_type => Mime::HTML
        return false
      end
    end

  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
infopark_rails_connector-6.9.1.3.22208381 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.9.0.3.197272233 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.3.174.51542603 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.3.115.227021242 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.3.73.75172665 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.3.2.153416031 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.3.67.110847540 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.3.1.23895778 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.2.36.82613853 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.2.7.128454143 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.1.26.236500544 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.1 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.539.93842523 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.529.114081979 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.518.30999728 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.515.34928522 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.498.46559598 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.480.261594408 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.444.171626367 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.406.131718077 app/controllers/rails_connector/time_machine_controller.rb