From 775d97cdbbf60a1d8a5821febd801c610444d5de Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Wed, 17 Oct 2012 20:51:54 -0400 Subject: [PATCH] initial commit --- .../javascripts/Jit/ForceDirected/metamap.js | 182 ++++++++++++++++-- app/assets/javascripts/application.js | 2 + app/assets/stylesheets/ForceDirected.css | 54 +++--- app/assets/stylesheets/application.css | 8 +- app/assets/stylesheets/base.css | 8 +- app/assets/stylesheets/items.css.scss | 2 +- app/controllers/items_controller.rb | 6 +- app/controllers/main_controller.rb | 12 +- app/controllers/synapses_controller.rb | 73 ++----- app/models/item.rb | 27 +-- app/models/synapse.rb | 6 - app/models/user.rb | 3 +- app/views/items/edit.html.erb | 69 +------ app/views/items/index.html.erb | 4 +- app/views/items/show.html.erb | 46 +---- app/views/layouts/application.html.erb | 15 +- app/views/main/home.html.erb | 2 +- app/views/main/userobjects.html.erb | 2 +- app/views/main/usersynapses.html.erb | 9 + app/views/synapses/index.html.erb | 11 ++ app/views/synapses/new.html.erb | 37 +--- app/views/synapses/show.html.erb | 16 +- config/database.yml | 18 +- config/routes.rb | 3 +- db/migrate/20120920014810_create_items.rb | 2 - db/schema.rb | 61 ------ test/fixtures/item_categories.yml | 17 +- 27 files changed, 286 insertions(+), 409 deletions(-) create mode 100644 app/views/main/usersynapses.html.erb create mode 100644 app/views/synapses/index.html.erb diff --git a/app/assets/javascripts/Jit/ForceDirected/metamap.js b/app/assets/javascripts/Jit/ForceDirected/metamap.js index 0c4f2e20..5b2bb78f 100644 --- a/app/assets/javascripts/Jit/ForceDirected/metamap.js +++ b/app/assets/javascripts/Jit/ForceDirected/metamap.js @@ -10,6 +10,7 @@ var labelType, useGradients, nativeTextSupport, animate, json; //I'm setting this based on the fact that ExCanvas provides text support for IE //and that as of today iPhone/iPad current text support is lame labelType = (!nativeCanvasSupport || (textSupport && !iStuff))? 'Native' : 'HTML'; + console.log(labelType); nativeTextSupport = labelType == 'Native'; useGradients = nativeCanvasSupport; animate = !(iStuff || !nativeCanvasSupport); @@ -25,9 +26,56 @@ var Log = { } }; +var imgArray = new Object(); + +imgArray['Group'] = new Image(); imgArray['Group'].src = '/assets/group.png'; +imgArray['Person'] = new Image(); imgArray['Person'].src = '/assets/person.png'; +imgArray['Bizarre'] = new Image(); imgArray['Bizarre'].src = '/assets/bizarre.png'; +imgArray['Catalyst'] = new Image(); imgArray['Catalyst'].src = '/assets/catalyst.png'; +imgArray['Closed'] = new Image(); imgArray['Closed'].src = '/assets/closed.png'; +imgArray['Experience'] = new Image(); imgArray['Experience'].src = '/assets/experience.png'; +imgArray['Future Dev'] = new Image(); imgArray['Future Dev'].src = '/assets/futuredev.png'; +imgArray['Idea'] = new Image(); imgArray['Idea'].src = '/assets/idea.png'; +imgArray['Implication'] = new Image(); imgArray['Implication'].src = '/assets/implication.png'; +imgArray['Insight'] = new Image(); imgArray['Insight'].src = '/assets/insight.png'; +imgArray['Intention'] = new Image(); imgArray['Intention'].src = '/assets/intention.png'; +imgArray['Knowledge'] = new Image(); imgArray['Knowledge'].src = '/assets/knowledge.png'; +imgArray['Location'] = new Image(); imgArray['Location'].src = '/assets/location.png'; +imgArray['Open Issue'] = new Image(); imgArray['Open Issue'].src = '/assets/openissue.png'; +imgArray['Opinion'] = new Image(); imgArray['Opinion'].src = '/assets/opinion.png'; +imgArray['Opportunity'] = new Image(); imgArray['Opportunity'].src = '/assets/opportunity.png'; +imgArray['Platform'] = new Image(); imgArray['Platform'].src = '/assets/platform.png'; +imgArray['Problem'] = new Image(); imgArray['Problem'].src = '/assets/problem.png'; +imgArray['Question'] = new Image(); imgArray['Question'].src = '/assets/question.png'; +imgArray['Reference'] = new Image(); imgArray['Reference'].src = '/assets/reference.png'; +imgArray['Requirement'] = new Image(); imgArray['Requirement'].src = '/assets/requirement.png'; +imgArray['Resource'] = new Image(); imgArray['Resource'].src = '/assets/resource.png'; +imgArray['Role'] = new Image(); imgArray['Role'].src = '/assets/role.png'; +imgArray['Task'] = new Image(); imgArray['Task'].src = '/assets/task.png'; +imgArray['Tool'] = new Image(); imgArray['Tool'].src = '/assets/tool.png'; +imgArray['Trajectory'] = new Image(); imgArray['Trajectory'].src = '/assets/trajectory.png'; +imgArray['Action'] = new Image(); imgArray['Action'].src = '/assets/action.png'; +imgArray['Activity'] = new Image(); imgArray['Activity'].src = '/assets/activity.png'; function init(){ - // init data + // init custom node type + $jit.ForceDirected.Plot.NodeTypes.implement({ + 'customNode': { + 'render': function (node, canvas) { + var pos = node.pos.getc(true), + dim = node.getData('dim'), + cat = node.getData('itemcatname'), + ctx = canvas.getCtx(); + ctx.drawImage(imgArray[cat], pos.x - dim, pos.y - dim, dim*2, dim*2); + + }, + 'contains': function(node, pos) { + var npos = node.pos.getc(true), + dim = node.getData('dim'); + return this.nodeHelper.circle.contains(npos, pos, dim); + } + } + }); // end // init ForceDirected var fd = new $jit.ForceDirected({ @@ -37,6 +85,7 @@ function init(){ //by scrolling and DnD Navigation: { enable: true, + type: 'HTML', //Enable panning events only if we're dragging the empty //canvas (and not a node). panning: 'avoid nodes', @@ -50,8 +99,8 @@ function init(){ Node: { overridable: true, color: '#2D6A5D', - type: 'circle', - dim: 15 + type: 'customNode', + dim: 25 }, Edge: { overridable: true, @@ -60,8 +109,8 @@ function init(){ }, //Native canvas text styling Label: { - type: labelType, //Native or HTML - size: 17, + type: 'HTML', //Native or HTML + size: 20, //style: 'bold' }, //Add Tips @@ -79,12 +128,13 @@ function init(){ // Add node events Events: { enable: true, + type: 'HTML', //Change cursor style when hovering a node onMouseEnter: function() { - fd.canvas.getElement().style.cursor = 'move'; + //fd.canvas.getElement().style.cursor = 'move'; }, onMouseLeave: function() { - fd.canvas.getElement().style.cursor = ''; + //fd.canvas.getElement().style.cursor = ''; }, //Update node positions when dragged onDragMove: function(node, eventInfo, e) { @@ -100,15 +150,40 @@ function init(){ //Add also a click handler to nodes onClick: function(node) { if(!node) return; + //set final styles + fd.graph.eachNode(function(n) { + if(n.id != node.id) delete n.selected; + n.setData('dim', 25, 'end'); + n.eachAdjacency(function(adj) { + adj.setDataset('end', { + lineWidth: 0.4, + color: '#d1d1d1' + }); + }); + }); + if(!node.selected) { + node.selected = true; + node.setData('dim', 35, 'end'); + node.eachAdjacency(function(adj) { + adj.setDataset('end', { + lineWidth: 3, + color: '#36acfb' + }); + }); + } else { + delete node.selected; + } + //trigger animation to final styles + fd.fx.animate({ + modes: ['node-property:dim', + 'edge-property:lineWidth:color'], + duration: 500 + }); // Build the right column relations list. // This is done by traversing the clicked node connections. - var html = "

