diff --git a/Gemfile b/Gemfile index 62b93e9..bf1fbb0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,14 @@ source 'https://rubygems.org' -gem 'rails', '~> 3.0.20' +gem 'rails', '~> 3.2.22.5' gem 'rake', '10.1.0' +gem 'dynamic_form' gem 'prawn', '~> 0.8.4' gem 'prawn-layout', '0.8.4' +gem 'prawnto' gem 'will_paginate', '~> 3.1.0' gem 'mysql2', '~> 0.3.16' -gem 'activerecord-mysql2-adapter', '0.0.3' #group :production do # gem 'fcgi' diff --git a/Gemfile.lock b/Gemfile.lock index 5044a73..5e3f369 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,49 +1,48 @@ GEM remote: https://rubygems.org/ specs: - abstract (1.0.0) - actionmailer (3.0.20) - actionpack (= 3.0.20) - mail (~> 2.2.19) - actionpack (3.0.20) - activemodel (= 3.0.20) - activesupport (= 3.0.20) - builder (~> 2.1.2) - erubis (~> 2.6.6) - i18n (~> 0.5.0) - rack (~> 1.2.5) - rack-mount (~> 0.6.14) - rack-test (~> 0.5.7) - tzinfo (~> 0.3.23) - activemodel (3.0.20) - activesupport (= 3.0.20) - builder (~> 2.1.2) - i18n (~> 0.5.0) - activerecord (3.0.20) - activemodel (= 3.0.20) - activesupport (= 3.0.20) - arel (~> 2.0.10) - tzinfo (~> 0.3.23) - activerecord-mysql2-adapter (0.0.3) - mysql2 - activeresource (3.0.20) - activemodel (= 3.0.20) - activesupport (= 3.0.20) - activesupport (3.0.20) - arel (2.0.10) - builder (2.1.2) - erubis (2.6.6) - abstract (>= 1.0.0) - i18n (0.5.4) - json (1.8.1) - mail (2.2.20) - activesupport (>= 2.3.6) - i18n (>= 0.4.0) + actionmailer (3.2.22.5) + actionpack (= 3.2.22.5) + mail (~> 2.5.4) + actionpack (3.2.22.5) + activemodel (= 3.2.22.5) + activesupport (= 3.2.22.5) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.4) + rack (~> 1.4.5) + rack-cache (~> 1.2) + rack-test (~> 0.6.1) + sprockets (~> 2.2.1) + activemodel (3.2.22.5) + activesupport (= 3.2.22.5) + builder (~> 3.0.0) + activerecord (3.2.22.5) + activemodel (= 3.2.22.5) + activesupport (= 3.2.22.5) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activeresource (3.2.22.5) + activemodel (= 3.2.22.5) + activesupport (= 3.2.22.5) + activesupport (3.2.22.5) + i18n (~> 0.6, >= 0.6.4) + multi_json (~> 1.0) + arel (3.0.3) + builder (3.0.4) + dynamic_form (1.1.4) + erubis (2.7.0) + hike (1.2.3) + i18n (0.7.0) + journey (1.0.4) + json (1.8.6) + mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.25.1) + multi_json (1.12.1) mysql2 (0.3.16) - polyglot (0.3.4) + polyglot (0.3.5) prawn (0.8.4) prawn-core (>= 0.8.4, < 0.9) prawn-layout (>= 0.8.4, < 0.9) @@ -51,43 +50,59 @@ GEM prawn-core (0.8.4) prawn-layout (0.8.4) prawn-security (0.8.4) - rack (1.2.8) - rack-mount (0.6.14) - rack (>= 1.0.0) - rack-test (0.5.7) + prawnto (0.1.1) + prawn + rails (>= 2.1) + rack (1.4.7) + rack-cache (1.7.0) + rack (>= 0.4) + rack-ssl (1.3.4) + rack + rack-test (0.6.3) rack (>= 1.0) - rails (3.0.20) - actionmailer (= 3.0.20) - actionpack (= 3.0.20) - activerecord (= 3.0.20) - activeresource (= 3.0.20) - activesupport (= 3.0.20) + rails (3.2.22.5) + actionmailer (= 3.2.22.5) + actionpack (= 3.2.22.5) + activerecord (= 3.2.22.5) + activeresource (= 3.2.22.5) + activesupport (= 3.2.22.5) bundler (~> 1.0) - railties (= 3.0.20) - railties (3.0.20) - actionpack (= 3.0.20) - activesupport (= 3.0.20) + railties (= 3.2.22.5) + railties (3.2.22.5) + actionpack (= 3.2.22.5) + activesupport (= 3.2.22.5) + rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) - thor (~> 0.14.4) + thor (>= 0.14.6, < 2.0) rake (10.1.0) rdoc (3.12.2) json (~> 1.4) - thor (0.14.6) + sprockets (2.2.3) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + thor (0.19.4) + tilt (1.4.1) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.39) + tzinfo (0.3.52) will_paginate (3.1.0) PLATFORMS ruby DEPENDENCIES - activerecord-mysql2-adapter (= 0.0.3) + dynamic_form mysql2 (~> 0.3.16) prawn (~> 0.8.4) prawn-layout (= 0.8.4) - rails (~> 3.0.20) + prawnto + rails (~> 3.2.22.5) rake (= 10.1.0) will_paginate (~> 3.1.0) + +BUNDLED WITH + 1.14.3 diff --git a/app/models/person.rb b/app/models/person.rb index 581257f..f8ad470 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -21,16 +21,16 @@ def medical_validity_valid_or_blank # Human names for attributes # .label of form_helper does not use this, but error_messages does - attr_human_name 'last_name' => 'Nachname' - attr_human_name :first_name => 'Vorname' - attr_human_name :club => 'Verein' - attr_human_name :medical_validity => 'Medical gültig bis' - attr_human_name :medical_validity_text => 'Medical gültig bis' - attr_human_name :check_medical_validity => 'Medical prüfen' - attr_human_name :check_medical_validity_text => 'Medical prüfen' - attr_human_name :club_id => 'Vereins-ID' - attr_human_name :nickname => 'Verein' - attr_human_name 'comments' => 'Bemerkungen' + human_attribute_name 'last_name' => 'Nachname' + human_attribute_name :first_name => 'Vorname' + human_attribute_name :club => 'Verein' + human_attribute_name :medical_validity => 'Medical gültig bis' + human_attribute_name :medical_validity_text => 'Medical gültig bis' + human_attribute_name :check_medical_validity => 'Medical prüfen' + human_attribute_name :check_medical_validity_text => 'Medical prüfen' + human_attribute_name :club_id => 'Vereins-ID' + human_attribute_name :nickname => 'Verein' + human_attribute_name 'comments' => 'Bemerkungen' # Callbacks # Prevent destruction of people that are in use. diff --git a/app/models/user.rb b/app/models/user.rb index 4070485..99ab8a2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,7 @@ # encoding: utf-8 class User < ActiveRecord::Base - set_primary_key "username" + self.primary_key = "username" # Associations belongs_to :person @@ -28,9 +28,9 @@ class User < ActiveRecord::Base validates_confirmation_of :password, :message => "stimmt nicht mit Bestätigung überein" # Human names for attributes - attr_human_name :username => 'Benutzername' - attr_human_name :current_password => 'Altes Passwort' - attr_human_name :password => 'Passwort' + human_attribute_name :username => 'Benutzername' + human_attribute_name :current_password => 'Altes Passwort' + human_attribute_name :password => 'Passwort' # Callbacks # If a password confirmation is given, a password is also given and must be diff --git a/app/views/debug/dump_environment.html.erb b/app/views/debug/dump_environment.html.erb index f30fdd3..c873bac 100644 --- a/app/views/debug/dump_environment.html.erb +++ b/app/views/debug/dump_environment.html.erb @@ -7,7 +7,7 @@ <% end %> -<% page_title "Environment dumper" do %> +<%= page_title "Environment dumper" do %> <% heading "Location" do %>

