huge refactor 75% done
This commit is contained in:
parent
eceb1174c3
commit
b06f5cae35
28 changed files with 17715 additions and 612 deletions
4
Gemfile
4
Gemfile
|
@ -1,5 +1,5 @@
|
|||
source 'https://rubygems.org'
|
||||
ruby '1.9.3'
|
||||
#ruby '1.9.3'
|
||||
|
||||
gem 'rails', '3.2.17'
|
||||
|
||||
|
@ -35,7 +35,7 @@ group :assets do
|
|||
end
|
||||
|
||||
group :production do #this is used on heroku
|
||||
gem 'rmagick'
|
||||
#gem 'rmagick'
|
||||
end
|
||||
|
||||
gem 'jquery-rails', '2.1.2'
|
||||
|
|
|
@ -585,47 +585,4 @@ function touchPanZoomHandler(eventInfo, e) {
|
|||
lastDist = dist;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function updateSelectedPermissions(permission) {
|
||||
|
||||
|
||||
if ($('.notice.metamaps').length == 0) {
|
||||
$('body').prepend('<div class="notice metamaps" />');
|
||||
}
|
||||
$('.notice.metamaps').hide().html('Working...').fadeIn('fast');
|
||||
|
||||
// variables to keep track of how many nodes and synapses you had the ability to change the permission of
|
||||
var nCount = 0,
|
||||
sCount = 0;
|
||||
|
||||
// change the permission of the selected synapses, if logged in user is the original creator
|
||||
var l = MetamapsModel.selectedEdges.length;
|
||||
for (var i = l - 1; i >= 0; i -= 1) {
|
||||
var edge = MetamapsModel.selectedEdges[i];
|
||||
|
||||
if (edge.getData('userid') == userid) {
|
||||
updateSynapsePermission(edge, permission);
|
||||
sCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// change the permission of the selected topics, if logged in user is the original creator
|
||||
var l = MetamapsModel.selectedNodes.length;
|
||||
for (var i = l - 1; i >= 0; i -= 1) {
|
||||
var node = MetamapsModel.selectedNodes[i];
|
||||
|
||||
if (node.getData('userid') == userid) {
|
||||
updateTopicPermission(node, permission);
|
||||
nCount++;
|
||||
}
|
||||
}
|
||||
|
||||
var nString = nCount == 1 ? (nCount.toString() + ' topic and ') : (nCount.toString() + ' topics and ');
|
||||
var sString = sCount == 1 ? (sCount.toString() + ' synapse') : (sCount.toString() + ' synapses');
|
||||
|
||||
$('.notice.metamaps').html(nString + sString + ' you created updated to ' + permission)
|
||||
setTimeout(function () {
|
||||
$('.notice.metamaps').fadeOut('fast');
|
||||
}, 8000);
|
||||
}
|
|
@ -7238,7 +7238,7 @@ Graph.Label.Native = new Class({
|
|||
function splitLine(st,n) {var b = ''; var s = st;while (s.length > n) {var c = s.substring(0,n);var d = c.lastIndexOf(' ');var e =c.lastIndexOf('\n');if (e != -1) d = e; if (d == -1) d = n; b += c.substring(0,d) + '\n';s = s.substring(d+1);}return b+s;}
|
||||
var arrayOfLabelLines = splitLine(node.name,30).split('\n');
|
||||
//render background
|
||||
ctx.fillStyle = 'rgba(24,32,46, 1)';
|
||||
ctx.fillStyle = 'rgba(24, 32, 46, 1)';
|
||||
ctx.strokeStyle = node.getData('whiteCircle') ? '#FFF' : 'rgba(24,32,46, 1)';
|
||||
ctx.lineWidth = 2;
|
||||
var height = 25 * arrayOfLabelLines.length; //font size + margin
|
||||
|
|
|
@ -20,7 +20,17 @@
|
|||
//= require jquery.roundabout.min
|
||||
//= require bip
|
||||
//= require jquery_ujs
|
||||
//= require_tree .
|
||||
//= require hogan-2.0.0
|
||||
//= require socket.io
|
||||
//= require typeahead
|
||||
//= require underscore
|
||||
//= require backbone
|
||||
//= require_directory ./carousel
|
||||
// require_directory ./Jit
|
||||
//= require_directory ./jquery
|
||||
//= require_directory ./realtime
|
||||
//= require_directory ./scroll
|
||||
//= require_directory ./typing
|
||||
|
||||
// other options are 'graph'
|
||||
var viewMode = "list";
|
||||
|
@ -165,70 +175,6 @@ function updateMetacode(node, metacode) {
|
|||
});
|
||||
}
|
||||
|
||||
function updateTopicPermission(node, permission) {
|
||||
var mdata = {
|
||||
"topic": {
|
||||
"permission": permission
|
||||
}
|
||||
};
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
dataType: 'json',
|
||||
url: "/topics/" + node.id,
|
||||
data: mdata,
|
||||
success: function (data) {
|
||||
$('.showcard .mapPerm').removeClass('co pu pr minimize').addClass(permission.substring(0, 2));
|
||||
$('.permissionSelect').remove();
|
||||
node.setData("permission", permission);
|
||||
},
|
||||
error: function () {
|
||||
alert('failed to update permission');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateSynapsePermission(edge, permission) {
|
||||
var mdata = {
|
||||
"synapse": {
|
||||
"permission": permission
|
||||
}
|
||||
};
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
dataType: 'json',
|
||||
url: "/synapses/" + edge.data.$id,
|
||||
data: mdata,
|
||||
success: function (data) {
|
||||
$('#edit_synapse .mapPerm').removeClass('co pu pr minimize').addClass(permission.substring(0, 2));
|
||||
$('#edit_synapse .permissionSelect').remove();
|
||||
edge.setData("permission", permission);
|
||||
},
|
||||
error: function () {
|
||||
alert('failed to update permission');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateMapPermission(mapid, permission) {
|
||||
var mdata = {
|
||||
"map": {
|
||||
"permission": permission
|
||||
}
|
||||
};
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
dataType: 'json',
|
||||
url: "/maps/" + mapid,
|
||||
data: mdata,
|
||||
success: function (data) {
|
||||
$('.mapPermission').removeClass('commons public private minimize').addClass(permission);
|
||||
$('.mapPermission .permissionSelect').remove();
|
||||
},
|
||||
error: function () {
|
||||
alert('failed to update permission');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateMetacodeSet(set, index, custom) {
|
||||
|
||||
|
@ -330,21 +276,6 @@ function MconsoleReset() {
|
|||
Mconsole.canvas.scale((1 / mX), (1 / mY));
|
||||
}
|
||||
|
||||
function openNodeShowcard(node) {
|
||||
//populate the card that's about to show with the right topics data
|
||||
populateShowCard(node);
|
||||
|
||||
$('.showcard').fadeIn('fast');
|
||||
var s = $('.showcard').find('.scroll');
|
||||
s.height(s.height()).mCustomScrollbar({
|
||||
mouseWheelPixels: 200,
|
||||
advanced: {
|
||||
updateOnContentResize: true
|
||||
}
|
||||
});
|
||||
MetamapsModel.showcardInUse = node.id;
|
||||
}
|
||||
|
||||
function openLightbox(which) {
|
||||
$('.lightboxContent').hide();
|
||||
$('#' + which).show();
|
||||
|
|
1571
app/assets/javascripts/backbone.js
Normal file
1571
app/assets/javascripts/backbone.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -198,7 +198,7 @@ jQuery.browser = browser;
|
|||
{
|
||||
$(options.titleBox).html( ($(event.target).attr('title') ));
|
||||
// METAMAPS CODE
|
||||
$('#topic_metacode').val($(event.target).attr('title'));
|
||||
Metamaps.Create.newTopic.metacode = $(event.target).attr('title');
|
||||
// NOT METAMAPS CODE
|
||||
var idx = $(event.target).data('itemIndex');
|
||||
var frontIndex = event.data.frontIndex;
|
||||
|
@ -236,7 +236,7 @@ jQuery.browser = browser;
|
|||
{
|
||||
if ( items[this.frontIndex] === undefined ) { return; } // Images might not have loaded yet.
|
||||
// METAMAPS CODE
|
||||
$('#topic_metacode').val($(items[this.frontIndex].image).attr('title'));
|
||||
Metamaps.Create.newTopic.metacode = $(items[this.frontIndex].image).attr('title');
|
||||
//$('img.cloudcarousel').css({"background":"none", "width":"","height":""});
|
||||
//$(items[this.frontIndex].image).css({"width":"45px","height":"45px"});
|
||||
// NOT METAMAPS CODE
|
||||
|
|
|
@ -57,7 +57,7 @@ $(document).ready(function () {
|
|||
// hide the other two
|
||||
$('.sidebarAccountBox').hide();
|
||||
$('.sidebarCollaborateBox').hide();
|
||||
$('.sidebarAccountIcon').css('background-color', '#0F1519');
|
||||
//$('.sidebarAccountIcon').css('background-color', '#0F1519');
|
||||
$('.sidebarCollaborateIcon').css('background-color', '#0F1519');
|
||||
|
||||
$('.sidebarFilterIcon').css('background-color', '#000');
|
||||
|
|
|
@ -37,7 +37,7 @@ $(document).ready(function () {
|
|||
$('.sidebarFilterBox').hide();
|
||||
$('.sidebarAccountBox').hide();
|
||||
$('.sidebarFilterIcon').css('background-color', '#0F1519');
|
||||
$('.sidebarAccountIcon').css('background-color', '#0F1519');
|
||||
//$('.sidebarAccountIcon').css('background-color', '#0F1519');
|
||||
|
||||
$('.sidebarCollaborateIcon').css('background-color', '#000');
|
||||
$('.sidebarCollaborateBox').fadeIn(200, function () {
|
||||
|
@ -58,7 +58,7 @@ $(document).ready(function () {
|
|||
var openSave = function () {
|
||||
// hide the other three
|
||||
$('.sidebarFilterBox, .sidebarAccountBox, .sidebarCollaborateBox').hide();
|
||||
$('.sidebarFilterIcon, .sidebarAccountIcon, .sidebarCollaborateIcon').css('background-color', '#0F1519');
|
||||
$('.sidebarFilterIcon, .sidebarCollaborateIcon').css('background-color', '#0F1519');
|
||||
}
|
||||
// bind the hover events
|
||||
$(".sidebarSave").hover(openSave, closeSave);
|
||||
|
|
|
@ -17,7 +17,7 @@ $(document).ready(function () {
|
|||
var openFork = function () {
|
||||
// hide the other three
|
||||
$('.sidebarFilterBox, .sidebarAccountBox, .sidebarCollaborateBox').hide();
|
||||
$('.sidebarFilterIcon, .sidebarAccountIcon, .sidebarCollaborateIcon').css('background-color', '#0F1519');
|
||||
$('.sidebarFilterIcon, .sidebarCollaborateIcon').css('background-color', '#0F1519');
|
||||
}
|
||||
// bind the hover events
|
||||
$(".sidebarFork").hover(openFork, closeFork);
|
||||
|
@ -25,137 +25,13 @@ $(document).ready(function () {
|
|||
|
||||
// bind hover events
|
||||
bindForkHover();
|
||||
|
||||
//////
|
||||
//////
|
||||
//// TOPIC CREATION
|
||||
|
||||
// initialize the autocomplete results for the metacode spinner
|
||||
$('#topic_name').typeahead([
|
||||
{
|
||||
name: 'topic_autocomplete',
|
||||
limit: 8,
|
||||
template: $('#topicAutocompleteTemplate').html(),
|
||||
remote: {
|
||||
url: '/topics/autocomplete_topic?term=%QUERY'
|
||||
},
|
||||
engine: Hogan
|
||||
}
|
||||
]);
|
||||
|
||||
var topicTypeahead = false;
|
||||
// tell the autocomplete to submit the form with the topic you clicked on if you pick from the autocomplete
|
||||
$('#topic_name').bind('typeahead:selected', function (event, datum, dataset) {
|
||||
$('#topic_grabTopic').val(datum.id);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
$('.new_topic').submit();
|
||||
topicTypeahead = true;
|
||||
});
|
||||
$('#topic_name').bind('typeahead:opened', function () {
|
||||
topicTypeahead = false;
|
||||
});
|
||||
|
||||
// bind keyboard handlers
|
||||
$('#topic_name').bind('keyup', function (e) {
|
||||
switch (e.which) {
|
||||
case 13:
|
||||
if (!topicTypeahead) $('.new_topic').submit();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// initialize metacode spinner and then hide it
|
||||
$("#metacodeImg").CloudCarousel({
|
||||
titleBox: $('#metacodeImgTitle'),
|
||||
yRadius: 40,
|
||||
xPos: 150,
|
||||
yPos: 40,
|
||||
speed: 0.3,
|
||||
mouseWheel: true,
|
||||
bringToFront: true
|
||||
});
|
||||
$('.new_topic').hide();
|
||||
|
||||
|
||||
//////
|
||||
//////
|
||||
//// SYNAPSE CREATION
|
||||
|
||||
// initialize the autocomplete results for synapse creation
|
||||
$('#synapse_desc').typeahead([
|
||||
{
|
||||
name: 'synapse_autocomplete',
|
||||
template: "<div>{{label}}</div>",
|
||||
remote: {
|
||||
url: '/search/synapses?term=%QUERY'
|
||||
},
|
||||
engine: Hogan
|
||||
},
|
||||
{
|
||||
name: 'existing_synapses',
|
||||
limit: 50,
|
||||
template: $('#synapseAutocompleteTemplate').html(),
|
||||
remote: {
|
||||
url: '/search/synapses',
|
||||
replace: function () {
|
||||
var q = '/search/synapses?topic1id=' + $('#synapse_topic1id').val() + '&topic2id=' + $('#synapse_topic2id').val();
|
||||
return q;
|
||||
}
|
||||
},
|
||||
engine: Hogan,
|
||||
header: "<h3>Existing Synapses</h3>"
|
||||
},
|
||||
]);
|
||||
|
||||
var synapseTypeahead = false;
|
||||
// tell the autocomplete to submit the form with the topic you clicked on if you pick from the autocomplete
|
||||
$('#synapse_desc').bind('typeahead:selected', function (event, datum, dataset) {
|
||||
if (datum.id) { // if they clicked on an existing synapse get it
|
||||
$('#synapse_grabSynapse').val(datum.id);
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
$('.new_synapse').submit();
|
||||
synapseTypeahead = true;
|
||||
});
|
||||
$('#synapse_desc').bind('typeahead:opened', function () {
|
||||
synapseTypeahead = false;
|
||||
});
|
||||
// bind keyboard handlers
|
||||
$('#synapse_desc').bind('keyup', function (e) {
|
||||
switch (e.which) {
|
||||
case 13:
|
||||
if (!synapseTypeahead) $('.new_synapse').submit();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//////
|
||||
//////
|
||||
//// TOPIC AND SYNAPSE CREATION
|
||||
|
||||
// when either form submits, don't leave the page
|
||||
$('.new_topic, .new_synapse').bind('submit', function (event, data) {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// disable right click events on the new topic and new synapse input fields
|
||||
$('#new_topic, #new_synapse').bind('contextmenu', function (e) {
|
||||
return false;
|
||||
});
|
||||
|
||||
//////
|
||||
//////
|
||||
//// SWITCHING METACODE SETS
|
||||
|
||||
$('#metacodeSwitchTabs').tabs({
|
||||
selected: MetamapsModel.selectedMetacodeSetIndex
|
||||
selected: Metamaps.Settings.selectedMetacodeSetIndex
|
||||
}).addClass("ui-tabs-vertical ui-helper-clearfix");
|
||||
$("#metacodeSwitchTabs .ui-tabs-nav li").removeClass("ui-corner-top").addClass("ui-corner-left");
|
||||
$('.customMetacodeList li').click(function () {
|
||||
|
|
18
app/assets/javascripts/jquery/EveryPage.js
vendored
18
app/assets/javascripts/jquery/EveryPage.js
vendored
|
@ -362,7 +362,7 @@ $(document).ready(function () {
|
|||
lT = setTimeout(function () {
|
||||
if (!sliding1) {
|
||||
sliding1 = true;
|
||||
$('.sidebarAccountIcon').css('background-color', '#0F1519');
|
||||
//$('.sidebarAccountIcon').css('background-color', '#0F1519');
|
||||
$('.sidebarAccountBox').fadeOut(200, function () {
|
||||
sliding1 = false;
|
||||
accountIsOpen = false;
|
||||
|
@ -382,7 +382,7 @@ $(document).ready(function () {
|
|||
$('.sidebarFilterIcon').css('background-color', '#0F1519');
|
||||
$('.sidebarCollaborateIcon').css('background-color', '#0F1519');
|
||||
|
||||
$('.sidebarAccountIcon').css('background-color', '#000');
|
||||
//$('.sidebarAccountIcon').css('background-color', '#000');
|
||||
$('.sidebarAccountBox').fadeIn(200, function () {
|
||||
sliding1 = false;
|
||||
accountIsOpen = true;
|
||||
|
@ -409,18 +409,4 @@ $(document).ready(function () {
|
|||
return false;
|
||||
});
|
||||
|
||||
// bind keyboard handlers
|
||||
$('body').bind('keyup', function (e) {
|
||||
switch (e.which) {
|
||||
case 13:
|
||||
enterKeyHandler(e);
|
||||
break;
|
||||
case 27:
|
||||
escKeyHandler();
|
||||
break;
|
||||
default:
|
||||
break; //console.log(e.which);
|
||||
}
|
||||
});
|
||||
|
||||
}); // end document.ready
|
14
app/assets/javascripts/map.js
Normal file
14
app/assets/javascripts/map.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
// This is a manifest file that'll be compiled into map.js, which will include all the files
|
||||
// listed below.
|
||||
//
|
||||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
||||
//
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
||||
// GO AFTER THE REQUIRES BELOW.
|
||||
//
|
||||
//= require ./metamaps/metamapsJIT
|
||||
//= require ./metamaps/metamaps
|
3589
app/assets/javascripts/metamaps/metamaps.js
Normal file
3589
app/assets/javascripts/metamaps/metamaps.js
Normal file
File diff suppressed because it is too large
Load diff
11149
app/assets/javascripts/metamaps/metamapsJIT.js
Normal file
11149
app/assets/javascripts/metamaps/metamapsJIT.js
Normal file
File diff suppressed because it is too large
Load diff
1227
app/assets/javascripts/underscore.js
Normal file
1227
app/assets/javascripts/underscore.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -569,10 +569,15 @@ label[for="user_remember_me"] {
|
|||
position: absolute;
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
background: #0F1519 url('MMCCicon_mapper.png') no-repeat center center;
|
||||
/*background: #0F1519 url('MMCCicon_mapper.png') no-repeat center center;*/
|
||||
background-size: 24px 24px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sidebarAccountIcon img {
|
||||
border-radius: 17px;
|
||||
}
|
||||
|
||||
.sidebarAccountBox {
|
||||
position: absolute;
|
||||
display: none;
|
||||
|
|
|
@ -1,67 +1,45 @@
|
|||
class MappingsController < ApplicationController
|
||||
respond_to :js, :html
|
||||
|
||||
before_filter :require_user, only: [:create, :update, :destroy]
|
||||
|
||||
respond_to :json
|
||||
|
||||
#skip_before_filter :verify_authenticity_token, :only => [:create]
|
||||
|
||||
# GET mappings
|
||||
def index
|
||||
# GET /mappings/1.json
|
||||
def show
|
||||
@mapping = Mapping.find(params[:id])
|
||||
|
||||
render json: @mapping
|
||||
end
|
||||
|
||||
# GET mappings/new
|
||||
def new
|
||||
@mapping = Mapping.new
|
||||
@user = current_user
|
||||
respond_with(@mapping)
|
||||
end
|
||||
|
||||
# POST mappings
|
||||
# POST /mappings.json
|
||||
def create
|
||||
@user = current_user
|
||||
if @user
|
||||
@mapping = Mapping.new()
|
||||
@mapping = Mapping.new(params[:mapping])
|
||||
|
||||
@mapping.user = @user
|
||||
@mapping.xloc = params[:xloc] if params[:xloc]
|
||||
@mapping.yloc = params[:yloc] if params[:yloc]
|
||||
|
||||
if params[:map]
|
||||
if params[:map][:id]
|
||||
@map = Map.find(params[:map][:id])
|
||||
@map.touch(:updated_at)
|
||||
@mapping.map = @map
|
||||
end
|
||||
end
|
||||
if params[:topic]
|
||||
if params[:topic][:id]
|
||||
@topic = Topic.find(params[:topic][:id])
|
||||
@mapping.topic = @topic
|
||||
@mapping.category = "Topic"
|
||||
end
|
||||
elsif params[:synapse]
|
||||
if params[:synapse][:id]
|
||||
@topic = Synapse.find(params[:synapse][:id])
|
||||
@mapping.synapse = @synapse
|
||||
@mapping.category = "Synapse"
|
||||
end
|
||||
end
|
||||
@mapping.save()
|
||||
|
||||
#push add to map to realtime viewers of the map
|
||||
@mapping.message 'create',@user.id
|
||||
if @mapping.save
|
||||
render json: @mapping, status: :created
|
||||
else
|
||||
render json: @mapping.errors, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# GET /mappings/:id
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /mappings/:id/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# PUT /mappings/:id
|
||||
# PUT /mappings/1.json
|
||||
def update
|
||||
@mapping = Mapping.find(params[:id])
|
||||
|
||||
if @mapping.update_attributes(params[:mapping])
|
||||
head :no_content
|
||||
else
|
||||
render json: @mapping.errors, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /mappings/:id
|
||||
# DELETE /mappings/1.json
|
||||
def destroy
|
||||
@mapping = Mapping.find(params[:id])
|
||||
@mapping.destroy
|
||||
|
||||
head :no_content
|
||||
end
|
||||
end
|
||||
end
|
|
@ -69,12 +69,18 @@ class MapsController < ApplicationController
|
|||
if not @map
|
||||
redirect_to root_url and return
|
||||
end
|
||||
|
||||
|
||||
@mapjson = @map.self_as_json(@current).html_safe
|
||||
|
||||
|
||||
@alltopics = @map.topics # should limit to topics visible to user
|
||||
@allsynapses = @map.synapses # should also be limited
|
||||
@allmappings = @map.mappings
|
||||
@allmetacodes = Metacode.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html { respond_with(@map, @user) }
|
||||
format.json { respond_with(@mapjson) }
|
||||
format.html { respond_with(@allmetacodes, @allmappings, @allsynapses, @alltopics, @map, @user) }
|
||||
#format.json { respond_with(@mapjson) }
|
||||
format.json { render json: @topics }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,14 +1,21 @@
|
|||
class MetacodesController < ApplicationController
|
||||
|
||||
before_filter :require_admin
|
||||
before_filter :require_admin, except: [:index]
|
||||
|
||||
# GET /metacodes
|
||||
# GET /metacodes.json
|
||||
def index
|
||||
|
||||
@metacodes = Metacode.order("name").all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.html {
|
||||
unless authenticated? && user.admin
|
||||
redirect_to root_url, notice: "You need to be an admin for that."
|
||||
return false
|
||||
end
|
||||
render action: "index"
|
||||
}
|
||||
format.json { render json: @metacodes }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class SynapsesController < ApplicationController
|
||||
include TopicsHelper
|
||||
|
||||
before_filter :require_user, only: [:create, :update, :removefrommap, :destroy]
|
||||
before_filter :require_user, only: [:create, :update, :destroy]
|
||||
|
||||
respond_to :html, :js, :json
|
||||
respond_to :js, :json
|
||||
|
||||
# GET synapses/:id/json
|
||||
def json
|
||||
|
@ -19,108 +19,31 @@ class SynapsesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# POST synapses
|
||||
# POST /synapses
|
||||
# POST /synapses.json
|
||||
def create
|
||||
@user = current_user
|
||||
|
||||
# if the topic exists grab it and return it
|
||||
if params[:synapse][:grabSynapse] != "null"
|
||||
@synapse = Synapse.find(params[:synapse][:grabSynapse])
|
||||
# if not selecting an existing synapse, create it
|
||||
else
|
||||
@synapse = Synapse.new()
|
||||
@synapse.desc = params[:synapse][:desc]
|
||||
@synapse.topic1 = Topic.find(params[:synapse][:topic1id])
|
||||
@synapse.topic2 = Topic.find(params[:synapse][:topic2id])
|
||||
@synapse.permission = "commons"
|
||||
@synapse.category = "from-to"
|
||||
@synapse.weight = 5
|
||||
@synapse.user = @user
|
||||
@synapse.save
|
||||
end
|
||||
|
||||
if params[:synapse][:map]
|
||||
@map = Map.find(params[:synapse][:map])
|
||||
@map.touch(:updated_at)
|
||||
|
||||
@mapping = Mapping.new()
|
||||
@mapping.category = "Synapse"
|
||||
@mapping.user = @user
|
||||
@mapping.map = @map
|
||||
@mapping.synapse = @synapse
|
||||
@mapping.save
|
||||
|
||||
#push add to map to realtime viewers of the map
|
||||
@mapping.message 'create',@user.id
|
||||
|
||||
# set the permission of the synapse to whatever the permission of the
|
||||
#map is
|
||||
@synapse.permission = @map.permission
|
||||
@synapse.save
|
||||
end
|
||||
|
||||
@synapse = Synapse.new(params[:synapse])
|
||||
|
||||
respond_to do |format|
|
||||
format.html { respond_with(@user, location: synapse_url(@synapse)) }
|
||||
format.js { respond_with(@synapse) }
|
||||
if @synapse.save
|
||||
format.json { render json: @synapse, status: :created }
|
||||
else
|
||||
format.json { render json: @synapse.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# PUT synapses/:id
|
||||
# PUT /synapses/1
|
||||
# PUT /synapses/1.json
|
||||
def update
|
||||
@current = current_user
|
||||
@synapse = Synapse.find(params[:id]).authorize_to_edit(@current)
|
||||
|
||||
if @synapse
|
||||
@permissionBefore = @synapse.permission
|
||||
|
||||
if params[:synapse]
|
||||
@synapse.desc = params[:synapse][:desc] if params[:synapse][:desc]
|
||||
@synapse.category = params[:synapse][:category] if params[:synapse][:category]
|
||||
@synapse.permission = params[:synapse][:permission] if params[:synapse][:permission]
|
||||
end
|
||||
if params[:node1_id] and params[:node1_id][:node1]
|
||||
@synapse.topic1 = Topic.find(params[:node1_id][:node1])
|
||||
end
|
||||
if params[:node2_id] and params[:node2_id][:node2]
|
||||
@synapse.topic2 = Topic.find(params[:node2_id][:node2])
|
||||
end
|
||||
@synapse.save
|
||||
|
||||
@permissionAfter = @synapse.permission
|
||||
|
||||
#push notify to anyone viewing this synapse on a map in realtime (see mapping.rb to understand the 'message' action)
|
||||
# if the topic was private and is being switched to PU or CO it is the same as being created for other viewers
|
||||
if @permissionBefore == "private" and @permissionAfter != "private"
|
||||
@synapse.message 'create',@current.id
|
||||
elsif @permissionBefore != "private" and @permissionAfter == "private"
|
||||
@synapse.message 'destroy',@current.id
|
||||
else
|
||||
@synapse.message 'update',@current.id
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.json { respond_with(@synapse) }
|
||||
end
|
||||
end
|
||||
|
||||
# POST synapses/:map_id/:synapse_id/removefrommap
|
||||
def removefrommap
|
||||
@user = current_user
|
||||
|
||||
@mapping = Mapping.find_by_synapse_id_and_map_id(params[:synapse_id],params[:map_id])
|
||||
|
||||
Map.find(params[:map_id]).touch(:updated_at)
|
||||
|
||||
#push notify to anyone viewing same map in realtime (see mapping.rb to understand the 'message' action)
|
||||
@mapping.message 'destroy',@user.id
|
||||
|
||||
@mapping.delete
|
||||
@synapse = Synapse.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
if @synapse.update_attributes(params[:synapse])
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.json { render json: @synapse.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -140,5 +63,9 @@ class SynapsesController < ApplicationController
|
|||
end
|
||||
|
||||
@synapse.delete if @synapse
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render :json => "success" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class TopicsController < ApplicationController
|
||||
include TopicsHelper
|
||||
|
||||
before_filter :require_user, only: [:create, :update, :removefrommap, :destroy]
|
||||
before_filter :require_user, only: [:create, :update, :destroy]
|
||||
|
||||
respond_to :html, :js, :json
|
||||
|
||||
|
@ -34,7 +34,8 @@ class TopicsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html { respond_with(@topic, @user) }
|
||||
format.json { respond_with(@relatives) }
|
||||
#format.json { respond_with(@relatives) }
|
||||
format.json { render :json => @topic }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -48,140 +49,36 @@ class TopicsController < ApplicationController
|
|||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render :json => @topic.self_as_json }
|
||||
#format.json { render :json => @topic.self_as_json }
|
||||
format.json { render :json => @topic.to_json }
|
||||
end
|
||||
end
|
||||
|
||||
# POST topics
|
||||
# POST /topics
|
||||
# POST /topics.json
|
||||
def create
|
||||
|
||||
@user = current_user
|
||||
|
||||
# if the topic exists grab it and return it
|
||||
if params[:topic][:grabTopic] != "null"
|
||||
@topic = Topic.find(params[:topic][:grabTopic])
|
||||
# if the topic doesn't exist yet, create it
|
||||
else
|
||||
@topic = Topic.new()
|
||||
@topic.name = params[:topic][:name]
|
||||
@topic.desc = ""
|
||||
@topic.link = ""
|
||||
@topic.permission = 'commons'
|
||||
@topic.metacode = Metacode.find_by_name(params[:topic][:metacode])
|
||||
@topic.user = @user
|
||||
|
||||
#if being created on a map, set topic by default to whatever permissions the map is
|
||||
if params[:topic][:map]
|
||||
@map = Map.find(params[:topic][:map])
|
||||
@topic.permission = @map.permission
|
||||
end
|
||||
@topic = Topic.new(params[:topic])
|
||||
|
||||
@topic.save
|
||||
end
|
||||
|
||||
# pass on to the topic create js whether it's being created with a synapse
|
||||
@synapse = "false"
|
||||
if params[:topic][:addSynapse] == "true"
|
||||
@synapse = "true"
|
||||
end
|
||||
|
||||
# also create an object to return the position to the canvas
|
||||
@position = Hash.new()
|
||||
@position['x'] = params[:topic][:x]
|
||||
@position['y'] = params[:topic][:y]
|
||||
|
||||
# set this for the case where the topic is being created on a map.
|
||||
@mapping = nil
|
||||
if params[:topic][:map]
|
||||
@map = Map.find(params[:topic][:map])
|
||||
@map.touch(:updated_at)
|
||||
|
||||
@mapping = Mapping.new()
|
||||
@mapping.category = "Topic"
|
||||
@mapping.user = @user
|
||||
@mapping.map = @map
|
||||
@mapping.topic = @topic
|
||||
@mapping.xloc = params[:topic][:x]
|
||||
@mapping.yloc = params[:topic][:y]
|
||||
@mapping.save
|
||||
|
||||
#push add to map to realtime viewers of the map
|
||||
@mapping.message 'create',@user.id
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { respond_with(@user, location: topic_url(@topic)) }
|
||||
format.js { respond_with(@topic, @mapping, @synapse, @position) }
|
||||
end
|
||||
end
|
||||
|
||||
# PUT topics/:id
|
||||
def update
|
||||
@current = current_user
|
||||
@topic = Topic.find(params[:id]).authorize_to_edit(@current)
|
||||
|
||||
if @topic
|
||||
if params[:topic]
|
||||
@permissionBefore = @topic.permission
|
||||
|
||||
@topic.name = params[:topic][:name] if params[:topic][:name]
|
||||
@topic.desc = params[:topic][:desc] if params[:topic][:desc]
|
||||
@topic.link = params[:topic][:link] if params[:topic][:link]
|
||||
@topic.permission = params[:topic][:permission] if params[:topic][:permission]
|
||||
@topic.metacode = Metacode.find_by_name(params[:topic][:metacode]) if params[:topic][:metacode]
|
||||
|
||||
@permissionAfter = @topic.permission
|
||||
end
|
||||
@topic.save
|
||||
|
||||
#push notify to anyone viewing this topic on a map in realtime (see mapping.rb to understand the 'message' action)
|
||||
# if the topic was private and is being switched to PU or CO it is the same as being created for other viewers
|
||||
if @permissionBefore == "private" and @permissionAfter != "private"
|
||||
@topic.message 'create',@current.id
|
||||
elsif @permissionBefore != "private" and @permissionAfter == "private"
|
||||
@topic.message 'destroy',@current.id
|
||||
else
|
||||
@topic.message 'update',@current.id
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render :json => @topic.self_as_json }
|
||||
format.json { render :json => @topic.self_as_json }
|
||||
end
|
||||
end
|
||||
|
||||
# POST topics/:map_id/:topic_id/removefrommap
|
||||
def removefrommap
|
||||
@current = current_user
|
||||
@mapping = Mapping.find_by_topic_id_and_map_id(params[:topic_id],params[:map_id])
|
||||
|
||||
@map = Map.find(params[:map_id])
|
||||
@map.touch(:updated_at)
|
||||
@topic = Topic.find(params[:topic_id])
|
||||
@mappings = @map.mappings.select{|m|
|
||||
if m.synapse != nil
|
||||
m.synapse.topic1 == @topic || m.synapse.topic2 == @topic
|
||||
if @topic.save
|
||||
format.json { render json: @topic, status: :created }
|
||||
else
|
||||
false
|
||||
format.json { render json: @topic.errors, status: :unprocessable_entity }
|
||||
end
|
||||
}
|
||||
@mappings.each do |m|
|
||||
|
||||
#push notify to anyone viewing same map in realtime (see mapping.rb to understand the 'message' action)
|
||||
m.message 'destroy',@current.id
|
||||
|
||||
m.delete
|
||||
end
|
||||
|
||||
|
||||
#push notify to anyone viewing same map in realtime (see mapping.rb to understand the 'message' action)
|
||||
#@mapping.message 'destroy',@current.id
|
||||
|
||||
@mapping.delete
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
||||
# PUT /topics/1
|
||||
# PUT /topics/1.json
|
||||
def update
|
||||
@topic = Topic.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @topic.update_attributes(params[:topic])
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.json { render json: @topic.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -223,8 +120,8 @@ class TopicsController < ApplicationController
|
|||
@topic.delete
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
respond_to do |format|
|
||||
format.js { render :json => "success" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
class UsersController < ApplicationController
|
||||
|
||||
before_filter :require_user, only: [:edit, :update]
|
||||
before_filter :require_user, only: [:edit, :update, :updatemetacodes]
|
||||
|
||||
respond_to :html, :json
|
||||
|
||||
# GET /users/1.json
|
||||
def show
|
||||
@user = User.find(params[:id])
|
||||
|
||||
render json: @user
|
||||
end
|
||||
|
||||
# GET /user/edit
|
||||
def edit
|
||||
@user = current_user
|
||||
|
|
|
@ -38,8 +38,8 @@ end
|
|||
#build a json object of a map
|
||||
def self_as_json(current)
|
||||
Jbuilder.encode do |json|
|
||||
@topics = self.topics
|
||||
@synapses = self.synapses
|
||||
@topics = self.topics.dup
|
||||
@synapses = self.synapses.dup
|
||||
|
||||
json.array!(@topics.delete_if{|topic| not topic.authorize_to_view(current)}) do |topic|
|
||||
|
||||
|
@ -57,7 +57,9 @@ end
|
|||
@synapsedata['$userid'] = synapse.user.id
|
||||
@synapsedata['$username'] = synapse.user.name
|
||||
@synapsedata['$direction'] = [synapse.node1_id.to_s(), synapse.node2_id.to_s()]
|
||||
@synapsedata['$permission'] = synapse.permission
|
||||
@synapsedata['$permission'] = synapse.permission
|
||||
@mapping = Mapping.find_by_synapse_id_and_map_id(synapse.id,self.id)
|
||||
@synapsedata['$mappingid'] = @mapping.id
|
||||
json.data @synapsedata
|
||||
end
|
||||
|
||||
|
@ -73,19 +75,20 @@ end
|
|||
@topicdata['$desc'] = topic.desc
|
||||
@topicdata['$link'] = topic.link
|
||||
@topicdata['$metacode'] = topic.metacode.name
|
||||
@topicdata['$inmaps'] = @inmaps
|
||||
@topicdata['$inmapsString'] = @mapsString
|
||||
@topicdata['$synapseCount'] = topic.synapses.count
|
||||
@topicdata['$inmaps'] = @inmaps
|
||||
@topicdata['$inmapsString'] = @mapsString
|
||||
@topicdata['$synapseCount'] = topic.synapses.count
|
||||
@topicdata['$userid'] = topic.user.id
|
||||
@topicdata['$username'] = topic.user.name
|
||||
@mapping = Mapping.find_by_topic_id_and_map_id(topic.id,self.id)
|
||||
@topicdata['$xloc'] = @mapping.xloc
|
||||
@topicdata['$yloc'] = @mapping.yloc
|
||||
@topicdata['$mappingid'] = @mapping.id
|
||||
@topicdata['$permission'] = topic.permission
|
||||
@topicdata['$date'] = topic.created_at.strftime("%m/%d/%Y")
|
||||
@topicdata['$permission'] = topic.permission
|
||||
@topicdata['$date'] = topic.created_at.strftime("%m/%d/%Y")
|
||||
@topicdata['$id'] = topic.id
|
||||
json.data @topicdata
|
||||
json.id topic.id
|
||||
json.id @mapping.id
|
||||
json.name topic.name
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,4 +14,4 @@ class Metacode < ActiveRecord::Base
|
|||
return false
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -64,6 +64,6 @@
|
|||
<div class="clearfloat"></div>
|
||||
|
||||
<script>
|
||||
MetamapsModel.selectedMetacodeSet = "metacodeset-<%= selectedSet %>";
|
||||
MetamapsModel.selectedMetacodeSetIndex = <%= index %>;
|
||||
Metamaps.Settings.selectedMetacodeSet = "metacodeset-<%= selectedSet %>";
|
||||
Metamaps.Settings.selectedMetacodeSetIndex = <%= index %>;
|
||||
</script>
|
|
@ -29,11 +29,15 @@
|
|||
</script>
|
||||
<%= stylesheet_link_tag "application", :media => "all" %>
|
||||
<%= javascript_include_tag "application" %>
|
||||
<% if controller_name == "maps" && action_name == "show" %>
|
||||
<%= javascript_include_tag "map" %>
|
||||
<% end %>
|
||||
<script type="text/javascript" src="//use.typekit.net/tki2nyo.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
<script type="text/javascript" src="//use.typekit.net/obp7wss.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
<%= csrf_meta_tags %>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no">
|
||||
</head>
|
||||
<body class="<%= (action_name == "show") ? "mapBody" : "" %>" >
|
||||
|
||||
|
@ -54,7 +58,9 @@
|
|||
<%= render :partial => 'layouts/templates' %>
|
||||
</div>
|
||||
<div class="sidebarAccount">
|
||||
<div class="sidebarAccountIcon"></div>
|
||||
<div class="sidebarAccountIcon">
|
||||
<% if user && user.image %><%= image_tag user.image.url(:thumb), :size => "35x35" %><% end %>
|
||||
</div>
|
||||
<div class="sidebarAccountBox <%= authenticated? ? 'loggedin' : 'loggedout' %>">
|
||||
<%= render :partial => 'layouts/account' %>
|
||||
</div>
|
||||
|
|
|
@ -92,42 +92,9 @@
|
|||
|
||||
|
||||
<script>
|
||||
var dragged = 0;
|
||||
mapid = <%= @map.id %>;
|
||||
<% if (@map.permission == "commons" && authenticated? ) || @map.user == user %>
|
||||
mapperm = true;
|
||||
<% end %>
|
||||
|
||||
viewMode = "graph";
|
||||
json = <%= @mapjson %>;
|
||||
if (json.length > 0) {
|
||||
$(window).load(function () {
|
||||
<% if (@map.arranged) %>
|
||||
initialize("arranged");
|
||||
<% else %>
|
||||
initialize("chaotic");
|
||||
<% end %>
|
||||
});
|
||||
} else {
|
||||
$(window).load(function () {
|
||||
initialize("chaotic", true);
|
||||
});
|
||||
}
|
||||
|
||||
<% if authenticated? && (@map.permission == "commons" || @map.user == user) %>
|
||||
// this is for the heroku staging environment
|
||||
window.realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com');
|
||||
|
||||
// this is for metamaps.cc
|
||||
//window.realtime.socket = io.connect('http://metamaps.cc:5001');
|
||||
|
||||
// this is for localhost development
|
||||
//window.realtime.socket = io.connect('http://localhost:5001');
|
||||
|
||||
window.realtime.socket.on('connect', function () {
|
||||
console.log('socket connected');
|
||||
window.realtime.setupSocket();
|
||||
});
|
||||
<% end %>
|
||||
|
||||
Metamaps.Active.Map = <%= @map.to_json.html_safe %>;
|
||||
Metamaps.Metacodes = <%= @allmetacodes.to_json.html_safe %>;
|
||||
Metamaps.Topics = <%= @alltopics.to_json.html_safe %>;
|
||||
Metamaps.Synapses = <%= @allsynapses.to_json.html_safe %>;
|
||||
Metamaps.Mappings = <%= @allmappings.to_json.html_safe %>;
|
||||
</script>
|
|
@ -70,7 +70,7 @@ ISSAD::Application.configure do
|
|||
# config.action_controller.asset_host = "http://assets.example.com"
|
||||
|
||||
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
||||
# config.assets.precompile += %w( search.js )
|
||||
config.assets.precompile += %w( metamaps.js )
|
||||
|
||||
# Disable delivery errors, bad email addresses will be ignored
|
||||
# config.action_mailer.raise_delivery_errors = false
|
||||
|
|
|
@ -44,7 +44,7 @@ ISSAD::Application.routes.draw do
|
|||
end
|
||||
match 'user/updatemetacodes', to: 'users#updatemetacodes', via: :post, as: :updatemetacodes
|
||||
|
||||
resources :users, except: [:show, :index]
|
||||
resources :users, except: [:index]
|
||||
|
||||
resources :mappings
|
||||
|
||||
|
|
Loading…
Reference in a new issue