From d25fc9ad8dbceb66fcf5f0c24184ca94c0406bdf Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Wed, 25 Jan 2012 15:52:46 +0100 Subject: [PATCH 01/40] Actively load active record --- stoptime.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/stoptime.rb b/stoptime.rb index d82f63a..dec6e67 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -12,6 +12,7 @@ require "action_view" require "active_support" require "camping" +require "camping/ar" require "markaby" require "pathname" require "sass/plugin/rack" From ed864e746aa7530f60af67cd38b7043044f47122 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Wed, 25 Jan 2012 15:53:24 +0100 Subject: [PATCH 02/40] Fix up some hacks that generate errors when used with Mab --- stoptime.rb | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index dec6e67..929d7fc 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -78,20 +78,28 @@ module StopTime end # = The Stop… Camping Time! Markaby extensions -class StopTime::Mab +module StopTime::Mab SUPPORTED = [:get, :post] - # Adds a method override field in form tags for (usually) unsupported - # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. - def tag!(tag, *attrs) - return super unless tag == :form && block_given? - attrs = attrs.last.is_a?(Hash) ? attrs.last : {} - meth = attrs[:method] - attrs[:method] = 'post' if override = !SUPPORTED.include?(meth) - super(tag, attrs) do - input :type => 'hidden', :name => '_method', :value => meth if override - yield - end + # # Adds a method override field in form tags for (usually) unsupported + # # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. + # def tag!(tag, *attrs) + # return super unless tag == :form && block_given? + # attrs = attrs.last.is_a?(Hash) ? attrs.last : {} + # meth = attrs[:method] + # attrs[:method] = 'post' if override = !SUPPORTED.include?(meth) + # super(tag, attrs) do + # input :type => 'hidden', :name => '_method', :value => meth if override + # yield + # end + # end + + def tag!(name, *args) + Kernel.p [name, args] + content = args.shift unless args.first.is_a?(Hash) + attrs = args.inject { |a,b| a.merge(b) } + Kernel.p [name, content, args] + super(name, content, attrs) end end From d3083e6fc5e19d8eae24f55d1f0658f5d83d4a1e Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Wed, 25 Jan 2012 15:53:43 +0100 Subject: [PATCH 03/40] More Mab compability: different doctype and text escaping --- stoptime.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 929d7fc..981f34e 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1349,7 +1349,8 @@ module StopTime::Views # The main layout used by all views. def layout - xhtml_strict do + doctype! + html do head do title "Stop… Camping Time!" # FIXME: improve static serving so that the hack below is not needed. @@ -1383,8 +1384,8 @@ module StopTime::Views h3 { a customer.name, :href => R(CustomersN, customer.id) } if @tasks[customer].empty? p do - text "No projects/tasks found! Create one " + - "#{a "here", :href => R(CustomersNTasksNew, customer.id)}." + text! "No projects/tasks found! Create one " + + "#{a "here", :href => R(CustomersNTasksNew, customer.id)}." end else table.overview do @@ -1543,7 +1544,7 @@ module StopTime::Views h2 "Customers" if @customers.empty? p do - text "None found! You can create one " + + text! "None found! You can create one " + "#{a "here", :href => R(CustomersNew)}." end else @@ -1705,8 +1706,8 @@ module StopTime::Views if @invoices.values.flatten.empty? p do - text "Found none! You can create one by " - "#{a "selecting a customer", :href => R(Customers)}." + text! "Found none! You can create one by " + "#{a "selecting a customer", :href => R(Customers)}." end else @invoices.keys.sort.each do |key| @@ -1994,7 +1995,7 @@ module StopTime::Views # menu item. def _menu_link(label, ctrl) # FIXME: dirty hack? - if self.helpers.class.to_s.match(/^#{ctrl.to_s}/) + if self.class.to_s.match(/^#{ctrl.to_s}/) li.selected { a label, :href => R(ctrl) } else li { a label, :href => R(ctrl) } From d40a4db28ed58cdf0f536e99cb27ade09514bebe Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 12:57:15 +0100 Subject: [PATCH 04/40] Actually load Mab instead of Markaby --- stoptime.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 981f34e..9dad845 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -12,12 +12,10 @@ require "action_view" require "active_support" require "camping" -require "camping/ar" -require "markaby" +require "camping/mab" require "pathname" require "sass/plugin/rack" -Markaby::Builder.set(:indent, 2) Camping.goes :StopTime unless defined? PUBLIC_DIR From b690f52d64336f0130f40c0346a73e3394c89f1c Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 12:57:37 +0100 Subject: [PATCH 05/40] Leave the form method override stuff for now --- stoptime.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 9dad845..3d7c5a9 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -76,8 +76,9 @@ module StopTime end # = The Stop… Camping Time! Markaby extensions -module StopTime::Mab - SUPPORTED = [:get, :post] +# FIXME: update for Mab! +module StopTime::Helpers + #SUPPORTED = [:get, :post] # # Adds a method override field in form tags for (usually) unsupported # # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. @@ -92,14 +93,6 @@ module StopTime::Mab # end # end - def tag!(name, *args) - Kernel.p [name, args] - content = args.shift unless args.first.is_a?(Hash) - attrs = args.inject { |a,b| a.merge(b) } - Kernel.p [name, content, args] - super(name, content, attrs) - end - end # = The Stop… Camping Time! models From 30440288d9544959a9d8631c9f7f716adbc57fa4 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 12:57:56 +0100 Subject: [PATCH 06/40] Updated views to use the instance vars and no longer rely on Markaby's method_missing --- stoptime.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 3d7c5a9..2d17e9c 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1407,7 +1407,7 @@ module StopTime::Views # FIXME: This should be done in a nicer way. def time_entries(task_id=nil) if task_id.present? - h2 "Registered #{task.billed? ? "billed" : "unbilled"} time" + h2 "Registered #{@task.billed? ? "billed" : "unbilled"} time" else h2 "Timeline" end @@ -1497,7 +1497,7 @@ module StopTime::Views "what you are doing!" end end - form :action => R(*target), :method => :post do + form :action => R(*@target), :method => :post do ol do li do label "Customer", :for => "customer" @@ -1651,7 +1651,7 @@ module StopTime::Views p.warn do em "This task is already billed! Only make changes if you know " + "what you are doing!" - end if task.billed? + end if @task.billed? form :action => R(*@target), :method => :post do ol do li do @@ -1673,7 +1673,7 @@ module StopTime::Views end end end - if task.billed? + if @task.billed? li do label "Billed in invoice" a @task.invoice.number, @@ -1760,7 +1760,7 @@ module StopTime::Views tr do td do a task.comment_or_name, - :href => R(CustomersNTasksN, customer.id, task.id) + :href => R(CustomersNTasksN, task.customer.id, task.id) end if line[1].blank? # FIXME: information of time spent is available in the summary From d4ee3a65843f142dd6edca085a91d2f26bcfefef Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 13:57:51 +0100 Subject: [PATCH 07/40] Port the Markaby method override support to Mab --- stoptime.rb | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 2d17e9c..5a7ddda 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -77,21 +77,24 @@ end # = The Stop… Camping Time! Markaby extensions # FIXME: update for Mab! -module StopTime::Helpers - #SUPPORTED = [:get, :post] +module StopTime::Mab + SUPPORTED = [:get, :post] - # # Adds a method override field in form tags for (usually) unsupported - # # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. - # def tag!(tag, *attrs) - # return super unless tag == :form && block_given? - # attrs = attrs.last.is_a?(Hash) ? attrs.last : {} - # meth = attrs[:method] - # attrs[:method] = 'post' if override = !SUPPORTED.include?(meth) - # super(tag, attrs) do - # input :type => 'hidden', :name => '_method', :value => meth if override - # yield - # end - # end + def mab_done(tag) + return super unless tag.name == :form + + meth = tag.attributes[:method] + tag.attributes[:method] = 'post' if override = !SUPPORTED.include?(meth) + # Inject a hidden input element with the proper method to the tag block + # if the form method is unsupported. + orig_blk = tag.block + tag.block = proc do + input :type => 'hidden', :name => '_method', :value => meth + orig_blk.call + end if override + end + + include Mab::Indentation end From 54da1353e654ca9e981c235156baf97138d9183a Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 13:58:04 +0100 Subject: [PATCH 08/40] Remove the double doctype, fix indentation --- stoptime.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 5a7ddda..4a3ec51 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1343,7 +1343,6 @@ module StopTime::Views # The main layout used by all views. def layout - doctype! html do head do title "Stop… Camping Time!" @@ -1539,7 +1538,7 @@ module StopTime::Views if @customers.empty? p do text! "None found! You can create one " + - "#{a "here", :href => R(CustomersNew)}." + "#{a "here", :href => R(CustomersNew)}." end else table.customers do From e29a95466308010fb6bd08c8c95fa2d21f7dffe8 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 15:02:59 +0100 Subject: [PATCH 09/40] Bumped dependency versions in the README --- README | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README b/README index 98efcfd..72effe8 100644 --- a/README +++ b/README @@ -18,11 +18,11 @@ invoicing. Stop… Camping Time! is a Camping application, so you need: -* Ruby 1.8 (>= 1.8.6) or 1.9 (>= 1.9.1) -* Camping (>= 2.0) with +* Ruby 1.8 (>= 1.8.7) or 1.9 (>= 1.9.3) +* Camping (>= 2.2) with * Active Record (>= 2.3) - * Markaby, and optionally: - * Mongrel (for testing and deployment without Apache/Rackup) + * Markaby (>= 0.1.0) , and optionally: + * Thin or Mongrel (for testing and deployment without Apache/Rackup) The following Ruby libraries are required: From a064cd952c63c1e80a8374c756ce068dbefb160f Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Tue, 31 Jan 2012 22:34:26 +0100 Subject: [PATCH 10/40] Small cleanup for the block override that works with recent Mab --- stoptime.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 4a3ec51..3b63bd9 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -87,8 +87,7 @@ module StopTime::Mab tag.attributes[:method] = 'post' if override = !SUPPORTED.include?(meth) # Inject a hidden input element with the proper method to the tag block # if the form method is unsupported. - orig_blk = tag.block - tag.block = proc do + tag.block do |orig_blk| input :type => 'hidden', :name => '_method', :value => meth orig_blk.call end if override From 3f594d49d078d7dc45a0f67f10b21694262f39c8 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Wed, 25 Jan 2012 15:52:46 +0100 Subject: [PATCH 11/40] Actively load active record --- stoptime.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/stoptime.rb b/stoptime.rb index d90923e..a67f41e 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -12,6 +12,7 @@ require "action_view" require "active_support" require "camping" +require "camping/ar" require "markaby" require "pathname" require "sass/plugin/rack" From 0e2c9ee02e4b40e7d57857adc5429adae0f1f012 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Wed, 25 Jan 2012 15:53:24 +0100 Subject: [PATCH 12/40] Fix up some hacks that generate errors when used with Mab --- stoptime.rb | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index a67f41e..709f870 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -78,20 +78,28 @@ module StopTime end # = The Stop… Camping Time! Markaby extensions -module StopTime::Helpers +module StopTime::Mab SUPPORTED = [:get, :post] - # Adds a method override field in form tags for (usually) unsupported - # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. - def tag!(tag, *attrs) - return super unless tag == :form && block_given? - attrs = attrs.last.is_a?(Hash) ? attrs.last : {} - meth = attrs[:method] - attrs[:method] = 'post' if override = !SUPPORTED.include?(meth) - super(tag, attrs) do - input :type => 'hidden', :name => '_method', :value => meth if override - yield - end + # # Adds a method override field in form tags for (usually) unsupported + # # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. + # def tag!(tag, *attrs) + # return super unless tag == :form && block_given? + # attrs = attrs.last.is_a?(Hash) ? attrs.last : {} + # meth = attrs[:method] + # attrs[:method] = 'post' if override = !SUPPORTED.include?(meth) + # super(tag, attrs) do + # input :type => 'hidden', :name => '_method', :value => meth if override + # yield + # end + # end + + def tag!(name, *args) + Kernel.p [name, args] + content = args.shift unless args.first.is_a?(Hash) + attrs = args.inject { |a,b| a.merge(b) } + Kernel.p [name, content, args] + super(name, content, attrs) end end From 395271f0b1f97f79de1b27489665ac021d3bac77 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Wed, 25 Jan 2012 15:53:43 +0100 Subject: [PATCH 13/40] More Mab compability: different doctype and text escaping --- stoptime.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 709f870..2b9a233 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1352,7 +1352,8 @@ module StopTime::Views # The main layout used by all views. def layout - xhtml_strict do + doctype! + html do head do title "Stop… Camping Time!" # FIXME: improve static serving so that the hack below is not needed. @@ -1386,8 +1387,8 @@ module StopTime::Views h3 { a customer.name, :href => R(CustomersN, customer.id) } if @tasks[customer].empty? p do - text "No projects/tasks found! Create one " + - "#{a "here", :href => R(CustomersNTasksNew, customer.id)}." + text! "No projects/tasks found! Create one " + + "#{a "here", :href => R(CustomersNTasksNew, customer.id)}." end else table.overview do @@ -1546,7 +1547,7 @@ module StopTime::Views h2 "Customers" if @customers.empty? p do - text "None found! You can create one " + + text! "None found! You can create one " + "#{a "here", :href => R(CustomersNew)}." end else @@ -1707,8 +1708,8 @@ module StopTime::Views if @invoices.values.flatten.empty? p do - text "Found none! You can create one by " - "#{a "selecting a customer", :href => R(Customers)}." + text! "Found none! You can create one by " + "#{a "selecting a customer", :href => R(Customers)}." end else @invoices.keys.sort.each do |key| @@ -1996,7 +1997,7 @@ module StopTime::Views # menu item. def _menu_link(label, ctrl) # FIXME: dirty hack? - if self.helpers.class.to_s.match(/^#{ctrl.to_s}/) + if self.class.to_s.match(/^#{ctrl.to_s}/) li.selected { a label, :href => R(ctrl) } else li { a label, :href => R(ctrl) } From 0e810f5b50908fe14a4f602fde414be50748c928 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 12:57:15 +0100 Subject: [PATCH 14/40] Actually load Mab instead of Markaby --- stoptime.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 2b9a233..6543339 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -12,12 +12,10 @@ require "action_view" require "active_support" require "camping" -require "camping/ar" -require "markaby" +require "camping/mab" require "pathname" require "sass/plugin/rack" -Markaby::Builder.set(:indent, 2) Camping.goes :StopTime unless defined? PUBLIC_DIR From 96197af487b20a36d3c3aae049ba4abe944e61bc Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 12:57:37 +0100 Subject: [PATCH 15/40] Leave the form method override stuff for now --- stoptime.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 6543339..21ede29 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -76,8 +76,9 @@ module StopTime end # = The Stop… Camping Time! Markaby extensions -module StopTime::Mab - SUPPORTED = [:get, :post] +# FIXME: update for Mab! +module StopTime::Helpers + #SUPPORTED = [:get, :post] # # Adds a method override field in form tags for (usually) unsupported # # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. @@ -92,14 +93,6 @@ module StopTime::Mab # end # end - def tag!(name, *args) - Kernel.p [name, args] - content = args.shift unless args.first.is_a?(Hash) - attrs = args.inject { |a,b| a.merge(b) } - Kernel.p [name, content, args] - super(name, content, attrs) - end - end # = The Stop… Camping Time! models From e100fec8e3f765b4443cc7db37a1488a5811ea6b Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 12:57:56 +0100 Subject: [PATCH 16/40] Updated views to use the instance vars and no longer rely on Markaby's method_missing --- stoptime.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 21ede29..4eac2b2 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1410,7 +1410,7 @@ module StopTime::Views # FIXME: This should be done in a nicer way. def time_entries(task_id=nil) if task_id.present? - h2 "Registered #{task.billed? ? "billed" : "unbilled"} time" + h2 "Registered #{@task.billed? ? "billed" : "unbilled"} time" else h2 "Timeline" end @@ -1500,7 +1500,7 @@ module StopTime::Views "what you are doing!" end end - form :action => R(*target), :method => :post do + form :action => R(*@target), :method => :post do ol do li do label "Customer", :for => "customer" @@ -1653,7 +1653,7 @@ module StopTime::Views p.warn do em "This task is already billed! Only make changes if you know " + "what you are doing!" - end if task.billed? + end if @task.billed? form :action => R(*@target), :method => :post do ol do li do @@ -1675,7 +1675,7 @@ module StopTime::Views end end end - if task.billed? + if @task.billed? li do label "Billed in invoice" a @task.invoice.number, @@ -1762,7 +1762,7 @@ module StopTime::Views tr do td do a task.comment_or_name, - :href => R(CustomersNTasksN, customer.id, task.id) + :href => R(CustomersNTasksN, task.customer.id, task.id) end if line[1].blank? # FIXME: information of time spent is available in the summary From 474b2a22d93e45c48f0bfbcbb223846fb94a4878 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 13:57:51 +0100 Subject: [PATCH 17/40] Port the Markaby method override support to Mab --- stoptime.rb | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 4eac2b2..e3a0708 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -77,21 +77,24 @@ end # = The Stop… Camping Time! Markaby extensions # FIXME: update for Mab! -module StopTime::Helpers - #SUPPORTED = [:get, :post] +module StopTime::Mab + SUPPORTED = [:get, :post] - # # Adds a method override field in form tags for (usually) unsupported - # # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. - # def tag!(tag, *attrs) - # return super unless tag == :form && block_given? - # attrs = attrs.last.is_a?(Hash) ? attrs.last : {} - # meth = attrs[:method] - # attrs[:method] = 'post' if override = !SUPPORTED.include?(meth) - # super(tag, attrs) do - # input :type => 'hidden', :name => '_method', :value => meth if override - # yield - # end - # end + def mab_done(tag) + return super unless tag.name == :form + + meth = tag.attributes[:method] + tag.attributes[:method] = 'post' if override = !SUPPORTED.include?(meth) + # Inject a hidden input element with the proper method to the tag block + # if the form method is unsupported. + orig_blk = tag.block + tag.block = proc do + input :type => 'hidden', :name => '_method', :value => meth + orig_blk.call + end if override + end + + include Mab::Indentation end From df07a61803dd94933968349b06801232619cb872 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 13:58:04 +0100 Subject: [PATCH 18/40] Remove the double doctype, fix indentation --- stoptime.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index e3a0708..273868f 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1346,7 +1346,6 @@ module StopTime::Views # The main layout used by all views. def layout - doctype! html do head do title "Stop… Camping Time!" @@ -1542,7 +1541,7 @@ module StopTime::Views if @customers.empty? p do text! "None found! You can create one " + - "#{a "here", :href => R(CustomersNew)}." + "#{a "here", :href => R(CustomersNew)}." end else table.customers do From d81480a2d030dae145cbf2d6d747b7ba6179a669 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 15:02:59 +0100 Subject: [PATCH 19/40] Bumped dependency versions in the README --- README | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README b/README index 98efcfd..72effe8 100644 --- a/README +++ b/README @@ -18,11 +18,11 @@ invoicing. Stop… Camping Time! is a Camping application, so you need: -* Ruby 1.8 (>= 1.8.6) or 1.9 (>= 1.9.1) -* Camping (>= 2.0) with +* Ruby 1.8 (>= 1.8.7) or 1.9 (>= 1.9.3) +* Camping (>= 2.2) with * Active Record (>= 2.3) - * Markaby, and optionally: - * Mongrel (for testing and deployment without Apache/Rackup) + * Markaby (>= 0.1.0) , and optionally: + * Thin or Mongrel (for testing and deployment without Apache/Rackup) The following Ruby libraries are required: From 9173b7485090d784c14eec4cb86d46332f1ad124 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Tue, 31 Jan 2012 22:34:26 +0100 Subject: [PATCH 20/40] Small cleanup for the block override that works with recent Mab --- stoptime.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 273868f..991e27f 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -87,8 +87,7 @@ module StopTime::Mab tag.attributes[:method] = 'post' if override = !SUPPORTED.include?(meth) # Inject a hidden input element with the proper method to the tag block # if the form method is unsupported. - orig_blk = tag.block - tag.block = proc do + tag.block do |orig_blk| input :type => 'hidden', :name => '_method', :value => meth orig_blk.call end if override From bc99fdad4d2000726f054e37bb48dbd0fabc5900 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 21 May 2012 17:11:06 +0200 Subject: [PATCH 21/40] Small Mab compatibility fix --- stoptime.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 991e27f..9c4b905 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1563,10 +1563,10 @@ module StopTime::Views td { customer.short_name || "–"} td do if customer.address_street.present? - text customer.address_street + text! customer.address_street br - text customer.address_postal_code + " " + - customer.address_city + text! customer.address_postal_code + " " + + customer.address_city else "–" end From 544036f93a77b13dd92f2de70963ed7ed348c7b6 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 21 May 2012 17:11:29 +0200 Subject: [PATCH 22/40] Replaced the dependency on Markaby by Mab --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 72effe8..f71727a 100644 --- a/README +++ b/README @@ -21,7 +21,7 @@ Stop… Camping Time! is a Camping application, so you need: * Ruby 1.8 (>= 1.8.7) or 1.9 (>= 1.9.3) * Camping (>= 2.2) with * Active Record (>= 2.3) - * Markaby (>= 0.1.0) , and optionally: + * Mab (>= 0.0.1) , and optionally: * Thin or Mongrel (for testing and deployment without Apache/Rackup) The following Ruby libraries are required: From 419d08a6eb6360e2247d5ecd5d208f869b4bfe17 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Wed, 25 Jan 2012 15:52:46 +0100 Subject: [PATCH 23/40] Actively load active record --- stoptime.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/stoptime.rb b/stoptime.rb index d90923e..a67f41e 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -12,6 +12,7 @@ require "action_view" require "active_support" require "camping" +require "camping/ar" require "markaby" require "pathname" require "sass/plugin/rack" From 3a824c2026941a5fafc59eadfe1b718fbea179b9 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Wed, 25 Jan 2012 15:53:24 +0100 Subject: [PATCH 24/40] Fix up some hacks that generate errors when used with Mab --- stoptime.rb | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index a67f41e..709f870 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -78,20 +78,28 @@ module StopTime end # = The Stop… Camping Time! Markaby extensions -module StopTime::Helpers +module StopTime::Mab SUPPORTED = [:get, :post] - # Adds a method override field in form tags for (usually) unsupported - # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. - def tag!(tag, *attrs) - return super unless tag == :form && block_given? - attrs = attrs.last.is_a?(Hash) ? attrs.last : {} - meth = attrs[:method] - attrs[:method] = 'post' if override = !SUPPORTED.include?(meth) - super(tag, attrs) do - input :type => 'hidden', :name => '_method', :value => meth if override - yield - end + # # Adds a method override field in form tags for (usually) unsupported + # # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. + # def tag!(tag, *attrs) + # return super unless tag == :form && block_given? + # attrs = attrs.last.is_a?(Hash) ? attrs.last : {} + # meth = attrs[:method] + # attrs[:method] = 'post' if override = !SUPPORTED.include?(meth) + # super(tag, attrs) do + # input :type => 'hidden', :name => '_method', :value => meth if override + # yield + # end + # end + + def tag!(name, *args) + Kernel.p [name, args] + content = args.shift unless args.first.is_a?(Hash) + attrs = args.inject { |a,b| a.merge(b) } + Kernel.p [name, content, args] + super(name, content, attrs) end end From d3129a11c1dc2b5bce905f92a880c7ebb3b942ba Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Wed, 25 Jan 2012 15:53:43 +0100 Subject: [PATCH 25/40] More Mab compability: different doctype and text escaping --- stoptime.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 709f870..2b9a233 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1352,7 +1352,8 @@ module StopTime::Views # The main layout used by all views. def layout - xhtml_strict do + doctype! + html do head do title "Stop… Camping Time!" # FIXME: improve static serving so that the hack below is not needed. @@ -1386,8 +1387,8 @@ module StopTime::Views h3 { a customer.name, :href => R(CustomersN, customer.id) } if @tasks[customer].empty? p do - text "No projects/tasks found! Create one " + - "#{a "here", :href => R(CustomersNTasksNew, customer.id)}." + text! "No projects/tasks found! Create one " + + "#{a "here", :href => R(CustomersNTasksNew, customer.id)}." end else table.overview do @@ -1546,7 +1547,7 @@ module StopTime::Views h2 "Customers" if @customers.empty? p do - text "None found! You can create one " + + text! "None found! You can create one " + "#{a "here", :href => R(CustomersNew)}." end else @@ -1707,8 +1708,8 @@ module StopTime::Views if @invoices.values.flatten.empty? p do - text "Found none! You can create one by " - "#{a "selecting a customer", :href => R(Customers)}." + text! "Found none! You can create one by " + "#{a "selecting a customer", :href => R(Customers)}." end else @invoices.keys.sort.each do |key| @@ -1996,7 +1997,7 @@ module StopTime::Views # menu item. def _menu_link(label, ctrl) # FIXME: dirty hack? - if self.helpers.class.to_s.match(/^#{ctrl.to_s}/) + if self.class.to_s.match(/^#{ctrl.to_s}/) li.selected { a label, :href => R(ctrl) } else li { a label, :href => R(ctrl) } From d41b70f0d835e8edecf8689419183522cdc39467 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 12:57:15 +0100 Subject: [PATCH 26/40] Actually load Mab instead of Markaby --- stoptime.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 2b9a233..6543339 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -12,12 +12,10 @@ require "action_view" require "active_support" require "camping" -require "camping/ar" -require "markaby" +require "camping/mab" require "pathname" require "sass/plugin/rack" -Markaby::Builder.set(:indent, 2) Camping.goes :StopTime unless defined? PUBLIC_DIR From 51f0bdfa9c4acb1342f1e03f1f5b1cc2369c97f4 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 12:57:37 +0100 Subject: [PATCH 27/40] Leave the form method override stuff for now --- stoptime.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 6543339..21ede29 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -76,8 +76,9 @@ module StopTime end # = The Stop… Camping Time! Markaby extensions -module StopTime::Mab - SUPPORTED = [:get, :post] +# FIXME: update for Mab! +module StopTime::Helpers + #SUPPORTED = [:get, :post] # # Adds a method override field in form tags for (usually) unsupported # # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. @@ -92,14 +93,6 @@ module StopTime::Mab # end # end - def tag!(name, *args) - Kernel.p [name, args] - content = args.shift unless args.first.is_a?(Hash) - attrs = args.inject { |a,b| a.merge(b) } - Kernel.p [name, content, args] - super(name, content, attrs) - end - end # = The Stop… Camping Time! models From 3c620040560ee02708f02b664cd14bf9ad96683b Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 12:57:56 +0100 Subject: [PATCH 28/40] Updated views to use the instance vars and no longer rely on Markaby's method_missing --- stoptime.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 21ede29..4eac2b2 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1410,7 +1410,7 @@ module StopTime::Views # FIXME: This should be done in a nicer way. def time_entries(task_id=nil) if task_id.present? - h2 "Registered #{task.billed? ? "billed" : "unbilled"} time" + h2 "Registered #{@task.billed? ? "billed" : "unbilled"} time" else h2 "Timeline" end @@ -1500,7 +1500,7 @@ module StopTime::Views "what you are doing!" end end - form :action => R(*target), :method => :post do + form :action => R(*@target), :method => :post do ol do li do label "Customer", :for => "customer" @@ -1653,7 +1653,7 @@ module StopTime::Views p.warn do em "This task is already billed! Only make changes if you know " + "what you are doing!" - end if task.billed? + end if @task.billed? form :action => R(*@target), :method => :post do ol do li do @@ -1675,7 +1675,7 @@ module StopTime::Views end end end - if task.billed? + if @task.billed? li do label "Billed in invoice" a @task.invoice.number, @@ -1762,7 +1762,7 @@ module StopTime::Views tr do td do a task.comment_or_name, - :href => R(CustomersNTasksN, customer.id, task.id) + :href => R(CustomersNTasksN, task.customer.id, task.id) end if line[1].blank? # FIXME: information of time spent is available in the summary From f1b5f5168b8a6b5b39752e704c344fd91d86b846 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 13:57:51 +0100 Subject: [PATCH 29/40] Port the Markaby method override support to Mab --- stoptime.rb | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 4eac2b2..e3a0708 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -77,21 +77,24 @@ end # = The Stop… Camping Time! Markaby extensions # FIXME: update for Mab! -module StopTime::Helpers - #SUPPORTED = [:get, :post] +module StopTime::Mab + SUPPORTED = [:get, :post] - # # Adds a method override field in form tags for (usually) unsupported - # # methods by browsers (i.e. PUT and DELETE) by injecting a hidden field. - # def tag!(tag, *attrs) - # return super unless tag == :form && block_given? - # attrs = attrs.last.is_a?(Hash) ? attrs.last : {} - # meth = attrs[:method] - # attrs[:method] = 'post' if override = !SUPPORTED.include?(meth) - # super(tag, attrs) do - # input :type => 'hidden', :name => '_method', :value => meth if override - # yield - # end - # end + def mab_done(tag) + return super unless tag.name == :form + + meth = tag.attributes[:method] + tag.attributes[:method] = 'post' if override = !SUPPORTED.include?(meth) + # Inject a hidden input element with the proper method to the tag block + # if the form method is unsupported. + orig_blk = tag.block + tag.block = proc do + input :type => 'hidden', :name => '_method', :value => meth + orig_blk.call + end if override + end + + include Mab::Indentation end From 29ad270f0fd2564b16bf18179171a6ff5815230c Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 13:58:04 +0100 Subject: [PATCH 30/40] Remove the double doctype, fix indentation --- stoptime.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index e3a0708..273868f 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1346,7 +1346,6 @@ module StopTime::Views # The main layout used by all views. def layout - doctype! html do head do title "Stop… Camping Time!" @@ -1542,7 +1541,7 @@ module StopTime::Views if @customers.empty? p do text! "None found! You can create one " + - "#{a "here", :href => R(CustomersNew)}." + "#{a "here", :href => R(CustomersNew)}." end else table.customers do From 8fd7f45efce768007805e3b9d11d08ca81d21199 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 15:02:59 +0100 Subject: [PATCH 31/40] Bumped dependency versions in the README --- README | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README b/README index 98efcfd..72effe8 100644 --- a/README +++ b/README @@ -18,11 +18,11 @@ invoicing. Stop… Camping Time! is a Camping application, so you need: -* Ruby 1.8 (>= 1.8.6) or 1.9 (>= 1.9.1) -* Camping (>= 2.0) with +* Ruby 1.8 (>= 1.8.7) or 1.9 (>= 1.9.3) +* Camping (>= 2.2) with * Active Record (>= 2.3) - * Markaby, and optionally: - * Mongrel (for testing and deployment without Apache/Rackup) + * Markaby (>= 0.1.0) , and optionally: + * Thin or Mongrel (for testing and deployment without Apache/Rackup) The following Ruby libraries are required: From 5c364e1d10eb2726ffc5aa7038d5d55e7ac102f8 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Tue, 31 Jan 2012 22:34:26 +0100 Subject: [PATCH 32/40] Small cleanup for the block override that works with recent Mab --- stoptime.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 273868f..991e27f 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -87,8 +87,7 @@ module StopTime::Mab tag.attributes[:method] = 'post' if override = !SUPPORTED.include?(meth) # Inject a hidden input element with the proper method to the tag block # if the form method is unsupported. - orig_blk = tag.block - tag.block = proc do + tag.block do |orig_blk| input :type => 'hidden', :name => '_method', :value => meth orig_blk.call end if override From 482e7eabebeaa81e119e5d8f89fcb870ff867aa6 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Wed, 25 Jan 2012 15:52:46 +0100 Subject: [PATCH 33/40] Actively load active record --- stoptime.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/stoptime.rb b/stoptime.rb index 991e27f..e14e4a7 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -13,6 +13,7 @@ require "action_view" require "active_support" require "camping" require "camping/mab" +require "camping/ar" require "pathname" require "sass/plugin/rack" From b47f8376134e2c23b42123e61bf588b5fcb0ac8c Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Wed, 25 Jan 2012 15:53:24 +0100 Subject: [PATCH 34/40] Fix up some hacks that generate errors when used with Mab --- stoptime.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/stoptime.rb b/stoptime.rb index e14e4a7..50837c2 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -77,7 +77,6 @@ module StopTime end # = The Stop… Camping Time! Markaby extensions -# FIXME: update for Mab! module StopTime::Mab SUPPORTED = [:get, :post] From 968ec1ab991ebe041956d7be2e7f48721577ad97 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Wed, 25 Jan 2012 15:53:43 +0100 Subject: [PATCH 35/40] More Mab compability: different doctype and text escaping --- stoptime.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/stoptime.rb b/stoptime.rb index 50837c2..cc31d76 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1345,6 +1345,7 @@ module StopTime::Views # The main layout used by all views. def layout + doctype! html do head do title "Stop… Camping Time!" From aa9f0e9dc0c6fe81a825596eda13252034b40713 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 12:57:37 +0100 Subject: [PATCH 36/40] Leave the form method override stuff for now --- stoptime.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index cc31d76..7a0892b 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -77,8 +77,9 @@ module StopTime end # = The Stop… Camping Time! Markaby extensions -module StopTime::Mab - SUPPORTED = [:get, :post] +# FIXME: update for Mab! +module StopTime::Helpers + #SUPPORTED = [:get, :post] def mab_done(tag) return super unless tag.name == :form From b25226ac7e5eee88bae1ad11328523c1315157b1 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 13:57:51 +0100 Subject: [PATCH 37/40] Port the Markaby method override support to Mab --- stoptime.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 7a0892b..cc31d76 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -77,9 +77,8 @@ module StopTime end # = The Stop… Camping Time! Markaby extensions -# FIXME: update for Mab! -module StopTime::Helpers - #SUPPORTED = [:get, :post] +module StopTime::Mab + SUPPORTED = [:get, :post] def mab_done(tag) return super unless tag.name == :form From 8ce00648f3e5dc830e1367ff9f0ce3d0a8ab730f Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 30 Jan 2012 13:58:04 +0100 Subject: [PATCH 38/40] Remove the double doctype, fix indentation --- stoptime.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/stoptime.rb b/stoptime.rb index cc31d76..50837c2 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1345,7 +1345,6 @@ module StopTime::Views # The main layout used by all views. def layout - doctype! html do head do title "Stop… Camping Time!" From 9df0a55e4bfc776ce41a357ec8090b1e804d242c Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 21 May 2012 17:11:06 +0200 Subject: [PATCH 39/40] Small Mab compatibility fix --- stoptime.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stoptime.rb b/stoptime.rb index 50837c2..b9ff21d 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1563,10 +1563,10 @@ module StopTime::Views td { customer.short_name || "–"} td do if customer.address_street.present? - text customer.address_street + text! customer.address_street br - text customer.address_postal_code + " " + - customer.address_city + text! customer.address_postal_code + " " + + customer.address_city else "–" end From 1a72b797c132074f7a27ee7a215223ae3a8df79d Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Mon, 21 May 2012 17:11:29 +0200 Subject: [PATCH 40/40] Replaced the dependency on Markaby by Mab --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 72effe8..f71727a 100644 --- a/README +++ b/README @@ -21,7 +21,7 @@ Stop… Camping Time! is a Camping application, so you need: * Ruby 1.8 (>= 1.8.7) or 1.9 (>= 1.9.3) * Camping (>= 2.2) with * Active Record (>= 2.3) - * Markaby (>= 0.1.0) , and optionally: + * Mab (>= 0.0.1) , and optionally: * Thin or Mongrel (for testing and deployment without Apache/Rackup) The following Ruby libraries are required: