From 19b633d3a3d33b99f0f59434473f46bbbdd2dc9b Mon Sep 17 00:00:00 2001 From: danielvincent Date: Sun, 1 Aug 2010 22:21:57 -0700 Subject: [PATCH 01/15] top nav for groups partially there. --- app/views/layouts/application.html.haml | 31 +++++++++++++++++++----- public/stylesheets/application.css | 24 +++++++++++++++--- public/stylesheets/sass/application.sass | 30 +++++++++++++++++++---- 3 files changed, 70 insertions(+), 15 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 31388333b..4a96e6b2a 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -42,6 +42,28 @@ - else = link_to "login", new_user_session_path + #group + %ul + %li.selected ACM + %li FAMILY + %li WORK + %li HIGH SCHOOL + #user_pictures + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + - for friend in @friends + = person_image_link(friend) + .container - if user_signed_in? #user_name @@ -63,12 +85,9 @@ .container .span-24.last - .span-20.append-1.last - = yield + = yield - .span-3.last - = render 'people/sidebar' if user_signed_in? - .span-24.last - = render "posts/debug" + .span-24.last + = render "posts/debug" diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index c50e1e9ff..b11e56ba1 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -67,24 +67,24 @@ header { margin-bottom: 30px; color: #555555; background-color: #2b2726; + background-color: black; border-bottom: 3px solid #333333; padding: 6px 0; padding-top: 0; } header #diaspora_text { + margin-bottom: 1em; font-family: "BrandonGrotesqueLightRegular"; - font-size: 24px; - position: absolute; + font-size: 16px; border: none; color: white; text-shadow: 0 2px 0 black; } header #diaspora_text a { color: #666666; } header #diaspora_text span.sub_text { - color: black; text-shadow: none; } header #session_action { float: right; - margin-top: 9px; + top: 0; text-shadow: 0 1px 0 black; padding-right: 10px; } header #session_action a { @@ -412,3 +412,19 @@ h1.big_text { .image_cycle img { display: none; } + +#group { + color: #333333; } + #group ul { + font-size: 18px; + margin: 0; + padding: 0; } + #group ul > li { + display: inline; + margin-right: 10px; } + #group ul > li.selected { + color: white; + font-weight: bold; } + #group #user_pictures img { + display: inline-block; + height: 40px; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 3490e3b39..0c436867a 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -72,16 +72,18 @@ header :color #555 :background :color #2B2726 + :color #000 :border :bottom 3px solid #333 :padding 6px 0 :top 0 #diaspora_text + :margin + :bottom 1em :font :family 'BrandonGrotesqueLightRegular' - :size 24px - :position absolute + :size 16px :border none :color #fff :text @@ -90,14 +92,12 @@ header :color #666 span.sub_text - :color #000 :text :shadow none #session_action :float right - :margin - :top 9px + :top 0 :text-shadow 0 1px 0 #000 a :color #777 @@ -513,3 +513,23 @@ h1.big_text .image_cycle img :display none + +#group + :color #333 + ul + :font-size 18px + :margin 0 + :padding 0 + > li + :display inline + :margin + :right 10px + + &.selected + :color #fff + :font-weight bold + + #user_pictures + img + :display inline-block + :height 40px From 5974bf357121509ca1fe8854fd6e7f9c3c0cc0f9 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Sun, 1 Aug 2010 22:27:39 -0700 Subject: [PATCH 02/15] group nav is now links to nothing --- app/views/layouts/application.html.haml | 18 ++++++++-------- public/stylesheets/application.css | 24 ++++++++++++++-------- public/stylesheets/sass/application.sass | 26 +++++++++++++++++------- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 4a96e6b2a..9cf9e25c9 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -18,8 +18,7 @@ = csrf_meta_tag = yield(:head) - = javascript_include_tag 'satisfaction' , 'satisfaction-display' - + = javascript_include_tag 'satisfaction', 'satisfaction-display' = javascript_include_tag 'jquery.html5_upload' %body @@ -44,11 +43,11 @@ #group %ul - %li.selected ACM - %li FAMILY - %li WORK - %li HIGH SCHOOL - #user_pictures + %li.selected= link_to "OTHER PRESIDENTS", root_path + %li= link_to "OSTATUS", ostatus_path + /%li= link_to "NEW YORK", "#" + /%li= link_to "NEW CIRCLE", "#" + #friend_pictures = link_to(person_image_tag(current_user), root_path) = link_to(person_image_tag(current_user), root_path) = link_to(person_image_tag(current_user), root_path) @@ -63,6 +62,8 @@ = link_to(person_image_tag(current_user), root_path) - for friend in @friends = person_image_link(friend) + .add_new + = link_to "+", requests_path .container - if user_signed_in? @@ -85,9 +86,6 @@ .container .span-24.last - = yield - - .span-24.last = render "posts/debug" diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index b11e56ba1..357f7bc99 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -84,7 +84,6 @@ header { text-shadow: none; } header #session_action { float: right; - top: 0; text-shadow: 0 1px 0 black; padding-right: 10px; } header #session_action a { @@ -155,9 +154,10 @@ h3 { font-weight: bold; } form { + position: relative; font-size: 120%; margin: 1em; - margin-left: 0em; } + margin-left: 0em; } #user_name { margin-bottom: 20px; } @@ -301,7 +301,8 @@ label { background-color: rgba(10, 81, 109, 0.05); border-bottom: 2px #999999 solid; color: #999999; - padding: 15px 1em; } + padding: 15px 1em; + padding-bottom: 30px; } #new_blog, #new_bookmark { @@ -416,15 +417,22 @@ h1.big_text { #group { color: #333333; } #group ul { - font-size: 18px; margin: 0; - padding: 0; } + padding: 0; + font-size: 14px; } #group ul > li { display: inline; margin-right: 10px; } - #group ul > li.selected { + #group ul > li.selected, #group ul > li.selected a { color: white; - font-weight: bold; } - #group #user_pictures img { + font-weight: bold; + font-size: 18px; } + #group a { + color: #333333; + font-weight: normal; } + #group #friend_pictures .add_new { + display: inline; + font-size: 40px; } + #group #friend_pictures img { display: inline-block; height: 40px; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 0c436867a..fe309e07f 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -97,7 +97,6 @@ header #session_action :float right - :top 0 :text-shadow 0 1px 0 #000 a :color #777 @@ -181,11 +180,11 @@ h3 :weight bold form + :position relative :font :size 120% :margin 1em - :margin-left 0em - + :left 0em #user_name :margin @@ -365,6 +364,7 @@ label :bottom 2px #999 solid :color #999 :padding 15px 1em + :bottom 30px #new_blog, #new_bookmark @@ -517,19 +517,31 @@ h1.big_text #group :color #333 ul - :font-size 18px :margin 0 :padding 0 + :font + :size 14px > li :display inline :margin :right 10px - &.selected + &.selected, &.selected a :color #fff - :font-weight bold + :font + :weight bold + :size 18px - #user_pictures + a + :color #333 + :font + :weight normal + + #friend_pictures + .add_new + :display inline + :font + :size 40px img :display inline-block :height 40px From 102b9128784e07136184c7357b283d40707b7cda Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 2 Aug 2010 16:20:30 -0700 Subject: [PATCH 03/15] moved group nav to its own partial --- app/views/layouts/application.html.haml | 28 +++---------------------- app/views/shared/_group_nav.haml | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 25 deletions(-) create mode 100644 app/views/shared/_group_nav.haml diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 4f647d00e..f5400aef9 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -10,8 +10,7 @@ = stylesheet_link_tag "application", "ui", 'bubble' /= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" = javascript_include_tag 'jquery142', 'rails', 'google' - = javascript_include_tag 'tiny_mce/tiny_mce', 'jquery.infieldlabel' - = javascript_include_tag 'jquery.cycle/jquery.cycle.min.js' + = javascript_include_tag 'tiny_mce/tiny_mce', 'jquery.infieldlabel', 'jquery.cycle/jquery.cycle.min.js' = javascript_include_tag 'view', 'publisher', 'image_picker' = render 'js/websocket_js' @@ -40,30 +39,9 @@ = link_to "logout", destroy_user_session_path - else = link_to "login", new_user_session_path + + = render "shared/group_nav" - #group - %ul - %li.selected= link_to "OTHER PRESIDENTS", root_path - %li= link_to "OSTATUS", ostatus_path - /%li= link_to "NEW YORK", "#" - /%li= link_to "NEW CIRCLE", "#" - #friend_pictures - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - - for friend in @friends - = person_image_link(friend) - .add_new - = link_to "+", requests_path .container - if user_signed_in? diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml new file mode 100644 index 000000000..813473c60 --- /dev/null +++ b/app/views/shared/_group_nav.haml @@ -0,0 +1,21 @@ +#group + %ul + %li.selected= link_to "OTHER PRESIDENTS", root_path + %li= link_to "OSTATUS", ostatus_path + #friend_pictures + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) + - for friend in @friends + = person_image_link(friend) + .add_new + = link_to "+", requests_path From 3d5f27fe5a49dad74f18bbab576bfe5ad4977a80 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 2 Aug 2010 17:27:45 -0700 Subject: [PATCH 04/15] javascript gets group param for temp testing... friend pictures on group nav displays all people and authors, also for testing --- app/views/layouts/application.html.haml | 2 +- app/views/shared/_group_nav.haml | 21 +++++++-------------- public/javascripts/group_nav.js | 13 +++++++++++++ public/stylesheets/application.css | 12 +++++++++++- public/stylesheets/sass/application.sass | 16 +++++++++++++--- 5 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 public/javascripts/group_nav.js diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f5400aef9..44bce846b 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -11,7 +11,7 @@ /= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" = javascript_include_tag 'jquery142', 'rails', 'google' = javascript_include_tag 'tiny_mce/tiny_mce', 'jquery.infieldlabel', 'jquery.cycle/jquery.cycle.min.js' - = javascript_include_tag 'view', 'publisher', 'image_picker' + = javascript_include_tag 'view', 'publisher', 'image_picker', 'group_nav' = render 'js/websocket_js' = csrf_meta_tag diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index 813473c60..9ba2f6d67 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -1,21 +1,14 @@ #group %ul - %li.selected= link_to "OTHER PRESIDENTS", root_path - %li= link_to "OSTATUS", ostatus_path + %li.other_presidents= link_to "OTHER PRESIDENTS", root_path(:g => "other_presidents") + %li.ostatus= link_to "OSTATUS", ostatus_path(:g => "ostatus") + %li.new_circle= link_to "NEW CIRCLE", "#" + #friend_pictures - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - = link_to(person_image_tag(current_user), root_path) - for friend in @friends = person_image_link(friend) + + -for author in @subscribed_persons + = link_to (image_tag author.avatar_thumbnail, :class => "person_picture"), author_path(author) .add_new = link_to "+", requests_path diff --git a/public/javascripts/group_nav.js b/public/javascripts/group_nav.js new file mode 100644 index 000000000..62b99e18c --- /dev/null +++ b/public/javascripts/group_nav.js @@ -0,0 +1,13 @@ +$(document).ready( function() { + + var vars = [], hash; + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); + for(var i = 0; i < hashes.length; i++) + { + hash = hashes[i].split('='); + vars.push(hash[0]); + vars[hash[0]] = hash[1]; + } + + $("."+vars['g']).addClass('selected'); +}); diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index dbb9964a0..1ba47cbca 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -431,8 +431,18 @@ h1.big_text { color: #333333; font-weight: normal; } #group #friend_pictures .add_new { - display: inline; + position: relative; + display: inline-block; + height: 40px; + width: 40px; + background-color: #222222; + text-align: center; font-size: 40px; } + #group #friend_pictures .add_new a { + display: block; + position: absolute; + top: -13px; + left: 7px; } #group #friend_pictures img { display: inline-block; height: 40px; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 13d2e6dca..bf3441940 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -539,9 +539,19 @@ h1.big_text #friend_pictures .add_new - :display inline - :font - :size 40px + :position relative + :display inline-block + :height 40px + :width 40px + :background + :color #222 + :text-align center + :font-size 40px + a + :display block + :position absolute + :top -13px + :left 7px img :display inline-block :height 40px From f3bc65135963003d686beb3c7f7ff6801c02c060 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Mon, 2 Aug 2010 19:16:01 -0700 Subject: [PATCH 05/15] stuff fades --- public/javascripts/group_nav.js | 3 +++ public/stylesheets/application.css | 2 +- public/stylesheets/sass/application.sass | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/public/javascripts/group_nav.js b/public/javascripts/group_nav.js index 62b99e18c..f3d9600bb 100644 --- a/public/javascripts/group_nav.js +++ b/public/javascripts/group_nav.js @@ -10,4 +10,7 @@ $(document).ready( function() { } $("."+vars['g']).addClass('selected'); + + $("#group img").load(function(){$(this).fadeIn("slow");}); + }); diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 7cdcd5beb..929192e13 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -445,5 +445,5 @@ h1.big_text { top: -13px; left: 7px; } #group #friend_pictures img { - display: inline-block; + display: none; height: 40px; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index a170bb967..6b7bc1317 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -553,5 +553,5 @@ h1.big_text :top -13px :left 7px img - :display inline-block + :display none :height 40px From c54d47337b326b433019a1b014c8c812cbd58ba6 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 6 Aug 2010 00:15:22 -0700 Subject: [PATCH 06/15] updated button style --- app/views/albums/index.html.haml | 4 +- app/views/albums/show.html.haml | 8 ++-- public/javascripts/view.js | 10 +---- public/stylesheets/application.css | 9 ++-- public/stylesheets/sass/application.sass | 6 ++- public/stylesheets/sass/ui.sass | 52 +++++++++++++----------- public/stylesheets/ui.css | 51 +++++++++++------------ 7 files changed, 70 insertions(+), 70 deletions(-) diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index 8f3816f3d..2e47295d6 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -2,8 +2,8 @@ .back = link_to "⇧ home", root_path Albums - .button.right#add_album_button - = link_to 'New Album', "#" + .right#add_album_button + = link_to 'New Album', "#", :class => "button" #add_album_box.contextual_pane = render "albums/new_album" diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index 253d94d19..208c3ae2b 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -5,8 +5,8 @@ = @album.name -if mine? @album - .button.right#add_photos_button - = link_to 'Add Photos', '#' + .right#add_photos_button + = link_to 'Add Photos', '#', :class => "button" #add_photo_box.contextual_pane = render "photos/new_photo", :photo => @photo, :album => @album @@ -26,5 +26,5 @@ .back = link_to "⇧ albums", albums_path -if mine? @album - .button.right - = link_to 'Edit Album', edit_album_path(@album) + .right + = link_to 'Edit Album', edit_album_path(@album), :class => "button" diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 5da7a9f9e..5e0f2ef51 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -21,15 +21,7 @@ $(document).ready(function(){ var show_comments_toggle = $(this).parent().prev().children(".show_post_comments"); show_comments_toggle.html("hide comments ("+ ($(this).children().length - 1) + ")"); }; - }); - - $('a').hover(function(){ - if( $(this).children("img").length < 1 ) - $(this).fadeTo(60, 0.5); - }, function(){ - if( $(this).children("img").length < 1 ) - $(this).fadeTo(80, 1); - }); + }); $('#debug_info').click(function() { $('#debug_more').toggle('fast', function() { diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 929192e13..6710c853d 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -12,10 +12,10 @@ body { a { color: #018790; - text-decoration: none; - font-weight: bold; } + text-decoration: none; } a:hover { - color: #018790; } + color: white; + background-color: #018790; } #flash_notice, #flash_error, @@ -377,7 +377,8 @@ h1.big_text { .back { position: absolute; - font-size: 12px; } + font-size: 12px; + font-weight: normal; } #content_bottom { position: relative; diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 6b7bc1317..223080f2d 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -13,9 +13,10 @@ a :color #018790 :text :decoration none - :font-weight bold &:hover - :color #018790 + :color #fff + :background + :color #018790 #flash_notice, @@ -464,6 +465,7 @@ h1.big_text :position absolute :font :size 12px + :weight normal #content_bottom :position relative diff --git a/public/stylesheets/sass/ui.sass b/public/stylesheets/sass/ui.sass index 50000a8d3..7a64e4ce6 100644 --- a/public/stylesheets/sass/ui.sass +++ b/public/stylesheets/sass/ui.sass @@ -5,21 +5,22 @@ :display inline - :color #777 + :padding 4px + :font-size 12px :line-height 100% :text-shadow 0 1px 0 #fff - :min-height 14px + :min-height 10px - :background -webkit-gradient(linear, 0% 29%, 0% 85%, from(#FAFAFA), to(#E0E0E0)) - :background -moz-linear-gradient(top, #FAFAFA, #E0E0E0) + :background -webkit-gradient(linear, 0% 29%, 0% 85%, from(#FCFCFC), to(#F6F6F6)) + :background -moz-linear-gradient(top, #FCFCFC, #F6F6F6) - :border 1px solid #ccc - :bottom 1px solid #666 - :left 1px solid #999 - :right 1px solid #999 + :border 1px solid #EEE + :bottom 1px solid #999 + :left 1px solid #ccc + :right 1px solid #ccc :border-radius 3px :-moz-border-radius 3px @@ -27,28 +28,31 @@ :cursor pointer + :box-shadow 0 1px 1px #eee + :-webkit-box-shadow 0 1px 1px #eee + :-moz-box-shadow 0 1px 1px #eee - :box-shadow 0 1px 1px #ccc - :-webkit-box-shadow 0 1px 1px #ccc - :-moz-box-shadow 0 1px 1px #ccc + :font-weight normal - a - :font-weight normal - :color #777 + :color #666 - -.button - :padding 5px + &:hover + :color #666 + :background -webkit-gradient(linear, 0% 29%, 0% 85%, from(#FAFAFA), to(#F0F0F0)) + :background -moz-linear-gradient(top, #FAFAFA, #F0F0F0) &:active - :box-shadow 0 0px 2px #000 - :-webkit-box-shadow 0 0px 2px #000 - :-moz-box-shadow 0 0px 2px #000 - :color #555 + :color #666 + :background -webkit-gradient(linear, 0% 29%, 0% 85%, from(#F0F0F0), to(#FAFAFA)) + :background -moz-linear-gradient(top, #F0F0F0, #FAFAFA) + :border + :top 1px solid #ccc ul.button_set - :padding 5px 0 + :padding + :left 0 + :right 0 > li :padding 5px @@ -75,8 +79,8 @@ ul.button_set :right none .button .selected, .button_set .selected - :background -webkit-gradient(linear, 0% 29%, 0% 85%, from(#E0E0E0), to(#FAFAFA)) - :background -moz-linear-gradient(top, #e0e0e0, #fafafa) + :background -webkit-gradient(linear, 0% 29%, 0% 85%, from(#F0F0F0), to(#FAFAFA)) + :background -moz-linear-gradient(top, #F0F0F0, #fafafa) :border :top 1px solid #aaa diff --git a/public/stylesheets/ui.css b/public/stylesheets/ui.css index 63c8dc0cc..f83cc7957 100644 --- a/public/stylesheets/ui.css +++ b/public/stylesheets/ui.css @@ -2,38 +2,39 @@ font-family: "Lucida Grande", sans-serif; font-style: normal; display: inline; - color: #777777; + padding: 4px; font-size: 12px; line-height: 100%; text-shadow: 0 1px 0 white; - min-height: 14px; - background: -webkit-gradient(linear, 0% 29%, 0% 85%, from(#fafafa), to(#e0e0e0)); - background: -moz-linear-gradient(top, #fafafa, #e0e0e0); - border: 1px solid #cccccc; - border-bottom: 1px solid #666666; - border-left: 1px solid #999999; - border-right: 1px solid #999999; + min-height: 10px; + background: -webkit-gradient(linear, 0% 29%, 0% 85%, from(#fcfcfc), to(#f6f6f6)); + background: -moz-linear-gradient(top, #fcfcfc, #f6f6f6); + border: 1px solid #eeeeee; + border-bottom: 1px solid #999999; + border-left: 1px solid #cccccc; + border-right: 1px solid #cccccc; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; cursor: pointer; - box-shadow: 0 1px 1px #cccccc; - -webkit-box-shadow: 0 1px 1px #cccccc; - -moz-box-shadow: 0 1px 1px #cccccc; } - .button a, .button_set a { - font-weight: normal; - color: #777777; } - -.button { - padding: 5px; } - .button:active { - box-shadow: 0 0px 2px black; - -webkit-box-shadow: 0 0px 2px black; - -moz-box-shadow: 0 0px 2px black; - color: #555555; } + box-shadow: 0 1px 1px #eeeeee; + -webkit-box-shadow: 0 1px 1px #eeeeee; + -moz-box-shadow: 0 1px 1px #eeeeee; + font-weight: normal; + color: #666666; } + .button:hover, .button_set:hover { + color: #666666; + background: -webkit-gradient(linear, 0% 29%, 0% 85%, from(#fafafa), to(#f0f0f0)); + background: -moz-linear-gradient(top, #fafafa, #f0f0f0); } + .button:active, .button_set:active { + color: #666666; + background: -webkit-gradient(linear, 0% 29%, 0% 85%, from(#f0f0f0), to(#fafafa)); + background: -moz-linear-gradient(top, #f0f0f0, #fafafa); + border-top: 1px solid #cccccc; } ul.button_set { - padding: 5px 0; } + padding-left: 0; + padding-right: 0; } ul.button_set > li { padding: 5px; display: inline; @@ -50,8 +51,8 @@ ul.button_set { border-right: none; } .button .selected, .button_set .selected { - background: -webkit-gradient(linear, 0% 29%, 0% 85%, from(#e0e0e0), to(#fafafa)); - background: -moz-linear-gradient(top, #e0e0e0, #fafafa); + background: -webkit-gradient(linear, 0% 29%, 0% 85%, from(#f0f0f0), to(#fafafa)); + background: -moz-linear-gradient(top, #f0f0f0, #fafafa); border-top: 1px solid #aaaaaa; } .right { From 6f1a596dff79ab459a6985fb0324dca8b2ad5e7d Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 6 Aug 2010 00:40:44 -0700 Subject: [PATCH 07/15] small color changes --- app/views/authors/show.html.haml | 4 ++-- app/views/photos/show.html.haml | 8 ++++---- .../status_messages/_status_message.html.haml | 2 +- public/javascripts/view.js | 3 +++ public/stylesheets/application.css | 15 ++++++++------- public/stylesheets/sass/application.sass | 12 +++++++----- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/app/views/authors/show.html.haml b/app/views/authors/show.html.haml index 89b6cd165..fbabf20ce 100644 --- a/app/views/authors/show.html.haml +++ b/app/views/authors/show.html.haml @@ -17,5 +17,5 @@ #content_bottom .back = link_to "⇧ ostatus", ostatus_path - .button.right - = link_to 'Unsubscribe', @author, :confirm => 'Are you sure?', :method => :delete + .right + = link_to 'Unsubscribe', @author, :confirm => 'Are you sure?', :method => :delete, :class => "button" diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 0714ec692..4da35fd36 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -3,8 +3,8 @@ = link_to "⇧ #{@album.name}", album_path(@album) = @photo.image - .button.right - = link_to 'Edit Photo', edit_photo_path(@photo) + .right + = link_to 'Edit Photo', edit_photo_path(@photo), :class => "button" .sub_header = link_to "full size", @photo.image.url @@ -23,8 +23,8 @@ .back = link_to "⇧ #{@album.name}", album_path(@album) -if mine? @album - .button.right - = link_to 'Delete Photo', @photo, :confirm => 'Are you sure?', :method => :delete + .right + = link_to 'Delete Photo', @photo, :confirm => 'Are you sure?', :method => :delete, :class => "button" %h4{:class => "show_post_comments"} = "comments (#{@photo.comments.count})" diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml index 5681e9753..954128431 100644 --- a/app/views/status_messages/_status_message.html.haml +++ b/app/views/status_messages/_status_message.html.haml @@ -14,4 +14,4 @@ - if mine?(post) .destroy_link - = link_to 'Delete', status_message_path(post), :confirm => 'Are you sure?', :method => :delete, :remote => true + = link_to 'Delete', status_message_path(post), :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "delete" diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 5e0f2ef51..c181e3bcc 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -107,5 +107,8 @@ $(document).ready(function(){ $(this).fadeIn("slow"); }); + $(".delete").hover(function(){ + $(this).toggleClass("button"); + }); });//end document ready diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 6710c853d..437ba0fd7 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -12,10 +12,12 @@ body { a { color: #018790; + color: #556270; text-decoration: none; } a:hover { color: white; - background-color: #018790; } + background-color: #018790; + background-color: #556270; } #flash_notice, #flash_error, @@ -107,13 +109,12 @@ header { ul#stream, ul#friend_stream { margin: 0; - padding: 0; - color: #666666; } + padding: 0; } ul#stream > li, ul#friend_stream > li { list-style: none; padding: 15px 0; - border-bottom: 1px solid #f1f1f1; - margin-bottom: 5px; } + margin-bottom: 5px; + border-bottom: 1px solid #eeeeee; } ul#friend_stream > li { padding: 0.2em 0; } @@ -295,7 +296,8 @@ label { color: #999999; position: absolute; top: 3px; - left: 0.48em; } + left: 0.48em; + font-weight: normal; } #publisher { background-color: rgba(10, 81, 109, 0.05); @@ -367,7 +369,6 @@ ul#publisher_content_pickers li { h1.big_text { position: relative; line-height: auto; - border-top: 2px solid #666666; border-bottom: 1px solid #666666; text-align: center; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 223080f2d..f84d8b0c3 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -11,13 +11,14 @@ body :margin 0 a :color #018790 + :color #556270 :text :decoration none &:hover :color #fff :background :color #018790 - + :color #556270 #flash_notice, #flash_error, @@ -121,13 +122,12 @@ header ul#stream, ul#friend_stream :margin 0 :padding 0 - :color #666 > li :list-style none :padding 15px 0 - :border - :bottom 1px solid #f1f1f1 :margin-bottom 5px + :border + :bottom 1px solid #eee ul#friend_stream > li @@ -356,6 +356,8 @@ label :position absolute :top 3px :left 0.48em + :font + :weight normal #publisher :background @@ -451,7 +453,7 @@ h1.big_text :position relative :line-height auto :border - :top 2px solid #666 + //:top 2px solid #666 :bottom 1px solid #666 :text :align center From 73a6cd911bbda5e881f86a67cfd54969cec0f540 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 10:46:02 -0700 Subject: [PATCH 08/15] DG, RS; User person delegation fixed --- app/models/comment.rb | 2 +- app/models/person.rb | 7 +++---- app/models/user.rb | 3 ++- db/seeds/dev.rb | 19 ++++++++++--------- lib/encryptable.rb | 6 +++--- spec/user_encryption_spec.rb | 20 ++++++++++---------- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index d374f13ed..f2b6aface 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -71,7 +71,7 @@ class Comment protected def sign_if_my_post unless self.post.person.owner.nil? - self.post_creator_signature = sign_with_key self.post.person.key + self.post_creator_signature = sign_with_key self.post.person.encryption_key end end diff --git a/app/models/person.rb b/app/models/person.rb index 196a249fa..e10a4bbfb 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -40,16 +40,16 @@ class Person "#{profile.first_name.to_s} #{profile.last_name.to_s}" end - def key + def encryption_key OpenSSL::PKey::RSA.new( serialized_key ) end - def key= new_key + def encryption_key= new_key raise TypeError unless new_key.class == OpenSSL::PKey::RSA serialized_key = new_key.export end def export_key - key.public_key.export + encryption_key.public_key.export end @@ -107,7 +107,6 @@ class Person end def owns?(post) - puts self.class self.id == post.person.id end diff --git a/app/models/user.rb b/app/models/user.rb index 8b51c20dd..8744699bc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -15,7 +15,8 @@ class User before_validation_on_create :assign_key before_validation :do_bad_things - ######## Posting ######## + ######## Making things work ######## + key :email, String def method_missing(method, *args) diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index f59cb7848..f13e27f4c 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -9,16 +9,17 @@ require 'config/environment' # Create seed user -user = User.create( :password => "evankorth", - :person => Person.create( - :email => "robert@joindiaspora.com", - :url => "http://localhost:3000/", - :profile => Profile.new( - :first_name => "bobert", - :last_name => "brin" ))) +user = User.create( :email => "robert@joindiaspora.com", + :password => "evankorth", + :person => Person.new( + :email => "robert@joindiaspora.com", + :url => "http://localhost:3000/", + :profile => Profile.new( + :first_name => "bobert", + :last_name => "brin" ))) -puts user.save! -puts user.person.save +puts user.save +puts user.person.save! puts user.save! puts user.person.inspect puts user.inspect diff --git a/lib/encryptable.rb b/lib/encryptable.rb index b552a5ab4..6925b4cd0 100644 --- a/lib/encryptable.rb +++ b/lib/encryptable.rb @@ -10,7 +10,7 @@ if person.nil? Rails.logger.info("Verifying sig on #{signable_string} but no person is here") return false - elsif person.key.nil? + elsif person.encryption_key.nil? Rails.logger.info("Verifying sig on #{signable_string} but #{person.real_name} has no key") return false elsif signature.nil? @@ -18,14 +18,14 @@ return false end Rails.logger.info("Verifying sig on #{signable_string} from person #{person.real_name}") - validity = person.key.verify "SHA", Base64.decode64(signature), signable_string + validity = person.encryption_key.verify "SHA", Base64.decode64(signature), signable_string Rails.logger.info("Validity: #{validity}") validity end protected def sign_if_mine - self.creator_signature = sign_with_key(person.key) unless person.owner_id.nil? + self.creator_signature = sign_with_key(person.encryption_key) unless person.owner_id.nil? end def sign_with_key(key) diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index d112b726b..2c7b8963b 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -33,7 +33,7 @@ describe 'user encryption' do #keys.each{|k| ctx.delete_key(k, true)} end it 'should have a key' do - @user.key.should_not be nil + @user.encryption_key.should_not be nil end describe 'key exchange on friending' do it 'should send over a public key' do @@ -44,7 +44,7 @@ describe 'user encryption' do it 'should receive and marshal a public key from a request' do person = Factory.build(:person, :url => "http://test.url/" ) - person.key.nil?.should== false + person.encryption_key.nil?.should== false #should move this to friend request, but i found it here id = person.id original_key = person.export_key @@ -78,7 +78,7 @@ describe 'user encryption' do it 'should verify a remote signature' do message = Factory.build(:status_message, :person => @person) - message.creator_signature = message.send(:sign_with_key,@person.key) + message.creator_signature = message.send(:sign_with_key,@person.encryption_key) message.save(:validate => false) message.verify_creator_signature.should be true end @@ -86,14 +86,14 @@ describe 'user encryption' do it 'should know if the signature is from the wrong person' do message = Factory.build(:status_message, :person => @person) message.save(:validate => false) - message.creator_signature = message.send(:sign_with_key,@person.key) + message.creator_signature = message.send(:sign_with_key,@person.encryption_key) message.person = @user message.verify_creator_signature.should be false end it 'should know if the signature is for the wrong text' do message = Factory.build(:status_message, :person => @person) - message.creator_signature = message.send(:sign_with_key,@person.key) + message.creator_signature = message.send(:sign_with_key,@person.encryption_key) message.message = 'I love VENISON' message.save(:validate => false) message.verify_creator_signature.should be false @@ -121,7 +121,7 @@ describe 'user encryption' do describe 'comments' do before do @remote_message = Factory.build(:status_message, :person => @person) - @remote_message.creator_signature = @remote_message.send(:sign_with_key,@person.key) + @remote_message.creator_signature = @remote_message.send(:sign_with_key,@person.encryption_key) @remote_message.save @message = @user.post :status_message, :message => "hi" end @@ -139,17 +139,17 @@ describe 'user encryption' do it 'should verify a comment made on a remote post by a different friend' do comment = Comment.new(:person => @person2, :text => "balls", :post => @remote_message) - comment.creator_signature = comment.send(:sign_with_key,@person2.key) + comment.creator_signature = comment.send(:sign_with_key,@person2.encryption_key) comment.verify_creator_signature.should be true comment.valid?.should be false - comment.post_creator_signature = comment.send(:sign_with_key,@person.key) + comment.post_creator_signature = comment.send(:sign_with_key,@person.encryption_key) comment.verify_post_creator_signature.should be true comment.valid?.should be true end it 'should reject comments on a remote post with only a creator sig' do comment = Comment.new(:person => @person2, :text => "balls", :post => @remote_message) - comment.creator_signature = comment.send(:sign_with_key,@person2.key) + comment.creator_signature = comment.send(:sign_with_key,@person2.encryption_key) comment.verify_creator_signature.should be true comment.verify_post_creator_signature.should be false comment.save.should be false @@ -157,7 +157,7 @@ describe 'user encryption' do it 'should receive remote comments on a user post with a creator sig' do comment = Comment.new(:person => @person2, :text => "balls", :post => @message) - comment.creator_signature = comment.send(:sign_with_key,@person2.key) + comment.creator_signature = comment.send(:sign_with_key,@person2.encryption_key) comment.save.should be true end From 0a40efdaf7c7dacf88495db0374062ed4709cc86 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 10:47:45 -0700 Subject: [PATCH 09/15] Removing unused messages --- app/controllers/sockets_controller.rb | 4 ---- config/initializers/socket.rb | 5 ----- 2 files changed, 9 deletions(-) diff --git a/app/controllers/sockets_controller.rb b/app/controllers/sockets_controller.rb index e25472d52..02c28421a 100644 --- a/app/controllers/sockets_controller.rb +++ b/app/controllers/sockets_controller.rb @@ -8,10 +8,6 @@ class SocketsController < ApplicationController puts "#{msg} connected!" end - def new_subscriber - WebSocket.subscribe - end - def outgoing(object) @_request = ActionDispatch::Request.new({}) WebSocket.push_to_clients(action_hash(object)) diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index aebf023f3..e0019b452 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -32,10 +32,5 @@ module WebSocket @channel.unsubscribe(sid) end - - def self.subscribe - @channel.subscribe{ |msg| ws.send msg } - end - end From 33a827c33a74084a4d0d7e874183eb597b229f3a Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 13:02:08 -0700 Subject: [PATCH 10/15] RS, DG; Websocket is now working again, users have a channel --- app/controllers/dashboards_controller.rb | 3 +-- app/controllers/sockets_controller.rb | 10 +++------ app/helpers/sockets_helper.rb | 5 +++-- app/models/post.rb | 5 ++++- app/views/js/_websocket_js.haml | 4 +++- config/app_config.yml | 2 +- config/initializers/socket.rb | 27 +++++++++++++++--------- spec/lib/socket_renderer_spec.rb | 24 --------------------- 8 files changed, 32 insertions(+), 48 deletions(-) delete mode 100644 spec/lib/socket_renderer_spec.rb diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index 438163fff..882cdca50 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -5,5 +5,4 @@ class DashboardsController < ApplicationController def index @posts = Post.paginate :page => params[:page], :order => 'created_at DESC' end - - end +end diff --git a/app/controllers/sockets_controller.rb b/app/controllers/sockets_controller.rb index 02c28421a..eb4f57fc9 100644 --- a/app/controllers/sockets_controller.rb +++ b/app/controllers/sockets_controller.rb @@ -2,18 +2,14 @@ class SocketsController < ApplicationController include ApplicationHelper include SocketsHelper include Rails.application.routes.url_helpers - before_filter :authenticate_user! def incoming(msg) - puts "#{msg} connected!" + puts "Got a connection to: #{msg}" end - def outgoing(object) + def outgoing(uid,object) @_request = ActionDispatch::Request.new({}) - WebSocket.push_to_clients(action_hash(object)) + WebSocket.push_to_user(uid, action_hash(uid, object)) end - def delete_subscriber(sid) - WebSocket.unsubscribe(sid) - end end diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb index 194f321ff..749de4b41 100644 --- a/app/helpers/sockets_helper.rb +++ b/app/helpers/sockets_helper.rb @@ -9,9 +9,10 @@ module SocketsHelper {:host => ""} end - def action_hash(object) + def action_hash(uid, object) begin - v = render_to_string(:partial => type_partial(object), :locals => {:post => object}) unless object.is_a? Retraction + user = User.first(:id => uid) + v = render_to_string(:partial => type_partial(object), :locals => {:post => object, :current_user => user}) unless object.is_a? Retraction rescue Exception => e Rails.logger.error("web socket view rendering failed for object #{object.inspect}.") raise e diff --git a/app/models/post.rb b/app/models/post.rb index 74fce8881..b5c61f492 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -76,7 +76,10 @@ protected end def send_to_view - SocketsController.new.outgoing(self) + people_with_permissions.each{|f| + SocketsController.new.outgoing(f.owner_id, self) if f.owner_id + } + SocketsController.new.outgoing(person.owner_id, self) if person.owner_id end def remove_from_view diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml index 768c03cb7..793aea9db 100644 --- a/app/views/js/_websocket_js.haml +++ b/app/views/js/_websocket_js.haml @@ -7,7 +7,9 @@ $(document).ready(function(){ function debug(str){ $("#debug").append("

