Merge branch 'master' of github.com:diaspora/diaspora

This commit is contained in:
maxwell 2010-08-23 18:45:31 -07:00
commit f172c9e1d2
166 changed files with 2237 additions and 398 deletions

View file

@ -26,7 +26,7 @@ gem 'json'
#Standards
gem 'pubsubhubbub'
gem 'redfinger'
gem 'redfinger', :git => 'git://github.com/rsofaer/redfinger.git'
#EventMachine
gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http'

View file

@ -1,15 +0,0 @@
class GridfsController < ActionController::Metal
def serve
gridfs_path = env["PATH_INFO"].gsub("/images/", "")
begin
gridfs_file = Mongo::GridFileSystem.new(MongoMapper.database).open(gridfs_path, 'r')
self.response_body = gridfs_file.read
self.content_type = gridfs_file.content_type
rescue
self.status = :file_not_found
self.content_type = 'text/plain'
self.response_body = "File totally imaginary #{gridfs_path}"
end
end
end

View file

@ -33,7 +33,6 @@ class GroupsController < ApplicationController
@group = Group.first(:id => params[:id])
@posts = current_user.visible_posts( :by_members_of => @group ).paginate :order => 'created_at DESC'
#@posts = Post.paginate :person_id => @people_ids, :order => 'created_at DESC'
end
def edit

View file

@ -2,6 +2,7 @@ class PhotosController < ApplicationController
before_filter :authenticate_user!
def create
render :nothing => true
begin
@photo = current_user.post(:photo, params)
@ -21,6 +22,8 @@ class PhotosController < ApplicationController
def new
@photo = Photo.new
@album = current_user.album_by_id(params[:album_id])
render :partial => "new_photo"
end
def destroy

View file

@ -31,22 +31,31 @@ class RequestsController < ApplicationController
end
def create
puts params.inspect
begin
rel_hash = relationship_flow(params[:request][:destination_url])
rescue Exception => e
flash[:error] = "no diaspora seed found with this email!"
redirect_to current_user.group_by_id(params[:request][:group_id])
return
end
Rails.logger.debug("Sending request: #{rel_hash}")
begin
@request = current_user.send_request(rel_hash, params[:request][:group_id])
rescue Exception => e
raise e unless e.message.include? "already friends"
flash[:notice] = "You are already friends with #{params[:request][:destination_url]}!"
redirect_to current_user.group_by_id(params[:request][:group_id])
return
end
if @request
flash[:notice] = "a friend request was sent to #{@request.destination_url}"
redirect_to requests_url
redirect_to current_user.group_by_id(params[:request][:group_id])
else
if url.include? '@'
flash[:error] = "no diaspora seed found with this email!"
else
flash[:error] = "you have already friended this person"
end
@request = Request.new
render :action => 'new'
flash[:error] = "Something went horribly wrong..."
redirect_to current_user.group_by_id(params[:request][:group_id])
end
end

View file

@ -9,7 +9,7 @@ class StatusMessagesController < ApplicationController
end
def create
puts params.inspect
params[:status_message][:group_ids] = params[:group_ids]
@status_message = current_user.post(:status_message, params[:status_message])
if @status_message.created_at

View file

@ -4,11 +4,11 @@ module PhotosHelper
link_to (image_tag photo.url(:scaled_full)), photo_path(album.next_photo(photo)), :rel => "prefetch"
end
def link_to_prev(photo, album)
link_to "<< prev", photo_path(album.prev_photo(photo)), :rel => "prefetch"
def url_to_prev(photo, album)
photo_path(album.prev_photo(photo))
end
def link_to_next(photo, album)
link_to "next >>", photo_path(album.next_photo(photo)), :rel => "prefetch"
def url_to_next(photo, album)
photo_path(album.next_photo(photo))
end
end

View file

@ -29,7 +29,6 @@ module RequestsHelper
action = :none
url = nil
local_person = Person.by_webfinger identifier
puts local_person.inspect
if local_person
action = (local_person == current_user.person ? :none : :friend)
url = local_person.receive_url

View file

