added maps, permissions, show user cards

This commit is contained in:
Connor Turland 2012-10-26 06:04:52 -04:00
parent dfb92b89a5
commit 5c195bd548
58 changed files with 829 additions and 237 deletions

View file

@ -171,9 +171,17 @@ function initFD(){
}); });
// Build the right column relations list. // Build the right column relations list.
// This is done by traversing the clicked node connections. // This is done by traversing the clicked node connections.
var html = '<div class="item" id="item_' + node.id + '"><p class="type">' + node.getData("itemcatname") + '</p><img alt="' + node.getData("itemcatname") + '" class="icon" height="50" src="' + imgArray[node.getData("itemcatname")].src + '" width="50" /><a href="/items/' + node.id + '" class="title">' + node.name + '</a><div class="desc"><p>' + node.getData('desc') + '</p></div><a href="' + node.getData('link') + '" class="link" target="_blank">' + node.getData('link') + '</a></div>'; var html =
'<p class="type">' + node.getData("itemcatname") + '</p>' +
'<img alt="' + node.getData("itemcatname") + '" class="icon" height="50" src="' + imgArray[node.getData("itemcatname")].src + '" width="50" />' +
'<a href="/users/' + node.getData("userid") + '/items/' + node.id + '" class="title">' + node.name + '</a>' +
'<div class="contributor">Added by: <a href="/users/' + node.getData('userid') + '">' + node.getData('username') + '</a></div>' +
'<div class="desc"><p>' + node.getData('desc') + '</p></div>' +
'<a href="' + node.getData('link') + '" class="link" target="_blank">' + node.getData('link') + '</a>';
//append connections information //append connections information
$jit.id('showcard').innerHTML = html; $jit.id('showcard').innerHTML = '<div class="item" id="item_' + node.id + '"></div>';
$jit.id('item_' + node.id).innerHTML = html;
} }
}, },
//Number of iterations for the FD algorithm //Number of iterations for the FD algorithm
@ -245,9 +253,17 @@ function initFD(){
}); });
// Build the right column relations list. // Build the right column relations list.
// This is done by traversing the clicked node connections. // This is done by traversing the clicked node connections.
var html = '<div class="item" id="item_' + node.id + '"><p class="type">' + node.getData("itemcatname") + '</p><img alt="' + node.getData("itemcatname") + '" class="icon" height="50" src="' + imgArray[node.getData("itemcatname")].src + '" width="50" /><a href="/items/' + node.id + '" class="title">' + node.name + '</a><div class="desc"><p>' + node.getData('desc') + '</p></div><a href="' + node.getData('link') + '" class="link" target="_blank">' + node.getData('link') + '</a></div>'; var html =
//append connections information '<p class="type">' + node.getData("itemcatname") + '</p>' +
$jit.id('showcard').innerHTML = html; '<img alt="' + node.getData("itemcatname") + '" class="icon" height="50" src="' + imgArray[node.getData("itemcatname")].src + '" width="50" />' +
'<a href="/users/' + node.getData("userid") + '/items/' + node.id + '" class="title">' + node.name + '</a>' +
'<div class="contributor">Added by: <a href="/users/' + node.getData('userid') + '">' + node.getData('username') + '</a></div>' +
'<div class="desc"><p>' + node.getData('desc') + '</p></div>' +
'<a href="' + node.getData('link') + '" class="link" target="_blank">' + node.getData('link') + '</a>';
//append connections information
$jit.id('showcard').innerHTML = '<div class="item" id="item_' + node.id + '"></div>';
$jit.id('item_' + node.id).innerHTML = html;
}; };
}, },
// Change node styles when DOM labels are placed // Change node styles when DOM labels are placed

View file

@ -177,9 +177,17 @@ function initRG(){
}); });
// Build the right column relations list. // Build the right column relations list.
// This is done by traversing the clicked node connections. // This is done by traversing the clicked node connections.
var html = '<div class="item" id="item_' + node.id + '"><p class="type">' + node.getData("itemcatname") + '</p><img alt="' + node.getData("itemcatname") + '" class="icon" height="50" src="' + imgArray[node.getData("itemcatname")].src + '" width="50" /><a href="/items/' + node.id + '" class="title">' + node.name + '</a><div class="desc"><p>' + node.getData('desc') + '</p></div><a href="' + node.getData('link') + '" class="link" target="_blank">' + node.getData('link') + '</a></div>'; var html =
'<p class="type">' + node.getData("itemcatname") + '</p>' +
'<img alt="' + node.getData("itemcatname") + '" class="icon" height="50" src="' + imgArray[node.getData("itemcatname")].src + '" width="50" />' +
'<a href="/users/' + node.getData("userid") + '/items/' + node.id + '" class="title">' + node.name + '</a>' +
'<div class="contributor">Added by: <a href="/users/' + node.getData('userid') + '">' + node.getData('username') + '</a></div>' +
'<div class="desc"><p>' + node.getData('desc') + '</p></div>' +
'<a href="' + node.getData('link') + '" class="link" target="_blank">' + node.getData('link') + '</a>';
//append connections information //append connections information
$jit.id('showcard').innerHTML = html; $jit.id('showcard').innerHTML = '<div class="item" id="item_' + node.id + '"></div>';
$jit.id('item_' + node.id).innerHTML = html;
} }
}, },
//Number of iterations for the rg algorithm //Number of iterations for the rg algorithm

View file

@ -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/

View file

