Sha256: f3c334ea12b94d5f00c374ed2b8214680030a55247b70ebc58b1206031f56447

Contents?: true

Size: 1.38 KB

Versions: 9

Compression:

Stored size: 1.38 KB

Contents

require_dependency "ishapi/application_controller"

module Ishapi
  class SitesController < ApplicationController

    before_action :check_profile_optionally, only: %i| show |

    def index
      authorize! :index, ::Site
      @sites = ::Site.all
    end

    def show
      if params[:domain].include?(".json")
        domain = params[:domain][0...-5]
      else
        domain = params[:domain]
      end
      @site = ::Site.find_by(domain: domain, lang: :en)
      authorize! :show, @site

      if @site.is_private
        if !params[:accessToken]
          render :json => { :status => :unauthorized}, :status => :unauthorized
          return
        end
        access_token = params[:accessToken]
        @graph = Koala::Facebook::API.new( access_token, ::FB[@site.domain][:secret] )
        @profile = @graph.get_object "me", :fields => 'email'
        if @site.private_user_emails.include?( @profile['email'] )
          ;
        else
          render :json => { :status => :unauthorized}, :status => :unauthorized
          render :status => :unauthorized
        end
      end

      @galleries    = @site.galleries.limit( 10 )
      @newsitems    = @site.newsitems.limit( @site.newsitems_per_page )
      @reports      = @site.reports.limit( 10 )
      @langs        = ::Site.where( :domain => domain ).map( &:lang )
      @feature_tags = @site.tags.where( :is_feature => true )

    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ishapi-0.1.8.142 app/controllers/ishapi/sites_controller.rb
ishapi-0.1.8.141 app/controllers/ishapi/sites_controller.rb
ishapi-0.1.8.140 app/controllers/ishapi/sites_controller.rb
ishapi-0.1.8.139 app/controllers/ishapi/sites_controller.rb
ishapi-0.1.8.138 app/controllers/ishapi/sites_controller.rb
ishapi-0.1.8.137 app/controllers/ishapi/sites_controller.rb
ishapi-0.1.8.136 app/controllers/ishapi/sites_controller.rb
ishapi-0.1.8.135 app/controllers/ishapi/sites_controller.rb
ishapi-0.1.8.134 app/controllers/ishapi/sites_controller.rb