Divide UserController into a UserController and a PreferencesController. Divide FeedController into a FeedController and a FeedlistController. Pull up layout and login filter into ApplicationController and override as needed. Ignored new tmp directories.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@376 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2006-12-13 08:31:48 +00:00
parent 1e4f462f21
commit 1d22f08670
25 changed files with 218 additions and 88 deletions

View file

@ -1,8 +1,6 @@
class AdminController < ApplicationController
before_filter :login_required
before_filter :admin_login_required
layout 'standard'
def index
@user_pages, @users = paginate :users, :order => 'login ASC', :per_page => 10

View file

@ -13,8 +13,11 @@ class ApplicationController < ActionController::Base
helper :application
include LoginSystem
layout 'standard'
before_filter :set_session_expiration
before_filter :get_current_user
prepend_before_filter :login_required
after_filter :set_charset

View file

@ -2,6 +2,8 @@ class BackendController < ApplicationController
wsdl_service_name 'Backend'
web_service_api TodoApi
web_service_scaffold :invoke
skip_before_filter :login_required
def new_todo(username, token, context_id, description)
check_token_against_user_word(username, token)

View file

@ -2,10 +2,8 @@ class ContextController < ApplicationController
helper :todo
prepend_before_filter :login_required
before_filter :init, :except => [:create, :destroy, :order]
before_filter :init_todos, :only => :show
layout "standard", :except => :date_preview
def index
list

View file

@ -3,19 +3,14 @@
class FeedController < ApplicationController
helper :feed
session :disabled => true, :except => 'index' # Prevents session control from interfering with feed
layout nil
before_filter :check_token_against_user_word, :except => 'index'
prepend_before_filter :login_required, :only => 'index'
session :disabled => true # Prevents session control from interfering with feed
skip_before_filter :login_required
before_filter :check_token_against_user_word
before_filter :prepare_for_feed, :only => [:rss, :text, :ical]
def index
@page_title = 'TRACKS::Feeds'
init_data_for_sidebar
render :layout => 'standard'
end
# Build an RSS feed
def rss
headers["Content-Type"] = "text/xml; charset=utf-8"

View file

@ -0,0 +1,11 @@
class FeedlistController < ApplicationController
helper :feedlist
def index
@page_title = 'TRACKS::Feeds'
init_data_for_sidebar
render :layout => 'standard'
end
end

View file

@ -1,6 +1,8 @@
class LoginController < ApplicationController
layout 'login'
skip_before_filter :set_session_expiration
skip_before_filter :login_required
open_id_consumer if Tracks::Config.auth_schemes.include?('open_id')
def login

View file

@ -2,7 +2,6 @@ class MobileController < ApplicationController
layout 'mobile'
prepend_before_filter :login_required
before_filter :init, :except => :update
# Plain list of all next actions, paginated 6 per page

View file

@ -1,9 +1,5 @@
class NoteController < ApplicationController
prepend_before_filter :login_required
layout "standard"
def index
@all_notes = @user.notes
@page_title = "TRACKS::All notes"

View file

@ -0,0 +1,25 @@
class PreferencesController < ApplicationController
def index
@page_title = "TRACKS::Preferences"
@prefs = @user.preference
end
def edit
@page_title = "TRACKS::Edit Preferences"
@prefs = @user.preference
render :object => @prefs
end
def update
user_success = @user.update_attributes(params['user'])
prefs_success = @user.preference.update_attributes(params['prefs'])
if user_success && prefs_success
redirect_to :action => 'index'
else
render :action => 'edit'
end
end
end

View file

@ -1,12 +1,9 @@
class ProjectController < ApplicationController
helper :todo
prepend_before_filter :login_required
before_filter :init, :except => [:create, :destroy, :order, :toggle_project_done]
before_filter :init_todos, :only => :show
layout "standard", :except => :date_preview
def index
list
render_action "list"

View file

@ -2,9 +2,8 @@ class TodoController < ApplicationController
helper :todo
prepend_before_filter :login_required
append_before_filter :init, :except => [ :destroy, :completed, :completed_archive, :check_tickler ]
layout "standard", :except => :date_preview
layout 'standard', :except => :date_preview
# Main method for listing tasks
# Set page title, and fill variables with contexts and done and not-done tasks

View file

@ -1,6 +1,5 @@
class UserController < ApplicationController
layout 'standard'
prepend_before_filter :login_required
if Tracks::Config.auth_schemes.include?('open_id')
open_id_consumer
before_filter :begin_open_id_auth, :only => :update_auth_type
@ -68,7 +67,7 @@ class UserController < ApplicationController
def update_password
if do_change_password_for(@user)
redirect_to :controller => 'user', :action => 'preferences'
redirect_to :controller => 'preferences'
else
redirect_to :controller => 'user', :action => 'change_password'
notify :warning, "There was a problem saving the password. Please retry."
@ -97,7 +96,7 @@ class UserController < ApplicationController
@user.auth_type = params[:user][:auth_type]
if @user.save
notify :notice, "Authentication type updated."
redirect_to :controller => 'user', :action => 'preferences'
redirect_to :controller => 'preferences'
else
notify :warning, "There was a problem updating your authentication type: #{ @user.errors.full_messages.join(', ')}"
redirect_to :controller => 'user', :action => 'change_auth_type'

View file

@ -66,24 +66,4 @@ module FeedHelper
sprintf("%s%s%s%s", @request.protocol, @request.host, @request.port_string, url_for(:controller => 'todo', :action => 'show', :id => todo.id))
end
def rss_feed_link(options = {})
image_tag = image_tag("feed-icon.png", :size => "16X16", :border => 0, :class => "rss-icon")
linkoptions = {:controller => 'feed', :action => 'rss', :login => "#{@user.login}", :token => "#{@user.word}"}
linkoptions.merge!(options)
link_to(image_tag, linkoptions, :title => "RSS feed")
end
def text_feed_link(options = {})
linkoptions = {:controller => 'feed', :action => 'text', :login => "#{@user.login}", :token => "#{@user.word}"}
linkoptions.merge!(options)
link_to('<span class="feed">TXT</span>', linkoptions, :title => "Plain text feed" )
end
def ical_feed_link(options = {})
linkoptions = {:controller => 'feed', :action => 'ical', :login => "#{@user.login}", :token => "#{@user.word}"}
linkoptions.merge!(options)
link_to('<span class="feed">iCal</span>', linkoptions, :title => "iCal feed")
end
end

View file

@ -0,0 +1,23 @@
module FeedlistHelper
def rss_feed_link(options = {})
image_tag = image_tag("feed-icon.png", :size => "16X16", :border => 0, :class => "rss-icon")
linkoptions = {:controller => 'feed', :action => 'rss', :login => "#{@user.login}", :token => "#{@user.word}"}
linkoptions.merge!(options)
link_to(image_tag, linkoptions, :title => "RSS feed")
end
def text_feed_link(options = {})
linkoptions = {:controller => 'feed', :action => 'text', :login => "#{@user.login}", :token => "#{@user.word}"}
linkoptions.merge!(options)
link_to('<span class="feed">TXT</span>', linkoptions, :title => "Plain text feed" )
end
def ical_feed_link(options = {})
linkoptions = {:controller => 'feed', :action => 'ical', :login => "#{@user.login}", :token => "#{@user.word}"}
linkoptions.merge!(options)
link_to('<span class="feed">iCal</span>', linkoptions, :title => "iCal feed")
end
end

View file

@ -0,0 +1,2 @@
module PreferencesHelper
end

View file

@ -0,0 +1,82 @@
<div id="display_box">
<div id="feeds">
<div id="feedlegend">
<h3>Legend:</h3>
<dl>
<dt><%= image_tag("feed-icon.png", :size => "16X16", :border => 0)%></dt><dd>RSS Feed</dd>
<dt><span class="feed">TXT</span></dt><dd>Plain Text Feed</dd>
<dt><span class="feed">iCal</span></dt><dd>iCal feed</dd>
</dl>
<p>Note: All feeds show only actions that have not been marked as done.</p>
</div>
<ul>
<li>
<%= rss_feed_link({ :limit => 15 }) %>
<%= text_feed_link({ :limit => 15 }) %>
<%= ical_feed_link({ :limit => 15 }) %>
Last 15 actions
</li>
<li>
<%= rss_feed_link %>
<%= text_feed_link %>
<%= ical_feed_link %>
All actions
</li>
<li>
<%= rss_feed_link({ :due => 0 }) %>
<%= text_feed_link({ :due => 0 }) %>
<%= ical_feed_link({ :due => 0 }) %>
Actions due today or earlier
</li>
<li>
<%= rss_feed_link({ :due => 6 }) %>
<%= text_feed_link({ :due => 6 }) %>
<%= ical_feed_link({ :due => 6 }) %>
Actions due in 7 days or earlier
</li>
<li>
<%= rss_feed_link({ :done => 7 }) %>
<%= text_feed_link({ :done => 7 }) %>
Actions completed in the last 7 days
</li>
<li>
<%= rss_feed_link({ :action => 'list_contexts_only', :feedtype => 'rss' }) %>
<%= text_feed_link({ :action => 'list_contexts_only', :feedtype => 'text' }) %>
All Contexts
</li>
<li>
<%= rss_feed_link({ :action => 'list_projects_only', :feedtype => 'rss' }) %>
<%= text_feed_link({ :action => 'list_projects_only', :feedtype => 'text' }) %>
All Projects
</li>
<li><h4>Feeds for uncompleted actions in a specific context:</h4>
<ul>
<% for context in @contexts %>
<li>
<%= rss_feed_link({ :context => context }) %>
<%= text_feed_link({ :context => context }) %>
<%= ical_feed_link({ :context => context }) %>
Next actions in <strong><%=h context.name %></strong>
</li>
<% end %>
</ul>
</li>
<li><h4>Feeds for uncompleted actions in a specific project:</h4>
<ul>
<% for project in @projects %>
<li>
<%= rss_feed_link({ :project => project }) %>
<%= text_feed_link({ :project => project }) %>
<%= ical_feed_link({ :project => project }) %>
Next actions for <strong><%=h project.name %></strong>
</li>
<% end %>
</ul>
</li>
</ul>
</div>
</div><!-- End of display_box -->
<div id="input_box">
<%= render "sidebar/sidebar" %>
</div><!-- End of input box -->