" + node.name + "

has connections to:"; + $jit.id('inner-details').innerHTML = html; } }, //Number of iterations for the FD algorithm @@ -117,12 +192,74 @@ function init(){ levelDistance: 130, // Add text to the labels. This method is only triggered // on label creation and only for DOM labels (not native canvas ones). - onCreateLabel: function(domElement, node){ - domElement.innerHTML = node.name; - var style = domElement.style; - style.fontSize = "0.9em"; - style.color = "#fff"; - }, + onCreateLabel: function(domElement, node){ + // Create a 'name' and 'close' buttons and add them + // to the main node label + var nameContainer = document.createElement('span'), + closeButton = document.createElement('span'), + style = nameContainer.style; + nameContainer.className = 'name'; + nameContainer.innerHTML = node.name; + closeButton.className = 'close'; + closeButton.innerHTML = 'x'; + domElement.appendChild(nameContainer); + domElement.appendChild(closeButton); + style.fontSize = "0.9em"; + style.color = "#ddd"; + //Fade the node and its connections when + //clicking the close button + closeButton.onclick = function() { + node.setData('alpha', 0, 'end'); + node.eachAdjacency(function(adj) { + adj.setData('alpha', 0, 'end'); + }); + fd.fx.animate({ + modes: ['node-property:alpha', + 'edge-property:alpha'], + duration: 500 + }); + }; + //Toggle a node selection when clicking + //its name. This is done by animating some + //node styles like its dimension and the color + //and lineWidth of its adjacencies. + nameContainer.onclick = function() { + //set final styles + fd.graph.eachNode(function(n) { + if(n.id != node.id) delete n.selected; + n.setData('dim', 25, 'end'); + n.eachAdjacency(function(adj) { + adj.setDataset('end', { + lineWidth: 0.4, + color: '#d1d1d1' + }); + }); + }); + if(!node.selected) { + node.selected = true; + node.setData('dim', 35, 'end'); + node.eachAdjacency(function(adj) { + adj.setDataset('end', { + lineWidth: 3, + color: '#36acfb' + }); + }); + } else { + delete node.selected; + } + //trigger animation to final styles + fd.fx.animate({ + modes: ['node-property:dim', + 'edge-property:lineWidth:color'], + duration: 500 + }); + // Build the right column relations list. + // This is done by traversing the clicked node connections. + var html = '

