Class: TopicsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/topics_controller.rb

Instance Method Summary collapse

Instance Method Details

#index ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/topics_controller.rb', line 8

def index
  params[:gbapp] = 'gbzh' if params[:gbapp] == 'default' #FIXME
  @app = Gbapplication.find_by_name(params[:gbapp]) if params[:gbapp]

  respond_to do |format|
    format.json do
      render :json => Topic.list(@app, current_ability, host_zone(request.host), wms_host)
    end
  end
end

#legend ⇒ Object



41
42
43
44
45
46
47
# File 'app/controllers/topics_controller.rb', line 41

def legend
  #TODO: -> show?mode=legend
  @topic = Topic.includes(:layers).where(:name => params[:id]).first
  @topic ||= Topic.includes(:layers).find(params[:id])
  authorize! :show, @topic
  render :layout => false
end

#query ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/topics_controller.rb', line 29

def query
  @query_topics = ActiveSupport::JSON.decode(params[:infoQuery])['queryTopics']
  #e.g. [{"layers"=>"lk25,grenzen,gemeindegrenzen,seen,wald,haltestellen", "divCls"=>"legmain", "level"=>"main", "topic"=>"BASISKARTEZH"}, {"layers"=>"", "divCls"=>"legover", "level"=>"over", "topic"=>"AVParzOverlayZH"}]
  @query_topics.each do |query_topic|
    topic = Topic.where(:name => query_topic['topic']).first
    authorize! :show, topic
    query_topic['topicobj'] = topic
    query_topic['results'] = topic.query(current_ability, query_topic, params['bbox'])
  end
  render :layout => false
end

#show ⇒ Object

TODO: obsolete?



19
20
21
22
23
24
25
26
27
# File 'app/controllers/topics_controller.rb', line 19

def show #TODO: obsolete?
  @topic = Topic.includes(:layers).find(params[:id])

  respond_to do |format|
    format.json do
      render :json => @topic.to_json(:include => :layers)
    end
  end
end