diff --git a/tracks/app/controllers/feed_controller.rb b/tracks/app/controllers/feed_controller.rb index c934e144..8e84dbdc 100644 --- a/tracks/app/controllers/feed_controller.rb +++ b/tracks/app/controllers/feed_controller.rb @@ -49,6 +49,18 @@ class FeedController < ApplicationController @headers["Content-Type"] = "text/plain; charset=utf-8" end + def list_projects_only + @projects = @user.projects + @description = "Lists all the projects for #{@user.login}." + render :action => 'projects_' + @params['feedtype'] + end + + def list_contexts_only + @contexts = @user.contexts + @description = "Lists all the contexts for #{@user.login}." + render :action => 'contexts_' + @params['feedtype'] + end + protected # Check whether the token in the URL matches the word in the User's table diff --git a/tracks/app/helpers/feed_helper.rb b/tracks/app/helpers/feed_helper.rb index 263ff2f5..7f8ee837 100644 --- a/tracks/app/helpers/feed_helper.rb +++ b/tracks/app/helpers/feed_helper.rb @@ -27,4 +27,30 @@ module FeedHelper return result_string end + def build_projects_text_page(projects) + result_string = "" + projects.each do |p| + result_string << "\n" + p.name.upcase + "\n" + + result_string << p.description + "\n" if p.description_present? + result_string << "#{p.count_undone_todos}. Project is #{p.done ? 'Done' : 'Active'}.\n" + result_string << "#{p.linkurl}\n" if p.linkurl_present? + result_string << "\n" + end + + return result_string + end + + def build_contexts_text_page(contexts) + result_string = "" + contexts.each do |c| + result_string << "\n" + c.name.upcase + "\n" + + result_string << "#{c.count_undone_todos}. Context is #{c.hidden? ? 'Hidden' : 'Active'}.\n" + result_string << "\n" + end + + return result_string + end + end diff --git a/tracks/app/models/project.rb b/tracks/app/models/project.rb index a04b5b05..d0873a18 100644 --- a/tracks/app/models/project.rb +++ b/tracks/app/models/project.rb @@ -17,6 +17,14 @@ class Project < ActiveRecord::Base find(:all, :conditions => [ "done = ?" , true ], :order => "position ASC") end + def description_present? + attribute_present?("description") + end + + def linkurl_present? + attribute_present?("linkurl") + end + def find_not_done_todos todos = Todo.find :all, :conditions => ["project_id = #{id} AND done = ?", false], :order => "due IS NULL, due ASC, created_at ASC" @@ -27,7 +35,7 @@ class Project < ActiveRecord::Base :order => "due IS NULL, due ASC, created_at ASC", :limit => @user.preferences["no_completed"].to_i end - + # Returns a count of next actions in the given project # The result is count and a string descriptor, correctly pluralised if there are no # actions or multiple actions diff --git a/tracks/app/views/feed/contexts_rss.rxml b/tracks/app/views/feed/contexts_rss.rxml new file mode 100644 index 00000000..a595f36e --- /dev/null +++ b/tracks/app/views/feed/contexts_rss.rxml @@ -0,0 +1,19 @@ +@headers["Content-Type"] = "text/xml; charset=utf-8" +xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do + xml.channel do + xml.title(@title) + xml.link("http://#{@request.host}:#{@request.port}/contexts") + xml.description(@description) + @contexts.each { |c| + xml.item do + xml.title(c.name) + xml.link(url_for(:only_path => false, :controller => 'context', :action => 'show', :name => urlize(c.name))) + context_description = '' + context_description += "
#{c.count_undone_todos}. " + context_description += "Context is #{c.hidden? ? 'Hidden' : 'Active'}. " + context_description += "
" + xml.description(context_description) + end + } + end +end \ No newline at end of file diff --git a/tracks/app/views/feed/contexts_text.rhtml b/tracks/app/views/feed/contexts_text.rhtml new file mode 100644 index 00000000..346100be --- /dev/null +++ b/tracks/app/views/feed/contexts_text.rhtml @@ -0,0 +1,2 @@ +<% @headers["Content-Type"] = "text/plain; charset=utf-8" -%> +<%= build_contexts_text_page( @contexts ) -%> diff --git a/tracks/app/views/feed/projects_rss.rxml b/tracks/app/views/feed/projects_rss.rxml new file mode 100644 index 00000000..36b14456 --- /dev/null +++ b/tracks/app/views/feed/projects_rss.rxml @@ -0,0 +1,21 @@ +@headers["Content-Type"] = "text/xml; charset=utf-8" +xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do + xml.channel do + xml.title(@title) + xml.link("http://#{@request.host}:#{@request.port}/projects") + xml.description(@description) + @projects.each { |p| + xml.item do + xml.title(p.name) + xml.link(url_for(:only_path => false, :controller => 'project', :action => 'show', :name => urlize(p.name))) + project_description = '' + project_description += sanitize(markdown( p.description )) if p.description_present? + project_description += "#{p.count_undone_todos}. " + project_description += "Project is #{p.done ? 'Done' : 'Active'}. " + project_description += "#{p.linkurl}" if p.linkurl_present? + project_description += "
" + xml.description(project_description) + end + } + end +end \ No newline at end of file diff --git a/tracks/app/views/feed/projects_text.rhtml b/tracks/app/views/feed/projects_text.rhtml new file mode 100644 index 00000000..cd17083e --- /dev/null +++ b/tracks/app/views/feed/projects_text.rhtml @@ -0,0 +1,2 @@ +<% @headers["Content-Type"] = "text/plain; charset=utf-8" -%> +<%= build_projects_text_page( @projects ) -%> diff --git a/tracks/app/views/todo/feeds.rhtml b/tracks/app/views/todo/feeds.rhtml index 6e542e6b..fd446dc6 100644 --- a/tracks/app/views/todo/feeds.rhtml +++ b/tracks/app/views/todo/feeds.rhtml @@ -41,6 +41,16 @@ <%= ical_feed_link({ :due => 6 }) %> Actions due in 7 days or earlier +