' + node.getData("itemcatname") + '

' + node.getData(' + node.name + '

' + node.getData('desc') + '

' + node.getData('link') + '
'; + //append connections information + $jit.id('inner-details').innerHTML = html; + }; + }, // Change node styles when DOM labels are placed // or moved. onPlaceLabel: function(domElement, node){ @@ -130,8 +267,9 @@ function init(){ var left = parseInt(style.left); var top = parseInt(style.top); var w = domElement.offsetWidth; + var dim = node.getData('dim'); style.left = (left - w / 2) + 'px'; - style.top = (top + 10) + 'px'; + style.top = (top + dim) + 'px'; style.display = ''; } }); @@ -154,4 +292,8 @@ function init(){ } }); // end + fd.graph.eachNode(function(n) { + var x = n.getData('itemcatname'); + console.log(x); + }); } diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 135a7ccc..1fa65463 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -20,3 +20,5 @@ $(document).ready(function() { $('.nodemargin').css('padding-top',$('.focus').css('height')); }); + + diff --git a/app/assets/stylesheets/ForceDirected.css b/app/assets/stylesheets/ForceDirected.css index fd2cbb53..af2d26f4 100644 --- a/app/assets/stylesheets/ForceDirected.css +++ b/app/assets/stylesheets/ForceDirected.css @@ -1,27 +1,27 @@ -#inner-details { - font-size:12px; -} - -span.close { - color:#FF5555; - cursor:pointer; - font-weight:bold; - margin-left:3px; -} - -span.name { - cursor: pointer; -} - -/*TOOLTIPS*/ -.tip { - text-align: left; - width:auto; - max-width:500px; -} - -.tip-title { - font-size: 11px; - text-align:center; - margin-bottom:2px; -} +#inner-details { + +} + +span.close { + color:#FF5555; + cursor:pointer; + font-weight:bold; + margin-left:3px; +} + +span.name { + cursor: pointer; +} + +/*TOOLTIPS*/ +.tip { + text-align: left; + width:auto; + max-width:500px; +} + +.tip-title { + font-size: 11px; + text-align:center; + margin-bottom:2px; +} diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 9e241e5e..63877dd3 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -68,10 +68,4 @@ input[type="submit"] { margin-top:5px; } .focus .link { padding:0 0 0 10px; display:block; width:90%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .divider { margin: 20px 50px 20px 50px; border-bottom:2px solid #FFF; } -.empty { margin-left:50px; } - -.selecttype { display:block; margin:100px auto 0; width:500px; } -.selecttype button { display:inline-block; width:150px; height:50px; background: #2D6A5D; color: white; border-radius: 15px; cursor: pointer; } -.selecttype button:hover { border-width:4px; border-color:#CCC; } -.selecttype .middle { margin:0 20px; } -.newsynapses form {display:none; } \ No newline at end of file +.empty { margin-left:50px; } \ No newline at end of file diff --git a/app/assets/stylesheets/base.css b/app/assets/stylesheets/base.css index 6096ffa1..1153c4e6 100644 --- a/app/assets/stylesheets/base.css +++ b/app/assets/stylesheets/base.css @@ -1,15 +1,16 @@ #center-container { position:relative; height:500px; - width:80%; + width:70%; float:left; /* background-color:#031924; */ color:#ccc; + max-width:900px; } #right-container { height:500px; - width:19%; + width:29%; color:#FFF; text-align: left; overflow: auto; @@ -25,9 +26,6 @@ } #inner-details { - font-size:0.8em; - list-style:none; - margin:7px; } #log { diff --git a/app/assets/stylesheets/items.css.scss b/app/assets/stylesheets/items.css.scss index ad18e634..8bb0ca56 100644 --- a/app/assets/stylesheets/items.css.scss +++ b/app/assets/stylesheets/items.css.scss @@ -16,7 +16,7 @@ line-height: 24px;} .item .title { font-size:22px; line-height:25px; display:block; border-bottom:2px solid #000; padding-bottom:5px; } -.item .desc { font-style:italic; } +.item .desc { font-style:italic; font-size:15px; } .item .desc h3 { font-style:normal; margin-top:5px; } .item .link { position:absolute; width:170px; top:295px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 5e979446..d26bd06b 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -24,14 +24,10 @@ class ItemsController < ApplicationController def show @item = Item.find(params[:id]) - @gparents = @item.groups - @pparents = @item.people - @iparents = @item.parent_items @relatives = @item.as_json.html_safe - @ichildren = @item.child_items respond_to do |format| - format.html { respond_with(@item, @gparents, @pparents, @iparents, @ichildren) } + format.html { respond_with(@item) } format.json { respond_with(@relatives) } end end diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 2505dd54..5619d864 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -6,7 +6,7 @@ class MainController < ApplicationController def home @current_user = current_user - @all = Group.all + Person.all + Item.all + @all = Item.all respond_with(@all) end @@ -14,7 +14,15 @@ class MainController < ApplicationController def userobjects @user = current_user - @all = @user.groups + @user.people + @user.items + @all = @user.items + + respond_with(@all) + end + + def usersynapses + @user = current_user + + @all = @user.synapses respond_with(@all) end diff --git a/app/controllers/synapses_controller.rb b/app/controllers/synapses_controller.rb index 20c75c29..cc22f90e 100644 --- a/app/controllers/synapses_controller.rb +++ b/app/controllers/synapses_controller.rb @@ -14,18 +14,11 @@ class SynapsesController < ApplicationController # Get /synapse/new def new - @synapse1 = Synapse.new - @synapse1.category = "Group" - @synapse2 = Synapse.new - @synapse2.category = "Person" - @synapse3 = Synapse.new - @synapse3.category = "Item" + @synapse = Synapse.new @user = current_user - @allgroups = Group.all - @allpeople = Person.all @allitems = Item.all - respond_with(@synapse1, @synapse2, @synapse3, @allgroups, @allpeople, @allitems) + respond_with(@synapse, @allitems) end # GET /synapse/:id @@ -36,18 +29,8 @@ class SynapsesController < ApplicationController @node2 = nil if @synapse - if (@synapse.category == "Group") - @node1 = @synapse.group1 - @node2 = @synapse.group2 - end - if (@synapse.category == "Person") - @node1 = @synapse.person1 - @node2 = @synapse.person2 - end - if (@synapse.category == "Item") - @node1 = @synapse.item1 - @node2 = @synapse.item2 - end + @node1 = @synapse.item1 + @node2 = @synapse.item2 end respond_to do |format| @@ -63,20 +46,9 @@ class SynapsesController < ApplicationController @synapse = Synapse.new() @synapse.desc = params[:synapse][:desc] @synapse.category = params[:category] - if ( @synapse.category == "Group" ) - @synapse.group1 = Group.find(params[:node1_id]) - @synapse.group2 = Group.find(params[:node2_id]) - end - if ( @synapse.category == "Person" ) - @synapse.person1 = Person.find(params[:node1_id]) - @synapse.person2 = Person.find(params[:node2_id]) - end - if ( @synapse.category == "Item" ) - @synapse.item1 = Item.find(params[:node1_id]) - @synapse.item2 = Item.find(params[:node2_id]) - end - @synapse.user = @user - + @synapse.item1 = Item.find(params[:node1_id]) + @synapse.item2 = Item.find(params[:node2_id]) + @synapse.user = @user @synapse.save respond_to do |format| @@ -90,22 +62,13 @@ class SynapsesController < ApplicationController def edit @synapse = Synapse.find_by_id(params[:id]) - @collection1 = nil - @collection2 = nil + @items = nil - if @synapse - if (@synapse.category == "Group") - @collection = Group.all - end - if (@synapse.category == "Person") - @collection = Person.all - end - if (@synapse.category == "Item") - @collection = Item.all - end + if @synapse + @items = Item.all end - respond_with(@synapse, @collection) + respond_with(@synapse, @items) end # PUT /actions/:id @@ -114,18 +77,8 @@ class SynapsesController < ApplicationController if @synapse @synapse.desc = params[:synapse][:desc] - if ( @synapse.category == "Group" ) - @synapse.group1 = Group.find(params[:node1_id][:node1]) - @synapse.group2 = Group.find(params[:node2_id][:node2]) - end - if ( @synapse.category == "Person" ) - @synapse.person1 = Person.find(params[:node1_id][:node1]) - @synapse.person2 = Person.find(params[:node2_id][:node2]) - end - if ( @synapse.category == "Item" ) - @synapse.item1 = Item.find(params[:node1_id][:node1]) - @synapse.item2 = Item.find(params[:node2_id][:node2]) - end + @synapse.item1 = Item.find(params[:node1_id][:node1]) + @synapse.item2 = Item.find(params[:node2_id][:node2]) @synapse.save end diff --git a/app/models/item.rb b/app/models/item.rb index 30da4be6..5a78f76d 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -2,17 +2,8 @@ class Item < ActiveRecord::Base belongs_to :user -has_many :itemitem_c, :foreign_key => 'parent_item_id', :class_name => 'Itemitem' -has_many :itemitem_p, :foreign_key => 'item_id', :class_name => 'Itemitem' - -has_many :groupitems -has_many :personitems - -has_many :groups, :through => :groupitems -has_many :people, :through => :personitems - -has_many :synapses1, :class_name => 'Synapse', :foreign_key => 'node1_id', :conditions => {:category => 'Item'} -has_many :synapses2, :class_name => 'Synapse', :foreign_key => 'node2_id', :conditions => {:category => 'Item'} +has_many :synapses1, :class_name => 'Synapse', :foreign_key => 'node1_id' #, :conditions => {:category => 'Item'} +has_many :synapses2, :class_name => 'Synapse', :foreign_key => 'node2_id' #, :conditions => {:category => 'Item'} has_many :items1, :through => :synapses2, :source => :item1 has_many :items2, :through => :synapses1, :source => :item2 @@ -26,14 +17,12 @@ has_many :items2, :through => :synapses1, :source => :item2 belongs_to :item_category -has_many :child_items, :through => :itemitem_c, :source => :item -has_many :parent_items, :through => :itemitem_p, :source => :parent_item - def as_json Jbuilder.encode do |json| @single = Array.new @single.push(self) - @items = @single + self.relatives + #@items = @single + self.relatives + @items = Item.all json.array!(@items) do |item| json.adjacencies item.synapses2.delete_if{|synapse| not @items.include?(Item.find_by_id(synapse.node1_id))} do |json, synapse| @@ -41,13 +30,15 @@ has_many :parent_items, :through => :itemitem_p, :source => :parent_item json.nodeFrom synapse.node2_id @synapsedata = Hash.new - @synapsedata['desc'] = synapse.desc + @synapsedata['$desc'] = synapse.desc + @synapsedata['$category'] = synapse.category json.data @synapsedata end @itemdata = Hash.new - @itemdata['desc'] = item.desc - @itemdata['link'] = item.link + @itemdata['$desc'] = item.desc + @itemdata['$link'] = item.link + @itemdata['$itemcatname'] = item.item_category.name json.data @itemdata json.id item.id json.name item.name diff --git a/app/models/synapse.rb b/app/models/synapse.rb index 6e5d5e8f..a328b65f 100644 --- a/app/models/synapse.rb +++ b/app/models/synapse.rb @@ -5,10 +5,4 @@ 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 :person1, :class_name => "Person", :foreign_key => "node1_id" -belongs_to :person2, :class_name => "Person", :foreign_key => "node2_id" - -belongs_to :group1, :class_name => "Group", :foreign_key => "node1_id" -belongs_to :group2, :class_name => "Group", :foreign_key => "node2_id" - end diff --git a/app/models/user.rb b/app/models/user.rb index a8df29df..2866db53 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,9 +2,8 @@ require 'open-uri' class User < ActiveRecord::Base -has_many :people -has_many :groups has_many :items +has_many :synapses acts_as_authentic do |configuration| configuration.session_class = Session diff --git a/app/views/items/edit.html.erb b/app/views/items/edit.html.erb index b3a7ef8c..ee94d764 100644 --- a/app/views/items/edit.html.erb +++ b/app/views/items/edit.html.erb @@ -7,73 +7,6 @@ <%= form.text_area :desc, class: "description", :rows => 5 %> - <%= form.text_field :link, class: "link" %> - - <% if @ingroups.count > 0 %> - - <%= select_tag "ingroups", options_from_collection_for_select(@ingroups, "id", "name"), { :multiple => true } %> - <% else %> -
- <%= select_tag "ingroups", options_from_collection_for_select(@ingroups, "id", "name"), { :multiple => true } %> -
- <% end %> - <% if @outgroups.count > 0 %> - - <%= select_tag "outgroups", options_from_collection_for_select(@outgroups, "id", "name"), { :multiple => true } %> - <% else %> -
- <%= select_tag "outgroups", options_from_collection_for_select(@outgroups, "id", "name"), { :multiple => true } %> -
- <% end %> - <% if @inpeople.count > 0 %> - - <%= select_tag "inpeople", options_from_collection_for_select(@inpeople, "id", "name"), { :multiple => true } %> - <% else %> -
- <%= select_tag "inpeople", options_from_collection_for_select(@inpeople, "id", "name"), { :multiple => true } %> -
- <% end %> - <% if @outpeople.count > 0 %> - - <%= select_tag "outpeople", options_from_collection_for_select(@outpeople, "id", "name"), { :multiple => true } %> - <% else %> -
- <%= select_tag "outpeople", options_from_collection_for_select(@outpeople, "id", "name"), { :multiple => true } %> -
- <% end %> - - <% if @initems1.count > 0 %> - - <%= select_tag "initems1", options_from_collection_for_select(@initems1, "id", "name"), { :multiple => true } %> - <% else %> -
- <%= select_tag "initems1", options_from_collection_for_select(@initems1, "id", "name"), { :multiple => true } %> -
- <% end %> - <% if @outitems1.count > 0 %> - - <%= select_tag "outitems1", options_from_collection_for_select(@outitems1, "id", "name"), { :multiple => true } %> - <% else %> -
- <%= select_tag "outitems1", options_from_collection_for_select(@outitems1, "id", "name"), { :multiple => true } %> -
- <% end %> - <% if @initems2.count > 0 %> - - <%= select_tag "initems2", options_from_collection_for_select(@initems2, "id", "name"), { :multiple => true } %> - <% else %> -
- <%= select_tag "initems2", options_from_collection_for_select(@initems2, "id", "name"), { :multiple => true } %> -
- <% end %> - <% if @outitems2.count > 0 %> - - <%= select_tag "outitems2", options_from_collection_for_select(@outitems2, "id", "name"), { :multiple => true } %> - <% else %> -
- <%= select_tag "outitems2", options_from_collection_for_select(@outitems2, "id", "name"), { :multiple => true } %> -
- <% end %> - + <%= form.text_field :link, class: "link" %> <%= form.submit "Update", class: "update" %> <% end %> \ No newline at end of file diff --git a/app/views/items/index.html.erb b/app/views/items/index.html.erb index 570e2198..fa7d4916 100644 --- a/app/views/items/index.html.erb +++ b/app/views/items/index.html.erb @@ -1,11 +1,11 @@ -

