2012-09-23 02:39:12 +00:00
|
|
|
class MainController < ApplicationController
|
2012-10-26 10:04:52 +00:00
|
|
|
include ItemsHelper
|
2012-09-23 02:39:12 +00:00
|
|
|
|
2012-10-29 17:52:29 +00:00
|
|
|
before_filter :require_user, only: [:invite]
|
|
|
|
|
2012-09-23 02:39:12 +00:00
|
|
|
respond_to :html, :js, :json
|
|
|
|
|
2012-10-28 18:37:46 +00:00
|
|
|
#homepage pick a random map and show it
|
2012-12-14 18:31:39 +00:00
|
|
|
def console
|
2012-10-28 18:37:46 +00:00
|
|
|
|
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)
|
2012-12-22 08:46:30 +00:00
|
|
|
@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
|
2012-10-28 18:37:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def metamap
|
2012-10-27 08:30:56 +00:00
|
|
|
@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
|
2012-10-08 05:45:44 +00:00
|
|
|
|
2012-10-27 08:30:56 +00:00
|
|
|
def allmaps
|
|
|
|
@current = current_user
|
|
|
|
@maps = Map.visibleToUser(@current, nil)
|
2012-10-08 05:45:44 +00:00
|
|
|
|
2012-10-26 10:04:52 +00:00
|
|
|
respond_to do |format|
|
|
|
|
format.html { respond_with(@maps) }
|
2012-10-19 21:26:46 +00:00
|
|
|
end
|
2012-10-08 05:45:44 +00:00
|
|
|
end
|
2012-10-28 18:37:46 +00:00
|
|
|
|
2012-10-29 17:52:29 +00:00
|
|
|
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
|