Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cleaning up old api code

api has dedicated controller (v1/posts)
removed code that has been moved there
  • Loading branch information...
commit f665047bc8d91555754ea02b198dd6a377e07738 1 parent 699c035
mcansky authored
Showing with 7 additions and 57 deletions.
  1. +7 −57 app/controllers/posts_controller.rb
View
64 app/controllers/posts_controller.rb
@@ -24,18 +24,8 @@ def index
# building conditions
conditions = Array.new
conditions[0] = ""
- if params[:fromdt]
- conditions[0] = "bookmarked_at >= ?"
- conditions << DateTime.parse(params[:fromdt])
- end
- if params[:todt]
- conditions[0] += " AND " if params[:fromdt]
- conditions[0] += "bookmarked_at <= ?"
- conditions << DateTime.parse(params[:todt])
- end
if params[:username]
# filter private ones
- conditions[0] += " AND " if (params[:fromdt] || params[:todt])
conditions[0] += "private = ?"
conditions << 0
elsif params[:all_users]
@@ -78,27 +68,7 @@ def index
@tags = user.bookmarks.tag_counts_on(:tags) unless params[:tag]
end
@posts_count = the_posts.size
- respond_to do |format|
- format.html do
- @posts = the_posts.paginate(:page => params[:page])
- end
- format.xml do
- if current_user
- xml_posts = Array.new
- the_posts.each do |post|
- tags = Array.new
- post.tags.each { |t| tags << t.name } if post.tags.count > 0
- xml_posts << {"href" => post.link.url, "description" => post.title, "tag" => tags.join(' ')}
- end
- meta = Digest::MD5.hexdigest(current_user.name + current_user.updated_at.utc.strftime("%Y-%m-%dT%H:%M:%SZ"))
- posts = {:user => current_user.name, :update => current_user.updated_at.utc.strftime("%Y-%m-%dT%H:%M:%SZ"), :hash => meta, :tag => "", :total => current_user.bookmarks.size, :post => xml_posts}
- xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + XmlSimple.xml_out(posts).gsub("opt","posts")
- render :xml => xml_output
- else
- render :xml => "<?xml version='1.0' standalone='yes'?>\n<result code=\"something went wrong\" />"
- end
- end
- end
+ @posts = the_posts.paginate(:page => params[:page])
end
def new
@@ -177,22 +147,11 @@ def create
logger.info("bookmark for #{new_b.link.url} cloned")
end
end
- respond_to do |format|
- format.html do
- if incomplete || error
- flash[:error] = "incomplet"
- render :file => File.join(Rails.root, 'public', '400.html'), :status => 400
- else
- redirect_to :action => "index", :notice => "Added properly !"
- end
- end
- format.xml do
- if incomplete || error
- render :xml => "<?xml version='1.0' standalone='yes'?>\n<result code=\"something went wrong\" />"
- else
- render :xml => "<?xml version='1.0' standalone='yes'?>\n<result code=\"done\" />"
- end
- end
+ if incomplete || error
+ flash[:error] = "incomplet"
+ render :file => File.join(Rails.root, 'public', '400.html'), :status => 400
+ else
+ redirect_to :action => "index", :notice => "Added properly !"
end
end
@@ -213,16 +172,7 @@ def destroy
link.destroy if link.bookmarks.size == 0 # destroy the link if no bookmarks are left
end
end
- respond_to do |format|
- format.html { redirect_to :action => "index" }
- format.xml do
- if error
- render :xml => "<?xml version='1.0' standalone='yes'?>\n<result code=\"something went wrong\" />"
- else
- render :xml => "<?xml version='1.0' standalone='yes'?>\n<result code=\"done\" />"
- end
- end
- end
+ redirect_to :action => "index"
end
# to fix
Please sign in to comment.
Something went wrong with that request. Please try again.