merged conflicts coming from develop branch

This commit is contained in:
Connor Turland 2014-10-22 11:52:31 -04:00
commit 13937ae51d
10 changed files with 327 additions and 130 deletions

View file

@ -72,6 +72,9 @@ now there is a couple other things we are going to need which is phantomjs, node
sudo apt-get install redis-server
Furthermore, if you want to be able to work on profile picture uploading, or use it
you'll need ImageMagick. On Ubuntu, you can just go find ImageMagick in the Ubuntu Software Centre
Install the specific version of ruby needed this will take some time
rvm install ruby-2.1.3
@ -110,12 +113,19 @@ Execute the server:
rails s
and dont forget to run realtime too open a new terminal
and dont forget to run the two other servers, for sidekiq, and realtime...
open a new terminal
navigate to ./realtime and run
sudo apt-get install npm
npm install
nodejs realtime-server.js
open a new terminal
navigate to the main directory and run
sidekiq
Now you're all set enjoy your personal server of metamaps :)
Navigate your browser to localhost:3000 once you have the server running

View file

@ -2481,6 +2481,7 @@ Extras.Classes.Navigation = new Class({
},
onMouseDown: function(e, win, eventInfo) {
///console.log('mouse down!!!!');
if(!this.config.panning) return;
//START METAMAPS CODE
@ -2495,8 +2496,9 @@ Extras.Classes.Navigation = new Class({
//START METAMAPS CODE
var rightClick = e.button == 2 || (navigator.platform.indexOf("Mac") != -1 && e.ctrlKey);
// TODO make sure this works across browsers
if (!Metamaps.Mouse.boxStartCoordinates && (e.shiftKey || rightClick)) {
if (!Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || (rightClick && e.ctrlKey))) {
Metamaps.Mouse.boxStartCoordinates = eventInfo.getPos();
//console.log('mouse down');
}
Metamaps.Mouse.didPan = false;
@ -2524,14 +2526,19 @@ Extras.Classes.Navigation = new Class({
// START METAMAPS CODE
var rightClick = e.button == 2 || (navigator.platform.indexOf("Mac") != -1 && e.ctrlKey);
if (!Metamaps.Mouse.boxStartCoordinates && (e.shiftKey || rightClick)) {
if (!Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || (rightClick && e.ctrlKey))) {
Metamaps.Visualize.mGraph.busy = true;
Metamaps.boxStartCoordinates = eventInfo.getPos();
//console.log('mouse move');
return;
}
if (Metamaps.Mouse.boxStartCoordinates && (e.shiftKey || rightClick)) {
if (Metamaps.Mouse.boxStartCoordinates && ((e.button == 0 && e.shiftKey) || (e.button == 0 && e.ctrlKey) || (rightClick && e.ctrlKey))) {
Metamaps.Visualize.mGraph.busy = true;
Metamaps.JIT.drawSelectBox(eventInfo,e);
//console.log('mouse move');
return;
}
if (rightClick){
return;
}
if (e.target.id != 'infovis-canvas') {

View file

@ -301,13 +301,16 @@ Metamaps.JIT = {
enableForEdges: true,
onMouseMove: function (node, eventInfo, e) {
Metamaps.JIT.onMouseMoveHandler(node, eventInfo, e);
//console.log('called mouse move handler');
},
//Update node positions when dragged
onDragMove: function (node, eventInfo, e) {
Metamaps.JIT.onDragMoveTopicHandler(node, eventInfo, e);
//console.log('called drag move handler');
},
onDragEnd: function (node, eventInfo, e) {
Metamaps.JIT.onDragEndTopicHandler(node, eventInfo, e, false);
//console.log('called drag end handler');
},
onDragCancel: function (node, eventInfo, e) {
Metamaps.JIT.onDragCancelHandler(node, eventInfo, e, false);
@ -352,21 +355,34 @@ Metamaps.JIT = {
$('.rightclickmenu').remove();
if (Metamaps.Mouse.boxStartCoordinates) {
if(e.ctrlKey && e.shiftKey){
Metamaps.Visualize.mGraph.busy = false;
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
Metamaps.JIT.zoomToBox(e);
//console.log('called zoom to box');
return;
}
else if (e.ctrlKey || e.shiftKey) {
Metamaps.Visualize.mGraph.busy = false;
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
Metamaps.JIT.selectWithBox(e);
//console.log('called select with box');
return;
};
}
if (e.target.id != "infovis-canvas") return false;
//clicking on a edge, node, or clicking on blank part of canvas?
if (node.nodeFrom) {
Metamaps.JIT.selectEdgeOnClickHandler(node, e);
//console.log('called selectEdgeOnClickHandler');
} else if (node && !node.nodeFrom) {
Metamaps.JIT.selectNodeOnClickHandler(node, e);
//console.log('called selectNodeOnClickHandler');
} else {
Metamaps.JIT.canvasClickHandler(eventInfo.getPos(), e);
//console.log('called canvasClickHandler');
} //if
},
//Add also a click handler to nodes
@ -375,10 +391,10 @@ Metamaps.JIT = {
// remove the rightclickmenu
$('.rightclickmenu').remove();
if (Metamaps.Mouse.boxStartCoordinates) {
if (Metamaps.Mouse.boxStartCoordinates && e.ctrlKey) {
Metamaps.Visualize.mGraph.busy = false;
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
Metamaps.JIT.selectWithBox(e);
Metamaps.JIT.zoomToBox(e);
return;
}
@ -390,8 +406,8 @@ Metamaps.JIT = {
} else if (node && !node.nodeFrom) {
Metamaps.JIT.selectNodeOnRightClickHandler(node, e);
} else {
console.log('right clicked on open space');
} //if
//console.log('right clicked on open space');
}
}
},
//Number of iterations for the FD algorithm
@ -736,7 +752,7 @@ Metamaps.JIT = {
if (node && !node.nodeFrom) {
var pos = eventInfo.getPos();
// if it's a left click, or a touch, move the node
if (e.touches || (e.button == 0 && !e.altKey && (e.buttons == 0 || e.buttons == 1 || e.buttons == undefined))) {
if (e.touches || (e.button == 0 && !e.altKey && !e.ctrlKey && !e.shiftKey && (e.buttons == 0 || e.buttons == 1 || e.buttons == undefined))) {
//if the node dragged isn't already selected, select it
var whatToDo = self.handleSelectionBeforeDragging(node, e);
if (node.pos.rho || node.pos.rho === 0) {
@ -949,9 +965,11 @@ Metamaps.JIT = {
tempInit = false;
tempNode = null;
tempNode2 = null;
if (!e.ctrlKey && !e.shiftKey) {
Metamaps.Control.deselectAllEdges();
Metamaps.Control.deselectAllNodes();
}
}
}, //canvasClickHandler
nodeDoubleClickHandler: function (node, e) {
@ -1181,17 +1199,18 @@ Metamaps.JIT = {
if (!e.shiftKey && !e.ctrlKey) {
Metamaps.Control.deselectAllNodes();
Metamaps.Control.deselectAllEdges();
Metamaps.Control.selectNode(node,e);
}
if(e.ctrlKey || e.shiftKey){
else if(e.shiftKey && e.ctrlKey){
//no result
}
else if(e.ctrlKey){
if (node.selected) {
Metamaps.Control.deselectNode(node);
} else {
Metamaps.Control.selectNode(node,e);
}
}
else{
Metamaps.Control.deselectAllNodes();
Metamaps.Control.deselectAllEdges();
}else if(e.shiftKey){
Metamaps.Control.selectNode(node,e);
}
@ -1352,15 +1371,24 @@ Metamaps.JIT = {
// wait a certain length of time, then check again, then run this code
setTimeout(function () {
if (!Metamaps.JIT.nodeWasDoubleClicked()) {
if (!e.shiftKey) {
if (!e.shiftKey && !e.ctrlKey) {
Metamaps.Control.deselectAllNodes();
Metamaps.Control.deselectAllEdges();
}
else if (e.shiftKey && e.ctrlKey){
//no result
}
else if (e.ctrlKey){
if (Metamaps.Selected.Edges.indexOf(adj) !== -1) {
Metamaps.Control.deselectEdge(adj);
} else {
Metamaps.Control.selectEdge(adj);
}
}
else if (e.shiftKey){
Metamaps.Control.selectEdge(adj);
}
Metamaps.Visualize.mGraph.plot();
}
}, Metamaps.Mouse.DOUBLE_CLICK_TOLERANCE);

View file

@ -3963,10 +3963,61 @@ Metamaps.Map.InfoBox = {
*
*/
Metamaps.Account = {
listenersInitialized: false,
init: function () {
var self = Metamaps.Account;
},
initListeners: function(){
var self = Metamaps.Account;
$('#user_image').change(self.showImagePreview);
self.listenersInitialized = true;
},
toggleChangePicture: function(){
var self = Metamaps.Account;
$('.userImageMenu').toggle();
if (!self.listenersInitialized) self.initListeners();
},
openChangePicture: function(){
var self = Metamaps.Account;
$('.userImageMenu').show();
if (!self.listenersInitialized) self.initListeners();
},
closeChangePicture: function(){
var self = Metamaps.Account;
$('.userImageMenu').hide();
},
showImagePreview: function(){
var self = Metamaps.Account;
var file = $('#user_image')[0].files[0];
var reader = new FileReader();
reader.onload = function(e) {
$('.userImageDiv img').attr('src', reader.result);
};
if (file) {
reader.readAsDataURL(file);
$('.userImageMenu').hide();
$('#remove_image').val('0');
}
},
removePicture: function(){
var self = Metamaps.Account;
$('.userImage img').attr('src', '/assets/user.png');
$('.userImageMenu').hide();
var input = $('#user_image');
input.replaceWith(input.val('').clone(true));
$('#remove_image').val('1');
},
changeName: function(){
$('.accountName').hide();

View file

@ -76,73 +76,6 @@ body,
.wrapper.mapPage {
overflow: hidden;
}
/* scrollbar override */
.mCS_no_scrollbar {
padding-right: 0px !important;
}
.mCSB_container {
margin-right: 15px !important;
}
/* forgot password fix */
.forgotPassword input[type="submit"] {
width: 300px;
color: #f5f5f5;
font-family: din-regular;
top: 118px;
position: absolute;
}
.new_user input[type="submit"] {
width: 96px;
padding: 0px;
font-family: din-regular;
text-transform: uppercase;
color: #f5f5f5;
margin-top:16px;
float: right;
}
.login input[type="submit"]{
width:84px;
margin-top: 16px;
font-family: din-regular;
text-transform: uppercase;
}
.edit_user input[type="submit"]{
width: 96px;
padding: 0px;
font-family: din-regular;
text-transform: uppercase;
color: #f5f5f5;
margin-top:16px;
float: right;
}
.edit_user .userImage {
width: 84px;
margin: 0 auto;
position: relative;
margin-top: 32px;
}
.edit_user .userImage img {
border-radius: 42px;
}
.edit_user .editPhoto {
display: none;
width: 40px;
height: 40px;
background-image: url(photo.png);
position: absolute;
top: 22px;
left: 22px;
cursor: pointer;
}
.edit_user .userImage:hover .editPhoto {
display: block;
}
html {
@ -310,6 +243,127 @@ input[type="submit"]:active {
line-height: 18px;
}
/* forgot password fix */
.forgotPassword input[type="submit"] {
width: 300px;
color: #f5f5f5;
font-family: din-regular;
top: 118px;
position: absolute;
}
.new_user input[type="submit"] {
width: 96px;
padding: 0px;
font-family: din-regular;
text-transform: uppercase;
color: #f5f5f5;
margin-top:16px;
float: right;
}
.login input[type="submit"]{
width:84px;
margin-top: 16px;
font-family: din-regular;
text-transform: uppercase;
}
.edit_user input[type="submit"]{
width: 96px;
padding: 0px;
font-family: din-regular;
text-transform: uppercase;
color: #f5f5f5;
margin-top:16px;
float: right;
}
.edit_user .userImage {
width: 84px;
margin: 0 auto;
position: relative;
margin-top: 32px;
cursor: pointer;
}
.edit_user .userImage img {
border-radius: 42px;
}
.edit_user .editPhoto {
display: none;
width: 40px;
height: 40px;
background-image: url(photo.png);
position: absolute;
top: 22px;
left: 22px;
}
.edit_user .userImageDiv:hover .editPhoto {
display: block;
}
.userImageMenu {
position: absolute;
top: 88px;
left: -18px;
display: none;
}
.userMenuArrow {
border-color: transparent;
border-bottom-color: #202020;
border-style: dashed dashed solid;
border-width: 0 8px 8px;
display: block;
position: absolute;
left: 52px;
top: 0px;
z-index: 1;
height: 0;
width: 0;
}
.userImageMenu ul {
background: #202020;
list-style: none;
text-align: center;
font-size: 14px;
line-height: 14px;
color: #FFFFFF;
width: 120px;
border-radius: 2px;
position: absolute;
top: 8px;
overflow: hidden;
z-index: 1;
}
.userImageMenu li {
height:14px;
padding: 5px 0;
position: relative;
}
.userImageMenu li:hover {
background-color: #757575;
}
.edit_user #user_image {
width: 120px;
height: 24px;
position: absolute;
top: 0;
left: 0;
opacity: 0;
cursor: pointer;
}
.edit_user .upload label {
width: 120px;
height: 24px;
position: absolute;
top: 0;
left: 0;
opacity: 0;
cursor: pointer;
margin: 0;
padding: 0;
}
.edit_user label.firstFieldText {
padding-top: 8px;
}
@ -2676,3 +2730,11 @@ and it won't be important on password protected instances */
-webkit-transform-origin: left center;
transform-origin: left center;
}
.blockchain-btn {
display: inline;
float: right;
}
script.data-gratipay-username {
display: inline;
float: left;
}

View file

@ -26,8 +26,7 @@ private
def require_no_user
if authenticated?
flash[:warning] = "You must be logged out."
store and redirect_to edit_user_path(user)
redirect_to edit_user_path(user), notice: "You must be logged out."
return false
end
end
@ -38,7 +37,7 @@ private
path = request.env["PATH_INFO"]
unless path == "/" || path == new_user_registration_path || path == new_user_session_path
store_location_for(:user, path) and redirect_to root_url
store_location_for(:user, path) and redirect_to root_url, notice: "You must be logged in."
return false
end
end

View file

@ -19,13 +19,49 @@ class UsersController < ApplicationController
# PUT /users/:id
def update
@user = current_user
@user.attributes = params[:user]
if params[:user][:password] == "" && params[:user][:password_confirmation] == ""
# not trying to change the password
if @user.update_attributes(params[:user])
if params[:remove_image] == "1"
@user.image = nil
end
@user.save
sign_in(@user, :bypass => true)
respond_to do |format|
format.html { redirect_to root_url, notice: "Account updated!" }
end
else
sign_in(@user, :bypass => true)
respond_to do |format|
format.html { redirect_to edit_user_path(@user), notice: @user.errors.to_a[0] }
end
end
else
# trying to change the password
correct_pass = @user.valid_password?(params[:current_password])
respond_with(@user, location: session[:previous_url]) do |format|
if correct_pass && @user.update_attributes(params[:user])
if params[:remove_image] == "1"
@user.image = nil
end
@user.save
sign_in(@user, :bypass => true)
respond_to do |format|
format.html { redirect_to root_url, notice: "Account updated!" }
end
else
respond_to do |format|
if correct_pass
u = User.find(@user.id)
sign_in(u, :bypass => true)
format.html { redirect_to edit_user_path(@user), notice: @user.errors.to_a[0] }
else
sign_in(@user, :bypass => true)
format.html { redirect_to edit_user_path(@user), notice: "Incorrect current password" }
end
end
end
end
end

View file

@ -15,6 +15,16 @@ class User < ActiveRecord::Base
serialize :settings, UserPreference
validates :password, :presence => true,
:length => { :within => 8..40 },
:on => :create
validates :password, :length => { :within => 8..40 },
:allow_blank => true,
:on => :update
validates_confirmation_of :password
validates_presence_of :name # done by devise
validates_presence_of :email # done by devise
validates_uniqueness_of :name # done by devise
validates_uniqueness_of :email # done by devise

View file

@ -6,12 +6,28 @@
<% content_for :title, @user.name + "'s Settings | Metamaps" %>
<div id="yield">
<%= form_for @user, url: user_url, :html =>{ :class => "edit_user centerGreyForm"} do |form| %>
<%= form_for @user, url: user_url, :html =>{ :multipart => true, :class => "edit_user centerGreyForm"} do |form| %>
<h3>Edit Account</h3>
<div class="userImage">
<div class="userImageDiv" onclick="Metamaps.Account.toggleChangePicture()">
<%= image_tag @user.image.url(:round), :size => "84x84" %>
<div class="editPhoto"></div>
</div>
<div class="userImageMenu">
<div class="userMenuArrow"></div>
<ul>
<li class="upload">
Upload Photo
<%= hidden_field_tag "remove_image", "0" %>
<%= form.file_field :image %>
<%= form.label :image %>
</li>
<li class="remove" onclick="Metamaps.Account.removePicture()">Remove</li>
<li class="cancel" onclick="Metamaps.Account.closeChangePicture()">Cancel</li>
</ul>
</div>
</div>
<div class="accountName" onclick="Metamaps.Account.changeName()">
<div class="nameEdit"><%= @user.name %></div>
</div>

View file

@ -1,22 +0,0 @@
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install' ]
2 info using npm@1.4.28
3 info using node@v0.10.32
4 verbose node symlink /usr/bin/node
5 error install Couldn't read dependencies
6 error Failed to parse json
6 error Unexpected token }
7 error File: /home/sandra/metamaps_gen002/realtime/package.json
8 error Failed to parse package.json data.
8 error package.json must be actual JSON, not just JavaScript.
8 error
8 error This is not a bug in npm.
8 error Tell the package author to fix their package.json file. JSON.parse
9 error System Linux 3.13.0-36-generic
10 error command "/usr/bin/node" "/usr/bin/npm" "install"
11 error cwd /home/sandra/metamaps_gen002/realtime
12 error node -v v0.10.32
13 error npm -v 1.4.28
14 error file /home/sandra/metamaps_gen002/realtime/package.json
15 error code EJSONPARSE
16 verbose exit [ 1, true ]