mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-05 15:31:47 +01:00
Added Luke's excellent changes to the feeds (#214). There are now loads of choices for feeds (including ones for individual contexts or projects and for actions due today or in the next 7 days). The list is accessed via the feed icon in the main navigation.
Thanks, Luke! git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@193 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
aa0760f0ef
commit
6dd0f51dbd
13 changed files with 209 additions and 32 deletions
|
|
@ -11,25 +11,84 @@ class FeedController < ApplicationController
|
|||
def index
|
||||
end
|
||||
|
||||
# Builds an RSS feed for the latest 15 items
|
||||
# This is fairly basic: it lists the action description as the title
|
||||
# and the item context as the description
|
||||
#
|
||||
def na_feed
|
||||
@not_done = @user.todos.collect { |x| x.done? ? nil:x }.compact.sort! {|x,y| y.created_at <=> x.created_at }
|
||||
# Build an RSS feed
|
||||
def rss
|
||||
conditions = '(done = 0)'
|
||||
options = {:conditions => conditions}
|
||||
|
||||
limit = @params['limit']
|
||||
options[:limit] = limit if limit
|
||||
@description = limit ? "Lists the last #{limit} uncompleted next actions" : "Lists uncompleted next actions"
|
||||
@title = "Tracks - Next Actions"
|
||||
|
||||
if @params['due']
|
||||
due_within = @params['due'].to_i
|
||||
due_within_date_s = due_within.days.from_now.strftime("%Y-%m-%d")
|
||||
conditions << " AND (due <= '#{due_within_date_s}')"
|
||||
@title << " due today" if (due_within == 0)
|
||||
@title << " due within a week" if (due_within == 6)
|
||||
@description << " with a due date #{due_within_date_s} or earlier"
|
||||
end
|
||||
|
||||
context_id = @params['context']
|
||||
if context_id
|
||||
conditions << " AND (context_id = #{context_id})"
|
||||
context = @user.contexts.find(context_id)
|
||||
@title << " in #{context.name}"
|
||||
@description << " in context '#{context.name}'"
|
||||
end
|
||||
|
||||
project_id = @params['project']
|
||||
if project_id
|
||||
conditions << " AND (project_id = #{project_id})"
|
||||
project = @user.projects.find(project_id)
|
||||
@title << " for #{project.name}"
|
||||
@description << " for project '#{project.name}'"
|
||||
end
|
||||
|
||||
@todos = @user.todos.find_all_by_done(false, options )
|
||||
@headers["Content-Type"] = "text/xml; charset=utf-8"
|
||||
end
|
||||
|
||||
# Builds a plain text page listing all the next actions,
|
||||
# sorted by context (contexts are sorted by position, as on the home page).
|
||||
# Builds a plain text page listing uncompleted next actions,
|
||||
# grouped by context (contexts are sorted by position, as on the home page).
|
||||
# Showing notes doesn't make much sense here so they are omitted.
|
||||
# Hidden contexts are also hidden in the text view
|
||||
# You can use this with GeekTool to get your next actions
|
||||
# on the desktop:
|
||||
# curl [url from "TXT" link on todo/list]
|
||||
#
|
||||
def na_text
|
||||
@contexts = @user.contexts.collect { |x| x.hide? ? nil:x }.compact.sort! { |x,y| x.position <=> y.position }
|
||||
def text
|
||||
conditions = '(done = 0)'
|
||||
options = {:conditions => conditions}
|
||||
|
||||
limit = @params['limit']
|
||||
options[:limit] = limit if limit
|
||||
|
||||
if @params['due']
|
||||
due_within = @params['due'].to_i
|
||||
due_within_date_s = due_within.days.from_now.strftime("%Y-%m-%d")
|
||||
conditions << " AND (due <= '#{due_within_date_s}')"
|
||||
end
|
||||
|
||||
context_id = @params['context']
|
||||
if context_id
|
||||
conditions << " AND (context_id = #{context_id})"
|
||||
context = @user.contexts.find(context_id)
|
||||
@contexts = [context]
|
||||
end
|
||||
|
||||
project_id = @params['project']
|
||||
if project_id
|
||||
conditions << " AND (project_id = #{project_id})"
|
||||
project = @user.projects.find(project_id)
|
||||
end
|
||||
|
||||
@todos = @user.todos.find_all_by_done(false, options )
|
||||
|
||||
if (!@contexts)
|
||||
@contexts = @user.contexts.find_all_by_hide(false)
|
||||
end
|
||||
@headers["Content-Type"] = "text/plain; charset=utf-8"
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -189,6 +189,11 @@ class TodoController < ApplicationController
|
|||
archive_date = Time.now - 32 * (60 * 60 * 24)
|
||||
@done_archive = @done.collect { |x| archive_date >= x.completed ? x:nil }.compact
|
||||
end
|
||||
|
||||
def feeds
|
||||
self.init
|
||||
@page_title = "TRACKS::Feeds"
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue