diff --git a/app/assets/javascripts/metamaps/Metamaps.Backbone.js b/app/assets/javascripts/metamaps/Metamaps.Backbone.js
index d73623de..f322ef9f 100644
--- a/app/assets/javascripts/metamaps/Metamaps.Backbone.js
+++ b/app/assets/javascripts/metamaps/Metamaps.Backbone.js
@@ -1,7 +1,7 @@
Metamaps.Backbone = {};
Metamaps.Backbone.Map = Backbone.Model.extend({
urlRoot: '/maps',
- blacklist: ['created_at', 'updated_at', 'topics', 'synapses', 'mappings', 'mappers'],
+ blacklist: ['created_at', 'updated_at', 'user_name', 'topic_count', 'synapse_count', 'topics', 'synapses', 'mappings', 'mappers'],
toJSON: function (options) {
return _.omit(this.attributes, this.blacklist);
},
@@ -14,15 +14,16 @@ Metamaps.Backbone.Map = Backbone.Model.extend({
},
fetchContained: function () {
var bb = Metamaps.Backbone;
+ var that = this;
var start = function (data) {
- this.set('mappers', new bb.MapperCollection(data.mappers));
- this.set('topics', new bb.TopicCollection(data.topics));
- this.set('synapses', new bb.SynapseCollection(data.synapses));
- this.set('mappings', new bb.MappingCollection(data.mappings));
+ that.set('mappers', new bb.MapperCollection(data.mappers));
+ that.set('topics', new bb.TopicCollection(data.topics));
+ that.set('synapses', new bb.SynapseCollection(data.synapses));
+ that.set('mappings', new bb.MappingCollection(data.mappings));
}
$.ajax({
- url: "/maps/" + this.id + "/contains",
+ url: "/maps/" + this.id + "/contains.json",
success: start,
async: false
});
@@ -56,11 +57,11 @@ Metamaps.Backbone.Map = Backbone.Model.extend({
id: this.id,
name: this.get('name'),
desc: this.get('desc'),
- username: this.getUser().get('name'),
- mkPermission: this.get("permission") ? this.get("permission").substring(0, 2) : "commons",
+ username: this.get('user_name'),
+ mkPermission: this.get("permission") ? this.get("permission").substring(0, 2) : "co",
editPermission: this.authorizeToEdit(Metamaps.Active.Mapper) ? 'canEdit' : 'cannotEdit',
- topicCount: this.getTopics().length,
- synapseCount: this.getSynapses().length,
+ topicCount: this.get('topic_count'),
+ synapseCount: this.get('synapse_count'),
createdAt: this.get('created_at')
};
return obj;
@@ -78,16 +79,21 @@ Metamaps.Backbone.MapsCollection = Backbone.Collection.extend({
comparator: function (a, b) {
a = a.get(this.sortBy);
b = b.get(this.sortBy);
+ var temp;
if (this.sortBy === 'name') {
a = a ? a.toLowerCase() : "";
b = b ? b.toLowerCase() : "";
}
+ else {
+ // this is for updated_at and created_at
+ temp = a;
+ a = b;
+ b = temp;
+ }
return a > b ? 1 : a < b ? -1 : 0;
},
getMaps: function () {
- Metamaps.Loading.loader.show();
-
var self = this;
this.fetch({
diff --git a/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js b/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js
index 4ecec60b..dccd5b29 100644
--- a/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js
+++ b/app/assets/javascripts/metamaps/Metamaps.GlobalUI.js
@@ -75,10 +75,6 @@ Metamaps.GlobalUI = {
});
$('#lightbox_screen, #lightbox_close').click(self.closeLightbox);
-
- // hide notices after 10 seconds
- $('.notice.metamaps').delay(10000).fadeOut('fast');
- $('.alert.metamaps').delay(10000).fadeOut('fast');
// initialize global backbone models and collections
if (Metamaps.Active.Mapper) Metamaps.Active.Mapper = new Metamaps.Backbone.Mapper(Metamaps.Active.Mapper);
diff --git a/app/assets/javascripts/metamaps/Metamaps.Router.js b/app/assets/javascripts/metamaps/Metamaps.Router.js
index 43c2482b..3702400c 100644
--- a/app/assets/javascripts/metamaps/Metamaps.Router.js
+++ b/app/assets/javascripts/metamaps/Metamaps.Router.js
@@ -52,15 +52,14 @@
Metamaps.GlobalUI.Search.close(0, true);
$('.mapsWrapper').fadeOut(300);
+ setTimeout(function(){
+ Metamaps.Router.navigate("");
+ }, 500);
}
Metamaps.Famous.viz.hide();
Metamaps.Active.Map = null;
Metamaps.Active.Topic = null;
-
- setTimeout(function(){
- Metamaps.Router.navigate("");
- }, 500);
},
explore: function (section) {
@@ -76,7 +75,10 @@
Metamaps.Views.exploreMaps.setCollection( Metamaps.Maps[capitalize] );
if (Metamaps.Maps[capitalize].length === 0) {
- Metamaps.Maps[capitalize].getMaps(); // this will trigger an explore maps render
+ Metamaps.Loading.loader.show();
+ setTimeout(function(){
+ Metamaps.Maps[capitalize].getMaps(); // this will trigger an explore maps render
+ }, 1000); // wait 500 milliseconds till the other animations are done to do the fetch
}
else {
Metamaps.Views.exploreMaps.render();
@@ -95,10 +97,6 @@
Metamaps.Famous.viz.hide();
Metamaps.Active.Map = null;
Metamaps.Active.Topic = null;
-
- setTimeout(function(){
- Metamaps.Router.navigate("/explore/" + section);
- }, 500);
},
maps: function (id) {
diff --git a/app/assets/javascripts/metamaps/Metamaps.Views.js b/app/assets/javascripts/metamaps/Metamaps.Views.js
index fc4da130..4dbcc251 100644
--- a/app/assets/javascripts/metamaps/Metamaps.Views.js
+++ b/app/assets/javascripts/metamaps/Metamaps.Views.js
@@ -47,8 +47,6 @@ Metamaps.Views.init = function () {
},
render: function () {
- Metamaps.Loading.loader.hide();
-
var that = this;
this.$el.empty();
@@ -57,12 +55,18 @@ Metamaps.Views.init = function () {
that.$el.append( view.render().el );
});
+
+ Metamaps.Loading.loader.hide();
+ setTimeout(function(){
+ var path = Metamaps.currentSection == "" ? "" : "/explore/" + Metamaps.currentPage;
+ Metamaps.Router.navigate(path);
+ }, 500);
},
handleSuccess: function () {
this.render();
},
handleError: function () {
- alert('error!');
+ console.log('error loading maps!'); //TODO
}
});
diff --git a/app/assets/javascripts/metamaps/Metamaps.js b/app/assets/javascripts/metamaps/Metamaps.js
index 73ea1044..64bc4991 100644
--- a/app/assets/javascripts/metamaps/Metamaps.js
+++ b/app/assets/javascripts/metamaps/Metamaps.js
@@ -126,9 +126,6 @@ Metamaps.Backbone.init = function () {
},
getDate: function () {
- },
- getUser: function () {
- return Metamaps.Mapper.get(this.get('user_id'));
},
getMetacode: function () {
return Metamaps.Metacodes.get(this.get('metacode_id'));
@@ -212,9 +209,6 @@ Metamaps.Backbone.init = function () {
if (mapper && this.get('user_id') === mapper.get('id')) return true;
else return false;
},
- getUser: function () {
- return Metamaps.Mapper.get(this.get('user_id'));
- },
getTopic1: function () {
return Metamaps.Topic.get(this.get('node1_id'));
},
@@ -291,9 +285,6 @@ Metamaps.Backbone.init = function () {
});
}
},
- getUser: function () {
- return Metamaps.Mapper.get(this.get('user_id'));
- },
getMap: function () {
return Metamaps.Map.get(this.get('map_id'));
},
@@ -924,7 +915,7 @@ Metamaps.TopicCard = {
nodeValues.imgsrc = topic.getMetacode().get("icon");
nodeValues.name = topic.get("name");
nodeValues.userid = topic.get("user_id");
- nodeValues.username = topic.getUser().get("name");
+ nodeValues.username = topic.get("user_name");
nodeValues.date = topic.getDate();
// the code for this is stored in /views/main/_metacodeOptions.html.erb
nodeValues.metacode_select = $('#metacodeOptions').html();
@@ -1036,7 +1027,7 @@ Metamaps.SynapseCard = {
add_user_info: function (synapse) {
var u = '
';
- u += '
Created by ' + synapse.getUser().get("name") + '
';
+ u += 'Created by ' + synapse.get("user_name") + '
';
$('#edit_synapse').append(u);
},
@@ -1399,7 +1390,7 @@ Metamaps.Realtime = {
var mapperm = Metamaps.Active.Map && Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper);
if (mapperm) {
- self.socket = io.connect('http://localhost:5001');
+ self.socket = io.connect('http://gentle-savannah-1303.herokuapp.com');
self.socket.on('connect', function () {
console.log('socket connected');
self.setupSocket();
@@ -2183,7 +2174,7 @@ Metamaps.Filter = {
},
checkMappers: function () {
var self = Metamaps.Filter;
- self.updateFilters('both', 'user_id', 'Mapper', 'mappers', 'mapper');
+ self.updateFilters('both', 'user_id', 'Mappers', 'mappers', 'mapper');
},
checkSynapses: function () {
var self = Metamaps.Filter;
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index 148c20c2..6a8411ce 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -201,15 +201,10 @@ input[type="submit"]:hover {
.forgotPassword {
display: block;
width: 250px;
- position: absolute;
- left: 50%;
- top: 0;
- margin: 100px 0 0 -145px;
- background: url(bg.png);
+ background-color: #E0E0E0;
padding: 20px;
border-radius: 5px;
color: black;
- border: 1px solid #000;
box-shadow: 6px 6px 8px rgba(0, 0, 0, 0.4);
}
.centerGreyForm input[type="text"],
diff --git a/app/assets/stylesheets/base.css b/app/assets/stylesheets/base.css
index 39dca589..37414fce 100644
--- a/app/assets/stylesheets/base.css
+++ b/app/assets/stylesheets/base.css
@@ -363,7 +363,7 @@ float:left;
}
.addLink div {
- display: inline-block;
+ float: left;
}
#addLinkBack {
@@ -383,7 +383,7 @@ padding: 7px 31px 7px 31px;
height: 16px;
width: 172px;
margin: 0 0 0 0;
-border: 1px solid #EFEFEF;
+border: 1px solid #BDBDBD;
outline: none;
font-size: 16px;
line-height: 16px;
@@ -399,6 +399,7 @@ font-family: 'LatoLight';
width: 32px;
height: 32px;
cursor: pointer;
+ float:none;
}
.cardSettings {
diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb
index eac994fa..fe7de0fe 100644
--- a/app/controllers/main_controller.rb
+++ b/app/controllers/main_controller.rb
@@ -9,17 +9,9 @@ class MainController < ApplicationController
# home page
def home
@current = current_user
-
- if !authenticated?
- @maps = Map.find_all_by_featured(true).shuffle!
- @maps = @maps.slice(0,3)
- elsif authenticated?
- #@maps = Map.order("updated_at DESC").where("permission != ?", "private").limit(3)
- @maps = Map.order("name ASC").find_all_by_user_id(@current.id)
- end
respond_to do |format|
- format.html { respond_with(@maps, @current) }
+ format.html { respond_with(@current) }
end
end
diff --git a/app/models/map.rb b/app/models/map.rb
index abac522f..cc86b6d3 100644
--- a/app/models/map.rb
+++ b/app/models/map.rb
@@ -32,6 +32,26 @@ end
return contributors
end
+
+ def topic_count
+ self.topics.length
+ end
+
+ def synapse_count
+ self.synapses.length
+ end
+
+ def user_name
+ self.user.name
+ end
+
+ def user_image
+ self.user.image.url
+ end
+
+ def as_json(options={})
+ super(:methods =>[:user_name, :user_image, :topic_count, :synapse_count])
+ end
##### PERMISSIONS ######
diff --git a/app/models/mapping.rb b/app/models/mapping.rb
index ada72cf9..0de78e09 100644
--- a/app/models/mapping.rb
+++ b/app/models/mapping.rb
@@ -5,6 +5,18 @@ belongs_to :synapse, :class_name => "Synapse", :foreign_key => "synapse_id"
belongs_to :map, :class_name => "Map", :foreign_key => "map_id"
belongs_to :user
+
+ def user_name
+ self.user.name
+ end
+
+ def user_image
+ self.user.image.url
+ end
+
+ def as_json(options={})
+ super(:methods =>[:user_name, :user_image])
+ end
# sends push updates through redis to websockets for realtime updates
def message action, origin_user_id
diff --git a/app/models/synapse.rb b/app/models/synapse.rb
index 1415997e..f7dc58c6 100644
--- a/app/models/synapse.rb
+++ b/app/models/synapse.rb
@@ -8,6 +8,18 @@ belongs_to :topic2, :class_name => "Topic", :foreign_key => "node2_id"
has_many :mappings
has_many :maps, :through => :mappings
+ def user_name
+ self.user.name
+ end
+
+ def user_image
+ self.user.image.url
+ end
+
+ def as_json(options={})
+ super(:methods =>[:user_name, :user_image])
+ end
+
# sends push updates through redis to websockets for realtime updates
def message action, origin_user_id
diff --git a/app/models/topic.rb b/app/models/topic.rb
index 668c94fe..79183195 100644
--- a/app/models/topic.rb
+++ b/app/models/topic.rb
@@ -37,7 +37,19 @@ has_many :maps, :through => :mappings
topics1 + topics2
end
-belongs_to :metacode
+ belongs_to :metacode
+
+ def user_name
+ self.user.name
+ end
+
+ def user_image
+ self.user.image.url
+ end
+
+ def as_json(options={})
+ super(:methods =>[:user_name, :user_image])
+ end
# sends push updates through redis to websockets for realtime updates
def message action, origin_user_id
diff --git a/app/models/user.rb b/app/models/user.rb
index b5921fa2..bf2ddd9a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -38,6 +38,14 @@ has_many :mappings
trans << '( +clone -flop ) -compose multiply -composite '
trans << ') -alpha off -compose copy_opacity -composite '
end
+
+ def as_json(options={})
+ { :id => self.id,
+ :name => self.name,
+ :email => self.email,
+ :image => self.image.url
+ }
+ end
if ActiveRecord::Base.connection.table_exists? 'users'
codes = ActiveRecord::Base.connection.execute("SELECT code FROM users").map {|user| user["code"] }
diff --git a/app/views/layouts/_account.html.erb b/app/views/layouts/_account.html.erb
index d4912682..c44f0a78 100644
--- a/app/views/layouts/_account.html.erb
+++ b/app/views/layouts/_account.html.erb
@@ -5,7 +5,7 @@
<% if authenticated? %>
<% account = current_user %>
-
+
- <%= link_to "Account", edit_user_url(account),
:data => { :bypass => 'true'} %>
@@ -38,8 +38,9 @@
<% end %>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
- <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+ <%= link_to "Forgot your password?", new_password_path(resource_name),
+ :data => { :bypass => 'true'} %>
<% end -%>
-
Request Invite
+
Request Invite
<% end %>
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb
index 3f4fe420..738d5c62 100644
--- a/app/views/users/edit.html.erb
+++ b/app/views/users/edit.html.erb
@@ -4,7 +4,8 @@
# User edit form
#%>
-<% content_for :title, @user.name + "'s Settings | Metamaps" %>
+<% content_for :title, @user.name + "'s Settings | Metamaps" %>
+
<%= formula_form_for @user, url: user_url do |form| %>
Edit Account
@@ -15,4 +16,5 @@
<%= form.input :password, label: "Password", class: "password", :autocomplete => :off %>
<%= form.submit "Update", class: "update" %>
<% end %>
+
diff --git a/app/views/users/passwords/edit.html.erb b/app/views/users/passwords/edit.html.erb
index a62d33f4..2cec4812 100644
--- a/app/views/users/passwords/edit.html.erb
+++ b/app/views/users/passwords/edit.html.erb
@@ -1,7 +1,6 @@
<% content_for :title, "Change Password | Metamaps" %>
-Change Password
-
+
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put, :class => "forgotPassword centerGreyForm" }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
@@ -17,5 +16,5 @@
<%= f.submit "Change my password" %>
<% end %>
-
+
diff --git a/app/views/users/passwords/new.html.erb b/app/views/users/passwords/new.html.erb
index 2fa7b099..bdd7a8bc 100644
--- a/app/views/users/passwords/new.html.erb
+++ b/app/views/users/passwords/new.html.erb
@@ -1,7 +1,6 @@
<% content_for :title, "Password Reset | Metamaps" %>
-Password Reset
-
+
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post, :class => "forgotPassword centerGreyForm" }) do |f| %>
<%= devise_error_messages! %>
@@ -13,5 +12,6 @@
<%= f.submit "Send me reset password instructions" %>
<% end %>
+
diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb
index ec61da36..e7c08256 100644
--- a/app/views/users/registrations/new.html.erb
+++ b/app/views/users/registrations/new.html.erb
@@ -1,7 +1,6 @@
<% content_for :title, "Sign Up | Metamaps" %>
-Sign Up
-
+
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :post, :class => "new_user centerGreyForm" }) do |f| %>
<%= devise_error_messages! %>
@@ -24,7 +23,7 @@
<%= f.submit "Sign up" %>
-
+
<% end %>
-
+
diff --git a/app/views/users/sessions/new.html.erb b/app/views/users/sessions/new.html.erb
index ef9866f5..6f55203b 100644
--- a/app/views/users/sessions/new.html.erb
+++ b/app/views/users/sessions/new.html.erb
@@ -1,7 +1,6 @@
<% content_for :title, "Sign In | Metamaps" %>
-Sign In
-
+
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :method => :post, :class => "new_user centerGreyForm" }) do |f| %>
Sign in
@@ -19,10 +18,11 @@
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
- <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+ <%= link_to "Forgot your password?", new_password_path(resource_name),
+ :data => { :bypass => 'true'} %>
<% end -%>
-
+
<% end %>
-
+
diff --git a/public/famous/main.js b/public/famous/main.js
index 3a8c0f91..beaf6bca 100644
--- a/public/famous/main.js
+++ b/public/famous/main.js
@@ -100,10 +100,12 @@ define(function(require, exports, module) {
f.loadYield = function () {
Metamaps.Loading.loader.hide();
- var yield = document.getElementById('yield').innerHTML;
- f.yield.surf.setContent(yield);
- f.yield.surf.deploy(f.yield.surf._currTarget);
- f.yield.show();
+ var yield = document.getElementById('yield') ? document.getElementById('yield').innerHTML : false;
+ if (yield) {
+ f.yield.surf.setContent(yield);
+ f.yield.surf.deploy(f.yield.surf._currTarget);
+ f.yield.show();
+ }
};