Items

+

All Topics

<% @items.each do |item| %> <%= render item %> <% end %> <% if @items.empty? %> -


Shucks, there are no items.

+


Shucks, there are no topics.

<% end %>

diff --git a/app/views/items/show.html.erb b/app/views/items/show.html.erb index b9c0d01d..647d6ef4 100644 --- a/app/views/items/show.html.erb +++ b/app/views/items/show.html.erb @@ -17,39 +17,6 @@
-
-
<%= @item.name %> is included in these groups
- <% @gparents.each do |group| %> - <%= render group %> - <% end %> - <% if @gparents.empty? %> -

Shucks, there are no groups.

- <% end %> -
-
- -
-
<%= @item.name %> is included by these people
- <% @pparents.each do |person| %> - <%= render person %> - <% end %> - <% if @pparents.empty? %> -

Shucks, there are no people.

- <% end %> -
-
- -
-
<%= @item.name %> is included by these items
- <% @iparents.each do |item| %> - <%= render item %> - <% end %> - <% if @iparents.empty? %> -

Shucks, there are no items.

- <% end %> -
-
-
<%= @item.name %> is connected to these items
@@ -68,15 +35,4 @@ $(document).ready(function() { init(); }); - - -
-
<%= @item.name %> includes these items
- <% @ichildren.each do |item| %> - <%= render item %> - <% end %> - <% if @ichildren.empty? %> -

