GeoRSS aggregator and Layar augmented reality server
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

feeds_controller.rb 2.2 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. class FeedsController < ApplicationController
  2. before_filter :require_login
  3. # GET /feeds
  4. # GET /feeds.json
  5. def index
  6. @feed = Feed.new
  7. @feeds = Feed.all :order => :title
  8. respond_to do |format|
  9. format.html # index.html.erb
  10. format.json { render json: @feeds }
  11. end
  12. end
  13. # GET /feeds/1
  14. # GET /feeds/1.json
  15. def show
  16. @feed = Feed.find(params[:id])
  17. @posts = @feed.posts.order("published desc").paginate(:page => params[:page], :per_page => 20)
  18. respond_to do |format|
  19. format.html # show.html.erb
  20. format.json { render json: @feed }
  21. end
  22. end
  23. # GET /feeds/new
  24. # GET /feeds/new.json
  25. def new
  26. @feed = Feed.new
  27. respond_to do |format|
  28. format.html # new.html.erb
  29. format.json { render json: @feed }
  30. end
  31. end
  32. # GET /feeds/1/edit
  33. def edit
  34. @feed = Feed.find(params[:id])
  35. end
  36. # POST /feeds
  37. # POST /feeds.json
  38. def create
  39. @feed = Feed.new(params[:feed])
  40. respond_to do |format|
  41. if @feed.save
  42. format.html { redirect_to '/', notice: 'Feed added OK' }
  43. format.json { render json: @feed, status: :created, location: @feed }
  44. else
  45. format.html { render action: "new" }
  46. format.json { render json: @feed.errors, status: :unprocessable_entity }
  47. end
  48. end
  49. end
  50. # PUT /feeds/1
  51. # PUT /feeds/1.json
  52. def update
  53. @feed = Feed.find(params[:id])
  54. respond_to do |format|
  55. if @feed.update_attributes(params[:feed])
  56. format.html { redirect_to @feed, notice: 'Feed updated OK' }
  57. format.json { head :no_content }
  58. else
  59. format.html { render action: "edit" }
  60. format.json { render json: @feed.errors, status: :unprocessable_entity }
  61. end
  62. end
  63. end
  64. # DELETE /feeds/1
  65. # DELETE /feeds/1.json
  66. def destroy
  67. @feed = Feed.find(params[:id])
  68. @feed.destroy
  69. respond_to do |format|
  70. format.html { redirect_to feeds_url, notice: 'Feed deleted OK' }
  71. format.json { head :no_content }
  72. end
  73. end
  74. def fetch
  75. @feed = Feed.find(params[:id])
  76. @feed.fetch
  77. redirect_to :back, notice: 'Feed fetched OK'
  78. end
  79. def fetch_all
  80. Feed.fetch_all
  81. redirect_to :back, notice: 'All feeds fetched OK'
  82. end
  83. end