From 9947a2abb87ecfa8aa5595bddde5535851a06ca5 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 12:26:43 -0700 Subject: [PATCH] RS, DG; latest_status thing now works, started putting signup back in --- app/controllers/application_controller.rb | 2 +- app/controllers/users_controller.rb | 16 +++++++++++ app/helpers/sockets_helper.rb | 1 + app/models/status_message.rb | 2 +- app/views/js/_websocket_js.haml | 1 + app/views/layouts/application.html.haml | 6 ++-- app/views/layouts/session_wall.html.haml | 16 ++++------- config/routes.rb | 13 ++++----- public/javascripts/publisher.js | 34 ++++++++++------------- 9 files changed, 49 insertions(+), 42 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 18e1280df..89c637b13 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -19,7 +19,7 @@ class ApplicationController < ActionController::Base if current_user @groups = current_user.groups @friends = current_user.friends - @latest_status_message = StatusMessage.newest_for(current_user) + @latest_status_message = StatusMessage.newest_for(current_user.person) @group = params[:group] ? current_user.groups.first(:id => params[:group]) : current_user.groups.first end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1e3f79102..97f8b31bc 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -25,4 +25,20 @@ class UsersController < ApplicationController render :action => 'edit' end end + + def create + @user = User.new(params[:user]) + + if @user.save! + flash[:notice] = "Successfully signed up." + redirect_to root_path + else + render :action => 'new' + end + end + + def new + @user = User.new + end + end diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb index 749de4b41..27a083bdf 100644 --- a/app/helpers/sockets_helper.rb +++ b/app/helpers/sockets_helper.rb @@ -23,6 +23,7 @@ module SocketsHelper action_hash[:photo_hash] = object.thumb_hash elsif object.is_a? StatusMessage action_hash[:status_message_hash] = object.latest_hash + action_hash[:status_message_hash][:mine?] = true if object.person.owner_id == uid end action_hash.to_json diff --git a/app/models/status_message.rb b/app/models/status_message.rb index fe641bdb2..bf56410be 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -22,7 +22,7 @@ class StatusMessage < Post end def latest_hash - {:mine? => self.person == User.owner, :text => message} + { :text => message} end end diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml index 793aea9db..9bf737e11 100644 --- a/app/views/js/_websocket_js.haml +++ b/app/views/js/_websocket_js.haml @@ -64,6 +64,7 @@ function processStatusMessage(className, html, messageHash){ processPost(className, html); + console.log(messageHash) if(messageHash['mine?']){ updateMyLatestStatus(messageHash); } diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index cb06b10f9..6f9884712 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -52,9 +52,9 @@ = link_to current_user.real_name, root_path %span#latest_message = my_latest_message - - unless @latest_status_message.nil? - %span{:style => "font-size: small", :id => 'latest_message_time'} - = " - #{how_long_ago @latest_status_message}" + %span{:style => "font-size: small", :id => 'latest_message_time'} + - unless @latest_status_message.nil? + = "- #{how_long_ago @latest_status_message}" %ul.nav %li= link_to "home", root_path diff --git a/app/views/layouts/session_wall.html.haml b/app/views/layouts/session_wall.html.haml index b025e419b..72603fbce 100644 --- a/app/views/layouts/session_wall.html.haml +++ b/app/views/layouts/session_wall.html.haml @@ -44,14 +44,8 @@ - flash.each do |name, msg| = content_tag :div, msg, :id => "flash_#{name}" - - if User.owner - %div#huge_text - welcome back, - %span - = User.owner.real_name.downcase - = yield - -else - %div#huge_text - %span - you need to add a user first! - + %div#huge_text + diaspora + = yield + + = link_to "signup", "/signup" diff --git a/config/routes.rb b/config/routes.rb index fb7d71fc6..501ac2f00 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,21 +12,20 @@ Diaspora::Application.routes.draw do |map| match "/images/files/*path" => "gridfs#serve" - match 'warzombie', :to => "dev_utilities#warzombie" - match 'zombiefriends', :to => "dev_utilities#zombiefriends" + match 'warzombie', :to => "dev_utilities#warzombie" + match 'zombiefriends', :to => "dev_utilities#zombiefriends" match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept" #routes for devise, not really sure you will need to mess with this in the future, lets put default, #non mutable stuff in anohter file devise_for :users, :path_names => {:sign_up => "signup", :sign_in => "login", :sign_out => "logout"} - match 'login', :to => 'devise/sessions#new', :as => "new_user_session" - match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" - #match 'signup', :to => 'devise/registrations#new', :as => "new_user_registration" - resources :users + match 'login', :to => 'devise/sessions#new', :as => "new_user_session" + match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" + match 'signup', :to => 'devise/registrations#new', :as => "new_user_registration" #public routes - match 'receive/users/:id', :to => 'publics#receive' + match 'receive/users/:id', :to => 'publics#receive' match '.well-known/host-meta',:to => 'publics#host_meta' match 'webfinger', :to => 'publics#webfinger' match 'hcard', :to => 'publics#hcard' diff --git a/public/javascripts/publisher.js b/public/javascripts/publisher.js index f8e0f369d..28d902098 100644 --- a/public/javascripts/publisher.js +++ b/public/javascripts/publisher.js @@ -1,24 +1,20 @@ - $(document).ready( function() { +$(document).ready( function() { - $("#publisher_content_pickers .status_message").click(selectPublisherTab); - $("#publisher_content_pickers .bookmark").click(selectPublisherTab); - $("#publisher_content_pickers .blog").click(selectPublisherTab); - $("#publisher_content_pickers .photo").click(selectPublisherTab); - - $("#new_status_message").submit(function() { - - }); + $("#publisher_content_pickers .status_message").click(selectPublisherTab); + $("#publisher_content_pickers .bookmark").click(selectPublisherTab); + $("#publisher_content_pickers .blog").click(selectPublisherTab); + $("#publisher_content_pickers .photo").click(selectPublisherTab); - function selectPublisherTab(evt){ - evt.preventDefault(); - var form_id = "#new_" + this.className - if( $(form_id).css("display") == "none" ) { - $("#publisher_content_pickers").children("li").removeClass("selected"); - $("#publisher_form form").fadeOut(50); + function selectPublisherTab(evt){ + evt.preventDefault(); + var form_id = "#new_" + this.className + if( $(form_id).css("display") == "none" ) { + $("#publisher_content_pickers").children("li").removeClass("selected"); + $("#publisher_form form").fadeOut(50); - $(this).toggleClass("selected"); - $(form_id).delay(50).fadeIn(200); - } + $(this).toggleClass("selected"); + $(form_id).delay(50).fadeIn(200); } + } - }); +});