@ -30,7 +30,7 @@ h2 {display:block; text-align:center; background: #333; font-size:24px;}
a {color:#2d6a5d; text-decoration:none;} a {color:#2d6a5d; text-decoration:none;}
.clearfloat {clear:both;} .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; } .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; } #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; } .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 { 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 { display:block; float: right; }
.headertop ul li {display:block; float:right; margin:10px 5px 0 5px; } .headertop ul li {display:block; float:right; margin:10px 5px 0 5px; }
.headertop ul li a { color:#FFF; } .headertop ul li a { color:#FFF; }

View file

@ -15,9 +15,9 @@
position:absolute; position:absolute;
top:50%; top:50%;
left:10px; left:10px;
margin-top:-150px; margin-top:-150px;
} }
#showcard .contributor { font-size:12px; }
.text { .text {
margin: 7px; margin: 7px;

View file

@ -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; }

View file

@ -4,15 +4,16 @@ class ItemsController < ApplicationController
respond_to :html, :js, :json respond_to :html, :js, :json
# GET /items # GET /users/:user_id/items
def index def index
@user = current_user @user = User.find(params[:user_id])
@items = Item.all
@items = @user.items
respond_with(@items,@user) respond_with(@user,@items)
end end
# Get /item/new # Get /users/:user_id/items/new
def new def new
@item = Item.new @item = Item.new
@user = current_user @user = current_user
@ -20,12 +21,13 @@ class ItemsController < ApplicationController
respond_with(@item) respond_with(@item)
end end
# GET /item/:id # GET /users/:user_id/items/:id
def show def show
@user = current_user @user = User.find(params[:user_id])
@item = Item.find(params[: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| respond_to do |format|
format.html { respond_with(@item, @user) } format.html { respond_with(@item, @user) }
@ -33,7 +35,7 @@ class ItemsController < ApplicationController
end end
end end
# POST /items # POST /users/:user_id/items
def create def create
@user = current_user @user = current_user
@ -41,53 +43,75 @@ class ItemsController < ApplicationController
@item.name = params[:item][:name] @item.name = params[:item][:name]
@item.desc = params[:item][:desc] @item.desc = params[:item][:desc]
@item.link = params[:item][:link] @item.link = params[:item][:link]
@item.permission = params[:item][:permission]
@item.item_category = ItemCategory.find(params[:category]) @item.item_category = ItemCategory.find(params[:category])
@item.user = @user @item.user = @user
@item.save @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| 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) } format.js { respond_with(@item) }
end end
end end
# GET /items/:id/edit # GET /users/:user_id/items/:id/edit
def 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) respond_with(@item)
end end
# PUT /actions/:id # PUT /users/:user_id/items/:id
def update def update
@item = Item.find_by_id(params[:id]) @user = User.find(params[:user_id])
@item = @user.items.find(params[:id])
if @item if @item
@item.name = params[:item][:name] @item.name = params[:item][:name]
@item.desc = params[:item][:desc] @item.desc = params[:item][:desc]
@item.link = params[:item][:link] @item.link = params[:item][:link]
@item.permission = params[:item][:permission]
@item.item_category = ItemCategory.find(params[:category][:item_category_id]) @item.item_category = ItemCategory.find(params[:category][:item_category_id])
@item.save @item.save
end end
respond_with(@user, location: item_url(@item)) do |format| respond_with(@user, location: user_item_url(@user, @item)) do |format|
end end
end end
# DELETE /items/:id # DELETE /users/:user_id/items/:id
def destroy def destroy
@item = Item.find_by_id(params[:id]) @user = User.find(params[:user_id])
@item = @user.items.find(params[:id])
@synapses = @item.synapses @synapses = @item.synapses
@mappings = @item.mappings
@synapses.each do |synapse| @synapses.each do |synapse|
synapse.delete synapse.delete
end end
@mappings.each do |mapping|
mapping.delete
end
@item.delete @item.delete
respond_to do |format| respond_to do |format|

View file

@ -1,7 +1,6 @@
class MainController < ApplicationController class MainController < ApplicationController
include ItemsHelper include ItemsHelper
before_filter :require_user, only: [:userobjects]
respond_to :html, :js, :json respond_to :html, :js, :json
def home def home
@ -9,7 +8,9 @@ include ItemsHelper
@item = Item.all.first @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| respond_to do |format|
format.html { respond_with(@item) } format.html { respond_with(@item) }
@ -17,22 +18,13 @@ include ItemsHelper
end end
end end
def userobjects def allmaps
@user = current_user @current_user = current_user
@all = @user.items @maps = Map.all
respond_with(@all) respond_to do |format|
end format.html { respond_with(@maps) }
def usersynapses
@user = current_user
@synapsesjson = usersynapses_as_json(@user).html_safe
respond_to do |format|
format.html
format.json { respond_with(@synapsesjson) }
end end
end end

View file

@ -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

View file

@ -22,7 +22,7 @@ class SessionsController < ApplicationController
@user = User.new @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
end end
@ -33,7 +33,7 @@ class SessionsController < ApplicationController
@session.destroy @session.destroy
respond_to do |format| respond_to do |format|
format.html { respond_with(@session, location: restore(default: root_url)) } format.html { respond_with(@session, location: root_url) }
end end
end end

View file

@ -1,18 +1,23 @@
class SynapsesController < ApplicationController class SynapsesController < ApplicationController
include ItemsHelper
before_filter :require_user, only: [:new, :create, :edit, :update] before_filter :require_user, only: [:new, :create, :edit, :update]
respond_to :html, :js, :json respond_to :html, :js, :json
# GET /synapses # GET users/:user_id/synapses
def index def index
@user = current_user @user = User.find(params[:user_id])
@synapses = Synapse.all
@synapsesjson = usersynapses_as_json(@user).html_safe
respond_with(@synapses)
respond_to do |format|
format.html
format.json { respond_with(@synapsesjson) }
end
end end
# Get /synapse/new # Get users/:user_id/synapses/new
def new def new
@synapse = Synapse.new @synapse = Synapse.new
@user = current_user @user = current_user
@ -20,9 +25,11 @@ class SynapsesController < ApplicationController
respond_with(@synapse) respond_with(@synapse)
end end
# GET /synapse/:id # GET users/:user_id/synapses/:id
def show def show
@synapse = Synapse.find(params[:id]) @user = User.find(params[:user_id])
@synapse = @user.synapses.find(params[:id])
if @synapse if @synapse
@synapsejson = @synapse.selfplusnodes_as_json.html_safe @synapsejson = @synapse.selfplusnodes_as_json.html_safe
@ -34,7 +41,7 @@ class SynapsesController < ApplicationController
end end
end end
# POST /synapses # POST users/:user_id/synapses
def create def create
@user = current_user @user = current_user
@ -43,19 +50,48 @@ class SynapsesController < ApplicationController
@synapse.category = params[:category] @synapse.category = params[:category]
@synapse.item1 = Item.find(params[:node1_id]) @synapse.item1 = Item.find(params[:node1_id])
@synapse.item2 = Item.find(params[:node2_id]) @synapse.item2 = Item.find(params[:node2_id])
@synapse.permission = params[:synapse][:permission]
@synapse.user = @user @synapse.user = @user
@synapse.save @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| 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) } format.js { respond_with(@synapse) }
end end
end end
# GET /synapses/:id/edit # GET users/:user_id/synapses/:id/edit
def edit def edit
@synapse = Synapse.find_by_id(params[:id]) @user = User.find(params[:user_id])
@synapse = @user.synapses.find(params[:id])
@items = nil @items = nil
@ -66,26 +102,30 @@ class SynapsesController < ApplicationController
respond_with(@synapse, @items) respond_with(@synapse, @items)
end end
# PUT /synapses/:id # PUT users/:user_id/synapses/:id
def update def update
@synapse = Synapse.find_by_id(params[:id]) @user = User.find(params[:user_id])
@synapse = @user.synapses.find(params[:id])
if @synapse if @synapse
@synapse.desc = params[:synapse][:desc] @synapse.desc = params[:synapse][:desc]
@synapse.item1 = Item.find(params[:node1_id][:node1]) @synapse.item1 = Item.find(params[:node1_id][:node1])
@synapse.item2 = Item.find(params[:node2_id][:node2]) @synapse.item2 = Item.find(params[:node2_id][:node2])
@synapse.permission = params[:synapse][:permission]
@synapse.save @synapse.save
end end
respond_with(@user, location: synapse_url(@synapse)) do |format| respond_with(@user, location: user_synapse_url(@user, @synapse)) do |format|
end end
end end
# DELETE /synapses/:id # DELETE users/:user_id/synapses/:id
def destroy def destroy
@synapse = Synapse.find_by_id(params[:id]) @user = User.find(params[:user_id])
@synapse = @user.synapses.find(params[:id])
@synapse.delete @synapse.delete
end end

View file

@ -1,7 +1,7 @@
class UsersController < ApplicationController class UsersController < ApplicationController
before_filter :require_no_user, only: [:new, :create] 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 respond_to :html, :json
@ -36,7 +36,7 @@ class UsersController < ApplicationController
@user.save @user.save
respond_with(@user, location: restore(default: root_url)) do |format| respond_with(@user, location: root_url) do |format|
end end
end end
@ -47,7 +47,7 @@ class UsersController < ApplicationController
@user.save @user.save
respond_with(@user, location: restore(default: root_url)) do |format| respond_with(@user, location: user_url(@user)) do |format|
end end
end end

View file

@ -54,6 +54,8 @@ module ItemsHelper
@itemdata['$desc'] = item.desc @itemdata['$desc'] = item.desc
@itemdata['$link'] = item.link @itemdata['$link'] = item.link
@itemdata['$itemcatname'] = item.item_category.name @itemdata['$itemcatname'] = item.item_category.name
@itemdata['$userid'] = item.user.id
@itemdata['$username'] = item.user.name
json.data @itemdata json.data @itemdata
json.id item.id json.id item.id
json.name item.name json.name item.name

View file

@ -0,0 +1,2 @@
module MapsHelper
end

View file

@ -3,10 +3,13 @@ include ItemsHelper
belongs_to :user belongs_to :user
has_many :synapses1, :class_name => 'Synapse', :foreign_key => 'node1_id' #, :conditions => {:category => 'Item'} has_many :synapses1, :class_name => 'Synapse', :foreign_key => 'node1_id'
has_many :synapses2, :class_name => 'Synapse', :foreign_key => 'node2_id' #, :conditions => {:category => 'Item'} has_many :synapses2, :class_name => 'Synapse', :foreign_key => 'node2_id'
has_many :items1, :through => :synapses2, :source => :item1 has_many :items1, :through => :synapses2, :source => :item1
has_many :items2, :through => :synapses1, :source => :item2 has_many :items2, :through => :synapses1, :source => :item2
has_many :mappings
has_many :maps, :through => :mappings
def synapses def synapses
synapses1 + synapses2 synapses1 + synapses2
@ -25,6 +28,8 @@ belongs_to :item_category
@itemdata['$desc'] = self.desc @itemdata['$desc'] = self.desc
@itemdata['$link'] = self.link @itemdata['$link'] = self.link
@itemdata['$itemcatname'] = self.item_category.name @itemdata['$itemcatname'] = self.item_category.name
@itemdata['$userid'] = self.user.id
@itemdata['$username'] = self.user.name
json.data @itemdata json.data @itemdata
json.id self.id json.id self.id
json.name self.name json.name self.name
@ -32,7 +37,7 @@ belongs_to :item_category
end end
#build a json object of everything connected to a specified node #build a json object of everything connected to a specified node
def map_as_json def network_as_json
Jbuilder.encode do |json| Jbuilder.encode do |json|
@items = network(self,nil) @items = network(self,nil)
@ -44,6 +49,8 @@ belongs_to :item_category
@synapsedata = Hash.new @synapsedata = Hash.new
@synapsedata['$desc'] = synapse.desc @synapsedata['$desc'] = synapse.desc
@synapsedata['$category'] = synapse.category @synapsedata['$category'] = synapse.category
@synapsedata['$userid'] = synapse.user.id
@synapsedata['$username'] = synapse.user.name
json.data @synapsedata json.data @synapsedata
end end
@ -51,6 +58,8 @@ belongs_to :item_category
@itemdata['$desc'] = item.desc @itemdata['$desc'] = item.desc
@itemdata['$link'] = item.link @itemdata['$link'] = item.link
@itemdata['$itemcatname'] = item.item_category.name @itemdata['$itemcatname'] = item.item_category.name
@itemdata['$userid'] = item.user.id
@itemdata['$username'] = item.user.name
json.data @itemdata json.data @itemdata
json.id item.id json.id item.id
json.name item.name json.name item.name
@ -71,6 +80,8 @@ belongs_to :item_category
@synapsedata = Hash.new @synapsedata = Hash.new
@synapsedata['$desc'] = synapse.desc @synapsedata['$desc'] = synapse.desc
@synapsedata['$category'] = synapse.category @synapsedata['$category'] = synapse.category
@synapsedata['$userid'] = synapse.user.id
@synapsedata['$username'] = synapse.user.name
json.data @synapsedata json.data @synapsedata
end end
@ -78,6 +89,9 @@ belongs_to :item_category
@itemdata['$desc'] = item.desc @itemdata['$desc'] = item.desc
@itemdata['$link'] = item.link @itemdata['$link'] = item.link
@itemdata['$itemcatname'] = item.item_category.name @itemdata['$itemcatname'] = item.item_category.name
@itemdata['$userid'] = item.user.id
@itemdata['$username'] = item.user.name
json.data @itemdata json.data @itemdata
json.id item.id json.id item.id
json.name item.name json.name item.name

View file

@ -1,2 +1,47 @@
class Map < ActiveRecord::Base 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 end

8
app/models/mapping.rb Normal file
View file

@ -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

View file

@ -5,11 +5,16 @@ belongs_to :user
belongs_to :item1, :class_name => "Item", :foreign_key => "node1_id" belongs_to :item1, :class_name => "Item", :foreign_key => "node1_id"
belongs_to :item2, :class_name => "Item", :foreign_key => "node2_id" belongs_to :item2, :class_name => "Item", :foreign_key => "node2_id"
has_many :mappings
has_many :maps, :through => :mappings
def self_as_json def self_as_json
Jbuilder.encode do |json| Jbuilder.encode do |json|
@synapsedata = Hash.new @synapsedata = Hash.new
@synapsedata['$desc'] = self.desc @synapsedata['$desc'] = self.desc
@synapsedata['$category'] = self.category @synapsedata['$category'] = self.category
@synapsedata['$userid'] = synapse.user.id
@synapsedata['$username'] = synapse.user.name
json.data @synapsedata json.data @synapsedata
end end
end end
@ -28,6 +33,8 @@ belongs_to :item2, :class_name => "Item", :foreign_key => "node2_id"
@synapsedata = Hash.new @synapsedata = Hash.new
@synapsedata['$desc'] = synapse.desc @synapsedata['$desc'] = synapse.desc
@synapsedata['$category'] = synapse.category @synapsedata['$category'] = synapse.category
@synapsedata['$userid'] = synapse.user.id
@synapsedata['$username'] = synapse.user.name
json.data @synapsedata json.data @synapsedata
end end
@ -35,6 +42,8 @@ belongs_to :item2, :class_name => "Item", :foreign_key => "node2_id"
@itemdata['$desc'] = item.desc @itemdata['$desc'] = item.desc
@itemdata['$link'] = item.link @itemdata['$link'] = item.link
@itemdata['$itemcatname'] = item.item_category.name @itemdata['$itemcatname'] = item.item_category.name
@itemdata['$userid'] = self.user.id
@itemdata['$username'] = self.user.name
json.data @itemdata json.data @itemdata
json.id item.id json.id item.id
json.name item.name json.name item.name

View file

@ -4,6 +4,8 @@ class User < ActiveRecord::Base
has_many :items has_many :items
has_many :synapses has_many :synapses
has_many :maps
has_many :mappings
acts_as_authentic do |configuration| acts_as_authentic do |configuration|
configuration.session_class = Session configuration.session_class = Session

View file

@ -1,8 +1,8 @@
<%= div_for item, class: item.item_category.name do %> <%= 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 %>
<p class="type"><%= item.item_category.name %></p> <p class="type"><%= item.item_category.name %></p>
<%= image_tag item.item_category.icon, :class => 'icon', :size => '50x50' %> <%= 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' %>
<div class="desc"><p><%=item.desc %></p></div> <div class="desc"><p><%=item.desc %></p></div>
<%= link_to item.link, item.link, :class => 'link', :target => '_blank' %> <%= link_to item.link, item.link, :class => 'link', :target => '_blank' %>
<% end %> <% end %>

View file

@ -1,5 +1,5 @@
<div class="anypage"> <div class="anypage">
<%= form_for Item.new, url: items_path, remote: true do |form| %> <%= form_for Item.new, url: user_items_url(user), remote: true do |form| %>
<button id="closenewtopic" onclick="$('#new_item').fadeOut('fast'); $('#new_item')[0].reset(); return false;">close</button> <button id="closenewtopic" onclick="$('#new_item').fadeOut('fast'); $('#new_item')[0].reset(); return false;">close</button>
<h3>Add Topic</h3> <h3>Add Topic</h3>
<label for="category">Category</label> <label for="category">Category</label>
@ -10,6 +10,8 @@
<%= form.text_area :desc, class: "description", :rows => 5 %> <%= form.text_area :desc, class: "description", :rows => 5 %>
<label for="item_link">Link</label> <label for="item_link">Link</label>
<%= form.text_field :link, class: "link" %> <%= form.text_field :link, class: "link" %>
<label for="item_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.submit "Add Item", class: "addItem", id: "addItem" %> <%= form.submit "Add Item", class: "addItem", id: "addItem" %>
<% end %> <% end %>
</div> </div>

