Merge branch 'master' of github.com:diaspora/diaspora_rails into pivots

This commit is contained in:
Raphael 2010-08-17 19:04:03 -07:00
commit e8e141b24e
19 changed files with 0 additions and 348 deletions

View file

@ -1,52 +0,0 @@
class BlogsController < ApplicationController
before_filter :authenticate_user!
def index
@blogs = Blog.paginate :page => params[:page], :order => 'created_at DESC'
respond_to do |format|
format.html
end
end
def show
@blog = Blog.find(params[:id])
end
def new
@blog = Blog.new
end
def create
@blog = current_user.post(:blog, params[:blog])
if @blog.created_at
flash[:notice] = "Successfully created blog."
else
render :action => 'new'
end
end
def edit
@blog = Blog.where(:id => params[:id]).first
end
def update
@blog = Blog.where(:id => params[:id]).first
if @blog.update_attributes(params[:blog])
flash[:notice] = "Successfully updated blog."
redirect_to @blog
else
render :action => 'edit'
end
end
def destroy
@blog = Blog.where(:id => params[:id]).first
@blog.destroy
flash[:notice] = "Successfully destroyed blog."
redirect_to root_url
end
end

View file

@ -1,47 +0,0 @@
class BookmarksController < ApplicationController
before_filter :authenticate_user!
def index
@bookmark = Bookmark.new
@bookmarks = Bookmark.paginate :page => params[:page], :order => 'created_at DESC'
end
def edit
@bookmark = Bookmark.first(:conditions => {:id => params[:id]})
end
def update
@bookmark = Bookmark.first(:conditions => {:id => params[:id]})
if @bookmark.update_attributes(params[:bookmark])
flash[:notice] = "Successfully updated bookmark."
redirect_to @bookmark
else
render :action => 'edit'
end
end
def show
@bookmark = Bookmark.first(:conditions => {:id => params[:id]})
end
def create
@bookmark = current_user.post(:bookmark, params[:bookmark])
if @bookmark.created_at
flash[:notice] = "Successfully created bookmark."
else
render :action => 'new'
end
end
def new
@bookmark = Bookmark.new
end
def destroy
@bookmark = Bookmark.first(:conditions => {:id => params[:id]})
@bookmark.destroy
flash[:notice] = "Successfully destroyed bookmark."
redirect_to root_url
end
end

View file

@ -1,26 +0,0 @@
class Blog < Post
xml_accessor :title
xml_accessor :body
key :title, String
key :body, String
validates_presence_of :title, :body
def to_activity
<<-XML
<entry>
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
<title>#{self.title}</title>
<content>#{self.body}</content>
<link rel="alternate" type="text/html" href="#{person.url}blogs/#{self.id}"/>
<id>#{person.url}blogs/#{self.id}</id>
<published>#{self.created_at.xmlschema}</published>
<updated>#{self.updated_at.xmlschema}</updated>
</entry>
XML
end
end

View file

@ -1,42 +0,0 @@
class Bookmark < Post
xml_accessor :link
xml_accessor :title
key :link, String
key :title, String
validates_presence_of :link
validates_format_of :link, :with =>
/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix
def to_activity
<<-XML
<entry>
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
<title>#{self.title}</title>
<link rel="alternate" type="text/html" href="#{person.url}bookmarks/#{self.id}"/>
<link rel="related" type="text/html" href="#{self.link}"/>
<id>#{person.url}bookmarks/#{self.id}</id>
<published>#{self.created_at.xmlschema}</published>
<updated>#{self.updated_at.xmlschema}</updated>
</entry>
XML
end
def self.instantiate params
params[:link] = clean_link(params[:link])
create params
end
protected
def self.clean_link link
if link
link = 'http://' + link unless link.match('https?://')
link = link + '/' if link[-1,1] != '/'
link
end
end
end

View file

@ -1,20 +0,0 @@
%li.message{:id => post.id, :class => ("mine" if current_user.owns?(post))}
= person_image_tag(post.person)
%span.from
= link_to post.person.real_name, post.person
%b wrote a new blog post
%br
%b= post.title
%br
= raw post.body
%div.time
= link_to(how_long_ago(post), object_path(post))
\--
= link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments"
= render "comments/comments", :post => post
- if current_user.owns?(post)
.destroy_link
= link_to 'Delete', blog_path(post), :confirm => 'Are you sure?', :method => :delete, :remote=> true

View file

@ -1,12 +0,0 @@
= form_for @blog do |f|
= f.error_messages
%p
= f.label :title
%br
= f.text_field :title
%p
= f.label :body
%br
= f.text_area :body
%p
= f.submit

View file

