more fixes

This commit is contained in:
Devin Howard 2015-11-08 23:14:53 +08:00
parent 7136f46ec3
commit 1f82238362
3 changed files with 7 additions and 15 deletions

View file

@ -499,7 +499,7 @@ Metamaps.GlobalUI.Search = {
remote: { remote: {
url: '/search/topics', url: '/search/topics',
prepare: function(query, settings) { prepare: function(query, settings) {
settings.url += '?term=' + $('.sidebarSearchField').val(); settings.url += '?term=' + query;
if (Metamaps.Active.Mapper && $("#limitTopicsToMe").is(':checked')) { if (Metamaps.Active.Mapper && $("#limitTopicsToMe").is(':checked')) {
settings.url += "&user=" + Metamaps.Active.Mapper.id.toString(); settings.url += "&user=" + Metamaps.Active.Mapper.id.toString();
} }
@ -532,7 +532,7 @@ Metamaps.GlobalUI.Search = {
remote: { remote: {
url: '/search/maps', url: '/search/maps',
prepare: function(query, settings) { prepare: function(query, settings) {
settings.url += '?term=' + $('.sidebarSearchField').val(); settings.url += '?term=' + query;
if (Metamaps.Active.Mapper && $("#limitMapsToMe").is(':checked')) { if (Metamaps.Active.Mapper && $("#limitMapsToMe").is(':checked')) {
settings.url += "&user=" + Metamaps.Active.Mapper.id.toString(); settings.url += "&user=" + Metamaps.Active.Mapper.id.toString();
} }
@ -564,7 +564,7 @@ Metamaps.GlobalUI.Search = {
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: Bloodhound.tokenizers.whitespace, queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: { remote: {
url: '/search/maps?term=%QUERY', url: '/search/mappers?term=%QUERY',
wildcard: '%QUERY', wildcard: '%QUERY',
}, },
}), }),

View file

@ -26,8 +26,6 @@ class MainController < ApplicationController
# get /search/topics?term=SOMETERM # get /search/topics?term=SOMETERM
def searchtopics def searchtopics
@current = current_user
term = params[:term] term = params[:term]
user = params[:user] ? params[:user] : false user = params[:user] ? params[:user] : false
@ -122,15 +120,13 @@ class MainController < ApplicationController
end end
#read this next line as 'delete a topic if its private and you're either 1. logged out or 2. logged in but not the topic creator #read this next line as 'delete a topic if its private and you're either 1. logged out or 2. logged in but not the topic creator
@topics.to_a.delete_if {|t| t.permission == "private" && (!authenticated? || (authenticated? && @current.id != t.user_id)) } @topics.to_a.delete_if {|t| t.permission == "private" && (!authenticated? || (authenticated? && current_user.id != t.user_id)) }
render json: autocomplete_array_json(@topics) render json: autocomplete_array_json(@topics)
end end
# get /search/maps?term=SOMETERM # get /search/maps?term=SOMETERM
def searchmaps def searchmaps
@current = current_user
term = params[:term] term = params[:term]
user = params[:user] ? params[:user] : nil user = params[:user] ? params[:user] : nil
@ -158,15 +154,13 @@ class MainController < ApplicationController
end end
#read this next line as 'delete a map if its private and you're either 1. logged out or 2. logged in but not the map creator #read this next line as 'delete a map if its private and you're either 1. logged out or 2. logged in but not the map creator
@maps.to_a.delete_if {|m| m.permission == "private" && (!authenticated? || (authenticated? && @current.id != m.user_id)) } @maps.to_a.delete_if {|m| m.permission == "private" && (!authenticated? || (authenticated? && current_user.id != m.user_id)) }
render json: autocomplete_map_array_json(@maps) render json: autocomplete_map_array_json(@maps)
end end
# get /search/mappers?term=SOMETERM # get /search/mappers?term=SOMETERM
def searchmappers def searchmappers
@current = current_user
term = params[:term] term = params[:term]
if term && !term.empty? && term.downcase[0..3] != "map:" && term.downcase[0..5] != "topic:" && term.downcase != "mapper:" if term && !term.empty? && term.downcase[0..3] != "map:" && term.downcase[0..5] != "topic:" && term.downcase != "mapper:"
@ -182,8 +176,6 @@ class MainController < ApplicationController
# get /search/synapses?term=SOMETERM OR # get /search/synapses?term=SOMETERM OR
# get /search/synapses?topic1id=SOMEID&topic2id=SOMEID # get /search/synapses?topic1id=SOMEID&topic2id=SOMEID
def searchsynapses def searchsynapses
@current = current_user
term = params[:term] term = params[:term]
topic1id = params[:topic1id] topic1id = params[:topic1id]
topic2id = params[:topic2id] topic2id = params[:topic2id]
@ -214,7 +206,7 @@ class MainController < ApplicationController
#permissions #permissions
@synapses.delete_if {|s| s.permission == "private" && !authenticated? } @synapses.delete_if {|s| s.permission == "private" && !authenticated? }
@synapses.delete_if {|s| s.permission == "private" && authenticated? && @current.id != s.user_id } @synapses.delete_if {|s| s.permission == "private" && authenticated? && current_user.id != s.user_id }
else else
@synapses = [] @synapses = []
end end

View file

@ -16,7 +16,7 @@ module MapsHelper
map['rtype'] = "map" map['rtype'] = "map"
contributorTip = '' contributorTip = ''
firstContributorImage = asset_path('user.png') firstContributorImage = 'https://s3.amazonaws.com/metamaps-assets/site/user.png'
if m.contributors.count > 0 if m.contributors.count > 0
firstContributorImage = m.contributors[0].image.url(:thirtytwo) firstContributorImage = m.contributors[0].image.url(:thirtytwo)
m.contributors.each_with_index do |c, index| m.contributors.each_with_index do |c, index|