View file

@ -36,6 +36,10 @@ if (map2 != null) {
duration: 400 duration: 400
}); });
} }
else {
json = newnode;
initFD();
}
// add the new node to the synapse select list // add the new node to the synapse select list
$("#node1_id").prepend("<option value='<%= @item.id %>'><%= @item.name %></option>"); $("#node1_id").prepend("<option value='<%= @item.id %>'><%= @item.name %></option>");
$("#node2_id").prepend("<option value='<%= @item.id %>'><%= @item.name %></option>"); $("#node2_id").prepend("<option value='<%= @item.id %>'><%= @item.name %></option>");

View file

@ -1,4 +1,4 @@
<%= form_for @item, url: item_url do |form| %> <%= form_for @item, url: user_item_url do |form| %>
<h3>Edit Item</h3> <h3>Edit Item</h3>
<label for="category">Category</label> <label for="category">Category</label>
<%= select "category", "item_category_id", ItemCategory.order("name ASC").all.collect {|p| [ p.name, p.id ] }, { :selected => @item.item_category.id } %> <%= 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_area :desc, class: "description", :rows => 5 %>
<label for="item_link">Link</label> <label for="item_link">Link</label>
<%= form.text_field :link, class: "link" %> <%= form.text_field :link, class: "link" %>
<label for="item_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.submit "Update", class: "update" %> <%= form.submit "Update", class: "update" %>
<% end %> <% end %>

View file

@ -1,4 +1,4 @@
<h1>All Topics</h1> <h1>Topics</h1>
<div class="items" id="cards"> <div class="items" id="cards">
<% @items.each do |item| %> <% @items.each do |item| %>
@ -10,4 +10,6 @@
</div> </div>
<div class="clearfloat"></div> <div class="clearfloat"></div>
<%= render :partial => 'items/new' %> <% if authenticated? %>
<%= render :partial => 'items/new' %>
<% end %>

View file

@ -1,5 +1,5 @@
<div class="nothidden"> <div class="nothidden">
<%= form_for @item || Item.new, url: items_path do |form| %> <%= form_for @item || Item.new, url: user_items_path do |form| %>
<h3>Add Topic</h3> <h3>Add Topic</h3>
<label for="category">Category</label> <label for="category">Category</label>
<%= select_tag "category", options_from_collection_for_select(ItemCategory.order("name ASC").all, "id", "name") %> <%= 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_area :desc, class: "description", :rows => 5 %>
<label for="item_link">Link</label> <label for="item_link">Link</label>
<%= form.text_field :link, class: "link" %> <%= form.text_field :link, class: "link" %>
<label for="item_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.submit "Add Item", class: "add" %> <%= form.submit "Add Item", class: "add" %>
<% end %> <% end %>
</div> </div>

View file

@ -1,11 +1,10 @@
<div class="focus"> <div class="focus">
<div class="focusleft"> <div class="focusleft">
<p><%= @item.item_category.name %></p> <p><%= @item.item_category.name %></p>
<%= image_tag @item.item_category.icon, :class => 'icon', :size => '50x50' %> <%= image_tag @item.item_category.icon, :class => 'icon', :size => '50x50' %>
</div> </div>
<div class="focusmiddle"> <div class="focusmiddle">
<h1 class="title"><%= @item.name %> <% if @user %><%= link_to "[edit]", edit_item_path(@item) %><% end %></h1> <h1 class="title"><%= @item.name %> <% if authenticated? %><%= link_to "[edit]", edit_user_item_path(@user, @item) %><% end %></h1>
<div class="desc"> <div class="desc">
<p><%= @item.desc %></p> <p><%= @item.desc %></p>
</div> </div>
@ -34,5 +33,8 @@
}); });
</script> </script>
<%= render :partial => 'items/new' %> <% if authenticated? %>
<%= render :partial => 'synapses/new' %> <%= render :partial => 'items/new' %>
<%= render :partial => 'synapses/new' %>
<% end %>

View file

@ -4,6 +4,8 @@
<title>Metamaps</title> <title>Metamaps</title>
<%= stylesheet_link_tag "application", :media => "all" %> <%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %> <%= javascript_include_tag "application" %>
<script type="text/javascript" src="//use.typekit.net/tki2nyo.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>
</head> </head>
<body> <body>
@ -52,20 +54,24 @@
<ul> <ul>
<li><%= link_to "Login", new_session_path, id: "Login" %></li> <li><%= link_to "Login", new_session_path, id: "Login" %></li>
<li>|</li> <li>|</li>
<li><%= link_to "Topics", items_path %></li> <li><%= link_to "Maps", allmaps_path %></li>
</ul> </ul>
<% end %> <% end %>
<% if authenticated? %> <% if authenticated? %>
<ul> <ul>
<li><%= link_to "Logout", session_path, method: 'delete', id: "Login" %></li> <li><%= link_to "Logout", session_path, method: 'delete', id: "Login" %></li>
<li><%= link_to "My Synapses", usersynapses_path %></li> <li><%= link_to "Account", edit_user_url(user) %></li>
<li><%= link_to "My Topics", userobjects_path %></li> <li><%= link_to "My Maps", user_maps_url(user) %></li>
<li><%= link_to "My Synapses", user_synapses_url(user) %></li>
<li><%= link_to "My Topics", user_items_url(user) %></li>
<li>|</li> <li>|</li>
<li><%= link_to "Add Synapse", new_synapse_path, id: "newsynapse" %></li> <li><%= link_to "Add Map", new_user_map_path(user), id: "newmap" %></li>
<li>|</li> <li>|</li>
<li><%= link_to "Add Topic", new_item_path, id: "newtopic" %></li> <li><%= link_to "Add Synapse", new_user_synapse_path(user), id: "newsynapse" %></li>
<li>|</li> <li>|</li>
<li><%= link_to "Topics", items_path %></li> <li><%= link_to "Add Topic", new_user_item_path(user), id: "newtopic" %></li>
<li>|</li>
<li><%= link_to "Maps", allmaps_path %></li>
</ul> </ul>
<% end %> <% end %>
</div> </div>

View file

@ -0,0 +1,11 @@
<h1>All Maps</h1>
<div class="maps" id="cards">
<% @maps.each do |map| %>
<%= render map %>
<% end %>
<% if @maps.empty? %>
<p><br>Shucks, there are no maps.<p>
<% end %>
</div>
<div class="clearfloat"></div>

View file

@ -18,6 +18,8 @@
<p><br>Shucks, there is nothing in metamaps.<p> <p><br>Shucks, there is nothing in metamaps.<p>
<% end %> <% end %>
<%= render :partial => 'items/new' %> <% if authenticated? %>
<%= render :partial => 'synapses/new' %> <%= render :partial => 'items/new' %>
<%= render :partial => 'synapses/new' %>
<% end %>

View file

@ -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' %>
<div class="desc"><p><%= map.desc %></p><p># of Topics: <%= map.items.count %></p><p># of Synapses: <%= map.synapses.count %></p></div>
<div class="link"><p>Permissions:<%= map.permission %></p></div>
<% end %>

View file

@ -0,0 +1,21 @@
<div class="anypage">
<%= form_for Synapse.new, url: user_synapses_url(user), remote: true do |form| %>
<button id="closenewsynapse" onclick="$('#new_synapse').fadeOut('fast'); $('#new_synapse')[0].reset(); return false;">close</button>
<h3>Add Synapse Between Topics</h3>
<%= hidden_field_tag(:category, "Item") %>
<% if Item.all.count > 0 %>
<label for="node1_id">Choose First Item</label>
<%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %>
<% end %>
<label for="item_desc">Describe The Connection</label>
<%= form.text_field :desc, class: "description" %>
<% if Item.all.count > 0 %>
<label for="node2_id">Choose Second Item</label>
<%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %>
<% end %>
<label for="synapse_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.hidden_field :map, :value => @map.id %>
<%= form.submit "Add Synapse", class: "add" %>
<% end %>
</div>

View file

@ -0,0 +1,18 @@
<div class="anypage">
<%= form_for Item.new, url: user_items_url(user), remote: true do |form| %>
<button id="closenewtopic" onclick="$('#new_item').fadeOut('fast'); $('#new_item')[0].reset(); return false;">close</button>
<h3>Add Topic</h3>
<label for="category">Category</label>
<%= select_tag "category", options_from_collection_for_select(ItemCategory.order("name ASC").all, "id", "name") %>
<label for="item_name">Title</label>
<%= form.text_field :name %>
<label for="item_desc">Description</label>
<%= form.text_area :desc, class: "description", :rows => 5 %>
<label for="item_link">Link</label>
<%= form.text_field :link, class: "link" %>
<label for="item_permission">Permission</label>
<%= 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 %>
</div>

View file

@ -0,0 +1,10 @@
<%= form_for @map, url: user_map_url(@user, @map) do |form| %>
<h3>Edit Map</h3>
<label for="map_name">Name</label>
<%= form.text_field :name %>
<label for="map_desc">Description</label>
<%= form.text_area :desc, class: "description", :rows => 5 %>
<label for="map_perm">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private']), { :selected => @map.permission }) %>
<%= form.submit "Update", class: "update" %>
<% end %>

View file

@ -0,0 +1,11 @@
<h1>Maps</h1>
<div class="maps" id="cards">
<% @maps.each do |map| %>
<%= render map %>
<% end %>
<% if @maps.empty? %>
<p><br>Shucks, there are no maps.<p>
<% end %>
</div>
<div class="clearfloat"></div>

View file

@ -0,0 +1,12 @@
<div class="nothidden">
<%= form_for @map || Map.new, url: user_maps_url do |form|%>
<h3>Add Map</h3>
<label for="map_name">Name</label>
<%= form.text_field :name %>
<label for="map_desc">Description</label>
<%= form.text_area :desc, class: "description", :rows => 5 %>
<label for="map_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.submit "Add Map", class: "add" %>
<% end %>
</div>

View file

@ -0,0 +1,37 @@
<div class="focus">
<div class="focusleft">
<p># of Topics: <%= @map.items.count %></p>
<p># of Synapses: <%= @map.synapses.count %></p>
</div>
<div class="focusmiddle">
<h1 class="title"><%= @map.name %> <% if authenticated? %><%= link_to "[edit]", edit_user_map_path(@user, @map) %><% end %></h1>
<div class="desc">
<p><%= @map.desc %></p>
</div>
</div>
<div class="focusright">
<div class="link"><p>Permissions:<%= @map.permission %></p></div>
</div>
</div>
<div class="clearfloat nodemargin"></div>
<div class="maps" id="container">
<div id="center-container">
<div id="infovis"></div>
</div>
<div id="showcard">
</div>
</div>
<div class="clearfloat"></div>
<script>
json = <%= @mapjson %>;
if (json.length > 0) {
$(document).ready(function() {
initFD();
});
}
</script>
<%= render :partial => 'newtopic' %>
<%= render :partial => 'newsynapse' %>

View file

@ -1,5 +1,5 @@
<div class="anypage"> <div class="anypage">
<%= form_for Synapse.new, url: synapses_url, remote: true do |form| %> <%= form_for Synapse.new, url: user_synapses_url(user), remote: true do |form| %>
<button id="closenewsynapse" onclick="$('#new_synapse').fadeOut('fast'); $('#new_synapse')[0].reset(); return false;">close</button> <button id="closenewsynapse" onclick="$('#new_synapse').fadeOut('fast'); $('#new_synapse')[0].reset(); return false;">close</button>
<h3>Add Synapse Between Topics</h3> <h3>Add Synapse Between Topics</h3>
<%= hidden_field_tag(:category, "Item") %> <%= hidden_field_tag(:category, "Item") %>
@ -13,6 +13,8 @@
<label for="node2_id">Choose Second Item</label> <label for="node2_id">Choose Second Item</label>
<%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %> <%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %>
<% end %> <% end %>
<label for="synapse_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.submit "Add Synapse", class: "add" %> <%= form.submit "Add Synapse", class: "add" %>
<% end %> <% end %>
</div> </div>

