Merge branch 'master' of github.com:diaspora/diaspora_rails
Conflicts: Gemfile
This commit is contained in:
commit
a742ef1253
25 changed files with 239 additions and 19 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -10,3 +10,4 @@ Gemfile.lock
|
|||
gpg/diaspora-development/*.gpg
|
||||
gpg/diaspora-production/*.gpg
|
||||
gpg/*/random_seed
|
||||
public/uploads/*
|
||||
|
|
|
|||
40
Gemfile
40
Gemfile
|
|
@ -3,31 +3,43 @@ source 'http://gemcutter.org'
|
|||
|
||||
gem 'rails', '3.0.0.beta4'
|
||||
gem 'bundler', '0.9.26'
|
||||
gem 'mongo_mapper', :git => "http://github.com/BadMinus/mongomapper.git"
|
||||
gem 'devise', :git => "http://github.com/BadMinus/devise.git"
|
||||
gem 'jnunemaker-validatable', :git => "http://github.com/BadMinus/validatable.git"
|
||||
|
||||
gem 'thin'
|
||||
|
||||
#Security
|
||||
gem 'gpgme'
|
||||
gem 'devise', :git => 'http://github.com/BadMinus/devise.git'
|
||||
|
||||
#Mongo
|
||||
gem 'mongo_mapper', :git => 'http://github.com/BadMinus/mongomapper.git'
|
||||
gem 'jnunemaker-validatable', :git => 'http://github.com/BadMinus/validatable.git'
|
||||
gem 'mongo_ext'
|
||||
gem 'bson_ext'
|
||||
|
||||
gem "haml"
|
||||
gem 'roxml', :git => "git://github.com/Empact/roxml.git"
|
||||
#Views
|
||||
gem 'haml'
|
||||
gem 'will_paginate', '3.0.pre'
|
||||
|
||||
gem 'gpgme'
|
||||
gem 'roxml', :git => 'git://github.com/Empact/roxml.git'
|
||||
|
||||
#Standards
|
||||
gem 'pubsubhubbub'
|
||||
#mai crazy async stuff
|
||||
#gem 'em-synchrony', :git => 'git://github.com/igrigorik/em-synchrony.git', :require => 'em-synchrony/em-http'
|
||||
|
||||
gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http'
|
||||
#gem 'rack-fiber_pool', :require => 'rack/fiber_pool'
|
||||
gem 'addressable', :require => "addressable/uri"
|
||||
gem 'addressable', :require => 'addressable/uri'
|
||||
gem 'em-websocket'
|
||||
gem 'thin'
|
||||
gem 'will_paginate', '3.0.pre'
|
||||
gem 'redfinger'
|
||||
|
||||
#File uploading
|
||||
gem 'carrierwave', :git => 'git://github.com/rsofaer/carrierwave.git' , :branch => 'master' #Untested mongomapper branch
|
||||
gem 'mini_magick'
|
||||
|
||||
group :test do
|
||||
gem 'rspec', '>= 2.0.0.beta.17'
|
||||
gem 'rspec-rails', '2.0.0.beta.17'
|
||||
gem "mocha"
|
||||
gem 'mocha'
|
||||
gem 'webrat'
|
||||
gem 'redgreen'
|
||||
gem 'autotest'
|
||||
|
|
@ -36,10 +48,10 @@ group :test do
|
|||
end
|
||||
|
||||
group :development do
|
||||
gem "nifty-generators"
|
||||
gem "ruby-debug"
|
||||
gem 'nifty-generators'
|
||||
gem 'ruby-debug'
|
||||
end
|
||||
|
||||
group :deployment do
|
||||
gem 'sprinkle', :git => "git://github.com/rsofaer/sprinkle.git"
|
||||
gem 'sprinkle', :git => 'git://github.com/rsofaer/sprinkle.git'
|
||||
end
|
||||
|
|
|
|||
2
README
2
README
|
|
@ -1 +1 @@
|
|||
broner
|
||||
bronenate
|
||||
|
|
|
|||
14
app/controllers/gridfs_controller.rb
Normal file
14
app/controllers/gridfs_controller.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
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
|
||||
33
app/controllers/photos_controller.rb
Normal file
33
app/controllers/photos_controller.rb
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
class PhotosController < ApplicationController
|
||||
#before_filter :authenticate_user!
|
||||
|
||||
def index
|
||||
@photos = Photo.paginate :page => params[:page], :order => 'created_at DESC'
|
||||
end
|
||||
|
||||
def create
|
||||
@photo = Photo.new(params[:photo])
|
||||
|
||||
if @photo.save
|
||||
flash[:notice] = "Successfully uploaded photo."
|
||||
redirect_to photos_url
|
||||
else
|
||||
render :action => 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@photo = Photo.new
|
||||
end
|
||||
|
||||
def destroy
|
||||
@photo = Photo.where(:id => params[:id]).first
|
||||
@photo.destroy
|
||||
flash[:notice] = "Successfully deleted photo."
|
||||
redirect_to root_url
|
||||
end
|
||||
|
||||
def show
|
||||
@photo = Photo.where(:id => params[:id]).first
|
||||
end
|
||||
end
|
||||
|
|
@ -5,7 +5,22 @@ class UsersController < ApplicationController
|
|||
@users = User.sort(:created_at.desc).all
|
||||
end
|
||||
def show
|
||||
@user= Person.where(:id => params[:id]).first
|
||||
@user= Person.first(:id => params[:id])
|
||||
@user_profile = @user.profile
|
||||
end
|
||||
|
||||
def edit
|
||||
@user = User.first(:id => params[:id])
|
||||
@profile = @user.profile
|
||||
end
|
||||
|
||||
def update
|
||||
@user = User.where(:id => params[:id]).first
|
||||
if @user.update_attributes(params[:user])
|
||||
flash[:notice] = "Successfully updated user."
|
||||
redirect_to @user
|
||||
else
|
||||
render :action => 'edit'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
6
app/models/photo.rb
Normal file
6
app/models/photo.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class Photo
|
||||
require 'carrierwave/orm/mongomapper'
|
||||
include MongoMapper::Document
|
||||
|
||||
mount_uploader :image, ImageUploader
|
||||
end
|
||||
|
|
@ -4,7 +4,7 @@ class User < Person
|
|||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
|
||||
before_validation :assign_key
|
||||
before_validation_on_create :assign_key
|
||||
validates_presence_of :profile
|
||||
|
||||
before_validation :do_bad_things
|
||||
|
|
|
|||
17
app/uploaders/image_uploader.rb
Normal file
17
app/uploaders/image_uploader.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
class ImageUploader < CarrierWave::Uploader::Base
|
||||
include CarrierWave::MiniMagick
|
||||
|
||||
storage :grid_fs
|
||||
|
||||
def store_dir
|
||||
"files/#{model.id}"
|
||||
end
|
||||
|
||||
def extension_white_list
|
||||
%w(jpg jpeg gif png)
|
||||
end
|
||||
|
||||
version :small_thumb do
|
||||
process :resize_to_fill => [100,100]
|
||||
end
|
||||
end
|
||||
|
|
@ -44,6 +44,9 @@
|
|||
.span-24.last
|
||||
.span-3.append-1.last
|
||||
= link_to owner_picture, root_path
|
||||
= link_to "Edit your profile", edit_user_path(current_user)
|
||||
%br
|
||||
%br
|
||||
= render 'people/sidebar' if user_signed_in?
|
||||
|
||||
.span-20.last
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
%h3 your people
|
||||
%ul#friend_stream.nav
|
||||
- for friend in @friends
|
||||
%li= link_to friend.real_name, person_path(friend)
|
||||
|
|
|
|||
5
app/views/photos/_new_photo.haml
Normal file
5
app/views/photos/_new_photo.haml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
= form_for Photo.new, :html => {:multipart => true} do |f|
|
||||
= f.error_messages
|
||||
%p
|
||||
= f.file_field :image
|
||||
= f.submit 'post it!', :class => 'button'
|
||||
3
app/views/photos/_photo.haml
Normal file
3
app/views/photos/_photo.haml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
%li.message{:id => post.id}
|
||||
= link_to (image_tag post.image.url(:small_thumb)), photo_path(post)
|
||||
|
||||
9
app/views/photos/index.html.haml
Normal file
9
app/views/photos/index.html.haml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
%h1.big_text photos
|
||||
= render "photos/new_photo", :photo => @photo
|
||||
%ul#stream
|
||||
|
||||
- for photo in @photos
|
||||
= render "photo", :post => photo
|
||||
#pagination
|
||||
= will_paginate @photos
|
||||
|
||||
9
app/views/photos/new.html.haml
Normal file
9
app/views/photos/new.html.haml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
- title "New Photo"
|
||||
|
||||
= form_for( @photo, :html => {:multipart => true}) do |f|
|
||||
= f.error_messages
|
||||
%p
|
||||
= f.file_field :image
|
||||
= f.submit 'post it!', :class => 'button'
|
||||
|
||||
%p= link_to "Back to List", photos_path
|
||||
10
app/views/photos/show.html.haml
Normal file
10
app/views/photos/show.html.haml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
- title "Photo"
|
||||
|
||||
%p
|
||||
%strong Photo:
|
||||
= image_tag @photo.image.url
|
||||
|
||||
%p
|
||||
= link_to "Destroy", @photo, :confirm => 'Are you sure?', :method => :delete
|
||||
|
|
||||
= link_to "View All", photos_path
|
||||
25
app/views/users/edit.html.haml
Normal file
25
app/views/users/edit.html.haml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
%h3 Editing Profile
|
||||
|
||||
= form_for @user do |f|
|
||||
= f.error_messages
|
||||
|
||||
= f.fields_for :profile do |p|
|
||||
%p
|
||||
= p.label :first_name
|
||||
= p.text_field :first_name, :value => @profile.first_name
|
||||
%p
|
||||
= p.label :last_name
|
||||
= p.text_field :last_name, :value => @profile.last_name
|
||||
|
||||
%p
|
||||
= f.label :email
|
||||
= f.text_field :email
|
||||
|
||||
%p
|
||||
= f.label :url
|
||||
= f.text_field :url
|
||||
%p
|
||||
= f.submit
|
||||
|
||||
%p
|
||||
= link_to "Show", user_path(@user)
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
%h1 user page!
|
||||
.span-18.last
|
||||
.span-20.last
|
||||
%h1= "#{@user.real_name}"
|
||||
- if @user_profile
|
||||
%p
|
||||
|
|
|
|||
6
config/initializers/carrierwave.rb
Normal file
6
config/initializers/carrierwave.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
CarrierWave.configure do |config|
|
||||
config.grid_fs_database = "#diaspora-#{Rails.env}"
|
||||
config.grid_fs_host = 'localhost'
|
||||
config.grid_fs_access_url = "/images"
|
||||
config.storage = :grid_fs
|
||||
end
|
||||
|
|
@ -2,10 +2,14 @@ Diaspora::Application.routes.draw do |map|
|
|||
resources :blogs
|
||||
resources :bookmarks
|
||||
resources :people
|
||||
resources :users
|
||||
resources :status_messages
|
||||
resources :comments
|
||||
resources :requests
|
||||
resources :photos
|
||||
|
||||
match "/images/files/*path" => "gridfs#serve"
|
||||
|
||||
match 'warzombie', :to => "dashboards#warzombie"
|
||||
match 'zombiefriends', :to => "dashboards#zombiefriends"
|
||||
match 'zombiefriendaccept', :to => "dashboards#zombiefriendaccept"
|
||||
|
|
|
|||
9
spec/controllers/request_controller_spec.rb
Normal file
9
spec/controllers/request_controller_spec.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
describe 'webfinger' do
|
||||
redner_views
|
||||
|
||||
describe "profile" do
|
||||
it 'should fetch the public webfinger profile on request' do
|
||||
post
|
||||
end
|
||||
end
|
||||
end
|
||||
11
spec/controllers/requests_controller_spec.rb
Normal file
11
spec/controllers/requests_controller_spec.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe RequestsController do
|
||||
redner_views
|
||||
|
||||
describe "profile" do
|
||||
it 'should fetch the public webfinger profile on request' do
|
||||
post
|
||||
end
|
||||
end
|
||||
end
|
||||
BIN
spec/fixtures/bp.jpeg
vendored
Normal file
BIN
spec/fixtures/bp.jpeg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 261 KiB |
19
spec/models/photo_spec.rb
Normal file
19
spec/models/photo_spec.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe Photo do
|
||||
it 'should save a photo to GridFS' do
|
||||
photo = Photo.new
|
||||
fixture_name = File.dirname(__FILE__) + '/../fixtures/bp.jpeg'
|
||||
file = File.open(fixture_name)
|
||||
photo.image = file
|
||||
photo.save.should == true
|
||||
binary = photo.image.read
|
||||
fixture_binary = File.open(fixture_name).read
|
||||
binary.should == fixture_binary
|
||||
end
|
||||
|
||||
it 'should create thumbnails' do
|
||||
pending('need to figure this out... tearing issue')
|
||||
end
|
||||
|
||||
end
|
||||
10
spec/models/webfinger_spec.rb
Normal file
10
spec/models/webfinger_spec.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'webfinger' do
|
||||
redner_views
|
||||
describe "profile" do
|
||||
it 'should fetch the public webfinger profile on request' do
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue