mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-31 22:38:49 +01:00
Also fixes #109: lolindrath's patch (plus a bit of extra tinkering) means that newly created and newly edited actions get the [C] link if they are on the projects page and the [P] link otherwise. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@147 a4c988fc-2ded-0310-b66e-134b36920a42
46 lines
1.5 KiB
Ruby
46 lines
1.5 KiB
Ruby
# Produces an feeds of the next actions, both RSS and plain text
|
|
#
|
|
class FeedController < ApplicationController
|
|
|
|
helper :feed
|
|
model :todo, :context, :project
|
|
|
|
before_filter :check_token_against_user_word
|
|
|
|
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 }
|
|
@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).
|
|
# 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 }
|
|
@headers["Content-Type"] = "text/plain; charset=utf-8"
|
|
end
|
|
|
|
protected
|
|
|
|
# Check whether the token in the URL matches the word in the User's table
|
|
def check_token_against_user_word
|
|
@user = User.find_by_login( @params['name'] )
|
|
unless ( @params['token'] == @user.word)
|
|
render :text => "Sorry, you don't have permission to view this page."
|
|
return false
|
|
end
|
|
end
|
|
|
|
end
|