This commit is contained in:
Devin Howard 2013-01-20 21:22:33 -05:00
commit aa911d4bdf
18 changed files with 249 additions and 38 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

View file

@ -83,7 +83,40 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
},800); },800);
} }
); );
// controls the sliding hover of the settings for cards
var sliding2 = false;
var lT2;
$(".permActivator").hover(
function () {
clearTimeout(lT2);
if (! sliding2) {
sliding2 = true;
$(this).animate({
width: '203px',
height: '37px'
}, 300, function() {
sliding2 = false;
});
}
},
function () {
that = this;
lT2 = setTimeout(function() {
if (! sliding2) {
sliding2 = true;
$(that).animate({
height: '16px',
width: '16px'
}, 300, function() {
sliding2 = false;
});
}
},800);
}
);
// this is to save the layout of maps when you're on a map page // this is to save the layout of maps when you're on a map page
$("#saveLayout").click(function(event) { $("#saveLayout").click(function(event) {
event.preventDefault(); event.preventDefault();

View file

@ -3,4 +3,4 @@
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
jQuery -> jQuery ->
$('.authenticated .best_in_place').best_in_place() $('.authenticated div.permission.canEdit .best_in_place').best_in_place()

View file

@ -135,3 +135,44 @@ margin-right: -8px;
.CardOnGraph .go-link { .CardOnGraph .go-link {
float:left; float:left;
} }
.cardSettings {
position: absolute;
left: 12px;
top: 13px;
}
.editSettings {
background: #ddd;
border-radius: 10px;
padding: 5px 0 5px 5px;
position: relative;
left: 16px;
width: 172px;
opacity: 0.98;
box-shadow: 4px 4px 5px #888888;
border: 1px solid #AAA;
}
.editSettings span {
float:left;
}
.permActivator {
width: 16px;
height: 16px;
background: url('settings.png') no-repeat 0 0;
overflow:hidden;
}
.mapPerm {
background: #fff;
padding: 0 4px 4px 4px;
border-radius: 15px;
border: 1px solid #AAA;
position: absolute;
left: -7px;
top: 18px;
width:16px;
text-align:center;
}

View file

@ -6,9 +6,12 @@ class MainController < ApplicationController
respond_to :html, :js, :json respond_to :html, :js, :json
def home def home
@topics = Topic.order("created_at DESC").limit(3).visibleToUser(@current, nil) @topics = Topic.visibleToUser(@current, nil).sort! { |a,b| b.created_at <=> a.created_at }
@synapses = Synapse.order("created_at DESC").limit(3).visibleToUser(@current, nil) @topics = @topics.slice(0,3)
@maps = Map.order("created_at DESC").limit(3).visibleToUser(@current, nil) @synapses = Synapse.visibleToUser(@current, nil).sort! { |a,b| b.created_at <=> a.created_at }
@synapses = @synapses.slice(0,3)
@maps = Map.visibleToUser(@current, nil).sort! { |a,b| b.created_at <=> a.created_at }
@maps = @maps.slice(0,3)
respond_with(@topics, @synapses, @maps) respond_with(@topics, @synapses, @maps)
end end

View file

@ -1,6 +1,6 @@
class MapsController < ApplicationController class MapsController < ApplicationController
before_filter :require_user, only: [:new, :create, :edit, :update, :savelayout] before_filter :require_user, only: [:new, :create, :edit, :update, :savelayout, :destroy]
respond_to :html, :js, :json respond_to :html, :js, :json
@ -48,6 +48,21 @@ class MapsController < ApplicationController
end end
end end
# GET maps/:id/json
def json
@current = current_user
@map = Map.find(params[:id]).authorize_to_show(@current)
if not @map
redirect_to root_url and return
end
respond_to do |format|
format.json { render :json => @map.self_as_json(@current) }
end
end
# POST maps # POST maps
def create def create
@ -116,13 +131,19 @@ class MapsController < ApplicationController
# PUT maps/:id # PUT maps/:id
def update def update
@map = Map.find(params[:id]) @current = current_user
@map = Map.find(params[:id]).authorize_to_edit(@current)
@map.attributes = params[:map] if @map
@map.save if params[:map]
@map.name = params[:map][:name] if params[:map][:name]
respond_with(@user, location: map_path(@map)) do |format| @map.desc = params[:map][:desc] if params[:map][:desc]
@map.permission = params[:map][:permission] if params[:map][:permission]
end
@map.save
end end
respond_with @map
end end
# PUT maps/:id/savelayout # PUT maps/:id/savelayout

View file

@ -1,7 +1,7 @@
class SynapsesController < ApplicationController class SynapsesController < ApplicationController
include TopicsHelper include TopicsHelper
before_filter :require_user, only: [:new, :create, :edit, :update] before_filter :require_user, only: [:new, :create, :edit, :update, :destroy]
respond_to :html, :js, :json respond_to :html, :js, :json
@ -54,6 +54,20 @@ class SynapsesController < ApplicationController
end end
end end
# GET synapses/:id/json
def json
@current = current_user
@synapse = Synapse.find(params[:id]).authorize_to_show(@current)
if not @synapse
redirect_to root_url and return
end
respond_to do |format|
format.json { render :json => @synapse.selfplusnodes_as_json }
end
end
# POST synapses # POST synapses
def create def create
@ -69,12 +83,18 @@ class SynapsesController < ApplicationController
@synapse.save @synapse.save
if params[:synapse][:map] if params[:synapse][:map]
@mapping = Mapping.new() @map = Map.find(params[:synapse][:map])
@mapping = Mapping.new()
@mapping.category = "Synapse" @mapping.category = "Synapse"
@mapping.user = @user @mapping.user = @user
@mapping.map = Map.find(params[:synapse][:map]) @mapping.map = @map
@mapping.synapse = @synapse @mapping.synapse = @synapse
@mapping.save @mapping.save
# set the permission of the synapse to whatever the permission of the map is
@synapse.permission = @map.permission
@synapse.save
end end
respond_to do |format| respond_to do |format|

View file

@ -1,5 +1,5 @@
class TopicsController < ApplicationController class TopicsController < ApplicationController
before_filter :require_user, only: [:new, :create, :edit, :update] before_filter :require_user, only: [:new, :create, :edit, :update, :destroy]
respond_to :html, :js, :json respond_to :html, :js, :json
@ -45,6 +45,20 @@ class TopicsController < ApplicationController
format.json { respond_with(@relatives) } format.json { respond_with(@relatives) }
end end
end end
# GET topics/:id/json
def json
@current = current_user
@topic = Topic.find(params[:id]).authorize_to_show(@current)
if not @topic
redirect_to root_url and return
end
respond_to do |format|
format.json { render :json => @topic.self_as_json }
end
end
# POST topics # POST topics
def create def create
@ -63,6 +77,12 @@ class TopicsController < ApplicationController
@topic.permission = 'commons' @topic.permission = 'commons'
@topic.metacode = Metacode.find_by_name(params[:topic][:metacode]) @topic.metacode = Metacode.find_by_name(params[:topic][:metacode])
@topic.user = @user @topic.user = @user
#if being created on a map, set topic by default to whatever permissions the map is
if params[:topic][:map]
@map = Map.find(params[:topic][:map])
@topic.permission = @map.permission
end
@topic.save @topic.save
end end
@ -81,9 +101,11 @@ class TopicsController < ApplicationController
# set this for the case where the topic is being created on a map. # set this for the case where the topic is being created on a map.
@mapping = Mapping.new() @mapping = Mapping.new()
if params[:topic][:map] if params[:topic][:map]
@map = Map.find(params[:topic][:map])
@mapping.category = "Topic" @mapping.category = "Topic"
@mapping.user = @user @mapping.user = @user
@mapping.map = Map.find(params[:topic][:map]) @mapping.map = @map
@mapping.topic = @topic @mapping.topic = @topic
@mapping.xloc = params[:topic][:x] @mapping.xloc = params[:topic][:x]
@mapping.yloc = params[:topic][:y] @mapping.yloc = params[:topic][:y]
@ -116,18 +138,15 @@ class TopicsController < ApplicationController
if @topic if @topic
if params[:topic] if params[:topic]
@topic.name = params[:topic][:name] if params[:topic][:name] @topic.name = params[:topic][:name] if params[:topic][:name]
@topic.desc = params[:topic][:desc] if params[:topic][:desc] @topic.desc = params[:topic][:desc] if params[:topic][:desc]
@topic.link = params[:topic][:link] if params[:topic][:link] @topic.link = params[:topic][:link] if params[:topic][:link]
@topic.permission = params[:topic][:permission] if params[:topic][:permission] @topic.permission = params[:topic][:permission] if params[:topic][:permission]
@topic.metacode = Metacode.find_by_name(params[:topic][:metacode]) if params[:topic][:metacode] @topic.metacode = Metacode.find_by_name(params[:topic][:metacode]) if params[:topic][:metacode]
end end
@topic.save @topic.save
end end
respond_with @topic respond_with @topic
# respond_with(@user, location: topic_url(@topic)) do |format|
# end
end end
# GET mappings/:map_id/:topic_id/removefrommap # GET mappings/:map_id/:topic_id/removefrommap

View file

@ -21,12 +21,15 @@ class UsersController < ApplicationController
respond_with(@user) respond_with(@user)
end end
# GET /user # GET /user/:id
def show def show
@user = User.find(params[:id]) @user = User.find(params[:id])
@topics = @user.topics.order("created_at DESC").limit(3) @topics = Topic.visibleToUser(@current, @user).sort! { |a,b| b.created_at <=> a.created_at }
@synapses = @user.synapses.order("created_at DESC").limit(3) @topics = @topics.slice(0,3)
@maps = @user.maps.order("created_at DESC").limit(3) @synapses = Synapse.visibleToUser(@current, @user).sort! { |a,b| b.created_at <=> a.created_at }
@synapses = @synapses.slice(0,3)
@maps = Map.visibleToUser(@current, @user).sort! { |a,b| b.created_at <=> a.created_at }
@maps = @maps.slice(0,3)
respond_with(@user, @topics, @synapses, @maps) respond_with(@user, @topics, @synapses, @maps)
end end

View file

@ -11,6 +11,16 @@ has_many :synapses, :through => :synapsemappings
def mappings def mappings
topicmappings + synapsemappings topicmappings + synapsemappings
end end
def mk_permission
if self.permission == "commons"
"co"
elsif self.permission == "public"
"pu"
elsif self.permission == "private"
"pr"
end
end
###### JSON ###### ###### JSON ######

View file

@ -25,6 +25,16 @@ belongs_to :metacode
def topic_autocomplete_method def topic_autocomplete_method
"Get: #{self.name}" "Get: #{self.name}"
end end
def mk_permission
if self.permission == "commons"
"cc"
elsif self.permission == "public"
"pu"
elsif self.permission == "private"
"pr"
end
end
# has no viewable synapses helper function # has no viewable synapses helper function
def has_viewable_synapses(current) def has_viewable_synapses(current)

View file

@ -1,16 +1,30 @@
<%# <%#
# @file # @file
# Shows a map as a card. # Shows a map as a card.
# I believe this is rendered on the profile pages. # Any list of maps uses this rendering.
# TODO: Am I correct?
# TODO: Is it rendered on any other pages?
#%> #%>
<%= div_for map do %> <%= div_for map do %>
<% if map.authorize_to_edit(user) %>
<div class="permission canEdit">
<% end %>
<% if map.user == user %><%= link_to 'Delete', map_path(map), :class => 'delete', :confirm => 'Delete this map (nodes and synapses will remain)?', :method => :delete, :remote => true %><% end %> <% if map.user == user %><%= link_to 'Delete', map_path(map), :class => 'delete', :confirm => 'Delete this map (nodes and synapses will remain)?', :method => :delete, :remote => true %><% end %>
<p class="type">Map</p> <p class="type">Map</p>
<%= image_tag 'map.png', :class => 'icon', :size => '50x50' %> <%= image_tag 'map.png', :class => 'icon', :size => '50x50' %>
<div class="cardSettings">
<% if map.user == user %>
<div class="permActivator">
<div class="editSettings">
<span>Permissions:&nbsp;</span>
<span title="Click to Edit"><%= best_in_place map, :permission, :type => :select, :collection => [['commons', 'commons'], ['public','public'], ['private','private']] %></span>
<div class="clearfloat"></div>
</div>
</div>
<% end %>
<div class="mapPerm"><%= map.mk_permission %></div>
</div>
<span class="title"> <span class="title">
<span><%=map.name %></span> <span><%= best_in_place map, :name, :type => :input %></span>
<a href="/maps/<%=map.id %>" class="topic-go-arrow"> <a href="/maps/<%=map.id %>" class="topic-go-arrow">
<img class="topic-go-arrow" <img class="topic-go-arrow"
title="Go to map" title="Go to map"
@ -25,7 +39,11 @@
<div class="scroll"> <div class="scroll">
<div class="desc"> <div class="desc">
<p class="mapdata"><%= map.topics.count %> topics and <%= map.synapses.count %> synapses</p> <p class="mapdata"><%= map.topics.count %> topics and <%= map.synapses.count %> synapses</p>
<p><%= map.desc %></p> <p><%= best_in_place map, :desc, :type => :textarea, :nil => "<span class='gray'>Click to add description.</span>" %></p>
</div> </div>
</div> </div>
<% if map.authorize_to_edit(user) %>
</div>
<% end %>
<% end %> <% end %>

View file

@ -9,8 +9,9 @@
<%= form.text_field :name %> <%= form.text_field :name %>
<label for="map_desc">Description</label> <label for="map_desc">Description</label>
<%= form.text_area :desc, class: "description", :rows => 5 %> <%= form.text_area :desc, class: "description", :rows => 5 %>
<label for="map_permission">Permission</label> <label for="map_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<p>Topics and synapses you create newly on this map will be set by default to the permissions of your map.</p>
<%= form.hidden_field :topicsToMap, :value => 0 %> <%= form.hidden_field :topicsToMap, :value => 0 %>
<%= form.hidden_field :synapsesToMap, :value => 0 %> <%= form.hidden_field :synapsesToMap, :value => 0 %>
<%= form.submit "Save", class: "add" %> <%= form.submit "Save", class: "add" %>

View file

@ -1,8 +1,7 @@
<%# <%#
# @file # @file
# Form for editing a map # Form for editing a map
# TODO: I think this code is no longer in use. Is it? # Located at addresses /maps/:id/edit. In use.
# TODO: What URL is this accessible at?
#%> #%>
<%= form_for @map, url: map_url(@map) do |form| %> <%= form_for @map, url: map_url(@map) do |form| %>
<h3>Edit Map</h3> <h3>Edit Map</h3>

View file

@ -1,8 +1,7 @@
<%# <%#
# @file # @file
# Form to create a new map. # Form to create a new map.
# TODO: What URL is this accessible from? # Accessible from /maps/new. Still in use.
# TODO: Is this code being used anymore?
#%> #%>
<div class="nothidden"> <div class="nothidden">
<%= form_for @map || Map.new, url: maps_url do |form|%> <%= form_for @map || Map.new, url: maps_url do |form|%>
@ -13,6 +12,7 @@
<%= form.text_area :desc, class: "description", :rows => 5 %> <%= form.text_area :desc, class: "description", :rows => 5 %>
<label for="map_permission">Permission</label> <label for="map_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<p>Topics and synapses you create newly on this map will be set by default to the permissions of your map.</p>
<%= form.submit "Add Map", class: "add" %> <%= form.submit "Add Map", class: "add" %>
<% end %> <% end %>
</div> </div>

View file

@ -5,6 +5,11 @@
#%> #%>
<%= div_for topic do %> <%= div_for topic do %>
<% if topic.authorize_to_edit(user) %>
<div class="permission canEdit">
<% end %>
<div class="CardOnGraph" <div class="CardOnGraph"
id="topic_<%=topic.id %>"> id="topic_<%=topic.id %>">
<% if topic.user == user %><%= link_to 'Delete', topic_path(topic), :class => 'delete', :confirm => 'Delete this topic and all synapses linking to it?', :method => :delete, :remote => true%><% end %> <% if topic.user == user %><%= link_to 'Delete', topic_path(topic), :class => 'delete', :confirm => 'Delete this topic and all synapses linking to it?', :method => :delete, :remote => true%><% end %>
@ -59,4 +64,8 @@
<div class="clearfloat"></div> <div class="clearfloat"></div>
</div> </div>
<% if topic.authorize_to_edit(user) %>
</div>
<% end %>
<% end %> <% end %>

View file

@ -0,0 +1,21 @@
development:
min_messages: WARNING
adapter: postgresql
host: 127.0.0.1
port: 5432
encoding: unicode
database: metamap002_development
pool: 5
username: postgres
password: "3112"
production:
min_messages: WARNING
adapter: postgresql
host: ec2-107-21-107-194.compute-1.amazonaws.com
port: 5432
encoding: unicode
database: ddcrn2lgphjk9k
pool: 5
username: qqpckkahytovwv
password: "njeP6cMA8EjM9ukHk9s3ReOdy7"

View file

@ -18,14 +18,17 @@ ISSAD::Application.routes.draw do
resources :topics do resources :topics do
get :autocomplete_topic_name, :on => :collection get :autocomplete_topic_name, :on => :collection
end end
match 'topics/:id/:format', to: 'topics#json', via: :get, as: :json
resources :synapses do resources :synapses do
get :autocomplete_synapse_desc, :on => :collection get :autocomplete_synapse_desc, :on => :collection
end end
match 'synapses/:id/:format', to: 'synapses#json', via: :get, as: :json
resources :maps do resources :maps do
get :autocomplete_map_name, :on => :collection get :autocomplete_map_name, :on => :collection
end end
match 'maps/:id/:format', to: 'maps#json', via: :get, as: :json
resources :users do resources :users do
get :autocomplete_user_name, :on => :collection get :autocomplete_user_name, :on => :collection