diff --git a/app/assets/javascripts/Jit/ForceDirected/metamapFD.js b/app/assets/javascripts/Jit/ForceDirected/metamapFD.js index fbcac2d6..695ba090 100644 --- a/app/assets/javascripts/Jit/ForceDirected/metamapFD.js +++ b/app/assets/javascripts/Jit/ForceDirected/metamapFD.js @@ -171,9 +171,17 @@ function initFD(){ }); // 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') + '
'; + var html = + '

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

' + + '' + node.getData(' + + '' + node.name + '' + + '
Added by: ' + node.getData('username') + '
' + + '

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

' + + '' + node.getData('link') + ''; + //append connections information - $jit.id('showcard').innerHTML = html; + $jit.id('showcard').innerHTML = '
'; + $jit.id('item_' + node.id).innerHTML = html; } }, //Number of iterations for the FD algorithm @@ -245,9 +253,17 @@ function initFD(){ }); // 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('showcard').innerHTML = html; + var html = + '

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

' + + '' + node.getData(' + + '' + node.name + '' + + '
Added by: ' + node.getData('username') + '
' + + '

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

' + + '' + node.getData('link') + ''; + + //append connections information + $jit.id('showcard').innerHTML = '
'; + $jit.id('item_' + node.id).innerHTML = html; }; }, // Change node styles when DOM labels are placed diff --git a/app/assets/javascripts/Jit/RGraph/metamapRG.js b/app/assets/javascripts/Jit/RGraph/metamapRG.js index 40cec4dc..0deaad1f 100644 --- a/app/assets/javascripts/Jit/RGraph/metamapRG.js +++ b/app/assets/javascripts/Jit/RGraph/metamapRG.js @@ -177,9 +177,17 @@ function initRG(){ }); // 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') + '
'; + var html = + '

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

' + + '' + node.getData(' + + '' + node.name + '' + + '
Added by: ' + node.getData('username') + '
' + + '

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

