New images (from eclipse.org) for the edit, delete, notes and up, down, top and bottom buttons. I've made a greyscale version for the default, then the coloured version gets loaded when the mouse is hovering over the button.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@93 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2005-06-04 15:55:58 +00:00
parent e202abac89
commit 9c912c18a5
42 changed files with 433 additions and 81 deletions

View file

@ -2,6 +2,7 @@
# Likewise will all the methods added be available for all controllers. # Likewise will all the methods added be available for all controllers.
require_dependency "login_system" require_dependency "login_system"
require_dependency "math/statistics"
require 'date' require 'date'
@ -29,5 +30,18 @@ class ApplicationController < ActionController::Base
def errors_for( obj ) def errors_for( obj )
error_messages_for( obj ) unless instance_eval("@#{obj}").nil? error_messages_for( obj ) unless instance_eval("@#{obj}").nil?
end end
def av_completed
completed = Todo.find(:all, :conditions => "done=1")
days = []
completed.each do |i|
days << (i.completed - i.created).to_f
end
return days.average, days.max
end
end
class Array
include Math::Statistics
end end

View file

@ -23,6 +23,7 @@ class TodoController < ApplicationController
@hidden_places = Context.find( :all, :conditions => "hide=1", :order => "position ASC" ) @hidden_places = Context.find( :all, :conditions => "hide=1", :order => "position ASC" )
@done = Todo.find( :all, :conditions => "done=1", :order => "completed DESC", @done = Todo.find( :all, :conditions => "done=1", :order => "completed DESC",
:limit => NO_OF_ACTIONS ) :limit => NO_OF_ACTIONS )
@av_days_to_completion, @max_days_to_completion = av_completed()
# Set count badge to number of not-done, not hidden context items # Set count badge to number of not-done, not hidden context items
@count = count_shown_items( @hidden_places ) @count = count_shown_items( @hidden_places )

View file

@ -5,9 +5,9 @@ class Todo < ActiveRecord::Base
# Description field can't be empty, and must be < 100 bytes # Description field can't be empty, and must be < 100 bytes
# Notes must be < 60,000 bytes (65,000 actually, but I'm being cautious) # Notes must be < 60,000 bytes (65,000 actually, but I'm being cautious)
validates_presence_of :description, :message => "no description provided" validates_presence_of :description
validates_length_of :description, :maximum => 100, :message => "description is too long" validates_length_of :description, :maximum => 100
validates_length_of :notes, :maximum => 60000, :message => "notes are too long" validates_length_of :notes, :maximum => 60000
# Add a creation date (Ruby object format) to item before it's saved # Add a creation date (Ruby object format) to item before it's saved
# if there is no existing creation date (this prevents creation date # if there is no existing creation date (this prevents creation date

View file

@ -1,17 +1,21 @@
<% context = context_listing %> <% context = context_listing %>
<div id="context-<%= context.id %>-container" class="container"> <div id="context-<%= context.id %>-container">
<!-- %= error_messages_for 'context' % --> <!-- %= error_messages_for 'context' % -->
<div id="context-<%= context.id %>-display" class="list"> <div id="context-<%= context.id %>-display">
<% if context.position % 2 == 0 %> <% if context.position % 2 == 0 %>
<div id="context-<%= context.id %>" class="even_row" style="display:'';"> <div id="context-<%= context.id %>" class="even_row" style="display:'';">
<% else %> <% else %>
<div id="context-<%= context.id %>" class="odd_row" style="display:'';"> <div id="context-<%= context.id %>" class="odd_row" style="display:'';">
<% end %> <% end %>
<div class="position"> <div class="position">
<%= link_to( "&#8670;", {:action => "move_top", :id => context.id}, :title => "Move to top" ) %> <%= link_to(image_tag("blank", :title=>"Move to top", :border=>"0", :width=>"16", :height=>"16"),
<%= link_to( "&#8593;", {:action => "move_up", :id => context.id}, :title => "Move up" ) %> {:action => "move_top", :id => context.id}, :title => "Move to top", :class=>"to_top") %>
<%= link_to( "&#8595;", {:action => "move_down", :id => context.id}, :title => "Move down" ) %> <%= link_to(image_tag("blank", :title=>"Move up", :border=>"0", :width=>"16", :height=>"16"),
<%= link_to( "&#8671;", {:action => "move_bottom", :id => context.id}, :title => "Move to bottom" ) %> {:action => "move_up", :id => context.id}, :title => "Move up", :class=>"up" ) %>
<%= link_to(image_tag("blank", :title=>"Move down", :border=>"0", :width=>"16", :height=>"16"),
{:action => "move_down", :id => context.id}, :title => "Move down", :class=>"down") %>
<%= link_to(image_tag("blank", :title=>"Move to bottom", :border=>"0", :width=>"16", :height=>"16"),
{:action => "move_bottom", :id => context.id}, :title => "Move to bottom", :class=>"to_bottom") %>
</div> </div>
<div class="data"> <div class="data">
<%= link_to( "#{context.name}", :action => "show", :name => urlize(context.name) ) %><%= " (" + Todo.count( "context_id=#{context.id} AND done=0" ).to_s + " actions)" %> <%= link_to( "#{context.name}", :action => "show", :name => urlize(context.name) ) %><%= " (" + Todo.count( "context_id=#{context.id} AND done=0" ).to_s + " actions)" %>
@ -24,11 +28,11 @@
<input type="checkbox" value="0" disabled="true" /> <input type="checkbox" value="0" disabled="true" />
<% end %> <% end %>
<%= link_to_function(image_tag( "edit", :title => "Edit item", :width=>"10", :height=>"10", :border=>"0"), "Element.toggle('context-#{context.id}','context-#{context.id}-edit-form'); new Effect.Appear('context-#{context.id}-edit-form'); Form.focus_first('form-context-#{context.id}');" ) + " " + <%= link_to_remote( image_tag("blank", :title =>"Delete context", :class=>"delete_item"),
link_to_remote( image_tag("delete", :title =>"Delete this context", :height=>"10", :width=>"10", :border=>"0"),
:update => "context-#{context.id}-container", :update => "context-#{context.id}-container",
:loading => "new Effect.Squish('context-#{context.id}-container')", :loading => "new Effect.Squish('context-#{context.id}-container')",
:url => { :controller => "context", :action => "destroy", :id => context.id }, :confirm => "Are you sure that you want to delete the context \'#{context.name}\'?" ) %> :url => { :controller => "context", :action => "destroy", :id => context.id }, :confirm => "Are you sure that you want to delete the context \'#{context.name}\'?" ) + " " +
link_to_function( image_tag( "blank", :title => "Edit context", :class=>"edit_item"), "Element.toggle('context-#{context.id}','context-#{context.id}-edit-form'); new Effect.Appear('context-#{context.id}-edit-form'); Form.focus_first('form-context-#{context.id}');" ) %>
</div> </div>
</div><!-- [end:context-context.id] --> </div><!-- [end:context-context.id] -->

