2012-09-22 22:39:12 -04:00
|
|
|
class MainController < ApplicationController
|
2012-10-26 06:04:52 -04:00
|
|
|
include ItemsHelper
|
2012-09-22 22:39:12 -04:00
|
|
|
|
2012-10-29 13:52:29 -04:00
|
|
|
before_filter :require_user, only: [:invite]
|
|
|
|
|
2012-09-22 22:39:12 -04:00
|
|
|
respond_to :html, :js, :json
|
|
|
|
|
2012-10-28 14:37:46 -04:00
|
|
|
#homepage pick a random map and show it
|
2012-12-14 13:31:39 -05:00
|
|
|
def console
|
2012-10-28 14:37:46 -04:00
|
|
|
|
2012-12-14 13:31:39 -05:00
|
|
|
@current = current_user
|
|
|
|
|
|
|
|
if authenticated?
|
2012-12-22 03:32:12 -05:00
|
|
|
@synapses = Synapse.visibleToUser(@current, nil)
|
|
|
|
@items = synapses_as_json(@current, @synapses).html_safe
|
2012-12-14 13:31:39 -05: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
|
2012-10-28 14:37:46 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def metamap
|
2012-10-27 04:30:56 -04:00
|
|
|
@current = current_user
|
|
|
|
|
|
|
|
@item = Item.visibleToUser(@current, nil).first
|
|
|
|
@alljson = all_as_json(@current).html_safe
|
2012-10-19 00:06:16 -04:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { respond_with(@item) }
|
|
|
|
format.json { respond_with(@alljson) }
|
|
|
|
end
|
2012-09-22 22:39:12 -04:00
|
|
|
end
|
2012-10-08 01:45:44 -04:00
|
|
|
|
2012-10-27 04:30:56 -04:00
|
|
|
def allmaps
|
|
|
|
@current = current_user
|
|
|
|
@maps = Map.visibleToUser(@current, nil)
|
2012-10-08 01:45:44 -04:00
|
|
|
|
2012-10-26 06:04:52 -04:00
|
|
|
respond_to do |format|
|
|
|
|
format.html { respond_with(@maps) }
|
2012-10-19 17:26:46 -04:00
|
|
|
end
|
2012-10-08 01:45:44 -04:00
|
|
|
end
|
2012-10-28 14:37:46 -04:00
|
|
|
|
2012-10-29 13:52:29 -04:00
|
|
|
def invite
|
|
|
|
@user = current_user
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { respond_with(@user) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-09-22 22:39:12 -04:00
|
|
|
|
|
|
|
end
|