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.
 
 
 
 
 

101 lines
2.4 KiB

  1. class LayersController < ApplicationController
  2. before_filter :require_login
  3. # GET /layers
  4. # GET /layers.json
  5. def index
  6. @layers = Layer.all
  7. respond_to do |format|
  8. format.html # index.html.erb
  9. format.json { render json: @layers }
  10. end
  11. end
  12. # GET /layers/1
  13. # GET /layers/1.json
  14. def show
  15. @layer = Layer.find(params[:id])
  16. @feed = Feed.new
  17. @feed.new_layer_id = @layer.id
  18. @layer_posts = 0
  19. @layer.feeds.each { |f| @layer_posts += f.posts.size }
  20. respond_to do |format|
  21. format.html # show.html.erb
  22. format.json { render json: @layer }
  23. end
  24. end
  25. # GET /layers/new
  26. # GET /layers/new.json
  27. def new
  28. @layer = Layer.new
  29. respond_to do |format|
  30. format.html # new.html.erb
  31. format.json { render json: @layer }
  32. end
  33. end
  34. # GET /layers/1/edit
  35. def edit
  36. @layer = Layer.find(params[:id])
  37. end
  38. # POST /layers
  39. # POST /layers.json
  40. def create
  41. @layer = Layer.new(params[:layer])
  42. respond_to do |format|
  43. if @layer.save
  44. format.html { redirect_to @layer, notice: 'Layer was successfully created.' }
  45. format.json { render json: @layer, status: :created, location: @layer }
  46. else
  47. format.html { render action: "new" }
  48. format.json { render json: @layer.errors, status: :unprocessable_entity }
  49. end
  50. end
  51. end
  52. # PUT /layers/1
  53. # PUT /layers/1.json
  54. def update
  55. @layer = Layer.find(params[:id])
  56. respond_to do |format|
  57. if @layer.update_attributes(params[:layer])
  58. format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }
  59. format.json { head :no_content }
  60. else
  61. format.html { render action: "edit" }
  62. format.json { render json: @layer.errors, status: :unprocessable_entity }
  63. end
  64. end
  65. end
  66. # DELETE /layers/1
  67. # DELETE /layers/1.json
  68. def destroy
  69. @layer = Layer.find(params[:id])
  70. @layer.destroy
  71. respond_to do |format|
  72. format.html { redirect_to layers_url }
  73. format.json { head :no_content }
  74. end
  75. end
  76. # DELETE /layers/1/delete_feed
  77. # This only deletes the relation between the layer and the feed. The feed (and its posts) are retained.
  78. # Currently there's no way for the user to actually delete a feed completely.
  79. def delete_feed
  80. @layer = Layer.find(params[:id])
  81. @feed = Feed.find(params[:feed_id])
  82. @layer.feeds.delete(@feed)
  83. redirect_to @layer, notice: "Deleted feed #{@feed.title} from this layer"
  84. end
  85. end