diff --git a/Gemfile b/Gemfile index 137303975..052aaa7bc 100644 --- a/Gemfile +++ b/Gemfile @@ -102,7 +102,7 @@ end group :test do gem 'mysql2', '0.2.6' - gem 'pg' + #gem 'pg' gem 'factory_girl_rails' gem 'fixture_builder', '0.2.2' gem 'selenium-webdriver', '2.4' diff --git a/Gemfile.lock b/Gemfile.lock index 091cdf07d..1e8a31b37 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -319,7 +319,6 @@ GEM oa-openid (= 0.2.6) open4 (1.1.0) orm_adapter (0.0.5) - pg (0.11.0) polyglot (0.3.2) pyu-ruby-sasl (0.0.3.3) rack (1.2.3) @@ -499,7 +498,6 @@ DEPENDENCIES oauth2-provider (= 0.0.16) ohai (= 0.5.8) omniauth (= 0.2.6) - pg rails (= 3.0.9) rails-i18n rcov diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index 9b7c7bde5..e4891b2da 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -1,5 +1,10 @@ WebSocketReceiver.processComment("<%= @comment.post.guid %>", - "<%= @comment.guid%>", - "<%= escape_javascript(render(:partial => 'comments/comment', :locals => { :comment => @comment, :person => current_user.person}))%>", - false); + "<%= @comment.guid%>", + "<%= escape_javascript(render(:partial => 'comments/comment', :locals => { :comment => @comment, :person => current_user.person}))%>", + false); +Diaspora.page + .stream + .streamElements["<%= @comment.post.guid %>"] + .commentStream + .instantiateCommentWidgets(); \ No newline at end of file diff --git a/app/views/conversations/show.js.erb b/app/views/conversations/show.js.erb index f13dbe3e4..767b22ad1 100644 --- a/app/views/conversations/show.js.erb +++ b/app/views/conversations/show.js.erb @@ -4,4 +4,4 @@ $(".stream_element", "#conversation_inbox").removeClass('selected'); $(".stream_element[data-guid='<%= @conversation.id %>']", "#conversation_inbox").addClass('selected'); $(".stream_element[data-guid='<%= @conversation.id %>']", "#conversation_inbox").find(".unread_message_count").remove() -Diaspora.Page.timeAgo.updateTimeAgo(); +Diaspora.page.timeAgo.updateTimeAgo(); diff --git a/config/assets.yml b/config/assets.yml index f6bcd4a06..31141f6ed 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -42,6 +42,7 @@ javascripts: - public/javascripts/widgets/stream-element.js - public/javascripts/widgets/comment-stream.js - public/javascripts/widgets/comment-toggler.js + - public/javascripts/widgets/comment-form.js - public/javascripts/widgets/comment.js - public/javascripts/widgets/likes.js - public/javascripts/widgets/hovercard.js @@ -50,6 +51,7 @@ javascripts: - public/javascripts/view.js - public/javascripts/stream.js - public/javascripts/content-updater.js + - public/javascripts/aspects-dropdown.js - public/javascripts/contact-edit.js - public/javascripts/contact-list.js - public/javascripts/aspect-sorting.js diff --git a/db/schema.rb b/db/schema.rb index 5f7edde5f..f6a25ff19 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -394,7 +394,8 @@ ActiveRecord::Schema.define(:version => 20110818212541) do t.string "language" t.string "email", :default => "", :null => false t.string "encrypted_password", :limit => 128, :default => "", :null => false - t.string "invitation_token", :limit => 60 + t.string "password_salt", :default => "", :null => false + t.string "invitation_token", :limit => 20 t.datetime "invitation_sent_at" t.string "reset_password_token" t.string "remember_token" diff --git a/public/javascripts/aspect-filters.js b/public/javascripts/aspect-filters.js index 258bc422e..536ba7da6 100644 --- a/public/javascripts/aspect-filters.js +++ b/public/javascripts/aspect-filters.js @@ -152,7 +152,7 @@ var AspectFilters = { // reinit listeners on stream photozone.html(photos_html); - Diaspora.Page.publish("stream/reloaded"); + Diaspora.page.publish("stream/reloaded"); // fade contents back in AspectFilters.fadeIn(); diff --git a/public/javascripts/aspects-dropdown.js b/public/javascripts/aspects-dropdown.js index 4bd65eb2f..ce6169fbf 100644 --- a/public/javascripts/aspects-dropdown.js +++ b/public/javascripts/aspects-dropdown.js @@ -9,25 +9,24 @@ var AspectsDropdown = { if (number == 0) { button.removeClass(inAspectClass); - replacement = Diaspora.widgets.i18n.t("aspect_dropdown.toggle.zero"); + replacement = Diaspora.I18n.t("aspect_dropdown.toggle.zero"); }else if (number == 1) { button.addClass(inAspectClass); replacement = dropdown.find(".selected").first().text(); }else if (number < 3) { - replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.few', { count: number.toString()}) + replacement = Diaspora.I18n.t('aspect_dropdown.toggle.few', { count: number.toString()}) }else if (number > 3) { - replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.many', { count: number.toString()}) + replacement = Diaspora.I18n.t('aspect_dropdown.toggle.many', { count: number.toString()}) }else { //the above one are a tautology, but I want to have them here once for once we figure out a neat way i18n them - replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.other', { count: number.toString()}) + replacement = Diaspora.I18n.t('aspect_dropdown.toggle.other', { count: number.toString()}) } button.html(replacement + ' ▼'); }, - toggleCheckbox: - function(check){ - check.toggleClass('selected'); - }, + toggleCheckbox: function(check) { + check.toggleClass('selected'); + } }; diff --git a/public/javascripts/contact-edit.js b/public/javascripts/contact-edit.js index db12c6038..756323116 100644 --- a/public/javascripts/contact-edit.js +++ b/public/javascripts/contact-edit.js @@ -5,7 +5,7 @@ var ContactEdit = { init: function(){ $.extend(ContactEdit, AspectsDropdown); - $('.dropdown.aspect_membership .dropdown_list > li, .dropdown.inviter .dropdown_list >li').live('click', function(evt){ + $('.dropdown.aspect_membership .dropdown_list > li, .dropdown.inviter .dropdown_list > li').live('click', function(evt){ ContactEdit.processClick($(this), evt); }); // $('.button.resend').live('click', function(evt){ @@ -24,19 +24,17 @@ var ContactEdit = { if (number == 0) { button.removeClass("in_aspects"); - replacement = Diaspora.widgets.i18n.t("aspect_dropdown.toggle.zero"); + replacement = Diaspora.I18n.t("aspect_dropdown.toggle.zero"); }else if (number == 1) { button.addClass("in_aspects"); replacement = dropdown.find(".selected").first().text(); }else if (number < 3) { - replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.few', { count: number.toString()}) + replacement = Diaspora.I18n.t('aspect_dropdown.toggle.few', { count: number.toString()}) }else if (number > 3) { - replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.many', { count: number.toString()}) + replacement = Diaspora.I18n.t('aspect_dropdown.toggle.many', { count: number.toString()}) }else { //the above one are a tautology, but I want to have them here once for once we figure out a neat way i18n them - replacement = Diaspora.widgets.i18n.t('aspect_dropdown.toggle.other', { count: number.toString()}) - } - else { + replacement = Diaspora.I18n.t('aspect_dropdown.toggle.other', { count: number.toString()}) ContactEdit.toggleAspectMembership(li, evt); } }, @@ -61,6 +59,18 @@ var ContactEdit = { } }, + processClick: function(li, evt){ + var dropdown = li.closest('.dropdown'); + li.addClass('loading'); + if (dropdown.hasClass('inviter')) { + ContactEdit.inviteFriend(li, evt); + dropdown.html('sending, please wait...'); + } + else { + ContactEdit.toggleAspectMembership(li, evt); + } + }, + toggleAspectMembership: function(li, evt) { var button = li.find('.button'); if(button.hasClass('disabled') || li.hasClass('newItem')){ return; } @@ -73,7 +83,8 @@ var ContactEdit = { "person_id": li.parent().data("person_id"), "_method": (selected) ? "DELETE" : "POST" }, function(aspectMembership) { - ContactEdit.toggleCheckbox(checkbox); + li.removeClass("loading"); + ContactEdit.toggleCheckbox(li); ContactEdit.updateNumber(li.closest(".dropdown_list"), li.parent().data("person_id"), aspectMembership.aspect_ids.length); Diaspora.page.publish("aspectDropdown/updated", [li.parent().data("person_id"), li.parents(".dropdown").parent(".right").html()]); diff --git a/public/javascripts/diaspora.js b/public/javascripts/diaspora.js index 4683c2d6b..6c4ff50fc 100644 --- a/public/javascripts/diaspora.js +++ b/public/javascripts/diaspora.js @@ -64,7 +64,10 @@ $(function() { - if(typeof Diaspora.Pages[Diaspora.Page] === "undefined") { throw new Error("Page " + Diaspora.Page + " does not exist"); } + if (typeof Diaspora.Pages[Diaspora.Page] === "undefined") { + Diaspora.page = Diaspora.EventBroker.extend(Diaspora.BaseWidget); + return; + } var Page = Diaspora.Pages[Diaspora.Page]; $.extend(Page.prototype, Diaspora.EventBroker.extend(Diaspora.BaseWidget)); diff --git a/public/javascripts/inbox.js b/public/javascripts/inbox.js index d7e9d3c44..1ca18eb87 100644 --- a/public/javascripts/inbox.js +++ b/public/javascripts/inbox.js @@ -7,7 +7,7 @@ $(document).ready(function(){ $('a.conversation').live('click', function(){ $.getScript(this.href, function() { - Diaspora.Page.directionDetector.updateBinds(); + Diaspora.page.directionDetector.updateBinds(); }); history.pushState(null, "", this.href); @@ -32,7 +32,7 @@ $(document).ready(function(){ $(window).bind("popstate", function(){ if (location.href.match(/conversations\/\d+/) !== null) { $.getScript(location.href, function() { - Diaspora.Page.directionDetector.updateBinds(); + Diaspora.page.directionDetector.updateBinds(); }); return false; } diff --git a/public/javascripts/pages/aspects-index.js b/public/javascripts/pages/aspects-index.js index 100d8d83d..2438b9ad8 100644 --- a/public/javascripts/pages/aspects-index.js +++ b/public/javascripts/pages/aspects-index.js @@ -2,7 +2,7 @@ Diaspora.Pages.AspectsIndex = function() { var self = this; this.subscribe("page/ready", function(evt, document) { - self.stream = self.instantiate("Stream", document.find("#main_stream")); + self.stream = self.instantiate("Stream", document.find("#aspect_stream_container")); self.header = self.instantiate("Header", document.find("header")); self.hoverCard = self.instantiate("HoverCard", document.find("#hovercard")); diff --git a/public/javascripts/pages/conversations-index.js b/public/javascripts/pages/conversations-index.js index 1665fe554..fc36e1016 100644 --- a/public/javascripts/pages/conversations-index.js +++ b/public/javascripts/pages/conversations-index.js @@ -3,5 +3,6 @@ Diaspora.Pages.ConversationsIndex = function() { this.subscribe("page/ready", function(evt, body) { self.header = self.instantiate("Header", body.find("header")); + self.directionDetector = self.instantiate("DirectionDetector"); }); }; \ No newline at end of file diff --git a/public/javascripts/pages/users-edit.js b/public/javascripts/pages/users-edit.js new file mode 100644 index 000000000..c013c2a51 --- /dev/null +++ b/public/javascripts/pages/users-edit.js @@ -0,0 +1,7 @@ +Diaspora.Pages.UsersEdit = function() { + var self = this; + + this.subscribe("page/ready", function(evt, body) { + self.header = self.instantiate("Header", body.find("header")); + }); +}; \ No newline at end of file diff --git a/public/javascripts/widgets/comment-form.js b/public/javascripts/widgets/comment-form.js index a2e5a563f..0873bef9e 100644 --- a/public/javascripts/widgets/comment-form.js +++ b/public/javascripts/widgets/comment-form.js @@ -3,20 +3,17 @@ var self = this; this.subscribe("widget/ready", function(evt, commentFormElement) { - $.extend({ - commentFormElement: commentFormElement + $.extend(self, { + commentFormElement: commentFormElement, + commentInput: commentFormElement.find("textarea") }); - self.commentFormElement.submit(self.submitComment); + self.commentInput.focus(self.showCommentForm); }); - this.submitComment = function(evt) { - evt.preventDefault(); - - $.post(self.commentFormElement.attr("action"), self.commentFormElement.serialize(), function() { - - }); - } + this.showCommentForm = function() { + self.commentFormElement.addClass("open"); + }; }; Diaspora.Widgets.CommentForm = CommentForm; diff --git a/public/javascripts/widgets/comment-stream.js b/public/javascripts/widgets/comment-stream.js index 9b04d38f9..16475eb5c 100644 --- a/public/javascripts/widgets/comment-stream.js +++ b/public/javascripts/widgets/comment-stream.js @@ -6,8 +6,7 @@ $.extend(self, { commentStream: commentStream, commentToggler: self.instantiate("CommentToggler", commentStream), - commentForm: self.instantiate("CommentForm", commentStream.find(".new_comment_form")), - comments: [] + comments: {} }); self.commentStream.delegate(".new_comment", "ajax:failure", function() { @@ -41,10 +40,10 @@ }); this.instantiateCommentWidgets = function() { - self.comments = []; + self.comments = {}; - $.each(self.commentStream.find("li.comment"), function(index, element) { - self.comments.push(self.instantiate("Comment", $(element))); + $.each(self.commentStream.find("li.comment"), function() { + self.comments[this.id] = self.instantiate("Comment", $(this)); }); }; }; diff --git a/public/javascripts/widgets/infinite-scroll.js b/public/javascripts/widgets/infinite-scroll.js index 71ab07227..6aebb05fd 100644 --- a/public/javascripts/widgets/infinite-scroll.js +++ b/public/javascripts/widgets/infinite-scroll.js @@ -43,7 +43,7 @@ this.reInitialize = function() { $("#main_stream").infinitescroll("destroy"); - self.trigger("widget/ready"); + self.publish("widget/ready"); }; this.globalSubscribe("stream/reloaded", self.reInitialize, this); diff --git a/public/javascripts/widgets/notifications-badge.js b/public/javascripts/widgets/notifications-badge.js index 4977626a3..6d3f5d19e 100644 --- a/public/javascripts/widgets/notifications-badge.js +++ b/public/javascripts/widgets/notifications-badge.js @@ -80,7 +80,7 @@ url: "/notifications/" + notification.id, type: "PUT", success: function() { - Diaspora.Page.notifications.decrementCount(); + Diaspora.page.header.notifications.decrementCount(); } }); } diff --git a/public/javascripts/widgets/stream-element.js b/public/javascripts/widgets/stream-element.js index 753f8bc43..93182a6f6 100644 --- a/public/javascripts/widgets/stream-element.js +++ b/public/javascripts/widgets/stream-element.js @@ -6,6 +6,7 @@ self.postGuid = element.attr("id"); $.extend(self, { + commentForm: self.instantiate("CommentForm", element.find("form.new_comment")), commentStream: self.instantiate("CommentStream", element.find("ul.comments")), embedder: self.instantiate("Embedder", element.find("div.content")), likes: self.instantiate("Likes", element.find("div.likes_container")), diff --git a/public/javascripts/widgets/stream.js b/public/javascripts/widgets/stream.js index baab670a6..38e86d267 100644 --- a/public/javascripts/widgets/stream.js +++ b/public/javascripts/widgets/stream.js @@ -1,12 +1,20 @@ (function() { var Stream = function() { var self = this; - this.streamElements = []; - this.subscribe("widget/ready", function(evt, element) { - $.each(element.find(".stream_element"), function(index, element) { - self.addPost($(element)); + this.subscribe("widget/ready", function(evt, stream) { + $.extend(self, { + stream: $(stream), + streamElements: {} }); + + $.each(self.stream.find(".stream_element"), function() { + self.addPost($(this)); + }); + }); + + this.globalSubscribe("stream/reloaded", function() { + self.publish("widget/ready", self.stream); }); this.globalSubscribe("stream/post/added", function(evt, post) { @@ -14,9 +22,7 @@ }); this.addPost = function(post) { - self.streamElements.push( - self.instantiate("StreamElement", post) - ); + self.streamElements[post.attr("id")] = self.instantiate("StreamElement", post); }; }; diff --git a/public/javascripts/widgets/user-dropdown.js b/public/javascripts/widgets/user-dropdown.js index 2b9ac94cf..cd46bba9f 100644 --- a/public/javascripts/widgets/user-dropdown.js +++ b/public/javascripts/widgets/user-dropdown.js @@ -8,7 +8,7 @@ }); self.menuElement.click(self.toggleDropdown); - self.menuElement.find("li a").slice(1, 3).click(function(evt) { evt.stopPropagation(); }); + self.menuElement.find("li a").slice(1).click(function(evt) { evt.stopPropagation(); }); $(document.body).click(self.hideDropdown); }); diff --git a/spec/javascripts/alert-spec.js b/spec/javascripts/alert-spec.js index 0db058fe3..5e5d87f95 100644 --- a/spec/javascripts/alert-spec.js +++ b/spec/javascripts/alert-spec.js @@ -2,9 +2,6 @@ describe("Diaspora.Alert", function() { beforeEach(function() { spec.loadFixture("aspects_index"); - Diaspora.page = new Diaspora.Pages.TestPage(); - Diaspora.page.directionDetector = Diaspora.BaseWidget.instantiate("DirectionDetector"); - $(document).trigger("close.facebox"); }); diff --git a/spec/javascripts/diaspora-spec.js b/spec/javascripts/diaspora-spec.js index 9fcce86cb..ceabc1639 100644 --- a/spec/javascripts/diaspora-spec.js +++ b/spec/javascripts/diaspora-spec.js @@ -3,10 +3,6 @@ * the COPYRIGHT file. */ - -Diaspora.Pages.TestPage = function() { }; -Diaspora.Page = "TestPage"; - describe("Diaspora", function() { describe("EventBroker", function() { describe("extend", function() { diff --git a/spec/javascripts/helpers/SpecHelper.js b/spec/javascripts/helpers/SpecHelper.js index 2426c0a47..f7880007b 100644 --- a/spec/javascripts/helpers/SpecHelper.js +++ b/spec/javascripts/helpers/SpecHelper.js @@ -14,6 +14,20 @@ beforeEach(function() { // NOTE Commented (as well as in afterEach) to keep the listeners from rails.js alive. //spec.clearLiveEventBindings(); jasmine.Clock.useMock(); + + + Diaspora.Pages.TestPage = function() { + var self = this; + this.subscribe("page/ready", function() { + self.timeAgo = self.instantiate("TimeAgo", "abbr.timeago"); + self.directionDetector = self.instantiate("DirectionDetector"); + }); + }; + var Page = Diaspora.Pages["TestPage"]; + $.extend(Page.prototype, Diaspora.EventBroker.extend(Diaspora.BaseWidget)); + + Diaspora.page = new Page(); + Diaspora.page.publish("page/ready", [$(document.body)]) }); afterEach(function() { @@ -84,4 +98,5 @@ spec.retrieveFixture = function(fixtureName) { }; spec.loadFixtureCount = 0; -spec.cachedFixtures = {}; \ No newline at end of file +spec.cachedFixtures = {}; + diff --git a/spec/javascripts/stream-spec.js b/spec/javascripts/stream-spec.js index 6738148d8..852743b1f 100644 --- a/spec/javascripts/stream-spec.js +++ b/spec/javascripts/stream-spec.js @@ -8,10 +8,6 @@ describe("Stream", function() { jasmine.Clock.useMock(); spec.loadFixture('aspects_index_with_posts'); Diaspora.I18n.locale = { }; - - Diaspora.page = new Diaspora.Pages.TestPage(); - Diaspora.page.timeAgo = Diaspora.BaseWidget.instantiate("TimeAgo"); - Diaspora.page.directionDetector = Diaspora.BaseWidget.instantiate("DirectionDetector"); }); describe("collapseText", function() {