" + str); }; - ws = new WebSocket("ws://#{request.host}:8080/"); + ws = new WebSocket("ws://#{request.host}:8080/#{CGI::escape(current_user.id.to_s)}"); + + //Attach onmessage to websocket ws.onmessage = function(evt) { var obj = jQuery.parseJSON(evt.data); debug("got a " + obj['class']); diff --git a/config/app_config.yml b/config/app_config.yml index 0c87b6b4c..02f2b1420 100644 --- a/config/app_config.yml +++ b/config/app_config.yml @@ -1,5 +1,5 @@ development: - debug: false + debug: true socket_port: 8080 pubsub_server: 'https://pubsubhubbub.appspot.com/' diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index e0019b452..711883ae3 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -3,33 +3,40 @@ require 'eventmachine' module WebSocket EM.next_tick { - initialize_channel + initialize_channels EventMachine::WebSocket.start( :host => "0.0.0.0", :port => APP_CONFIG[:socket_port], :debug =>APP_CONFIG[:debug]) do |ws| ws.onopen { - @ws = ws - sid = @channel.subscribe{ |msg| ws.send msg }#SocketsController.new.new_subscriber + + sid = self.subscribe(ws.request['Path'].gsub('/',''), ws) ws.onmessage { |msg| SocketsController.new.incoming(msg) }#@channel.push msg; puts msg} - ws.onclose { SocketsController.new.delete_subscriber(sid) } + ws.onclose { unsubscribe(ws.request['Path'].gsub('/',''), sid) } } end } - def self.initialize_channel - @channel = EM::Channel.new + def self.initialize_channels + @channels = {} end - def self.push_to_clients(html) - @channel.push(html) + def self.push_to_user(uid, data) + puts "Pushing to #{uid}" + @channels[uid.to_s].push(data) if @channels[uid.to_s] end - def self.unsubscribe(sid) - @channel.unsubscribe(sid) + def self.subscribe(uid, ws) + puts "Subscribing #{uid}" + @channels[uid] ||= EM::Channel.new + @channels[uid].subscribe{ |msg| ws.send msg } + end + + def self.unsubscribe(uid,sid) + @channels[uid].unsubscribe(sid) if @channels[uid] end end diff --git a/spec/lib/socket_renderer_spec.rb b/spec/lib/socket_renderer_spec.rb deleted file mode 100644 index 009de8b78..000000000 --- a/spec/lib/socket_renderer_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -=begin - require File.dirname(__FILE__) + '/../spec_helper' - -describe SocketRenderer do - before do - SocketRenderer.instantiate_view - @user = Factory.create(:user, :email => "bob@jones.com") - @user.profile = Factory.create(:profile, :person => @user) - end - - it 'should render a partial for a status message' do - message = Factory.create(:status_message, :person => @user) - html = SocketRenderer.view_for message - html.include? message.message - end - - it 'should prepare a class/view hash' do - message = Factory.create(:status_message, :person => @user) - - hash = SocketRenderer.view_hash(message) - hash[:class].should == "status_messages" - end -end -=end From 088da2544b0ddcdffb0ba78d1a08e172d127ef4d Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 14:11:46 -0700 Subject: [PATCH 11/15] RS, DG; We now delete channels when there is nobody subscribed to them --- config/initializers/socket.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index 711883ae3..9223b5148 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -26,17 +26,26 @@ module WebSocket def self.push_to_user(uid, data) puts "Pushing to #{uid}" - @channels[uid.to_s].push(data) if @channels[uid.to_s] + @channels[uid.to_s][0].push(data) if @channels[uid.to_s] end def self.subscribe(uid, ws) puts "Subscribing #{uid}" - @channels[uid] ||= EM::Channel.new - @channels[uid].subscribe{ |msg| ws.send msg } + self.ensure_channel(uid) + @channels[uid][0].subscribe{ |msg| ws.send msg } + @channels[uid][1] += 1 + end + + def self.ensure_channel(uid) + @channels[uid] ||= [EM::Channel.new, 0 ] end def self.unsubscribe(uid,sid) - @channels[uid].unsubscribe(sid) if @channels[uid] + @channels[uid][0].unsubscribe(sid) if @channels[uid] + @channels[uid][1] -= 1 + if @channels[uid][1] <= 0 + @channels[uid] = nil + end end end From 614c8c72baeb51acdf257c377d14b9f42106a9f3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 14:27:17 -0700 Subject: [PATCH 12/15] RS, DG; Log files should now rotate --- config/app_config.yml | 2 +- config/initializers/logging.rb | 2 ++ config/initializers/socket.rb | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 config/initializers/logging.rb diff --git a/config/app_config.yml b/config/app_config.yml index 02f2b1420..0c87b6b4c 100644 --- a/config/app_config.yml +++ b/config/app_config.yml @@ -1,5 +1,5 @@ development: - debug: true + debug: false socket_port: 8080 pubsub_server: 'https://pubsubhubbub.appspot.com/' diff --git a/config/initializers/logging.rb b/config/initializers/logging.rb new file mode 100644 index 000000000..447ec5c17 --- /dev/null +++ b/config/initializers/logging.rb @@ -0,0 +1,2 @@ +Rails.logger = Logger.new( + Rails.root.join("log",Rails.env + ".log"),3,5*1024*1024) diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index 9223b5148..068c50e14 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -25,12 +25,13 @@ module WebSocket end def self.push_to_user(uid, data) - puts "Pushing to #{uid}" + puts @channels.size + Rails.logger.info "Pushing to #{uid}" @channels[uid.to_s][0].push(data) if @channels[uid.to_s] end def self.subscribe(uid, ws) - puts "Subscribing #{uid}" + puts "Subscribing socket to #{User.first(:id => uid).email}" self.ensure_channel(uid) @channels[uid][0].subscribe{ |msg| ws.send msg } @channels[uid][1] += 1 @@ -41,6 +42,7 @@ module WebSocket end def self.unsubscribe(uid,sid) + puts "Unsubscribing socket #{sid} from #{User.first(:id => uid).email}" @channels[uid][0].unsubscribe(sid) if @channels[uid] @channels[uid][1] -= 1 if @channels[uid][1] <= 0 From c14bb5a4f875b0d9bcb301d5f423a0a17efd42d6 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 14:39:37 -0700 Subject: [PATCH 13/15] Changed info logging to debug logging almost everywhere --- app/controllers/dev_utilities_controller.rb | 38 ++++++++++----------- app/controllers/publics_controller.rb | 2 +- app/controllers/requests_controller.rb | 2 +- app/models/photo.rb | 2 -- app/models/post.rb | 4 +-- app/models/retraction.rb | 2 +- app/models/user.rb | 6 ++-- config/initializers/socket.rb | 9 +++-- lib/diaspora/parser.rb | 6 ++-- lib/diaspora/webhooks.rb | 4 +-- lib/encryptable.rb | 6 ++-- 11 files changed, 39 insertions(+), 42 deletions(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index f45be992b..d1b2d9995 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -3,21 +3,21 @@ class DevUtilitiesController < ApplicationController include ApplicationHelper def warzombie render :nothing => true - if User.owner.email == "tom@tom.joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil - StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => User.owner) - Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => User.owner ) - StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => User.owner, :created_at => Time.now-930) - StatusMessage.create(:message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :person => User.owner, :created_at => Time.now-43990) - StatusMessage.create(:message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :person => User.owner, :created_at => Time.now-4390) - Bookmark.create( :title => "Reddit", :link => "http://reddit.com", :person => User.owner, :created_at => Time.now-54390) - Blog.create(:title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "

The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.

also i can tell it won’t be long and also happy summer imaginary constructs -mumblelard

", :person => User.owner, :created_at => Time.now-3090) - StatusMessage.create(:message => "Commercials for IE make me SO MAD and my friends just don't get why.", :person => User.owner, :created_at => Time.now-30900) - Bookmark.create(:title => "Zombo.com", :link => "http://zombo.com", :person => User.owner, :created_at => Time.now-9090) - StatusMessage.create(:message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :person => User.owner, :created_at => Time.now-590000) - StatusMessage.create(:message => "Mmm. Friday night. Acknowledged.", :person => User.owner, :created_at => Time.now-503900) - StatusMessage.create(:message => "Getting a universal remote is the epitome of laziness, I do declare.", :person => User.owner, :created_at => Time.now-4400) - StatusMessage.create(:message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :person => User.owner, :created_at => Time.now-400239) - StatusMessage.create(:message => "A cool, cool morning for once.", :person => User.owner, :created_at => Time.now-150000) + if current_user.email == "tom@tom.joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil + StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => current_user) + Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => current_user ) + StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => current_user, :created_at => Time.now-930) + StatusMessage.create(:message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :person => current_user, :created_at => Time.now-43990) + StatusMessage.create(:message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :person => current_user, :created_at => Time.now-4390) + Bookmark.create( :title => "Reddit", :link => "http://reddit.com", :person => current_user, :created_at => Time.now-54390) + Blog.create(:title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "

The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.

also i can tell it won’t be long and also happy summer imaginary constructs -mumblelard

", :person => current_user, :created_at => Time.now-3090) + StatusMessage.create(:message => "Commercials for IE make me SO MAD and my friends just don't get why.", :person => current_user, :created_at => Time.now-30900) + Bookmark.create(:title => "Zombo.com", :link => "http://zombo.com", :person => current_user, :created_at => Time.now-9090) + StatusMessage.create(:message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :person => current_user, :created_at => Time.now-590000) + StatusMessage.create(:message => "Mmm. Friday night. Acknowledged.", :person => current_user, :created_at => Time.now-503900) + StatusMessage.create(:message => "Getting a universal remote is the epitome of laziness, I do declare.", :person => current_user, :created_at => Time.now-4400) + StatusMessage.create(:message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :person => current_user, :created_at => Time.now-400239) + StatusMessage.create(:message => "A cool, cool morning for once.", :person => current_user, :created_at => Time.now-150000) end end @@ -25,10 +25,10 @@ def warzombie render :nothing => true bkr_info = backer_info - if User.owner.email == "tom@tom.joindiaspora.com" && User.owner.friends.first.nil? + if current_user.email == "tom@tom.joindiaspora.com" && current_user.friends.first.nil? bkr_info.each do |backer| - logger.info "Zombefriending #{backer['given_name']} #{backer['family_name']}" - User.owner.send_friend_request_to("http://#{backer['username']}.joindiaspora.com/") + logger.debug "Zombefriending #{backer['given_name']} #{backer['family_name']}" + current_user.send_friend_request_to("http://#{backer['username']}.joindiaspora.com/") end end end @@ -36,7 +36,7 @@ def warzombie def zombiefriendaccept render :nothing => true Request.all.each{|r| - User.owner.accept_friend_request(r.id) + current_user.accept_friend_request(r.id) } end diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index 0582e4571..1b05532f9 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -18,7 +18,7 @@ class PublicsController < ApplicationController end def receive - Rails.logger.info "PublicsController has received: #{params[:xml]}" + Rails.logger.debug "PublicsController has received: #{params[:xml]}" store_objects_from_xml params[:xml] render :nothing => true end diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 39f9c8376..38714034f 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -26,7 +26,7 @@ class RequestsController < ApplicationController def create rel_hash = relationship_flow(params[:request][:destination_url]) - Rails.logger.info("Sending request: #{rel_hash}") + Rails.logger.debug("Sending request: #{rel_hash}") @request = current_user.send_request(rel_hash) if @request diff --git a/app/models/photo.rb b/app/models/photo.rb index e57e2f78d..c06ceb62c 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -41,11 +41,9 @@ class Photo < Post end def remote_photo= remote_path - Rails.logger.info("Setting remote photo with id #{id}") @remote_photo = remote_path image.download! remote_path image.store! - Rails.logger.info("Setting remote photo with id #{id}") end def ensure_user_picture diff --git a/app/models/post.rb b/app/models/post.rb index b5c61f492..0768a91c8 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -59,10 +59,10 @@ class Post end def log_inspection - Rails.logger.info self.inspect + Rails.logger.debug self.inspect end def log_save_inspection - Rails.logger.info "After saving, object is:" + Rails.logger.debug "After saving, object is:" log_inspection end diff --git a/app/models/retraction.rb b/app/models/retraction.rb index 6ade21ec7..dff72b767 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -27,7 +27,7 @@ class Retraction def perform begin return unless signature_valid? - Rails.logger.info("Retracting #{self.type} id: #{self.post_id}") + Rails.logger.debug("Retracting #{self.type} id: #{self.post_id}") self.type.constantize.destroy(self.post_id) rescue NameError Rails.logger.info("Retraction for unknown type recieved.") diff --git a/app/models/user.rb b/app/models/user.rb index e2d1a5773..7a73971ab 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -64,18 +64,18 @@ class User end def receive_friend_request(friend_request) - Rails.logger.info("receiving friend request #{friend_request.to_json}") + Rails.logger.debug("receiving friend request #{friend_request.to_json}") friend_request.person.serialized_key = friend_request.exported_key if Request.where(:callback_url => friend_request.callback_url).first activate_friend friend_request.person - Rails.logger.info("#{self.real_name}'s friend request has been accepted") + Rails.logger.debug("#{self.real_name}'s friend request has been accepted") friend_request.destroy else friend_request.person.save pending_friends << friend_request.person save - Rails.logger.info("#{self.real_name} has received a friend request") + Rails.logger.debug("#{self.real_name} has received a friend request") friend_request.save end end diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index 068c50e14..2fec8a328 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -25,13 +25,12 @@ module WebSocket end def self.push_to_user(uid, data) - puts @channels.size - Rails.logger.info "Pushing to #{uid}" + Rails.logger.debug "Websocketing to #{uid}" @channels[uid.to_s][0].push(data) if @channels[uid.to_s] end def self.subscribe(uid, ws) - puts "Subscribing socket to #{User.first(:id => uid).email}" + Rails.logger.debug "Subscribing socket to #{User.first(:id => uid).email}" self.ensure_channel(uid) @channels[uid][0].subscribe{ |msg| ws.send msg } @channels[uid][1] += 1 @@ -42,11 +41,11 @@ module WebSocket end def self.unsubscribe(uid,sid) - puts "Unsubscribing socket #{sid} from #{User.first(:id => uid).email}" + Rails.logger.debug "Unsubscribing socket #{sid} from #{User.first(:id => uid).email}" @channels[uid][0].unsubscribe(sid) if @channels[uid] @channels[uid][1] -= 1 if @channels[uid][1] <= 0 - @channels[uid] = nil + @channels.delete(uid) end end diff --git a/lib/diaspora/parser.rb b/lib/diaspora/parser.rb index 265e44912..9feb07cdc 100644 --- a/lib/diaspora/parser.rb +++ b/lib/diaspora/parser.rb @@ -45,16 +45,16 @@ module Diaspora def store_objects_from_xml(xml) objects = parse_objects_from_xml(xml) objects.each do |p| - Rails.logger.info("Receiving object:\n#{p.inspect}") + Rails.logger.debug("Receiving object:\n#{p.inspect}") if p.is_a? Retraction - Rails.logger.info "Got a retraction for #{p.post_id}" + Rails.logger.debug "Got a retraction for #{p.post_id}" p.perform elsif p.is_a? Request User.owner.receive_friend_request(p) elsif p.is_a? Profile p.save elsif p.respond_to?(:person) && !(p.person.nil?) && !(p.person.is_a? User) - Rails.logger.info("Saving object with success: #{p.save}") + Rails.logger.debug("Saving object with success: #{p.save}") end end end diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index 929dff515..423800459 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -20,7 +20,7 @@ module Diaspora unless recipients.empty? recipients.map!{|x| x = x.url + "receive/"} xml = Post.build_xml_for(self) - Rails.logger.info("Adding xml for #{self} to message queue to #{recipients}") + Rails.logger.debug("Adding xml for #{self} to message queue to #{recipients}") @@queue.add_post_request( recipients, xml ) end @@queue.process @@ -29,7 +29,7 @@ module Diaspora def push_to_url(url) hook_url = url + "receive/" xml = self.class.build_xml_for(self) - Rails.logger.info("Adding xml for #{self} to message queue to #{url}") + Rails.logger.debug("Adding xml for #{self} to message queue to #{url}") @@queue.add_post_request( hook_url, xml ) @@queue.process end diff --git a/lib/encryptable.rb b/lib/encryptable.rb index 6925b4cd0..850499bff 100644 --- a/lib/encryptable.rb +++ b/lib/encryptable.rb @@ -17,9 +17,9 @@ Rails.logger.info("Verifying sig on #{signable_string} but #{person.real_name} did not sign") return false end - Rails.logger.info("Verifying sig on #{signable_string} from person #{person.real_name}") + Rails.logger.debug("Verifying sig on #{signable_string} from person #{person.real_name}") validity = person.encryption_key.verify "SHA", Base64.decode64(signature), signable_string - Rails.logger.info("Validity: #{validity}") + Rails.logger.debug("Validity: #{validity}") validity end @@ -29,7 +29,7 @@ end def sign_with_key(key) - Rails.logger.info("Signing #{signable_string}") + Rails.logger.debug("Signing #{signable_string}") Base64.encode64(key.sign "SHA", signable_string) end From 039ec0d06e00307e32021610f5c03b98664c39e4 Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 15:05:54 -0700 Subject: [PATCH 14/15] warzombie is now more friendly --- app/controllers/dev_utilities_controller.rb | 28 ++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index d1b2d9995..7a1021b09 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -4,20 +4,20 @@ class DevUtilitiesController < ApplicationController def warzombie render :nothing => true if current_user.email == "tom@tom.joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil - StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => current_user) - Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => current_user ) - StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => current_user, :created_at => Time.now-930) - StatusMessage.create(:message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :person => current_user, :created_at => Time.now-43990) - StatusMessage.create(:message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :person => current_user, :created_at => Time.now-4390) - Bookmark.create( :title => "Reddit", :link => "http://reddit.com", :person => current_user, :created_at => Time.now-54390) - Blog.create(:title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "

The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.

also i can tell it won’t be long and also happy summer imaginary constructs -mumblelard

", :person => current_user, :created_at => Time.now-3090) - StatusMessage.create(:message => "Commercials for IE make me SO MAD and my friends just don't get why.", :person => current_user, :created_at => Time.now-30900) - Bookmark.create(:title => "Zombo.com", :link => "http://zombo.com", :person => current_user, :created_at => Time.now-9090) - StatusMessage.create(:message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :person => current_user, :created_at => Time.now-590000) - StatusMessage.create(:message => "Mmm. Friday night. Acknowledged.", :person => current_user, :created_at => Time.now-503900) - StatusMessage.create(:message => "Getting a universal remote is the epitome of laziness, I do declare.", :person => current_user, :created_at => Time.now-4400) - StatusMessage.create(:message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :person => current_user, :created_at => Time.now-400239) - StatusMessage.create(:message => "A cool, cool morning for once.", :person => current_user, :created_at => Time.now-150000) + current_user.post(:status_message, :message => "There's a bomb in the lasagna!?") + current_user.post(:bookmark, :title => "xkcd", :link => "http://xkcd.com/743/" ) + current_user.post(:status_message, :message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :created_at => Time.now-930) + current_user.post(:status_message, :message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :created_at => Time.now-43990) + current_user.post(:status_message, :message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :created_at => Time.now-4390) + current_user.post(:bookmark, :title => "Reddit", :link => "http://reddit.com", :created_at => Time.now-54390) + current_user.post(:blog, :title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "

The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.

also i can tell it won’t be long and also happy summer imaginary constructs -mumblelard

", :created_at => Time.now-3090) + current_user.post(:status_message, :message => "Commercials for IE make me SO MAD and my friends just don't get why.", :created_at => Time.now-30900) + current_user.post(:bookmark, :title => "Zombo.com", :link => "http://zombo.com", :created_at => Time.now-9090) + current_user.post(:status_message, :message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :created_at => Time.now-590000) + current_user.post(:status_message, :message => "Mmm. Friday night. Acknowledged.", :created_at => Time.now-503900) + current_user.post(:status_message, :message => "Getting a universal remote is the epitome of laziness, I do declare.", :created_at => Time.now-4400) + current_user.post(:status_message, :message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :created_at => Time.now-400239) + current_user.post(:status_message, :message => "A cool, cool morning for once.", :created_at => Time.now-150000) end end From aebe7b97c0835fc19e39639f323e73564ce7fccd Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 9 Aug 2010 15:58:53 -0700 Subject: [PATCH 15/15] DG RS; added groups. can't delete, but can make new ones --- app/controllers/application_controller.rb | 1 + app/controllers/groups_controller.rb | 44 +++++++++++++++++++++++ app/models/group.rb | 12 +++++++ app/models/user.rb | 9 ++++- app/views/groups/_new_group.haml | 6 ++++ app/views/groups/edit.html.haml | 25 +++++++++++++ app/views/groups/new.html.haml | 14 ++++++++ app/views/shared/_group_nav.haml | 9 +++-- config/routes.rb | 1 + public/stylesheets/application.css | 2 ++ public/stylesheets/sass/application.sass | 2 ++ spec/models/group_spec.rb | 32 +++++++++++++++++ 12 files changed, 151 insertions(+), 6 deletions(-) create mode 100644 app/controllers/groups_controller.rb create mode 100644 app/models/group.rb create mode 100644 app/views/groups/_new_group.haml create mode 100644 app/views/groups/edit.html.haml create mode 100644 app/views/groups/new.html.haml create mode 100644 spec/models/group_spec.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bb091706b..a36a8c873 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,6 +16,7 @@ class ApplicationController < ActionController::Base end def set_friends_and_status + @groups = current_user.groups @friends = current_user.friends if current_user @latest_status_message = StatusMessage.newest_for(current_user) if current_user end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb new file mode 100644 index 000000000..e12809fb6 --- /dev/null +++ b/app/controllers/groups_controller.rb @@ -0,0 +1,44 @@ +class GroupsController < ApplicationController + before_filter :authenticate_user! + + def create + @group = current_user.group(params[:group]) + + if @group.created_at + flash[:notice] = "Successfully created group." + redirect_to root_url + else + render :action => 'new' + end + end + + def new + @group = Group.new + end + + def destroy + @group = Group.first(:id => params[:id]) + @group.destroy + flash[:notice] = "Successfully destroyed group." + redirect_to groups_url + end + + def show + @group = Group.first(:id => params[:id]) + end + + def edit + @group = Group.first(:id => params[:id]) + end + + def update + @group = Group.first(:id => params[:id]) + if @group.update_attributes(params[:group]) + flash[:notice] = "Successfully updated group." + redirect_to @group + else + render :action => 'edit' + end + end + +end diff --git a/app/models/group.rb b/app/models/group.rb new file mode 100644 index 000000000..885e471cc --- /dev/null +++ b/app/models/group.rb @@ -0,0 +1,12 @@ +class Group + include MongoMapper::Document + + key :name, String + + many :people, :class_name => 'Person' + belongs_to :user, :class_name => 'User' + + timestamps! + +end + diff --git a/app/models/user.rb b/app/models/user.rb index 7a73971ab..794c7970a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -12,6 +12,8 @@ class User many :friends, :in => :friend_ids, :class_name => 'Person' many :pending_friends, :in => :pending_friend_ids, :class_name => 'Person' + many :groups, :class_name => 'Group' + before_validation_on_create :assign_key before_validation :do_bad_things @@ -28,9 +30,14 @@ class User "#{person.profile.first_name.to_s} #{person.profile.last_name.to_s}" end + ######### Groups ###################### + def group( opts = {} ) + opts[:user] = self + Group.create(opts) + end - ######### Friend Requesting + ######### Friend Requesting ########### def send_friend_request_to(friend_url) unless self.friends.find{ |x| x.url == friend_url} p = Request.instantiate(:to => friend_url, :from => self.person) diff --git a/app/views/groups/_new_group.haml b/app/views/groups/_new_group.haml new file mode 100644 index 000000000..755223fd8 --- /dev/null +++ b/app/views/groups/_new_group.haml @@ -0,0 +1,6 @@ += form_for Group.new do |f| + = f.error_messages + %p + = f.label :name + = f.text_field :name + = f.submit 'create', :class => 'button' diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml new file mode 100644 index 000000000..461bff1db --- /dev/null +++ b/app/views/groups/edit.html.haml @@ -0,0 +1,25 @@ +%h1.big_text + .back + = link_to "⇧ #{@group.name}", @group + + = "Editing #{@group.name}" + +.sub_header + ="updated #{how_long_ago(@group)}" + +- form_for @group do |a| + = a.error_messages + %p + = a.text_field :name + + #submit_block + = link_to "Cancel", root_path + or + = a.submit + +.button.delete + = link_to 'Delete Album', @group, :confirm => 'Are you sure?', :method => :delete + +#content_bottom + .back + = link_to "⇧ #{@group.name}", @group diff --git a/app/views/groups/new.html.haml b/app/views/groups/new.html.haml new file mode 100644 index 000000000..c899fd9ae --- /dev/null +++ b/app/views/groups/new.html.haml @@ -0,0 +1,14 @@ +%h1.big_text + =link_to 'groups', groups_path + >> + new group + += form_for @group do |f| + = f.error_messages + %p + = f.label :name + = f.text_field :name + %p + = f.submit + +%p= link_to "Back to List", groups_path diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index 9ba2f6d67..c61712038 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -1,14 +1,13 @@ #group %ul - %li.other_presidents= link_to "OTHER PRESIDENTS", root_path(:g => "other_presidents") - %li.ostatus= link_to "OSTATUS", ostatus_path(:g => "ostatus") - %li.new_circle= link_to "NEW CIRCLE", "#" + - for group in @groups + %li= link_to group.name, group_path(group) + + %li.new_group= link_to "NEW GROUP", new_group_path #friend_pictures - for friend in @friends = person_image_link(friend) - -for author in @subscribed_persons - = link_to (image_tag author.avatar_thumbnail, :class => "person_picture"), author_path(author) .add_new = link_to "+", requests_path diff --git a/config/routes.rb b/config/routes.rb index 3726f5bf4..8d0cd5c01 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,6 +8,7 @@ Diaspora::Application.routes.draw do |map| resources :requests resources :photos resources :albums + resources :groups match "/images/files/*path" => "gridfs#serve" diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 157423bba..ad207bf50 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -70,6 +70,7 @@ header { color: #555555; background-color: #2b2726; background-color: black; + background-color: white; border-bottom: 3px solid #333333; padding: 6px 0; padding-top: 0; } @@ -436,6 +437,7 @@ h1.big_text { margin-right: 10px; } #group ul > li.selected, #group ul > li.selected a { color: white; + color: black; font-weight: bold; font-size: 18px; } #group a { diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index df7530904..75b14624e 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -75,6 +75,7 @@ header :background :color #2B2726 :color #000 + :color #fff :border :bottom 3px solid #333 :padding 6px 0 @@ -546,6 +547,7 @@ h1.big_text &.selected, &.selected a :color #fff + :color #000 :font :weight bold :size 18px diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb new file mode 100644 index 000000000..a40a9be11 --- /dev/null +++ b/spec/models/group_spec.rb @@ -0,0 +1,32 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Group do + before do + @user = Factory.create(:user) + @friend = Factory.create(:person) + end + + describe 'creation' do + it 'should have a name' do + group = @user.group(:name => 'losers') + group.name.should == "losers" + end + end + + describe 'querying' do + before do + @group = @user.group(:name => 'losers', :people => [@friend]) + end + + it 'belong to a user' do + @group.user.id.should == @user.id + @user.groups.size.should == 1 + @user.groups.first.id.should == @group.id + end + + it 'should have people' do + @group.people.all.include?(@friend).should be true + @group.people.size.should == 1 + end + end +end