GeoRSS aggregator and Layar augmented reality server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 11 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
преди 12 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. Rails.logger.debug "Feed URL: %s" % params['feed']['feed_url']
  40. if Feed.where(:feed_url => params['feed']['feed_url']).size == 1 # ensure this test returns the values we expect
  41. Rails.logger.debug "Adding existing feed to a new layer"
  42. @feed = Feed.where(:feed_url => params['feed']['feed_url']).first
  43. @layer = Layer.find(params['feed']['new_layer_id']) # assumes that the specified layer exists
  44. # Attach the existing feed to the specified layer (making sure we only add each one once)
  45. @feed.layers << @layer unless @feed.layers.include?(@layer)
  46. else
  47. # Create a new feed
  48. Rails.logger.debug "Creating a new feed"
  49. @feed = Feed.new(params[:feed])
  50. @layer = Layer.find(params['feed']['new_layer_id']) # assumes that the specified layer exists
  51. @feed.layers << @layer unless @feed.layers.include?(@layer)
  52. end
  53. respond_to do |format|
  54. if @feed.save
  55. format.html { redirect_to @layer, notice: 'Feed added OK' }
  56. format.json { render json: @feed, status: :created, location: @feed }
  57. else
  58. format.html { render action: "new" }
  59. format.json { render json: @feed.errors, status: :unprocessable_entity }
  60. end
  61. end
  62. end
  63. # PUT /feeds/1
  64. # PUT /feeds/1.json
  65. def update
  66. @feed = Feed.find(params[:id])
  67. respond_to do |format|
  68. if @feed.update_attributes(params[:feed])
  69. format.html { redirect_to @feed, notice: 'Feed updated OK' }
  70. format.json { head :no_content }
  71. else
  72. format.html { render action: "edit" }
  73. format.json { render json: @feed.errors, status: :unprocessable_entity }
  74. end
  75. end
  76. end
  77. # DELETE /feeds/1
  78. # DELETE /feeds/1.json
  79. def destroy
  80. @feed = Feed.find(params[:id])
  81. @feed.destroy
  82. respond_to do |format|
  83. format.html { redirect_to feeds_url, notice: 'Feed deleted OK' }
  84. format.json { head :no_content }
  85. end
  86. end
  87. def fetch
  88. @feed = Feed.find(params[:id])
  89. @feed.fetch
  90. redirect_to :back, notice: 'Feed fetched OK'
  91. end
  92. def fetch_all
  93. Feed.fetch_all
  94. redirect_to :back, notice: 'All feeds fetched OK'
  95. end
  96. end