a better solution than renaming all the paths
This commit is contained in:
parent
562da81a0f
commit
da026a3003
28 changed files with 54 additions and 54 deletions
|
@ -1,13 +1,12 @@
|
||||||
import request from 'request'
|
const request = require('request')
|
||||||
|
|
||||||
function apiProxyMiddleware (req, res, next) {
|
function apiProxyMiddleware (req, res, next) {
|
||||||
if (true) { // is application/json
|
if (!req.xhr) {
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
console.log(req.get('Content-Type'))
|
|
||||||
const method = req.method.toLowerCase()
|
const method = req.method.toLowerCase()
|
||||||
req.pipe(
|
req.pipe(
|
||||||
request[method](url, {
|
request[method](process.env.API + req.originalUrl, {
|
||||||
headers: {
|
headers: {
|
||||||
...req.headers,
|
...req.headers,
|
||||||
host: process.env.API
|
host: process.env.API
|
||||||
|
@ -18,4 +17,4 @@ function apiProxyMiddleware (req, res, next) {
|
||||||
.pipe(res)
|
.pipe(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default apiProxyMiddleware
|
module.exports = apiProxyMiddleware
|
|
@ -71,6 +71,7 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var Metamaps = {
|
var Metamaps = {
|
||||||
ServerData: {
|
ServerData: {
|
||||||
|
RAILS_ENV: 'development',
|
||||||
ActiveMapper: {
|
ActiveMapper: {
|
||||||
id: 10,
|
id: 10,
|
||||||
name: 'Connor',
|
name: 'Connor',
|
||||||
|
|
|
@ -67,7 +67,7 @@ const Cable = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/main/synapses/' + event.synapse.id + '.json',
|
url: '/synapses/' + event.synapse.id + '.json',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
DataModel.Synapses.add(response)
|
DataModel.Synapses.add(response)
|
||||||
synapse = DataModel.Synapses.get(response.id)
|
synapse = DataModel.Synapses.get(response.id)
|
||||||
|
@ -77,7 +77,7 @@ const Cable = {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/main/mappings/' + event.mapping_id + '.json',
|
url: '/mappings/' + event.mapping_id + '.json',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
DataModel.Mappings.add(response)
|
DataModel.Mappings.add(response)
|
||||||
mapping = DataModel.Mappings.get(response.id)
|
mapping = DataModel.Mappings.get(response.id)
|
||||||
|
@ -149,7 +149,7 @@ const Cable = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/main/topics/' + event.topic.id + '.json',
|
url: '/topics/' + event.topic.id + '.json',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
DataModel.Topics.add(response)
|
DataModel.Topics.add(response)
|
||||||
topic = DataModel.Topics.get(response.id)
|
topic = DataModel.Topics.get(response.id)
|
||||||
|
@ -159,7 +159,7 @@ const Cable = {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/main/mappings/' + event.mapping_id + '.json',
|
url: '/mappings/' + event.mapping_id + '.json',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
DataModel.Mappings.add(response)
|
DataModel.Mappings.add(response)
|
||||||
mapping = DataModel.Mappings.get(response.id)
|
mapping = DataModel.Mappings.get(response.id)
|
||||||
|
|
|
@ -147,7 +147,7 @@ const Create = {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
url: '/main/user/updatemetacodes',
|
url: '/user/updatemetacodes',
|
||||||
data: mdata,
|
data: mdata,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
console.log('selected metacodes saved')
|
console.log('selected metacodes saved')
|
||||||
|
@ -206,7 +206,7 @@ const Create = {
|
||||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
||||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
remote: {
|
remote: {
|
||||||
url: '/main/topics/autocomplete_topic?term=%QUERY',
|
url: '/topics/autocomplete_topic?term=%QUERY',
|
||||||
wildcard: '%QUERY'
|
wildcard: '%QUERY'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -296,7 +296,7 @@ const Create = {
|
||||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
||||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
remote: {
|
remote: {
|
||||||
url: '/main/search/synapses?term=%QUERY',
|
url: '/search/synapses?term=%QUERY',
|
||||||
wildcard: '%QUERY'
|
wildcard: '%QUERY'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -304,7 +304,7 @@ const Create = {
|
||||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
||||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
remote: {
|
remote: {
|
||||||
url: '/main/search/synapses?topic1id=%TOPIC1&topic2id=%TOPIC2',
|
url: '/search/synapses?topic1id=%TOPIC1&topic2id=%TOPIC2',
|
||||||
prepare: function(query, settings) {
|
prepare: function(query, settings) {
|
||||||
var self = Create.newSynapse
|
var self = Create.newSynapse
|
||||||
if (Selected.Nodes.length < 2 && self.topic1id && self.topic2id) {
|
if (Selected.Nodes.length < 2 && self.topic1id && self.topic2id) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import InfoBox from '../Map/InfoBox'
|
||||||
import Mapper from '../Mapper'
|
import Mapper from '../Mapper'
|
||||||
|
|
||||||
const Map = Backbone.Model.extend({
|
const Map = Backbone.Model.extend({
|
||||||
urlRoot: '/main/maps',
|
urlRoot: '/maps',
|
||||||
blacklist: ['created_at', 'updated_at', 'created_at_clean', 'updated_at_clean', 'user_name', 'contributor_count', 'topic_count', 'synapse_count', 'topics', 'synapses', 'mappings', 'mappers'],
|
blacklist: ['created_at', 'updated_at', 'created_at_clean', 'updated_at_clean', 'user_name', 'contributor_count', 'topic_count', 'synapse_count', 'topics', 'synapses', 'mappings', 'mappers'],
|
||||||
toJSON: function(options) {
|
toJSON: function(options) {
|
||||||
return _.omit(this.attributes, this.blacklist)
|
return _.omit(this.attributes, this.blacklist)
|
||||||
|
|
|
@ -4,7 +4,7 @@ try { Backbone.$ = window.$ } catch (err) {}
|
||||||
import outdent from 'outdent'
|
import outdent from 'outdent'
|
||||||
|
|
||||||
const Mapper = Backbone.Model.extend({
|
const Mapper = Backbone.Model.extend({
|
||||||
urlRoot: '/main/users',
|
urlRoot: '/users',
|
||||||
blacklist: ['created_at', 'updated_at', 'follows'],
|
blacklist: ['created_at', 'updated_at', 'follows'],
|
||||||
toJSON: function(options) {
|
toJSON: function(options) {
|
||||||
return _.omit(this.attributes, this.blacklist)
|
return _.omit(this.attributes, this.blacklist)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Mapper from './Mapper'
|
||||||
|
|
||||||
const MapperCollection = Backbone.Collection.extend({
|
const MapperCollection = Backbone.Collection.extend({
|
||||||
model: Mapper,
|
model: Mapper,
|
||||||
url: '/main/users'
|
url: '/users'
|
||||||
})
|
})
|
||||||
|
|
||||||
export default MapperCollection
|
export default MapperCollection
|
||||||
|
|
|
@ -8,7 +8,7 @@ import Synapse from '../Synapse'
|
||||||
import Topic from '../Topic'
|
import Topic from '../Topic'
|
||||||
|
|
||||||
const Mapping = Backbone.Model.extend({
|
const Mapping = Backbone.Model.extend({
|
||||||
urlRoot: '/main/mappings',
|
urlRoot: '/mappings',
|
||||||
blacklist: ['created_at', 'updated_at'],
|
blacklist: ['created_at', 'updated_at'],
|
||||||
toJSON: function(options) {
|
toJSON: function(options) {
|
||||||
return _.omit(this.attributes, this.blacklist)
|
return _.omit(this.attributes, this.blacklist)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Mapping from './Mapping'
|
||||||
|
|
||||||
const MappingCollection = Backbone.Collection.extend({
|
const MappingCollection = Backbone.Collection.extend({
|
||||||
model: Mapping,
|
model: Mapping,
|
||||||
url: '/main/mappings'
|
url: '/mappings'
|
||||||
})
|
})
|
||||||
|
|
||||||
export default MappingCollection
|
export default MappingCollection
|
||||||
|
|
|
@ -3,7 +3,7 @@ import Backbone from 'backbone'
|
||||||
try { Backbone.$ = window.$ } catch (err) {}
|
try { Backbone.$ = window.$ } catch (err) {}
|
||||||
|
|
||||||
const Message = Backbone.Model.extend({
|
const Message = Backbone.Model.extend({
|
||||||
urlRoot: '/main/messages',
|
urlRoot: '/messages',
|
||||||
blacklist: ['created_at', 'updated_at'],
|
blacklist: ['created_at', 'updated_at'],
|
||||||
toJSON: function(options) {
|
toJSON: function(options) {
|
||||||
return _.omit(this.attributes, this.blacklist)
|
return _.omit(this.attributes, this.blacklist)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Message from './Message'
|
||||||
|
|
||||||
const MessageCollection = Backbone.Collection.extend({
|
const MessageCollection = Backbone.Collection.extend({
|
||||||
model: Message,
|
model: Message,
|
||||||
url: '/main/messages'
|
url: '/messages'
|
||||||
})
|
})
|
||||||
|
|
||||||
export default MessageCollection
|
export default MessageCollection
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Metacode from './Metacode'
|
||||||
|
|
||||||
const MetacodeCollection = Backbone.Collection.extend({
|
const MetacodeCollection = Backbone.Collection.extend({
|
||||||
model: Metacode,
|
model: Metacode,
|
||||||
url: '/main/metacodes',
|
url: '/metacodes',
|
||||||
comparator: function(a, b) {
|
comparator: function(a, b) {
|
||||||
a = a.get('name').toLowerCase()
|
a = a.get('name').toLowerCase()
|
||||||
b = b.get('name').toLowerCase()
|
b = b.get('name').toLowerCase()
|
||||||
|
|
|
@ -11,7 +11,7 @@ import Visualize from '../Visualize'
|
||||||
import DataModel from './index'
|
import DataModel from './index'
|
||||||
|
|
||||||
const Synapse = Backbone.Model.extend({
|
const Synapse = Backbone.Model.extend({
|
||||||
urlRoot: '/main/synapses',
|
urlRoot: '/synapses',
|
||||||
blacklist: ['edge', 'created_at', 'updated_at'],
|
blacklist: ['edge', 'created_at', 'updated_at'],
|
||||||
toJSON: function(options) {
|
toJSON: function(options) {
|
||||||
return _.omit(this.attributes, this.blacklist)
|
return _.omit(this.attributes, this.blacklist)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Synapse from './Synapse'
|
||||||
|
|
||||||
const SynapseCollection = Backbone.Collection.extend({
|
const SynapseCollection = Backbone.Collection.extend({
|
||||||
model: Synapse,
|
model: Synapse,
|
||||||
url: '/main/synapses'
|
url: '/synapses'
|
||||||
})
|
})
|
||||||
|
|
||||||
export default SynapseCollection
|
export default SynapseCollection
|
||||||
|
|
|
@ -10,7 +10,7 @@ import Visualize from '../Visualize'
|
||||||
import DataModel from './index'
|
import DataModel from './index'
|
||||||
|
|
||||||
const Topic = Backbone.Model.extend({
|
const Topic = Backbone.Model.extend({
|
||||||
urlRoot: '/main/topics',
|
urlRoot: '/topics',
|
||||||
blacklist: ['node', 'created_at', 'updated_at', 'user_name', 'user_image', 'map_count', 'synapse_count'],
|
blacklist: ['node', 'created_at', 'updated_at', 'user_name', 'user_image', 'map_count', 'synapse_count'],
|
||||||
toJSON: function(options) {
|
toJSON: function(options) {
|
||||||
return _.omit(this.attributes, this.blacklist)
|
return _.omit(this.attributes, this.blacklist)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Topic from './Topic'
|
||||||
|
|
||||||
const TopicCollection = Backbone.Collection.extend({
|
const TopicCollection = Backbone.Collection.extend({
|
||||||
model: Topic,
|
model: Topic,
|
||||||
url: '/main/topics'
|
url: '/topics'
|
||||||
})
|
})
|
||||||
|
|
||||||
export default TopicCollection
|
export default TopicCollection
|
||||||
|
|
|
@ -9,7 +9,7 @@ const Notifications = {
|
||||||
},
|
},
|
||||||
fetch: render => {
|
fetch: render => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/main/notifications.json',
|
url: '/notifications.json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
Notifications.notifications = data
|
Notifications.notifications = data
|
||||||
render()
|
render()
|
||||||
|
@ -27,7 +27,7 @@ const Notifications = {
|
||||||
markAsRead: (render, id) => {
|
markAsRead: (render, id) => {
|
||||||
const n = Notifications.notifications.find(n => n.id === id)
|
const n = Notifications.notifications.find(n => n.id === id)
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/main/notifications/${id}/mark_read.json`,
|
url: `/notifications/${id}/mark_read.json`,
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
success: function(r) {
|
success: function(r) {
|
||||||
if (n) {
|
if (n) {
|
||||||
|
@ -44,7 +44,7 @@ const Notifications = {
|
||||||
markAsUnread: (render, id) => {
|
markAsUnread: (render, id) => {
|
||||||
const n = Notifications.notifications.find(n => n.id === id)
|
const n = Notifications.notifications.find(n => n.id === id)
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/main/notifications/${id}/mark_unread.json`,
|
url: `/notifications/${id}/mark_unread.json`,
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
success: function() {
|
success: function() {
|
||||||
if (n) {
|
if (n) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ const Search = {
|
||||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
||||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
remote: {
|
remote: {
|
||||||
url: '/main/search/topics',
|
url: '/search/topics',
|
||||||
prepare: function(query, settings) {
|
prepare: function(query, settings) {
|
||||||
settings.url += '?term=' + query
|
settings.url += '?term=' + query
|
||||||
if (Active.Mapper && self.limitTopicsToMe) {
|
if (Active.Mapper && self.limitTopicsToMe) {
|
||||||
|
@ -101,7 +101,7 @@ const Search = {
|
||||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
||||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
remote: {
|
remote: {
|
||||||
url: '/main/search/maps',
|
url: '/search/maps',
|
||||||
prepare: function(query, settings) {
|
prepare: function(query, settings) {
|
||||||
settings.url += '?term=' + query
|
settings.url += '?term=' + query
|
||||||
if (Active.Mapper && self.limitMapsToMe) {
|
if (Active.Mapper && self.limitMapsToMe) {
|
||||||
|
@ -135,7 +135,7 @@ const Search = {
|
||||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
||||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
remote: {
|
remote: {
|
||||||
url: '/main/search/mappers?term=%QUERY',
|
url: '/search/mappers?term=%QUERY',
|
||||||
wildcard: '%QUERY'
|
wildcard: '%QUERY'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -370,7 +370,7 @@ const Import = {
|
||||||
{
|
{
|
||||||
success: function(topic) {
|
success: function(topic) {
|
||||||
if (topic.get('name') !== 'Link') return
|
if (topic.get('name') !== 'Link') return
|
||||||
$.get('/main/hacks/load_url_title', {
|
$.get('/hacks/load_url_title', {
|
||||||
url
|
url
|
||||||
}, function success(data, textStatus) {
|
}, function success(data, textStatus) {
|
||||||
if (typeof data === 'string' && data.trim() === '') return
|
if (typeof data === 'string' && data.trim() === '') return
|
||||||
|
|
|
@ -213,7 +213,7 @@ const InfoBox = {
|
||||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
|
||||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
remote: {
|
remote: {
|
||||||
url: '/main/search/mappers?term=%QUERY',
|
url: '/search/mappers?term=%QUERY',
|
||||||
wildcard: '%QUERY'
|
wildcard: '%QUERY'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -237,7 +237,7 @@ const InfoBox = {
|
||||||
var self = InfoBox
|
var self = InfoBox
|
||||||
DataModel.Collaborators.remove(DataModel.Collaborators.get(collaboratorId))
|
DataModel.Collaborators.remove(DataModel.Collaborators.get(collaboratorId))
|
||||||
var mapperIds = DataModel.Collaborators.models.map(function(mapper) { return mapper.id })
|
var mapperIds = DataModel.Collaborators.models.map(function(mapper) { return mapper.id })
|
||||||
$.post('/main/maps/' + Active.Map.id + '/access', { access: mapperIds })
|
$.post('/maps/' + Active.Map.id + '/access', { access: mapperIds })
|
||||||
self.updateNumbers()
|
self.updateNumbers()
|
||||||
},
|
},
|
||||||
addCollaborator: function(newCollaboratorId) {
|
addCollaborator: function(newCollaboratorId) {
|
||||||
|
@ -251,13 +251,13 @@ const InfoBox = {
|
||||||
function callback(mapper) {
|
function callback(mapper) {
|
||||||
DataModel.Collaborators.add(mapper)
|
DataModel.Collaborators.add(mapper)
|
||||||
var mapperIds = DataModel.Collaborators.models.map(function(mapper) { return mapper.id })
|
var mapperIds = DataModel.Collaborators.models.map(function(mapper) { return mapper.id })
|
||||||
$.post('/main/maps/' + Active.Map.id + '/access', { access: mapperIds })
|
$.post('/maps/' + Active.Map.id + '/access', { access: mapperIds })
|
||||||
var name = DataModel.Collaborators.get(newCollaboratorId).get('name')
|
var name = DataModel.Collaborators.get(newCollaboratorId).get('name')
|
||||||
GlobalUI.notifyUser(name + ' will be notified')
|
GlobalUI.notifyUser(name + ' will be notified')
|
||||||
self.updateNumbers()
|
self.updateNumbers()
|
||||||
}
|
}
|
||||||
|
|
||||||
$.getJSON('/main/users/' + newCollaboratorId + '.json', callback)
|
$.getJSON('/users/' + newCollaboratorId + '.json', callback)
|
||||||
},
|
},
|
||||||
handleResultClick: function(event, item) {
|
handleResultClick: function(event, item) {
|
||||||
var self = InfoBox
|
var self = InfoBox
|
||||||
|
|
|
@ -63,7 +63,7 @@ const Map = {
|
||||||
self.setAccessRequest()
|
self.setAccessRequest()
|
||||||
const mapId = Active.Map.id
|
const mapId = Active.Map.id
|
||||||
$.post({
|
$.post({
|
||||||
url: `/main/maps/${mapId}/access_request`
|
url: `/maps/${mapId}/access_request`
|
||||||
})
|
})
|
||||||
GlobalUI.notifyUser('Map creator will be notified of your request')
|
GlobalUI.notifyUser('Map creator will be notified of your request')
|
||||||
},
|
},
|
||||||
|
@ -117,7 +117,7 @@ const Map = {
|
||||||
else {
|
else {
|
||||||
Loading.show()
|
Loading.show()
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/main/maps/' + id + '/contains.json',
|
url: '/maps/' + id + '/contains.json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
Active.Map = new DataModelMap(data.map)
|
Active.Map = new DataModelMap(data.map)
|
||||||
DataModel.Mappers = new DataModel.MapperCollection(data.mappers)
|
DataModel.Mappers = new DataModel.MapperCollection(data.mappers)
|
||||||
|
@ -153,7 +153,7 @@ const Map = {
|
||||||
var self = Map
|
var self = Map
|
||||||
|
|
||||||
if (!Active.Map) return
|
if (!Active.Map) return
|
||||||
$.post('/main/maps/' + Active.Map.id + '/star')
|
$.post('/maps/' + Active.Map.id + '/star')
|
||||||
DataModel.Stars.push({ user_id: Active.Mapper.id, map_id: Active.Map.id })
|
DataModel.Stars.push({ user_id: Active.Mapper.id, map_id: Active.Map.id })
|
||||||
DataModel.Maps.Starred.add(Active.Map)
|
DataModel.Maps.Starred.add(Active.Map)
|
||||||
GlobalUI.notifyUser('Map is now starred')
|
GlobalUI.notifyUser('Map is now starred')
|
||||||
|
@ -164,7 +164,7 @@ const Map = {
|
||||||
var self = Map
|
var self = Map
|
||||||
|
|
||||||
if (!Active.Map) return
|
if (!Active.Map) return
|
||||||
$.post('/main/maps/' + Active.Map.id + '/unstar')
|
$.post('/maps/' + Active.Map.id + '/unstar')
|
||||||
DataModel.Stars = DataModel.Stars.filter(function(s) { return s.user_id !== Active.Mapper.id })
|
DataModel.Stars = DataModel.Stars.filter(function(s) { return s.user_id !== Active.Mapper.id })
|
||||||
DataModel.Maps.Starred.remove(Active.Map)
|
DataModel.Maps.Starred.remove(Active.Map)
|
||||||
self.mapIsStarred = false
|
self.mapIsStarred = false
|
||||||
|
@ -263,7 +263,7 @@ const Map = {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'PATCH',
|
type: 'PATCH',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
url: `/main/maps/${Active.Map.id}`,
|
url: `/maps/${Active.Map.id}`,
|
||||||
data: formData,
|
data: formData,
|
||||||
processData: false,
|
processData: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
|
|
|
@ -7,7 +7,7 @@ const Mapper = {
|
||||||
// @param id = the id of the mapper to retrieve
|
// @param id = the id of the mapper to retrieve
|
||||||
get: function(id, callback) {
|
get: function(id, callback) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `/main/users/${id}.json`,
|
url: `/users/${id}.json`,
|
||||||
success: data => {
|
success: data => {
|
||||||
callback(new DataModel.Mapper(data))
|
callback(new DataModel.Mapper(data))
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ export const acceptCall = self => userid => {
|
||||||
invited: Active.Mapper.id,
|
invited: Active.Mapper.id,
|
||||||
inviter: userid
|
inviter: userid
|
||||||
})
|
})
|
||||||
$.post('/main/maps/' + Active.Map.id + '/events/conversation')
|
$.post('/maps/' + Active.Map.id + '/events/conversation')
|
||||||
self.joinCall()
|
self.joinCall()
|
||||||
GlobalUI.clearNotify()
|
GlobalUI.clearNotify()
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ const Synapse = {
|
||||||
// if the desired topic is not yet in the local topic repository, fetch it
|
// if the desired topic is not yet in the local topic repository, fetch it
|
||||||
if (DataModel.Synapses.get(id) === undefined) {
|
if (DataModel.Synapses.get(id) === undefined) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/main/synapses/' + id + '.json',
|
url: '/synapses/' + id + '.json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
DataModel.Synapses.add(data)
|
DataModel.Synapses.add(data)
|
||||||
callback(DataModel.Synapses.get(id))
|
callback(DataModel.Synapses.get(id))
|
||||||
|
|
|
@ -85,7 +85,7 @@ const SynapseCard = {
|
||||||
$('#edit_synapse_desc').attr('data-bip-attribute', 'desc')
|
$('#edit_synapse_desc').attr('data-bip-attribute', 'desc')
|
||||||
$('#edit_synapse_desc').attr('data-bip-type', 'textarea')
|
$('#edit_synapse_desc').attr('data-bip-type', 'textarea')
|
||||||
$('#edit_synapse_desc').attr('data-bip-nil', dataNil)
|
$('#edit_synapse_desc').attr('data-bip-nil', dataNil)
|
||||||
$('#edit_synapse_desc').attr('data-bip-url', '/main/synapses/' + synapse.id)
|
$('#edit_synapse_desc').attr('data-bip-url', '/synapses/' + synapse.id)
|
||||||
$('#edit_synapse_desc').attr('data-bip-value', synapse.get('desc'))
|
$('#edit_synapse_desc').attr('data-bip-value', synapse.get('desc'))
|
||||||
$('#edit_synapse_desc').html(synapse.get('desc'))
|
$('#edit_synapse_desc').html(synapse.get('desc'))
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ const Topic = {
|
||||||
// if the desired topic is not yet in the local topic repository, fetch it
|
// if the desired topic is not yet in the local topic repository, fetch it
|
||||||
if (DataModel.Topics.get(id) === undefined) {
|
if (DataModel.Topics.get(id) === undefined) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/main/topics/' + id + '.json',
|
url: '/topics/' + id + '.json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
DataModel.Topics.add(data)
|
DataModel.Topics.add(data)
|
||||||
callback(DataModel.Topics.get(id))
|
callback(DataModel.Topics.get(id))
|
||||||
|
@ -55,7 +55,7 @@ const Topic = {
|
||||||
else {
|
else {
|
||||||
Loading.show()
|
Loading.show()
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/main/topics/' + id + '/network.json',
|
url: '/topics/' + id + '/network.json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
Active.Topic = new DataModel.Topic(data.topic)
|
Active.Topic = new DataModel.Topic(data.topic)
|
||||||
DataModel.Creators = new DataModel.MapperCollection(data.creators)
|
DataModel.Creators = new DataModel.MapperCollection(data.creators)
|
||||||
|
@ -90,7 +90,7 @@ const Topic = {
|
||||||
onTopicFollow: topic => {
|
onTopicFollow: topic => {
|
||||||
const isFollowing = topic.isFollowedBy(Active.Mapper)
|
const isFollowing = topic.isFollowedBy(Active.Mapper)
|
||||||
$.post({
|
$.post({
|
||||||
url: `/main/topics/${topic.id}/${isFollowing ? 'un' : ''}follow`
|
url: `/topics/${topic.id}/${isFollowing ? 'un' : ''}follow`
|
||||||
})
|
})
|
||||||
if (isFollowing) {
|
if (isFollowing) {
|
||||||
GlobalUI.notifyUser('You are no longer following this topic')
|
GlobalUI.notifyUser('You are no longer following this topic')
|
||||||
|
@ -166,7 +166,7 @@ const Topic = {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url: '/main/topics/' + topic.id + '/relatives.json?' + paramsString,
|
url: '/topics/' + topic.id + '/relatives.json?' + paramsString,
|
||||||
success: successCallback,
|
success: successCallback,
|
||||||
error: function() {}
|
error: function() {}
|
||||||
})
|
})
|
||||||
|
|
|
@ -98,7 +98,7 @@ const ContextMenu = {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url: `/main/topics/${id}/relative_numbers.json?network=${topicsString}`,
|
url: `/topics/${id}/relative_numbers.json?network=${topicsString}`,
|
||||||
success: successCallback,
|
success: successCallback,
|
||||||
error: function() {}
|
error: function() {}
|
||||||
})
|
})
|
||||||
|
|
|
@ -109,7 +109,7 @@ const ExploreMaps = {
|
||||||
|
|
||||||
// first load the mapper object and then call the render function
|
// first load the mapper object and then call the render function
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/main/users/' + self.collection.mapperId + '/details.json',
|
url: '/users/' + self.collection.mapperId + '/details.json',
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
self.mapper = response
|
self.mapper = response
|
||||||
document.title = self.mapper.name + ' | Metamaps'
|
document.title = self.mapper.name + ' | Metamaps'
|
||||||
|
@ -122,7 +122,7 @@ const ExploreMaps = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onStar: function(map) {
|
onStar: function(map) {
|
||||||
$.post('/main/maps/' + map.id + '/star')
|
$.post('/maps/' + map.id + '/star')
|
||||||
map.set('star_count', map.get('star_count') + 1)
|
map.set('star_count', map.get('star_count') + 1)
|
||||||
if (DataModel.Stars) DataModel.Stars.push({ user_id: Active.Mapper.id, map_id: map.id })
|
if (DataModel.Stars) DataModel.Stars.push({ user_id: Active.Mapper.id, map_id: map.id })
|
||||||
DataModel.Maps.Starred.add(map)
|
DataModel.Maps.Starred.add(map)
|
||||||
|
@ -131,14 +131,14 @@ const ExploreMaps = {
|
||||||
},
|
},
|
||||||
onRequest: function(map) {
|
onRequest: function(map) {
|
||||||
$.post({
|
$.post({
|
||||||
url: `/main/maps/${map.id}/access_request`
|
url: `/maps/${map.id}/access_request`
|
||||||
})
|
})
|
||||||
GlobalUI.notifyUser('You will be notified by email if request accepted')
|
GlobalUI.notifyUser('You will be notified by email if request accepted')
|
||||||
},
|
},
|
||||||
onMapFollow: function(map) {
|
onMapFollow: function(map) {
|
||||||
const isFollowing = map.isFollowedBy(Active.Mapper)
|
const isFollowing = map.isFollowedBy(Active.Mapper)
|
||||||
$.post({
|
$.post({
|
||||||
url: `/main/maps/${map.id}/${isFollowing ? 'un' : ''}follow`
|
url: `/maps/${map.id}/${isFollowing ? 'un' : ''}follow`
|
||||||
})
|
})
|
||||||
if (isFollowing) {
|
if (isFollowing) {
|
||||||
GlobalUI.notifyUser('You are no longer following this map')
|
GlobalUI.notifyUser('You are no longer following this map')
|
||||||
|
|
Loading…
Reference in a new issue