<%= h s.username||"?" %>@<%= h s.hostname||"?" %>:<%= h Dir.pwd %>

<% end %> diff --git a/app/views/debug/redirect.html.erb b/app/views/debug/redirect.html.erb index fb477d5..17cf970 100644 --- a/app/views/debug/redirect.html.erb +++ b/app/views/debug/redirect.html.erb @@ -1,4 +1,4 @@ -<% page_title "Weiterleitung" do %> +<%= page_title "Weiterleitung" do %>

Weiterleitung zu <%= link_to @target_url, @target_url %> mit Status <%= @status.inspect %> diff --git a/app/views/people/edit.html.erb b/app/views/people/edit.html.erb index be7d33b..40d789b 100644 --- a/app/views/people/edit.html.erb +++ b/app/views/people/edit.html.erb @@ -1,4 +1,4 @@ -<% page_title "Person #{h @person.full_name} editieren" do %> +<%= page_title "Person #{h @person.full_name} editieren" do %> <%= form_for(@person) do |f| %> <%# TODO code duplication %> diff --git a/app/views/people/export_select.html.erb b/app/views/people/export_select.html.erb index 4637a8d..d6cf625 100644 --- a/app/views/people/export_select.html.erb +++ b/app/views/people/export_select.html.erb @@ -1,4 +1,4 @@ -<% page_title "Personen exportieren" do %> +<%= page_title "Personen exportieren" do %> <%= form_tag 'export' do %> diff --git a/app/views/people/import_errors.html.erb b/app/views/people/import_errors.html.erb index c30a428..8536599 100644 --- a/app/views/people/import_errors.html.erb +++ b/app/views/people/import_errors.html.erb @@ -1,4 +1,4 @@ -<% page_title "Personen importieren - Fehler" do %> +<%= page_title "Personen importieren - Fehler" do %> <% single_person_errors=@errors.select { |error| error[:entries].size==1 } diff --git a/app/views/people/import_review.html.erb b/app/views/people/import_review.html.erb index 11531a6..52e3b6d 100644 --- a/app/views/people/import_review.html.erb +++ b/app/views/people/import_review.html.erb @@ -1,4 +1,4 @@ -<% page_title "Personen importieren" do %> +<%= page_title "Personen importieren" do %> <% new_people_entries =@import_data.entries.select { |entry| entry.new? } diff --git a/app/views/people/import_select.html.erb b/app/views/people/import_select.html.erb index ed91051..2289c04 100644 --- a/app/views/people/import_select.html.erb +++ b/app/views/people/import_select.html.erb @@ -1,4 +1,4 @@ -<% page_title "Personen importieren" do %> +<%= page_title "Personen importieren" do %> <%= form_tag 'import', :multipart => true do %>
diff --git a/app/views/people/new.html.erb b/app/views/people/new.html.erb index 6858d17..2090d8d 100644 --- a/app/views/people/new.html.erb +++ b/app/views/people/new.html.erb @@ -1,4 +1,4 @@ -<% page_title "Person anlegen" do %> +<%= page_title "Person anlegen" do %> <%= form_for(@person) do |f| %> <%= f.error_messages \ diff --git a/app/views/people/overwrite_confirm.html.erb b/app/views/people/overwrite_confirm.html.erb index e272eda..1986de8 100644 --- a/app/views/people/overwrite_confirm.html.erb +++ b/app/views/people/overwrite_confirm.html.erb @@ -1,4 +1,4 @@ -<% page_title "Person #{h @wrong_person.full_name} überschreiben" do %> +<%= page_title "Person #{h @wrong_person.full_name} überschreiben" do %> <% heading h "Falsche Person" do %> diff --git a/app/views/people/show.html.erb b/app/views/people/show.html.erb index 671836d..a4c2302 100644 --- a/app/views/people/show.html.erb +++ b/app/views/people/show.html.erb @@ -1,4 +1,4 @@ -<% page_title "Person: #{h @person.full_name}" do %> +<%= page_title "Person: #{h @person.full_name}" do %> <% user=@person.user %> diff --git a/app/views/pilot_log/index.html.erb b/app/views/pilot_log/index.html.erb index e48afe9..8027d53 100644 --- a/app/views/pilot_log/index.html.erb +++ b/app/views/pilot_log/index.html.erb @@ -1,4 +1,4 @@ -<% page_title "Flugbuch für #{h @person.full_name}" do %> +<%= page_title "Flugbuch für #{h @person.full_name}" do %> <%= form_tag do %>
diff --git a/app/views/users/change_password.html.erb b/app/views/users/change_password.html.erb index 5261a8c..6938b07 100644 --- a/app/views/users/change_password.html.erb +++ b/app/views/users/change_password.html.erb @@ -1,4 +1,4 @@ -<% page_title "Passwort für Benutzer #{h @user.username} ändern" do %> +<%= page_title "Passwort für Benutzer #{h @user.username} ändern" do %> <% @user.clear_passwords %> <%= form_for(@user, :url => { :action => params[:action] }, :html=>{:method=>:post}) do |f| %> diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 5eee496..79a8e13 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -1,4 +1,4 @@ -<% page_title "Benutzer anlegen" do %> +<%= page_title "Benutzer anlegen" do %> <% @user.clear_passwords %> <%= form_for(@user) do |f| %> diff --git a/config/environments/development.rb b/config/environments/development.rb index 2ac6858..90583cb 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -11,7 +11,7 @@ # Show full error reports and disable caching config.consider_all_requests_local = true - config.action_view.debug_rjs = true + #config.action_view.debug_rjs = true config.action_controller.perform_caching = false # Don't care if the mailer can't send @@ -22,5 +22,12 @@ # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin + + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + config.active_record.auto_explain_threshold_in_seconds = 0.5 end diff --git a/config/environments/test.rb b/config/environments/test.rb index ce35521..3b8e309 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -32,4 +32,7 @@ # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict end diff --git a/config/initializers/fix_relative_url_root.rb b/config/initializers/fix_relative_url_root.rb.bak similarity index 100% rename from config/initializers/fix_relative_url_root.rb rename to config/initializers/fix_relative_url_root.rb.bak diff --git a/vendor/plugins/human_attribute_override/README b/vendor/plugins/human_attribute_override/README deleted file mode 100644 index a4c6da9..0000000 --- a/vendor/plugins/human_attribute_override/README +++ /dev/null @@ -1,53 +0,0 @@ -HumanAttributeOverride -====================== - -Read a tutorial for this plugin at http://weblog.redlinesoftware.com/2008/1/2/human-attribute-override-plugin-tutorial - -------- -Updates - -Nov. 14, 2007 - -Fixed a bug where column.human_name didn't use the new attribute name. - -This should now produce the correct results: - -<% for column in Company.content_columns %> - <%= column.human_name %> -<% end %> - - -Aug. 18, 2007 - -Attributes can now be specified with symbols or strings (only strings were accepted before) -ex. attr_human_name :num_employees => 'Number of employees', 'unit_num' => 'Unit#' - -Attributes can also be accessed with symbols or strings -ex. -Company.human_attribute_name('num_employees') == 'Number of employees' -Company.human_attribute_name(:num_employees) == 'Number of employees' -------- - -After Rails 1.2, the method human_attribute_name will be removed, so this must be implemented as a plugin to keep the method and it's existing uses of the method intact, while adding additional functionality described below. - - -This plugin allows humanized versions of attributes to be overridden with custom strings to provide a better conversion than humanize may provide. - -This is useful in error reporting and possibly legacy databases where more "cryptic" field names may be used in database tables and a humanized version is not very human. - -Rails uses these humanized conversions in error reporting with the error_messages_for method and in schema definitions for column names with the human_name method. - -For example, a table (Company) has a field called num_employees which when humanized becomes 'Num employees' using the human_attribute_name method (which currently equates to a humanize method call). Ex. - -Company.human_attribute_name('num_employees') == 'Num employees' - -With this patch you can override this conversion... - -class Company - attr_human_name 'num_employees' => 'Number of employees' - ... -end - -Now the following is true... - -Company.human_attribute_name('num_employees') == 'Number of employees' diff --git a/vendor/plugins/human_attribute_override/Rakefile b/vendor/plugins/human_attribute_override/Rakefile deleted file mode 100644 index 0db7eb8..0000000 --- a/vendor/plugins/human_attribute_override/Rakefile +++ /dev/null @@ -1,22 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the human_attribute_override plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the human_attribute_override plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'HumanAttributeOverride' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end diff --git a/vendor/plugins/human_attribute_override/init.rb b/vendor/plugins/human_attribute_override/init.rb deleted file mode 100644 index 8afbc21..0000000 --- a/vendor/plugins/human_attribute_override/init.rb +++ /dev/null @@ -1 +0,0 @@ -require 'human_attribute_override' diff --git a/vendor/plugins/human_attribute_override/install.rb b/vendor/plugins/human_attribute_override/install.rb deleted file mode 100644 index f7732d3..0000000 --- a/vendor/plugins/human_attribute_override/install.rb +++ /dev/null @@ -1 +0,0 @@ -# Install hook code here diff --git a/vendor/plugins/human_attribute_override/lib/human_attribute_override.rb b/vendor/plugins/human_attribute_override/lib/human_attribute_override.rb deleted file mode 100644 index e022e75..0000000 --- a/vendor/plugins/human_attribute_override/lib/human_attribute_override.rb +++ /dev/null @@ -1,43 +0,0 @@ -# HumanAttributeOverride - -module ActiveRecord - class Base - class <human_attribute_name. More descriptive text can be set. Example: - # attr_human_name 'num_employees' => 'Number of employees' - def attr_human_name(attributes) # :nodoc: - return unless table_exists? - - attributes.stringify_keys! - write_inheritable_hash("attr_human_name", attributes || {}) - - # assign the current class to each column that is being assigned a new human attribute name - self.columns.reject{|c| !attributes.has_key?(c.name)}.each{|c| c.parent_record_class = self} - end - - # Returns a hash of alternate human name conversions set with attr_human_name. - def human_name_attributes # :nodoc: - read_inheritable_attribute("attr_human_name") - end - - # Transforms attribute key names into a more humane format, such as "First name" instead of "first_name". Example: - # Person.human_attribute_name("first_name") # => "First name" - def human_attribute_name(attribute_key_name) #:nodoc: - (read_inheritable_attribute("attr_human_name") || {})[attribute_key_name.to_s] || attribute_key_name.to_s.humanize - end - end - end - - module ConnectionAdapters #:nodoc: - # An abstract definition of a column in a table. - class Column - # the active record class that this column is associated with - attr_accessor :parent_record_class - - def human_name - (@parent_record_class || Base).human_attribute_name(@name) - end - end - end -end diff --git a/vendor/plugins/human_attribute_override/test/human_attribute_override_test.rb b/vendor/plugins/human_attribute_override/test/human_attribute_override_test.rb deleted file mode 100644 index 5e1b438..0000000 --- a/vendor/plugins/human_attribute_override/test/human_attribute_override_test.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'test/unit' - -class Customer < ActiveRecord::Base; end - -class HumanAttributeOverrideTest < Test::Unit::TestCase - def teardown - Customer.write_inheritable_attribute "attr_human_name", nil - end - - def test_human_name_override - # no human name overrides defined - assert_nil Customer.human_name_attributes - - # test normal value of human attribute names - assert_equal 'Address street', Customer.human_attribute_name('address_street') - assert_equal 'Address city', Customer.human_attribute_name('address_city') - - # override the humanized version - Customer.attr_human_name 'address_street' => 'Street Address' - - # test that we now have the new version of the humanized attribute - assert_equal 'Street Address', Customer.human_attribute_name('address_street') - # test the unchanged attribute still converts normally - assert_equal 'Address city', Customer.human_attribute_name('address_city') - - # check the attributes that we've overridden exist - assert_equal({'address_street' => 'Street Address'}, Customer.human_name_attributes) - end -end diff --git a/vendor/plugins/prawnto/MIT-LICENSE b/vendor/plugins/prawnto/MIT-LICENSE deleted file mode 100644 index 497d7c5..0000000 --- a/vendor/plugins/prawnto/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2008 cracklabs.com - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/prawnto/README b/vendor/plugins/prawnto/README deleted file mode 100644 index c9b2544..0000000 --- a/vendor/plugins/prawnto/README +++ /dev/null @@ -1,12 +0,0 @@ -Prawnto -======= - -a rails plugin providing templating abilities -for generating pdf files leveraging the new kick-ass prawn library - -full documentation/demos at: http://cracklabs.com/prawnto - - - - -Copyright (c) 2008 cracklabs.com, released under the MIT license diff --git a/vendor/plugins/prawnto/Rakefile b/vendor/plugins/prawnto/Rakefile deleted file mode 100644 index 9d998d1..0000000 --- a/vendor/plugins/prawnto/Rakefile +++ /dev/null @@ -1,22 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the prawnto plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the prawnto plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'Prawnto' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end diff --git a/vendor/plugins/prawnto/init.rb b/vendor/plugins/prawnto/init.rb deleted file mode 100644 index c8cf1dd..0000000 --- a/vendor/plugins/prawnto/init.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'prawnto' - -Mime::Type.register "application/pdf", :pdf -ActionView::Template.register_template_handler 'prawn', Prawnto::TemplateHandlers::Base -ActionView::Template.register_template_handler 'prawn_dsl', Prawnto::TemplateHandlers::Dsl -ActionView::Template.register_template_handler 'prawn_xxx', Prawnto::TemplateHandlers::Raw - diff --git a/vendor/plugins/prawnto/lib/prawnto.rb b/vendor/plugins/prawnto/lib/prawnto.rb deleted file mode 100644 index 1f673c1..0000000 --- a/vendor/plugins/prawnto/lib/prawnto.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'action_controller' -require 'action_view' - -begin - require 'prawn' - require "prawn/layout" # give people what they probably want -rescue LoadError -end - -require 'prawnto/action_controller' -require 'prawnto/action_view' - -require 'prawnto/template_handler/compile_support' - -require 'prawnto/template_handlers/base' -#require 'prawnto/template_handlers/raw' - -# for now applying to all Controllers -# however, could reduce footprint by letting user mixin (i.e. include) only into controllers that need it -# but does it really matter performance wise to include in a controller that doesn't need it? doubtful-- depends how much of a hit the before_filter is i guess.. -# - -class ActionController::Base - include Prawnto::ActionController -end - -class ActionView::Base - include Prawnto::ActionView -end - - - diff --git a/vendor/plugins/prawnto/lib/prawnto/action_controller.rb b/vendor/plugins/prawnto/lib/prawnto/action_controller.rb deleted file mode 100644 index ed33d14..0000000 --- a/vendor/plugins/prawnto/lib/prawnto/action_controller.rb +++ /dev/null @@ -1,45 +0,0 @@ -module Prawnto - module ActionController - - DEFAULT_PRAWNTO_OPTIONS = {:inline=>true} - - def self.included(base) - base.extend ClassMethods - end - - module ClassMethods - def prawnto(options) - prawn_options, prawnto_options = breakdown_prawnto_options options - write_inheritable_hash(:prawn, prawn_options) - write_inheritable_hash(:prawnto, prawnto_options) - end - - private - - def breakdown_prawnto_options(options) - prawnto_options = options.dup - prawn_options = (prawnto_options.delete(:prawn) || {}).dup - [prawn_options, prawnto_options] - end - end - - def prawnto(options) - @prawnto_options ||= DEFAULT_PRAWNTO_OPTIONS.dup - @prawnto_options.merge! options - end - - - private - - def compute_prawnto_options - @prawnto_options ||= DEFAULT_PRAWNTO_OPTIONS.dup - @prawnto_options[:prawn] ||= {} - @prawnto_options[:prawn].merge!(self.class.read_inheritable_attribute(:prawn) || {}) {|k,o,n| o} - @prawnto_options.merge!(self.class.read_inheritable_attribute(:prawnto) || {}) {|k,o,n| o} - @prawnto_options - end - - end -end - - diff --git a/vendor/plugins/prawnto/lib/prawnto/action_view.rb b/vendor/plugins/prawnto/lib/prawnto/action_view.rb deleted file mode 100644 index a3a77f3..0000000 --- a/vendor/plugins/prawnto/lib/prawnto/action_view.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Prawnto - module ActionView - - private - def _prawnto_compile_setup(dsl_setup = false) - compile_support = Prawnto::TemplateHandler::CompileSupport.new(controller) - @prawnto_options = compile_support.options - end - - end -end - diff --git a/vendor/plugins/prawnto/lib/prawnto/template_handler/compile_support.rb b/vendor/plugins/prawnto/lib/prawnto/template_handler/compile_support.rb deleted file mode 100644 index 3a45b8b..0000000 --- a/vendor/plugins/prawnto/lib/prawnto/template_handler/compile_support.rb +++ /dev/null @@ -1,72 +0,0 @@ -module Prawnto - module TemplateHandler - - class CompileSupport - extend ActiveSupport::Memoizable - - attr_reader :options - - def initialize(controller) - @controller = controller - @options = pull_options - set_headers - end - - def pull_options - @controller.send :compute_prawnto_options || {} - end - - def set_headers - set_pragma - set_cache_control - set_content_type - set_disposition - end - - # TODO: kept around from railspdf-- maybe not needed anymore? should check. - def ie_request? - @controller.request.env['HTTP_USER_AGENT'] =~ /msie/i - end - memoize :ie_request? - - # added to make ie happy with ssl pdf's (per naisayer) - def ssl_request? - @controller.request.env['SERVER_PROTOCOL'].downcase == "https" - end - memoize :ssl_request? - - # TODO: kept around from railspdf-- maybe not needed anymore? should check. - def set_pragma - if ssl_request? && ie_request? - @controller.headers['Pragma'] = 'public' # added to make ie ssl pdfs work (per naisayer) - else - @controller.headers['Pragma'] ||= ie_request? ? 'no-cache' : '' - end - end - - # TODO: kept around from railspdf-- maybe not needed anymore? should check. - def set_cache_control - if ssl_request? && ie_request? - @controller.headers['Cache-Control'] = 'maxage=1' # added to make ie ssl pdfs work (per naisayer) - else - @controller.headers['Cache-Control'] ||= ie_request? ? 'no-cache, must-revalidate' : '' - end - end - - def set_content_type - @controller.response.content_type ||= Mime::PDF - end - - def set_disposition - inline = options[:inline] ? 'inline' : 'attachment' - filename = options[:filename] ? "filename=#{options[:filename]}" : nil - @controller.headers["Content-Disposition"] = [inline,filename].compact.join(';') - end - - end - - end -end - - - diff --git a/vendor/plugins/prawnto/lib/prawnto/template_handlers/base.rb b/vendor/plugins/prawnto/lib/prawnto/template_handlers/base.rb deleted file mode 100644 index 0f148af..0000000 --- a/vendor/plugins/prawnto/lib/prawnto/template_handlers/base.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Prawnto - module TemplateHandlers - class Base < ::ActionView::TemplateHandler - include ::ActionView::TemplateHandlers::Compilable - - def compile(template) - "_prawnto_compile_setup;" + - "pdf = Prawn::Document.new(@prawnto_options[:prawn]);" + - "#{template.source}\n" + - "pdf.render;" - end - end - end -end - - diff --git a/vendor/plugins/prawnto/lib/prawnto/template_handlers/dsl.rb b/vendor/plugins/prawnto/lib/prawnto/template_handlers/dsl.rb deleted file mode 100644 index f8458f3..0000000 --- a/vendor/plugins/prawnto/lib/prawnto/template_handlers/dsl.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Prawnto - module TemplateHandlers - class Dsl < Base - - def compile(template) - "_prawnto_compile_setup(true);" + - "pdf = Prawn::Document.new(@prawnto_options[:prawn]);" + - "pdf.instance_eval do; #{template.source}\nend;" + - "pdf.render;" - end - - end - end -end - - diff --git a/vendor/plugins/prawnto/lib/prawnto/template_handlers/raw.rb b/vendor/plugins/prawnto/lib/prawnto/template_handlers/raw.rb deleted file mode 100644 index ef2f7e0..0000000 --- a/vendor/plugins/prawnto/lib/prawnto/template_handlers/raw.rb +++ /dev/null @@ -1,64 +0,0 @@ -module Prawnto - module TemplateHandlers - class Raw < Base - - def compile(template) - #TODO: what's up with filename here? not used is it? - source,filename = massage_template_source(template) - "_prawnto_compile_setup;" + -# (filename ? "@prawnto_options[:filename] = filename" : "") + - source - end - -# attr_reader :run_environment - - GENERATE_REGULAR_EXPRESSION = /^\s*Prawn\:\:Document\.generate(\(?)(.*?)(\,(.*))?(\s*\)?\s+do(.*?))$/m - RENDER_FILE_REGULAR_EXPRESSION = /(\w+)\.render_file\(?(.*?)\)?\s*$/ - -=begin - def render(template) - setup_run_environment - pull_prawnto_options - source,filename = massage_template_source(template) - @prawnto_options[:filename] = filename if filename - build_headers - @run_environment.instance_eval(source, template.filename, 0) #run in anonymous class - end - - - protected - - def setup_run_environment - @run_environment = Object.new - end - -=end - protected - def massage_template_source(template) - source = template.source.dup - variable_name = '_pdf' - filename = nil - - source.gsub! /^(\s*?)(\$LOAD_PATH)/, '\1#\2' - source.gsub! /^(\s*?)(require\(?\s*['"]rubygems['"]\s*\)?\s*)$/, '\1#\2' - source.gsub! /^(\s*?)(require\(?\s*['"]prawn['"]\s*\)?\s*)$/, '\1#\2' - - if (source =~ GENERATE_REGULAR_EXPRESSION) - filename = $2 - source.sub! GENERATE_REGULAR_EXPRESSION, "#{variable_name} = Prawn::Document.new\\1\\4\\5" - elsif (source =~ RENDER_FILE_REGULAR_EXPRESSION) - variable_name = $1 - filename = $2 - source.sub! RENDER_FILE_REGULAR_EXPRESSION, '#\0' - end - source.gsub! /^(\s*)(class\s|def\s).*?\n\1end/m do |match| - eval "class <<@run_environment; #{match}; end;" - "\n" * match.count("\n") - end - source += "\n[#{variable_name}.render,#{filename}]\n" - source - end - - end - end -end diff --git a/vendor/plugins/prawnto/test/action_controller_test.rb b/vendor/plugins/prawnto/test/action_controller_test.rb deleted file mode 100644 index 29718cf..0000000 --- a/vendor/plugins/prawnto/test/action_controller_test.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'rubygems' -require 'action_controller' -require 'action_controller/test_process' -require 'action_view' - -require 'test/unit' -require File.dirname(__FILE__) + '/../lib/prawnto' - - -class ActionControllerTest < Test::Unit::TestCase - class PrawntoController < ActionController::Base - prawnto :inline=>true, :prawn=>{:page_orientation=>:landscape} - - def test - prawnto :inline=>false, :prawn=>{:page_size=>'A4'} - end - end - - def test_inheritable_options - assert_equal({:page_orientation=>:landscape}, PrawntoController.read_inheritable_attribute(:prawn)) - assert_equal({:inline=>true}, PrawntoController.read_inheritable_attribute(:prawnto)) - end - - def test_computed_options - controller = PrawntoController.new - test_process(controller) - assert_equal({:inline=>false, :prawn=>{:page_orientation=>:landscape, :page_size=>'A4'}}, controller.send(:compute_prawnto_options)) - end - -protected - def test_process(controller, action = "test") - request = ActionController::TestRequest.new - request.action = action - controller.process(request, ActionController::TestResponse.new) - end - -end - diff --git a/vendor/plugins/prawnto/test/base_template_handler_test.rb b/vendor/plugins/prawnto/test/base_template_handler_test.rb deleted file mode 100644 index 9b30f52..0000000 --- a/vendor/plugins/prawnto/test/base_template_handler_test.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'rubygems' -require 'test/unit' -require File.dirname(__FILE__) + '/template_handler_test_mocks' -require File.dirname(__FILE__) + '/../lib/prawnto' -#require File.dirname(__FILE__) + '/../init' - - -#TODO: ruby1.9: pull same testing scheme from Raw once we're on 1.9 -class BaseTemplateHandlerTest < Test::Unit::TestCase - include TemplateHandlerTestMocks - - def setup - @view = ActionView.new - @handler = Prawnto::TemplateHandlers::Base.new(@view) - @controller = @view.controller - end - - def test_headers_disposition_inline_and_filename - @controller.prawnto :filename=>'xxx.pdf', :inline=>true - @handler.pull_prawnto_options - @handler.set_disposition - assert_equal 'inline;filename=xxx.pdf', @view.headers['Content-Disposition'] - end - - def test_headers_disposition_attachment_and_filename - @controller.prawnto :filename=>'xxx.pdf', :inline=>false - @handler.pull_prawnto_options - @handler.set_disposition - assert_equal 'attachment;filename=xxx.pdf', @view.headers['Content-Disposition'] - end - - def test_headers_disposition_default - @handler.pull_prawnto_options - @handler.set_disposition - assert_equal 'inline', @view.headers['Content-Disposition'] - end - -end - diff --git a/vendor/plugins/prawnto/test/dsl_template_handler_test.rb b/vendor/plugins/prawnto/test/dsl_template_handler_test.rb deleted file mode 100644 index 6033e21..0000000 --- a/vendor/plugins/prawnto/test/dsl_template_handler_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'rubygems' -require 'test/unit' -require File.dirname(__FILE__) + '/template_handler_test_mocks' -require File.dirname(__FILE__) + '/../lib/prawnto' -#require File.dirname(__FILE__) + '/../init' - - -#TODO: ruby1.9: pull same testing scheme from Raw once we're on 1.9 -class DslTemplateHandlerTest < Test::Unit::TestCase - include TemplateHandlerTestMocks - - def setup - @view = ActionView.new - @handler = Prawnto::TemplateHandlers::Dsl.new(@view) - @controller = @view.controller - end - - def test_prawnto_options_dsl_hash - @y = 3231; @x = 5322 - @controller.prawnto :dsl=> {'x'=>:@x, :y=>'@y'} - @handler.pull_prawnto_options - source = @handler.build_source_to_establish_locals(Template.new("")) - - assert_equal @x, eval(source + "\nx") - assert_equal @y, eval(source + "\ny") - end - - def test_prawnto_options_dsl_array - @y = 3231; @x = 5322 - @controller.prawnto :dsl=> ['x', :@y] - @handler.pull_prawnto_options - source = @handler.build_source_to_establish_locals(Template.new("")) - - assert_equal @x, eval(source + "\nx") - assert_equal @y, eval(source + "\ny") - end - - -end - diff --git a/vendor/plugins/prawnto/test/raw_template_handler_test.rb b/vendor/plugins/prawnto/test/raw_template_handler_test.rb deleted file mode 100644 index ba44c77..0000000 --- a/vendor/plugins/prawnto/test/raw_template_handler_test.rb +++ /dev/null @@ -1,163 +0,0 @@ -# uncomment and edit below if you want to get off gem version -#$LOAD_PATH.unshift '~/cracklabs/vendor/gems/prawn-0.0.0.1/lib/' #to force picup of latest prawn (instead of stable gem) - -require 'rubygems' -require 'action_controller' -require 'action_view' - -require 'test/unit' -require File.dirname(__FILE__) + '/../lib/prawnto' -require File.dirname(__FILE__) + '/template_handler_test_mocks' - - -class RawTemplateHandlerTest < Test::Unit::TestCase - include TemplateHandlerTestMocks - class ::ApplicationHelper - end - - def setup - @view = ActionView.new - @handler = Prawnto::TemplateHandlers::Raw.new(@view) - end - - - def test_massage_template_source_header_comments - expected_commented_lines = [0,2,3] - source = <true - INPUTS.each do |path| - pre_brood = INPUT_PATH.children - cd INPUT_PATH - system("ruby #{path.basename}") - post_brood = INPUT_PATH.children - new_kids = post_brood - pre_brood - new_kids.each {|p| mv p, REFERENCE_PATH + p.basename} - cd CURRENT_PATH - end - cp head_version, current_version - end - else - puts "\n reference pdfs are current-- continuing...\n" - end - end - - #TODO: ruby 1.9: uncomment below line when on 1.9 - #ensure_reference_pdfs_are_recent - - - def assert_renders_correctly(name, path) - input_source = path.read - output_source = @handler.compile(Template.new(input_source)) - value = @view.instance_eval output_source - reference = (REFERENCE_PATH + @view.prawnto_options[:filename]).read - - message = "template: #{name}\n" - message += ">"*30 + " original template: " + ">"*20 + "\n" - message += input_source + "\n"*2 - message += ">"*30 + " manipulated template: " + ">"*20 + "\n" - message += output_source + "\n" + "<"*60 + "\n" - - assert_equal reference, value, message - end - - #!!! Can't actually verify pdf equality until ruby 1.9 - # (cuz hash orders are messed up otherwise and no other way to test equality at the moment) - INPUTS.each do |path| - name = path.basename('.rb') - define_method "test_template_should_render_correctly [template: #{name}] " do - # assert_renders_correctly name, path - assert true - end - end - - - - -end - diff --git a/vendor/plugins/prawnto/test/template_handler_test_mocks.rb b/vendor/plugins/prawnto/test/template_handler_test_mocks.rb deleted file mode 100644 index c7b0ed4..0000000 --- a/vendor/plugins/prawnto/test/template_handler_test_mocks.rb +++ /dev/null @@ -1,77 +0,0 @@ -require 'rubygems' -require File.dirname(__FILE__) + '/../lib/prawnto' - -module TemplateHandlerTestMocks - - class Template - attr_reader :source, :locals, :filename - - def initialize(source, locals={}) - @source = source - @locals = locals - @filename = "blah.pdf" - end - end - - - class Response - def initialize - @headers = {} - end - - def headers - @headers - end - - def content_type=(value) - end - end - - class Request - def env - {} - end - end - - class ActionController - - include Prawnto::ActionController - - def response - @response ||= Response.new - end - - def request - @request ||= Request.new - end - - def headers - response.headers - end - end - - class ActionView - def controller - @controller ||= ActionController.new - end - - def response - controller.response - end - - def request - controller.request - end - - def headers - controller.headers - end - - def prawnto_options - controller.get_instance_variable(:@prawnto_options) - end - end - - -end -