Shucks, there are no items.

- <% end %> -
-
+ \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2c2eac2a..98476fe1 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -15,25 +15,20 @@
  • <%= link_to "Login", new_session_path, id: "Login" %>
  • |
  • -
  • <%= link_to "Items", items_path %>
  • -
  • <%= link_to "People", people_path %>
  • -
  • <%= link_to "Groups", groups_path %>
  • +
  • <%= link_to "Topics", items_path %>
<% end %> <% if authenticated? %>
  • <%= link_to "Logout", session_path, method: 'delete', id: "Login" %>
  • -
  • <%= link_to "My Cards", userobjects_path %>
  • +
  • <%= link_to "My Synapses", usersynapses_path %>
  • +
  • <%= link_to "My Topics", userobjects_path %>
  • |
  • <%= link_to "Add Synapse", new_synapse_path %>
  • |
  • -
  • <%= link_to "Add Item", new_item_path %>
  • -
  • <%= link_to "Add Person", new_person_path %>
  • -
  • <%= link_to "Add Group", new_group_path %>
  • +
  • <%= link_to "Add Topic", new_item_path %>
  • |
  • -
  • <%= link_to "Items", items_path %>
  • -
  • <%= link_to "People", people_path %>
  • -
  • <%= link_to "Groups", groups_path %>
  • +
  • <%= link_to "Topics", items_path %>
<% end %>
diff --git a/app/views/main/home.html.erb b/app/views/main/home.html.erb index 2e95ed2a..59ef992d 100644 --- a/app/views/main/home.html.erb +++ b/app/views/main/home.html.erb @@ -3,7 +3,7 @@ <%= render object %> <% end %> <% if @all.empty? %> -


Shucks, there is nothing in metamap.

+


Shucks, there is nothing in metamaps.

<% end %>

diff --git a/app/views/main/userobjects.html.erb b/app/views/main/userobjects.html.erb index b3b4691f..cf5bbeb4 100644 --- a/app/views/main/userobjects.html.erb +++ b/app/views/main/userobjects.html.erb @@ -3,7 +3,7 @@ <%= render object %> <% end %> <% if @all.empty? %> -


You haven't added any objects yet.

+


You haven't added any topics yet.

<% end %>

diff --git a/app/views/main/usersynapses.html.erb b/app/views/main/usersynapses.html.erb new file mode 100644 index 00000000..0c783c8d --- /dev/null +++ b/app/views/main/usersynapses.html.erb @@ -0,0 +1,9 @@ +
+ <% @all.each do |object| %> + <%= render object %> + <% end %> + <% if @all.empty? %> +


You haven't added any synapses yet.

+ <% end %> +

+
diff --git a/app/views/synapses/index.html.erb b/app/views/synapses/index.html.erb new file mode 100644 index 00000000..1c76b5d2 --- /dev/null +++ b/app/views/synapses/index.html.erb @@ -0,0 +1,11 @@ +

Synapses

+ +
+ <% @synapses.each do |synapse| %> + <%= render synapse %> + <% end %> + <% if @synapses.empty? %> +


Shucks, there are no synapses.

+ <% end %> +

+
diff --git a/app/views/synapses/new.html.erb b/app/views/synapses/new.html.erb index b2c985fb..84564d9d 100644 --- a/app/views/synapses/new.html.erb +++ b/app/views/synapses/new.html.erb @@ -1,40 +1,5 @@ -
- - - -
- <%= form_for @synapse1, url: synapses_url do |form| %> -

Add Synapse Between Groups

- <%= hidden_field_tag(:category, "Group") %> - <% if @allgroups.count > 0 %> - - <%= select_tag :node1_id, options_from_collection_for_select(@allgroups, "id", "name") %> - <% end %> - - <%= form.text_field :desc, class: "description" %> - <% if @allgroups.count > 0 %> - - <%= select_tag :node2_id, options_from_collection_for_select(@allgroups, "id", "name") %> - <% end %> - <%= form.submit "Add Synapse", class: "add" %> - <% end %> - <%= form_for @synapse2, url: synapses_url do |form| %> -

Add Synapse Between People

- <%= hidden_field_tag(:category, "Person") %> - <% if @allpeople.count > 0 %> - - <%= select_tag :node1_id, options_from_collection_for_select(@allpeople, "id", "name") %> - <% end %> - - <%= form.text_field :desc, class: "description" %> - <% if @allpeople.count > 0 %> - - <%= select_tag :node2_id, options_from_collection_for_select(@allpeople, "id", "name") %> - <% end %> - <%= form.submit "Add Synapse", class: "add" %> - <% end %> - <%= form_for @synapse3, url: synapses_url do |form| %> + <%= form_for @synapse, url: synapses_url do |form| %>

Add Synapse Between Items

<%= hidden_field_tag(:category, "Item") %> <% if @allitems.count > 0 %> diff --git a/app/views/synapses/show.html.erb b/app/views/synapses/show.html.erb index 59cf57db..64292ae0 100644 --- a/app/views/synapses/show.html.erb +++ b/app/views/synapses/show.html.erb @@ -1,13 +1,7 @@

<%= @node1.name %>

- <% if (@node1.class == Group) %> - <%= image_tag "group.png", :class => 'icon', :size => '50x50' %> - <% elsif (@node1.class == Person) %> - <%= image_tag "person.png", :class => 'icon', :size => '50x50' %> - <% elsif (@node1.class == Item) %> - <%= image_tag @node1.item_category.icon, :class => 'icon', :size => '50x50' %> - <% end %> + <%= image_tag @node1.item_category.icon, :class => 'icon', :size => '50x50' %>

<%= @node1.desc %>

@@ -18,13 +12,7 @@

<%= @node2.name %>

- <% if (@node2.class == Group) %> - <%= image_tag "group.png", :class => 'icon', :size => '50x50' %> - <% elsif (@node2.class == Person) %> - <%= image_tag "person.png", :class => 'icon', :size => '50x50' %> - <% elsif (@node2.class == Item) %> - <%= image_tag @node2.item_category.icon, :class => 'icon', :size => '50x50' %> - <% end %> + <%= image_tag @node2.item_category.icon, :class => 'icon', :size => '50x50' %>

<%= @node2.desc %>

diff --git a/config/database.yml b/config/database.yml index eab21bab..9e06d857 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,13 +1,13 @@ development: min_messages: WARNING adapter: postgresql - host: ec2-54-243-217-241.compute-1.amazonaws.com + host: 127.0.0.1 port: 5432 encoding: unicode - database: dbct9hosrirq2h + database: metamap002_development pool: 5 - username: tkbwavghytilon - password: "To6z-64f1Lr3LqpWrcLBPG2Xdv" + username: postgres + password: "3112" test: min_messages: WARNING @@ -15,7 +15,7 @@ test: host: 127.0.0.1 port: 5432 encoding: unicode - database: metamap_test + database: metamap002_test pool: 5 username: postgres password: "3112" @@ -23,10 +23,10 @@ test: production: min_messages: WARNING adapter: postgresql - host: ec2-54-243-217-241.compute-1.amazonaws.com + host: 127.0.0.1 port: 5432 encoding: unicode - database: dbct9hosrirq2h + database: metamap002_production pool: 5 - username: tkbwavghytilon - password: "To6z-64f1Lr3LqpWrcLBPG2Xdv" + username: postgres + password: "3112" diff --git a/config/routes.rb b/config/routes.rb index 1a657a88..8a35d982 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,7 +2,8 @@ ISSAD::Application.routes.draw do root to: 'main#home', via: :get - match 'my-cards', to: 'main#userobjects', via: :get, as: :userobjects + match 'my-topics', to: 'main#userobjects', via: :get, as: :userobjects + match 'my-synapses', to: 'main#usersynapses', via: :get, as: :usersynapses resource :user resource :session diff --git a/db/migrate/20120920014810_create_items.rb b/db/migrate/20120920014810_create_items.rb index 40cce10d..7e98f63e 100644 --- a/db/migrate/20120920014810_create_items.rb +++ b/db/migrate/20120920014810_create_items.rb @@ -5,8 +5,6 @@ class CreateItems < ActiveRecord::Migration t.text :desc t.text :link t.integer :user_id - t.integer :person_id - t.integer :group_id t.integer :item_category_id t.timestamps diff --git a/db/schema.rb b/db/schema.rb index 547a6dfd..6d76773a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -13,39 +13,6 @@ ActiveRecord::Schema.define(:version => 20121005160234) do - create_table "groupgroups", :force => true do |t| - t.integer "group_id" - t.integer "parent_group_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "groupitems", :force => true do |t| - t.integer "group_id" - t.integer "item_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "grouppeople", :force => true do |t| - t.integer "group_id" - t.integer "person_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "groups", :force => true do |t| - t.text "name" - t.text "desc" - t.text "city" - t.text "province" - t.text "country" - t.text "link" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "item_categories", :force => true do |t| t.text "name" t.string "icon" @@ -53,44 +20,16 @@ ActiveRecord::Schema.define(:version => 20121005160234) do t.datetime "updated_at", :null => false end - create_table "itemitems", :force => true do |t| - t.integer "item_id" - t.integer "parent_item_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "items", :force => true do |t| t.text "name" t.text "desc" t.text "link" t.integer "user_id" - t.integer "person_id" - t.integer "group_id" t.integer "item_category_id" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end - create_table "people", :force => true do |t| - t.text "name" - t.text "desc" - t.text "city" - t.text "province" - t.text "country" - t.text "link" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "personitems", :force => true do |t| - t.integer "person_id" - t.integer "item_id" - 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" diff --git a/test/fixtures/item_categories.yml b/test/fixtures/item_categories.yml index 4b33b173..61d74ce8 100644 --- a/test/fixtures/item_categories.yml +++ b/test/fixtures/item_categories.yml @@ -1,12 +1,12 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html one: - name: Action - icon: action.png + name: Person + icon: person.png two: - name: Activity - icon: activity.png + name: Group + icon: group.png three: name: Bizarre @@ -28,7 +28,6 @@ seven: name: Future Dev icon: futuredev.png - eight: name: Idea icon: idea.png @@ -105,7 +104,13 @@ twentysix: name: Trajectory icon: trajectory.png - +twentyseven: + name: Action + icon: action.png + +twentyeight: + name: Activity + icon: activity.png