View file

@ -6,7 +6,7 @@ map1 = document.getElementById('container');
if (map1 != null) { if (map1 != null) {
var mymap, newnode, select1, select2, option, temp1, temp2, temp; var mymap, newnode, temp1, temp2, temp;
if (fd != null) { if (fd != null) {
mymap = fd; mymap = fd;
} }
@ -14,69 +14,69 @@ if (map1 != null) {
mymap = rg; mymap = rg;
} }
temp1 = mymap.graph.getNode(<%= @synapse.item1.id %>); if (mymap == fd || mymap == rg) {
if (temp1 == null) { temp1 = mymap.graph.getNode(<%= @synapse.item1.id %>);
newnode = <%= @synapse.item1.self_as_json.html_safe %>; if (temp1 == null) {
mymap.graph.addNode(newnode); newnode = <%= @synapse.item1.self_as_json.html_safe %>;
temp = mymap.graph.getNode('<%= @synapse.item1.id %>'); mymap.graph.addNode(newnode);
temp.setData('dim', 1, 'start'); temp = mymap.graph.getNode('<%= @synapse.item1.id %>');
temp.setData('dim', 40, 'end'); temp.setData('dim', 1, 'start');
if (mymap == fd) { temp.setData('dim', 40, 'end');
temp.setPos(new $jit.Complex(0, 0), 'current'); if (mymap == fd) {
temp.setPos(new $jit.Complex(0, 0), 'start'); temp.setPos(new $jit.Complex(0, 0), 'current');
temp.setPos(new $jit.Complex(0, 0), 'end'); 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'); else if (mymap == rg) {
temp.setPos(new $jit.Polar(5.54, 347.6), 'start'); temp.setPos(new $jit.Polar(5.54, 347.6), 'current');
temp.setPos(new $jit.Polar(5.54, 347.6), 'end'); 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 %>); mymap.fx.plotNode(temp, mymap.canvas);
// add the new node to the synapse select list temp1 = mymap.graph.getNode(<%= @synapse.item1.id %>);
$("#node1_id").prepend("<option value='<%= @synapse.item1.id %>'><%= @synapse.item1.name %></option>"); }
$("#node2_id").prepend("<option value='<%= @synapse.item1.id %>'><%= @synapse.item1.name %></option>"); 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 %>); else {
if (temp2 == null) { json = <%= @synapse.selfplusnodes_as_json.html_safe %>
newnode = <%= @synapse.item2.self_as_json.html_safe %>; initFD();
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("<option value='<%= @synapse.item2.id %>'><%= @synapse.item2.name %></option>");
$("#node2_id").prepend("<option value='<%= @synapse.item2.id %>'><%= @synapse.item2.name %></option>");
} }
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
});
} }

View file

@ -1,4 +1,4 @@
<%= form_for @synapse, url: synapse_url do |form| %> <%= form_for @synapse, url: user_synapse_url do |form| %>
<h3>Edit Synapse</h3> <h3>Edit Synapse</h3>
<% if @collection.count > 0 %> <% if @collection.count > 0 %>
<label for="node1_id">Choose First <%= @synapse.category %></label> <label for="node1_id">Choose First <%= @synapse.category %></label>
@ -10,5 +10,7 @@
<label for="node2_id">Choose Second <%= @synapse.category %></label> <label for="node2_id">Choose Second <%= @synapse.category %></label>
<%= select "node2_id", "node2", @collection.order("name ASC").map {|p| [ p.name, p.id ] }, { :selected => @synapse.node2_id } %> <%= select "node2_id", "node2", @collection.order("name ASC").map {|p| [ p.name, p.id ] }, { :selected => @synapse.node2_id } %>
<% end %> <% end %>
<label for="synapse_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.submit "Update", class: "update" %> <%= form.submit "Update", class: "update" %>
<% end %> <% end %>

View file

@ -1,11 +1,20 @@
<h1>Synapses</h1> <div class="synapses" id="container">
<div id="center-container">
<div class="synapses" id="synapses"> <div id="infovis"></div>
<% @synapses.each do |synapse| %> </div>
<%= render synapse %> <div id="showcard">
<% end %> </div>
<% if @synapses.empty? %>
<p><br>Shucks, there are no synapses.<p>
<% end %>
</div> </div>
<div class="clearfloat"></div> <div class="clearfloat"></div>
<script>
json = <%= @synapsesjson %>;
$(document).ready(function() {
initFD();
});
</script>
<% if authenticated? %>
<%= render :partial => 'items/new' %>
<%= render :partial => 'synapses/new' %>
<% end %>

View file

@ -1,5 +1,5 @@
<div class="newsynapses"> <div class="newsynapses">
<%= form_for @synapse, url: synapses_url do |form| %> <%= form_for @synapse, url: user_synapses_url do |form| %>
<h3>Add Synapse Between Topics</h3> <h3>Add Synapse Between Topics</h3>
<%= hidden_field_tag(:category, "Item") %> <%= hidden_field_tag(:category, "Item") %>
<% if Item.all.count > 0 %> <% if Item.all.count > 0 %>
@ -12,6 +12,8 @@
<label for="node2_id">Choose Second Item</label> <label for="node2_id">Choose Second Item</label>
<%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %> <%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %>
<% end %> <% end %>
<label for="synapse_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.submit "Add Synapse", class: "add" %> <%= form.submit "Add Synapse", class: "add" %>
<% end %> <% end %>
</div> </div>