@ -1,8 +0,0 @@
- title "Edit Blog"
= render 'form'
%p
= link_to "Show", blog_path(@blog)
|
= link_to "View All", blogs_path

View file

@ -1,7 +0,0 @@
%h1= link_to "new blog", new_blog_path
%ul#stream
- for blog in @blogs
= render "blog", :post => blog
#pagination
= will_paginate @blogs

View file

@ -1,5 +0,0 @@
- title "New Blog"
= render 'form'
%p= link_to "Back to List", blogs_path

View file

@ -1,21 +0,0 @@
- title "Blog"
%p
%strong Title:
= @blog.title
%p
%strong Body:
= raw @blog.body
%p
%strong Owner:
= @blog.person.real_name
%h4= "comments (#{@blog.comments.count})"
= render "comments/comments", :post => @blog
%p
= link_to "Edit", edit_blog_path(@blog)
|
= link_to "Destroy", @blog, :confirm => 'Are you sure?', :method => :delete
|
= link_to "View All", blogs_path

View file

@ -1,21 +0,0 @@
%li.message{:id => post.id, :class => ("mine" if current_user.owns?(post))}
= person_image_tag(post.person)
%span.from
= link_to post.person.real_name, post.person
%b shared a link
%br
= post.title
%a{:href => "#{post.link}"}
= post.link
%div.time
= link_to(how_long_ago(post), object_path(post))
\--
= link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments"
= render "comments/comments", :post => post
- if current_user.owns?(post)
.destroy_link
= link_to 'Delete', bookmark_path(post), :confirm => 'Are you sure?', :method => :delete, :remote => true

View file

@ -1,12 +0,0 @@
= form_for @bookmark do |f|
= f.error_messages
%p
= f.label :title
%br
= f.text_field :title
%p
= f.label :link
%br
= f.text_field :link
%p
= f.submit

View file

@ -1,6 +0,0 @@
= form_for @bookmark, :remote => true do |f|
= f.error_messages
= f.text_field :title, :value => "Title"
= f.text_field :link, :value => "URL"
%p
= f.submit

View file

@ -1,8 +0,0 @@
- title "Edit Bookmark"
= render 'form'
%p
= link_to "Show", bookmark_path(@bookmark)
|
= link_to "View All", bookmarks_path

View file

@ -1,7 +0,0 @@
%h1.big_text bookmarks
= render "bookmarks/new_bookmark", :bookmark => @bookmark
%ul#stream
- for bookmark in @bookmarks
= render "bookmark", :post => bookmark
#pagination
= will_paginate @bookmarks

View file

@ -1,5 +0,0 @@
- title "New Bookmark"
= render 'form'
%p= link_to "Back to List", bookmarks_path

View file

@ -1,21 +0,0 @@
- title "Bookmark"
%p
%strong Title:
= @bookmark.title
%p
%strong Link:
= link_to @bookmark.link
%p
%strong Owner:
= @bookmark.person.real_name
%h4= "comments (#{@bookmark.comments.count})"
= render "comments/comments", :post => @bookmark
%p
= link_to "Edit", edit_bookmark_path(@bookmark)
|
= link_to "Destroy", @bookmark, :confirm => 'Are you sure?', :method => :delete
|
= link_to "View All", bookmarks_path

View file

@ -1,8 +1,4 @@
#publisher #publisher
%ul#publisher_content_pickers
%li{ :class => "status_message selected" }= link_to "status message", "#"
%li{ :class => "bookmark" }= link_to "bookmark", "#"
%li{ :class => "blog" }= link_to "blog", "#"
#publisher_form #publisher_form
= form_for StatusMessage.new, :remote => true do |f| = form_for StatusMessage.new, :remote => true do |f|
@ -12,25 +8,3 @@
= f.text_area :message, :rows => 2 = f.text_area :message, :rows => 2
%p.right %p.right
= f.submit "Post" = f.submit "Post"
= form_for Bookmark.new, :remote => true do |f|
= f.error_messages
%p
%label{:for => "bookmark_title"} Title
= f.text_field :title
%p
%label{:for => "bookmark_link"} Link
= f.text_field :link
%p.right
= f.submit "Post"
= form_for Blog.new, :remote => true do |f|
= f.error_messages
%p
%label{:for => "blog_title"} Title
= f.text_field :title
%p
%label{:for => "blog_body"} Body
= f.text_area :body
%p.right
= f.submit "Post"

View file

@ -1,6 +1,4 @@
Diaspora::Application.routes.draw do |map| Diaspora::Application.routes.draw do |map|
resources :blogs
resources :bookmarks
resources :people resources :people
resources :users, :only => [:edit] resources :users, :only => [:edit]
resources :status_messages resources :status_messages