@ -29,11 +29,6 @@ class Post
self.create params
end
#Querying
def self.newest_for(person)
self.where(:person_id => person.id, :order => '_id desc')
end
#ENCRYPTION
xml_accessor :creator_signature
key :creator_signature, String

View file

@ -42,23 +42,25 @@ class User
def post(class_name, options = {})
options[:person] = self.person
group_id = options[:group_id]
options.delete(:group_id)
group_ids = options[:group_ids]
options.delete(:group_ids)
model_class = class_name.to_s.camelize.constantize
post = model_class.instantiate(options)
post.creator_signature = post.sign_with_key(encryption_key)
post.save
if group_id
group = self.groups.find_by_id(group_id)
groups = self.groups.find_all_by_id(group_ids)
target_people = []
groups.each{ |group|
group.posts << post
group.save
post.push_to( group.people.all )
else
post.push_to( self.friends.all )
end
target_people = target_people | group.people
}
post.push_to( target_people )
post.socket_to_uid(id) if post.respond_to?(:socket_to_uid)
@ -122,7 +124,7 @@ class User
######### Friend Requesting ###########
def send_friend_request_to(friend_url, group_id)
unless self.friends.detect{ |x| x.receive_url == friend_url}
raise "You are already friends with that person!" if self.friends.detect{ |x| x.receive_url == friend_url}
request = Request.instantiate(:to => friend_url, :from => self.person, :into => group_id)
if request.save
self.pending_requests << request
@ -137,7 +139,7 @@ class User
end
request
end
end
def accept_friend_request(friend_request_id, group_id)
request = Request.find_by_id(friend_request_id)
@ -324,14 +326,19 @@ class User
groups.detect{|x| x.id == id }
end
def album_by_id( id )
id = ensure_bson id
albums.detect{|x| x.id == id }
end
def groups_with_person person
id = ensure_bson person.id
groups.select {|group| group.person_ids.include? id}
end
def setup_person
self.person.serialized_key = generate_key.export
self.person.email = email
self.person.serialized_key ||= generate_key.export
self.person.email ||= email
self.person.save!
end

View file

@ -11,9 +11,9 @@ class ImageUploader < CarrierWave::Uploader::Base
%w(jpg jpeg gif png)
end
# def filename
# model.id.to_s + File.extname(@filename)
# end
def filename
model.id.to_s + File.extname(@filename) if @filename
end
version :thumb_small do
process :resize_to_fill => [30,30]

View file

@ -1,3 +1,9 @@
:javascript
$(document).ready(function(){
reset_photo_fancybox();
});
.album_id{:id => @album.id, :style => "display:hidden;"}
.back= link_to '⇧ albums', albums_path
%h1.big_text
@ -11,7 +17,6 @@
.yo{:style => "display:none;"}
#new_photo_pane
= render "photos/new_photo", :photo => @photo, :album => @album
.sub_header
="updated #{how_long_ago(@album)}"

View file