View file

@ -11,14 +11,18 @@
<div id="item-<%= item.id %>"> <div id="item-<%= item.id %>">
<div class="big-box"> <div class="big-box">
<input type="checkbox" name="item_id" value="<%= item.id %>" onclick="document.forms['checkbox-notdone-<%= item.id %>'].onsubmit();" />
<%= <%=
link_to_function(image_tag( "edit", :title => "Edit item", :width=>"10", :height=>"10", :border=>"0"), "Element.toggle('item-#{item.id}','action-#{item.id}-edit-form'); new Effect.Appear('action-#{item.id}-edit-form'); Form.focusFirstElement('form-action-#{item.id}');" ) + " " + link_to_remote( image_tag("blank", :title =>"Delete this action", :class=>"delete_item"),
link_to_remote( image_tag("delete", :title =>"Delete this action"), :update => "item-#{item.id}-container",
:update => "item-#{item.id}-container", :loading => "new Effect.Squish('item-#{item.id}-container')",
:loading => "new Effect.Squish('item-#{item.id}-container')", :url => { :controller => "context", :action => "destroy_action", :id => item.id }, :confirm => "Are you sure that you want to delete the action \'#{item.description}\'?" ) + " " +
:url => { :controller => "context", :action => "destroy_action", :id => item.id }, :confirm => "Are you sure that you want to delete the action \'#{item.description}\'?" ) + " " link_to_function(image_tag( "blank", :title => "Edit item", :class=>"edit_item"), "Element.toggle('item-#{item.id}','action-#{item.id}-edit-form'); new Effect.Appear('action-#{item.id}-edit-form'); Form.focusFirstElement('form-action-#{item.id}');" ) + " "
%> %>
<!-- begin div.checkbox -->
<div class="checkbox">
<input type="checkbox" name="item_id" value="<%= item.id %>" onclick="document.forms['checkbox-notdone-<%= item.id %>'].onsubmit();" />
</div>
<!-- end div.checkbox -->
</div> </div>
<!-- start of div which has a class 'description' or 'stale_7d', 'stale_14d' etc --> <!-- start of div which has a class 'description' or 'stale_7d', 'stale_14d' etc -->
<%= staleness(item.created) %> <%= staleness(item.created) %>
@ -28,7 +32,7 @@
<%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(item.project.name) }, :title => "View project: #{item.project.name}" ) %> <%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(item.project.name) }, :title => "View project: #{item.project.name}" ) %>
<% end %> <% end %>
<% if item.notes? %> <% if item.notes? %>
<%= "<a href=\"javascript:Element.toggle('" + item.id.to_s + "')\" title=\"Show notes\">" + image_tag( "notes", :width=>"10", :height=>"10", :border=>"0") + "</a>" %> <%= "<a href=\"javascript:Element.toggle('" + item.id.to_s + "')\" class=\"show_notes\" title=\"Show notes\">" + image_tag( "blank", :width=>"16", :height=>"16", :border=>"0" ) + "</a>" %>
<% m_notes = markdown( item.notes ) %> <% m_notes = markdown( item.notes ) %>
<%= "<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">" + m_notes + "</div>" %> <%= "<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">" + m_notes + "</div>" %>
<% end %> <% end %>
@ -58,14 +62,19 @@
<div id="done-item-<%= item.id %>"> <div id="done-item-<%= item.id %>">
<div class="big-box"> <div class="big-box">
<input type="checkbox" name="item_id" value="<%= item.id %>" checked="checked" onclick="document.forms['checkbox-done-<%= item.id %>'].onsubmit();" />
<%= <%=
link_to_remote( image_tag("delete", :title =>"Delete this action"), link_to_remote( image_tag("blank", :title =>"Delete this action", :class=>"delete_item"),
:update => "done-item-#{item.id}-container", :update => "done-item-#{item.id}-container",
:loading => "new Effect.Squish('done-item-#{item.id}-container')", :loading => "new Effect.Squish('done-item-#{item.id}-container')",
:url => { :controller => "context", :action => "destroy_action", :id => item.id }, :confirm => "Are you sure that you want to delete the action \'#{item.description}\'?" ) + " " :url => { :controller => "context", :action => "destroy_action", :id => item.id }, :confirm => "Are you sure that you want to delete the action \'#{item.description}\'?" ) + " "
%> %>
<%= image_tag("blank") %>
</div><!-- [end:big-box] --> </div><!-- [end:big-box] -->
<!-- begin div.checkbox -->
<div class="checkbox">
<input type="checkbox" name="item_id" value="<%= item.id %>" checked="checked" onclick="document.forms['checkbox-done-<%= item.id %>'].onsubmit();" />
</div>
<!-- end div.checkbox -->
<div class="description"> <div class="description">
<span class="grey"><%= format_date( item.completed ) %></span> <span class="grey"><%= format_date( item.completed ) %></span>
<%= item.description %> <%= item.description %>
@ -73,7 +82,7 @@
<%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(item.project.name) }, :title => "View project: #{item.project.name}" ) %> <%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(item.project.name) }, :title => "View project: #{item.project.name}" ) %>
<% end %> <% end %>
<% if item.notes? %> <% if item.notes? %>
<%= "<a href=\"javascript:Element.toggle('" + item.id.to_s + "')\" title=\"Show notes\">" + image_tag( "notes", :width=>"10", :height=>"10", :border=>"0") + "</a>" %> <%= "<a href=\"javascript:Element.toggle('" + item.id.to_s + "')\" class=\"show_notes\" title=\"Show notes\">" + image_tag( "blank", :width=>"16", :height=>"16", :border=>"0" ) + "</a>" %>
<% m_notes = markdown( item.notes ) %> <% m_notes = markdown( item.notes ) %>
<%= "<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">" + m_notes + "</div>" %> <%= "<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">" + m_notes + "</div>" %>
<% end %> <% end %>

View file

@ -8,10 +8,14 @@
<div id="project-<%= project.id %>" class="odd_row" style="display:'';"> <div id="project-<%= project.id %>" class="odd_row" style="display:'';">
<% end %> <% end %>
<div class="position"> <div class="position">
<%= link_to( "&#8670;", {:action => "move_top", :id => project.id}, :title => "Move to top" ) %> <%= link_to(image_tag("blank", :title=>"Move to top", :border=>"0", :width=>"16", :height=>"16"),
<%= link_to( "&#8593;", {:action => "move_up", :id => project.id}, :title => "Move up" ) %> {:action => "move_top", :id => project.id}, :title => "Move to top", :class=>"to_top") %>
<%= link_to( "&#8595;", {:action => "move_down", :id => project.id}, :title => "Move down" ) %> <%= link_to(image_tag("blank", :title=>"Move up", :border=>"0", :width=>"16", :height=>"16"),
<%= link_to( "&#8671;", {:action => "move_bottom", :id => project.id}, :title => "Move to bottom" ) %> {:action => "move_up", :id => project.id}, :title => "Move up", :class=>"up" ) %>
<%= link_to(image_tag("blank", :title=>"Move down", :border=>"0", :width=>"16", :height=>"16"),
{:action => "move_down", :id => project.id}, :title => "Move down", :class=>"down") %>
<%= link_to(image_tag("blank", :title=>"Move to bottom", :border=>"0", :width=>"16", :height=>"16"),
{:action => "move_bottom", :id => project.id}, :title => "Move to bottom", :class=>"to_bottom") %>
</div> </div>
<div class="data"> <div class="data">
<%= link_to( "#{project.name}", :action => "show", :name => urlize(project.name) ) %><%= " (" + Todo.count( "project_id=#{project.id} AND done=0" ).to_s + " actions)" %> <%= link_to( "#{project.name}", :action => "show", :name => urlize(project.name) ) %><%= " (" + Todo.count( "project_id=#{project.id} AND done=0" ).to_s + " actions)" %>
@ -23,11 +27,11 @@
<input type="checkbox" value="0" disabled="true" /> <input type="checkbox" value="0" disabled="true" />
<% end -%> <% end -%>
<%= link_to_function(image_tag( "edit", :title => "Edit item", :width=>"10", :height=>"10", :border=>"0"), "Element.toggle('project-#{project.id}','project-#{project.id}-edit-form'); new Effect.Appear('project-#{project.id}-edit-form'); Form.focus_first('form-project-#{project.id}');" ) + " " + <%= link_to_remote( image_tag("blank", :title =>"Delete project", :class=>"delete_item"),
link_to_remote( image_tag("delete", :title =>"Delete this project",:width=>"10", :height=>"10", :border=>"0"),
:update => "project-#{project.id}-container", :update => "project-#{project.id}-container",
:loading => "new Effect.Squish('project-#{project.id}-container')", :loading => "new Effect.Squish('project-#{project.id}-container')",
:url => { :controller => "project", :action => "destroy", :id => project.id }, :confirm => "Are you sure that you want to delete the project \'#{project.name}\'?" ) %> :url => { :controller => "project", :action => "destroy", :id => project.id }, :confirm => "Are you sure that you want to delete the project \'#{project.name}\'?" ) + " " +
link_to_function(image_tag( "blank", :title => "Edit item", :class=>"edit_item"), "Element.toggle('project-#{project.id}','project-#{project.id}-edit-form'); new Effect.Appear('project-#{project.id}-edit-form'); Form.focus_first('form-project-#{project.id}');" ) %>
</div> </div>
</div><!-- [end:project-project.id] --> </div><!-- [end:project-project.id] -->

View file

