converted all references to items to topics
This commit is contained in:
parent
0d4e694a4c
commit
131e27aefe
61 changed files with 1142 additions and 212 deletions
BIN
app/assets/images/ui-bg_flat_75_ffffff_40x100.png
Normal file
BIN
app/assets/images/ui-bg_flat_75_ffffff_40x100.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 178 B |
|
@ -1,6 +1,6 @@
|
|||
// create filters for maps, and for card views
|
||||
|
||||
// keep an array of which item categories are currently visible.
|
||||
// keep an array of which metacodes are currently visible.
|
||||
var categoryVisible = new Object();
|
||||
|
||||
categoryVisible['Group'] = true;
|
||||
|
@ -44,7 +44,7 @@ function switchVisible(category, duration) {
|
|||
function hideCategory(category, duration) {
|
||||
if (duration == null) duration = 500;
|
||||
Mconsole.graph.eachNode( function (n) {
|
||||
if (n.getData('itemcatname') == category) {
|
||||
if (n.getData('metacode') == category) {
|
||||
n.setData('alpha', 0.4, 'end');
|
||||
n.eachAdjacency(function(adj) {
|
||||
adj.setData('alpha', 0.4, 'end');
|
||||
|
@ -61,7 +61,7 @@ function hideCategory(category, duration) {
|
|||
function showCategory(category, duration) {
|
||||
if (duration == null) duration = 500;
|
||||
Mconsole.graph.eachNode( function (n) {
|
||||
if (n.getData('itemcatname') == category) {
|
||||
if (n.getData('metacode') == category) {
|
||||
n.setData('alpha', 1, 'end');
|
||||
n.eachAdjacency(function(adj) {
|
||||
adj.setData('alpha', 1, 'end');
|
||||
|
@ -130,31 +130,31 @@ function onCanvasSearch(name,mapID,mapperID) {
|
|||
if (name != null) {
|
||||
if (n.name.indexOf(name) !== -1 && name != "") {
|
||||
n.setData('onCanvas', true);
|
||||
//$('.name.item_' + n.id).css('display','block');
|
||||
//$('.name.topic_' + n.id).css('display','block');
|
||||
}
|
||||
else {
|
||||
n.setData('onCanvas', false);
|
||||
//$('.name.item_' + n.id).css('display','none');
|
||||
//$('.name.topic_' + n.id).css('display','none');
|
||||
}
|
||||
}
|
||||
else if (mapID != null) {
|
||||
if (n.getData('inmaps').indexOf(parseInt(mapID)) !== -1) {
|
||||
n.setData('onCanvas', true);
|
||||
//$('.name.item_' + n.id).css('display','block');
|
||||
//$('.name.topic_' + n.id).css('display','block');
|
||||
}
|
||||
else {
|
||||
n.setData('onCanvas', false);
|
||||
//$('.name.item_' + n.id).css('display','none');
|
||||
//$('.name.topic_' + n.id).css('display','none');
|
||||
}
|
||||
}
|
||||
else if (mapperID != null) {
|
||||
if (n.getData('userid').toString() == mapperID) {
|
||||
n.setData('onCanvas', true);
|
||||
//$('.name.item_' + n.id).css('display','block');
|
||||
//$('.name.topic_' + n.id).css('display','block');
|
||||
}
|
||||
else {
|
||||
n.setData('onCanvas', false);
|
||||
//$('.name.item_' + n.id).css('display','none');
|
||||
//$('.name.topic_' + n.id).css('display','none');
|
||||
}
|
||||
}
|
||||
Mconsole.plot();
|
||||
|
@ -194,7 +194,7 @@ $(document).ready(function() {
|
|||
Mconsole.graph.eachNode( function (n) {
|
||||
n.setData('inCommons', false);
|
||||
n.setData('onCanvas', false);
|
||||
//$('.name.item_' + n.id).css('display','block');
|
||||
//$('.name.topic_' + n.id).css('display','block');
|
||||
});
|
||||
Mconsole.plot();
|
||||
$('#closeFind, #findWhere').css('display','none');
|
||||
|
@ -372,7 +372,7 @@ $(document).ready(function() {
|
|||
$('.find_topic_by_name #topic_by_name_input').bind('railsAutocomplete.select', function(event, data){
|
||||
/* Do something here */
|
||||
if (data.item.id != undefined) {
|
||||
window.open("/items/" + data.item.id)
|
||||
window.open("/topics/" + data.item.id)
|
||||
}
|
||||
$('.find_topic_by_name #topic_by_name_input').val('');
|
||||
});
|
||||
|
@ -471,7 +471,7 @@ $(document).ready(function() {
|
|||
event.preventDefault();
|
||||
});
|
||||
|
||||
// toggle visibility of item categories based on status in the filters list
|
||||
// toggle visibility of topics with metacodes based on status in the filters list
|
||||
$('.find_topic_by_metacode ul li').click(function(event) {
|
||||
obj = document.getElementById('container');
|
||||
|
||||
|
@ -485,7 +485,7 @@ $(document).ready(function() {
|
|||
}
|
||||
// this means that we are on a card view
|
||||
else {
|
||||
$('.item').fadeIn('slow');
|
||||
$('.topic').fadeIn('slow');
|
||||
}
|
||||
$('.find_topic_by_metacode ul li').not('#hideAll, #showAll').removeClass('toggledOff');
|
||||
for (var catVis in categoryVisible) {
|
||||
|
@ -499,7 +499,7 @@ $(document).ready(function() {
|
|||
}
|
||||
// this means that we are on a card view
|
||||
else {
|
||||
$('.item').fadeOut('slow');
|
||||
$('.topic').fadeOut('slow');
|
||||
}
|
||||
$('.find_topic_by_metacode ul li').not('#hideAll, #showAll').addClass('toggledOff');
|
||||
for (var catVis in categoryVisible) {
|
||||
|
|
|
@ -61,15 +61,15 @@ function graphSettings(type) {
|
|||
},
|
||||
onDragEnd: function() {
|
||||
if (tempInit && tempNode2 == null) {
|
||||
$('#item_addSynapse').val("true");
|
||||
$('#new_item').fadeIn('fast');
|
||||
$('#topic_addSynapse').val("true");
|
||||
$('#new_topic').fadeIn('fast');
|
||||
addMetacode();
|
||||
$('#item_name').focus();
|
||||
$('#topic_name').focus();
|
||||
}
|
||||
else if (tempInit && tempNode2 != null) {
|
||||
$('#item_addSynapse').val("false");
|
||||
$('#synapse_item1id').val(tempNode.id);
|
||||
$('#synapse_item2id').val(tempNode2.id);
|
||||
$('#topic_addSynapse').val("false");
|
||||
$('#synapse_topic1id').val(tempNode.id);
|
||||
$('#synapse_topic2id').val(tempNode2.id);
|
||||
$('#new_synapse').fadeIn('fast');
|
||||
$('#synapse_desc').focus();
|
||||
tempNode = null;
|
||||
|
@ -81,9 +81,9 @@ function graphSettings(type) {
|
|||
tempNode = null;
|
||||
tempNode2 = null;
|
||||
tempInit = false;
|
||||
$('#item_addSynapse').val("false");
|
||||
$('#item_item1id').val(0);
|
||||
$('#item_item2id').val(0);
|
||||
$('#topic_addSynapse').val("false");
|
||||
$('#topic_topic1id').val(0);
|
||||
$('#topic_topic2id').val(0);
|
||||
Mconsole.plot();
|
||||
},
|
||||
//Implement the same handler for touchscreens
|
||||
|
@ -112,14 +112,14 @@ function graphSettings(type) {
|
|||
// on label creation and only for DOM labels (not native canvas ones).
|
||||
onCreateLabel: function (domElement, node) {
|
||||
var html =
|
||||
'<div class="CardOnGraph" title="Click to Hide" id="item_' + node.id + '"><p class="type">' + node.getData("itemcatname") + '</p>' +
|
||||
'<img alt="' + node.getData("itemcatname") + '" class="icon" height="50" src="' + imgArray[node.getData("itemcatname")].src + '" width="50" />' +
|
||||
'<div class="scroll"><a href="/items/' + node.id + '" class="title">' + node.name + '</a>' +
|
||||
'<div class="CardOnGraph" title="Click to Hide" id="topic_' + node.id + '"><p class="type">' + node.getData("metacode") + '</p>' +
|
||||
'<img alt="' + node.getData("metacode") + '" class="icon" height="50" src="' + imgArray[node.getData("metacode")].src + '" width="50" />' +
|
||||
'<div class="scroll"><a href="/topics/' + node.id + '" class="title">' + node.name + '</a>' +
|
||||
'<div class="contributor">Added by: <a href="/users/' + node.getData('userid') + '">' + node.getData('username') + '</a></div>' +
|
||||
'<div class="desc"><p>' + node.getData('desc') + '</p></div></div>' +
|
||||
'<a href="' + node.getData('link') + '" class="link" target="_blank">' + node.getData('link') + '</a></div>';
|
||||
var showCard = document.createElement('div');
|
||||
showCard.className = 'showcard item_' + node.id;
|
||||
showCard.className = 'showcard topic_' + node.id;
|
||||
showCard.innerHTML = html;
|
||||
showCard.style.display = "none";
|
||||
domElement.appendChild(showCard);
|
||||
|
@ -139,7 +139,7 @@ function graphSettings(type) {
|
|||
modes: ['edge-property:lineWidth:color'],
|
||||
duration: 500
|
||||
});
|
||||
$('.showcard.item_' + node.id).fadeOut('fast', function(){
|
||||
$('.showcard.topic_' + node.id).fadeOut('fast', function(){
|
||||
$('.name').css('display','block');
|
||||
Mconsole.plot();
|
||||
});
|
||||
|
@ -149,7 +149,7 @@ function graphSettings(type) {
|
|||
// to the main node label
|
||||
var nameContainer = document.createElement('span'),
|
||||
style = nameContainer.style;
|
||||
nameContainer.className = 'name item_' + node.id;
|
||||
nameContainer.className = 'name topic_' + node.id;
|
||||
nameContainer.innerHTML = '<div class="label">' + node.name + '</div>';
|
||||
domElement.appendChild(nameContainer);
|
||||
style.fontSize = "0.9em";
|
||||
|
@ -239,15 +239,15 @@ function graphSettings(type) {
|
|||
},
|
||||
onDragEnd: function() {
|
||||
if (tempInit && tempNode2 == null) {
|
||||
$('#item_addSynapse').val("true");
|
||||
$('#new_item').fadeIn('fast');
|
||||
$('#topic_addSynapse').val("true");
|
||||
$('#new_topic').fadeIn('fast');
|
||||
addMetacode();
|
||||
$('#item_name').focus();
|
||||
$('#topic_name').focus();
|
||||
}
|
||||
else if (tempInit && tempNode2 != null) {
|
||||
$('#item_addSynapse').val("false");
|
||||
$('#synapse_item1id').val(tempNode.id);
|
||||
$('#synapse_item2id').val(tempNode2.id);
|
||||
$('#topic_addSynapse').val("false");
|
||||
$('#synapse_topic1id').val(tempNode.id);
|
||||
$('#synapse_topic2id').val(tempNode2.id);
|
||||
$('#new_synapse').fadeIn('fast');
|
||||
$('#synapse_desc').focus();
|
||||
tempNode = null;
|
||||
|
@ -294,14 +294,14 @@ function graphSettings(type) {
|
|||
// on label creation and only for DOM labels (not native canvas ones).
|
||||
onCreateLabel: function (domElement, node) {
|
||||
var html =
|
||||
'<div class="CardOnGraph" title="Click to Hide" id="item_' + node.id + '"><p class="type">' + node.getData("itemcatname") + '</p>' +
|
||||
'<img alt="' + node.getData("itemcatname") + '" class="icon" height="50" src="' + imgArray[node.getData("itemcatname")].src + '" width="50" />' +
|
||||
'<div class="scroll"><a href="/items/' + node.id + '" class="title">' + node.name + '</a>' +
|
||||
'<div class="CardOnGraph" title="Click to Hide" id="topic_' + node.id + '"><p class="type">' + node.getData("metacode") + '</p>' +
|
||||
'<img alt="' + node.getData("metacode") + '" class="icon" height="50" src="' + imgArray[node.getData("metacode")].src + '" width="50" />' +
|
||||
'<div class="scroll"><a href="/topics/' + node.id + '" class="title">' + node.name + '</a>' +
|
||||
'<div class="contributor">Added by: <a href="/users/' + node.getData('userid') + '">' + node.getData('username') + '</a></div>' +
|
||||
'<div class="desc"><p>' + node.getData('desc') + '</p></div></div>' +
|
||||
'<a href="' + node.getData('link') + '" class="link" target="_blank">' + node.getData('link') + '</a></div>';
|
||||
var showCard = document.createElement('div');
|
||||
showCard.className = 'showcard item_' + node.id;
|
||||
showCard.className = 'showcard topic_' + node.id;
|
||||
showCard.innerHTML = html;
|
||||
showCard.style.display = "none";
|
||||
domElement.appendChild(showCard);
|
||||
|
@ -322,7 +322,7 @@ function graphSettings(type) {
|
|||
modes: ['edge-property:lineWidth:color'],
|
||||
duration: 500
|
||||
});
|
||||
$('.showcard.item_' + node.id).fadeOut('fast', function(){
|
||||
$('.showcard.topic_' + node.id).fadeOut('fast', function(){
|
||||
$('.name').css('display','block');
|
||||
Mconsole.plot();
|
||||
});
|
||||
|
@ -333,7 +333,7 @@ function graphSettings(type) {
|
|||
// to the main node label
|
||||
var nameContainer = document.createElement('span'),
|
||||
style = nameContainer.style;
|
||||
nameContainer.className = 'name item_' + node.id;
|
||||
nameContainer.className = 'name topic_' + node.id;
|
||||
nameContainer.innerHTML = '<div class="label">' + node.name + '</div>';
|
||||
domElement.appendChild(nameContainer);
|
||||
style.fontSize = "0.9em";
|
||||
|
@ -410,7 +410,7 @@ var nodeSettings = {
|
|||
'render': function (node, canvas) {
|
||||
var pos = node.pos.getc(true),
|
||||
dim = node.getData('dim'),
|
||||
cat = node.getData('itemcatname'),
|
||||
cat = node.getData('metacode'),
|
||||
inCommons = node.getData('inCommons'),
|
||||
onCanvas = node.getData('onCanvas'),
|
||||
ctx = canvas.getCtx();
|
||||
|
@ -502,8 +502,8 @@ function selectNodeOnClickHandler(node) {
|
|||
|
||||
$('.showcard').css('display','none');
|
||||
$('.name').css('display','block');
|
||||
$('.name.item_' + node.id).css('display','none');
|
||||
$('.showcard.item_' + node.id).fadeIn('fast');
|
||||
$('.name.topic_' + node.id).css('display','none');
|
||||
$('.showcard.topic_' + node.id).fadeIn('fast');
|
||||
|
||||
//set final styles
|
||||
Mconsole.graph.eachNode(function (n) {
|
||||
|
@ -552,18 +552,18 @@ function canvasDoubleClickHandler(canvasLoc,e) {
|
|||
|
||||
if (now - storedTime < TOLERANCE) {
|
||||
//pop up node creation :)
|
||||
$('#item_grabItem').val("null");
|
||||
$('#item_addSynapse').val("false");
|
||||
document.getElementById('new_item').style.left = e.x + "px";
|
||||
document.getElementById('new_item').style.top = e.y + "px";
|
||||
$('#item_x').val(canvasLoc.x);
|
||||
$('#item_y').val(canvasLoc.y);
|
||||
$('#new_item').fadeIn('fast');
|
||||
$('#topic_grabTopic').val("null");
|
||||
$('#topic_addSynapse').val("false");
|
||||
document.getElementById('new_topic').style.left = e.x + "px";
|
||||
document.getElementById('new_topic').style.top = e.y + "px";
|
||||
$('#topic_x').val(canvasLoc.x);
|
||||
$('#topic_y').val(canvasLoc.y);
|
||||
$('#new_topic').fadeIn('fast');
|
||||
addMetacode();
|
||||
$('#item_name').focus();
|
||||
$('#topic_name').focus();
|
||||
} else {
|
||||
canvasDoubleClickHandlerObject.storedTime = now;
|
||||
$('#new_item').fadeOut('fast');
|
||||
$('#new_topic').fadeOut('fast');
|
||||
$('#new_synapse').fadeOut('fast');
|
||||
tempInit = false;
|
||||
tempNode = null;
|
||||
|
@ -576,7 +576,7 @@ function canvasDoubleClickHandler(canvasLoc,e) {
|
|||
function clickDragOnTopic(node, eventInfo, e) {
|
||||
if (node && !node.nodeFrom) {
|
||||
$('#new_synapse').fadeOut('fast');
|
||||
$('#new_item').fadeOut('fast');
|
||||
$('#new_topic').fadeOut('fast');
|
||||
var pos = eventInfo.getPos();
|
||||
// if it's a left click, move the node
|
||||
if (e.button == 0 && !e.altKey ) {
|
||||
|
@ -608,15 +608,15 @@ function clickDragOnTopic(node, eventInfo, e) {
|
|||
n.setData('dim', 25, 'current');
|
||||
});
|
||||
//pop up node creation :)
|
||||
$('#item_grabItem').val("null");
|
||||
$('#topic_grabTopic').val("null");
|
||||
var myX = e.x - 110;
|
||||
var myY = e.y - 30;
|
||||
document.getElementById('new_item').style.left = myX + "px";
|
||||
document.getElementById('new_item').style.top = myY + "px";
|
||||
document.getElementById('new_topic').style.left = myX + "px";
|
||||
document.getElementById('new_topic').style.top = myY + "px";
|
||||
document.getElementById('new_synapse').style.left = myX + "px";
|
||||
document.getElementById('new_synapse').style.top = myY + "px";
|
||||
$('#item_x').val(eventInfo.getPos().x);
|
||||
$('#item_y').val(eventInfo.getPos().y);
|
||||
$('#topic_x').val(eventInfo.getPos().x);
|
||||
$('#topic_y').val(eventInfo.getPos().y);
|
||||
Mconsole.plot();
|
||||
renderMidArrow({ x: tempNode.pos.getc().x, y: tempNode.pos.getc().y }, { x: pos.x, y: pos.y }, 13, false, Mconsole.canvas);
|
||||
Mconsole.fx.plotNode(tempNode, Mconsole.canvas);
|
||||
|
|
|
@ -25,14 +25,14 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
|
|||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#new_item, #new_synapse').bind('contextmenu', function(e){
|
||||
$('#new_topic, #new_synapse').bind('contextmenu', function(e){
|
||||
return false;
|
||||
});
|
||||
|
||||
/// this is for the topic creation autocomplete field
|
||||
$('#item_name').bind('railsAutocomplete.select', function(event, data){
|
||||
$('#topic_name').bind('railsAutocomplete.select', function(event, data){
|
||||
if (data.item.id != undefined) {
|
||||
$('#item_grabItem').val(data.item.id);
|
||||
$('#topic_grabTopic').val(data.item.id);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@
|
|||
if ( items[this.frontIndex] === undefined ) { return; } // Images might not have loaded yet.
|
||||
$(options.titleBox).html( $(items[this.frontIndex].image).attr('title'));
|
||||
// METAMAPS CODE
|
||||
$('#item_metacode').val( $(items[this.frontIndex].image).attr('title'));
|
||||
$('#topic_metacode').val( $(items[this.frontIndex].image).attr('title'));
|
||||
// NOT METAMAPS CODE
|
||||
$(options.altBox).html( $(items[this.frontIndex].image).attr('alt'));
|
||||
};
|
||||
|
|
6
app/assets/javascripts/topics.js.coffee
Normal file
6
app/assets/javascripts/topics.js.coffee
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
|
||||
jQuery ->
|
||||
$('.best_in_place').best_in_place()
|
|
@ -93,7 +93,7 @@ a {
|
|||
.new_user,
|
||||
.new_map,
|
||||
.edit_user,
|
||||
.edit_item,
|
||||
.edit_topic,
|
||||
.edit_synapse,
|
||||
.edit_map,
|
||||
.invite {
|
||||
|
@ -135,18 +135,18 @@ a {
|
|||
right:3px;
|
||||
}
|
||||
|
||||
.anypage .new_item {
|
||||
.anypage .new_topic {
|
||||
width:300px;
|
||||
margin:-40px 0 0 -50px;
|
||||
}
|
||||
|
||||
.anypage .new_item,
|
||||
.anypage .new_topic,
|
||||
.anypage .new_synapse {
|
||||
display: block;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.anypage #item_name {
|
||||
.anypage #topic_name {
|
||||
width:200px;
|
||||
position:absolute;
|
||||
top:40px;
|
||||
|
|
10
app/assets/stylesheets/jquery-ui.css
vendored
10
app/assets/stylesheets/jquery-ui.css
vendored
|
@ -152,18 +152,18 @@ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra pad
|
|||
|
||||
.ui-menu { list-style:none; padding: 2px; margin: 0; display:block; outline: none; }
|
||||
.ui-menu .ui-menu { margin-top: -3px; position: absolute; }
|
||||
.ui-menu .ui-menu-item { margin: 0; padding: 0; zoom: 1; width: 100%; }
|
||||
.ui-menu .ui-menu-topic { margin: 0; padding: 0; zoom: 1; width: 100%; }
|
||||
.ui-menu .ui-menu-divider { margin: 5px -2px 5px -2px; height: 0; font-size: 0; line-height: 0; border-width: 1px 0 0 0; }
|
||||
.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.5; zoom: 1; font-weight: normal; }
|
||||
.ui-menu .ui-menu-item a.ui-state-focus,
|
||||
.ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; }
|
||||
.ui-menu .ui-menu-topic a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.5; zoom: 1; font-weight: normal; }
|
||||
.ui-menu .ui-menu-topic a.ui-state-focus,
|
||||
.ui-menu .ui-menu-topic a.ui-state-active { font-weight: normal; margin: -1px; }
|
||||
|
||||
.ui-menu .ui-state-disabled { font-weight: normal; margin: .4em 0 .2em; line-height: 1.5; }
|
||||
.ui-menu .ui-state-disabled a { cursor: default; }
|
||||
|
||||
/* icon support */
|
||||
.ui-menu-icons { position: relative; }
|
||||
.ui-menu-icons .ui-menu-item a { position: relative; padding-left: 2em; }
|
||||
.ui-menu-icons .ui-menu-topic a { position: relative; padding-left: 2em; }
|
||||
|
||||
/* left-aligned */
|
||||
.ui-menu .ui-icon { position: absolute; top: .2em; left: .2em; }
|
||||
|
|
|
@ -46,4 +46,4 @@ line-height: 24px;}
|
|||
|
||||
// add topic on maps pages
|
||||
.selecttype { border:1px solid #000; margin-top: 20px; border-radius:15px; }
|
||||
.mapspages .new_item h3 { padding: 10px 26px; display: block; cursor: pointer; color: #2d6a5d; float:left; }
|
||||
.mapspages .new_topic h3 { padding: 10px 26px; display: block; cursor: pointer; color: #2d6a5d; float:left; }
|
37
app/assets/stylesheets/topics.css.scss
Normal file
37
app/assets/stylesheets/topics.css.scss
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Place all the styles related to the Topics controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
|
||||
.topic { display:block; float:left; position:relative; width:175px; height:300px; padding:10px 5px 10px 35px; background: url('bg.png'); border-radius:15px; margin:30px 0 30px 50px; color:#000; }
|
||||
|
||||
.topic .delete {position: absolute;
|
||||
top: -14px;
|
||||
left: 0px;
|
||||
background: none;
|
||||
border: 0;
|
||||
color: white;
|
||||
border: none;
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.topic .scroll { display:block; height:283px; }
|
||||
|
||||
.topic .type {position: absolute;
|
||||
color: white;
|
||||
top: -22px;
|
||||
right: 0;
|
||||
font-weight: bold;
|
||||
font-size: 20px;
|
||||
line-height: 24px;}
|
||||
|
||||
.topic .icon { position:absolute; top:135px; left:-25px; }
|
||||
|
||||
.topic .title { font-size:22px; line-height:25px; display:block; border-bottom:2px solid #000; padding-bottom:5px; }
|
||||
|
||||
.topic .desc { font-size:15px; font-family:Arial, Helvetica, sans-serif; }
|
||||
.topic .desc h3 { font-style:normal; margin-top:5px; }
|
||||
|
||||
.topic .link { position:absolute; width:170px; top:295px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
@ -1,5 +1,5 @@
|
|||
class MainController < ApplicationController
|
||||
include ItemsHelper
|
||||
include TopicsHelper
|
||||
|
||||
before_filter :require_user, only: [:invite]
|
||||
|
||||
|
@ -11,16 +11,16 @@ class MainController < ApplicationController
|
|||
|
||||
def search
|
||||
@current = current_user
|
||||
@items = Array.new()
|
||||
@topics = Array.new()
|
||||
if params[:topics_by_user_id] != ""
|
||||
@user = User.find(params[:topics_by_user_id])
|
||||
@items = Item.visibleToUser(@current, @user)
|
||||
@topics = Topic.visibleToUser(@current, @user)
|
||||
elsif params[:topics_by_map_id] != ""
|
||||
@map = Map.find(params[:topics_by_map_id])
|
||||
@items = @map.items.delete_if{|item| not item.authorize_to_view(@current)}
|
||||
@topics = @map.topics.delete_if{|topic| not topic.authorize_to_view(@current)}
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js { respond_with(@items) }
|
||||
format.js { respond_with(@topics) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -63,15 +63,15 @@ class MapsController < ApplicationController
|
|||
if params[:map][:topicsToMap]
|
||||
@all = params[:map][:topicsToMap]
|
||||
@all = @all.split(',')
|
||||
@all.each do |item|
|
||||
item = item.split('/')
|
||||
@all.each do |topic|
|
||||
topic = topic.split('/')
|
||||
@mapping = Mapping.new()
|
||||
@mapping.category = "Item"
|
||||
@mapping.category = "Topic"
|
||||
@mapping.user = @user
|
||||
@mapping.map = @map
|
||||
@mapping.item = Item.find(item[0])
|
||||
@mapping.xloc = item[1]
|
||||
@mapping.yloc = item[2]
|
||||
@mapping.topic = Topic.find(topic[0])
|
||||
@mapping.xloc = topic[1]
|
||||
@mapping.yloc = topic[2]
|
||||
@mapping.save
|
||||
end
|
||||
@map.arranged = true
|
||||
|
@ -95,9 +95,9 @@ class MapsController < ApplicationController
|
|||
redirect_to root_url and return
|
||||
end
|
||||
|
||||
@outitems = @map.items.order("name ASC").delete_if{|item| not item.authorize_to_view(@current)}
|
||||
@outtopics = @map.topics.order("name ASC").delete_if{|topic| not topic.authorize_to_view(@current)}
|
||||
|
||||
respond_with(@user, @map, @outitems)
|
||||
respond_with(@user, @map, @outtopics)
|
||||
end
|
||||
|
||||
# PUT maps/:id
|
||||
|
@ -107,10 +107,10 @@ class MapsController < ApplicationController
|
|||
@map.attributes = params[:map]
|
||||
@map.save
|
||||
|
||||
if params[:outitems]
|
||||
@outitems = params[:outitems]
|
||||
@outitems.each do |item|
|
||||
@mapping = Mapping.where("map_id = ? AND item_id = ?", @map.id, item).first
|
||||
if params[:outtopics]
|
||||
@outtopics = params[:outtopics]
|
||||
@outtopics.each do |topic|
|
||||
@mapping = Mapping.where("map_id = ? AND topic_id = ?", @map.id, topic).first
|
||||
@mapping.delete
|
||||
end
|
||||
end
|
||||
|
@ -126,11 +126,11 @@ class MapsController < ApplicationController
|
|||
if params[:map][:coordinates]
|
||||
@all = params[:map][:coordinates]
|
||||
@all = @all.split(',')
|
||||
@all.each do |item|
|
||||
item = item.split('/')
|
||||
@mapping = Mapping.find(item[0])
|
||||
@mapping.xloc = item[1]
|
||||
@mapping.yloc = item[2]
|
||||
@all.each do |topic|
|
||||
topic = topic.split('/')
|
||||
@mapping = Mapping.find(topic[0])
|
||||
@mapping.xloc = topic[1]
|
||||
@mapping.yloc = topic[2]
|
||||
@mapping.save
|
||||
end
|
||||
@map.arranged = true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class SynapsesController < ApplicationController
|
||||
include ItemsHelper
|
||||
include TopicsHelper
|
||||
|
||||
before_filter :require_user, only: [:new, :create, :edit, :update]
|
||||
|
||||
|
@ -39,10 +39,10 @@ class SynapsesController < ApplicationController
|
|||
def show
|
||||
@current = current_user
|
||||
@synapse = Synapse.find(params[:id]).authorize_to_show(@current)
|
||||
@item1 = @synapse.item1.authorize_to_show(@current)
|
||||
@item2 = @synapse.item2.authorize_to_show(@current)
|
||||
@topic1 = @synapse.topic1.authorize_to_show(@current)
|
||||
@topic2 = @synapse.topic2.authorize_to_show(@current)
|
||||
|
||||
if @synapse && @item1 && @item2
|
||||
if @synapse && @topic1 && @topic2
|
||||
@synapsejson = @synapse.selfplusnodes_as_json.html_safe
|
||||
else
|
||||
redirect_to root_url and return
|
||||
|
@ -60,8 +60,8 @@ class SynapsesController < ApplicationController
|
|||
@user = current_user
|
||||
@synapse = Synapse.new()
|
||||
@synapse.desc = params[:synapse][:desc]
|
||||
@synapse.item1 = Item.find(params[:synapse][:item1id])
|
||||
@synapse.item2 = Item.find(params[:synapse][:item2id])
|
||||
@synapse.topic1 = Topic.find(params[:synapse][:topic1id])
|
||||
@synapse.topic2 = Topic.find(params[:synapse][:topic2id])
|
||||
@synapse.permission = "commons"
|
||||
@synapse.category = "from-to"
|
||||
@synapse.weight = 5
|
||||
|
@ -90,12 +90,12 @@ class SynapsesController < ApplicationController
|
|||
@synapse = Synapse.find(params[:id]).authorize_to_edit(@current)
|
||||
|
||||
if @synapse
|
||||
@items = Item.visibleToUser(@current, nil)
|
||||
@topics = Topic.visibleToUser(@current, nil)
|
||||
elsif not @synapse
|
||||
redirect_to root_url and return
|
||||
end
|
||||
|
||||
respond_with(@synapse, @items)
|
||||
respond_with(@synapse, @topics)
|
||||
end
|
||||
|
||||
# PUT synapses/:id
|
||||
|
@ -106,8 +106,8 @@ class SynapsesController < ApplicationController
|
|||
if @synapse
|
||||
@synapse.desc = params[:synapse][:desc]
|
||||
@synapse.category = params[:synapse][:category]
|
||||
@synapse.item1 = Item.find(params[:node1_id][:node1])
|
||||
@synapse.item2 = Item.find(params[:node2_id][:node2])
|
||||
@synapse.topic1 = Topic.find(params[:node1_id][:node1])
|
||||
@synapse.topic2 = Topic.find(params[:node2_id][:node2])
|
||||
@synapse.permission = params[:synapse][:permission]
|
||||
@synapse.save
|
||||
end
|
||||
|
|
163
app/controllers/topics_controller.rb
Normal file
163
app/controllers/topics_controller.rb
Normal file
|
@ -0,0 +1,163 @@
|
|||
class TopicsController < ApplicationController
|
||||
before_filter :require_user, only: [:new, :create, :edit, :update]
|
||||
|
||||
respond_to :html, :js, :json
|
||||
|
||||
autocomplete :topic, :name, :full => true, :extra_data => [:user_id]
|
||||
|
||||
|
||||
# GET topics
|
||||
# or GET /users/:user_id/topics
|
||||
def index
|
||||
@current = current_user
|
||||
|
||||
if params[:user_id]
|
||||
@user = User.find(params[:user_id])
|
||||
@topics = Topic.order("name ASC").visibleToUser(@current, @user)
|
||||
elsif
|
||||
@topics = Topic.order("name ASC").visibleToUser(@current, nil)
|
||||
end
|
||||
|
||||
respond_with(@user,@topics)
|
||||
end
|
||||
|
||||
# Get topics/new
|
||||
def new
|
||||
@topic = Topic.new
|
||||
@user = current_user
|
||||
|
||||
respond_with(@topic)
|
||||
end
|
||||
|
||||
# GET topics/:id
|
||||
def show
|
||||
@current = current_user
|
||||
@topic = Topic.find(params[:id]).authorize_to_show(@current)
|
||||
|
||||
if @topic
|
||||
@relatives = @topic.network_as_json(@current).html_safe
|
||||
else
|
||||
redirect_to root_url and return
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { respond_with(@topic, @user) }
|
||||
format.json { respond_with(@relatives) }
|
||||
end
|
||||
end
|
||||
|
||||
# GET showcard/:id
|
||||
def showcard
|
||||
@user = current_user
|
||||
@topic = Topic.find(params[:id]).authorize_to_show(@user)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { respond_with(@topic, @user) }
|
||||
end
|
||||
end
|
||||
|
||||
# POST topics
|
||||
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
|
||||
|
||||
@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 = Mapping.new()
|
||||
if params[:topic][:map]
|
||||
@mapping.category = "Topic"
|
||||
@mapping.user = @user
|
||||
@mapping.map = Map.find(params[:topic][:map])
|
||||
@mapping.topic = @topic
|
||||
@mapping.xloc = params[:topic][:x]
|
||||
@mapping.yloc = params[:topic][:y]
|
||||
@mapping.save
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { respond_with(@user, location: topic_url(@topic)) }
|
||||
format.js { respond_with(@topic, @mapping, @synapse, @position) }
|
||||
end
|
||||
end
|
||||
|
||||
# GET topics/:id/edit
|
||||
def edit
|
||||
@current = current_user
|
||||
@topic = Topic.find(params[:id]).authorize_to_edit(@current)
|
||||
|
||||
if not @topic
|
||||
redirect_to root_url and return
|
||||
end
|
||||
|
||||
respond_with(@topic)
|
||||
end
|
||||
|
||||
# PUT topics/:id
|
||||
def update
|
||||
@current = current_user
|
||||
@topic = Topic.find(params[:id]).authorize_to_edit(@current)
|
||||
|
||||
if @topic
|
||||
@topic.name = params[:topic][:name]
|
||||
@topic.desc = params[:topic][:desc]
|
||||
@topic.link = params[:topic][:link]
|
||||
@topic.permission = params[:topic][:permission]
|
||||
@topic.metacode = Metacode.find(params[:category][:metacode_id])
|
||||
@topic.save
|
||||
end
|
||||
|
||||
respond_with(@user, location: topic_url(@topic)) do |format|
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE topics/:id
|
||||
def destroy
|
||||
@current = current_user
|
||||
@topic = Topic.find(params[:id]).authorize_to_edit(@current)
|
||||
|
||||
if @topic
|
||||
@synapses = @topic.synapses
|
||||
@mappings = @topic.mappings
|
||||
|
||||
@synapses.each do |synapse|
|
||||
synapse.delete
|
||||
end
|
||||
|
||||
@mappings.each do |mapping|
|
||||
mapping.delete
|
||||
end
|
||||
|
||||
@topic.delete
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
128
app/helpers/topics_helper.rb
Normal file
128
app/helpers/topics_helper.rb
Normal file
|
@ -0,0 +1,128 @@
|
|||
module TopicsHelper
|
||||
|
||||
#find all nodes in any given nodes network
|
||||
def network(node, array, count)
|
||||
# recurse starting with a node to find all connected nodes and return an array of topics that constitutes the starting nodes network
|
||||
|
||||
# if the array of nodes is empty initialize it
|
||||
if array.nil?
|
||||
array = Array.new
|
||||
end
|
||||
|
||||
# add the node to the array
|
||||
array.push(node)
|
||||
|
||||
if count == 0
|
||||
return array
|
||||
end
|
||||
|
||||
count = count - 1
|
||||
|
||||
# check if each relative is already in the array and if not, call the network function again
|
||||
if not node.relatives.empty?
|
||||
if (node.relatives-array).empty?
|
||||
return array
|
||||
else
|
||||
(node.relatives-array).each do |relative|
|
||||
array = (array | network(relative, array, count))
|
||||
end
|
||||
return array
|
||||
end
|
||||
|
||||
elsif node.relatives.empty?
|
||||
return array
|
||||
end
|
||||
end
|
||||
|
||||
#return a json object containing all of a users added synapses
|
||||
def synapses_as_json(current, synapses)
|
||||
Jbuilder.encode do |json|
|
||||
@topics = Array.new
|
||||
|
||||
synapses.each do |synapse|
|
||||
@topics.push(synapse.topic1) if (not @topics.include?(synapse.topic1)) && synapse.topic1.authorize_to_view(current)
|
||||
@topics.push(synapse.topic2) if (not @topics.include?(synapse.topic2)) && synapse.topic2.authorize_to_view(current)
|
||||
end
|
||||
|
||||
json.array!(@topics) do |topic|
|
||||
json.adjacencies topic.synapses2.delete_if{|synapse| not @topics.include?(Topic.find_by_id(synapse.node1_id))} do |json, synapse|
|
||||
json.nodeTo synapse.node1_id
|
||||
json.nodeFrom synapse.node2_id
|
||||
|
||||
@synapsedata = Hash.new
|
||||
@synapsedata['$desc'] = synapse.desc
|
||||
@synapsedata['$showDesc'] = false
|
||||
@synapsedata['$category'] = synapse.category
|
||||
@synapsedata['$id'] = synapse.id
|
||||
@synapsedata['$userid'] = synapse.user.id
|
||||
@synapsedata['$username'] = synapse.user.name
|
||||
@synapsedata['$direction'] = [synapse.node1_id.to_s(), synapse.node2_id.to_s()]
|
||||
json.data @synapsedata
|
||||
end
|
||||
|
||||
@inmaps = Array.new
|
||||
topic.maps.each do |map|
|
||||
@inmaps.push(map.id)
|
||||
end
|
||||
|
||||
@topicdata = Hash.new
|
||||
@topicdata['$desc'] = topic.desc
|
||||
@topicdata['$link'] = topic.link
|
||||
@topicdata['$metacode'] = topic.metacode.name
|
||||
@topicdata['$inmaps'] = @inmaps
|
||||
@topicdata['$userid'] = topic.user.id
|
||||
@topicdata['$username'] = topic.user.name
|
||||
json.data @topicdata
|
||||
json.id topic.id
|
||||
json.name topic.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def all_as_json(current, user)
|
||||
|
||||
# current is current user
|
||||
|
||||
Jbuilder.encode do |json|
|
||||
if user.nil?
|
||||
@topics = Topic.visibleToUser(current, nil)
|
||||
@synapses = Synapse.visibleToUser(current, nil)
|
||||
else
|
||||
@topics = Topic.visibleToUser(current, user)
|
||||
@synapses = Synapse.visibleToUser(current, user)
|
||||
end
|
||||
|
||||
json.array!(@topics) do |topic|
|
||||
json.adjacencies topic.synapses2.delete_if{|synapse| (not @topics.include?(Topic.find_by_id(synapse.node1_id))) || (not @synapses.include?(synapse))} do |json, synapse|
|
||||
json.nodeTo synapse.node1_id
|
||||
json.nodeFrom synapse.node2_id
|
||||
|
||||
@synapsedata = Hash.new
|
||||
@synapsedata['$desc'] = synapse.desc
|
||||
@synapsedata['$category'] = synapse.category
|
||||
@synapsedata['$userid'] = synapse.user.id
|
||||
@synapsedata['$username'] = synapse.user.name
|
||||
json.data @synapsedata
|
||||
end
|
||||
|
||||
@inmaps = Array.new
|
||||
topic.maps.each do |map|
|
||||
@inmaps.push(map.id)
|
||||
end
|
||||
|
||||
@topicdata = Hash.new
|
||||
@topicdata['$desc'] = topic.desc
|
||||
@topicdata['$link'] = topic.link
|
||||
@topicdata['$metacode'] = topic.metacode.name
|
||||
@topicdata['$inmaps'] = @inmaps
|
||||
@topicdata['$userid'] = topic.user.id
|
||||
@topicdata['$username'] = topic.user.name
|
||||
|
||||
json.data @topicdata
|
||||
json.id topic.id
|
||||
json.name topic.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -2,14 +2,14 @@ class Map < ActiveRecord::Base
|
|||
|
||||
belongs_to :user
|
||||
|
||||
has_many :itemmappings, :class_name => 'Mapping', :conditions => {:category => 'Item'}
|
||||
has_many :topicmappings, :class_name => 'Mapping', :conditions => {:category => 'Topic'}
|
||||
has_many :synapsemappings, :class_name => 'Mapping', :conditions => {:category => 'Synapse'}
|
||||
|
||||
has_many :items, :through => :itemmappings
|
||||
has_many :topics, :through => :topicmappings
|
||||
has_many :synapses, :through => :synapsemappings
|
||||
|
||||
def mappings
|
||||
itemmappings + synapsemappings
|
||||
topicmappings + synapsemappings
|
||||
end
|
||||
|
||||
|
||||
|
@ -17,14 +17,14 @@ end
|
|||
#build a json object of a map
|
||||
def self_as_json(current)
|
||||
Jbuilder.encode do |json|
|
||||
@items = self.items
|
||||
@topics = self.topics
|
||||
@synapses = self.synapses
|
||||
|
||||
json.array!(@items.delete_if{|item| not item.authorize_to_view(current)}) do |item|
|
||||
json.array!(@topics.delete_if{|topic| not topic.authorize_to_view(current)}) do |topic|
|
||||
|
||||
#json.adjacencies item.synapses2.delete_if{|synapse| (not @items.include?(synapse.item1)) || (not @synapses.include?(synapse)) || (not synapse.authorize_to_view(current)) || (not synapse.item1.authorize_to_view(current)) } do |json, synapse|
|
||||
#json.adjacencies topic.synapses2.delete_if{|synapse| (not @topics.include?(synapse.topic1)) || (not @synapses.include?(synapse)) || (not synapse.authorize_to_view(current)) || (not synapse.topic1.authorize_to_view(current)) } do |json, synapse|
|
||||
|
||||
json.adjacencies item.synapses1.delete_if{|synapse| (not @items.include?(synapse.item2)) || (not synapse.authorize_to_view(current)) || (not synapse.item2.authorize_to_view(current)) } do |json, synapse|
|
||||
json.adjacencies topic.synapses1.delete_if{|synapse| (not @topics.include?(synapse.topic2)) || (not synapse.authorize_to_view(current)) || (not synapse.topic2.authorize_to_view(current)) } do |json, synapse|
|
||||
json.nodeTo synapse.node2_id
|
||||
json.nodeFrom synapse.node1_id
|
||||
|
||||
|
@ -40,24 +40,24 @@ end
|
|||
end
|
||||
|
||||
@inmaps = Array.new
|
||||
item.maps.each do |map|
|
||||
topic.maps.each do |map|
|
||||
@inmaps.push(map.id)
|
||||
end
|
||||
|
||||
@itemdata = Hash.new
|
||||
@itemdata['$desc'] = item.desc
|
||||
@itemdata['$link'] = item.link
|
||||
@itemdata['$itemcatname'] = item.item_category.name
|
||||
@itemdata['$inmaps'] = @inmaps
|
||||
@itemdata['$userid'] = item.user.id
|
||||
@itemdata['$username'] = item.user.name
|
||||
@mapping = Mapping.find_by_item_id_and_map_id(item.id,self.id)
|
||||
@itemdata['$xloc'] = @mapping.xloc
|
||||
@itemdata['$yloc'] = @mapping.yloc
|
||||
@itemdata['$mappingid'] = @mapping.id
|
||||
json.data @itemdata
|
||||
json.id item.id
|
||||
json.name item.name
|
||||
@topicdata = Hash.new
|
||||
@topicdata['$desc'] = topic.desc
|
||||
@topicdata['$link'] = topic.link
|
||||
@topicdata['$metacode'] = topic.metacode.name
|
||||
@topicdata['$inmaps'] = @inmaps
|
||||
@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
|
||||
json.data @topicdata
|
||||
json.id topic.id
|
||||
json.name topic.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Mapping < ActiveRecord::Base
|
||||
|
||||
belongs_to :item, :class_name => "Item", :foreign_key => "item_id"
|
||||
belongs_to :topic, :class_name => "Topic", :foreign_key => "topic_id"
|
||||
belongs_to :synapse, :class_name => "Synapse", :foreign_key => "synapse_id"
|
||||
belongs_to :map, :class_name => "Map", :foreign_key => "map_id"
|
||||
|
||||
|
|
5
app/models/metacode.rb
Normal file
5
app/models/metacode.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class Metacode < ActiveRecord::Base
|
||||
|
||||
has_many :topics
|
||||
|
||||
end
|
|
@ -2,8 +2,8 @@ class Synapse < ActiveRecord::Base
|
|||
|
||||
belongs_to :user
|
||||
|
||||
belongs_to :item1, :class_name => "Item", :foreign_key => "node1_id"
|
||||
belongs_to :item2, :class_name => "Item", :foreign_key => "node2_id"
|
||||
belongs_to :topic1, :class_name => "Topic", :foreign_key => "node1_id"
|
||||
belongs_to :topic2, :class_name => "Topic", :foreign_key => "node2_id"
|
||||
|
||||
has_many :mappings
|
||||
has_many :maps, :through => :mappings
|
||||
|
@ -26,12 +26,12 @@ has_many :maps, :through => :mappings
|
|||
|
||||
def selfplusnodes_as_json
|
||||
Jbuilder.encode do |json|
|
||||
@items = Array.new
|
||||
@items.push(self.item1)
|
||||
@items.push(self.item2)
|
||||
@topics = Array.new
|
||||
@topics.push(self.topic1)
|
||||
@topics.push(self.topic2)
|
||||
|
||||
json.array!(@items) do |item|
|
||||
json.adjacencies item.synapses1.delete_if{|synapse| not @items.include?(Item.find_by_id(synapse.node2_id))} do |json, synapse|
|
||||
json.array!(@topics) do |topic|
|
||||
json.adjacencies topic.synapses1.delete_if{|synapse| not @topics.include?(Topic.find_by_id(synapse.node2_id))} do |json, synapse|
|
||||
json.nodeTo synapse.node2_id
|
||||
json.nodeFrom synapse.node1_id
|
||||
|
||||
|
@ -47,20 +47,20 @@ has_many :maps, :through => :mappings
|
|||
end
|
||||
|
||||
@inmaps = Array.new
|
||||
item.maps.each do |map|
|
||||
topic.maps.each do |map|
|
||||
@inmaps.push(map.id)
|
||||
end
|
||||
|
||||
@itemdata = Hash.new
|
||||
@itemdata['$desc'] = item.desc
|
||||
@itemdata['$link'] = item.link
|
||||
@itemdata['$itemcatname'] = item.item_category.name
|
||||
@itemdata['$inmaps'] = @inmaps
|
||||
@itemdata['$userid'] = item.user.id
|
||||
@itemdata['$username'] = item.user.name
|
||||
json.data @itemdata
|
||||
json.id item.id
|
||||
json.name item.name
|
||||
@topicdata = Hash.new
|
||||
@topicdata['$desc'] = topic.desc
|
||||
@topicdata['$link'] = topic.link
|
||||
@topicdata['$metacode'] = topic.metacode.name
|
||||
@topicdata['$inmaps'] = @inmaps
|
||||
@topicdata['$userid'] = topic.user.id
|
||||
@topicdata['$username'] = topic.user.name
|
||||
json.data @topicdata
|
||||
json.id topic.id
|
||||
json.name topic.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
171
app/models/topic.rb
Normal file
171
app/models/topic.rb
Normal file
|
@ -0,0 +1,171 @@
|
|||
class Topic < ActiveRecord::Base
|
||||
|
||||
include TopicsHelper
|
||||
|
||||
belongs_to :user
|
||||
|
||||
has_many :synapses1, :class_name => 'Synapse', :foreign_key => 'node1_id'
|
||||
has_many :synapses2, :class_name => 'Synapse', :foreign_key => 'node2_id'
|
||||
has_many :topics1, :through => :synapses2, :source => :topic1
|
||||
has_many :topics2, :through => :synapses1, :source => :topic2
|
||||
|
||||
has_many :mappings
|
||||
has_many :maps, :through => :mappings
|
||||
|
||||
def synapses
|
||||
synapses1 + synapses2
|
||||
end
|
||||
|
||||
def relatives
|
||||
topics1 + topics2
|
||||
end
|
||||
|
||||
belongs_to :metacode
|
||||
|
||||
# has no viewable synapses helper function
|
||||
def has_viewable_synapses(current)
|
||||
result = false
|
||||
self.synapses.each do |synapse|
|
||||
if synapse.authorize_to_view(current)
|
||||
result = true
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
###### JSON ######
|
||||
|
||||
def self_as_json
|
||||
Jbuilder.encode do |json|
|
||||
@inmaps = Array.new
|
||||
self.maps.each do |map|
|
||||
@inmaps.push(map.id)
|
||||
end
|
||||
|
||||
@topicdata = Hash.new
|
||||
@topicdata['$desc'] = self.desc
|
||||
@topicdata['$link'] = self.link
|
||||
@topicdata['$metacode'] = self.metacode.name
|
||||
@topicdata['$inmaps'] = @inmaps
|
||||
@topicdata['$userid'] = self.user.id
|
||||
@topicdata['$username'] = self.user.name
|
||||
json.data @topicdata
|
||||
json.id self.id
|
||||
json.name self.name
|
||||
end
|
||||
end
|
||||
|
||||
#build a json object of everything connected to a specified node
|
||||
def network_as_json(current)
|
||||
Jbuilder.encode do |json|
|
||||
@topics = network(self,nil,4)
|
||||
|
||||
if @topics.count > 1
|
||||
json.array!(@topics.delete_if{|topic| (not topic.authorize_to_view(current)) || (not topic.has_viewable_synapses(current))}) do |topic|
|
||||
|
||||
json.adjacencies topic.synapses1.delete_if{|synapse| (not @topics.include?(synapse.topic2)) || (not synapse.authorize_to_view(current)) || (not synapse.topic2.authorize_to_view(current)) } do |json, synapse|
|
||||
json.nodeTo synapse.node2_id
|
||||
json.nodeFrom synapse.node1_id
|
||||
|
||||
@synapsedata = Hash.new
|
||||
@synapsedata['$desc'] = synapse.desc
|
||||
@synapsedata['$showDesc'] = false
|
||||
@synapsedata['$category'] = synapse.category
|
||||
@synapsedata['$id'] = synapse.id
|
||||
@synapsedata['$userid'] = synapse.user.id
|
||||
@synapsedata['$username'] = synapse.user.name
|
||||
@synapsedata['$direction'] = [synapse.node1_id.to_s(), synapse.node2_id.to_s()]
|
||||
json.data @synapsedata
|
||||
end
|
||||
|
||||
@inmaps = Array.new
|
||||
topic.maps.each do |map|
|
||||
@inmaps.push(map.id)
|
||||
end
|
||||
|
||||
@topicdata = Hash.new
|
||||
@topicdata['$desc'] = topic.desc
|
||||
@topicdata['$link'] = topic.link
|
||||
@topicdata['$metacode'] = topic.metacode.name
|
||||
@topicdata['$inmaps'] = @inmaps
|
||||
@topicdata['$userid'] = topic.user.id
|
||||
@topicdata['$username'] = topic.user.name
|
||||
json.data @topicdata
|
||||
json.id topic.id
|
||||
json.name topic.name
|
||||
end
|
||||
elsif @topics.count == 1
|
||||
json.array!(@topics) do |topic|
|
||||
@inmaps = Array.new
|
||||
topic.maps.each do |map|
|
||||
@inmaps.push(map.id)
|
||||
end
|
||||
|
||||
@topicdata = Hash.new
|
||||
@topicdata['$desc'] = topic.desc
|
||||
@topicdata['$link'] = topic.link
|
||||
@topicdata['$metacode'] = topic.metacode.name
|
||||
@topicdata['$inmaps'] = @inmaps
|
||||
@topicdata['$userid'] = topic.user.id
|
||||
@topicdata['$username'] = topic.user.name
|
||||
json.data @topicdata
|
||||
json.id topic.id
|
||||
json.name topic.name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
##### PERMISSIONS ######
|
||||
|
||||
scope :visibleToUser, lambda { |current, user|
|
||||
if user != nil
|
||||
if user != current
|
||||
Topic.find_all_by_user_id_and_permission(user.id, "commons") | Topic.find_all_by_user_id_and_permission(user.id, "public")
|
||||
elsif user == current
|
||||
Topic.find_all_by_user_id_and_permission(user.id, "commons") | Topic.find_all_by_user_id_and_permission(user.id, "public") | current.topics.where(:permission => "private")
|
||||
end
|
||||
elsif (current != nil && user == nil)
|
||||
Topic.find_all_by_permission("commons") | Topic.find_all_by_permission("public") | current.topics.where(:permission => "private")
|
||||
elsif (current == nil)
|
||||
Topic.find_all_by_permission("commons") | Topic.find_all_by_permission("public")
|
||||
end
|
||||
}
|
||||
|
||||
# returns false if user not allowed to 'show' Topic, Synapse, or Map
|
||||
def authorize_to_show(user)
|
||||
if (self.permission == "private" && self.user != user)
|
||||
return false
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
# returns false if user not allowed to 'edit' Topic, Synapse, or Map
|
||||
def authorize_to_edit(user)
|
||||
if (self.permission == "private" && self.user != user)
|
||||
return false
|
||||
elsif (self.permission == "public" && self.user != user)
|
||||
return false
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
# returns Boolean if user allowed to view Topic, Synapse, or Map
|
||||
def authorize_to_view(user)
|
||||
if (self.permission == "private" && self.user != user)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
# returns Boolean based on whether user has permissions to edit or not
|
||||
def authorize_linkto_edit(user)
|
||||
if (self.user == user)
|
||||
return true
|
||||
elsif (self.permission == "commons")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
end
|
|
@ -2,7 +2,7 @@ require 'open-uri'
|
|||
|
||||
class User < ActiveRecord::Base
|
||||
|
||||
has_many :items
|
||||
has_many :topics
|
||||
has_many :synapses
|
||||
has_many :maps
|
||||
has_many :mappings
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<% unless authenticated? %>
|
||||
<ul class="menu">
|
||||
<li class="first"><%= link_to "Console", console_url %></li>
|
||||
<li><%= link_to "Topics", items_url %></li>
|
||||
<li><%= link_to "Topics", topics_url %></li>
|
||||
<li><%= link_to "Synapses", synapses_url %></li>
|
||||
<li><%= link_to "Maps", maps_url %></li>
|
||||
<li class="last"><%= link_to "Login", new_session_path, id: "Login" %></li>
|
||||
|
@ -43,7 +43,7 @@
|
|||
<ul class="menu">
|
||||
<li class="first"><%= link_to "Console", console_url %></li>
|
||||
<li><%= link_to "Create Map", new_map_url %></li>
|
||||
<li><%= link_to "My Topics", user_items_url(user) %></li>
|
||||
<li><%= link_to "My Topics", user_topics_url(user) %></li>
|
||||
<li><%= link_to "My Synapses", user_synapses_url(user) %></li>
|
||||
<li><%= link_to "My Maps", user_maps_url(user) %></li>
|
||||
<li><%= link_to "Invite", invite_path %></li>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</div>
|
||||
<div class="clearfloat"></div>
|
||||
<% if authenticated? %>
|
||||
<%= render :partial => 'items/new' %>
|
||||
<%= render :partial => 'topics/new' %>
|
||||
<%= render :partial => 'synapses/new' %>
|
||||
<%= render :partial => 'maps/new' %>
|
||||
<% end %>
|
||||
|
@ -43,8 +43,8 @@
|
|||
<option value="mapper (by name)">mapper (by name)</option>
|
||||
</select>
|
||||
<div class="clearfloat"></div>
|
||||
<%= form_for Item.new, :html => { :class => "find_topic_by_name find find_topic", :id => "find_topic_by_name" } do |f| %>
|
||||
<%= f.autocomplete_field :name, autocomplete_item_name_items_path, :id => "topic_by_name_input", :placeholder => "Search for topics..." %>
|
||||
<%= form_for Topic.new, :html => { :class => "find_topic_by_name find find_topic", :id => "find_topic_by_name" } do |f| %>
|
||||
<%= f.autocomplete_field :name, autocomplete_topic_name_topics_path, :id => "topic_by_name_input", :placeholder => "Search for topics..." %>
|
||||
<% end %>
|
||||
<%= form_for Map.new, :html => { :class => "find_map_by_name find", :id => "find_map_by_name" } do |f| %>
|
||||
<%= f.autocomplete_field :name, autocomplete_map_name_maps_path, :id => "map_by_name_input", :placeholder => "Search for maps..." %>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<% unless @item.nil? %>
|
||||
<% unless @topic.nil? %>
|
||||
<div class="home" id="container">
|
||||
<div id="center-container">
|
||||
<div id="infovis"></div>
|
||||
|
@ -14,12 +14,12 @@
|
|||
});
|
||||
</script>
|
||||
<% end %>
|
||||
<% if @item.nil? %>
|
||||
<% if @topic.nil? %>
|
||||
<p><br>Shucks, there is nothing in metamaps.<p>
|
||||
<% end %>
|
||||
|
||||
<% if authenticated? %>
|
||||
<%= render :partial => 'items/new' %>
|
||||
<%= render :partial => 'topics/new' %>
|
||||
<%= render :partial => 'synapses/new' %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -7,11 +7,11 @@ var myX = -w + 400;
|
|||
var myY = -h + 100;
|
||||
var even = true;
|
||||
|
||||
<% @items.each do |item| %>
|
||||
<% @topics.each do |topic| %>
|
||||
if ($.isEmptyObject(Mconsole.graph.nodes)) {
|
||||
json = <%= item.self_as_json.html_safe %>;
|
||||
json = <%= topic.self_as_json.html_safe %>;
|
||||
Mconsole.loadJSON(json);
|
||||
var temp = Mconsole.graph.getNode('<%= item.id %>');
|
||||
var temp = Mconsole.graph.getNode('<%= topic.id %>');
|
||||
temp.setData('dim', 1, 'start');
|
||||
temp.setData('dim', 25, 'end');
|
||||
temp.setData('inCommons',true);
|
||||
|
@ -23,11 +23,11 @@ var even = true;
|
|||
even = !even;
|
||||
}
|
||||
else {
|
||||
var temp = Mconsole.graph.getNode('<%= item.id %>');
|
||||
var temp = Mconsole.graph.getNode('<%= topic.id %>');
|
||||
if (temp == null) {
|
||||
var newnode = <%= item.self_as_json.html_safe %>;
|
||||
var newnode = <%= topic.self_as_json.html_safe %>;
|
||||
Mconsole.graph.addNode(newnode);
|
||||
var temp = Mconsole.graph.getNode('<%= item.id %>');
|
||||
var temp = Mconsole.graph.getNode('<%= topic.id %>');
|
||||
temp.setData('dim', 1, 'start');
|
||||
temp.setData('dim', 25, 'end');
|
||||
temp.setData('inCommons',true);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<% if map.user == user %><%= link_to 'Delete', map_path(map), :class => 'delete', :confirm => 'Delete this map (nodes and synapses will remain)?', :method => :delete, :remote => true %><% end %>
|
||||
<div class="scroll">
|
||||
<%= link_to map.name, map_path(map), :class => 'title' %>
|
||||
<div class="desc"><p><%= map.desc %></p><p># of Topics: <%= map.items.count %></p><p># of Synapses: <%= map.synapses.count %></p></div>
|
||||
<div class="desc"><p><%= map.desc %></p><p># of Topics: <%= map.topics.count %></p><p># of Synapses: <%= map.synapses.count %></p></div>
|
||||
</div>
|
||||
<div class="link"><p>Permissions:<%= map.permission %></p></div>
|
||||
<% end %>
|
|
@ -1,8 +1,8 @@
|
|||
<div class="anypage">
|
||||
<%= form_for Synapse.new, url: synapses_url, remote: true do |form| %>
|
||||
<%= form.autocomplete_field :desc, autocomplete_synapse_desc_synapses_path, :placeholder => "Describe the connection..." %>
|
||||
<%= form.hidden_field :item1id, :value => 0 %>
|
||||
<%= form.hidden_field :item2id, :value => 0 %>
|
||||
<%= form.hidden_field :topic1id, :value => 0 %>
|
||||
<%= form.hidden_field :topic2id, :value => 0 %>
|
||||
<%= form.hidden_field :map, :value => @map.id %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -1,12 +1,12 @@
|
|||
<div class="anypage">
|
||||
<%= form_for Item.new, url: items_url, remote: true do |form| %>
|
||||
<%= form_for Topic.new, url: topics_url, remote: true do |form| %>
|
||||
<div id="metacodeImg"><img class="cloudcarousel" width="40" height="40" src="/assets/action.png" alt="Action" title="Action"/><img class="cloudcarousel" width="40" height="40" src="/assets/activity.png" alt="Activity" title="Activity"/><img class="cloudcarousel" width="40" height="40" src="/assets/bizarre.png" alt="Bizarre" title="Bizarre"/><img class="cloudcarousel" width="40" height="40" src="/assets/catalyst.png" alt="Catalyst" title="Catalyst"/><img class="cloudcarousel" width="40" height="40" src="/assets/closed.png" alt="Closed" title="Closed"/><img class="cloudcarousel" width="40" height="40" src="/assets/experience.png" alt="Experience" title="Experience"/><img class="cloudcarousel" width="40" height="40" src="/assets/futuredev.png" alt="Future Dev" title="Future Dev"/><img class="cloudcarousel" width="40" height="40" src="/assets/group.png" alt="Group" title="Group"/><img class="cloudcarousel" width="40" height="40" src="/assets/idea.png" alt="Idea" title="Idea"/><img class="cloudcarousel" width="40" height="40" src="/assets/implication.png" alt="Implication" title="Implication"/><img class="cloudcarousel" width="40" height="40" src="/assets/insight.png" alt="Insight" title="Insight"/><img class="cloudcarousel" width="40" height="40" src="/assets/intention.png" alt="Intention" title="Intention"/><img class="cloudcarousel" width="40" height="40" src="/assets/knowledge.png" alt="Knowledge" title="Knowledge"/><img class="cloudcarousel" width="40" height="40" src="/assets/location.png" alt="Location" title="Location"/><img class="cloudcarousel" width="40" height="40" src="/assets/openissue.png" alt="Open Issue" title="Open Issue"/><img class="cloudcarousel" width="40" height="40" src="/assets/opinion.png" alt="Opinion" title="Opinion"/><img class="cloudcarousel" width="40" height="40" src="/assets/opportunity.png" alt="Opportunity" title="Opportunity"/><img class="cloudcarousel" width="40" height="40" src="/assets/person.png" alt="Person" title="Person"/><img class="cloudcarousel" width="40" height="40" src="/assets/platform.png" alt="Platform" title="Platform"/><img class="cloudcarousel" width="40" height="40" src="/assets/problem.png" alt="Problem" title="Problem"/><img class="cloudcarousel" width="40" height="40" src="/assets/question.png" alt="Question" title="Question"/><img class="cloudcarousel" width="40" height="40" src="/assets/reference.png" alt="Reference" title="Reference"/><img class="cloudcarousel" width="40" height="40" src="/assets/requirement.png" alt="Requirement" title="Requirement"/><img class="cloudcarousel" width="40" height="40" src="/assets/resource.png" alt="Resource" title="Resource"/><img class="cloudcarousel" width="40" height="40" src="/assets/role.png" alt="Role" title="Role"/><img class="cloudcarousel" width="40" height="40" src="/assets/task.png" alt="Task" title="Task"/><img class="cloudcarousel" width="40" height="40" src="/assets/tool.png" alt="Tool" title="Tool"/><img class="cloudcarousel" width="40" height="40" src="/assets/trajectory.png" alt="Trajectory" title="Trajectory"/></div>
|
||||
<%= form.autocomplete_field :name, autocomplete_item_name_items_path, :placeholder => "What is the name of your topic?" %>
|
||||
<%= form.autocomplete_field :name, autocomplete_topic_name_topics_path, :placeholder => "What is the name of your topic?" %>
|
||||
<%= form.hidden_field :metacode, :value => "Action" %>
|
||||
<%= form.hidden_field :x, :value => 0 %>
|
||||
<%= form.hidden_field :y, :value => 0 %>
|
||||
<%= form.hidden_field :map, :value => @map.id %>
|
||||
<%= form.hidden_field :grabItem, :value => "null" %>
|
||||
<%= form.hidden_field :grabTopic, :value => "null" %>
|
||||
<%= form.hidden_field :addSynapse, :value => false %>
|
||||
<!--<input id="left-but" type="button" value="Left" />-->
|
||||
<div id="metacodeImgTitle"></div>
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
<%= form.text_field :name %>
|
||||
<label for="map_desc">Description</label>
|
||||
<%= form.text_area :desc, class: "description", :rows => 5 %>
|
||||
<label for="outitems">Remove Topics From Map</label>
|
||||
<%= select_tag "outitems", options_from_collection_for_select(@outitems, "id", "name"), { :multiple => true } %>
|
||||
<label for="outtopics">Remove Topics From Map</label>
|
||||
<%= select_tag "outtopics", options_from_collection_for_select(@outtopics, "id", "name"), { :multiple => true } %>
|
||||
<label for="map_perm">Permission</label>
|
||||
<%= form.select :permission, options_for_select(['commons', 'public', 'private'], @map.permission) %>
|
||||
<%= form.submit "Update", class: "update" %>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="focus">
|
||||
<div class="focusleft">
|
||||
<p># of Topics: <%= @map.items.count %></p>
|
||||
<p># of Topics: <%= @map.topics.count %></p>
|
||||
<p># of Synapses: <%= @map.synapses.count %></p>
|
||||
<% if (@map.permission == "commons" && authenticated?) || @map.user == user %>
|
||||
<%= form_for @map, :url => savelayout_path(@map), :html => { :class => "saveMapLayout", :id => "saveMapLayout"}, remote: true do |form| %>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="anypage">
|
||||
<%= form_for Synapse.new, url: synapses_url, remote: true do |form| %>
|
||||
<%= form.autocomplete_field :desc, autocomplete_synapse_desc_synapses_path, :placeholder => "Describe the connection..." %>
|
||||
<%= form.hidden_field :item1id, :value => 0 %>
|
||||
<%= form.hidden_field :item2id, :value => 0 %>
|
||||
<%= form.hidden_field :topic1id, :value => 0 %>
|
||||
<%= form.hidden_field :topic2id, :value => 0 %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -1,13 +1,13 @@
|
|||
$('#new_synapse').fadeOut('fast');
|
||||
$('#synapse_desc').attr('value','');
|
||||
$('#synapse_item1id').attr('value','0');
|
||||
$('#synapse_item2id').attr('value','0');
|
||||
$('#synapse_topic1id').attr('value','0');
|
||||
$('#synapse_topic2id').attr('value','0');
|
||||
|
||||
var temp1, temp2, temp;
|
||||
|
||||
if ( Mconsole != null) {
|
||||
temp1 = Mconsole.graph.getNode(<%= @synapse.item1.id %>);
|
||||
temp2 = Mconsole.graph.getNode(<%= @synapse.item2.id %>);
|
||||
temp1 = Mconsole.graph.getNode(<%= @synapse.topic1.id %>);
|
||||
temp2 = Mconsole.graph.getNode(<%= @synapse.topic2.id %>);
|
||||
Mconsole.graph.addAdjacence(temp1, temp2, {});
|
||||
temp = Mconsole.graph.getAdjacence(temp1.id, temp2.id);
|
||||
console.log(temp);
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<%= form_for @synapse, url: synapse_url do |form| %>
|
||||
<h3>Edit Synapse</h3>
|
||||
<% if Item.visibleToUser(user, nil).count > 0 %>
|
||||
<% if Topic.visibleToUser(user, nil).count > 0 %>
|
||||
<label for="node1_id">Choose First Topic</label>
|
||||
<%= select "node1_id", "node1", Item.order("name ASC").visibleToUser(user, nil).map {|p| [ p.name, p.id ] }, { :selected => @synapse.node1_id } %>
|
||||
<%= select "node1_id", "node1", Topic.order("name ASC").visibleToUser(user, nil).map {|p| [ p.name, p.id ] }, { :selected => @synapse.node1_id } %>
|
||||
<% end %>
|
||||
<label for="item_category">Directionality of the Connection</label>
|
||||
<label for="metacode">Directionality of the Connection</label>
|
||||
<%= form.select :category, options_for_select(['none', 'both', 'from-to'], @synapse.category) %>
|
||||
<label for="item_desc">Describe The Connection</label>
|
||||
<label for="topic_desc">Describe The Connection</label>
|
||||
<%= form.text_field :desc, class: "description" %>
|
||||
<% if Item.visibleToUser(user, nil).count > 0 %>
|
||||
<% if Topic.visibleToUser(user, nil).count > 0 %>
|
||||
<label for="node2_id">Choose Second Topic</label>
|
||||
<%= select "node2_id", "node2", Item.order("name ASC").visibleToUser(user, nil).map {|p| [ p.name, p.id ] }, { :selected => @synapse.node2_id } %>
|
||||
<%= select "node2_id", "node2", Topic.order("name ASC").visibleToUser(user, nil).map {|p| [ p.name, p.id ] }, { :selected => @synapse.node2_id } %>
|
||||
<% end %>
|
||||
<label for="synapse_permission">Permission</label>
|
||||
<%= form.select :permission, options_for_select(['commons', 'public', 'private'], @synapse.permission) %>
|
||||
|
|
|
@ -17,6 +17,6 @@
|
|||
</script>
|
||||
|
||||
<% if authenticated? %>
|
||||
<%= render :partial => 'items/new' %>
|
||||
<%= render :partial => 'topics/new' %>
|
||||
<%= render :partial => 'synapses/new' %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<div class="newsynapses">
|
||||
<%= form_for @synapse, url: synapses_url do |form| %>
|
||||
<h3>Add Synapse Between Topics</h3>
|
||||
<% if Item.visibleToUser(user, nil).count > 0 %>
|
||||
<% if Topic.visibleToUser(user, nil).count > 0 %>
|
||||
<label for="node1_id">Choose First Topic</label>
|
||||
<%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %>
|
||||
<%= select_tag :node1_id, options_from_collection_for_select(Topic.order("name ASC").visibleToUser(user, nil), "id", "name") %>
|
||||
<% end %>
|
||||
<label for="item_category">Directionality of the Connection</label>
|
||||
<label for="metacode">Directionality of the Connection</label>
|
||||
<%= form.select :category, options_for_select(['none', 'both', 'from-to']) %>
|
||||
<label for="item_desc">Describe The Connection</label>
|
||||
<label for="topic_desc">Describe The Connection</label>
|
||||
<%= form.text_field :desc, class: "description" %>
|
||||
<% if Item.visibleToUser(user, nil).count > 0 %>
|
||||
<% if Topic.visibleToUser(user, nil).count > 0 %>
|
||||
<label for="node2_id">Choose Second Topic</label>
|
||||
<%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %>
|
||||
<%= select_tag :node2_id, options_from_collection_for_select(Topic.order("name ASC").visibleToUser(user, nil), "id", "name") %>
|
||||
<% end %>
|
||||
<label for="synapse_permission">Permission</label>
|
||||
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
|
||||
|
|
|
@ -16,6 +16,6 @@
|
|||
</script>
|
||||
|
||||
<% if authenticated? %>
|
||||
<%= render :partial => 'items/new' %>
|
||||
<%= render :partial => 'topics/new' %>
|
||||
<%= render :partial => 'synapses/new' %>
|
||||
<% end %>
|
15
app/views/topics/_new.html.erb
Normal file
15
app/views/topics/_new.html.erb
Normal file
|
@ -0,0 +1,15 @@
|
|||
<div class="anypage">
|
||||
<%= form_for Topic.new, url: topics_url, remote: true do |form| %>
|
||||
<div id="metacodeImg"><img class="cloudcarousel" width="40" height="40" src="/assets/action.png" alt="Action" title="Action"/><img class="cloudcarousel" width="40" height="40" src="/assets/activity.png" alt="Activity" title="Activity"/><img class="cloudcarousel" width="40" height="40" src="/assets/bizarre.png" alt="Bizarre" title="Bizarre"/><img class="cloudcarousel" width="40" height="40" src="/assets/catalyst.png" alt="Catalyst" title="Catalyst"/><img class="cloudcarousel" width="40" height="40" src="/assets/closed.png" alt="Closed" title="Closed"/><img class="cloudcarousel" width="40" height="40" src="/assets/experience.png" alt="Experience" title="Experience"/><img class="cloudcarousel" width="40" height="40" src="/assets/futuredev.png" alt="Future Dev" title="Future Dev"/><img class="cloudcarousel" width="40" height="40" src="/assets/group.png" alt="Group" title="Group"/><img class="cloudcarousel" width="40" height="40" src="/assets/idea.png" alt="Idea" title="Idea"/><img class="cloudcarousel" width="40" height="40" src="/assets/implication.png" alt="Implication" title="Implication"/><img class="cloudcarousel" width="40" height="40" src="/assets/insight.png" alt="Insight" title="Insight"/><img class="cloudcarousel" width="40" height="40" src="/assets/intention.png" alt="Intention" title="Intention"/><img class="cloudcarousel" width="40" height="40" src="/assets/knowledge.png" alt="Knowledge" title="Knowledge"/><img class="cloudcarousel" width="40" height="40" src="/assets/location.png" alt="Location" title="Location"/><img class="cloudcarousel" width="40" height="40" src="/assets/openissue.png" alt="Open Issue" title="Open Issue"/><img class="cloudcarousel" width="40" height="40" src="/assets/opinion.png" alt="Opinion" title="Opinion"/><img class="cloudcarousel" width="40" height="40" src="/assets/opportunity.png" alt="Opportunity" title="Opportunity"/><img class="cloudcarousel" width="40" height="40" src="/assets/person.png" alt="Person" title="Person"/><img class="cloudcarousel" width="40" height="40" src="/assets/platform.png" alt="Platform" title="Platform"/><img class="cloudcarousel" width="40" height="40" src="/assets/problem.png" alt="Problem" title="Problem"/><img class="cloudcarousel" width="40" height="40" src="/assets/question.png" alt="Question" title="Question"/><img class="cloudcarousel" width="40" height="40" src="/assets/reference.png" alt="Reference" title="Reference"/><img class="cloudcarousel" width="40" height="40" src="/assets/requirement.png" alt="Requirement" title="Requirement"/><img class="cloudcarousel" width="40" height="40" src="/assets/resource.png" alt="Resource" title="Resource"/><img class="cloudcarousel" width="40" height="40" src="/assets/role.png" alt="Role" title="Role"/><img class="cloudcarousel" width="40" height="40" src="/assets/task.png" alt="Task" title="Task"/><img class="cloudcarousel" width="40" height="40" src="/assets/tool.png" alt="Tool" title="Tool"/><img class="cloudcarousel" width="40" height="40" src="/assets/trajectory.png" alt="Trajectory" title="Trajectory"/></div>
|
||||
<%= form.autocomplete_field :name, autocomplete_topic_name_topics_path, :placeholder => "What is the name of your topic?" %>
|
||||
<%= form.hidden_field :metacode, :value => "Action" %>
|
||||
<%= form.hidden_field :x, :value => 0 %>
|
||||
<%= form.hidden_field :y, :value => 0 %>
|
||||
<%= form.hidden_field :grabTopic, :value => "null" %>
|
||||
<%= form.hidden_field :addSynapse, :value => false %>
|
||||
<!--<input id="left-but" type="button" value="Left" />-->
|
||||
<div id="metacodeImgTitle"></div>
|
||||
<!--<input id="right-but" type="button" value="Right" />-->
|
||||
<div class="clearfloat"></div>
|
||||
<% end %>
|
||||
</div>
|
10
app/views/topics/_topic.html.erb
Normal file
10
app/views/topics/_topic.html.erb
Normal file
|
@ -0,0 +1,10 @@
|
|||
<%= div_for topic, class: topic.metacode.name do %>
|
||||
<% if topic.user == user %><%= link_to 'Delete', topic_path(topic), :class => 'delete', :confirm => 'Delete this topic and all synapses linking to it?', :method => :delete, :remote => true%><% end %>
|
||||
<p class="type"><%= topic.metacode.name %></p>
|
||||
<%= image_tag topic.metacode.icon, :class => 'icon', :size => '50x50' %>
|
||||
<div class="scroll">
|
||||
<%= link_to topic.name, topic_path(topic), :class => 'title' %>
|
||||
<div class="desc"><p><%=topic.desc %></p></div>
|
||||
</div>
|
||||
<%= link_to topic.link, topic.link, :class => 'link', :target => '_blank' %>
|
||||
<% end %>
|
83
app/views/topics/create.js.erb
Normal file
83
app/views/topics/create.js.erb
Normal file
|
@ -0,0 +1,83 @@
|
|||
$('#new_topic').fadeOut('fast');
|
||||
$('#topic_name').data().autocomplete.term = null;
|
||||
$('.ui-autocomplete').children().remove();
|
||||
$('.ui-autocomplete').css('display','none');
|
||||
$('#topic_name').attr('value','');
|
||||
$('#topic_grabTopic').attr('value','null');
|
||||
$('#topic_addSynapse').attr('value','false');
|
||||
|
||||
|
||||
|
||||
var newnode = <%= @topic.self_as_json.html_safe %>;
|
||||
var x = <%= @position['x'] %>;
|
||||
var y = <%= @position['y'] %>;
|
||||
|
||||
|
||||
if (!$.isEmptyObject(Mconsole.graph.nodes)) {
|
||||
Mconsole.graph.addNode(newnode);
|
||||
|
||||
// set the animation for everything back to normal
|
||||
Mconsole.graph.eachNode( function (n) {
|
||||
n.setData('dim', 25, 'start');
|
||||
n.setData('dim', 25, 'end');
|
||||
});
|
||||
var temp = Mconsole.graph.getNode('<%= @topic.id %>');
|
||||
temp.setData('dim', 1, 'start');
|
||||
temp.setData('dim', 40, 'end');
|
||||
|
||||
if (gType == "centered") {
|
||||
var tempPos = new $jit.Complex(x, y);
|
||||
tempPos = tempPos.toPolar();
|
||||
temp.setPos(tempPos, 'current');
|
||||
temp.setPos(tempPos, 'start');
|
||||
temp.setPos(tempPos, 'end');
|
||||
}
|
||||
else if (gType == "arranged" || gType == "chaotic") {
|
||||
temp.setData('xloc',0);
|
||||
temp.setData('yloc',0);
|
||||
temp.setData('mappingid', '<%= @mapping.id %>');
|
||||
temp.setPos(new $jit.Complex(x, y), 'current');
|
||||
temp.setPos(new $jit.Complex(x, y), 'start');
|
||||
temp.setPos(new $jit.Complex(x, y), 'end');
|
||||
}
|
||||
|
||||
if ( '<%= @synapse %>' == "true" ) {
|
||||
$('#synapse_topic1id').val(tempNode.id);
|
||||
$('#synapse_topic2id').val(temp.id);
|
||||
$('#new_synapse').fadeIn('fast');
|
||||
$('#synapse_desc').focus();
|
||||
Mconsole.fx.animate({
|
||||
modes: ['node-property:dim'],
|
||||
duration: 500,
|
||||
onComplete: function() {
|
||||
renderMidArrow({ x: tempNode.pos.getc().x, y: tempNode.pos.getc().y }, { x: temp.pos.getc().x, y: temp.pos.getc().y }, 13, false, Mconsole.canvas);
|
||||
Mconsole.fx.plotNode(tempNode, Mconsole.canvas);
|
||||
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
||||
tempNode = null;
|
||||
tempNode2 = null;
|
||||
tempInit = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
||||
Mconsole.fx.animate({
|
||||
modes: ['node-property:dim'],
|
||||
duration: 500
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
json = newnode;
|
||||
Mconsole.loadJSON(json);
|
||||
var temp = Mconsole.graph.getNode('<%= @topic.id %>');
|
||||
temp.setData('dim', 1, 'start');
|
||||
temp.setData('dim', 25, 'end');
|
||||
temp.setPos(new $jit.Complex(x, y), 'current');
|
||||
temp.setPos(new $jit.Complex(x, y), 'start');
|
||||
temp.setPos(new $jit.Complex(x, y), 'end');
|
||||
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
||||
Mconsole.fx.animate({
|
||||
modes: ['node-property:dim'],
|
||||
duration: 500
|
||||
});
|
||||
}
|
1
app/views/topics/destroy.js.erb
Normal file
1
app/views/topics/destroy.js.erb
Normal file
|
@ -0,0 +1 @@
|
|||
$('#<%= dom_id(@topic) %>').fadeOut('slow');
|
14
app/views/topics/edit.html.erb
Normal file
14
app/views/topics/edit.html.erb
Normal file
|
@ -0,0 +1,14 @@
|
|||
<%= form_for @topic, url: topic_url do |form| %>
|
||||
<h3>Edit Topic</h3>
|
||||
<label for="category">Category</label>
|
||||
<%= select "category", "metacode_id", Metacode.order("name ASC").all.collect {|p| [ p.name, p.id ] }, { :selected => @topic.metacode.id } %>
|
||||
<label for="topic_name">Title</label>
|
||||
<%= form.text_field :name %>
|
||||
<label for="topic_desc">Description</label>
|
||||
<%= form.text_area :desc, class: "description", :rows => 5 %>
|
||||
<label for="topic_link">Link</label>
|
||||
<%= form.text_field :link, class: "link" %>
|
||||
<label for="topic_permission">Permission</label>
|
||||
<%= form.select :permission, options_for_select(['commons', 'public', 'private'], @topic.permission) %>
|
||||
<%= form.submit "Update", class: "update" %>
|
||||
<% end %>
|
11
app/views/topics/index.html.erb
Normal file
11
app/views/topics/index.html.erb
Normal file
|
@ -0,0 +1,11 @@
|
|||
<h1 class="index"><% if @user %><%= @user.name %>'s<% end %> Topics</h1>
|
||||
|
||||
<div class="topics" id="cards">
|
||||
<% @topics.each do |topic| %>
|
||||
<%= render topic %>
|
||||
<% end %>
|
||||
<% if @topics.empty? %>
|
||||
<p class="empty"><br>Shucks, there are no topics. <% if authenticated? %><%= link_to "Create some if you want.", console_url %><% end %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="clearfloat"></div>
|
16
app/views/topics/new.html.erb
Normal file
16
app/views/topics/new.html.erb
Normal file
|
@ -0,0 +1,16 @@
|
|||
<div class="nothidden">
|
||||
<%= form_for @topic || Topic.new, url: topics_path do |form| %>
|
||||
<h3>Add Topic</h3>
|
||||
<label for="category">Category</label>
|
||||
<%= select_tag "category", options_from_collection_for_select(Metacode.order("name ASC").all, "id", "name") %>
|
||||
<label for="topic_name">Title</label>
|
||||
<%= form.text_field :name %>
|
||||
<label for="topic_desc">Description</label>
|
||||
<%= form.text_area :desc, class: "description", :rows => 5 %>
|
||||
<label for="topic_link">Link</label>
|
||||
<%= form.text_field :link, class: "link" %>
|
||||
<label for="topic_permission">Permission</label>
|
||||
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
|
||||
<%= form.submit "Add Topic", class: "addTopic", id: "addTopic" %>
|
||||
<% end %>
|
||||
</div>
|
38
app/views/topics/show.html.erb
Normal file
38
app/views/topics/show.html.erb
Normal file
|
@ -0,0 +1,38 @@
|
|||
<div class="focus">
|
||||
<div class="focusleft">
|
||||
<p><%= @topic.metacode.name %></p>
|
||||
<%= image_tag @topic.metacode.icon, :class => 'icon', :size => '50x50' %>
|
||||
</div>
|
||||
<div class="focusmiddle">
|
||||
<h1 class="title"><%= @topic.name %> <% if (@topic.permission == "commons" && authenticated?) || @topic.user == user %><%= link_to "[edit]", edit_topic_path(@topic) %><% end %></h1>
|
||||
<div class="desc">
|
||||
<p><%= @topic.desc %></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="focusright">
|
||||
<p>Link</p>
|
||||
<%= link_to @topic.link, @topic.link, :class => 'link', :target => '_blank' %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfloat nodemargin"></div>
|
||||
|
||||
<div class="relatives" id="container">
|
||||
<div id="center-container">
|
||||
<div id="infovis"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfloat"></div>
|
||||
|
||||
<script>
|
||||
json = <%= @relatives %>;
|
||||
console.log(json);
|
||||
$(document).ready(function() {
|
||||
initialize("centered");
|
||||
});
|
||||
</script>
|
||||
|
||||
<% if authenticated? %>
|
||||
<%= render :partial => 'topics/new' %>
|
||||
<%= render :partial => 'synapses/new' %>
|
||||
<% end %>
|
||||
|
29
app/views/topics/showcard.html.erb
Normal file
29
app/views/topics/showcard.html.erb
Normal file
|
@ -0,0 +1,29 @@
|
|||
<div class="showcard topic_<%= @topic.id %>">
|
||||
<div class="CardOnGraph" title="Click to Hide" id="topic_' + node.id + '">
|
||||
<p class="type">
|
||||
<%= @topic.metacode.name %>
|
||||
</p>
|
||||
<img alt="<%= @topic.metacode.name %>"
|
||||
src="/assets/<%= @topic.metacode.name %>.png"
|
||||
class="icon" height="50" width="50" />
|
||||
<div class="scroll">
|
||||
<a href="/topics/<%=@topic.id%>" class="title">
|
||||
<%= @topic.name %>
|
||||
</a>
|
||||
<div class="contributor">
|
||||
Added by:
|
||||
<a href="/users/<%= @user.id %>">
|
||||
<%= @user.name %>
|
||||
</a>
|
||||
</div>
|
||||
<div class="desc">
|
||||
<p>
|
||||
<%= @topic.desc %>
|
||||
</p>
|
||||
</div>
|
||||
</div><!-- div.scroll -->
|
||||
<a href="<%= @topic.link %>" class="link" target="_blank">
|
||||
<%= @topic.link %>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
|
@ -1,13 +1,13 @@
|
|||
<div class="focus">
|
||||
<div class="focusleft">
|
||||
<p># of Topics: <%= @user.items.count %></p>
|
||||
<p># of Topics: <%= @user.topics.count %></p>
|
||||
<p># of Synapses: <%= @user.synapses.count %></p>
|
||||
<p># of Maps: <%= @user.maps.count %></p>
|
||||
</div>
|
||||
<div class="focusmiddle">
|
||||
<h1 class="title"><%= @user.name %></h1>
|
||||
<div class="desc">
|
||||
<p><%= link_to "View their topics", user_items_path(@user)%></p>
|
||||
<p><%= link_to "View their topics", user_topics_path(@user)%></p>
|
||||
<p><%= link_to "View their synapses", user_synapses_path(@user)%></p>
|
||||
<p><%= link_to "View their maps", user_maps_path(@user) %></p>
|
||||
</div>
|
||||
|
|
|
@ -14,8 +14,8 @@ ISSAD::Application.routes.draw do
|
|||
|
||||
resource :session
|
||||
|
||||
resources :items do
|
||||
get :autocomplete_item_name, :on => :collection
|
||||
resources :topics do
|
||||
get :autocomplete_topic_name, :on => :collection
|
||||
end
|
||||
|
||||
resources :synapses do
|
||||
|
@ -28,7 +28,7 @@ ISSAD::Application.routes.draw do
|
|||
|
||||
resources :users do
|
||||
get :autocomplete_user_name, :on => :collection
|
||||
resources :items, :only => [:index]
|
||||
resources :topics, :only => [:index]
|
||||
resources :synapses, :only => [:index]
|
||||
resources :maps, :only => [:index]
|
||||
end
|
||||
|
|
|
@ -3,8 +3,8 @@ class CreateUsers < ActiveRecord::Migration
|
|||
create_table :users do |t|
|
||||
t.string :name
|
||||
t.string :email
|
||||
t.string :code, :limit => 8
|
||||
t.string :joinedwithcode, :limit => 8
|
||||
t.string :code, :limit => 8
|
||||
t.string :joinedwithcode, :limit => 8
|
||||
t.string :crypted_password
|
||||
t.string :password_salt
|
||||
t.string :persistence_token
|
||||
|
|
|
@ -2,12 +2,12 @@ class CreateSynapses < ActiveRecord::Migration
|
|||
def change
|
||||
create_table :synapses do |t|
|
||||
t.text :desc
|
||||
t.text :category
|
||||
t.text :weight
|
||||
t.text :permission
|
||||
t.integer :node1_id
|
||||
t.integer :node2_id
|
||||
t.integer :user_id
|
||||
t.text :category
|
||||
t.text :weight
|
||||
t.text :permission
|
||||
t.integer :node1_id
|
||||
t.integer :node2_id
|
||||
t.integer :user_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
|
|
@ -2,12 +2,12 @@ class CreateMappings < ActiveRecord::Migration
|
|||
def change
|
||||
create_table :mappings do |t|
|
||||
t.text :category
|
||||
t.integer :xloc
|
||||
t.integer :xloc
|
||||
t.integer :yloc
|
||||
t.integer :item_id
|
||||
t.integer :synapse_id
|
||||
t.integer :map_id
|
||||
t.integer :user_id
|
||||
t.integer :topic_id
|
||||
t.integer :synapse_id
|
||||
t.integer :map_id
|
||||
t.integer :user_id
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
|
13
db/migrate/20130101193917_create_topics.rb
Normal file
13
db/migrate/20130101193917_create_topics.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class CreateTopics < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :topics do |t|
|
||||
t.text :name
|
||||
t.text :desc
|
||||
t.text :link
|
||||
t.text :permission
|
||||
t.integer :user_id
|
||||
t.integer :metacode_id
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
10
db/migrate/20130101194424_create_metacodes.rb
Normal file
10
db/migrate/20130101194424_create_metacodes.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class CreateMetacodes < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :metacodes do |t|
|
||||
t.text :name
|
||||
t.string :icon
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
9
db/migrate/20130101215010_items_to_topics.rb
Normal file
9
db/migrate/20130101215010_items_to_topics.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class ItemsToTopics < ActiveRecord::Migration
|
||||
def change
|
||||
rename_column :items, :item_category_id, :metacode_id
|
||||
rename_column :mappings, :item_id, :topic_id
|
||||
|
||||
rename_table :items, :topics
|
||||
rename_table :item_categories, :metacodes
|
||||
end
|
||||
end
|
22
db/schema.rb
22
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20121203225613) do
|
||||
ActiveRecord::Schema.define(:version => 20130101215010) do
|
||||
|
||||
create_table "item_categories", :force => true do |t|
|
||||
t.text "name"
|
||||
|
@ -35,7 +35,7 @@ ActiveRecord::Schema.define(:version => 20121203225613) do
|
|||
t.text "category"
|
||||
t.integer "xloc"
|
||||
t.integer "yloc"
|
||||
t.integer "item_id"
|
||||
t.integer "topic_id"
|
||||
t.integer "synapse_id"
|
||||
t.integer "map_id"
|
||||
t.integer "user_id"
|
||||
|
@ -53,6 +53,13 @@ ActiveRecord::Schema.define(:version => 20121203225613) do
|
|||
t.boolean "arranged"
|
||||
end
|
||||
|
||||
create_table "metacodes", :force => true do |t|
|
||||
t.text "name"
|
||||
t.string "icon"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "synapses", :force => true do |t|
|
||||
t.text "desc"
|
||||
t.text "category"
|
||||
|
@ -65,6 +72,17 @@ ActiveRecord::Schema.define(:version => 20121203225613) do
|
|||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "topics", :force => true do |t|
|
||||
t.text "name"
|
||||
t.text "desc"
|
||||
t.text "link"
|
||||
t.text "permission"
|
||||
t.integer "user_id"
|
||||
t.integer "metacode_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "users", :force => true do |t|
|
||||
t.string "name"
|
||||
t.string "email"
|
||||
|
|
4
test/fixtures/mappings.yml
vendored
4
test/fixtures/mappings.yml
vendored
|
@ -4,8 +4,8 @@
|
|||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
#one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
#two: {}
|
||||
# column: value
|
||||
|
|
117
test/fixtures/metacodes.yml
vendored
Normal file
117
test/fixtures/metacodes.yml
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one:
|
||||
name: Action
|
||||
icon: action.png
|
||||
|
||||
two:
|
||||
name: Activity
|
||||
icon: activity.png
|
||||
|
||||
three:
|
||||
name: Bizarre
|
||||
icon: bizarre.png
|
||||
|
||||
four:
|
||||
name: Catalyst
|
||||
icon: catalyst.png
|
||||
|
||||
five:
|
||||
name: Closed
|
||||
icon: closed.png
|
||||
|
||||
six:
|
||||
name: Experience
|
||||
icon: experience.png
|
||||
|
||||
seven:
|
||||
name: Future Dev
|
||||
icon: futuredev.png
|
||||
|
||||
eight:
|
||||
name: Group
|
||||
icon: group.png
|
||||
|
||||
nine:
|
||||
name: Idea
|
||||
icon: idea.png
|
||||
|
||||
ten:
|
||||
name: Implication
|
||||
icon: implication.png
|
||||
|
||||
eleven:
|
||||
name: Insight
|
||||
icon: insight.png
|
||||
|
||||
twelve:
|
||||
name: Intention
|
||||
icon: intention.png
|
||||
|
||||
thirteen:
|
||||
name: Knowledge
|
||||
icon: knowledge.png
|
||||
|
||||
fourteen:
|
||||
name: Location
|
||||
icon: location.png
|
||||
|
||||
fifteen:
|
||||
name: Open Issue
|
||||
icon: openissue.png
|
||||
|
||||
sixteen:
|
||||
name: Opinion
|
||||
icon: opinion.png
|
||||
|
||||
seventeen:
|
||||
name: Opportunity
|
||||
icon: opportunity.png
|
||||
|
||||
eighteen:
|
||||
name: Person
|
||||
icon: person.png
|
||||
|
||||
nineteen:
|
||||
name: Platform
|
||||
icon: platform.png
|
||||
|
||||
twenty:
|
||||
name: Problem
|
||||
icon: problem.png
|
||||
|
||||
twenty-one:
|
||||
name: Question
|
||||
icon: question.png
|
||||
|
||||
twenty-two:
|
||||
name: Reference
|
||||
icon: reference.png
|
||||
|
||||
twenty-three:
|
||||
name: Requirement
|
||||
icon: requirement.png
|
||||
|
||||
twenty-four:
|
||||
name: Resource
|
||||
icon: resource.png
|
||||
|
||||
twenty-five:
|
||||
name: Role
|
||||
icon: role.png
|
||||
|
||||
twenty-six:
|
||||
name: Task
|
||||
icon: task.png
|
||||
|
||||
twenty-seven:
|
||||
name: Tool
|
||||
icon: tool.png
|
||||
|
||||
twenty-eight:
|
||||
name: Trajectory
|
||||
icon: trajectory.png
|
11
test/fixtures/topics.yml
vendored
Normal file
11
test/fixtures/topics.yml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
#one: {}
|
||||
# column: value
|
||||
#
|
||||
#two: {}
|
||||
# column: value
|
7
test/functional/topics_controller_test.rb
Normal file
7
test/functional/topics_controller_test.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class TopicsControllerTest < ActionController::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
4
test/unit/helpers/topics_helper_test.rb
Normal file
4
test/unit/helpers/topics_helper_test.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class TopicsHelperTest < ActionView::TestCase
|
||||
end
|
7
test/unit/metacode_test.rb
Normal file
7
test/unit/metacode_test.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class MetacodeTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
7
test/unit/topic_test.rb
Normal file
7
test/unit/topic_test.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class TopicTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in a new issue