metamaps--metamaps/app/controllers/main_controller.rb

66 lines
1.4 KiB
Ruby
Raw Normal View History

2012-09-23 02:39:12 +00:00
class MainController < ApplicationController
include ItemsHelper
2012-09-23 02:39:12 +00:00
before_filter :require_user, only: [:invite]
2012-09-23 02:39:12 +00:00
respond_to :html, :js, :json
#homepage pick a random map and show it
2012-12-14 18:31:39 +00:00
def console
2012-12-14 18:31:39 +00:00
@current = current_user
if authenticated?
2012-12-22 08:32:12 +00:00
@synapses = Synapse.visibleToUser(@current, nil)
@synapses = @synapses.slice(0, 50)
2012-12-22 08:32:12 +00:00
@items = synapses_as_json(@current, @synapses).html_safe
2012-12-14 18:31:39 +00:00
respond_to do |format|
format.html { respond_with(@current) }
format.json { respond_with(@items) }
end
else
@maps = Map.visibleToUser(@current, nil)
@map = @maps.sample
@mapjson = @map.self_as_json(@current).html_safe if @map
respond_to do |format|
format.html { respond_with(@map) }
format.json { respond_with(@mapjson) }
end
end
end
def metamap
@current = current_user
@item = Item.visibleToUser(@current, nil).first
@alljson = all_as_json(@current).html_safe
2012-10-19 04:06:16 +00:00
respond_to do |format|
format.html { respond_with(@item) }
format.json { respond_with(@alljson) }
end
2012-09-23 02:39:12 +00:00
end
def allmaps
@current = current_user
@maps = Map.visibleToUser(@current, nil)
respond_to do |format|
format.html { respond_with(@maps) }
end
end
def invite
@user = current_user
respond_to do |format|
format.html { respond_with(@user) }
end
end
2012-09-23 02:39:12 +00:00
end