GeoRSS aggregator and Layar augmented reality server
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 

99 líneas
2.2 KiB

  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.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.get
  77. redirect_to :back, notice: 'Feed fetched OK'
  78. end
  79. def fetch_all
  80. Feed.get_all
  81. redirect_to :back, notice: 'All feeds fetched OK'
  82. end
  83. end