' + + '' + node.getData('link') + ''; + //append connections information - $jit.id('showcard').innerHTML = html; + $jit.id('showcard').innerHTML = '
'; + $jit.id('item_' + node.id).innerHTML = html; } }, //Number of iterations for the rg algorithm diff --git a/app/assets/javascripts/maps.js.coffee b/app/assets/javascripts/maps.js.coffee new file mode 100644 index 00000000..76156794 --- /dev/null +++ b/app/assets/javascripts/maps.js.coffee @@ -0,0 +1,3 @@ +# 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/ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index bf7058fb..85f2f1dc 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -30,7 +30,7 @@ h2 {display:block; text-align:center; background: #333; font-size:24px;} a {color:#2d6a5d; text-decoration:none;} .clearfloat {clear:both;} -.new_session, .new_user, .new_item, .new_synapse, .edit_item, .edit_synapse { display: block; width: 350px; margin: 0 auto; background: #D1D1D1; padding: 20px; border-radius: 15px; color: #000; border:2px solid #000; } +.new_session, .new_user, .new_item, .new_synapse, .new_map, .edit_user, .edit_item, .edit_synapse, .edit_map { display: block; width: 350px; margin: 0 auto; background: url('bg.png'); padding: 20px; border-radius: 15px; color: #000; border:2px solid #000; } .anypage .new_item, .anypage .new_synapse { display: none; position:absolute; left:50%; top:0; margin:200px 0 0 -195px; border:2px solid #000; } #closenewtopic, #closenewsynapse { position:absolute; top: 3px; right:3px; } @@ -51,7 +51,7 @@ input[type="submit"] { margin-top:5px; } .headertop { display:block; position:fixed; top:0; left:0; z-index:10; height:38px; width:100%; min-width:622px; background: url(topbg2.png) repeat-x top left; } #mainTitle { float: left; } -#mainTitle a { color:#FFF; } +#mainTitle a { color:#FFF; font-family: "vinyl",sans-serif; text-transform:uppercase; font-style: italic; font-weight: 400;} .headertop ul { display:block; float: right; } .headertop ul li {display:block; float:right; margin:10px 5px 0 5px; } .headertop ul li a { color:#FFF; } diff --git a/app/assets/stylesheets/base.css b/app/assets/stylesheets/base.css index 085fef08..e765ecbc 100644 --- a/app/assets/stylesheets/base.css +++ b/app/assets/stylesheets/base.css @@ -15,9 +15,9 @@ position:absolute; top:50%; left:10px; - margin-top:-150px; - + margin-top:-150px; } +#showcard .contributor { font-size:12px; } .text { margin: 7px; diff --git a/app/assets/stylesheets/maps.css.scss b/app/assets/stylesheets/maps.css.scss new file mode 100644 index 00000000..4716c561 --- /dev/null +++ b/app/assets/stylesheets/maps.css.scss @@ -0,0 +1,35 @@ +// Place all the styles related to the maps controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + +.map { display:block; float:left; position:relative; width:170px; height:300px; padding:10px 10px 10px 35px; background: url('bg.png'); border-radius:15px; margin:30px 0 30px 50px; color:#000; } + +.map .delete {position: absolute; +top: -14px; +left: 0px; +background: none; +border: 0; +color: white; +border: none; +font-size: 14px; +margin: 0; +padding: 0; +cursor:pointer; +} + +.map .type {position: absolute; +color: white; +top: -22px; +right: 0; +font-weight: bold; +font-size: 20px; +line-height: 24px;} + +.map .icon { position:absolute; top:135px; left:-25px; } + +.map .title { font-size:22px; line-height:25px; display:block; border-bottom:2px solid #000; padding-bottom:5px; } + +.map .desc { font-style:italic; font-size:15px; } +.map .desc h3 { font-style:normal; margin-top:5px; } + +.map .link { position:absolute; width:170px; top:295px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } \ No newline at end of file diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index cb05033c..054e5c98 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -4,15 +4,16 @@ class ItemsController < ApplicationController respond_to :html, :js, :json - # GET /items + # GET /users/:user_id/items def index - @user = current_user - @items = Item.all + @user = User.find(params[:user_id]) + + @items = @user.items - respond_with(@items,@user) + respond_with(@user,@items) end - # Get /item/new + # Get /users/:user_id/items/new def new @item = Item.new @user = current_user @@ -20,12 +21,13 @@ class ItemsController < ApplicationController respond_with(@item) end - # GET /item/:id + # GET /users/:user_id/items/:id def show - @user = current_user - @item = Item.find(params[:id]) + @user = User.find(params[:user_id]) + + @item = @user.items.find(params[:id]) - @relatives = @item.map_as_json.html_safe + @relatives = @item.network_as_json.html_safe respond_to do |format| format.html { respond_with(@item, @user) } @@ -33,7 +35,7 @@ class ItemsController < ApplicationController end end - # POST /items + # POST /users/:user_id/items def create @user = current_user @@ -41,53 +43,75 @@ class ItemsController < ApplicationController @item.name = params[:item][:name] @item.desc = params[:item][:desc] @item.link = params[:item][:link] + @item.permission = params[:item][:permission] @item.item_category = ItemCategory.find(params[:category]) @item.user = @user @item.save + + if params[:item][:map] + @mapping = Mapping.new() + @mapping.category = "Item" + @mapping.user = @user + @mapping.map = Map.find(params[:item][:map]) + @mapping.item = @item + @mapping.save + end respond_to do |format| - format.html { respond_with(@user, location: item_url(@item)) } + format.html { respond_with(@user, location: user_item_url(@user, @item)) } format.js { respond_with(@item) } end end - # GET /items/:id/edit + # GET /users/:user_id/items/:id/edit def edit - @item = Item.find_by_id(params[:id]) + @user = User.find(params[:user_id]) + + @item = @user.items.find(params[:id]) respond_with(@item) end - # PUT /actions/:id + # PUT /users/:user_id/items/:id def update - @item = Item.find_by_id(params[:id]) + @user = User.find(params[:user_id]) + + @item = @user.items.find(params[:id]) if @item @item.name = params[:item][:name] @item.desc = params[:item][:desc] @item.link = params[:item][:link] + @item.permission = params[:item][:permission] @item.item_category = ItemCategory.find(params[:category][:item_category_id]) @item.save end - respond_with(@user, location: item_url(@item)) do |format| + respond_with(@user, location: user_item_url(@user, @item)) do |format| end end - # DELETE /items/:id + # DELETE /users/:user_id/items/:id def destroy - @item = Item.find_by_id(params[:id]) + @user = User.find(params[:user_id]) + + @item = @user.items.find(params[:id]) @synapses = @item.synapses + @mappings = @item.mappings @synapses.each do |synapse| synapse.delete end + @mappings.each do |mapping| + mapping.delete + end + @item.delete respond_to do |format| diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 1b4a9250..f3414d0c 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -1,7 +1,6 @@ class MainController < ApplicationController -include ItemsHelper + include ItemsHelper - before_filter :require_user, only: [:userobjects] respond_to :html, :js, :json def home @@ -9,7 +8,9 @@ include ItemsHelper @item = Item.all.first - @alljson = @item.all_as_json.html_safe + if @item + @alljson = @item.all_as_json.html_safe + end respond_to do |format| format.html { respond_with(@item) } @@ -17,22 +18,13 @@ include ItemsHelper end end - def userobjects - @user = current_user + def allmaps + @current_user = current_user - @all = @user.items + @maps = Map.all - respond_with(@all) - end - - def usersynapses - @user = current_user - - @synapsesjson = usersynapses_as_json(@user).html_safe - - respond_to do |format| - format.html - format.json { respond_with(@synapsesjson) } + respond_to do |format| + format.html { respond_with(@maps) } end end diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb new file mode 100644 index 00000000..4973bce8 --- /dev/null +++ b/app/controllers/maps_controller.rb @@ -0,0 +1,93 @@ +class MapsController < ApplicationController + + before_filter :require_user, only: [:new, :create, :edit, :update] + + respond_to :html, :js, :json + + # GET /users/:user_id/maps + def index + @user = User.find(params[:user_id]) + @maps = @user.maps + + respond_with(@maps,@user) + end + + # GET /users/:user_id/maps/new + def new + @map = Map.new + @user = current_user + + respond_with(@map) + end + + # GET Get /users/:user_id/maps/:id + def show + @user = User.find(params[:user_id]) + + @map = @user.maps.find(params[:id]) + + @mapjson = @map.self_as_json.html_safe + + respond_to do |format| + format.html { respond_with(@map, @user) } + format.json { respond_with(@mapjson) } + end + end + + # POST /users/:user_id/maps + def create + + @user = current_user + @map = Map.create(params[:map]) + @map.user = @user + + @map.save + + respond_to do |format| + format.html { respond_with(@user, location: user_map_path(@user, @map)) } + end + + end + + # GET /users/:user_id/maps/:id/edit + def edit + @user = User.find(params[:user_id]) + + @map = @user.maps.find(params[:id]) + + respond_with(@user, @map) + end + + # PUT /users/:user_id/maps/:id + def update + @user = User.find(params[:user_id]) + + @map = @user.maps.find(params[:id]) + + @map.attributes = params[:map] + @map.save + + respond_with(@user, location: user_map_path(@user, @map)) do |format| + end + + end + + # DELETE /users/:user_id/maps/:id + def destroy + @user = User.find(params[:user_id]) + + @map = @user.maps.find(params[:id]) + + @mappings = @map.mappings + + @mappings.each do |mapping| + mapping.delete + end + + @map.delete + + respond_with(location: user_maps_path(@user)) do |format| + end + end + +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index edce363d..67baa140 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -22,7 +22,7 @@ class SessionsController < ApplicationController @user = User.new - respond_with(@user, @session, location: restore(default: root_url)) do |format| + respond_with(@user, @session, location: root_url) do |format| end end @@ -33,7 +33,7 @@ class SessionsController < ApplicationController @session.destroy respond_to do |format| - format.html { respond_with(@session, location: restore(default: root_url)) } + format.html { respond_with(@session, location: root_url) } end end diff --git a/app/controllers/synapses_controller.rb b/app/controllers/synapses_controller.rb index 82dfe7da..43465492 100644 --- a/app/controllers/synapses_controller.rb +++ b/app/controllers/synapses_controller.rb @@ -1,18 +1,23 @@ class SynapsesController < ApplicationController + include ItemsHelper before_filter :require_user, only: [:new, :create, :edit, :update] respond_to :html, :js, :json - # GET /synapses + # GET users/:user_id/synapses def index - @user = current_user - @synapses = Synapse.all - - respond_with(@synapses) + @user = User.find(params[:user_id]) + + @synapsesjson = usersynapses_as_json(@user).html_safe + + respond_to do |format| + format.html + format.json { respond_with(@synapsesjson) } + end end - # Get /synapse/new + # Get users/:user_id/synapses/new def new @synapse = Synapse.new @user = current_user @@ -20,9 +25,11 @@ class SynapsesController < ApplicationController respond_with(@synapse) end - # GET /synapse/:id + # GET users/:user_id/synapses/:id def show - @synapse = Synapse.find(params[:id]) + @user = User.find(params[:user_id]) + + @synapse = @user.synapses.find(params[:id]) if @synapse @synapsejson = @synapse.selfplusnodes_as_json.html_safe @@ -34,7 +41,7 @@ class SynapsesController < ApplicationController end end - # POST /synapses + # POST users/:user_id/synapses def create @user = current_user @@ -43,19 +50,48 @@ class SynapsesController < ApplicationController @synapse.category = params[:category] @synapse.item1 = Item.find(params[:node1_id]) @synapse.item2 = Item.find(params[:node2_id]) + @synapse.permission = params[:synapse][:permission] @synapse.user = @user @synapse.save + + if params[:synapse][:map] + @mapping = Mapping.new() + @mapping.category = "Synapse" + @mapping.user = @user + @mapping.map = Map.find(params[:synapse][:map]) + @mapping.synapse = @synapse + @mapping.save + + if not Map.find(params[:synapse][:map]).items.include?(@synapse.item1) + @mapping1 = Mapping.new() + @mapping1.category = "Item" + @mapping1.user = @user + @mapping1.map = Map.find(params[:synapse][:map]) + @mapping1.item = @synapse.item1 + @mapping1.save + end + if not Map.find(params[:synapse][:map]).items.include?(@synapse.item2) + @mapping2 = Mapping.new() + @mapping2.category = "Item" + @mapping2.user = @user + @mapping2.map = Map.find(params[:synapse][:map]) + @mapping2.item = @synapse.item2 + @mapping2.save + end + end respond_to do |format| - format.html { respond_with(@user, location: synapse_url(@synapse)) } + format.html { respond_with(@user, location: user_synapse_url(@user, @synapse)) } format.js { respond_with(@synapse) } end end - # GET /synapses/:id/edit + # GET users/:user_id/synapses/:id/edit def edit - @synapse = Synapse.find_by_id(params[:id]) + @user = User.find(params[:user_id]) + + @synapse = @user.synapses.find(params[:id]) @items = nil @@ -66,26 +102,30 @@ class SynapsesController < ApplicationController respond_with(@synapse, @items) end - # PUT /synapses/:id + # PUT users/:user_id/synapses/:id def update - @synapse = Synapse.find_by_id(params[:id]) + @user = User.find(params[:user_id]) + + @synapse = @user.synapses.find(params[:id]) if @synapse @synapse.desc = params[:synapse][:desc] @synapse.item1 = Item.find(params[:node1_id][:node1]) @synapse.item2 = Item.find(params[:node2_id][:node2]) - + @synapse.permission = params[:synapse][:permission] @synapse.save end - respond_with(@user, location: synapse_url(@synapse)) do |format| + respond_with(@user, location: user_synapse_url(@user, @synapse)) do |format| end end - # DELETE /synapses/:id + # DELETE users/:user_id/synapses/:id def destroy - @synapse = Synapse.find_by_id(params[:id]) + @user = User.find(params[:user_id]) + + @synapse = @user.synapses.find(params[:id]) @synapse.delete end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3f67c1f1..245550b8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,7 +1,7 @@ class UsersController < ApplicationController before_filter :require_no_user, only: [:new, :create] - before_filter :require_user, only: [:edit, :show, :update] + before_filter :require_user, only: [:edit, :update] respond_to :html, :json @@ -36,7 +36,7 @@ class UsersController < ApplicationController @user.save - respond_with(@user, location: restore(default: root_url)) do |format| + respond_with(@user, location: root_url) do |format| end end @@ -47,7 +47,7 @@ class UsersController < ApplicationController @user.save - respond_with(@user, location: restore(default: root_url)) do |format| + respond_with(@user, location: user_url(@user)) do |format| end end diff --git a/app/helpers/items_helper.rb b/app/helpers/items_helper.rb index 55f4e110..a9e179d9 100644 --- a/app/helpers/items_helper.rb +++ b/app/helpers/items_helper.rb @@ -54,6 +54,8 @@ module ItemsHelper @itemdata['$desc'] = item.desc @itemdata['$link'] = item.link @itemdata['$itemcatname'] = item.item_category.name + @itemdata['$userid'] = item.user.id + @itemdata['$username'] = item.user.name json.data @itemdata json.id item.id json.name item.name diff --git a/app/helpers/maps_helper.rb b/app/helpers/maps_helper.rb new file mode 100644 index 00000000..88ee3d5c --- /dev/null +++ b/app/helpers/maps_helper.rb @@ -0,0 +1,2 @@ +module MapsHelper +end diff --git a/app/models/item.rb b/app/models/item.rb index 71c1053a..418e57c8 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -3,10 +3,13 @@ include ItemsHelper belongs_to :user -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' +has_many :synapses2, :class_name => 'Synapse', :foreign_key => 'node2_id' has_many :items1, :through => :synapses2, :source => :item1 has_many :items2, :through => :synapses1, :source => :item2 + +has_many :mappings +has_many :maps, :through => :mappings def synapses synapses1 + synapses2 @@ -25,6 +28,8 @@ belongs_to :item_category @itemdata['$desc'] = self.desc @itemdata['$link'] = self.link @itemdata['$itemcatname'] = self.item_category.name + @itemdata['$userid'] = self.user.id + @itemdata['$username'] = self.user.name json.data @itemdata json.id self.id json.name self.name @@ -32,7 +37,7 @@ belongs_to :item_category end #build a json object of everything connected to a specified node - def map_as_json + def network_as_json Jbuilder.encode do |json| @items = network(self,nil) @@ -44,6 +49,8 @@ belongs_to :item_category @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 @@ -51,6 +58,8 @@ belongs_to :item_category @itemdata['$desc'] = item.desc @itemdata['$link'] = item.link @itemdata['$itemcatname'] = item.item_category.name + @itemdata['$userid'] = item.user.id + @itemdata['$username'] = item.user.name json.data @itemdata json.id item.id json.name item.name @@ -71,6 +80,8 @@ belongs_to :item_category @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 @@ -78,6 +89,9 @@ belongs_to :item_category @itemdata['$desc'] = item.desc @itemdata['$link'] = item.link @itemdata['$itemcatname'] = item.item_category.name + @itemdata['$userid'] = item.user.id + @itemdata['$username'] = item.user.name + json.data @itemdata json.id item.id json.name item.name diff --git a/app/models/map.rb b/app/models/map.rb index e7d4ce28..2d3e6113 100644 --- a/app/models/map.rb +++ b/app/models/map.rb @@ -1,2 +1,47 @@ class Map < ActiveRecord::Base + +belongs_to :user + +has_many :itemmappings, :class_name => 'Mapping', :conditions => {:category => 'Item'} +has_many :synapsemappings, :class_name => 'Mapping', :conditions => {:category => 'Synapse'} + +has_many :items, :through => :itemmappings +has_many :synapses, :through => :synapsemappings + +def mappings + itemmappings + synapsemappings +end + + #build a json object of a map + def self_as_json + Jbuilder.encode do |json| + @items = self.items + @synapses = self.synapses + + json.array!(@items) do |item| + json.adjacencies item.synapses2.delete_if{|synapse| 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 + + @itemdata = Hash.new + @itemdata['$desc'] = item.desc + @itemdata['$link'] = item.link + @itemdata['$itemcatname'] = item.item_category.name + @itemdata['$userid'] = item.user.id + @itemdata['$username'] = item.user.name + json.data @itemdata + json.id item.id + json.name item.name + end + end + end + end diff --git a/app/models/mapping.rb b/app/models/mapping.rb new file mode 100644 index 00000000..b36fee81 --- /dev/null +++ b/app/models/mapping.rb @@ -0,0 +1,8 @@ +class Mapping < ActiveRecord::Base + +belongs_to :item, :class_name => "Item", :foreign_key => "item_id" +belongs_to :synapse, :class_name => "Synapse", :foreign_key => "synapse_id" +belongs_to :map, :class_name => "Map", :foreign_key => "map_id" + +belongs_to :user +end diff --git a/app/models/synapse.rb b/app/models/synapse.rb index 7ceebb5a..29dcecb3 100644 --- a/app/models/synapse.rb +++ b/app/models/synapse.rb @@ -5,11 +5,16 @@ belongs_to :user belongs_to :item1, :class_name => "Item", :foreign_key => "node1_id" belongs_to :item2, :class_name => "Item", :foreign_key => "node2_id" +has_many :mappings +has_many :maps, :through => :mappings + def self_as_json Jbuilder.encode do |json| @synapsedata = Hash.new @synapsedata['$desc'] = self.desc @synapsedata['$category'] = self.category + @synapsedata['$userid'] = synapse.user.id + @synapsedata['$username'] = synapse.user.name json.data @synapsedata end end @@ -28,6 +33,8 @@ belongs_to :item2, :class_name => "Item", :foreign_key => "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 @@ -35,6 +42,8 @@ belongs_to :item2, :class_name => "Item", :foreign_key => "node2_id" @itemdata['$desc'] = item.desc @itemdata['$link'] = item.link @itemdata['$itemcatname'] = item.item_category.name + @itemdata['$userid'] = self.user.id + @itemdata['$username'] = self.user.name json.data @itemdata json.id item.id json.name item.name diff --git a/app/models/user.rb b/app/models/user.rb index 2866db53..efa5088b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,6 +4,8 @@ class User < ActiveRecord::Base has_many :items has_many :synapses +has_many :maps +has_many :mappings acts_as_authentic do |configuration| configuration.session_class = Session diff --git a/app/views/items/_item.html.erb b/app/views/items/_item.html.erb index 32f8b589..22035d19 100644 --- a/app/views/items/_item.html.erb +++ b/app/views/items/_item.html.erb @@ -1,8 +1,8 @@ <%= div_for item, class: item.item_category.name do %> - <% if @user %><%= link_to 'Delete', item, :class => 'delete', :confirm => 'Delete this topic and all synapses linking to it?', :method => :delete, :remote => true%><% end %> + <% if @user %><%= link_to 'Delete', user_item_path(@user,item), :class => 'delete', :confirm => 'Delete this topic and all synapses linking to it?', :method => :delete, :remote => true%><% end %>