View file

@ -46,11 +46,11 @@
<li><%= navigation_link( "Tickler", {:controller => "todo", :action => "tickler"}, :title => "Tickler" ) %></li>
<li><%= navigation_link( "Done", {:controller => "todo", :action => "completed"}, {:accesskey=>"d", :title=>"Completed"} ) %></li>
<li><%= navigation_link( "Notes", {:controller => "note", :action => "index"}, {:accesskey => "o", :title => "Show all notes"} ) %></li>
<li><%= navigation_link( "Preferences", {:controller => "user", :action => "preferences"}, {:accesskey => "u", :title => "Show my preferences"} ) %></li>
<li><%= navigation_link( "Preferences", {:controller => "preferences", :action => "index"}, {:accesskey => "u", :title => "Show my preferences"} ) %></li>
<% if @user.is_admin? -%>
<li><%= navigation_link("Admin", {:controller => "admin", :action => "index"}, {:accesskey => "a", :title => "Add or delete users"} ) %></li>
<% end -%>
<li><%= navigation_link(image_tag("feed-icon.png", :size => "16X16", :border => 0), {:controller => "feed", :action => "index"}, :title => "See a list of available feeds" ) %></li>
<li><%= navigation_link(image_tag("feed-icon.png", :size => "16X16", :border => 0), {:controller => "feedlist", :action => "index"}, :title => "See a list of available feeds" ) %></li>
</ul>
</div>

View file

@ -19,7 +19,7 @@
</div>
<div id="input_box" class="container context">
<% form_tag :action => 'update_preferences' do %>
<% form_tag :action => 'update' do %>
<table>
<tr>
<td><label>first name:</label></td>
@ -62,7 +62,7 @@
<%= row_with_select_field("verbose_action_descriptors") %>
<tr><td><%= submit_tag "Update" %></td>
<td><%= link_to "Cancel", :controller => 'user', :action => 'preferences' %></td>
<td><%= link_to "Cancel", :action => 'index' %></td>
</tr>
</table>
<% end %>

View file

@ -26,7 +26,7 @@
<li>Verbose action descriptors: <span class="highlight"><%= @prefs.verbose_action_descriptors %></span></li>
</ul>
<div class="actions">
<%= link_to "Edit preferences &raquo;", { :controller => 'user', :action => 'edit_preferences'}, :class => 'edit_link' %>
<%= link_to "Edit preferences &raquo;", { :controller => 'preferences', :action => 'edit'}, :class => 'edit_link' %>
</div>
<h2>Your token</h2>

View file

@ -9,7 +9,7 @@
<% form_tag :action => 'update_auth_type' do %>
<div><label for="user_auth_type">Authentication type:</label> <%= select('user', 'auth_type', Tracks::Config.auth_schemes.collect {|p| [ p, p ] }) %></div>
<div id="open_id" style="display:<%= @user.auth_type == 'open_id' ? 'block' : 'none' %>"><label for="user_open_id_url">Identity URL:</label> <input type="text" name="openid_url" value="<%= @user.open_id_url %>" class="open_id" /></div>
<div class="actions"><%= submit_tag 'Change Authentication Type' %> <%= link_to 'Cancel', :action => 'preferences' %></div>
<div class="actions"><%= submit_tag 'Change Authentication Type' %> <%= link_to 'Cancel', :controller => 'preferences' %></div>
<%= observe_field( :user_auth_type, :function => "$('open_id').style.display = value == 'open_id' ? 'block' : 'none'") %>

View file

@ -17,7 +17,7 @@
<td><%= password_field "updateuser", "password_confirmation", :size => 40 %></td>
</tr>
<tr>
<td><%= link_to 'Cancel', :action => 'preferences' %></td>
<td><%= link_to 'Cancel', :controller => 'preferences' %></td>
<td><%= submit_tag 'Change password' %></td>
</tr>
</table>