Sha256: c749f88a89476b6f409eef01a19310e9f22c4c17f110fca568de546891945dc6

Contents?: true

Size: 1.19 KB

Versions: 21

Compression:

Stored size: 1.19 KB

Contents

module RailsConnector

  class TimeMachineController < ApplicationController #:nodoc:

    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

21 entries across 21 versions & 1 rubygems

Version Path
infopark_rails_connector-6.8.0.210.ed204b0 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.110.6570b45 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.72.d18d096 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.23.da7f96b app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.16.def5e85 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.15.a24f5ff app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.891.647580e app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.889.d503e42 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.883.f5f063b app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.884.4bd86e6 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.869.9609b39 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.856.8c0fec5 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.809.bdfa8c3 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.785.05d4af9 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.744.99f67fc app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.720.44fbabd app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.713.e5c3150 app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.681.7c84f4a app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.663.ceecdee app/controllers/rails_connector/time_machine_controller.rb
infopark_rails_connector-6.8.0.beta.200.650.7c93155 app/controllers/rails_connector/time_machine_controller.rb