<%= item.item_category.name %>

<%= image_tag item.item_category.icon, :class => 'icon', :size => '50x50' %> - <%= link_to item.name, item_url(item), :class => 'title' %> + <%= link_to item.name, user_item_path(@user, item), :class => 'title' %>

<%=item.desc %>

<%= link_to item.link, item.link, :class => 'link', :target => '_blank' %> <% end %> \ No newline at end of file diff --git a/app/views/items/_new.html.erb b/app/views/items/_new.html.erb index cb240dfd..cac45c96 100644 --- a/app/views/items/_new.html.erb +++ b/app/views/items/_new.html.erb @@ -1,5 +1,5 @@
-<%= form_for Item.new, url: items_path, remote: true do |form| %> +<%= form_for Item.new, url: user_items_url(user), remote: true do |form| %>

Add Topic

@@ -10,6 +10,8 @@ <%= form.text_area :desc, class: "description", :rows => 5 %> <%= form.text_field :link, class: "link" %> + + <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> <%= form.submit "Add Item", class: "addItem", id: "addItem" %> <% end %>
\ No newline at end of file diff --git a/app/views/items/create.js.erb b/app/views/items/create.js.erb index b6e67a44..0910f085 100644 --- a/app/views/items/create.js.erb +++ b/app/views/items/create.js.erb @@ -36,6 +36,10 @@ if (map2 != null) { duration: 400 }); } + else { + json = newnode; + initFD(); + } // add the new node to the synapse select list $("#node1_id").prepend(""); $("#node2_id").prepend(""); diff --git a/app/views/items/edit.html.erb b/app/views/items/edit.html.erb index 33c3af8f..3b02cf38 100644 --- a/app/views/items/edit.html.erb +++ b/app/views/items/edit.html.erb @@ -1,4 +1,4 @@ -<%= form_for @item, url: item_url do |form| %> +<%= form_for @item, url: user_item_url do |form| %>

