From ec69c715646b6893ff7f266d516235449abab199 Mon Sep 17 00:00:00 2001 From: bsag Date: Wed, 30 Mar 2005 15:35:37 +0000 Subject: [PATCH] [Contributed by Nicholas Lee] Changes to the way that URLs are specified which should improve the situation for people using Tracks in a subdirectory. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@54 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/application.rb | 3 --- tracks/app/controllers/context_controller.rb | 4 ++-- tracks/app/controllers/todo_controller.rb | 4 ++-- tracks/app/views/context/_not_done.rhtml | 15 ++++++++++++--- tracks/app/views/context/list.rhtml | 4 +++- tracks/app/views/feed/na_feed.rxml | 3 ++- tracks/app/views/layouts/scaffold.rhtml | 2 +- tracks/app/views/layouts/standard.rhtml | 8 +++----- tracks/app/views/project/_not_done.rhtml | 16 +++++++++++++--- tracks/app/views/project/edit.rhtml | 2 +- tracks/app/views/project/list.rhtml | 6 +++++- tracks/app/views/todo/_done.rhtml | 4 ++-- tracks/app/views/todo/_not_done.rhtml | 9 +++++++-- tracks/app/views/todo/edit.rhtml | 2 +- tracks/config/routes.rb | 6 +++++- tracks/doc/CHANGENOTES.txt | 1 + tracks/public/stylesheets/standard.css | 13 +++++++++++++ 17 files changed, 73 insertions(+), 29 deletions(-) diff --git a/tracks/app/controllers/application.rb b/tracks/app/controllers/application.rb index 2949cafb..62085a88 100644 --- a/tracks/app/controllers/application.rb +++ b/tracks/app/controllers/application.rb @@ -4,9 +4,6 @@ require_dependency "login_system" require 'date' -$notes_img = "" -$done_img = "" - class ApplicationController < ActionController::Base helper :application diff --git a/tracks/app/controllers/context_controller.rb b/tracks/app/controllers/context_controller.rb index b03b0661..1d82b8d4 100644 --- a/tracks/app/controllers/context_controller.rb +++ b/tracks/app/controllers/context_controller.rb @@ -93,7 +93,7 @@ class ContextController < ApplicationController expire_action(:controller => "context", :action => "list") item = Todo.new item.attributes = @params["new_item"] - where = Context.find_by_id(item.context_id) + # where = Context.find_by_id(item.context_id) back_to = urlize(where.name) @@ -112,7 +112,7 @@ class ContextController < ApplicationController # If you choose to go ahead, any actions in the context will also be deleted. def destroy expire_action(:controller => "context", :action => "list") - context = Context.find(@params['id']) + context = Context.find( @params['id'] ) if context.destroy flash["confirmation"] = "Succesfully deleted context \"#{context.name}\"" redirect_to( :action => "list" ) diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index 2d8cceed..281506bd 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -121,8 +121,8 @@ class TodoController < ApplicationController item.toggle!('done') if item.save - #flash["confirmation"] = "Next action \"#{item.description}\" marked as completed" - #redirect_to( :action => "list" ) + flash["confirmation"] = "Next action \"#{item.description}\" marked as completed" + redirect_to( :action => "list" ) else flash["warning"] = "Couldn't mark action \"#{item.description}\" as completed" redirect_to( :action => "list" ) diff --git a/tracks/app/views/context/_not_done.rhtml b/tracks/app/views/context/_not_done.rhtml index e0ae5c66..399c1597 100644 --- a/tracks/app/views/context/_not_done.rhtml +++ b/tracks/app/views/context/_not_done.rhtml @@ -1,15 +1,24 @@ <% @item = not_done %> - <%= check_box( "item", "done", "onclick" => "document.location.href='/todo/toggle_check/#{@item.id}'" ) %> - <%= link_image_to( "edit", { :controller => "todo", :action => "edit", :id => @item.id }, :title => "Edit item", :size => "10x10", :border => "0" ) + " " + link_image_to( "delete", { :controller => "todo", :action => "destroy", :id => @item.id }, :title => "Delete item", :size => "10x10", :border => "0", :confirm => "Are you sure you want to delete this entry: #{@item.description}" ) + " " %> + <%= + link = url_for( :controller => 'todo', :action => 'toggle_check', :id => "#{@item.id}" ); check_box( "item", "done", :onclick => "document.location.href='#{link}'" ) + %> + + + <%= + link_to(image_tag( "edit", :title => "Edit item", :width=>"10", :height=>"10", :border=>"0"), { :controller =>"todo", :action => "edit", :id => @item.id } ) + " " + link_to(image_tag( "delete", :title => "Delete item", :width=>"10", :height=>"10", :border=>"0" ), { :controller => "todo", :action => "destroy", :id => @item.id}, :confirm => "Are you sure you want to delete this entry: #{@item.description}" ) + " " + %> + <%= due_date( @item.due ) %> <%= @item.description %> <% if @item.project_id %> <%= link_to( "[P]", { :controller => "project", :action => "show", :id => @item.project_id }, :title => "View project: #{@item.project['name']}" ) %> <% end %> <% if @item.notes? %> - <%= "" + $notes_img + "" %> + <%= "" + + image_tag( "notes", :width=>"10", :height=>"10", :border=>"0") + "" + %> <% m_notes = markdown( @item.notes ) %> <%= "
" + m_notes + "
" %> <% end %> diff --git a/tracks/app/views/context/list.rhtml b/tracks/app/views/context/list.rhtml index bb5a680a..eae39504 100644 --- a/tracks/app/views/context/list.rhtml +++ b/tracks/app/views/context/list.rhtml @@ -18,7 +18,9 @@ shown <% end %> - <%= link_image_to("edit", { :action => "edit", :id => @context.id }, :title => "Edit item", :size => "10x10", :border => "0" ) + " " + link_image_to("delete", { :action => "destroy", :id => @context.id }, :title => "Delete item", :size => "10x10", :border => "0", :confirm => "Are you sure you want to delete the context \"#{@context.name}?\" Any todos in this context will be deleted.") + " " %> + + <%= link_to(image_tag( "edit", :title => "Edit item", :width=>"10", :height=>"10", :border=>"0"), { :action => "edit", :id => @context.id } ) + " " + link_to(image_tag( "delete", :title => "Delete item", :width=>10, :height=>10, :border=>0 ), { :action => "destroy", :id => @context.id}, :confirm => "Are you sure you want to delete the context \"#{@context.name}?\" Any todos in this context will be deleted." ) %> + <% row += 1 %> <% end %> diff --git a/tracks/app/views/feed/na_feed.rxml b/tracks/app/views/feed/na_feed.rxml index f7e8fe1b..6b1bf732 100644 --- a/tracks/app/views/feed/na_feed.rxml +++ b/tracks/app/views/feed/na_feed.rxml @@ -6,7 +6,8 @@ xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do @not_done.each { |i| xml.item do xml.title(i.description) - xml.link("http://#{@request.host}:#{@request.port}/context/show/#{i.context_id}") + @link = url_for(:controller => 'context', :action => 'show', :id => "#{i.context_id}") + xml.link("http://#{@request.host}:#{@request.port}#{@link}") xml.description(i.context['name'].capitalize) end } diff --git a/tracks/app/views/layouts/scaffold.rhtml b/tracks/app/views/layouts/scaffold.rhtml index a57887a2..9633f9c9 100644 --- a/tracks/app/views/layouts/scaffold.rhtml +++ b/tracks/app/views/layouts/scaffold.rhtml @@ -2,7 +2,7 @@ Login - + <%= stylesheet_link_tag "scaffold" %> <%= @content_for_layout %> diff --git a/tracks/app/views/layouts/standard.rhtml b/tracks/app/views/layouts/standard.rhtml index a28039af..25f27e9c 100644 --- a/tracks/app/views/layouts/standard.rhtml +++ b/tracks/app/views/layouts/standard.rhtml @@ -4,7 +4,7 @@ <%= stylesheet_link_tag "standard" %> <%= javascript_include_tag "toggle_notes" %> <%= javascript_include_tag "calendar" %> - + <%= @page_title %> @@ -35,10 +35,8 @@ var moty = ["January","February","March","April","May","June","July","August","S
  • <%= link_to( "Completed", {:controller => "todo", :action => "completed"}, {:accesskey=>"d", :title=>"Completed AccessKey: Alt+D"} ) %>
  • Show
  • Hide
  • -
  • <%= link_to("RSS", {:controller => "feed", :action => "na_feed", :params => {"name", "#{@session['user']['login']}", "token", "#{@session['user']['word']}"}}, :title => "Subscribe to an RSS feed of your next actions" ) %>
  • -
  • <%= link_to("TXT", {:controller => "feed", :action => "na_text", :params => {"name", "#{@session['user']['login']}", "token", "#{@session['user']['word']}"}}, :title => "View a plain text feed of your next actions" ) %>
  • +
  • <%= link_to("RSS", {:controller => "feed", :action => "na_feed", :name => "#{@session['user']['login']}", :token => "#{@session['user']['word']}"}, :title => "Subscribe to an RSS feed of your next actions" ) %>
  • +
  • <%= link_to("TXT", {:controller => "feed", :action => "na_text", :name => "#{@session['user']['login']}", :token => "#{@session['user']['word']}"}, :title => "View a plain text feed of your next actions" ) %>
  • <%= link_to "Logout (#{@session['user']['login']}) »", :controller => "login", :action=>"logout"%>
  • diff --git a/tracks/app/views/project/_not_done.rhtml b/tracks/app/views/project/_not_done.rhtml index db73fe5f..e98ce4e7 100644 --- a/tracks/app/views/project/_not_done.rhtml +++ b/tracks/app/views/project/_not_done.rhtml @@ -1,14 +1,24 @@ <% @item = not_done %> - <%= check_box( "item", "done", "onclick" => "document.location.href='/todo/toggle_check/#{@item.id}'" ) %> - <%= link_image_to( "edit", { :controller => "todo", :action => "edit", :id => @item.id }, :title => "Edit item", :size => "10x10", :border => "0" ) + " " + link_image_to( "delete", { :controller => "todo", :action => "destroy", :id => @item.id }, :title => "Delete item", :size => "10x10", :border => "0", :confirm => "Are you sure you want to delete this entry: #{@item.description}" ) + " " %> + + <%= + link = url_for(:controller => 'todo', :action => 'toggle_check', :id => "#{@item.id}") + check_box( "item", "done", :onclick => "document.location.href='#{link}'" ) + %> + + + <%= + link_to(image_tag( "edit", :title => "Edit item", :width=>"10", :height=>"10", :border=>"0"), { :controller => "todo", :action => "edit", :id => @item.id } ) + " " + + link_to(image_tag( "delete", :title => "Delete item", :width=>"10", :height=>"10", :border=>"0"), { :controller => "todo", :action => "destroy", :id => @item.id}, :confirm => "Are you sure you want to delete this entry: #{@item.description}" ) + " " + %> + <%= due_date( @item.due ) %> <%= @item.description %> <% if @item.project_id %> <%= link_to( "[C]", { :controller => "context", :action => "show", :id => @item.context_id }, :title => "View context: #{@item.context['name'].capitalize}" ) %> <% end %> <% if @item.notes? %> - <%= "" + $notes_img + "" %> + <%= "" + image_tag( "notes", :width=>"10", :height=>"10", :border=>"0") + "" %> <% m_notes = markdown( @item.notes ) %> <%= "
    " + m_notes + "
    " %> <% end %> diff --git a/tracks/app/views/project/edit.rhtml b/tracks/app/views/project/edit.rhtml index 8f73008a..e04ec1ca 100644 --- a/tracks/app/views/project/edit.rhtml +++ b/tracks/app/views/project/edit.rhtml @@ -1,6 +1,6 @@

    Edit project

    -
    + <%= render_partial "edit_project", "@project" %>
    diff --git a/tracks/app/views/project/list.rhtml b/tracks/app/views/project/list.rhtml index 3f64356a..164ae914 100644 --- a/tracks/app/views/project/list.rhtml +++ b/tracks/app/views/project/list.rhtml @@ -10,7 +10,11 @@ <% end %> <%= @project.id.to_s %> <%= link_to ( "#{@project.name}", :action => "show", :name => urlize(@project.name) ) %> - <%= link_image_to( "edit", { :action => "edit", :id => @project.id }, :title => "Edit item", :size => "10x10", :border => "0" ) + " " + link_image_to( "delete", { :action => "destroy", :id => @project.id }, :title => "Delete item", :size => "10x10", :border => "0", :confirm => "Are you sure you want to delete the project \"#{@project.name}?\" Any todos in this project will be deleted." ) + " " %> + + <%= link_to(image_tag( "edit", :title => "Edit item", :width=>"10", :height=>"10", :border=>"0"), { :action => "edit", :id => @project.id } ) + " " + + link_to(image_tag( "delete", :title => "Delete item", :width=>"10", :height=>"10", :border=>"0"), { :action => "destroy", :id => @project.id}, :confirm => "Are you sure you want to delete this entry: #{@project.name}" ) + " " + %> + <% row += 1 %> <% end %> diff --git a/tracks/app/views/todo/_done.rhtml b/tracks/app/views/todo/_done.rhtml index a50832c0..278e5d8f 100644 --- a/tracks/app/views/todo/_done.rhtml +++ b/tracks/app/views/todo/_done.rhtml @@ -1,7 +1,7 @@ <% @done_item = done %> <% if @done_item.completed %> - <%= $done_img %> + <%= image_tag( "done", :width=>"16", :height=>"16", :border=>"0") %> <%= format_date( @done_item.completed ) %> <%= " " + @done_item.description + " "%> @@ -16,7 +16,7 @@ <% end %> <% if @done_item.notes? %> - <%= "" + $notes_img + "" %> + <%= "" + image_tag( "notes", :width=>"10", :height=>"10", :border=>"0") + "" %> <% m_notes = markdown( @done_item.notes ) %> <%= "
    " + m_notes + "
    " %> <% end %> diff --git a/tracks/app/views/todo/_not_done.rhtml b/tracks/app/views/todo/_not_done.rhtml index 707935ad..7b920441 100644 --- a/tracks/app/views/todo/_not_done.rhtml +++ b/tracks/app/views/todo/_not_done.rhtml @@ -1,14 +1,19 @@ <% @notdone_item = not_done %> <%= check_box( "item", "done", "onclick" => "markItemDone('action-#{@notdone_item.id}', '/todo/toggle_check/#{@notdone_item.id}', '#{@notdone_item.id}')" ) %> - <%= link_image_to( "edit", { :action => "edit", :id => @notdone_item.id }, :title => "Edit item", :size => "10x10", :border => "0" ) + " " + link_image_to( "delete", { :controller => "todo", :action => "destroy", :id => @notdone_item.id }, :title => "Delete item", :size => "10x10", :border => "0", :confirm => "Are you sure you want to delete this entry: #{@notdone_item.description}" ) + " " %> + + <%= link_to(image_tag( "edit", :title => "Edit item", :width=>"10", :height=>"10", :border=>"0"), { :action => "edit", :id => @notdone_item.id } ) + " " + + link_to(image_tag( "delete", :title => "Delete item", :width=>"10", :height=>"10", :border=>"0"), { :action => "destroy", :id => @notdone_item.id }, :confirm => "Are you sure you want to delete this entry: #{@notdone_item.description}" ) + " " %> + <%= due_date( @notdone_item.due ) %> <%= @notdone_item.description %> <% if @notdone_item.project_id %> <%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(@notdone_item.project.name) }, :title => "View project: #{@notdone_item.project.name}" ) %> <% end %> <% if @notdone_item.notes? %> - <%= "" + $notes_img + "" %> + <%= "" + + image_tag( "notes", :width=>"10", :height=>"10", :border=>"0") + "" + %> <% m_notes = markdown( @notdone_item.notes ) %> <%= "
    " + m_notes + "
    " %> <% end %> diff --git a/tracks/app/views/todo/edit.rhtml b/tracks/app/views/todo/edit.rhtml index 6ebc65c7..92d782f1 100644 --- a/tracks/app/views/todo/edit.rhtml +++ b/tracks/app/views/todo/edit.rhtml @@ -1,6 +1,6 @@

    Edit task

    -
    + <%= render_partial "todo/item", "@item" %>
    diff --git a/tracks/config/routes.rb b/tracks/config/routes.rb index d4f4517a..87b33623 100644 --- a/tracks/config/routes.rb +++ b/tracks/config/routes.rb @@ -8,7 +8,7 @@ ActionController::Routing::Routes.draw do |map| # Allow downloading Web Service WSDL as a file with an extension # instead of a file named 'wsdl' - map.connect ':controller/service.wsdl', :action => 'wsdl' + #map.connect ':controller/service.wsdl', :action => 'wsdl' # Index Route map.connect '', :controller => 'todo', :action => 'list' @@ -35,10 +35,14 @@ ActionController::Routing::Routes.draw do |map| map.connect 'project/:name', :controller => 'project', :action => 'show' map.connect 'project/:id', :controller => 'project', :action => 'show' map.connect 'delete/project/:id', :controller => 'project', :action => 'destroy' + + # Feed Routes + map.connect 'feed/:action/:name/:user', :controller => 'feed' map.connect 'add_item', :controller => 'todo', :action => 'add_item' # Install the default route as the lowest priority. + map.connect ':controller/:action' map.connect ':controller/:action/:id' end diff --git a/tracks/doc/CHANGENOTES.txt b/tracks/doc/CHANGENOTES.txt index 28abdd89..66615491 100644 --- a/tracks/doc/CHANGENOTES.txt +++ b/tracks/doc/CHANGENOTES.txt @@ -21,6 +21,7 @@ Project wiki: 6. [Contributed by Andrew Williams] Toggling of contexts in /todo/list to collapse or expand their display via a small '+' or '-' graphic. This is independent of the shown/hidden setting for contexts, and is ideal for just hiding things on the fly to focus your view. 7. [Contributed by Jim Ray] Jim added a host of fixes and bits of cleaning up, including a position column for contexts and projects to allow custom sorting, and changes to the links for pages to make them more human-readable. 8. I added a pop-up calendar to set the due date. This is entirely lifted from Michele's excellent tutorial on pxl8.com . It works well, but I need to make sure it doesn't break in postgresql or sqlite. +9. [Contributed by Nicholas Lee] Changes to the way that URLs are specified which should improve the situation for people using Tracks in a subdirectory. ## Version 1.02 diff --git a/tracks/public/stylesheets/standard.css b/tracks/public/stylesheets/standard.css index 74a1644f..37e51abc 100644 --- a/tracks/public/stylesheets/standard.css +++ b/tracks/public/stylesheets/standard.css @@ -276,6 +276,19 @@ input { margin-bottom: 5px; } +.feed { + font-family: verdana, sans-serif; + font-size: 10px; + font-weight:bold; + text-decoration:none; + color: white; + background-color: #F60; + border:1px solid; + border-color: #FC9 #630 #330 #F96; + padding:0px 3px 0px 3px; + margin:0px; + } + /* Popup calendar styles */ #calNavPY, #calNavPM {border:1px #999 solid}