Permalink
Browse files

Add Atome feeds

  • Loading branch information...
1 parent f933637 commit a38ac3686691d0cf1c895a79acdbbf446aec1295 Marc Lagrange committed Jun 27, 2011
View
2 README.textile
@@ -13,10 +13,10 @@ Current features are:
- Sample uploading, playing is done using an <audio> tag, downloading the sample is also possible!
- Raw export in plain text : if you want to print it or avoid web garbage :-)
- Zero javascript used for validations! All are done server-side, better :-)
+- Atome feeds for most urls
Planned:
- Search into instruments names
-- RSS feeds
- Banks ?
h2. Idea based on
View
6 app/controllers/authors_controller.rb
@@ -6,6 +6,10 @@ def index
def show
@instruments = Instrument.page(params[:page]).where(:author => params[:id])
@app_title = "Author #{params[:id]} - LSDJ Patch Book"
- render 'instruments/index'
+ @is_filter_authors = true
+ respond_to do |format|
+ format.html { render 'instruments/index' }
+ format.atom { render 'instruments/index', :layout => false }
+ end
end
end
View
10 app/controllers/instruments_controller.rb
@@ -4,12 +4,20 @@ class InstrumentsController < ApplicationController
def index
@instruments = Instrument.page(params[:page])
@app_title = "Instruments - LSDJ Patch Book"
+ respond_to do |format|
+ format.html
+ format.atom { render :layout => false }
+ end
end
def by_type
@instruments = Instrument.page(params[:page]).where(:type => params[:id].upcase)
@app_title = "Instruments by type #{params[:id]} - LSDJ Patch Book"
- render 'index'
+ @is_filter_types = true
+ respond_to do |format|
+ format.html { render 'index' }
+ format.atom { render :layout => false, :action => :index }
+ end
end
def new
View
6 app/controllers/tags_controller.rb
@@ -7,6 +7,10 @@ def index
def show
@app_title = "Instruments tagged with @{params[:id]} - LSDJ Patch Book"
@instruments = Instrument.page.tagged_with(params[:id])
- render 'instruments/index'
+ @is_filter_tag = true
+ respond_to do |format|
+ format.html { render 'instruments/index' }
+ format.atom { render 'instruments/index', :layout => false }
+ end
end
end
View
5 app/controllers/users_controller.rb
@@ -26,6 +26,11 @@ def show
@app_title = "Contributor #{@user.login} - LSDJ Patch Book"
@authored = @user.instruments.where(:author => @user.login)
@submitted = @user.instruments.where('author IS NOT ?', @user.login)
+ @instruments = @user.instruments
+ respond_to do |format|
+ format.html
+ format.atom { render 'instruments/index', :layout => false }
+ end
end
def edit
View
5 app/views/application/index.html.haml
@@ -6,6 +6,7 @@ Explore & experiment.
%br
%h3
Recently added Instruments
+ = link_to image_tag("feed-icon-28x28.png", :width => 20), instruments_path(:atom)
%table
%tr
%th{:width => "50%", :align => :left} Name
@@ -14,7 +15,7 @@ Explore & experiment.
- @instruments.each do |ins|
%tr
%td= link_to ins.name, ins
- %td= ins.type
- %td= ins.author
+ %td= link_to ins.type, types_path(ins.type)
+ %td= link_to ins.author, author_path(ins.author)
%br
= paginate @instruments
View
20 app/views/instruments/index.atom.builder
@@ -0,0 +1,20 @@
+atom_feed :language => 'en-US' do |feed|
+feed.title "New instruments on LSDJ Patch Book"
+feed.updated(@instruments.blank? ? Time.now : @instruments.first.created_at)
+
+@instruments.each do |instrument|
+feed.entry instrument, :published => instrument.created_at do |entry|
+ entry.title instrument.name
+
+ entry.comments do |comments|
+ instrument.comment.each do |comment1|
+ comments.comment do |comment|
+ comment.author comment1.user.login
+ comment.content comment1.comment
+ end
+ end
+ end
+
+end
+end
+end
View
8 app/views/instruments/index.html.haml
@@ -1,5 +1,13 @@
%h3
Instruments
+ - if @is_filter_types
+ = link_to image_tag("feed-icon-28x28.png", :width => 20), types_path(params[:id], :atom)
+ - elsif @is_filter_authors
+ = link_to image_tag("feed-icon-28x28.png", :width => 20), author_path(params[:id], :atom)
+ - elsif @is_filter_tag
+ = link_to image_tag("feed-icon-28x28.png", :width => 20), tag_path(params[:id], :atom)
+ - else
+ = link_to image_tag("feed-icon-28x28.png", :width => 20), instruments_path(:atom)
%table
%tr
View
1 app/views/layouts/application.html.haml
@@ -14,6 +14,7 @@
%title= @app_title
= yield :head
= csrf_meta_tag
+ = auto_discovery_link_tag(:atom, instruments_path(:atom))
%body
%header
#logo
View
2 app/views/tags/index.html.haml
@@ -1,3 +1,3 @@
%h3 Tag cloud
- tag_cloud(@tags, %w(css1 css2 css3 css4)) do |tag, css_class|
- = link_to tag.name, tag_path(tag), :class => css_class
+ = link_to tag.name, tag_path(tag.name), :class => css_class
View
1 app/views/users/show.html.haml
@@ -1,5 +1,6 @@
%h3
%span.bold= @user.login
+ = link_to image_tag("feed-icon-28x28.png", :width => 20), user_path(params[:id], :atom)
- if current_user == @user
%br
View
BIN public/images/feed-icon-14x14.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/images/feed-icon-28x28.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a38ac36

Please sign in to comment.