Edit Item

<%= select "category", "item_category_id", ItemCategory.order("name ASC").all.collect {|p| [ p.name, p.id ] }, { :selected => @item.item_category.id } %> @@ -8,5 +8,7 @@ <%= form.text_area :desc, class: "description", :rows => 5 %> <%= form.text_field :link, class: "link" %> + + <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> <%= 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 86591f4f..9a1624ef 100644 --- a/app/views/items/index.html.erb +++ b/app/views/items/index.html.erb @@ -1,4 +1,4 @@ -

All Topics

+

Topics

<% @items.each do |item| %> @@ -10,4 +10,6 @@
-<%= render :partial => 'items/new' %> \ No newline at end of file +<% if authenticated? %> + <%= render :partial => 'items/new' %> +<% end %> \ No newline at end of file diff --git a/app/views/items/new.html.erb b/app/views/items/new.html.erb index 9e8afb5e..0c55a47b 100644 --- a/app/views/items/new.html.erb +++ b/app/views/items/new.html.erb @@ -1,5 +1,5 @@
-<%= form_for @item || Item.new, url: items_path do |form| %> +<%= form_for @item || Item.new, url: user_items_path do |form| %>

Add Topic

<%= select_tag "category", options_from_collection_for_select(ItemCategory.order("name ASC").all, "id", "name") %> @@ -9,6 +9,8 @@ <%= form.text_area :desc, class: "description", :rows => 5 %> <%= form.text_field :link, class: "link" %> + + <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> <%= form.submit "Add Item", class: "add" %> <% end %>
\ No newline at end of file diff --git a/app/views/items/show.html.erb b/app/views/items/show.html.erb index f3de9ac6..eb13810b 100644 --- a/app/views/items/show.html.erb +++ b/app/views/items/show.html.erb @@ -1,11 +1,10 @@
-

