From f696ffc3a60711a6a457269c9bd669a1ceb45713 Mon Sep 17 00:00:00 2001
From: maxwell <maxwell@joindiaspora.com>
Date: Mon, 21 Jun 2010 16:46:19 -0700
Subject: [PATCH] fixed up some views, but some stuff feels like it broke

---
 app/controllers/application_controller.rb           |  1 -
 app/helpers/application_helper.rb                   |  3 +++
 app/helpers/dashboard_helper.rb                     |  2 +-
 app/views/blogs/_blog.html.haml                     | 11 +++++++++++
 app/views/blogs/_pane.html.haml                     | 11 -----------
 app/views/blogs/index.html.haml                     |  2 +-
 app/views/bookmarks/_bookmark.html.haml             | 11 +++++++++++
 app/views/bookmarks/_pane.html.haml                 |  9 ---------
 app/views/bookmarks/index.html.haml                 |  2 +-
 app/views/layouts/application.html.haml             |  4 +---
 app/views/status_messages/_pane.html.haml           |  7 -------
 app/views/status_messages/_status_message.html.haml | 11 +++++++++++
 app/views/status_messages/index.html.haml           |  2 +-
 config/initializers/socket.rb                       | 10 ++--------
 config/routes.rb                                    |  1 -
 public/stylesheets/application.css                  |  6 +++++-
 public/stylesheets/sass/application.sass            |  3 +++
 17 files changed, 51 insertions(+), 45 deletions(-)
 create mode 100644 app/views/blogs/_blog.html.haml
 delete mode 100644 app/views/blogs/_pane.html.haml
 create mode 100644 app/views/bookmarks/_bookmark.html.haml
 delete mode 100644 app/views/bookmarks/_pane.html.haml
 delete mode 100644 app/views/status_messages/_pane.html.haml
 create mode 100644 app/views/status_messages/_status_message.html.haml

diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 876af6c653..83445dbdef 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -2,5 +2,4 @@ class ApplicationController < ActionController::Base
   protect_from_forgery :except => :receive
   layout 'application'
 
-  
 end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index b9b94f28a5..95dff0a711 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -29,4 +29,7 @@ module ApplicationHelper
     end
   end
 
+  def mine?(post)
+    post.owner == User.first.email
+  end
 end
diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb
index 3a3b0bfeaa..810c2b74f1 100644
--- a/app/helpers/dashboard_helper.rb
+++ b/app/helpers/dashboard_helper.rb
@@ -2,7 +2,7 @@ module DashboardHelper
 
   def type_partial(post)
     class_name = post.class.name.to_s.underscore
-    "#{class_name.pluralize}/pane"
+    "#{class_name.pluralize}/#{class_name}"
   end
 
 end
diff --git a/app/views/blogs/_blog.html.haml b/app/views/blogs/_blog.html.haml
new file mode 100644
index 0000000000..34b2d82648
--- /dev/null
+++ b/app/views/blogs/_blog.html.haml
@@ -0,0 +1,11 @@
+%li.message{:class => ("mine" if mine?(post))}
+  %span.from
+    = link_to post.owner, "#"
+    %b wrote a new blog post
+    %br
+  %b= post.title
+  %br
+  = post.body
+  %div.time= link_to "#{time_ago_in_words(post.updated_at)} ago", blog_path(post)
+  - if mine?(post)
+    = link_to 'Destroy', blog_path(post), :confirm => 'Are you sure?', :method => :delete
\ No newline at end of file
diff --git a/app/views/blogs/_pane.html.haml b/app/views/blogs/_pane.html.haml
deleted file mode 100644
index a5270a1b2c..0000000000
--- a/app/views/blogs/_pane.html.haml
+++ /dev/null
@@ -1,11 +0,0 @@
-%li.message
-  %span.from
-    = link_to post.owner, "#"
-    %b wrote a new blog post
-    %br
-  %b= post.title
-  %br
-  = post.body
-  %div.time
-    = "#{time_ago_in_words(post.updated_at)} ago"
-
diff --git a/app/views/blogs/index.html.haml b/app/views/blogs/index.html.haml
index 655aa67eb3..c7aab65254 100644
--- a/app/views/blogs/index.html.haml
+++ b/app/views/blogs/index.html.haml
@@ -2,4 +2,4 @@
 
 %ul#stream
   - for blog in @blogs
-    = render "pane", :post => blog
+    = render "blog", :post => blog
diff --git a/app/views/bookmarks/_bookmark.html.haml b/app/views/bookmarks/_bookmark.html.haml
new file mode 100644
index 0000000000..f1fcc1b4da
--- /dev/null
+++ b/app/views/bookmarks/_bookmark.html.haml
@@ -0,0 +1,11 @@
+%li.message{:class => ("mine" if mine?(post))}
+  %span.from
+    = link_to post.owner, "#"
+    %b shared a link
+    %br
+  = post.title
+  = link_to post.link
+  %div.time= link_to "#{time_ago_in_words(post.updated_at)} ago", bookmark_path(post)
+  - if mine?(post)
+    = link_to 'Destroy', bookmark_path(post), :confirm => 'Are you sure?', :method => :delete
+
diff --git a/app/views/bookmarks/_pane.html.haml b/app/views/bookmarks/_pane.html.haml
deleted file mode 100644
index 8526bb91b1..0000000000
--- a/app/views/bookmarks/_pane.html.haml
+++ /dev/null
@@ -1,9 +0,0 @@
-%li.message
-  %span.from
-    = link_to post.owner, "#"
-    %b shared a link
-    %br
-  = post.title
-  = link_to post.link
-  %div.time= "#{time_ago_in_words(post.updated_at)} ago"
-
diff --git a/app/views/bookmarks/index.html.haml b/app/views/bookmarks/index.html.haml
index 4380e370a2..f518a2635a 100644
--- a/app/views/bookmarks/index.html.haml
+++ b/app/views/bookmarks/index.html.haml
@@ -2,4 +2,4 @@
 
 %ul#stream
   - for bookmark in @bookmarks