@ -1,8 +1,6 @@
- if user_signed_in?
= javascript_include_tag 'FABridge', 'swfobject', 'web_socket'
:javascript
= javascript_include_tag 'FABridge', 'swfobject', 'web_socket'
:javascript
WebSocket.__swfLocation = "/javascripts/WebSocketMain.swf";
:javascript
$(document).ready(function(){
function debug(str){ $("#debug").append("<p>" + str); };

View file

@ -13,7 +13,6 @@
/= 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'
= javascript_include_tag 'jquery.infieldlabel', 'jquery.cycle/jquery.cycle.min.js'
= javascript_include_tag 'fancybox/jquery.fancybox-1.3.1.pack'
@ -33,26 +32,35 @@
%header
.container
#session_action
- if user_signed_in?
%ul#user_menu
%li.name= link_to current_user.real_name, current_user.person
%li= link_to "requests (#{@request_count})", requests_path, :class => new_request(@request_count)
%li= link_to "settings", edit_user_path(current_user)
%li= link_to "search", users_path
%li= link_to "logout", destroy_user_session_path
- else
= link_to "login", new_user_session_path
%li#global_search
= form_tag(users_path, :method => 'get') do
%label{:for => 'q'} Search
= text_field_tag 'q'
%li
%ul#other_user_menu
%li
= owner_image_tag
= link_to current_user.real_name, current_user.person
%li.requests= link_to "requests (#{@request_count})", requests_path, :class => new_request(@request_count)
%li.settings= link_to "settings", edit_user_path(current_user)
%li.logout= link_to "logout", destroy_user_session_path
#diaspora_text{:href => root_path}
= link_to "DIASPORA*", root_path
%span.sub_text
PREVIEW
= render "shared/group_nav"
%span{:style => "padding-left:30px;"}
= link_to "photos", albums_path
.container
.span-24.last
.span-4.append-1.last
= render "shared/group_nav"
.span-19.last
= yield
.span-24.last
= render "posts/debug"

View file

@ -2,7 +2,7 @@
$(function() {
$("#photo_image").html5_upload({
// WE INSERT ALBUM_ID PARAM HERE
url: "/photos?album_id=#{album.id}",
url: "/photos?album_id=#{@album.id}",
sendBoundary: window.FormData || $.browser.mozilla,
setName: function(text) {
$("#progress_report_name").text(text);
@ -12,7 +12,9 @@
$("#add_photo_loader").fadeOut(400);
$("#photo_title_status").text("Done!");
$("#progress_report").html("Great job!");
$("#progress_report").html("Good job me!");
$("#add_photo_button").addClass("uploading_complete");
},
onStart: function(event, total){
$("#add_photo_button").html( "Uploading Photos" );
@ -29,10 +31,10 @@
%h1
%span{:id=>"photo_title_status"}
Add photos to
%i= album.name
= form_for photo, :html => {:multipart => true} do |f|
%i= @album.name
= form_for @photo, :html => {:multipart => true} do |f|
= f.error_messages
= f.hidden_field :album_id, :value => album.id
= f.hidden_field :album_id, :value => @album.id
= f.file_field :image, :multiple => 'multiple'
#progress_report{ :style => "display:none;text-align:center;" }

View file

@ -1,3 +1,16 @@
:javascript
$(document).keydown(function(e){
switch(e.keyCode) {
case 37:
window.location.replace( "#{url_to_prev(@photo,@album)}" );
break;
case 39:
window.location.replace( "#{url_to_next(@photo,@album)}" );
break;
}
});
.back= link_to "⇧ #{@album.name}", album_path(@album)
%h1.big_text
= @photo.image
@ -6,11 +19,11 @@
= link_to 'Edit Photo', edit_photo_path(@photo), :class => "button"
.sub_header
= link_to_prev @photo, @album
= link_to "<< prev", url_to_prev(@photo, @album)
|
= link_to "full size", @photo.url
|
= link_to_next @photo, @album
= link_to "next >>", url_to_next(@photo, @album)
%div{:id => @photo.id}
#show_photo

View file

@ -1,6 +0,0 @@
= form_for @request do |f|
= f.error_messages
.field_with_submit
= f.text_field :destination_url
= f.submit

View file

@ -1,5 +0,0 @@
%h1 requests
= render 'form'
%p= link_to "Back to List", requests_path

View file

@ -1,7 +1,12 @@
#group
%ul
= link_to @group.name, @group, :class => "selected"
= link_to "edit", edit_group_path(@group)
- for group in @groups
%li{:class => ("selected" if group.id.to_s == params[:id])}
- unless (group.id.to_s == params[:id])
%li
= link_to group.name, group
%li.new_group= link_to("NEW GROUP", "#add_group_pane", :id => "add_group_button")
@ -16,11 +21,6 @@
= person_image_link(friend)
= link_to (image_tag 'add_friend_button.png'), "#add_request_pane", :id => 'add_request_button'
- if @group.people.count == 0
%span.add_new_description
<< click the plus to add friends to this group
.yo{:style => 'display:none'}
#add_request_pane
= render "requests/new_request"

View file

@ -1,18 +1,24 @@
#publisher
#publisher_form
.span-19.last
= form_for StatusMessage.new, :remote => true do |f|
= f.error_messages
-if group_id
= f.hidden_field :group_id, :value => group_id
.span-15.last
.span-2.last
.user_image
= owner_image_tag
.span-13.last
%p
%label{:for => "status_message_message"} Message
= f.text_area :message, :rows => 2
%ul
.span-3.last
%ul.group_selector
going to...
- for group in current_user.groups
%li
= check_box_tag("group_ids[]", group.id, current_group?(group))
= group.name
= check_box_tag("groups_id[]", group.id, current_group?(group))
.right
.span-1.last
= f.submit "Post"

View file

@ -1,14 +1,17 @@
development:
debug: false
socket_debug : false
socket_port: 8080
pubsub_server: 'https://pubsubhubbub.appspot.com/'
test:
debug: false
socket_debug : false
socket_port: 8081
pubsub_server: 'https://pubsubhubbub.appspot.com/'
production:
debug: false
socket_debug : false
socket_port: 8080
pubsub_server: 'https://pubsubhubbub.appspot.com/'

View file

@ -1,3 +1,4 @@
require 'lib/mongo_mapper/clear_dev_memory'
Diaspora::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
@ -17,5 +18,6 @@ Diaspora::Application.configure do
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
config.active_support.deprecation = :log
config.middleware.use MongoMapper::ClearDevMemory
#config.threadsafe!
end

View file

@ -7,7 +7,7 @@ require "lib/diaspora/websocket"
EventMachine::WebSocket.start(
:host => "0.0.0.0",
:port => APP_CONFIG[:socket_port],
:debug =>APP_CONFIG[:debug]) do |ws|
:debug =>APP_CONFIG[:socket_debug]) do |ws|
ws.onopen {
sid = Diaspora::WebSocket.subscribe(ws.request['Path'].gsub('/',''), ws)

View file

@ -4,7 +4,7 @@ Diaspora::Application.routes.draw do
resources :status_messages
resources :comments
resources :requests
resources :photos
resources :photos, :except => [:index]
resources :albums
resources :groups

View file

@ -7,7 +7,7 @@ max_conns: 1024
require: []
max_persistent_conns: 512
environment: production
environment: development
servers: 1
daemonize: true
#chdir: /usr/applications/localhash/current

View file

@ -0,0 +1,19 @@
module MongoMapper
class ClearDevMemory
def initialize(app)
@app = app
end
def call(env)
if Rails.configuration.cache_classes
else
MongoMapper::Document.descendants.each do |m|
m.descendants.clear if m.respond_to? :descendants
end
MongoMapper::Document.descendants.clear
MongoMapper::EmbeddedDocument.descendants.clear
end
@app.call(env)
end
end
end

View file

@ -29,7 +29,7 @@ namespace :db do
MongoMapper::connection.drop_database(MongoMapper::database.name)
puts 'Deleting tmp folder...'
`rm -rf #{File.dirname(__FILE__)}/../../public/uploads/tmp`
`rm -rf #{File.dirname(__FILE__)}/../../public/uploads/*`
end
desc 'Purge and seed the current RAILS_ENV database using information from db/seeds.rb'

View file

@ -0,0 +1,13 @@
Created by Joseph Wain (see http://penandthink.com) at and probably downloaded from http://glyphish.com
This work is licensed under the Creative Commons Attribution 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
You are free to share it and to remix it remix under the following conditions:
* You must attribute the work in the manner specified by the author (SEE BELOW).
* For any reuse or distribution, you must make clear to others the license terms of this work.
* The above conditions can be waived if you get permission from the copyright holder (send me an email!).
ATTRIBUTION -- a note reading "icons by Joseph Wain / glyphish.com" or similar, plus a link back to glyphish.com from your app's website, is the preferred form of attribution. Also acceptable would be, like, a link from within your iPhone application, or from the iTunes store page, but those aren't as useful to other people. If none of these work for you, please contact hello@glyphish.com and we can work something out.
USE WITHOUT ATTRIBUTION -- If attribution is not possible, workable or desirable for your application, contact hello@glyphish.com for commercial non-attributed licensing terms.

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 743 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Some files were not shown because too many files have changed in this diff Show more