View file

@ -13,4 +13,9 @@
$(document).ready(function() { $(document).ready(function() {
initFD(); initFD();
}); });
</script> </script>
<% if authenticated? %>
<%= render :partial => 'items/new' %>
<%= render :partial => 'synapses/new' %>
<% end %>

View file

@ -0,0 +1,7 @@
<%= formula_form_for @user, url: user_url do |form| %>
<h3>Edit Account</h3>
<%= 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 %>

View file

@ -1,4 +1,4 @@
<%= formula_form_for @user, url: user_url do |form| %> <%= formula_form_for @user, url: users_url do |form| %>
<h3>Create Account</h3> <h3>Create Account</h3>
<%= form.input :name, label: "Name", class: "name" %> <%= form.input :name, label: "Name", class: "name" %>
<%= form.input :email, label: "Email", class: "email" %> <%= form.input :email, label: "Email", class: "email" %>

View file

@ -0,0 +1,18 @@
<div class="focus">
<div class="focusleft">
<p># of Topics: <%= @user.items.count %></p>
<p># of Synapses: <%= @user.synapses.count %></p>
<p># of Maps: <%= @user.maps.count %></p>
</div>
<div class="focusmiddle">
<h1 class="title"><%= @user.name %></h1>
<div class="desc">
<p><%= link_to "View their topics", user_items_path(@user)%></p>
<p><%= link_to "View their synapses", user_synapses_path(@user)%></p>
<p><%= link_to "View their maps", user_maps_path(@user) %></p>
</div>
</div>
<div class="focusright">
</div>
</div>
<div class="clearfloat nodemargin"></div>

View file

@ -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: development:
min_messages: WARNING min_messages: WARNING
adapter: postgresql adapter: postgresql
host: ec2-54-243-188-58.compute-1.amazonaws.com host: 127.0.0.1
port: 5442 port: 5432
encoding: unicode encoding: unicode
database: da81fvorvn5pp9 database: metamap002_development
pool: 5 pool: 5
username: yolhqgtlivenrk username: postgres
password: "oi_EAZwbXboYjqB_9tWPh2x5YS" password: "3112"
test: test:
min_messages: WARNING min_messages: WARNING
adapter: postgresql adapter: postgresql

View file

@ -2,16 +2,15 @@ ISSAD::Application.routes.draw do
root to: 'main#home', via: :get root to: 'main#home', via: :get
match 'my-topics', to: 'main#userobjects', via: :get, as: :userobjects match 'maps', to: 'main#allmaps', via: :get, as: :allmaps
match 'my-synapses', to: 'main#usersynapses', via: :get, as: :usersynapses
resource :user
resource :session resource :session
resources :items resources :users do
resources :people resources :items
resources :groups resources :synapses
resources :synapses resources :maps
end
# The priority is based upon order of creation: # The priority is based upon order of creation:
# first created -> highest priority. # first created -> highest priority.

View file

@ -4,6 +4,7 @@ class CreateItems < ActiveRecord::Migration
t.text :name t.text :name
t.text :desc t.text :desc
t.text :link t.text :link
t.text :permission
t.integer :user_id t.integer :user_id
t.integer :item_category_id t.integer :item_category_id

View file

@ -3,6 +3,8 @@ class CreateSynapses < ActiveRecord::Migration
create_table :synapses do |t| create_table :synapses do |t|
t.text :desc t.text :desc
t.text :category t.text :category
t.text :weight
t.text :permission
t.integer :node1_id t.integer :node1_id
t.integer :node2_id t.integer :node2_id
t.integer :user_id t.integer :user_id

View file

@ -1,7 +1,10 @@
class CreateMaps < ActiveRecord::Migration class CreateMaps < ActiveRecord::Migration
def change def change
create_table :maps do |t| create_table :maps do |t|
t.text :name
t.text :desc
t.text :permission
t.integer :user_id
t.timestamps t.timestamps
end end
end end

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,54 +1,78 @@
# encoding: UTF-8 # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead # 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 # of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition. # incrementally modify your database, and then regenerate this schema definition.
# #
# Note that this schema.rb definition is the authoritative source for your # Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another # 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 # 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 # 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). # 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. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20121005160234) do ActiveRecord::Schema.define(:version => 20121026064859) do
create_table "item_categories", :force => true do |t| create_table "item_categories", :force => true do |t|
t.text "name" t.text "name"
t.string "icon" t.string "icon"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
create_table "items", :force => true do |t| create_table "items", :force => true do |t|
t.text "name" t.text "name"
t.text "desc" t.text "desc"
t.text "link" t.text "link"
t.integer "user_id" t.integer "user_id"
t.integer "item_category_id" t.integer "item_category_id"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end t.text "permission"
end
create_table "synapses", :force => true do |t|
t.text "desc" create_table "mappings", :force => true do |t|
t.text "category" t.text "category"
t.integer "node1_id" t.integer "xloc"
t.integer "node2_id" t.integer "yloc"
t.integer "user_id" t.integer "map_id"
t.datetime "created_at", :null => false t.integer "user_id"
t.datetime "updated_at", :null => false t.datetime "created_at", :null => false
end t.datetime "updated_at", :null => false
t.integer "item_id"
create_table "users", :force => true do |t| t.integer "synapse_id"
t.string "name" end
t.string "email"
t.string "crypted_password" create_table "maps", :force => true do |t|
t.string "password_salt" t.text "name"
t.string "persistence_token" t.text "desc"
t.string "perishable_token" t.text "permission"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end t.integer "user_id"
end
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

11
test/fixtures/mappings.yml vendored Normal file
View file

@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value

View file

@ -0,0 +1,7 @@
require 'test_helper'
class MapsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View file

@ -0,0 +1,4 @@
require 'test_helper'
class MapsHelperTest < ActionView::TestCase
end

View file

@ -0,0 +1,7 @@
require 'test_helper'
class MappingTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end