<%= @item.item_category.name %>

<%= image_tag @item.item_category.icon, :class => 'icon', :size => '50x50' %>
-

<%= @item.name %> <% if @user %><%= link_to "[edit]", edit_item_path(@item) %><% end %>

+

<%= @item.name %> <% if authenticated? %><%= link_to "[edit]", edit_user_item_path(@user, @item) %><% end %>

<%= @item.desc %>

@@ -34,5 +33,8 @@ }); -<%= render :partial => 'items/new' %> -<%= render :partial => 'synapses/new' %> +<% if authenticated? %> + <%= render :partial => 'items/new' %> + <%= render :partial => 'synapses/new' %> +<% end %> + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1cd23c83..e28d7ece 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -4,6 +4,8 @@ Metamaps <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %> + + <%= csrf_meta_tags %> @@ -52,20 +54,24 @@ <% end %> <% if authenticated? %> <% end %>
diff --git a/app/views/main/allmaps.html.erb b/app/views/main/allmaps.html.erb new file mode 100644 index 00000000..dbe8b55d --- /dev/null +++ b/app/views/main/allmaps.html.erb @@ -0,0 +1,11 @@ +

All Maps

+ +
+ <% @maps.each do |map| %> + <%= render map %> + <% end %> + <% if @maps.empty? %> +


Shucks, there are no maps.

+ <% end %> +

+
\ No newline at end of file diff --git a/app/views/main/home.html.erb b/app/views/main/home.html.erb index 12363628..0f9e900c 100644 --- a/app/views/main/home.html.erb +++ b/app/views/main/home.html.erb @@ -18,6 +18,8 @@


Shucks, there is nothing in metamaps.

<% end %> -<%= render :partial => 'items/new' %> -<%= render :partial => 'synapses/new' %> +<% if authenticated? %> + <%= render :partial => 'items/new' %> + <%= render :partial => 'synapses/new' %> +<% end %> diff --git a/app/views/maps/_map.html.erb b/app/views/maps/_map.html.erb new file mode 100644 index 00000000..425115a0 --- /dev/null +++ b/app/views/maps/_map.html.erb @@ -0,0 +1,6 @@ +<%= div_for map do %> + <% if authenticated? %><%= link_to 'Delete', user_map_path(map.user,map), :class => 'delete', :confirm => 'Delete this map (nodes and synapses will remain)?', :method => :delete %><% end %> + <%= link_to map.name, user_map_path(map.user, map), :class => 'title' %> +

<%= map.desc %>

# of Topics: <%= map.items.count %>

# of Synapses: <%= map.synapses.count %>

+ +<% end %> \ No newline at end of file diff --git a/app/views/maps/_newsynapse.html.erb b/app/views/maps/_newsynapse.html.erb new file mode 100644 index 00000000..11760702 --- /dev/null +++ b/app/views/maps/_newsynapse.html.erb @@ -0,0 +1,21 @@ +
+ <%= form_for Synapse.new, url: user_synapses_url(user), remote: true do |form| %> + +

Add Synapse Between Topics

+ <%= hidden_field_tag(:category, "Item") %> + <% if Item.all.count > 0 %> + + <%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %> + <% end %> + + <%= form.text_field :desc, class: "description" %> + <% if Item.all.count > 0 %> + + <%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %> + <% end %> + + <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> + <%= form.hidden_field :map, :value => @map.id %> + <%= form.submit "Add Synapse", class: "add" %> + <% end %> +
\ No newline at end of file diff --git a/app/views/maps/_newtopic.html.erb b/app/views/maps/_newtopic.html.erb new file mode 100644 index 00000000..75fe05e3 --- /dev/null +++ b/app/views/maps/_newtopic.html.erb @@ -0,0 +1,18 @@ +
+<%= form_for Item.new, url: user_items_url(user), remote: true do |form| %> + +

Add Topic

+ + <%= select_tag "category", options_from_collection_for_select(ItemCategory.order("name ASC").all, "id", "name") %> + + <%= form.text_field :name %> + + <%= form.text_area :desc, class: "description", :rows => 5 %> + + <%= form.text_field :link, class: "link" %> + + <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> + <%= form.hidden_field :map, :value => @map.id %> + <%= form.submit "Add Item", class: "addItem", id: "addItem" %> +<% end %> +
\ No newline at end of file diff --git a/app/views/maps/edit.html.erb b/app/views/maps/edit.html.erb new file mode 100644 index 00000000..3577aa6c --- /dev/null +++ b/app/views/maps/edit.html.erb @@ -0,0 +1,10 @@ +<%= form_for @map, url: user_map_url(@user, @map) do |form| %> +

Edit Map

+ + <%= form.text_field :name %> + + <%= form.text_area :desc, class: "description", :rows => 5 %> + + <%= form.select(:permission, options_for_select(['commons', 'public', 'private']), { :selected => @map.permission }) %> + <%= form.submit "Update", class: "update" %> +<% end %> diff --git a/app/views/maps/index.html.erb b/app/views/maps/index.html.erb new file mode 100644 index 00000000..092b3438 --- /dev/null +++ b/app/views/maps/index.html.erb @@ -0,0 +1,11 @@ +

Maps

+ +
+ <% @maps.each do |map| %> + <%= render map %> + <% end %> + <% if @maps.empty? %> +


Shucks, there are no maps.

+ <% end %> +

+
\ No newline at end of file diff --git a/app/views/maps/new.html.erb b/app/views/maps/new.html.erb new file mode 100644 index 00000000..33a51e25 --- /dev/null +++ b/app/views/maps/new.html.erb @@ -0,0 +1,12 @@ +
+<%= form_for @map || Map.new, url: user_maps_url do |form|%> +

Add Map

+ + <%= form.text_field :name %> + + <%= form.text_area :desc, class: "description", :rows => 5 %> + + <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> + <%= form.submit "Add Map", class: "add" %> +<% end %> +
diff --git a/app/views/maps/show.html.erb b/app/views/maps/show.html.erb new file mode 100644 index 00000000..848fb6d3 --- /dev/null +++ b/app/views/maps/show.html.erb @@ -0,0 +1,37 @@ +
+
+

# of Topics: <%= @map.items.count %>

+

# of Synapses: <%= @map.synapses.count %>

+
+
+

<%= @map.name %> <% if authenticated? %><%= link_to "[edit]", edit_user_map_path(@user, @map) %><% end %>

+
+

<%= @map.desc %>

+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ + + +<%= render :partial => 'newtopic' %> +<%= render :partial => 'newsynapse' %> diff --git a/app/views/synapses/_new.html.erb b/app/views/synapses/_new.html.erb index 535576cf..712f82f4 100644 --- a/app/views/synapses/_new.html.erb +++ b/app/views/synapses/_new.html.erb @@ -1,5 +1,5 @@
- <%= form_for Synapse.new, url: synapses_url, remote: true do |form| %> + <%= form_for Synapse.new, url: user_synapses_url(user), remote: true do |form| %>

Add Synapse Between Topics

