diaspora/app/controllers/bookmarks_controller.rb

54 lines
1.3 KiB
Ruby

class BookmarksController < ApplicationController
before_filter :authenticate_user!
def index
@bookmark = Bookmark.new
@bookmarks = Bookmark.paginate :page => params[:page], :order => 'created_at DESC'
respond_to do |format|
format.html
format.atom {render :xml => Diaspora::OStatus::generate(:current_url => request.url, :objects => @bookmarks)}
end
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 = Bookmark.new(params[:bookmark])
@bookmark.person = current_user
if @bookmark.save
flash[:notice] = "Successfully created bookmark."
redirect_to @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