@ -11,15 +11,19 @@
<div id="item-<%= item.id %>"> <div id="item-<%= item.id %>">
<div class="big-box"> <div class="big-box">
<input type="checkbox" name="item_id" value="<%= item.id %>" onclick="document.forms['checkbox-notdone-<%= item.id %>'].onsubmit();" />
<%= <%=
link_to_function(image_tag( "edit", :title => "Edit item", :width=>"10", :height=>"10", :border=>"0"), "Element.toggle('item-#{item.id}','action-#{item.id}-edit-form'); new Effect.Appear('action-#{item.id}-edit-form'); Form.focusFirstElement('form-action-#{item.id}');" ) + " " + link_to_remote( image_tag("blank", :title =>"Delete action", :class=>"delete_item"),
link_to_remote( image_tag("delete", :title =>"Delete this action"),
:update => "item-#{item.id}-container", :update => "item-#{item.id}-container",
:loading => "new Effect.Squish('item-#{item.id}-container')", :loading => "new Effect.Squish('item-#{item.id}-container')",
:url => { :controller => "project", :action => "destroy_action", :id => item.id }, :confirm => "Are you sure that you want to delete the action \'#{item.description}\'?" ) + " " :url => { :controller => "project", :action => "destroy_action", :id => item.id }, :confirm => "Are you sure that you want to delete the action \'#{item.description}\'?" ) + " " +
link_to_function(image_tag( "blank", :title => "Edit action", :class=>"edit_item"), "Element.toggle('item-#{item.id}','action-#{item.id}-edit-form'); new Effect.Appear('action-#{item.id}-edit-form'); Form.focusFirstElement('form-action-#{item.id}');" ) + " "
%> %>
</div> </div>
<!-- begin div.checkbox -->
<div class="checkbox">
<input type="checkbox" name="item_id" value="<%= item.id %>" onclick="document.forms['checkbox-notdone-<%= item.id %>'].onsubmit();" />
</div>
<!-- end div.checkbox -->
<!-- start of div which has a class 'description' or 'stale_7d', 'stale_14d' etc --> <!-- start of div which has a class 'description' or 'stale_7d', 'stale_14d' etc -->
<%= staleness(item.created) %> <%= staleness(item.created) %>
<%= due_date( item.due ) %> <%= due_date( item.due ) %>
@ -28,7 +32,7 @@
<%= link_to( "[C]", { :controller => "context", :action => "show", :name => urlize(item.context.name) }, :title => "View context: #{item.context.name}" ) %> <%= link_to( "[C]", { :controller => "context", :action => "show", :name => urlize(item.context.name) }, :title => "View context: #{item.context.name}" ) %>
<% end %> <% end %>
<% if item.notes? %> <% if item.notes? %>
<%= "<a href=\"javascript:Element.toggle('" + item.id.to_s + "')\" title=\"Show notes\">" + image_tag( "notes", :width=>"10", :height=>"10", :border=>"0") + "</a>" %> <%= "<a href=\"javascript:Element.toggle('" + item.id.to_s + "')\" class=\"show_notes\" title=\"Show notes\">" + image_tag( "blank", :width=>"16", :height=>"16", :border=>"0" ) + "</a>" %>
<% m_notes = markdown( item.notes ) %> <% m_notes = markdown( item.notes ) %>
<%= "<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">" + m_notes + "</div>" %> <%= "<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">" + m_notes + "</div>" %>
<% end %> <% end %>
@ -58,14 +62,18 @@
<div id="done-item-<%= item.id %>"> <div id="done-item-<%= item.id %>">
<div class="big-box"> <div class="big-box">
<input type="checkbox" name="item_id" value="<%= item.id %>" checked="checked" onclick="document.forms['checkbox-done-<%= item.id %>'].onsubmit();" />
<%= <%=
link_to_remote( image_tag("delete", :title =>"Delete this action"), link_to_remote( image_tag("blank", :title =>"Delete action", :class=>"delete_item"),
:update => "done-item-#{item.id}-container", :update => "done-item-#{item.id}-container",
:loading => "new Effect.Squish('done-item-#{item.id}-container')", :loading => "new Effect.Squish('done-item-#{item.id}-container')",
:url => { :controller => "project", :action => "destroy_action", :id => item.id }, :confirm => "Are you sure that you want to delete the action \'#{item.description}\'?" ) + " " :url => { :controller => "project", :action => "destroy_action", :id => item.id }, :confirm => "Are you sure that you want to delete the action \'#{item.description}\'?" ) + " "
%> %>
</div><!-- [end:big-box] --> </div><!-- [end:big-box] -->
<!-- begin div.checkbox -->
<div class="checkbox">
<input type="checkbox" name="item_id" value="<%= item.id %>" checked="checked" onclick="document.forms['checkbox-done-<%= item.id %>'].onsubmit();" />
</div>
<!-- end div.checkbox -->
<div class="description"> <div class="description">
<span class="grey"><%= format_date( item.completed ) %></span> <span class="grey"><%= format_date( item.completed ) %></span>
<%= item.description %> <%= item.description %>
@ -73,7 +81,7 @@
<%= link_to( "[C]", { :controller => "context", :action => "show", :name => urlize(item.context.name) }, :title => "View context: #{item.context.name}" ) %> <%= link_to( "[C]", { :controller => "context", :action => "show", :name => urlize(item.context.name) }, :title => "View context: #{item.context.name}" ) %>
<% end %> <% end %>
<% if item.notes? %> <% if item.notes? %>
<%= "<a href=\"javascript:Element.toggle('" + item.id.to_s + "')\" title=\"Show notes\">" + image_tag( "notes", :width=>"10", :height=>"10", :border=>"0") + "</a>" %> <%= "<a href=\"javascript:Element.toggle('" + item.id.to_s + "')\" class=\"show_notes\" title=\"Show notes\">" + image_tag( "blank", :width=>"16", :height=>"16", :border=>"0" ) + "</a>" %>
<% m_notes = markdown( item.notes ) %> <% m_notes = markdown( item.notes ) %>
<%= "<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">" + m_notes + "</div>" %> <%= "<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">" + m_notes + "</div>" %>
<% end %> <% end %>