<%= hidden_field_tag(:category, "Item") %> @@ -13,6 +13,8 @@ <%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %> <% end %> + + <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> <%= form.submit "Add Synapse", class: "add" %> <% end %>
\ No newline at end of file diff --git a/app/views/synapses/create.js.erb b/app/views/synapses/create.js.erb index 960d500f..5b6906c1 100644 --- a/app/views/synapses/create.js.erb +++ b/app/views/synapses/create.js.erb @@ -6,7 +6,7 @@ map1 = document.getElementById('container'); if (map1 != null) { - var mymap, newnode, select1, select2, option, temp1, temp2, temp; + var mymap, newnode, temp1, temp2, temp; if (fd != null) { mymap = fd; } @@ -14,69 +14,69 @@ if (map1 != null) { mymap = rg; } - temp1 = mymap.graph.getNode(<%= @synapse.item1.id %>); - if (temp1 == null) { - newnode = <%= @synapse.item1.self_as_json.html_safe %>; - mymap.graph.addNode(newnode); - temp = mymap.graph.getNode('<%= @synapse.item1.id %>'); - temp.setData('dim', 1, 'start'); - temp.setData('dim', 40, 'end'); - if (mymap == fd) { - temp.setPos(new $jit.Complex(0, 0), 'current'); - temp.setPos(new $jit.Complex(0, 0), 'start'); - temp.setPos(new $jit.Complex(0, 0), 'end'); - } - else if (mymap == rg) { - temp.setPos(new $jit.Polar(5.54, 347.6), 'current'); - temp.setPos(new $jit.Polar(5.54, 347.6), 'start'); - temp.setPos(new $jit.Polar(5.54, 347.6), 'end'); - } - mymap.fx.plotNode(temp, mymap.canvas); - temp1 = mymap.graph.getNode(<%= @synapse.item1.id %>); - // add the new node to the synapse select list - $("#node1_id").prepend(""); - $("#node2_id").prepend(""); + if (mymap == fd || mymap == rg) { + temp1 = mymap.graph.getNode(<%= @synapse.item1.id %>); + if (temp1 == null) { + newnode = <%= @synapse.item1.self_as_json.html_safe %>; + mymap.graph.addNode(newnode); + temp = mymap.graph.getNode('<%= @synapse.item1.id %>'); + temp.setData('dim', 1, 'start'); + temp.setData('dim', 40, 'end'); + if (mymap == fd) { + temp.setPos(new $jit.Complex(0, 0), 'current'); + temp.setPos(new $jit.Complex(0, 0), 'start'); + temp.setPos(new $jit.Complex(0, 0), 'end'); + } + else if (mymap == rg) { + temp.setPos(new $jit.Polar(5.54, 347.6), 'current'); + temp.setPos(new $jit.Polar(5.54, 347.6), 'start'); + temp.setPos(new $jit.Polar(5.54, 347.6), 'end'); + } + mymap.fx.plotNode(temp, mymap.canvas); + temp1 = mymap.graph.getNode(<%= @synapse.item1.id %>); + } + temp2 = mymap.graph.getNode(<%= @synapse.item2.id %>); + if (temp2 == null) { + newnode = <%= @synapse.item2.self_as_json.html_safe %>; + mymap.graph.addNode(newnode); + temp = mymap.graph.getNode('<%= @synapse.item2.id %>'); + temp.setData('dim', 1, 'start'); + temp.setData('dim', 40, 'end'); + if (mymap == fd) { + temp.setPos(new $jit.Complex(0, 0), 'current'); + temp.setPos(new $jit.Complex(0, 0), 'start'); + temp.setPos(new $jit.Complex(0, 0), 'end'); + } + else if (mymap == rg) { + temp.setPos(new $jit.Polar(5.54, 347.6), 'current'); + temp.setPos(new $jit.Polar(5.54, 347.6), 'start'); + temp.setPos(new $jit.Polar(5.54, 347.6), 'end'); + } + mymap.fx.plotNode(temp, mymap.canvas); + temp2 = mymap.graph.getNode(<%= @synapse.item2.id %>); + } + mymap.graph.addAdjacence(temp1, temp2, {}); + temp = mymap.graph.getAdjacence(temp1.id, temp2.id); + temp.setDataset('start', { + lineWidth: 0.4, + color: '#d1d1d1' + }); + temp.setDataset('end', { + lineWidth: 3, + color: '#36acfb' + }); + temp.setDataset('current', { + desc: '<%= @synapse.desc %>', + category: '<%= @synapse.category %>' + }); + mymap.fx.plotLine(temp, mymap.canvas); + mymap.fx.animate({ + modes: ['node-property:dim','edge-property:lineWidth:color'], + duration: 400 + }); } - temp2 = mymap.graph.getNode(<%= @synapse.item2.id %>); - if (temp2 == null) { - newnode = <%= @synapse.item2.self_as_json.html_safe %>; - mymap.graph.addNode(newnode); - temp = mymap.graph.getNode('<%= @synapse.item2.id %>'); - temp.setData('dim', 1, 'start'); - temp.setData('dim', 40, 'end'); - if (mymap == fd) { - temp.setPos(new $jit.Complex(0, 0), 'current'); - temp.setPos(new $jit.Complex(0, 0), 'start'); - temp.setPos(new $jit.Complex(0, 0), 'end'); - } - else if (mymap == rg) { - temp.setPos(new $jit.Polar(5.54, 347.6), 'current'); - temp.setPos(new $jit.Polar(5.54, 347.6), 'start'); - temp.setPos(new $jit.Polar(5.54, 347.6), 'end'); - } - mymap.fx.plotNode(temp, mymap.canvas); - temp2 = mymap.graph.getNode(<%= @synapse.item2.id %>); - // add the new node to the synapse select list - $("#node1_id").prepend(""); - $("#node2_id").prepend(""); + else { + json = <%= @synapse.selfplusnodes_as_json.html_safe %> + initFD(); } - mymap.graph.addAdjacence(temp1, temp2, {}); - temp = mymap.graph.getAdjacence(temp1.id, temp2.id); - temp.setDataset('start', { - lineWidth: 0.4, - color: '#d1d1d1' - }); - temp.setDataset('end', { - lineWidth: 3, - color: '#36acfb' - }); - temp.setDataset('current', { - desc: '<%= @synapse.desc %>', - category: '<%= @synapse.category %>' - }); - mymap.fx.plotLine(temp, mymap.canvas); - mymap.fx.animate({ - modes: ['node-property:dim','edge-property:lineWidth:color'], - duration: 400 - }); } \ No newline at end of file diff --git a/app/views/synapses/edit.html.erb b/app/views/synapses/edit.html.erb index c681a896..e182d4f9 100644 --- a/app/views/synapses/edit.html.erb +++ b/app/views/synapses/edit.html.erb @@ -1,4 +1,4 @@ -<%= form_for @synapse, url: synapse_url do |form| %> +<%= form_for @synapse, url: user_synapse_url do |form| %>

Edit Synapse

<% if @collection.count > 0 %> @@ -10,5 +10,7 @@ <%= select "node2_id", "node2", @collection.order("name ASC").map {|p| [ p.name, p.id ] }, { :selected => @synapse.node2_id } %> <% end %> + + <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> <%= form.submit "Update", class: "update" %> <% end %> \ No newline at end of file diff --git a/app/views/synapses/index.html.erb b/app/views/synapses/index.html.erb index 1c76b5d2..88002110 100644 --- a/app/views/synapses/index.html.erb +++ b/app/views/synapses/index.html.erb @@ -1,11 +1,20 @@ -

Synapses

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


Shucks, there are no synapses.

- <% end %> +

+
+
+
+
+
+ + + +<% if authenticated? %> + <%= render :partial => 'items/new' %> + <%= render :partial => 'synapses/new' %> +<% end %> diff --git a/app/views/synapses/new.html.erb b/app/views/synapses/new.html.erb index d4e652c0..1cb598e4 100644 --- a/app/views/synapses/new.html.erb +++ b/app/views/synapses/new.html.erb @@ -1,5 +1,5 @@
- <%= form_for @synapse, url: synapses_url do |form| %> + <%= form_for @synapse, url: user_synapses_url do |form| %>

Add Synapse Between Topics

<%= hidden_field_tag(:category, "Item") %> <% if Item.all.count > 0 %> @@ -12,6 +12,8 @@ <%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %> <% end %> + + <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> <%= form.submit "Add Synapse", class: "add" %> <% end %>
\ No newline at end of file diff --git a/app/views/synapses/show.html.erb b/app/views/synapses/show.html.erb index 9f7f67a0..2720bfb1 100644 --- a/app/views/synapses/show.html.erb +++ b/app/views/synapses/show.html.erb @@ -13,4 +13,9 @@ $(document).ready(function() { initFD(); }); - \ No newline at end of file + + +<% if authenticated? %> + <%= render :partial => 'items/new' %> + <%= render :partial => 'synapses/new' %> +<% end %> \ No newline at end of file diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index e69de29b..e5185ea2 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -0,0 +1,7 @@ +<%= formula_form_for @user, url: user_url do |form| %> +

Edit Account

+ <%= form.input :name, label: "Name", class: "name" %> + <%= form.input :email, label: "Email", class: "email" %> + <%= form.input :password, label: "Password", class: "password" %> + <%= form.submit "Update", class: "update" %> +<% end %> \ No newline at end of file diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 3e36ec4a..e7c273a7 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -1,4 +1,4 @@ -<%= formula_form_for @user, url: user_url do |form| %> +<%= formula_form_for @user, url: users_url do |form| %>

Create Account

<%= form.input :name, label: "Name", class: "name" %> <%= form.input :email, label: "Email", class: "email" %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index e69de29b..cd1902f1 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -0,0 +1,18 @@ +
+
+

# of Topics: <%= @user.items.count %>

+

# of Synapses: <%= @user.synapses.count %>

+

# of Maps: <%= @user.maps.count %>

+
+
+

<%= @user.name %>

+
+

<%= link_to "View their topics", user_items_path(@user)%>

+

<%= link_to "View their synapses", user_synapses_path(@user)%>

+

<%= link_to "View their maps", user_maps_path(@user) %>

+
+
+
+
+
+
diff --git a/config/database.yml b/config/database.yml index f53b7940..8129268a 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,14 +1,25 @@ +#development: +# min_messages: WARNING +# adapter: postgresql +# host: ec2-54-243-188-58.compute-1.amazonaws.com +# port: 5442 +# encoding: unicode +# database: da81fvorvn5pp9 +# pool: 5 +# username: yolhqgtlivenrk +# password: "oi_EAZwbXboYjqB_9tWPh2x5YS" + development: min_messages: WARNING adapter: postgresql - host: ec2-54-243-188-58.compute-1.amazonaws.com - port: 5442 + host: 127.0.0.1 + port: 5432 encoding: unicode - database: da81fvorvn5pp9 + database: metamap002_development pool: 5 - username: yolhqgtlivenrk - password: "oi_EAZwbXboYjqB_9tWPh2x5YS" - + username: postgres + password: "3112" + test: min_messages: WARNING adapter: postgresql diff --git a/config/routes.rb b/config/routes.rb index 8a35d982..ee5f2e24 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,16 +2,15 @@ ISSAD::Application.routes.draw do root to: 'main#home', via: :get - match 'my-topics', to: 'main#userobjects', via: :get, as: :userobjects - match 'my-synapses', to: 'main#usersynapses', via: :get, as: :usersynapses + match 'maps', to: 'main#allmaps', via: :get, as: :allmaps - resource :user resource :session - resources :items - resources :people - resources :groups - resources :synapses + resources :users do + resources :items + resources :synapses + resources :maps + end # The priority is based upon order of creation: # first created -> highest priority. diff --git a/db/migrate/20120920014810_create_items.rb b/db/migrate/20120920014810_create_items.rb index 7e98f63e..20457350 100644 --- a/db/migrate/20120920014810_create_items.rb +++ b/db/migrate/20120920014810_create_items.rb @@ -4,6 +4,7 @@ class CreateItems < ActiveRecord::Migration t.text :name t.text :desc t.text :link + t.text :permission t.integer :user_id t.integer :item_category_id diff --git a/db/migrate/20121005160234_create_synapses.rb b/db/migrate/20121005160234_create_synapses.rb index 28c6f599..17b1f5a3 100644 --- a/db/migrate/20121005160234_create_synapses.rb +++ b/db/migrate/20121005160234_create_synapses.rb @@ -3,6 +3,8 @@ class CreateSynapses < ActiveRecord::Migration 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 diff --git a/db/migrate/20121023231434_create_maps.rb b/db/migrate/20121023231434_create_maps.rb index 628e032f..2266067a 100644 --- a/db/migrate/20121023231434_create_maps.rb +++ b/db/migrate/20121023231434_create_maps.rb @@ -1,7 +1,10 @@ class CreateMaps < ActiveRecord::Migration def change create_table :maps do |t| - + t.text :name + t.text :desc + t.text :permission + t.integer :user_id t.timestamps end end diff --git a/db/migrate/20121025234111_add_permission_to_item.rb b/db/migrate/20121025234111_add_permission_to_item.rb new file mode 100644 index 00000000..0b8fb156 --- /dev/null +++ b/db/migrate/20121025234111_add_permission_to_item.rb @@ -0,0 +1,10 @@ +class AddPermissionToItem < ActiveRecord::Migration + def self.up + add_column :items, :permission, :text + Item.update_all ["permission = ?", "commons"] + end + + def self.down + remove_column :items, :permission + end +end diff --git a/db/migrate/20121025234344_add_permission_to_synapse.rb b/db/migrate/20121025234344_add_permission_to_synapse.rb new file mode 100644 index 00000000..8bea0c03 --- /dev/null +++ b/db/migrate/20121025234344_add_permission_to_synapse.rb @@ -0,0 +1,13 @@ +class AddPermissionToSynapse < ActiveRecord::Migration + def self.up + add_column :synapses, :permission, :text + add_column :synapses, :weight, :text + Synapse.update_all ["permission = ?", "commons"] + Synapse.update_all ["weight = ?", "5"] + end + + def self.down + remove_column :synapses, :permission + remove_column :synapses, :weight + end +end diff --git a/db/migrate/20121026000731_create_mappings.rb b/db/migrate/20121026000731_create_mappings.rb new file mode 100644 index 00000000..b03ee426 --- /dev/null +++ b/db/migrate/20121026000731_create_mappings.rb @@ -0,0 +1,14 @@ +class CreateMappings < ActiveRecord::Migration + def change + create_table :mappings do |t| + t.text :category + t.integer :xloc + t.integer :yloc + t.integer :item_id + t.integer :synapse_id + t.integer :map_id + t.integer :user_id + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 5e30d2b0..0b29163d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,54 +1,78 @@ -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended to check this file into your version control system. - -ActiveRecord::Schema.define(:version => 20121005160234) do - - create_table "item_categories", :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 "items", :force => true do |t| - t.text "name" - t.text "desc" - t.text "link" - t.integer "user_id" - t.integer "item_category_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" - t.integer "node1_id" - t.integer "node2_id" - t.integer "user_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" - t.string "crypted_password" - t.string "password_salt" - t.string "persistence_token" - t.string "perishable_token" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - -end +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended to check this file into your version control system. + +ActiveRecord::Schema.define(:version => 20121026064859) do + + create_table "item_categories", :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 "items", :force => true do |t| + t.text "name" + t.text "desc" + t.text "link" + t.integer "user_id" + t.integer "item_category_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "permission" + end + + create_table "mappings", :force => true do |t| + t.text "category" + t.integer "xloc" + t.integer "yloc" + t.integer "map_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "item_id" + t.integer "synapse_id" + end + + create_table "maps", :force => true do |t| + t.text "name" + t.text "desc" + t.text "permission" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "user_id" + end + + create_table "synapses", :force => true do |t| + t.text "desc" + t.text "category" + t.integer "node1_id" + t.integer "node2_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "permission" + t.text "weight" + end + + create_table "users", :force => true do |t| + t.string "name" + t.string "email" + t.string "crypted_password" + t.string "password_salt" + t.string "persistence_token" + t.string "perishable_token" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + +end diff --git a/test/fixtures/mappings.yml b/test/fixtures/mappings.yml new file mode 100644 index 00000000..c63aac0b --- /dev/null +++ b/test/fixtures/mappings.yml @@ -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 diff --git a/test/functional/maps_controller_test.rb b/test/functional/maps_controller_test.rb new file mode 100644 index 00000000..9517ea55 --- /dev/null +++ b/test/functional/maps_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class MapsControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/helpers/maps_helper_test.rb b/test/unit/helpers/maps_helper_test.rb new file mode 100644 index 00000000..0a0efccd --- /dev/null +++ b/test/unit/helpers/maps_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class MapsHelperTest < ActionView::TestCase +end diff --git a/test/unit/mapping_test.rb b/test/unit/mapping_test.rb new file mode 100644 index 00000000..20115809 --- /dev/null +++ b/test/unit/mapping_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class MappingTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end