-    = render "pane", :post => bookmark
+    = render "bookmark", :post => bookmark
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index 856c72e998..deab8559ad 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -1,6 +1,5 @@
 !!!
 %html
-  
   %head
     %title
       = yield(:title) || "Untitled"
@@ -11,7 +10,7 @@
     = javascript_include_tag 'jquery142'
     /= javascript_include_tag"http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"
     = javascript_include_tag 'rails'
-    = javascript_include_tag 'socket'
+    = javascript_include_tag 'socket' if user_signed_in?
     = csrf_meta_tag
     = yield(:head)
 
@@ -28,7 +27,6 @@
           $(this).fadeTo(80, 1);
         });
       });
-      
 
   %body
     %header
diff --git a/app/views/status_messages/_pane.html.haml b/app/views/status_messages/_pane.html.haml
deleted file mode 100644
index f523dc7039..0000000000
--- a/app/views/status_messages/_pane.html.haml
+++ /dev/null
@@ -1,7 +0,0 @@
-%li.message
-  %span.from
-    = link_to post.owner, "#"
-    = post.message
-  %div.time
-    = "#{time_ago_in_words(post.updated_at)} ago"
-
diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml
new file mode 100644
index 0000000000..bfe97c6788
--- /dev/null
+++ b/app/views/status_messages/_status_message.html.haml
@@ -0,0 +1,11 @@
+%li.message{:class => ("mine" if mine?(post))}
+  %span.from
+    = link_to post.owner, "#"
+    = post.message
+  %div.time
+    = "#{time_ago_in_words(post.updated_at)} ago"
+  - if mine?(post)
+    = link_to 'Destroy', status_message_path(post), :confirm => 'Are you sure?', :method => :delete
+    
+    
+
diff --git a/app/views/status_messages/index.html.haml b/app/views/status_messages/index.html.haml
index c6518c4d38..940352f06b 100644
--- a/app/views/status_messages/index.html.haml
+++ b/app/views/status_messages/index.html.haml
@@ -1,5 +1,5 @@
 %h1.big_text= link_to "new status message", new_status_message_path
 %ul#stream
   - for status_message in @status_messages
-    = render "pane", :post => status_message
+    = render "status_message", :post => status_message
 
diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb
index 8e1193f3e4..a9ed0e9b58 100644
--- a/config/initializers/socket.rb
+++ b/config/initializers/socket.rb
@@ -7,16 +7,13 @@ module WebSocket
 
   EM.next_tick {
     EM.add_timer(0.1) do
-      #puts "channel set"
       @channel = EM::Channel.new
     end
     
     EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug => true) do |ws|
       ws.onopen {
         sid = @channel.subscribe { |msg| ws.send msg }
-        #@channel.push "#{sid} connectdfged!"
-        puts @channel.inspect
-
+        
         ws.onmessage { |msg|
           @channel.push "#{msg}"
         }
@@ -30,10 +27,7 @@ module WebSocket
 }
   #this should get folded into message queue i think?
   def self.update_clients(json)
-    #EM.add_timer(5) do
-      #puts @channel
-      @channel.push json
-    #end
+      @channel.push(json) if @channel
   end
 
 end
diff --git a/config/routes.rb b/config/routes.rb
index 54f48a4ffb..ec7eab734f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -3,7 +3,6 @@ Diaspora::Application.routes.draw do |map|
   resources :bookmarks
   resources :friends
   resources :status_messages
-  resources :status_messages
   
   #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
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index c4d8f9a0af..8368985822 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -131,7 +131,8 @@ li.message {
   line-height: 140%;
   font-size: 120%;
   font-family: "Lucida Grande";
-  color: #999999; }
+  color: #999999;
+  margin-bottom: 5px; }
   li.message span.from {
     color: black;
     font-weight: bold;
@@ -140,6 +141,9 @@ li.message {
     color: #bababa;
     font-size: 70%; }
 
+.mine {
+  background-color: rgba(202, 237, 204, 0.5); }
+
 h1 {
   position: relative;
   font-size: 24px;
diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass
index d4c837e00f..e6b4dde877 100644
--- a/public/stylesheets/sass/application.sass
+++ b/public/stylesheets/sass/application.sass
@@ -158,6 +158,7 @@ li.message
     :size 120%
     :family 'Lucida Grande'
   :color #999
+  :margin-bottom 5px
 
   span.from
     :color #000
@@ -169,6 +170,8 @@ li.message
   div.time
     :color #bababa
     :font-size 70%
+.mine
+  :background-color rgba(202, 237, 204, 0.5)
 
 h1
   :position relative
-- 
GitLab