View file

@ -1,7 +1,8 @@
<% <%
@item = action_edit_form @item = action_edit_form
%> %>
<!-- %= error_messages_for 'item' % --> <%= error_messages_for("item") %>
<%= hidden_field( "item", "id" ) %> <%= hidden_field( "item", "id" ) %>
<table> <table>
<tr> <tr>

View file

@ -11,15 +11,19 @@
<div id="item-<%= item.id %>"> <div id="item-<%= item.id %>">
<div class="big-box"> <div class="big-box">
<input type="checkbox" name="item_id" value="<%= item.id %>" onclick="document.forms['checkbox-notdone-<%= item.id %>'].onsubmit();" />
<%= <%=
link_to_function(image_tag( "edit", :title => "Edit item", :width=>"10", :height=>"10", :border=>"0"), "Element.toggle('item-#{item.id}','action-#{item.id}-edit-form'); new Effect.Appear('action-#{item.id}-edit-form'); Form.focusFirstElement('form-action-#{item.id}')" ) + " " + link_to_remote( image_tag("blank", :title =>"Delete action", :class=>"delete_item"),
link_to_remote( image_tag("delete", :title =>"Delete this action"), :update => "item-#{item.id}-container",
:update => "item-#{item.id}-container", :loading => "new Effect.Squish('item-#{item.id}-container')",
:loading => "new Effect.Squish('item-#{item.id}-container')", :url => { :controller => "todo", :action => "destroy_action", :id => item.id },
:url => { :controller => "todo", :action => "destroy_action", :id => item.id }, :confirm => "Are you sure that you want to delete the action \'#{item.description}\'?" ) + " " :confirm => "Are you sure that you want to delete the action, \'#{item.description}\'?") + " " +
link_to_function(image_tag( "blank", :title => "Edit action", :class => "edit_item"),
"Element.toggle('item-#{item.id}','action-#{item.id}-edit-form'); new Effect.Appear('action-#{item.id}-edit-form'); Form.focusFirstElement('form-action-#{item.id}')" ) + " "
%> %>
</div> </div>
<div class="checkbox">
<input type="checkbox" name="item_id" value="<%= item.id %>" onclick="document.forms['checkbox-notdone-<%= item.id %>'].onsubmit();" />
</div>
<!-- start of div which has a class 'description' or 'stale_7d', 'stale_14d' etc --> <!-- start of div which has a class 'description' or 'stale_7d', 'stale_14d' etc -->
<%= staleness(item.created) %> <%= staleness(item.created) %>
<%= due_date( item.due ) %> <%= due_date( item.due ) %>
@ -28,7 +32,7 @@
<%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(item.project.name) }, :title => "View project: #{item.project.name}" ) %> <%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(item.project.name) }, :title => "View project: #{item.project.name}" ) %>
<% end %> <% end %>
<% if item.notes? %> <% if item.notes? %>
<%= "<a href=\"javascript:Element.toggle('" + item.id.to_s + "')\" title=\"Show notes\">" + image_tag( "notes", :width=>"10", :height=>"10", :border=>"0") + "</a>" %> <%= "<a href=\"javascript:Element.toggle('" + item.id.to_s + "')\" class=\"show_notes\" title=\"Show notes\">" + image_tag( "blank", :width=>"16", :height=>"16", :border=>"0" ) + "</a>" %>
<% m_notes = markdown( item.notes ) %> <% m_notes = markdown( item.notes ) %>
<%= "<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">" + m_notes + "</div>" %> <%= "<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">" + m_notes + "</div>" %>
<% end %> <% end %>
@ -58,14 +62,19 @@
<div id="done-item-<%= item.id %>"> <div id="done-item-<%= item.id %>">
<div class="big-box"> <div class="big-box">
<input type="checkbox" name="item_id" value="<%= item.id %>" checked="checked" onclick="document.forms['checkbox-done-<%= item.id %>'].onsubmit();" />
<%= <%=
link_to_remote( image_tag("delete", :title =>"Delete this action"), link_to_remote( image_tag("blank", :title =>"Delete action", :class=>"delete_item"),
:update => "done-item-#{item.id}-container", :update => "done-item-#{item.id}-container",
:loading => "new Effect.Squish('done-item-#{item.id}-container')", :loading => "new Effect.Squish('done-item-#{item.id}-container')",
:url => { :controller => "todo", :action => "destroy_action", :id => item.id }, :confirm => "Are you sure that you want to delete the action \'#{item.description}\'?" ) + " " :url => { :controller => "todo", :action => "destroy_action", :id => item.id }, :confirm => "Are you sure that you want to delete the action \'#{item.description}\'?" ) + " "
%> %>
<%= image_tag("blank") %>
</div><!-- [end:big-box] --> </div><!-- [end:big-box] -->
<!-- begin div.checkbox -->
<div class="checkbox">
<input type="checkbox" name="item_id" value="<%= item.id %>" checked="checked" onclick="document.forms['checkbox-done-<%= item.id %>'].onsubmit();" />
</div>
<!-- end div.checkbox -->
<div class="description"> <div class="description">
<span class="grey"><%= format_date( item.completed ) %></span> <span class="grey"><%= format_date( item.completed ) %></span>
<%= item.description %> <%= item.description %>
@ -73,7 +82,7 @@
<%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(item.project.name) }, :title => "View project: #{item.project.name}" ) %> <%= link_to( "[P]", { :controller => "project", :action => "show", :name => urlize(item.project.name) }, :title => "View project: #{item.project.name}" ) %>
<% end %> <% end %>
<% if item.notes? %> <% if item.notes? %>
<%= "<a href=\"javascript:Element.toggle('" + item.id.to_s + "')\" title=\"Show notes\">" + image_tag( "notes", :width=>"10", :height=>"10", :border=>"0") + "</a>" %> <%= "<a href=\"javascript:Element.toggle('" + item.id.to_s + "')\" class=\"show_notes\" title=\"Show notes\">" + image_tag( "blank", :width=>"16", :height=>"16", :border=>"0" ) + "</a>" %>
<% m_notes = markdown( item.notes ) %> <% m_notes = markdown( item.notes ) %>
<%= "<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">" + m_notes + "</div>" %> <%= "<div class=\"notes\" id=\"" + item.id.to_s + "\" style=\"display:none\">" + m_notes + "</div>" %>
<% end %> <% end %>

