diff --git a/app/assets/javascripts/Jit/ForceDirected/metamap.js b/app/assets/javascripts/Jit/ForceDirected/metamap.js index 62b2fa2b..04e7e6d6 100644 --- a/app/assets/javascripts/Jit/ForceDirected/metamap.js +++ b/app/assets/javascripts/Jit/ForceDirected/metamap.js @@ -48,17 +48,20 @@ function init(){ // with dollar prefixed data-properties in the // JSON structure. Node: { - overridable: true + overridable: true, + color: '#2D6A5D', + type: 'circle', + dim: 11 }, Edge: { overridable: true, color: '#23A4FF', - lineWidth: 0.4 + lineWidth: 0.5 }, //Native canvas text styling Label: { type: labelType, //Native or HTML - size: 10, + size: 12, style: 'bold' }, //Add Tips @@ -117,7 +120,7 @@ function init(){ onCreateLabel: function(domElement, node){ domElement.innerHTML = node.name; var style = domElement.style; - style.fontSize = "0.8em"; + style.fontSize = "0.9em"; style.color = "#ddd"; }, // Change node styles when DOM labels are placed diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 87d7513e..149c6962 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -68,4 +68,10 @@ 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; } \ No newline at end of file +.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 diff --git a/app/models/group.rb b/app/models/group.rb index c51dce1e..02e5c94e 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,52 +1,56 @@ -class Group < ActiveRecord::Base - -belongs_to :user - -has_many :groupgroup_c, :foreign_key => 'parent_group_id', :class_name => 'Groupgroup' -has_many :groupgroup_p, :foreign_key => 'group_id', :class_name => 'Groupgroup' - -has_many :synapses1, :class_name => 'Synapse', :foreign_key => 'node1_id', :conditions => {:category => 'Group'} -has_many :synapses2, :class_name => 'Synapse', :foreign_key => 'node2_id', :conditions => {:category => 'Group'} -has_many :groups1, :through => :synapses2, :source => :group1 -has_many :groups2, :through => :synapses1, :source => :group2 - - def synapses - synapses1 + synapses2 - end - - def relatives - groups1 + groups2 - end - -has_many :grouppeople -has_many :groupitems - -has_many :child_groups, :through => :groupgroup_c, :source => :group -has_many :parent_groups, :through => :groupgroup_p, :source => :parent_group - -has_many :people, :through => :grouppeople -has_many :items, :through => :groupitems - - def as_json - Jbuilder.encode do |json| - @data1 = {'$color'=> '#909291'} - @data2 = {'$color'=> '#70A35E', '$type'=> 'triangle', '$dim'=> 11 } - @single = Array.new - @single.push(self) - @groups = @single + self.relatives - - json.array!(@groups) do |group| - json.adjacencies group.synapses2.delete_if{|synapse| not @groups.include?(Group.find_by_id(synapse.node1_id))} do |json, synapse| - json.nodeTo synapse.node1_id - json.nodeFrom synapse.node2_id - json.data @data1 - end - - json.data @data2 - json.id group.id - json.name group.name - end - end - end - -end +class Group < ActiveRecord::Base + +belongs_to :user + +has_many :groupgroup_c, :foreign_key => 'parent_group_id', :class_name => 'Groupgroup' +has_many :groupgroup_p, :foreign_key => 'group_id', :class_name => 'Groupgroup' + +has_many :synapses1, :class_name => 'Synapse', :foreign_key => 'node1_id', :conditions => {:category => 'Group'} +has_many :synapses2, :class_name => 'Synapse', :foreign_key => 'node2_id', :conditions => {:category => 'Group'} +has_many :groups1, :through => :synapses2, :source => :group1 +has_many :groups2, :through => :synapses1, :source => :group2 + + def synapses + synapses1 + synapses2 + end + + def relatives + groups1 + groups2 + end + +has_many :grouppeople +has_many :groupitems + +has_many :child_groups, :through => :groupgroup_c, :source => :group +has_many :parent_groups, :through => :groupgroup_p, :source => :parent_group + +has_many :people, :through => :grouppeople +has_many :items, :through => :groupitems + + def as_json + Jbuilder.encode do |json| + @single = Array.new + @single.push(self) + @groups = @single + self.relatives + + json.array!(@groups) do |group| + json.adjacencies group.synapses2.delete_if{|synapse| not @groups.include?(Group.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 + json.data @synapsedata + end + + @groupdata = Hash.new + @groupdata['desc'] = group.desc + @groupdata['link'] = group.link + json.data @groupdata + json.id group.id + json.name group.name + end + end + end + +end diff --git a/app/models/item.rb b/app/models/item.rb index b99b4055..30da4be6 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -1,54 +1,58 @@ -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 :items1, :through => :synapses2, :source => :item1 -has_many :items2, :through => :synapses1, :source => :item2 - - def synapses - synapses1 + synapses2 - end - - def relatives - items1 + items2 - end - -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| - @data1 = {'$color'=> '#909291'} - @data2 = {'$color'=> '#70A35E', '$type'=> 'triangle', '$dim'=> 11 } - @single = Array.new - @single.push(self) - @items = @single + self.relatives - - 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| - json.nodeTo synapse.node1_id - json.nodeFrom synapse.node2_id - json.data @data1 - end - - json.data @data2 - json.id item.id - json.name item.name - end - end - end - -end +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 :items1, :through => :synapses2, :source => :item1 +has_many :items2, :through => :synapses1, :source => :item2 + + def synapses + synapses1 + synapses2 + end + + def relatives + items1 + items2 + end + +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 + + 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| + json.nodeTo synapse.node1_id + json.nodeFrom synapse.node2_id + + @synapsedata = Hash.new + @synapsedata['desc'] = synapse.desc + json.data @synapsedata + end + + @itemdata = Hash.new + @itemdata['desc'] = item.desc + @itemdata['link'] = item.link + json.data @itemdata + json.id item.id + json.name item.name + end + end + end + +end diff --git a/app/models/person.rb b/app/models/person.rb index 43b19860..192ea15e 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -1,46 +1,50 @@ -class Person < ActiveRecord::Base - -belongs_to :user - -has_many :grouppeople -has_many :personitems - -has_many :groups, :through => :grouppeople -has_many :items, :through => :personitems - -has_many :synapses1, :class_name => 'Synapse', :foreign_key => 'node1_id', :conditions => {:category => 'Person'} -has_many :synapses2, :class_name => 'Synapse', :foreign_key => 'node2_id', :conditions => {:category => 'Person'} -has_many :people1, :through => :synapses2, :source => :person1 -has_many :people2, :through => :synapses1, :source => :person2 - - def synapses - synapses1 + synapses2 - end - - def relatives - people1 + people2 - end - - def as_json - Jbuilder.encode do |json| - @data1 = {'$color'=> '#909291'} - @data2 = {'$color'=> '#70A35E', '$type'=> 'triangle', '$dim'=> 11 } - @single = Array.new - @single.push(self) - @people = @single + self.relatives - - json.array!(@people) do |person| - json.adjacencies person.synapses2.delete_if{|synapse| not @people.include?(Person.find_by_id(synapse.node1_id))} do |json, synapse| - json.nodeTo synapse.node1_id - json.nodeFrom synapse.node2_id - json.data @data1 - end - - json.data @data2 - json.id person.id - json.name person.name - end - end - end - -end +class Person < ActiveRecord::Base + +belongs_to :user + +has_many :grouppeople +has_many :personitems + +has_many :groups, :through => :grouppeople +has_many :items, :through => :personitems + +has_many :synapses1, :class_name => 'Synapse', :foreign_key => 'node1_id', :conditions => {:category => 'Person'} +has_many :synapses2, :class_name => 'Synapse', :foreign_key => 'node2_id', :conditions => {:category => 'Person'} +has_many :people1, :through => :synapses2, :source => :person1 +has_many :people2, :through => :synapses1, :source => :person2 + + def synapses + synapses1 + synapses2 + end + + def relatives + people1 + people2 + end + + def as_json + Jbuilder.encode do |json| + @single = Array.new + @single.push(self) + @people = @single + self.relatives + + json.array!(@people) do |person| + json.adjacencies person.synapses2.delete_if{|synapse| not @people.include?(Person.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 + json.data @synapsedata + end + + @persondata = Hash.new + @persondata['desc'] = person.desc + @persondata['link'] = person.link + json.data @persondata + json.id person.id + json.name person.name + end + end + end + +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 67da80cd..2c2eac2a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,53 +1,53 @@ - - - - Metamap - <%= stylesheet_link_tag "application", :media => "all" %> - <%= javascript_include_tag "application" %> - <%= csrf_meta_tags %> - - - <%= content_tag :div, class: authenticated? ? "main authenticated" : "main unauthenticated" do %> - -
-

<%= link_to "metamap", root_path %>

 beta - <% unless authenticated? %> - - <% end %> - <% if authenticated? %> - - <% end %> -
-
-
- <%= yield %> -
- -