View file

@ -2,7 +2,7 @@
<!-- begin div.new_actions --> <!-- begin div.new_actions -->
<div id="new_actions" class="new_actions" style="display:none"> <div id="new_actions" class="new_actions" style="display:none">
<h2>Fresh actions (hit refresh to sort)</h2> <h2>Fresh actions (hit <a href="javascript:window.location.reload()">refresh</a> to sort)</h2>
</div> </div>
<!-- end div.new_actions --> <!-- end div.new_actions -->
@ -10,8 +10,8 @@
<% @not_done = Todo.find_all("done=0 AND context_id=#{@shown_place.id}", "due IS NULL, due ASC, created ASC") -%> <% @not_done = Todo.find_all("done=0 AND context_id=#{@shown_place.id}", "due IS NULL, due ASC, created ASC") -%>
<% if !@not_done.empty? -%> <% if !@not_done.empty? -%>
<div class="contexts"> <div class="contexts">
<h2><a href="javascript:toggleSingle('c<%=@shown_place.id%>');javascript:toggleImage('toggle_context_<%=@shown_place.id%>')"> <h2><a href="javascript:toggleSingle('c<%=@shown_place.id%>');javascript:toggleImage('toggle_context_<%=@shown_place.id%>')"><%= image_tag("collapse.png", :name=>"toggle_context_#{@shown_place.id}", :border=>"0") %></a>
<img src="/images/collapse.png" name="toggle_context_<%= @shown_place.id %>"/></a><%= link_to( "#{@shown_place.name}", :controller => "context", :action => "show", :name => urlize(@shown_place.name) ) %></h2> <%= link_to( "#{@shown_place.name}", :controller => "context", :action => "show", :name => urlize(@shown_place.name) ) %></h2>
<div id="c<%= @shown_place.id %>" class="next_actions"> <div id="c<%= @shown_place.id %>" class="next_actions">
<% if @not_done.empty? -%> <% if @not_done.empty? -%>
@ -42,7 +42,7 @@
</div><!-- End of display_box --> </div><!-- End of display_box -->
<div id="input_box"> <div id="input_box">
<%= link_to_function( "Add the next action in this context &#187;", "Element.toggle('todo_new_action');Element.toggle('new_actions');Form.focusFirstElement('todo-form-new-action');", {:title => "Add the next action [Alt+n]", :accesskey => "n"}) %> <%= link_to_function( "Add the next action in this context &#187;", "Element.toggle('todo_new_action');Element.toggle('new_actions');Form.focusFirstElement('todo-form-new-action');", {:title => "Add the next action [Alt+n]", :accesskey => "n"}) %>
<div id="todo_new_action" class="context_new" style="display:none"> <div id="todo_new_action" class="context_new" style="display:none">
@ -92,14 +92,14 @@
<h3>Active Contexts:</h3> <h3>Active Contexts:</h3>
<ul> <ul>
<% for other_context in Context.find(:all, :conditions => "hide=0", :order => "position ASC") %> <% for other_context in Context.find(:all, :conditions => "hide=0", :order => "position ASC") %>
<li><%= link_to( other_context.name, { :controller => "context", :action => "show", :name => urlize(other_context.name) } ) + " (" + Todo.count( "project_id=#{other_context.id} AND done=0" ).to_s + " actions)" %></li> <li><%= link_to( other_context.name, { :controller => "context", :action => "show", :name => urlize(other_context.name) } ) + " (" + Todo.count( "context_id=#{other_context.id} AND done=0" ).to_s + " actions)" %></li>
<% end %> <% end %>
</ul> </ul>
<h3>Hidden Contexts:</h3> <h3>Hidden Contexts:</h3>
<ul> <ul>
<% for other_context in Context.find(:all, :conditions => "hide=1", :order => "position ASC") %> <% for other_context in Context.find(:all, :conditions => "hide=1", :order => "position ASC") %>
<li><%= link_to( other_context.name, { :controller => "context", :action => "show", :name => urlize(other_context.name) } ) + " (" + Todo.count( "project_id=#{other_context.id} AND done=0" ).to_s + " actions)" %></li> <li><%= link_to( other_context.name, { :controller => "context", :action => "show", :name => urlize(other_context.name) } ) + " (" + Todo.count( "context_id=#{other_context.id} AND done=0" ).to_s + " actions)" %></li>
<% end %> <% end %>
</ul> </ul>
</div><!-- End of input box --> </div><!-- End of input box -->

View file

@ -32,6 +32,7 @@ marked darker yellow, and those created more than 28 days ago (staleness_starts
yellow! yellow!
17. Contexts and projects can now be sorted in any order you like. Arrow buttons on the /contexts and /projects pages let you move an item to the top, up, down or to the bottom. For contexts, this affects the order in which they sort on the home page. 17. Contexts and projects can now be sorted in any order you like. Arrow buttons on the /contexts and /projects pages let you move an item to the top, up, down or to the bottom. For contexts, this affects the order in which they sort on the home page.
18. You can mark projects as completed (by editing the project on /projects). In the 'sidebar' active and completed projects are shown separately, but you can still view the completed project. 18. You can mark projects as completed (by editing the project on /projects). In the 'sidebar' active and completed projects are shown separately, but you can still view the completed project.
19. New images (from eclipse.org) for the edit, delete, notes and up, down, top and bottom buttons. I've made a greyscale version for the default, then the coloured version gets loaded when the mouse is hovering over the button.
## Version 1.02 ## Version 1.02

View file

@ -0,0 +1,253 @@
=begin
= module Math::Statistics
== SYNOPSIS
----
require "math/statistics"
class Array
include Math::Statistics
end
a = [-2,-1,1,2]
p a.sum
p a.avg
p a.var
p a.std
p a.Min
p a.Max
----
produces
----
0.0
0.0
2.5
1.58113883
-2
2
----
For hashes,
----
require "math/statistics"
class Hash
include Math::Statistics
Hash::default_block = lambda{|i,j| j}
end
h = {'alice'=>-2, 'bob'=>-1, 'cris'=>1, 'diana'=>2}
p h.sum
p h.avg
p h.var
p h.std
p h.Min
p h.Max
----
produces
----
0.0
0.0
2.5
1.58113883
-2
2
----
== DESCRIPTION
(({Math::Statistics})) provides basic statistical methods, i.e.,
sum, average, variance, standard deviation, min and max.
This module can be used after including to the target class.
The target class must be Enumerable, more precisely, this module
uses each, size, min, and max.
== CLASS METHOD
: default_block= aProc
Sets default block of the class. This block will be used by the methods.
: default_block
Returns default block for class if defined. Otherwise nil will be returnd.
== METHOD
: default_block= aProc
Sets default block of the object. This block will be used by the methods.
Priority of the blocks is in the other: in-place given block,
object's default then class's default.
: default_block
Returns default block if defined. Otherwise nil will be returnd.
: sum
: sum{...}
Returns sum. When a block is given, summation is taken over the
each result of block evaluation. The role of blocks in the below
are same to this one.
: average
: average{...}
: avg
: avg{...}
Returns average.
: variance
: variance{...}
: var
: var{...}
Returns variance.
: standard_deviation
: standard_deviation{...}
: std
: std{...}
Returns standard deviation.
: Min
: Min{...}
Returns minimum.
: Max
: Max{...}
Returns maximam.
== AUTHORS
Gotoken
== HISTORY
2001-02-28 created (gotoken#notwork.org)
=end
module Math
module Statistics
VERSION = "2001_02_18"
def self.append_features(mod)
unless mod < Enumerable
raise TypeError,
"`#{self}' can't be included non Enumerable (#{mod})"
end
def mod.default_block= (blk)
self.const_set("STAT_BLOCK", blk)
end
def mod.default_block
defined?(self::STAT_BLOCK) && self::STAT_BLOCK
end
super
end
def default_block
@stat_block || type.default_block
end
def default_block=(blk)
@stat_block = blk
end
def sum
sum = 0.0
if block_given?
each{|i| sum += yield(i)}
elsif default_block
each{|i| sum += default_block[*i]}
else
each{|i| sum += i}
end
sum
end
def average(&blk)
sum(&blk)/size
end
def variance(&blk)
sum2 = if block_given?
sum{|i| j=yield(i); j*j}
elsif default_block
sum{|i| j=default_block[*i]; j*j}
else
sum{|i| i**2}
end
sum2/size - average(&blk)**2
end
def standard_deviation(&blk)
Math::sqrt(variance(&blk))
end
def Min(&blk)
if block_given?
if min = find{|i| i}
min = yield(min)
each{|i|
j = yield(i)
min = j if min > j
}
min
end
elsif default_block
if min = find{|i| i}
min = default_block[*min]
each{|i|
j = default_block[*i]
min = j if min > j
}
min
end
else
min()
end
end
def Max(&blk)
if block_given?
if max = find{|i| i}
max = yield(max)
each{|i|
j = yield(i)
max = j if max < j
}
max
end
elsif default_block
if max = find{|i| i}
max = default_block[*max]
each{|i|
j = default_block[*i]
max = j if max > j
}
max
end
else
max()
end
end
alias avg average
alias std standard_deviation
alias var variance
end
end

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby #!/usr/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby #!/usr/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" require File.dirname(__FILE__) + "/../config/environment"
require 'dispatcher' require 'dispatcher'

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby #!/usr/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -13,8 +13,6 @@ p {
padding: 2px; padding: 2px;
} }
img {border: 0px;}
a, a:link, a:active, a:visited { a, a:link, a:active, a:visited {
color: #cc3334; color: #cc3334;
text-decoration: none; text-decoration: none;
@ -26,6 +24,31 @@ a:hover {
color: #fff; color: #fff;
background-color: #cc3334; background-color: #cc3334;
} }
/* Rules for the icon links */
img.edit_item {background-image: url(../images/edit_off.png); background-repeat: no-repeat; border: none;}
a:hover img.edit_item {background-image: url(../images/edit_on.png); background-color: transparent; background-repeat: no-repeat; border: none;}
img.delete_item {background-image: url(../images/delete_off.png); background-repeat: no-repeat; border: none;}
a:hover img.delete_item {background-image: url(../images/delete_on.png);background-color: transparent;background-repeat: no-repeat; border: none;}
a.to_top {background: transparent url(../images/top_off.png) no-repeat;}
a.to_top:hover {background: transparent url(../images/top_on.png) no-repeat;}
a.up {background: transparent url(../images/up_off.png) no-repeat;}
a.up:hover {background: transparent url(../images/up_on.png) no-repeat;}
a.down {background: transparent url(../images/down_off.png) no-repeat;}
a.down:hover {background: transparent url(../images/down_on.png) no-repeat;}
a.to_bottom {background: transparent url(../images/bottom_off.png) no-repeat;}
a.to_bottom:hover {background: transparent url(../images/bottom_on.png) no-repeat;}
a.show_notes {background-image: url(../images/notes_off.png); background-repeat: no-repeat; padding: 1px; background-color: transparent;}
a.show_notes:hover {background-image: url(../images/notes_on.png); background-repeat: no-repeat; padding: 1px; background-color: transparent;}
/* Structural divs */ /* Structural divs */
@ -146,14 +169,20 @@ h2 a:hover {
width: 20px; width: 20px;
} }
.big-box { div.big-box, div.big-box a, div.big-box a:hover {
float: left; float: left;
width: 55px;
vertical-align: middle; vertical-align: middle;
background-color: transparent;
} }
.checkbox {
float: left;
margin-left: 10px;
vertical-align: middle;
}
.description { .description {
margin-left: 60px; margin-left: 70px;
margin-right: 10px; margin-right: 10px;
} }
@ -258,19 +287,19 @@ h2 a:hover {
The colour of the background gets progressively yellower with age */ The colour of the background gets progressively yellower with age */
.stale_l1 { .stale_l1 {
margin-left: 60px; margin-left: 70px;
margin-right: 10px; margin-right: 10px;
background: #ffffCC; background: #ffffCC;
} }
.stale_l2 { .stale_l2 {
margin-left: 60px; margin-left: 70px;
margin-right: 10px; margin-right: 10px;
background: #ffff66; background: #ffff66;
} }
.stale_l3 { .stale_l3 {
margin-left: 60px; margin-left: 70px;
margin-right: 10px; margin-right: 10px;
background: #ffff00; background: #ffff00;
} }
@ -323,10 +352,6 @@ input {
} }
/* Positioning the 'cells' in the list */ /* Positioning the 'cells' in the list */
.position {text-align: left; width: 10%; float: left; font-size: 1.1em;}
.data {text-align: left; width: 60%; float: left;}
.buttons {text-align: right; width: 25%; margin-left: 75%;}
table.list { table.list {
margin-top: 0px; margin-top: 0px;
border-top: 1px solid #ccc; border-top: 1px solid #ccc;
@ -334,6 +359,29 @@ table.list {
border-right: 1px solid #ccc; border-right: 1px solid #ccc;
background: #fff; background: #fff;
} }
.position {
float: left;
}
img.position, a:hover img.position {
text-align: left;
vertical-align: middle;
background-color: transparent;
}
.data {
text-align: left;
margin-left: 40px;
float: left;
}
div.buttons, div.buttons a, div.buttons a:hover {
text-align: right;
margin-right: 0px;
vertical-align: middle;
background-color: transparent;
}
div#list-projects, div#list-contexts { div#list-projects, div#list-contexts {
border: 1px solid #999; border: 1px solid #999;

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby #!/usr/bin/ruby
if ARGV.empty? if ARGV.empty?
puts "Usage: benchmarker times 'Person.expensive_way' 'Person.another_expensive_way' ..." puts "Usage: benchmarker times 'Person.expensive_way' 'Person.another_expensive_way' ..."

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby #!/usr/bin/ruby
require 'rubygems' require 'rubygems'
require_gem 'rails' require_gem 'rails'
require 'breakpoint_client' require 'breakpoint_client'

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby #!/usr/bin/ruby
irb = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb' irb = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb'
require 'optparse' require 'optparse'

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby #!/usr/bin/ruby
ActiveRecord::Base.lock_mutex ActiveRecord::Base.lock_mutex
ActiveRecord::Base.connection.begin_db_transaction ActiveRecord::Base.connection.begin_db_transaction
at_exit do at_exit do

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby #!/usr/bin/ruby
ActiveRecord::Base.lock_mutex ActiveRecord::Base.lock_mutex
ActiveRecord::Base.connection.begin_db_transaction ActiveRecord::Base.connection.begin_db_transaction
at_exit do at_exit do

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby #!/usr/bin/ruby
require File.dirname(__FILE__) + '/../config/environment' require File.dirname(__FILE__) + '/../config/environment'
require 'rails_generator' require 'rails_generator'
require 'rails_generator/scripts/destroy' require 'rails_generator/scripts/destroy'

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby #!/usr/bin/ruby
require File.dirname(__FILE__) + '/../config/environment' require File.dirname(__FILE__) + '/../config/environment'
require 'rails_generator' require 'rails_generator'
require 'rails_generator/scripts/generate' require 'rails_generator/scripts/generate'

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby #!/usr/bin/ruby
if ARGV.empty? if ARGV.empty?
puts "Usage: profiler 'Person.expensive_method(10)' [times]" puts "Usage: profiler 'Person.expensive_method(10)' [times]"

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby #!/usr/bin/ruby
require File.dirname(__FILE__) + '/../config/environment' require File.dirname(__FILE__) + '/../config/environment'
eval(ARGV.first) eval(ARGV.first)

View file

@ -1,4 +1,4 @@
#!/usr/local/bin/ruby #!/usr/bin/ruby
require 'webrick' require 'webrick'
require 'optparse' require 'optparse'