|.|^) # start of line?
+ \! # opening
+ (\<|\=|\>)? # optional alignment atts
+ (#{C}) # optional style,class atts
+ (?:\. )? # optional dot-space
+ ([^\s(!]+?) # presume this is the src
+ \s? # optional space
+ (?:\(((?:[^\(\)]|\([^\)]+\))+?)\))? # optional title
+ \! # closing
+ (?::#{ HYPERLINK })? # optional href
+ /x
+
+ def inline_textile_image( text )
+ text.gsub!( IMAGE_RE ) do |m|
+ stln,algn,atts,url,title,href,href_a1,href_a2 = $~[1..8]
+ atts = pba( atts )
+ atts = " src=\"#{ url }\"#{ atts }"
+ atts << " title=\"#{ title }\"" if title
+ atts << " alt=\"#{ title }\""
+ # size = @getimagesize($url);
+ # if($size) $atts.= " $size[3]";
+
+ href, alt_title = check_refs( href ) if href
+ url, url_title = check_refs( url )
+
+ out = ''
+ out << "" if href
+ out << " "
+ out << " #{ href_a1 }#{ href_a2 }" if href
+
+ if algn
+ algn = h_align( algn )
+ if stln == "
, etc.
+ if $1
+ if line =~ OFFTAG_OPEN
+ codepre += 1
+ elsif line =~ OFFTAG_CLOSE
+ codepre -= 1
+ codepre = 0 if codepre < 0
+ end
+ elsif codepre.zero?
+ glyphs_textile( line, level + 1 )
+ else
+ htmlesc( line, :NoQuotes )
+ end
+ # p [level, codepre, line]
+
+ line
+ end
+ end
+ end
+
+ def rip_offtags( text )
+ if text =~ /<.*>/
+ ## strip and encode content
+ codepre, used_offtags = 0, {}
+ text.gsub!( OFFTAG_MATCH ) do |line|
+ if $3
+ offtag, aftertag = $4, $5
+ codepre += 1
+ used_offtags[offtag] = true
+ if codepre - used_offtags.length > 0
+ htmlesc( line, :NoQuotes ) unless used_offtags['notextile']
+ @pre_list.last << line
+ line = ""
+ else
+ htmlesc( aftertag, :NoQuotes ) if aftertag and not used_offtags['notextile']
+ line = ""
+ @pre_list << "#{ $3 }#{ aftertag }"
+ end
+ elsif $1 and codepre > 0
+ if codepre - used_offtags.length > 0
+ htmlesc( line, :NoQuotes ) unless used_offtags['notextile']
+ @pre_list.last << line
+ line = ""
+ end
+ codepre -= 1 unless codepre.zero?
+ used_offtags = {} if codepre.zero?
+ end
+ line
+ end
+ end
+ text
+ end
+
+ def smooth_offtags( text )
+ unless @pre_list.empty?
+ ## replace content
+ text.gsub!( // ) { @pre_list[$1.to_i] }
+ end
+ end
+
+ def inline( text )
+ [/^inline_/, /^glyphs_/].each do |meth_re|
+ @rules.each do |rule_name|
+ method( rule_name ).call( text ) if rule_name.to_s.match( meth_re )
+ end
+ end
+ end
+
+ def h_align( text )
+ H_ALGN_VALS[text]
+ end
+
+ def v_align( text )
+ V_ALGN_VALS[text]
+ end
+
+ def textile_popup_help( name, windowW, windowH )
+ ' ' + name + ' '
+ end
+
+ # HTML cleansing stuff
+ BASIC_TAGS = {
+ 'a' => ['href', 'title'],
+ 'img' => ['src', 'alt', 'title'],
+ 'br' => [],
+ 'i' => nil,
+ 'u' => nil,
+ 'b' => nil,
+ 'pre' => nil,
+ 'kbd' => nil,
+ 'code' => ['lang'],
+ 'cite' => nil,
+ 'strong' => nil,
+ 'em' => nil,
+ 'ins' => nil,
+ 'sup' => nil,
+ 'sub' => nil,
+ 'del' => nil,
+ 'table' => nil,
+ 'tr' => nil,
+ 'td' => ['colspan', 'rowspan'],
+ 'th' => nil,
+ 'ol' => nil,
+ 'ul' => nil,
+ 'li' => nil,
+ 'p' => nil,
+ 'h1' => nil,
+ 'h2' => nil,
+ 'h3' => nil,
+ 'h4' => nil,
+ 'h5' => nil,
+ 'h6' => nil,
+ 'blockquote' => ['cite']
+ }
+
+ def clean_html( text, tags = BASIC_TAGS )
+ text.gsub!( /]*)>/ ) do
+ raw = $~
+ tag = raw[2].downcase
+ if tags.has_key? tag
+ pcs = [tag]
+ tags[tag].each do |prop|
+ ['"', "'", ''].each do |q|
+ q2 = ( q != '' ? q : '\s' )
+ if raw[3] =~ /#{prop}\s*=\s*#{q}([^#{q2}]+)#{q}/i
+ attrv = $1
+ next if prop == 'src' and attrv =~ %r{^(?!http)\w+:}
+ pcs << "#{prop}=\"#{$1.gsub('"', '\\"')}\""
+ break
+ end
+ end
+ end if tags[tag]
+ "<#{raw[1]}#{pcs.join " "}>"
+ else
+ " "
+ end
+ end
+ end
+end
+
diff --git a/rest_sys/lib/redmine.rb b/rest_sys/lib/redmine.rb
new file mode 100644
index 000000000..1f1053438
--- /dev/null
+++ b/rest_sys/lib/redmine.rb
@@ -0,0 +1,106 @@
+require 'redmine/access_control'
+require 'redmine/menu_manager'
+require 'redmine/mime_type'
+require 'redmine/themes'
+require 'redmine/plugin'
+
+begin
+ require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick)
+rescue LoadError
+ # RMagick is not available
+end
+
+REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs Bazaar )
+
+# Permissions
+Redmine::AccessControl.map do |map|
+ map.permission :view_project, {:projects => [:show, :activity]}, :public => true
+ map.permission :search_project, {:search => :index}, :public => true
+ map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member
+ map.permission :select_project_modules, {:projects => :modules}, :require => :member
+ map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy]}, :require => :member
+ map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member
+
+ map.project_module :issue_tracking do |map|
+ # Issue categories
+ map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member
+ # Issues
+ map.permission :view_issues, {:projects => [:changelog, :roadmap],
+ :issues => [:index, :changes, :show, :context_menu],
+ :versions => [:show, :status_by],
+ :queries => :index,
+ :reports => :issue_report}, :public => true
+ map.permission :add_issues, {:projects => :add_issue}
+ map.permission :edit_issues, {:projects => :bulk_edit_issues,
+ :issues => [:edit, :destroy_attachment]}
+ map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
+ map.permission :add_issue_notes, {:issues => :add_note}
+ map.permission :change_issue_status, {:issues => :change_status}, :require => :loggedin
+ map.permission :move_issues, {:projects => :move_issues}, :require => :loggedin
+ map.permission :delete_issues, {:issues => :destroy}, :require => :member
+ # Queries
+ map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member
+ map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin
+ # Gantt & calendar
+ map.permission :view_gantt, :projects => :gantt
+ map.permission :view_calendar, :projects => :calendar
+ end
+
+ map.project_module :time_tracking do |map|
+ map.permission :log_time, {:timelog => :edit}, :require => :loggedin
+ map.permission :view_time_entries, :timelog => [:details, :report]
+ end
+
+ map.project_module :news do |map|
+ map.permission :manage_news, {:projects => :add_news, :news => [:edit, :destroy, :destroy_comment]}, :require => :member
+ map.permission :view_news, {:news => [:index, :show]}, :public => true
+ map.permission :comment_news, {:news => :add_comment}
+ end
+
+ map.project_module :documents do |map|
+ map.permission :manage_documents, {:projects => :add_document, :documents => [:edit, :destroy, :add_attachment, :destroy_attachment]}, :require => :loggedin
+ map.permission :view_documents, :projects => :list_documents, :documents => [:show, :download]
+ end
+
+ map.project_module :files do |map|
+ map.permission :manage_files, {:projects => :add_file, :versions => :destroy_file}, :require => :loggedin
+ map.permission :view_files, :projects => :list_files, :versions => :download
+ end
+
+ map.project_module :wiki do |map|
+ map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
+ map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
+ map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member
+ map.permission :view_wiki_pages, :wiki => [:index, :history, :diff, :special]
+ map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment, :destroy_attachment]
+ end
+
+ map.project_module :repository do |map|
+ map.permission :manage_repository, {:repositories => [:edit, :destroy]}, :require => :member
+ map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph]
+ map.permission :view_changesets, :repositories => [:show, :revisions, :revision]
+ end
+
+ map.project_module :boards do |map|
+ map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member
+ map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true
+ map.permission :add_messages, {:messages => [:new, :reply]}
+ map.permission :edit_messages, {:messages => :edit}, :require => :member
+ map.permission :delete_messages, {:messages => :destroy}, :require => :member
+ end
+end
+
+# Project menu configuration
+Redmine::MenuManager.map :project_menu do |menu|
+ menu.push :label_overview, :controller => 'projects', :action => 'show'
+ menu.push :label_activity, :controller => 'projects', :action => 'activity'
+ menu.push :label_roadmap, :controller => 'projects', :action => 'roadmap'
+ menu.push :label_issue_plural, { :controller => 'issues', :action => 'index' }, :param => :project_id
+ menu.push :label_news_plural, { :controller => 'news', :action => 'index' }, :param => :project_id
+ menu.push :label_document_plural, :controller => 'projects', :action => 'list_documents'
+ menu.push :label_wiki, { :controller => 'wiki', :action => 'index', :page => nil }, :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
+ menu.push :label_board_plural, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, :if => Proc.new { |p| p.boards.any? }
+ menu.push :label_attachment_plural, :controller => 'projects', :action => 'list_files'
+ menu.push :label_repository, { :controller => 'repositories', :action => 'show' }, :if => Proc.new { |p| p.repository && !p.repository.new_record? }
+ menu.push :label_settings, :controller => 'projects', :action => 'settings'
+end
diff --git a/rest_sys/lib/redmine/access_control.rb b/rest_sys/lib/redmine/access_control.rb
new file mode 100644
index 000000000..f5b25f277
--- /dev/null
+++ b/rest_sys/lib/redmine/access_control.rb
@@ -0,0 +1,112 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module Redmine
+ module AccessControl
+
+ class << self
+ def map
+ mapper = Mapper.new
+ yield mapper
+ @permissions ||= []
+ @permissions += mapper.mapped_permissions
+ end
+
+ def permissions
+ @permissions
+ end
+
+ def allowed_actions(permission_name)
+ perm = @permissions.detect {|p| p.name == permission_name}
+ perm ? perm.actions : []
+ end
+
+ def public_permissions
+ @public_permissions ||= @permissions.select {|p| p.public?}
+ end
+
+ def members_only_permissions
+ @members_only_permissions ||= @permissions.select {|p| p.require_member?}
+ end
+
+ def loggedin_only_permissions
+ @loggedin_only_permissions ||= @permissions.select {|p| p.require_loggedin?}
+ end
+
+ def available_project_modules
+ @available_project_modules ||= @permissions.collect(&:project_module).uniq.compact
+ end
+
+ def modules_permissions(modules)
+ @permissions.select {|p| p.project_module.nil? || modules.include?(p.project_module.to_s)}
+ end
+ end
+
+ class Mapper
+ def initialize
+ @project_module = nil
+ end
+
+ def permission(name, hash, options={})
+ @permissions ||= []
+ options.merge!(:project_module => @project_module)
+ @permissions << Permission.new(name, hash, options)
+ end
+
+ def project_module(name, options={})
+ @project_module = name
+ yield self
+ @project_module = nil
+ end
+
+ def mapped_permissions
+ @permissions
+ end
+ end
+
+ class Permission
+ attr_reader :name, :actions, :project_module
+
+ def initialize(name, hash, options)
+ @name = name
+ @actions = []
+ @public = options[:public] || false
+ @require = options[:require]
+ @project_module = options[:project_module]
+ hash.each do |controller, actions|
+ if actions.is_a? Array
+ @actions << actions.collect {|action| "#{controller}/#{action}"}
+ else
+ @actions << "#{controller}/#{actions}"
+ end
+ end
+ end
+
+ def public?
+ @public
+ end
+
+ def require_member?
+ @require && @require == :member
+ end
+
+ def require_loggedin?
+ @require && (@require == :member || @require == :loggedin)
+ end
+ end
+ end
+end
diff --git a/rest_sys/lib/redmine/helpers/calendar.rb b/rest_sys/lib/redmine/helpers/calendar.rb
new file mode 100644
index 000000000..347f1c5b5
--- /dev/null
+++ b/rest_sys/lib/redmine/helpers/calendar.rb
@@ -0,0 +1,76 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module Redmine
+ module Helpers
+
+ # Simple class to compute the start and end dates of a calendar
+ class Calendar
+ include GLoc
+ attr_reader :startdt, :enddt
+
+ def initialize(date, lang = current_language, period = :month)
+ @date = date
+ @events = []
+ @ending_events_by_days = {}
+ @starting_events_by_days = {}
+ set_language lang
+ case period
+ when :month
+ @startdt = Date.civil(date.year, date.month, 1)
+ @enddt = (@startdt >> 1)-1
+ # starts from the first day of the week
+ @startdt = @startdt - (@startdt.cwday - first_wday)%7
+ # ends on the last day of the week
+ @enddt = @enddt + (last_wday - @enddt.cwday)%7
+ when :week
+ @startdt = date - (date.cwday - first_wday)%7
+ @enddt = date + (last_wday - date.cwday)%7
+ else
+ raise 'Invalid period'
+ end
+ end
+
+ # Sets calendar events
+ def events=(events)
+ @events = events
+ @ending_events_by_days = @events.group_by {|event| event.due_date}
+ @starting_events_by_days = @events.group_by {|event| event.start_date}
+ end
+
+ # Returns events for the given day
+ def events_on(day)
+ ((@ending_events_by_days[day] || []) + (@starting_events_by_days[day] || [])).uniq
+ end
+
+ # Calendar current month
+ def month
+ @date.month
+ end
+
+ # Return the first day of week
+ # 1 = Monday ... 7 = Sunday
+ def first_wday
+ @first_dow ||= (l(:general_first_day_of_week).to_i - 1)%7 + 1
+ end
+
+ def last_wday
+ @last_dow ||= (first_wday + 5)%7 + 1
+ end
+ end
+ end
+end
diff --git a/rest_sys/lib/redmine/info.rb b/rest_sys/lib/redmine/info.rb
new file mode 100644
index 000000000..0e00e8b85
--- /dev/null
+++ b/rest_sys/lib/redmine/info.rb
@@ -0,0 +1,10 @@
+module Redmine
+ module Info
+ class << self
+ def app_name; 'Redmine' end
+ def url; 'http://www.redmine.org/' end
+ def help_url; 'http://www.redmine.org/guide' end
+ def versioned_name; "#{app_name} #{Redmine::VERSION}" end
+ end
+ end
+end
diff --git a/rest_sys/lib/redmine/menu_manager.rb b/rest_sys/lib/redmine/menu_manager.rb
new file mode 100644
index 000000000..d4a46b3e1
--- /dev/null
+++ b/rest_sys/lib/redmine/menu_manager.rb
@@ -0,0 +1,61 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module Redmine
+ module MenuManager
+
+ class << self
+ def map(menu_name)
+ mapper = Mapper.new
+ yield mapper
+ @items ||= {}
+ @items[menu_name.to_sym] ||= []
+ @items[menu_name.to_sym] += mapper.items
+ end
+
+ def items(menu_name)
+ @items[menu_name.to_sym] || []
+ end
+
+ def allowed_items(menu_name, user, project)
+ items(menu_name).select {|item| user && user.allowed_to?(item.url, project)}
+ end
+ end
+
+ class Mapper
+ def push(name, url, options={})
+ @items ||= []
+ @items << MenuItem.new(name, url, options)
+ end
+
+ def items
+ @items
+ end
+ end
+
+ class MenuItem
+ attr_reader :name, :url, :param, :condition
+
+ def initialize(name, url, options)
+ @name = name
+ @url = url
+ @condition = options[:if]
+ @param = options[:param] || :id
+ end
+ end
+ end
+end
diff --git a/rest_sys/lib/redmine/mime_type.rb b/rest_sys/lib/redmine/mime_type.rb
new file mode 100644
index 000000000..e041c731f
--- /dev/null
+++ b/rest_sys/lib/redmine/mime_type.rb
@@ -0,0 +1,61 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module Redmine
+ module MimeType
+
+ MIME_TYPES = {
+ 'text/plain' => 'txt',
+ 'text/css' => 'css',
+ 'text/html' => 'html,htm,xhtml',
+ 'text/x-c' => 'c,cpp,h',
+ 'text/x-javascript' => 'js',
+ 'text/x-html-template' => 'rhtml',
+ 'text/x-ruby' => 'rb,rbw,ruby,rake',
+ 'text/xml' => 'xml',
+ 'text/yaml' => 'yml,yaml',
+ 'image/gif' => 'gif',
+ 'image/jpeg' => 'jpg,jpeg,jpe',
+ 'image/png' => 'png',
+ 'image/tiff' => 'tiff,tif'
+ }.freeze
+
+ EXTENSIONS = MIME_TYPES.inject({}) do |map, (type, exts)|
+ exts.split(',').each {|ext| map[ext] = type}
+ map
+ end
+
+ # returns mime type for name or nil if unknown
+ def self.of(name)
+ return nil unless name
+ m = name.to_s.match(/\.([^\.]+)$/)
+ EXTENSIONS[m[1]] if m
+ end
+
+ def self.main_mimetype_of(name)
+ mimetype = of(name)
+ mimetype.split('/').first if mimetype
+ end
+
+ # return true if mime-type for name is type/*
+ # otherwise false
+ def self.is_type?(type, name)
+ main_mimetype = main_mimetype_of(name)
+ type.to_s == main_mimetype
+ end
+ end
+end
diff --git a/rest_sys/lib/redmine/plugin.rb b/rest_sys/lib/redmine/plugin.rb
new file mode 100644
index 000000000..e6047974e
--- /dev/null
+++ b/rest_sys/lib/redmine/plugin.rb
@@ -0,0 +1,124 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module Redmine #:nodoc:
+
+ # Base class for Redmine plugins.
+ # Plugins are registered using the register class method that acts as the public constructor.
+ #
+ # Redmine::Plugin.register :example do
+ # name 'Example plugin'
+ # author 'John Smith'
+ # description 'This is an example plugin for Redmine'
+ # version '0.0.1'
+ # settings :default => {'foo'=>'bar'}, :partial => 'settings/settings'
+ # end
+ #
+ # === Plugin attributes
+ #
+ # +settings+ is an optional attribute that let the plugin be configurable.
+ # It must be a hash with the following keys:
+ # * :default : default value for the plugin settings
+ # * :partial : path of the configuration partial view, relative to the plugin app/views directory
+ # Example:
+ # settings :default => {'foo'=>'bar'}, :partial => 'settings/settings'
+ # In this example, the settings partial will be found here in the plugin directory: app/views/settings/_settings.rhtml .
+ #
+ # When rendered, the plugin settings value is available as the local variable +settings+
+ class Plugin
+ @registered_plugins = {}
+ class << self
+ attr_reader :registered_plugins
+ private :new
+
+ def def_field(*names)
+ class_eval do
+ names.each do |name|
+ define_method(name) do |*args|
+ args.empty? ? instance_variable_get("@#{name}") : instance_variable_set("@#{name}", *args)
+ end
+ end
+ end
+ end
+ end
+ def_field :name, :description, :author, :version, :settings
+
+ # Plugin constructor
+ def self.register(name, &block)
+ p = new
+ p.instance_eval(&block)
+ Plugin.registered_plugins[name] = p
+ end
+
+ # Adds an item to the given +menu+.
+ # The +id+ parameter (equals to the project id) is automatically added to the url.
+ # menu :project_menu, :label_plugin_example, :controller => 'example', :action => 'say_hello'
+ #
+ # Currently, only the project menu can be extended. Thus, the +name+ parameter must be +:project_menu+
+ def menu(name, label, url)
+ Redmine::MenuManager.map(name) {|menu| menu.push label, url}
+ end
+
+ # Defines a permission called +name+ for the given +actions+.
+ #
+ # The +actions+ argument is a hash with controllers as keys and actions as values (a single value or an array):
+ # permission :destroy_contacts, { :contacts => :destroy }
+ # permission :view_contacts, { :contacts => [:index, :show] }
+ #
+ # The +options+ argument can be used to make the permission public (implicitly given to any user)
+ # or to restrict users the permission can be given to.
+ #
+ # Examples
+ # # A permission that is implicitly given to any user
+ # # This permission won't appear on the Roles & Permissions setup screen
+ # permission :say_hello, { :example => :say_hello }, :public => true
+ #
+ # # A permission that can be given to any user
+ # permission :say_hello, { :example => :say_hello }
+ #
+ # # A permission that can be given to registered users only
+ # permission :say_hello, { :example => :say_hello }, :require => loggedin
+ #
+ # # A permission that can be given to project members only
+ # permission :say_hello, { :example => :say_hello }, :require => member
+ def permission(name, actions, options = {})
+ if @project_module
+ Redmine::AccessControl.map {|map| map.project_module(@project_module) {|map|map.permission(name, actions, options)}}
+ else
+ Redmine::AccessControl.map {|map| map.permission(name, actions, options)}
+ end
+ end
+
+ # Defines a project module, that can be enabled/disabled for each project.
+ # Permissions defined inside +block+ will be bind to the module.
+ #
+ # project_module :things do
+ # permission :view_contacts, { :contacts => [:list, :show] }, :public => true
+ # permission :destroy_contacts, { :contacts => :destroy }
+ # end
+ def project_module(name, &block)
+ @project_module = name
+ self.instance_eval(&block)
+ @project_module = nil
+ end
+
+ # Returns +true+ if the plugin can be configured.
+ def configurable?
+ settings && settings.is_a?(Hash) && !settings[:partial].blank?
+ end
+ end
+end
diff --git a/rest_sys/lib/redmine/scm/adapters/abstract_adapter.rb b/rest_sys/lib/redmine/scm/adapters/abstract_adapter.rb
new file mode 100644
index 000000000..c93fc6350
--- /dev/null
+++ b/rest_sys/lib/redmine/scm/adapters/abstract_adapter.rb
@@ -0,0 +1,385 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'cgi'
+
+module Redmine
+ module Scm
+ module Adapters
+ class CommandFailed < StandardError #:nodoc:
+ end
+
+ class AbstractAdapter #:nodoc:
+ def initialize(url, root_url=nil, login=nil, password=nil)
+ @url = url
+ @login = login if login && !login.empty?
+ @password = (password || "") if @login
+ @root_url = root_url.blank? ? retrieve_root_url : root_url
+ end
+
+ def adapter_name
+ 'Abstract'
+ end
+
+ def supports_cat?
+ true
+ end
+
+ def supports_annotate?
+ respond_to?('annotate')
+ end
+
+ def root_url
+ @root_url
+ end
+
+ def url
+ @url
+ end
+
+ # get info about the svn repository
+ def info
+ return nil
+ end
+
+ # Returns the entry identified by path and revision identifier
+ # or nil if entry doesn't exist in the repository
+ def entry(path=nil, identifier=nil)
+ e = entries(path, identifier)
+ e ? e.first : nil
+ end
+
+ # Returns an Entries collection
+ # or nil if the given path doesn't exist in the repository
+ def entries(path=nil, identifier=nil)
+ return nil
+ end
+
+ def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
+ return nil
+ end
+
+ def diff(path, identifier_from, identifier_to=nil, type="inline")
+ return nil
+ end
+
+ def cat(path, identifier=nil)
+ return nil
+ end
+
+ def with_leading_slash(path)
+ path ||= ''
+ (path[0,1]!="/") ? "/#{path}" : path
+ end
+
+ def shell_quote(str)
+ if RUBY_PLATFORM =~ /mswin/
+ '"' + str.gsub(/"/, '\\"') + '"'
+ else
+ "'" + str.gsub(/'/, "'\"'\"'") + "'"
+ end
+ end
+
+ private
+ def retrieve_root_url
+ info = self.info
+ info ? info.root_url : nil
+ end
+
+ def target(path)
+ path ||= ""
+ base = path.match(/^\//) ? root_url : url
+ " \"" << "#{base}/#{path}".gsub(/["?<>\*]/, '') << "\""
+ end
+
+ def logger
+ RAILS_DEFAULT_LOGGER
+ end
+
+ def shellout(cmd, &block)
+ logger.debug "Shelling out: #{cmd}" if logger && logger.debug?
+ begin
+ IO.popen(cmd, "r+") do |io|
+ io.close_write
+ block.call(io) if block_given?
+ end
+ rescue Errno::ENOENT => e
+ # The command failed, log it and re-raise
+ log.error("SCM command failed: #{cmd}\n with: #{e.message}")
+ raise CommandFailed
+ end
+ end
+ end
+
+ class Entries < Array
+ def sort_by_name
+ sort {|x,y|
+ if x.kind == y.kind
+ x.name <=> y.name
+ else
+ x.kind <=> y.kind
+ end
+ }
+ end
+
+ def revisions
+ revisions ||= Revisions.new(collect{|entry| entry.lastrev}.compact)
+ end
+ end
+
+ class Info
+ attr_accessor :root_url, :lastrev
+ def initialize(attributes={})
+ self.root_url = attributes[:root_url] if attributes[:root_url]
+ self.lastrev = attributes[:lastrev]
+ end
+ end
+
+ class Entry
+ attr_accessor :name, :path, :kind, :size, :lastrev
+ def initialize(attributes={})
+ self.name = attributes[:name] if attributes[:name]
+ self.path = attributes[:path] if attributes[:path]
+ self.kind = attributes[:kind] if attributes[:kind]
+ self.size = attributes[:size].to_i if attributes[:size]
+ self.lastrev = attributes[:lastrev]
+ end
+
+ def is_file?
+ 'file' == self.kind
+ end
+
+ def is_dir?
+ 'dir' == self.kind
+ end
+
+ def is_text?
+ Redmine::MimeType.is_type?('text', name)
+ end
+ end
+
+ class Revisions < Array
+ def latest
+ sort {|x,y|
+ unless x.time.nil? or y.time.nil?
+ x.time <=> y.time
+ else
+ 0
+ end
+ }.last
+ end
+ end
+
+ class Revision
+ attr_accessor :identifier, :scmid, :name, :author, :time, :message, :paths, :revision, :branch
+ def initialize(attributes={})
+ self.identifier = attributes[:identifier]
+ self.scmid = attributes[:scmid]
+ self.name = attributes[:name] || self.identifier
+ self.author = attributes[:author]
+ self.time = attributes[:time]
+ self.message = attributes[:message] || ""
+ self.paths = attributes[:paths]
+ self.revision = attributes[:revision]
+ self.branch = attributes[:branch]
+ end
+
+ end
+
+ # A line of Diff
+ class Diff
+ attr_accessor :nb_line_left
+ attr_accessor :line_left
+ attr_accessor :nb_line_right
+ attr_accessor :line_right
+ attr_accessor :type_diff_right
+ attr_accessor :type_diff_left
+
+ def initialize ()
+ self.nb_line_left = ''
+ self.nb_line_right = ''
+ self.line_left = ''
+ self.line_right = ''
+ self.type_diff_right = ''
+ self.type_diff_left = ''
+ end
+
+ def inspect
+ puts '### Start Line Diff ###'
+ puts self.nb_line_left
+ puts self.line_left
+ puts self.nb_line_right
+ puts self.line_right
+ end
+ end
+
+ class DiffTableList < Array
+ def initialize (diff, type="inline")
+ diff_table = DiffTable.new type
+ diff.each do |line|
+ if line =~ /^(---|\+\+\+) (.*)$/
+ self << diff_table if diff_table.length > 1
+ diff_table = DiffTable.new type
+ end
+ a = diff_table.add_line line
+ end
+ self << diff_table
+ end
+ end
+
+ # Class for create a Diff
+ class DiffTable < Hash
+ attr_reader :file_name, :line_num_l, :line_num_r
+
+ # Initialize with a Diff file and the type of Diff View
+ # The type view must be inline or sbs (side_by_side)
+ def initialize(type="inline")
+ @parsing = false
+ @nb_line = 1
+ @start = false
+ @before = 'same'
+ @second = true
+ @type = type
+ end
+
+ # Function for add a line of this Diff
+ def add_line(line)
+ unless @parsing
+ if line =~ /^(---|\+\+\+) (.*)$/
+ @file_name = $2
+ return false
+ elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/
+ @line_num_l = $5.to_i
+ @line_num_r = $2.to_i
+ @parsing = true
+ end
+ else
+ if line =~ /^[^\+\-\s@\\]/
+ self.delete(self.keys.sort.last)
+ @parsing = false
+ return false
+ elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/
+ @line_num_l = $5.to_i
+ @line_num_r = $2.to_i
+ else
+ @nb_line += 1 if parse_line(line, @type)
+ end
+ end
+ return true
+ end
+
+ def inspect
+ puts '### DIFF TABLE ###'
+ puts "file : #{file_name}"
+ self.each do |d|
+ d.inspect
+ end
+ end
+
+ private
+ # Test if is a Side By Side type
+ def sbs?(type, func)
+ if @start and type == "sbs"
+ if @before == func and @second
+ tmp_nb_line = @nb_line
+ self[tmp_nb_line] = Diff.new
+ else
+ @second = false
+ tmp_nb_line = @start
+ @start += 1
+ @nb_line -= 1
+ end
+ else
+ tmp_nb_line = @nb_line
+ @start = @nb_line
+ self[tmp_nb_line] = Diff.new
+ @second = true
+ end
+ unless self[tmp_nb_line]
+ @nb_line += 1
+ self[tmp_nb_line] = Diff.new
+ else
+ self[tmp_nb_line]
+ end
+ end
+
+ # Escape the HTML for the diff
+ def escapeHTML(line)
+ CGI.escapeHTML(line)
+ end
+
+ def parse_line(line, type="inline")
+ if line[0, 1] == "+"
+ diff = sbs? type, 'add'
+ @before = 'add'
+ diff.line_left = escapeHTML line[1..-1]
+ diff.nb_line_left = @line_num_l
+ diff.type_diff_left = 'diff_in'
+ @line_num_l += 1
+ true
+ elsif line[0, 1] == "-"
+ diff = sbs? type, 'remove'
+ @before = 'remove'
+ diff.line_right = escapeHTML line[1..-1]
+ diff.nb_line_right = @line_num_r
+ diff.type_diff_right = 'diff_out'
+ @line_num_r += 1
+ true
+ elsif line[0, 1] =~ /\s/
+ @before = 'same'
+ @start = false
+ diff = Diff.new
+ diff.line_right = escapeHTML line[1..-1]
+ diff.nb_line_right = @line_num_r
+ diff.line_left = escapeHTML line[1..-1]
+ diff.nb_line_left = @line_num_l
+ self[@nb_line] = diff
+ @line_num_l += 1
+ @line_num_r += 1
+ true
+ elsif line[0, 1] = "\\"
+ true
+ else
+ false
+ end
+ end
+ end
+
+ class Annotate
+ attr_reader :lines, :revisions
+
+ def initialize
+ @lines = []
+ @revisions = []
+ end
+
+ def add_line(line, revision)
+ @lines << line
+ @revisions << revision
+ end
+
+ def content
+ content = lines.join("\n")
+ end
+
+ def empty?
+ lines.empty?
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/lib/redmine/scm/adapters/bazaar_adapter.rb b/rest_sys/lib/redmine/scm/adapters/bazaar_adapter.rb
new file mode 100644
index 000000000..11a44b7cf
--- /dev/null
+++ b/rest_sys/lib/redmine/scm/adapters/bazaar_adapter.rb
@@ -0,0 +1,197 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'redmine/scm/adapters/abstract_adapter'
+
+module Redmine
+ module Scm
+ module Adapters
+ class BazaarAdapter < AbstractAdapter
+
+ # Bazaar executable name
+ BZR_BIN = "bzr"
+
+ # Get info about the repository
+ def info
+ cmd = "#{BZR_BIN} revno #{target('')}"
+ info = nil
+ shellout(cmd) do |io|
+ if io.read =~ %r{^(\d+)$}
+ info = Info.new({:root_url => url,
+ :lastrev => Revision.new({
+ :identifier => $1
+ })
+ })
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ info
+ rescue CommandFailed
+ return nil
+ end
+
+ # Returns the entry identified by path and revision identifier
+ # or nil if entry doesn't exist in the repository
+ def entry(path=nil, identifier=nil)
+ path ||= ''
+ parts = path.split(%r{[\/\\]}).select {|p| !p.blank?}
+ if parts.size > 0
+ parent = parts[0..-2].join('/')
+ entries = entries(parent, identifier)
+ entries ? entries.detect {|e| e.name == parts.last} : nil
+ end
+ end
+
+ # Returns an Entries collection
+ # or nil if the given path doesn't exist in the repository
+ def entries(path=nil, identifier=nil)
+ path ||= ''
+ entries = Entries.new
+ cmd = "#{BZR_BIN} ls -v --show-ids"
+ cmd << " -r#{identifier.to_i}" if identifier && identifier.to_i > 0
+ cmd << " #{target(path)}"
+ shellout(cmd) do |io|
+ prefix = "#{url}/#{path}".gsub('\\', '/')
+ logger.debug "PREFIX: #{prefix}"
+ re = %r{^V\s+#{Regexp.escape(prefix)}(\/?)([^\/]+)(\/?)\s+(\S+)$}
+ io.each_line do |line|
+ next unless line =~ re
+ entries << Entry.new({:name => $2.strip,
+ :path => ((path.empty? ? "" : "#{path}/") + $2.strip),
+ :kind => ($3.blank? ? 'file' : 'dir'),
+ :size => nil,
+ :lastrev => Revision.new(:revision => $4.strip)
+ })
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ logger.debug("Found #{entries.size} entries in the repository for #{target(path)}") if logger && logger.debug?
+ entries.sort_by_name
+ end
+
+ def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
+ path ||= ''
+ identifier_from = 'last:1' unless identifier_from and identifier_from.to_i > 0
+ identifier_to = 1 unless identifier_to and identifier_to.to_i > 0
+ revisions = Revisions.new
+ cmd = "#{BZR_BIN} log -v --show-ids -r#{identifier_to.to_i}..#{identifier_from} #{target(path)}"
+ shellout(cmd) do |io|
+ revision = nil
+ parsing = nil
+ io.each_line do |line|
+ if line =~ /^----/
+ revisions << revision if revision
+ revision = Revision.new(:paths => [], :message => '')
+ parsing = nil
+ else
+ next unless revision
+
+ if line =~ /^revno: (\d+)$/
+ revision.identifier = $1.to_i
+ elsif line =~ /^committer: (.+)$/
+ revision.author = $1.strip
+ elsif line =~ /^revision-id:(.+)$/
+ revision.scmid = $1.strip
+ elsif line =~ /^timestamp: (.+)$/
+ revision.time = Time.parse($1).localtime
+ elsif line =~ /^ -----/
+ # partial revisions
+ parsing = nil unless parsing == 'message'
+ elsif line =~ /^(message|added|modified|removed|renamed):/
+ parsing = $1
+ elsif line =~ /^ (.*)$/
+ if parsing == 'message'
+ revision.message << "#{$1}\n"
+ else
+ if $1 =~ /^(.*)\s+(\S+)$/
+ path = $1.strip
+ revid = $2
+ case parsing
+ when 'added'
+ revision.paths << {:action => 'A', :path => "/#{path}", :revision => revid}
+ when 'modified'
+ revision.paths << {:action => 'M', :path => "/#{path}", :revision => revid}
+ when 'removed'
+ revision.paths << {:action => 'D', :path => "/#{path}", :revision => revid}
+ when 'renamed'
+ new_path = path.split('=>').last
+ revision.paths << {:action => 'M', :path => "/#{new_path.strip}", :revision => revid} if new_path
+ end
+ end
+ end
+ else
+ parsing = nil
+ end
+ end
+ end
+ revisions << revision if revision
+ end
+ return nil if $? && $?.exitstatus != 0
+ revisions
+ end
+
+ def diff(path, identifier_from, identifier_to=nil, type="inline")
+ path ||= ''
+ if identifier_to
+ identifier_to = identifier_to.to_i
+ else
+ identifier_to = identifier_from.to_i - 1
+ end
+ cmd = "#{BZR_BIN} diff -r#{identifier_to}..#{identifier_from} #{target(path)}"
+ diff = []
+ shellout(cmd) do |io|
+ io.each_line do |line|
+ diff << line
+ end
+ end
+ #return nil if $? && $?.exitstatus != 0
+ DiffTableList.new diff, type
+ end
+
+ def cat(path, identifier=nil)
+ cmd = "#{BZR_BIN} cat"
+ cmd << " -r#{identifier.to_i}" if identifier && identifier.to_i > 0
+ cmd << " #{target(path)}"
+ cat = nil
+ shellout(cmd) do |io|
+ io.binmode
+ cat = io.read
+ end
+ return nil if $? && $?.exitstatus != 0
+ cat
+ end
+
+ def annotate(path, identifier=nil)
+ cmd = "#{BZR_BIN} annotate --all"
+ cmd << " -r#{identifier.to_i}" if identifier && identifier.to_i > 0
+ cmd << " #{target(path)}"
+ blame = Annotate.new
+ shellout(cmd) do |io|
+ author = nil
+ identifier = nil
+ io.each_line do |line|
+ next unless line =~ %r{^(\d+) ([^|]+)\| (.*)$}
+ blame.add_line($3.rstrip, Revision.new(:identifier => $1.to_i, :author => $2.strip))
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ blame
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/lib/redmine/scm/adapters/cvs_adapter.rb b/rest_sys/lib/redmine/scm/adapters/cvs_adapter.rb
new file mode 100644
index 000000000..73dc9b6c4
--- /dev/null
+++ b/rest_sys/lib/redmine/scm/adapters/cvs_adapter.rb
@@ -0,0 +1,361 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'redmine/scm/adapters/abstract_adapter'
+
+module Redmine
+ module Scm
+ module Adapters
+ class CvsAdapter < AbstractAdapter
+
+ # CVS executable name
+ CVS_BIN = "cvs"
+
+ # Guidelines for the input:
+ # url -> the project-path, relative to the cvsroot (eg. module name)
+ # root_url -> the good old, sometimes damned, CVSROOT
+ # login -> unnecessary
+ # password -> unnecessary too
+ def initialize(url, root_url=nil, login=nil, password=nil)
+ @url = url
+ @login = login if login && !login.empty?
+ @password = (password || "") if @login
+ #TODO: better Exception here (IllegalArgumentException)
+ raise CommandFailed if root_url.blank?
+ @root_url = root_url
+ end
+
+ def root_url
+ @root_url
+ end
+
+ def url
+ @url
+ end
+
+ def info
+ logger.debug " info"
+ Info.new({:root_url => @root_url, :lastrev => nil})
+ end
+
+ def get_previous_revision(revision)
+ CvsRevisionHelper.new(revision).prevRev
+ end
+
+ # Returns the entry identified by path and revision identifier
+ # or nil if entry doesn't exist in the repository
+ # this method returns all revisions from one single SCM-Entry
+ def entry(path=nil, identifier="HEAD")
+ e = entries(path, identifier)
+ logger.debug(" #{e.first.inspect}") if e
+ e ? e.first : nil
+ end
+
+ # Returns an Entries collection
+ # or nil if the given path doesn't exist in the repository
+ # this method is used by the repository-browser (aka LIST)
+ def entries(path=nil, identifier=nil)
+ logger.debug " entries '#{path}' with identifier '#{identifier}'"
+ path_with_project="#{url}#{with_leading_slash(path)}"
+ entries = Entries.new
+ cmd = "#{CVS_BIN} -d #{root_url} rls -ed #{path_with_project}"
+ shellout(cmd) do |io|
+ io.each_line(){|line|
+ fields=line.chop.split('/',-1)
+ logger.debug(">>InspectLine #{fields.inspect}")
+
+ if fields[0]!="D"
+ entries << Entry.new({:name => fields[-5],
+ #:path => fields[-4].include?(path)?fields[-4]:(path + "/"+ fields[-4]),
+ :path => "#{path}/#{fields[-5]}",
+ :kind => 'file',
+ :size => nil,
+ :lastrev => Revision.new({
+ :revision => fields[-4],
+ :name => fields[-4],
+ :time => Time.parse(fields[-3]),
+ :author => ''
+ })
+ })
+ else
+ entries << Entry.new({:name => fields[1],
+ :path => "#{path}/#{fields[1]}",
+ :kind => 'dir',
+ :size => nil,
+ :lastrev => nil
+ })
+ end
+ }
+ end
+ return nil if $? && $?.exitstatus != 0
+ entries.sort_by_name
+ end
+
+ STARTLOG="----------------------------"
+ ENDLOG ="============================================================================="
+
+ # Returns all revisions found between identifier_from and identifier_to
+ # in the repository. both identifier have to be dates or nil.
+ # these method returns nothing but yield every result in block
+ def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}, &block)
+ logger.debug " revisions path:'#{path}',identifier_from #{identifier_from}, identifier_to #{identifier_to}"
+
+ path_with_project="#{url}#{with_leading_slash(path)}"
+ cmd = "#{CVS_BIN} -d #{root_url} rlog"
+ cmd << " -d\">#{time_to_cvstime(identifier_from)}\"" if identifier_from
+ cmd << " #{path_with_project}"
+ shellout(cmd) do |io|
+ state="entry_start"
+
+ commit_log=String.new
+ revision=nil
+ date=nil
+ author=nil
+ entry_path=nil
+ entry_name=nil
+ file_state=nil
+ branch_map=nil
+
+ io.each_line() do |line|
+
+ if state!="revision" && /^#{ENDLOG}/ =~ line
+ commit_log=String.new
+ revision=nil
+ state="entry_start"
+ end
+
+ if state=="entry_start"
+ branch_map=Hash.new
+ # gsub(/^:.*@[^:]+:/, '') is here to remove :pserver:anonymous@foo.bar: string if present in the url
+ if /^RCS file: #{Regexp.escape(root_url.gsub(/^:.*@[^:]+:/, ''))}\/#{Regexp.escape(path_with_project)}(.+),v$/ =~ line
+ entry_path = normalize_cvs_path($1)
+ entry_name = normalize_path(File.basename($1))
+ logger.debug("Path #{entry_path} <=> Name #{entry_name}")
+ elsif /^head: (.+)$/ =~ line
+ entry_headRev = $1 #unless entry.nil?
+ elsif /^symbolic names:/ =~ line
+ state="symbolic" #unless entry.nil?
+ elsif /^#{STARTLOG}/ =~ line
+ commit_log=String.new
+ state="revision"
+ end
+ next
+ elsif state=="symbolic"
+ if /^(.*):\s(.*)/ =~ (line.strip)
+ branch_map[$1]=$2
+ else
+ state="tags"
+ next
+ end
+ elsif state=="tags"
+ if /^#{STARTLOG}/ =~ line
+ commit_log = ""
+ state="revision"
+ elsif /^#{ENDLOG}/ =~ line
+ state="head"
+ end
+ next
+ elsif state=="revision"
+ if /^#{ENDLOG}/ =~ line || /^#{STARTLOG}/ =~ line
+ if revision
+
+ revHelper=CvsRevisionHelper.new(revision)
+ revBranch="HEAD"
+
+ branch_map.each() do |branch_name,branch_point|
+ if revHelper.is_in_branch_with_symbol(branch_point)
+ revBranch=branch_name
+ end
+ end
+
+ logger.debug("********** YIELD Revision #{revision}::#{revBranch}")
+
+ yield Revision.new({
+ :time => date,
+ :author => author,
+ :message=>commit_log.chomp,
+ :paths => [{
+ :revision => revision,
+ :branch=> revBranch,
+ :path=>entry_path,
+ :name=>entry_name,
+ :kind=>'file',
+ :action=>file_state
+ }]
+ })
+ end
+
+ commit_log=String.new
+ revision=nil
+
+ if /^#{ENDLOG}/ =~ line
+ state="entry_start"
+ end
+ next
+ end
+
+ if /^branches: (.+)$/ =~ line
+ #TODO: version.branch = $1
+ elsif /^revision (\d+(?:\.\d+)+).*$/ =~ line
+ revision = $1
+ elsif /^date:\s+(\d+.\d+.\d+\s+\d+:\d+:\d+)/ =~ line
+ date = Time.parse($1)
+ author = /author: ([^;]+)/.match(line)[1]
+ file_state = /state: ([^;]+)/.match(line)[1]
+ #TODO: linechanges only available in CVS.... maybe a feature our SVN implementation. i'm sure, they are
+ # useful for stats or something else
+ # linechanges =/lines: \+(\d+) -(\d+)/.match(line)
+ # unless linechanges.nil?
+ # version.line_plus = linechanges[1]
+ # version.line_minus = linechanges[2]
+ # else
+ # version.line_plus = 0
+ # version.line_minus = 0
+ # end
+ else
+ commit_log << line unless line =~ /^\*\*\* empty log message \*\*\*/
+ end
+ end
+ end
+ end
+ end
+
+ def diff(path, identifier_from, identifier_to=nil, type="inline")
+ logger.debug " diff path:'#{path}',identifier_from #{identifier_from}, identifier_to #{identifier_to}"
+ path_with_project="#{url}#{with_leading_slash(path)}"
+ cmd = "#{CVS_BIN} -d #{root_url} rdiff -u -r#{identifier_to} -r#{identifier_from} #{path_with_project}"
+ diff = []
+ shellout(cmd) do |io|
+ io.each_line do |line|
+ diff << line
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ DiffTableList.new diff, type
+ end
+
+ def cat(path, identifier=nil)
+ identifier = (identifier) ? identifier : "HEAD"
+ logger.debug " cat path:'#{path}',identifier #{identifier}"
+ path_with_project="#{url}#{with_leading_slash(path)}"
+ cmd = "#{CVS_BIN} -d #{root_url} co -r#{identifier} -p #{path_with_project}"
+ cat = nil
+ shellout(cmd) do |io|
+ cat = io.read
+ end
+ return nil if $? && $?.exitstatus != 0
+ cat
+ end
+
+ def annotate(path, identifier=nil)
+ identifier = (identifier) ? identifier : "HEAD"
+ logger.debug " annotate path:'#{path}',identifier #{identifier}"
+ path_with_project="#{url}#{with_leading_slash(path)}"
+ cmd = "#{CVS_BIN} -d #{root_url} rannotate -r#{identifier} #{path_with_project}"
+ blame = Annotate.new
+ shellout(cmd) do |io|
+ io.each_line do |line|
+ next unless line =~ %r{^([\d\.]+)\s+\(([^\)]+)\s+[^\)]+\):\s(.*)$}
+ blame.add_line($3.rstrip, Revision.new(:revision => $1, :author => $2.strip))
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ blame
+ end
+
+ private
+
+ # convert a date/time into the CVS-format
+ def time_to_cvstime(time)
+ return nil if time.nil?
+ unless time.kind_of? Time
+ time = Time.parse(time)
+ end
+ return time.strftime("%Y-%m-%d %H:%M:%S")
+ end
+
+ def normalize_cvs_path(path)
+ normalize_path(path.gsub(/Attic\//,''))
+ end
+
+ def normalize_path(path)
+ path.sub(/^(\/)*(.*)/,'\2').sub(/(.*)(,v)+/,'\1')
+ end
+ end
+
+ class CvsRevisionHelper
+ attr_accessor :complete_rev, :revision, :base, :branchid
+
+ def initialize(complete_rev)
+ @complete_rev = complete_rev
+ parseRevision()
+ end
+
+ def branchPoint
+ return @base
+ end
+
+ def branchVersion
+ if isBranchRevision
+ return @base+"."+@branchid
+ end
+ return @base
+ end
+
+ def isBranchRevision
+ !@branchid.nil?
+ end
+
+ def prevRev
+ unless @revision==0
+ return buildRevision(@revision-1)
+ end
+ return buildRevision(@revision)
+ end
+
+ def is_in_branch_with_symbol(branch_symbol)
+ bpieces=branch_symbol.split(".")
+ branch_start="#{bpieces[0..-3].join(".")}.#{bpieces[-1]}"
+ return (branchVersion==branch_start)
+ end
+
+ private
+ def buildRevision(rev)
+ if rev== 0
+ @base
+ elsif @branchid.nil?
+ @base+"."+rev.to_s
+ else
+ @base+"."+@branchid+"."+rev.to_s
+ end
+ end
+
+ # Interpretiert die cvs revisionsnummern wie z.b. 1.14 oder 1.3.0.15
+ def parseRevision()
+ pieces=@complete_rev.split(".")
+ @revision=pieces.last.to_i
+ baseSize=1
+ baseSize+=(pieces.size/2)
+ @base=pieces[0..-baseSize].join(".")
+ if baseSize > 2
+ @branchid=pieces[-2]
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/lib/redmine/scm/adapters/darcs_adapter.rb b/rest_sys/lib/redmine/scm/adapters/darcs_adapter.rb
new file mode 100644
index 000000000..2955b26dc
--- /dev/null
+++ b/rest_sys/lib/redmine/scm/adapters/darcs_adapter.rb
@@ -0,0 +1,157 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'redmine/scm/adapters/abstract_adapter'
+require 'rexml/document'
+
+module Redmine
+ module Scm
+ module Adapters
+ class DarcsAdapter < AbstractAdapter
+ # Darcs executable name
+ DARCS_BIN = "darcs"
+
+ def initialize(url, root_url=nil, login=nil, password=nil)
+ @url = url
+ @root_url = url
+ end
+
+ def supports_cat?
+ false
+ end
+
+ # Get info about the svn repository
+ def info
+ rev = revisions(nil,nil,nil,{:limit => 1})
+ rev ? Info.new({:root_url => @url, :lastrev => rev.last}) : nil
+ end
+
+ # Returns the entry identified by path and revision identifier
+ # or nil if entry doesn't exist in the repository
+ def entry(path=nil, identifier=nil)
+ e = entries(path, identifier)
+ e ? e.first : nil
+ end
+
+ # Returns an Entries collection
+ # or nil if the given path doesn't exist in the repository
+ def entries(path=nil, identifier=nil)
+ path_prefix = (path.blank? ? '' : "#{path}/")
+ path = '.' if path.blank?
+ entries = Entries.new
+ cmd = "#{DARCS_BIN} annotate --repodir #{@url} --xml-output #{path}"
+ shellout(cmd) do |io|
+ begin
+ doc = REXML::Document.new(io)
+ if doc.root.name == 'directory'
+ doc.elements.each('directory/*') do |element|
+ next unless ['file', 'directory'].include? element.name
+ entries << entry_from_xml(element, path_prefix)
+ end
+ elsif doc.root.name == 'file'
+ entries << entry_from_xml(doc.root, path_prefix)
+ end
+ rescue
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ entries.sort_by_name
+ end
+
+ def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
+ path = '.' if path.blank?
+ revisions = Revisions.new
+ cmd = "#{DARCS_BIN} changes --repodir #{@url} --xml-output"
+ cmd << " --from-match \"hash #{identifier_from}\"" if identifier_from
+ cmd << " --last #{options[:limit].to_i}" if options[:limit]
+ shellout(cmd) do |io|
+ begin
+ doc = REXML::Document.new(io)
+ doc.elements.each("changelog/patch") do |patch|
+ message = patch.elements['name'].text
+ message << "\n" + patch.elements['comment'].text.gsub(/\*\*\*END OF DESCRIPTION\*\*\*.*\z/m, '') if patch.elements['comment']
+ revisions << Revision.new({:identifier => nil,
+ :author => patch.attributes['author'],
+ :scmid => patch.attributes['hash'],
+ :time => Time.parse(patch.attributes['local_date']),
+ :message => message,
+ :paths => (options[:with_path] ? get_paths_for_patch(patch.attributes['hash']) : nil)
+ })
+ end
+ rescue
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ revisions
+ end
+
+ def diff(path, identifier_from, identifier_to=nil, type="inline")
+ path = '*' if path.blank?
+ cmd = "#{DARCS_BIN} diff --repodir #{@url}"
+ cmd << " --to-match \"hash #{identifier_from}\""
+ cmd << " --from-match \"hash #{identifier_to}\"" if identifier_to
+ cmd << " -u #{path}"
+ diff = []
+ shellout(cmd) do |io|
+ io.each_line do |line|
+ diff << line
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ DiffTableList.new diff, type
+ end
+
+ private
+
+ def entry_from_xml(element, path_prefix)
+ Entry.new({:name => element.attributes['name'],
+ :path => path_prefix + element.attributes['name'],
+ :kind => element.name == 'file' ? 'file' : 'dir',
+ :size => nil,
+ :lastrev => Revision.new({
+ :identifier => nil,
+ :scmid => element.elements['modified'].elements['patch'].attributes['hash']
+ })
+ })
+ end
+
+ # Retrieve changed paths for a single patch
+ def get_paths_for_patch(hash)
+ cmd = "#{DARCS_BIN} annotate --repodir #{@url} --summary --xml-output"
+ cmd << " --match \"hash #{hash}\" "
+ paths = []
+ shellout(cmd) do |io|
+ begin
+ # Darcs xml output has multiple root elements in this case (tested with darcs 1.0.7)
+ # A root element is added so that REXML doesn't raise an error
+ doc = REXML::Document.new("" + io.read + " ")
+ doc.elements.each('fake_root/summary/*') do |modif|
+ paths << {:action => modif.name[0,1].upcase,
+ :path => "/" + modif.text.chomp.gsub(/^\s*/, '')
+ }
+ end
+ rescue
+ end
+ end
+ paths
+ rescue CommandFailed
+ paths
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/lib/redmine/scm/adapters/mercurial_adapter.rb b/rest_sys/lib/redmine/scm/adapters/mercurial_adapter.rb
new file mode 100644
index 000000000..1b9cab47c
--- /dev/null
+++ b/rest_sys/lib/redmine/scm/adapters/mercurial_adapter.rb
@@ -0,0 +1,171 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'redmine/scm/adapters/abstract_adapter'
+
+module Redmine
+ module Scm
+ module Adapters
+ class MercurialAdapter < AbstractAdapter
+
+ # Mercurial executable name
+ HG_BIN = "hg"
+
+ def info
+ cmd = "#{HG_BIN} -R #{target('')} root"
+ root_url = nil
+ shellout(cmd) do |io|
+ root_url = io.gets
+ end
+ return nil if $? && $?.exitstatus != 0
+ info = Info.new({:root_url => root_url.chomp,
+ :lastrev => revisions(nil,nil,nil,{:limit => 1}).last
+ })
+ info
+ rescue CommandFailed
+ return nil
+ end
+
+ def entries(path=nil, identifier=nil)
+ path ||= ''
+ entries = Entries.new
+ cmd = "#{HG_BIN} -R #{target('')} --cwd #{target(path)} locate -X */*/*"
+ cmd << " -r #{identifier.to_i}" if identifier
+ cmd << " * */*"
+ shellout(cmd) do |io|
+ io.each_line do |line|
+ e = line.chomp.split('\\')
+ entries << Entry.new({:name => e.first,
+ :path => (path.empty? ? e.first : "#{path}/#{e.first}"),
+ :kind => (e.size > 1 ? 'dir' : 'file'),
+ :lastrev => Revision.new
+ }) unless entries.detect{|entry| entry.name == e.first}
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ entries.sort_by_name
+ end
+
+ def entry(path=nil, identifier=nil)
+ path ||= ''
+ search_path = path.split('/')[0..-2].join('/')
+ entry_name = path.split('/').last
+ e = entries(search_path, identifier)
+ e ? e.detect{|entry| entry.name == entry_name} : nil
+ end
+
+ def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
+ revisions = Revisions.new
+ cmd = "#{HG_BIN} -v -R #{target('')} log"
+ cmd << " -r #{identifier_from.to_i}:" if identifier_from
+ cmd << " --limit #{options[:limit].to_i}" if options[:limit]
+ shellout(cmd) do |io|
+ changeset = {}
+ parsing_descr = false
+ line_feeds = 0
+
+ io.each_line do |line|
+ if line =~ /^(\w+):\s*(.*)$/
+ key = $1
+ value = $2
+ if parsing_descr && line_feeds > 1
+ parsing_descr = false
+ revisions << Revision.new({:identifier => changeset[:changeset].split(':').first.to_i,
+ :scmid => changeset[:changeset].split(':').last,
+ :author => changeset[:user],
+ :time => Time.parse(changeset[:date]),
+ :message => changeset[:description],
+ :paths => changeset[:files].to_s.split.collect{|path| {:action => 'X', :path => "/#{path}"}}
+ })
+ changeset = {}
+ end
+ if !parsing_descr
+ changeset.store key.to_sym, value
+ if $1 == "description"
+ parsing_descr = true
+ line_feeds = 0
+ next
+ end
+ end
+ end
+ if parsing_descr
+ changeset[:description] << line
+ line_feeds += 1 if line.chomp.empty?
+ end
+ end
+ revisions << Revision.new({:identifier => changeset[:changeset].split(':').first.to_i,
+ :scmid => changeset[:changeset].split(':').last,
+ :author => changeset[:user],
+ :time => Time.parse(changeset[:date]),
+ :message => changeset[:description],
+ :paths => changeset[:files].split.collect{|path| {:action => 'X', :path => "/#{path}"}}
+ })
+ end
+ return nil if $? && $?.exitstatus != 0
+ revisions
+ end
+
+ def diff(path, identifier_from, identifier_to=nil, type="inline")
+ path ||= ''
+ if identifier_to
+ identifier_to = identifier_to.to_i
+ else
+ identifier_to = identifier_from.to_i - 1
+ end
+ cmd = "#{HG_BIN} -R #{target('')} diff -r #{identifier_to} -r #{identifier_from} --nodates"
+ cmd << " -I #{target(path)}" unless path.empty?
+ diff = []
+ shellout(cmd) do |io|
+ io.each_line do |line|
+ diff << line
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ DiffTableList.new diff, type
+ end
+
+ def cat(path, identifier=nil)
+ cmd = "#{HG_BIN} -R #{target('')} cat #{target(path)}"
+ cat = nil
+ shellout(cmd) do |io|
+ io.binmode
+ cat = io.read
+ end
+ return nil if $? && $?.exitstatus != 0
+ cat
+ end
+
+ def annotate(path, identifier=nil)
+ path ||= ''
+ cmd = "#{HG_BIN} -R #{target('')}"
+ cmd << " annotate -n -u"
+ cmd << " -r #{identifier.to_i}" if identifier
+ cmd << " #{target(path)}"
+ blame = Annotate.new
+ shellout(cmd) do |io|
+ io.each_line do |line|
+ next unless line =~ %r{^([^:]+)\s(\d+):(.*)$}
+ blame.add_line($3.rstrip, Revision.new(:identifier => $2.to_i, :author => $1.strip))
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ blame
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/lib/redmine/scm/adapters/subversion_adapter.rb b/rest_sys/lib/redmine/scm/adapters/subversion_adapter.rb
new file mode 100644
index 000000000..f698f4a62
--- /dev/null
+++ b/rest_sys/lib/redmine/scm/adapters/subversion_adapter.rb
@@ -0,0 +1,194 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'redmine/scm/adapters/abstract_adapter'
+require 'rexml/document'
+
+module Redmine
+ module Scm
+ module Adapters
+ class SubversionAdapter < AbstractAdapter
+
+ # SVN executable name
+ SVN_BIN = "svn"
+
+ # Get info about the svn repository
+ def info
+ cmd = "#{SVN_BIN} info --xml #{target('')}"
+ cmd << credentials_string
+ info = nil
+ shellout(cmd) do |io|
+ begin
+ doc = REXML::Document.new(io)
+ #root_url = doc.elements["info/entry/repository/root"].text
+ info = Info.new({:root_url => doc.elements["info/entry/repository/root"].text,
+ :lastrev => Revision.new({
+ :identifier => doc.elements["info/entry/commit"].attributes['revision'],
+ :time => Time.parse(doc.elements["info/entry/commit/date"].text).localtime,
+ :author => (doc.elements["info/entry/commit/author"] ? doc.elements["info/entry/commit/author"].text : "")
+ })
+ })
+ rescue
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ info
+ rescue CommandFailed
+ return nil
+ end
+
+ # Returns the entry identified by path and revision identifier
+ # or nil if entry doesn't exist in the repository
+ def entry(path=nil, identifier=nil)
+ e = entries(path, identifier)
+ e ? e.first : nil
+ end
+
+ # Returns an Entries collection
+ # or nil if the given path doesn't exist in the repository
+ def entries(path=nil, identifier=nil)
+ path ||= ''
+ identifier = 'HEAD' unless identifier and identifier > 0
+ entries = Entries.new
+ cmd = "#{SVN_BIN} list --xml #{target(path)}@#{identifier}"
+ cmd << credentials_string
+ cmd << " 2>&1"
+ shellout(cmd) do |io|
+ output = io.read
+ begin
+ doc = REXML::Document.new(output)
+ doc.elements.each("lists/list/entry") do |entry|
+ entries << Entry.new({:name => entry.elements['name'].text,
+ :path => ((path.empty? ? "" : "#{path}/") + entry.elements['name'].text),
+ :kind => entry.attributes['kind'],
+ :size => (entry.elements['size'] and entry.elements['size'].text).to_i,
+ :lastrev => Revision.new({
+ :identifier => entry.elements['commit'].attributes['revision'],
+ :time => Time.parse(entry.elements['commit'].elements['date'].text).localtime,
+ :author => (entry.elements['commit'].elements['author'] ? entry.elements['commit'].elements['author'].text : "")
+ })
+ })
+ end
+ rescue Exception => e
+ logger.error("Error parsing svn output: #{e.message}")
+ logger.error("Output was:\n #{output}")
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ logger.debug("Found #{entries.size} entries in the repository for #{target(path)}") if logger && logger.debug?
+ entries.sort_by_name
+ end
+
+ def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
+ path ||= ''
+ identifier_from = 'HEAD' unless identifier_from and identifier_from.to_i > 0
+ identifier_to = 1 unless identifier_to and identifier_to.to_i > 0
+ revisions = Revisions.new
+ cmd = "#{SVN_BIN} log --xml -r #{identifier_from}:#{identifier_to}"
+ cmd << credentials_string
+ cmd << " --verbose " if options[:with_paths]
+ cmd << target(path)
+ shellout(cmd) do |io|
+ begin
+ doc = REXML::Document.new(io)
+ doc.elements.each("log/logentry") do |logentry|
+ paths = []
+ logentry.elements.each("paths/path") do |path|
+ paths << {:action => path.attributes['action'],
+ :path => path.text,
+ :from_path => path.attributes['copyfrom-path'],
+ :from_revision => path.attributes['copyfrom-rev']
+ }
+ end
+ paths.sort! { |x,y| x[:path] <=> y[:path] }
+
+ revisions << Revision.new({:identifier => logentry.attributes['revision'],
+ :author => (logentry.elements['author'] ? logentry.elements['author'].text : ""),
+ :time => Time.parse(logentry.elements['date'].text).localtime,
+ :message => logentry.elements['msg'].text,
+ :paths => paths
+ })
+ end
+ rescue
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ revisions
+ end
+
+ def diff(path, identifier_from, identifier_to=nil, type="inline")
+ path ||= ''
+ if identifier_to and identifier_to.to_i > 0
+ identifier_to = identifier_to.to_i
+ else
+ identifier_to = identifier_from.to_i - 1
+ end
+ cmd = "#{SVN_BIN} diff -r "
+ cmd << "#{identifier_to}:"
+ cmd << "#{identifier_from}"
+ cmd << "#{target(path)}@#{identifier_from}"
+ cmd << credentials_string
+ diff = []
+ shellout(cmd) do |io|
+ io.each_line do |line|
+ diff << line
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ DiffTableList.new diff, type
+ end
+
+ def cat(path, identifier=nil)
+ identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
+ cmd = "#{SVN_BIN} cat #{target(path)}@#{identifier}"
+ cmd << credentials_string
+ cat = nil
+ shellout(cmd) do |io|
+ io.binmode
+ cat = io.read
+ end
+ return nil if $? && $?.exitstatus != 0
+ cat
+ end
+
+ def annotate(path, identifier=nil)
+ identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD"
+ cmd = "#{SVN_BIN} blame #{target(path)}@#{identifier}"
+ cmd << credentials_string
+ blame = Annotate.new
+ shellout(cmd) do |io|
+ io.each_line do |line|
+ next unless line =~ %r{^\s*(\d+)\s*(\S+)\s(.*)$}
+ blame.add_line($3.rstrip, Revision.new(:identifier => $1.to_i, :author => $2.strip))
+ end
+ end
+ return nil if $? && $?.exitstatus != 0
+ blame
+ end
+
+ private
+
+ def credentials_string
+ str = ''
+ str << " --username #{shell_quote(@login)}" unless @login.blank?
+ str << " --password #{shell_quote(@password)}" unless @login.blank? || @password.blank?
+ str
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/lib/redmine/themes.rb b/rest_sys/lib/redmine/themes.rb
new file mode 100644
index 000000000..a7cf940b8
--- /dev/null
+++ b/rest_sys/lib/redmine/themes.rb
@@ -0,0 +1,72 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module Redmine
+ module Themes
+
+ # Return an array of installed themes
+ def self.themes
+ @@installed_themes ||= scan_themes
+ end
+
+ # Rescan themes directory
+ def self.rescan
+ @@installed_themes = scan_themes
+ end
+
+ # Return theme for given id, or nil if it's not found
+ def self.theme(id)
+ themes.find {|t| t.id == id}
+ end
+
+ # Class used to represent a theme
+ class Theme
+ attr_reader :name, :dir, :stylesheets
+
+ def initialize(path)
+ @dir = File.basename(path)
+ @name = @dir.humanize
+ @stylesheets = Dir.glob("#{path}/stylesheets/*.css").collect {|f| File.basename(f).gsub(/\.css$/, '')}
+ end
+
+ # Directory name used as the theme id
+ def id; dir end
+
+ def <=>(theme)
+ name <=> theme.name
+ end
+ end
+
+ private
+
+ def self.scan_themes
+ dirs = Dir.glob("#{RAILS_ROOT}/public/themes/*").select do |f|
+ # A theme should at least override application.css
+ File.directory?(f) && File.exist?("#{f}/stylesheets/application.css")
+ end
+ dirs.collect {|dir| Theme.new(dir)}.sort
+ end
+ end
+end
+
+module ApplicationHelper
+ def stylesheet_path(source)
+ @current_theme ||= Redmine::Themes.theme(Setting.ui_theme)
+ super((@current_theme && @current_theme.stylesheets.include?(source)) ?
+ "/themes/#{@current_theme.dir}/stylesheets/#{source}" : source)
+ end
+end
diff --git a/rest_sys/lib/redmine/version.rb b/rest_sys/lib/redmine/version.rb
new file mode 100644
index 000000000..b109d098e
--- /dev/null
+++ b/rest_sys/lib/redmine/version.rb
@@ -0,0 +1,35 @@
+require 'rexml/document'
+
+module Redmine
+ module VERSION #:nodoc:
+ MAJOR = 0
+ MINOR = 6
+ TINY = 2
+
+ def self.revision
+ revision = nil
+ entries_path = "#{RAILS_ROOT}/.svn/entries"
+ if File.readable?(entries_path)
+ begin
+ f = File.open(entries_path, 'r')
+ entries = f.read
+ f.close
+ if entries.match(%r{^\d+})
+ revision = $1.to_i if entries.match(%r{^\d+\s+dir\s+(\d+)\s})
+ else
+ xml = REXML::Document.new(entries)
+ revision = xml.elements['wc-entries'].elements[1].attributes['revision'].to_i
+ end
+ rescue
+ # Could not find the current revision
+ end
+ end
+ revision
+ end
+
+ REVISION = self.revision
+ STRING = [MAJOR, MINOR, TINY, REVISION].compact.join('.')
+
+ def self.to_s; STRING end
+ end
+end
diff --git a/rest_sys/lib/redmine/wiki_formatting.rb b/rest_sys/lib/redmine/wiki_formatting.rb
new file mode 100644
index 000000000..4aebe9a96
--- /dev/null
+++ b/rest_sys/lib/redmine/wiki_formatting.rb
@@ -0,0 +1,160 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'redcloth'
+require 'coderay'
+
+module Redmine
+ module WikiFormatting
+
+ private
+
+ class TextileFormatter < RedCloth
+
+ RULES = [:inline_auto_link, :inline_auto_mailto, :textile, :inline_toc, :inline_macros]
+
+ def initialize(*args)
+ super
+ self.hard_breaks=true
+ self.no_span_caps=true
+ end
+
+ def to_html(*rules, &block)
+ @toc = []
+ @macros_runner = block
+ super(*RULES).to_s
+ end
+
+ private
+
+ # Patch for RedCloth. Fixed in RedCloth r128 but _why hasn't released it yet.
+ # http://code.whytheluckystiff.net/redcloth/changeset/128
+ def hard_break( text )
+ text.gsub!( /(.)\n(?!\n|\Z| *([#*=]+(\s|$)|[{|]))/, "\\1 " ) if hard_breaks
+ end
+
+ # Patch to add code highlighting support to RedCloth
+ def smooth_offtags( text )
+ unless @pre_list.empty?
+ ## replace content
+ text.gsub!(//) do
+ content = @pre_list[$1.to_i]
+ if content.match(/\s?(.+)/m)
+ content = "" +
+ CodeRay.scan($2, $1).html(:escape => false, :line_numbers => :inline)
+ end
+ content
+ end
+ end
+ end
+
+ # Patch to add 'table of content' support to RedCloth
+ def textile_p_withtoc(tag, atts, cite, content)
+ if tag =~ /^h(\d)$/
+ @toc << [$1.to_i, content]
+ end
+ content = " " + content
+ textile_p(tag, atts, cite, content)
+ end
+
+ alias :textile_h1 :textile_p_withtoc
+ alias :textile_h2 :textile_p_withtoc
+ alias :textile_h3 :textile_p_withtoc
+
+ def inline_toc(text)
+ text.gsub!(/\{\{([<>]?)toc\}\}<\/p>/i) do
+ div_class = 'toc'
+ div_class << ' right' if $1 == '>'
+ div_class << ' left' if $1 == '<'
+ out = "
"
+ @toc.each_with_index do |heading, index|
+ # remove wiki links from the item
+ toc_item = heading.last.gsub(/(\[\[|\]\])/, '')
+ out << "
#{toc_item} "
+ end
+ out << '
'
+ out
+ end
+ end
+
+ MACROS_RE = /
+ \{\{ # opening tag
+ ([\w]+) # macro name
+ (\(([^\}]*)\))? # optional arguments
+ \}\} # closing tag
+ /x unless const_defined?(:MACROS_RE)
+
+ def inline_macros(text)
+ text.gsub!(MACROS_RE) do
+ all, macro = $&, $1.downcase
+ args = ($3 || '').split(',').each(&:strip)
+ begin
+ @macros_runner.call(macro, args)
+ rescue => e
+ "Error executing the #{macro} macro (#{e})
"
+ end || all
+ end
+ end
+
+ AUTO_LINK_RE = %r{
+ ( # leading text
+ <\w+.*?>| # leading HTML tag, or
+ [^=<>!:'"/]| # leading punctuation, or
+ ^ # beginning of line
+ )
+ (
+ (?:https?://)| # protocol spec, or
+ (?:www\.) # www.*
+ )
+ (
+ (\S+?) # url
+ (\/)? # slash
+ )
+ ([^\w\=\/;]*?) # post
+ (?=<|\s|$)
+ }x unless const_defined?(:AUTO_LINK_RE)
+
+ # Turns all urls into clickable links (code from Rails).
+ def inline_auto_link(text)
+ text.gsub!(AUTO_LINK_RE) do
+ all, leading, proto, url, post = $&, $1, $2, $3, $6
+ if leading =~ /=]?/
+ # don't replace URL's that are already linked
+ # and URL's prefixed with ! !> !< != (textile images)
+ all
+ else
+ %(#{leading} #{proto + url} #{post})
+ end
+ end
+ end
+
+ # Turns all email addresses into clickable links (code from Rails).
+ def inline_auto_mailto(text)
+ text.gsub!(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do
+ text = $1
+ %{#{text} }
+ end
+ end
+ end
+
+ public
+
+ def self.to_html(text, options = {}, &block)
+ TextileFormatter.new(text).to_html(&block)
+ end
+ end
+end
diff --git a/rest_sys/lib/redmine/wiki_formatting/macros.rb b/rest_sys/lib/redmine/wiki_formatting/macros.rb
new file mode 100644
index 000000000..f9920afdb
--- /dev/null
+++ b/rest_sys/lib/redmine/wiki_formatting/macros.rb
@@ -0,0 +1,81 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module Redmine
+ module WikiFormatting
+ module Macros
+ module Definitions
+ def exec_macro(name, obj, args)
+ method_name = "macro_#{name}"
+ send(method_name, obj, args) if respond_to?(method_name)
+ end
+ end
+
+ @@available_macros = {}
+
+ class << self
+ # Called with a block to define additional macros.
+ # Macro blocks accept 2 arguments:
+ # * obj: the object that is rendered
+ # * args: macro arguments
+ #
+ # Plugins can use this method to define new macros:
+ #
+ # Redmine::WikiFormatting::Macros.register do
+ # desc "This is my macro"
+ # macro :my_macro do |obj, args|
+ # "My macro output"
+ # end
+ # end
+ def register(&block)
+ class_eval(&block) if block_given?
+ end
+
+ private
+ # Defines a new macro with the given name and block.
+ def macro(name, &block)
+ name = name.to_sym if name.is_a?(String)
+ @@available_macros[name] = @@desc || ''
+ @@desc = nil
+ raise "Can not create a macro without a block!" unless block_given?
+ Definitions.send :define_method, "macro_#{name}".downcase, &block
+ end
+
+ # Sets description for the next macro to be defined
+ def desc(txt)
+ @@desc = txt
+ end
+ end
+
+ # Builtin macros
+ desc "Example macro."
+ macro :hello_world do |obj, args|
+ "Hello world! Object: #{obj.class.name}, " + (args.empty? ? "Called with no argument." : "Arguments: #{args.join(', ')}")
+ end
+
+ desc "Displays a list of all available macros, including description if available."
+ macro :macro_list do
+ out = ''
+ @@available_macros.keys.collect(&:to_s).sort.each do |macro|
+ out << content_tag('dt', content_tag('code', macro))
+ out << content_tag('dd', simple_format(@@available_macros[macro.to_sym]))
+ end
+ content_tag('dl', out)
+ end
+ end
+ end
+end
diff --git a/rest_sys/lib/tasks/deprecated.rake b/rest_sys/lib/tasks/deprecated.rake
new file mode 100644
index 000000000..dca43ddc7
--- /dev/null
+++ b/rest_sys/lib/tasks/deprecated.rake
@@ -0,0 +1,9 @@
+def deprecated_task(name, new_name)
+ task name=>new_name do
+ $stderr.puts "\nNote: The rake task #{name} has been deprecated, please use the replacement version #{new_name}"
+ end
+end
+
+deprecated_task :load_default_data, "redmine:load_default_data"
+deprecated_task :migrate_from_mantis, "redmine:migrate_from_mantis"
+deprecated_task :migrate_from_trac, "redmine:migrate_from_trac"
diff --git a/rest_sys/lib/tasks/extract_fixtures.rake b/rest_sys/lib/tasks/extract_fixtures.rake
new file mode 100644
index 000000000..49834e5ab
--- /dev/null
+++ b/rest_sys/lib/tasks/extract_fixtures.rake
@@ -0,0 +1,24 @@
+desc 'Create YAML test fixtures from data in an existing database.
+Defaults to development database. Set RAILS_ENV to override.'
+
+task :extract_fixtures => :environment do
+ sql = "SELECT * FROM %s"
+ skip_tables = ["schema_info"]
+ ActiveRecord::Base.establish_connection
+ (ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
+ i = "000"
+ File.open("#{RAILS_ROOT}/#{table_name}.yml", 'w' ) do |file|
+ data = ActiveRecord::Base.connection.select_all(sql % table_name)
+ file.write data.inject({}) { |hash, record|
+
+ # cast extracted values
+ ActiveRecord::Base.connection.columns(table_name).each { |col|
+ record[col.name] = col.type_cast(record[col.name]) if record[col.name]
+ }
+
+ hash["#{table_name}_#{i.succ!}"] = record
+ hash
+ }.to_yaml
+ end
+ end
+end
\ No newline at end of file
diff --git a/rest_sys/lib/tasks/load_default_data.rake b/rest_sys/lib/tasks/load_default_data.rake
new file mode 100644
index 000000000..8e89d4ecd
--- /dev/null
+++ b/rest_sys/lib/tasks/load_default_data.rake
@@ -0,0 +1,168 @@
+desc 'Load Redmine default configuration data'
+
+namespace :redmine do
+task :load_default_data => :environment do
+ include GLoc
+ set_language_if_valid('en')
+ puts
+
+ while true
+ print "Select language: "
+ print GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }.join(", ")
+ print " [#{GLoc.current_language}] "
+ lang = STDIN.gets.chomp!
+ break if lang.empty?
+ break if set_language_if_valid(lang)
+ puts "Unknown language!"
+ end
+
+ puts "===================================="
+
+begin
+ # check that no data already exists
+ if Role.find(:first, :conditions => {:builtin => 0})
+ raise "Some roles are already defined."
+ end
+ if Tracker.find(:first)
+ raise "Some trackers are already defined."
+ end
+ if IssueStatus.find(:first)
+ raise "Some statuses are already defined."
+ end
+ if Enumeration.find(:first)
+ raise "Some enumerations are already defined."
+ end
+
+ puts "Loading default configuration data for language: #{current_language}"
+
+ # roles
+ manager = Role.create :name => l(:default_role_manager),
+ :position => 1
+ manager.permissions = manager.setable_permissions.collect {|p| p.name}
+ manager.save
+
+ developper = Role.create :name => l(:default_role_developper),
+ :position => 2,
+ :permissions => [:manage_versions,
+ :manage_categories,
+ :add_issues,
+ :edit_issues,
+ :manage_issue_relations,
+ :add_issue_notes,
+ :change_issue_status,
+ :save_queries,
+ :view_gantt,
+ :view_calendar,
+ :log_time,
+ :view_time_entries,
+ :comment_news,
+ :view_documents,
+ :view_wiki_pages,
+ :edit_wiki_pages,
+ :delete_wiki_pages,
+ :add_messages,
+ :view_files,
+ :manage_files,
+ :browse_repository,
+ :view_changesets]
+
+ reporter = Role.create :name => l(:default_role_reporter),
+ :position => 3,
+ :permissions => [:add_issues,
+ :add_issue_notes,
+ :change_issue_status,
+ :save_queries,
+ :view_gantt,
+ :view_calendar,
+ :log_time,
+ :view_time_entries,
+ :comment_news,
+ :view_documents,
+ :view_wiki_pages,
+ :add_messages,
+ :view_files,
+ :browse_repository,
+ :view_changesets]
+
+ Role.non_member.update_attribute :permissions, [:add_issues,
+ :add_issue_notes,
+ :change_issue_status,
+ :save_queries,
+ :view_gantt,
+ :view_calendar,
+ :view_time_entries,
+ :comment_news,
+ :view_documents,
+ :view_wiki_pages,
+ :add_messages,
+ :view_files,
+ :browse_repository,
+ :view_changesets]
+
+ Role.anonymous.update_attribute :permissions, [:view_gantt,
+ :view_calendar,
+ :view_time_entries,
+ :view_documents,
+ :view_wiki_pages,
+ :view_files,
+ :browse_repository,
+ :view_changesets]
+
+ # trackers
+ Tracker.create(:name => l(:default_tracker_bug), :is_in_chlog => true, :is_in_roadmap => false, :position => 1)
+ Tracker.create(:name => l(:default_tracker_feature), :is_in_chlog => true, :is_in_roadmap => true, :position => 2)
+ Tracker.create(:name => l(:default_tracker_support), :is_in_chlog => false, :is_in_roadmap => false, :position => 3)
+
+ # issue statuses
+ new = IssueStatus.create(:name => l(:default_issue_status_new), :is_closed => false, :is_default => true, :position => 1)
+ assigned = IssueStatus.create(:name => l(:default_issue_status_assigned), :is_closed => false, :is_default => false, :position => 2)
+ resolved = IssueStatus.create(:name => l(:default_issue_status_resolved), :is_closed => false, :is_default => false, :position => 3)
+ feedback = IssueStatus.create(:name => l(:default_issue_status_feedback), :is_closed => false, :is_default => false, :position => 4)
+ closed = IssueStatus.create(:name => l(:default_issue_status_closed), :is_closed => true, :is_default => false, :position => 5)
+ rejected = IssueStatus.create(:name => l(:default_issue_status_rejected), :is_closed => true, :is_default => false, :position => 6)
+
+ # workflow
+ Tracker.find(:all).each { |t|
+ IssueStatus.find(:all).each { |os|
+ IssueStatus.find(:all).each { |ns|
+ Workflow.create(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
+ }
+ }
+ }
+
+ Tracker.find(:all).each { |t|
+ [new, assigned, resolved, feedback].each { |os|
+ [assigned, resolved, feedback, closed].each { |ns|
+ Workflow.create(:tracker_id => t.id, :role_id => developper.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
+ }
+ }
+ }
+
+ Tracker.find(:all).each { |t|
+ [new, assigned, resolved, feedback].each { |os|
+ [closed].each { |ns|
+ Workflow.create(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
+ }
+ }
+ Workflow.create(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => resolved.id, :new_status_id => feedback.id)
+ }
+
+ # enumerations
+ Enumeration.create(:opt => "DCAT", :name => l(:default_doc_category_user), :position => 1)
+ Enumeration.create(:opt => "DCAT", :name => l(:default_doc_category_tech), :position => 2)
+
+ Enumeration.create(:opt => "IPRI", :name => l(:default_priority_low), :position => 1)
+ Enumeration.create(:opt => "IPRI", :name => l(:default_priority_normal), :position => 2, :is_default => true)
+ Enumeration.create(:opt => "IPRI", :name => l(:default_priority_high), :position => 3)
+ Enumeration.create(:opt => "IPRI", :name => l(:default_priority_urgent), :position => 4)
+ Enumeration.create(:opt => "IPRI", :name => l(:default_priority_immediate), :position => 5)
+
+ Enumeration.create(:opt => "ACTI", :name => l(:default_activity_design), :position => 1)
+ Enumeration.create(:opt => "ACTI", :name => l(:default_activity_development), :position => 2)
+
+rescue => error
+ puts "Error: " + error
+ puts "Default configuration data can't be loaded."
+end
+end
+end
diff --git a/rest_sys/lib/tasks/migrate_from_mantis.rake b/rest_sys/lib/tasks/migrate_from_mantis.rake
new file mode 100644
index 000000000..6d8d55e7c
--- /dev/null
+++ b/rest_sys/lib/tasks/migrate_from_mantis.rake
@@ -0,0 +1,491 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+desc 'Mantis migration script'
+
+require 'active_record'
+require 'iconv'
+require 'pp'
+
+namespace :redmine do
+task :migrate_from_mantis => :environment do
+
+ module MantisMigrate
+
+ DEFAULT_STATUS = IssueStatus.default
+ assigned_status = IssueStatus.find_by_position(2)
+ resolved_status = IssueStatus.find_by_position(3)
+ feedback_status = IssueStatus.find_by_position(4)
+ closed_status = IssueStatus.find :first, :conditions => { :is_closed => true }
+ STATUS_MAPPING = {10 => DEFAULT_STATUS, # new
+ 20 => feedback_status, # feedback
+ 30 => DEFAULT_STATUS, # acknowledged
+ 40 => DEFAULT_STATUS, # confirmed
+ 50 => assigned_status, # assigned
+ 80 => resolved_status, # resolved
+ 90 => closed_status # closed
+ }
+
+ priorities = Enumeration.get_values('IPRI')
+ DEFAULT_PRIORITY = priorities[2]
+ PRIORITY_MAPPING = {10 => priorities[1], # none
+ 20 => priorities[1], # low
+ 30 => priorities[2], # normal
+ 40 => priorities[3], # high
+ 50 => priorities[4], # urgent
+ 60 => priorities[5] # immediate
+ }
+
+ TRACKER_BUG = Tracker.find_by_position(1)
+ TRACKER_FEATURE = Tracker.find_by_position(2)
+
+ roles = Role.find(:all, :conditions => {:builtin => 0}, :order => 'position ASC')
+ manager_role = roles[0]
+ developer_role = roles[1]
+ DEFAULT_ROLE = roles.last
+ ROLE_MAPPING = {10 => DEFAULT_ROLE, # viewer
+ 25 => DEFAULT_ROLE, # reporter
+ 40 => DEFAULT_ROLE, # updater
+ 55 => developer_role, # developer
+ 70 => manager_role, # manager
+ 90 => manager_role # administrator
+ }
+
+ CUSTOM_FIELD_TYPE_MAPPING = {0 => 'string', # String
+ 1 => 'int', # Numeric
+ 2 => 'int', # Float
+ 3 => 'list', # Enumeration
+ 4 => 'string', # Email
+ 5 => 'bool', # Checkbox
+ 6 => 'list', # List
+ 7 => 'list', # Multiselection list
+ 8 => 'date', # Date
+ }
+
+ RELATION_TYPE_MAPPING = {1 => IssueRelation::TYPE_RELATES, # related to
+ 2 => IssueRelation::TYPE_RELATES, # parent of
+ 3 => IssueRelation::TYPE_RELATES, # child of
+ 0 => IssueRelation::TYPE_DUPLICATES, # duplicate of
+ 4 => IssueRelation::TYPE_DUPLICATES # has duplicate
+ }
+
+ class MantisUser < ActiveRecord::Base
+ set_table_name :mantis_user_table
+
+ def firstname
+ realname.blank? ? username : realname.split.first[0..29]
+ end
+
+ def lastname
+ realname.blank? ? username : realname.split[1..-1].join(' ')[0..29]
+ end
+
+ def email
+ if read_attribute(:email).match(/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i)
+ read_attribute(:email)
+ else
+ "#{username}@foo.bar"
+ end
+ end
+
+ def username
+ read_attribute(:username)[0..29].gsub(/[^a-zA-Z0-9_\-@\.]/, '-')
+ end
+ end
+
+ class MantisProject < ActiveRecord::Base
+ set_table_name :mantis_project_table
+ has_many :versions, :class_name => "MantisVersion", :foreign_key => :project_id
+ has_many :categories, :class_name => "MantisCategory", :foreign_key => :project_id
+ has_many :news, :class_name => "MantisNews", :foreign_key => :project_id
+ has_many :members, :class_name => "MantisProjectUser", :foreign_key => :project_id
+
+ def name
+ read_attribute(:name)[0..29]
+ end
+
+ def description
+ read_attribute(:description).blank? ? read_attribute(:name) : read_attribute(:description)[0..254]
+ end
+
+ def identifier
+ read_attribute(:name).underscore[0..19].gsub(/[^a-z0-9\-]/, '-')
+ end
+ end
+
+ class MantisVersion < ActiveRecord::Base
+ set_table_name :mantis_project_version_table
+
+ def version
+ read_attribute(:version)[0..29]
+ end
+
+ def description
+ read_attribute(:description)[0..254]
+ end
+ end
+
+ class MantisCategory < ActiveRecord::Base
+ set_table_name :mantis_project_category_table
+ end
+
+ class MantisProjectUser < ActiveRecord::Base
+ set_table_name :mantis_project_user_list_table
+ end
+
+ class MantisBug < ActiveRecord::Base
+ set_table_name :mantis_bug_table
+ belongs_to :bug_text, :class_name => "MantisBugText", :foreign_key => :bug_text_id
+ has_many :bug_notes, :class_name => "MantisBugNote", :foreign_key => :bug_id
+ has_many :bug_files, :class_name => "MantisBugFile", :foreign_key => :bug_id
+ has_many :bug_monitors, :class_name => "MantisBugMonitor", :foreign_key => :bug_id
+ end
+
+ class MantisBugText < ActiveRecord::Base
+ set_table_name :mantis_bug_text_table
+
+ # Adds Mantis steps_to_reproduce and additional_information fields
+ # to description if any
+ def full_description
+ full_description = description
+ full_description += "\n\n*Steps to reproduce:*\n\n#{steps_to_reproduce}" unless steps_to_reproduce.blank?
+ full_description += "\n\n*Additional information:*\n\n#{additional_information}" unless additional_information.blank?
+ full_description
+ end
+ end
+
+ class MantisBugNote < ActiveRecord::Base
+ set_table_name :mantis_bugnote_table
+ belongs_to :bug, :class_name => "MantisBug", :foreign_key => :bug_id
+ belongs_to :bug_note_text, :class_name => "MantisBugNoteText", :foreign_key => :bugnote_text_id
+ end
+
+ class MantisBugNoteText < ActiveRecord::Base
+ set_table_name :mantis_bugnote_text_table
+ end
+
+ class MantisBugFile < ActiveRecord::Base
+ set_table_name :mantis_bug_file_table
+
+ def size
+ filesize
+ end
+
+ def original_filename
+ filename
+ end
+
+ def content_type
+ file_type
+ end
+
+ def read
+ content
+ end
+ end
+
+ class MantisBugRelationship < ActiveRecord::Base
+ set_table_name :mantis_bug_relationship_table
+ end
+
+ class MantisBugMonitor < ActiveRecord::Base
+ set_table_name :mantis_bug_monitor_table
+ end
+
+ class MantisNews < ActiveRecord::Base
+ set_table_name :mantis_news_table
+ end
+
+ class MantisCustomField < ActiveRecord::Base
+ set_table_name :mantis_custom_field_table
+ set_inheritance_column :none
+ has_many :values, :class_name => "MantisCustomFieldString", :foreign_key => :field_id
+ has_many :projects, :class_name => "MantisCustomFieldProject", :foreign_key => :field_id
+
+ def format
+ read_attribute :type
+ end
+
+ def name
+ read_attribute(:name)[0..29].gsub(/[^\w\s\'\-]/, '-')
+ end
+ end
+
+ class MantisCustomFieldProject < ActiveRecord::Base
+ set_table_name :mantis_custom_field_project_table
+ end
+
+ class MantisCustomFieldString < ActiveRecord::Base
+ set_table_name :mantis_custom_field_string_table
+ end
+
+
+ def self.migrate
+
+ # Users
+ print "Migrating users"
+ User.delete_all "login <> 'admin'"
+ users_map = {}
+ users_migrated = 0
+ MantisUser.find(:all).each do |user|
+ u = User.new :firstname => encode(user.firstname),
+ :lastname => encode(user.lastname),
+ :mail => user.email,
+ :last_login_on => user.last_visit
+ u.login = user.username
+ u.password = 'mantis'
+ u.status = User::STATUS_LOCKED if user.enabled != 1
+ u.admin = true if user.access_level == 90
+ next unless u.save
+ users_migrated += 1
+ users_map[user.id] = u.id
+ print '.'
+ end
+ puts
+
+ # Projects
+ print "Migrating projects"
+ Project.destroy_all
+ projects_map = {}
+ versions_map = {}
+ categories_map = {}
+ MantisProject.find(:all).each do |project|
+ p = Project.new :name => encode(project.name),
+ :description => encode(project.description)
+ p.identifier = project.identifier
+ next unless p.save
+ projects_map[project.id] = p.id
+ p.enabled_module_names = ['issue_tracking', 'news', 'wiki']
+ p.trackers << TRACKER_BUG
+ p.trackers << TRACKER_FEATURE
+ print '.'
+
+ # Project members
+ project.members.each do |member|
+ m = Member.new :user => User.find_by_id(users_map[member.user_id]),
+ :role => ROLE_MAPPING[member.access_level] || DEFAULT_ROLE
+ m.project = p
+ m.save
+ end
+
+ # Project versions
+ project.versions.each do |version|
+ v = Version.new :name => encode(version.version),
+ :description => encode(version.description),
+ :effective_date => version.date_order.to_date
+ v.project = p
+ v.save
+ versions_map[version.id] = v.id
+ end
+
+ # Project categories
+ project.categories.each do |category|
+ g = IssueCategory.new :name => category.category[0,30]
+ g.project = p
+ g.save
+ categories_map[category.category] = g.id
+ end
+ end
+ puts
+
+ # Bugs
+ print "Migrating bugs"
+ Issue.destroy_all
+ issues_map = {}
+ MantisBug.find(:all).each do |bug|
+ next unless projects_map[bug.project_id] && users_map[bug.reporter_id]
+ i = Issue.new :project_id => projects_map[bug.project_id],
+ :subject => encode(bug.summary),
+ :description => encode(bug.bug_text.full_description),
+ :priority => PRIORITY_MAPPING[bug.priority] || DEFAULT_PRIORITY,
+ :created_on => bug.date_submitted,
+ :updated_on => bug.last_updated
+ i.author = User.find_by_id(users_map[bug.reporter_id])
+ i.category = IssueCategory.find_by_project_id_and_name(i.project_id, bug.category[0,30]) unless bug.category.blank?
+ i.fixed_version = Version.find_by_project_id_and_name(i.project_id, bug.fixed_in_version) unless bug.fixed_in_version.blank?
+ i.status = STATUS_MAPPING[bug.status] || DEFAULT_STATUS
+ i.tracker = (bug.severity == 10 ? TRACKER_FEATURE : TRACKER_BUG)
+ next unless i.save
+ issues_map[bug.id] = i.id
+ print '.'
+
+ # Assignee
+ # Redmine checks that the assignee is a project member
+ if (bug.handler_id && users_map[bug.handler_id])
+ i.assigned_to = User.find_by_id(users_map[bug.handler_id])
+ i.save_with_validation(false)
+ end
+
+ # Bug notes
+ bug.bug_notes.each do |note|
+ next unless users_map[note.reporter_id]
+ n = Journal.new :notes => encode(note.bug_note_text.note),
+ :created_on => note.date_submitted
+ n.user = User.find_by_id(users_map[note.reporter_id])
+ n.journalized = i
+ n.save
+ end
+
+ # Bug files
+ bug.bug_files.each do |file|
+ a = Attachment.new :created_on => file.date_added
+ a.file = file
+ a.author = User.find :first
+ a.container = i
+ a.save
+ end
+
+ # Bug monitors
+ bug.bug_monitors.each do |monitor|
+ next unless users_map[monitor.user_id]
+ i.add_watcher(User.find_by_id(users_map[monitor.user_id]))
+ end
+ end
+ puts
+
+ # Bug relationships
+ print "Migrating bug relations"
+ MantisBugRelationship.find(:all).each do |relation|
+ next unless issues_map[relation.source_bug_id] && issues_map[relation.destination_bug_id]
+ r = IssueRelation.new :relation_type => RELATION_TYPE_MAPPING[relation.relationship_type]
+ r.issue_from = Issue.find_by_id(issues_map[relation.source_bug_id])
+ r.issue_to = Issue.find_by_id(issues_map[relation.destination_bug_id])
+ pp r unless r.save
+ print '.'
+ end
+ puts
+
+ # News
+ print "Migrating news"
+ News.destroy_all
+ MantisNews.find(:all, :conditions => 'project_id > 0').each do |news|
+ next unless projects_map[news.project_id]
+ n = News.new :project_id => projects_map[news.project_id],
+ :title => encode(news.headline[0..59]),
+ :description => encode(news.body),
+ :created_on => news.date_posted
+ n.author = User.find_by_id(users_map[news.poster_id])
+ n.save
+ print '.'
+ end
+ puts
+
+ # Custom fields
+ print "Migrating custom fields"
+ IssueCustomField.destroy_all
+ MantisCustomField.find(:all).each do |field|
+ f = IssueCustomField.new :name => field.name[0..29],
+ :field_format => CUSTOM_FIELD_TYPE_MAPPING[field.format],
+ :min_length => field.length_min,
+ :max_length => field.length_max,
+ :regexp => field.valid_regexp,
+ :possible_values => field.possible_values.split('|'),
+ :is_required => field.require_report?
+ next unless f.save
+ print '.'
+
+ # Trackers association
+ f.trackers = Tracker.find :all
+
+ # Projects association
+ field.projects.each do |project|
+ f.projects << Project.find_by_id(projects_map[project.project_id]) if projects_map[project.project_id]
+ end
+
+ # Values
+ field.values.each do |value|
+ v = CustomValue.new :custom_field_id => f.id,
+ :value => value.value
+ v.customized = Issue.find_by_id(issues_map[value.bug_id]) if issues_map[value.bug_id]
+ v.save
+ end unless f.new_record?
+ end
+ puts
+
+ puts
+ puts "Users: #{users_migrated}/#{MantisUser.count}"
+ puts "Projects: #{Project.count}/#{MantisProject.count}"
+ puts "Memberships: #{Member.count}/#{MantisProjectUser.count}"
+ puts "Versions: #{Version.count}/#{MantisVersion.count}"
+ puts "Categories: #{IssueCategory.count}/#{MantisCategory.count}"
+ puts "Bugs: #{Issue.count}/#{MantisBug.count}"
+ puts "Bug notes: #{Journal.count}/#{MantisBugNote.count}"
+ puts "Bug files: #{Attachment.count}/#{MantisBugFile.count}"
+ puts "Bug relations: #{IssueRelation.count}/#{MantisBugRelationship.count}"
+ puts "Bug monitors: #{Watcher.count}/#{MantisBugMonitor.count}"
+ puts "News: #{News.count}/#{MantisNews.count}"
+ puts "Custom fields: #{IssueCustomField.count}/#{MantisCustomField.count}"
+ end
+
+ def self.encoding(charset)
+ @ic = Iconv.new('UTF-8', charset)
+ rescue Iconv::InvalidEncoding
+ return false
+ end
+
+ def self.establish_connection(params)
+ constants.each do |const|
+ klass = const_get(const)
+ next unless klass.respond_to? 'establish_connection'
+ klass.establish_connection params
+ end
+ end
+
+ private
+ def self.encode(text)
+ @ic.iconv text
+ rescue
+ text
+ end
+ end
+
+ puts
+ puts "WARNING: Your Redmine data will be deleted during this process."
+ print "Are you sure you want to continue ? [y/N] "
+ break unless STDIN.gets.match(/^y$/i)
+
+ # Default Mantis database settings
+ db_params = {:adapter => 'mysql',
+ :database => 'bugtracker',
+ :host => 'localhost',
+ :username => 'root',
+ :password => '' }
+
+ puts
+ puts "Please enter settings for your Mantis database"
+ [:adapter, :host, :database, :username, :password].each do |param|
+ print "#{param} [#{db_params[param]}]: "
+ value = STDIN.gets.chomp!
+ db_params[param] = value unless value.blank?
+ end
+
+ while true
+ print "encoding [UTF-8]: "
+ encoding = STDIN.gets.chomp!
+ encoding = 'UTF-8' if encoding.blank?
+ break if MantisMigrate.encoding encoding
+ puts "Invalid encoding!"
+ end
+ puts
+
+ # Make sure bugs can refer bugs in other projects
+ Setting.cross_project_issue_relations = 1 if Setting.respond_to? 'cross_project_issue_relations'
+
+ MantisMigrate.establish_connection db_params
+ MantisMigrate.migrate
+end
+end
diff --git a/rest_sys/lib/tasks/migrate_from_trac.rake b/rest_sys/lib/tasks/migrate_from_trac.rake
new file mode 100644
index 000000000..828027b87
--- /dev/null
+++ b/rest_sys/lib/tasks/migrate_from_trac.rake
@@ -0,0 +1,555 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'active_record'
+require 'iconv'
+require 'pp'
+
+namespace :redmine do
+ desc 'Trac migration script'
+ task :migrate_from_trac => :environment do
+
+ module TracMigrate
+ TICKET_MAP = []
+
+ DEFAULT_STATUS = IssueStatus.default
+ assigned_status = IssueStatus.find_by_position(2)
+ resolved_status = IssueStatus.find_by_position(3)
+ feedback_status = IssueStatus.find_by_position(4)
+ closed_status = IssueStatus.find :first, :conditions => { :is_closed => true }
+ STATUS_MAPPING = {'new' => DEFAULT_STATUS,
+ 'reopened' => feedback_status,
+ 'assigned' => assigned_status,
+ 'closed' => closed_status
+ }
+
+ priorities = Enumeration.get_values('IPRI')
+ DEFAULT_PRIORITY = priorities[0]
+ PRIORITY_MAPPING = {'lowest' => priorities[0],
+ 'low' => priorities[0],
+ 'normal' => priorities[1],
+ 'high' => priorities[2],
+ 'highest' => priorities[3]
+ }
+
+ TRACKER_BUG = Tracker.find_by_position(1)
+ TRACKER_FEATURE = Tracker.find_by_position(2)
+ DEFAULT_TRACKER = TRACKER_BUG
+ TRACKER_MAPPING = {'defect' => TRACKER_BUG,
+ 'enhancement' => TRACKER_FEATURE,
+ 'task' => TRACKER_FEATURE,
+ 'patch' =>TRACKER_FEATURE
+ }
+
+ roles = Role.find(:all, :conditions => {:builtin => 0}, :order => 'position ASC')
+ manager_role = roles[0]
+ developer_role = roles[1]
+ DEFAULT_ROLE = roles.last
+ ROLE_MAPPING = {'admin' => manager_role,
+ 'developer' => developer_role
+ }
+
+ class TracComponent < ActiveRecord::Base
+ set_table_name :component
+ end
+
+ class TracMilestone < ActiveRecord::Base
+ set_table_name :milestone
+
+ def due
+ if read_attribute(:due) > 0
+ Time.at(read_attribute(:due)).to_date
+ else
+ nil
+ end
+ end
+ end
+
+ class TracTicketCustom < ActiveRecord::Base
+ set_table_name :ticket_custom
+ end
+
+ class TracAttachment < ActiveRecord::Base
+ set_table_name :attachment
+ set_inheritance_column :none
+
+ def time; Time.at(read_attribute(:time)) end
+
+ def original_filename
+ filename
+ end
+
+ def content_type
+ Redmine::MimeType.of(filename) || ''
+ end
+
+ def exist?
+ File.file? trac_fullpath
+ end
+
+ def read
+ File.open("#{trac_fullpath}", 'rb').read
+ end
+
+ private
+ def trac_fullpath
+ attachment_type = read_attribute(:type)
+ trac_file = filename.gsub( /[^a-zA-Z0-9\-_\.!~*']/n ) {|x| sprintf('%%%02x', x[0]) }
+ "#{TracMigrate.trac_attachments_directory}/#{attachment_type}/#{id}/#{trac_file}"
+ end
+ end
+
+ class TracTicket < ActiveRecord::Base
+ set_table_name :ticket
+ set_inheritance_column :none
+
+ # ticket changes: only migrate status changes and comments
+ has_many :changes, :class_name => "TracTicketChange", :foreign_key => :ticket
+ has_many :attachments, :class_name => "TracAttachment", :foreign_key => :id, :conditions => "#{TracMigrate::TracAttachment.table_name}.type = 'ticket'"
+ has_many :customs, :class_name => "TracTicketCustom", :foreign_key => :ticket
+
+ def ticket_type
+ read_attribute(:type)
+ end
+
+ def summary
+ read_attribute(:summary).blank? ? "(no subject)" : read_attribute(:summary)
+ end
+
+ def description
+ read_attribute(:description).blank? ? summary : read_attribute(:description)
+ end
+
+ def time; Time.at(read_attribute(:time)) end
+ end
+
+ class TracTicketChange < ActiveRecord::Base
+ set_table_name :ticket_change
+
+ def time; Time.at(read_attribute(:time)) end
+ end
+
+ class TracWikiPage < ActiveRecord::Base
+ set_table_name :wiki
+
+ def self.columns
+ # Hides readonly Trac field to prevent clash with AR readonly? method (Rails 2.0)
+ super.select {|column| column.name.to_s != 'readonly'}
+ end
+ end
+
+ class TracPermission < ActiveRecord::Base
+ set_table_name :permission
+ end
+
+ def self.find_or_create_user(username, project_member = false)
+ u = User.find_by_login(username)
+ if !u
+ # Create a new user if not found
+ mail = username[0,limit_for(User, 'mail')]
+ mail = "#{mail}@foo.bar" unless mail.include?("@")
+ u = User.new :firstname => username[0,limit_for(User, 'firstname')].gsub(/[^\w\s\'\-]/i, '-'),
+ :lastname => '-',
+ :mail => mail.gsub(/[^-@a-z0-9\.]/i, '-')
+ u.login = username[0,limit_for(User, 'login')].gsub(/[^a-z0-9_\-@\.]/i, '-')
+ u.password = 'trac'
+ u.admin = true if TracPermission.find_by_username_and_action(username, 'admin')
+ # finally, a default user is used if the new user is not valid
+ u = User.find(:first) unless u.save
+ end
+ # Make sure he is a member of the project
+ if project_member && !u.member_of?(@target_project)
+ role = DEFAULT_ROLE
+ if u.admin
+ role = ROLE_MAPPING['admin']
+ elsif TracPermission.find_by_username_and_action(username, 'developer')
+ role = ROLE_MAPPING['developer']
+ end
+ Member.create(:user => u, :project => @target_project, :role => role)
+ u.reload
+ end
+ u
+ end
+
+ # Basic wiki syntax conversion
+ def self.convert_wiki_text(text)
+ # Titles
+ text = text.gsub(/^(\=+)\s(.+)\s(\=+)/) {|s| "\nh#{$1.length}. #{$2}\n"}
+ # External Links
+ text = text.gsub(/\[(http[^\s]+)\s+([^\]]+)\]/) {|s| "\"#{$2}\":#{$1}"}
+ # Internal Links
+ text = text.gsub(/\[\[BR\]\]/, "\n") # This has to go before the rules below
+ text = text.gsub(/\[\"(.+)\".*\]/) {|s| "[[#{$1.delete(',./?;|:')}]]"}
+ text = text.gsub(/\[wiki:\"(.+)\".*\]/) {|s| "[[#{$1.delete(',./?;|:')}]]"}
+ text = text.gsub(/\[wiki:\"(.+)\".*\]/) {|s| "[[#{$1.delete(',./?;|:')}]]"}
+ text = text.gsub(/\[wiki:([^\s\]]+).*\]/) {|s| "[[#{$1.delete(',./?;|:')}]]"}
+ # Revisions links
+ text = text.gsub(/\[(\d+)\]/, 'r\1')
+ # Ticket number re-writing
+ text = text.gsub(/#(\d+)/) do |s|
+ TICKET_MAP[$1.to_i] ||= $1
+ "\##{TICKET_MAP[$1.to_i] || $1}"
+ end
+ # Preformatted blocks
+ text = text.gsub(/\{\{\{/, '')
+ text = text.gsub(/\}\}\}/, ' ')
+ # Highlighting
+ text = text.gsub(/'''''([^\s])/, '_*\1')
+ text = text.gsub(/([^\s])'''''/, '\1*_')
+ text = text.gsub(/'''/, '*')
+ text = text.gsub(/''/, '_')
+ text = text.gsub(/__/, '+')
+ text = text.gsub(/~~/, '-')
+ text = text.gsub(/`/, '@')
+ text = text.gsub(/,,/, '~')
+ # Lists
+ text = text.gsub(/^([ ]+)\* /) {|s| '*' * $1.length + " "}
+
+ text
+ end
+
+ def self.migrate
+ establish_connection
+
+ # Quick database test
+ TracComponent.count
+
+ migrated_components = 0
+ migrated_milestones = 0
+ migrated_tickets = 0
+ migrated_custom_values = 0
+ migrated_ticket_attachments = 0
+ migrated_wiki_edits = 0
+
+ # Components
+ print "Migrating components"
+ issues_category_map = {}
+ TracComponent.find(:all).each do |component|
+ print '.'
+ STDOUT.flush
+ c = IssueCategory.new :project => @target_project,
+ :name => encode(component.name[0, limit_for(IssueCategory, 'name')])
+ next unless c.save
+ issues_category_map[component.name] = c
+ migrated_components += 1
+ end
+ puts
+
+ # Milestones
+ print "Migrating milestones"
+ version_map = {}
+ TracMilestone.find(:all).each do |milestone|
+ print '.'
+ STDOUT.flush
+ v = Version.new :project => @target_project,
+ :name => encode(milestone.name[0, limit_for(Version, 'name')]),
+ :description => encode(milestone.description.to_s[0, limit_for(Version, 'description')]),
+ :effective_date => milestone.due
+ next unless v.save
+ version_map[milestone.name] = v
+ migrated_milestones += 1
+ end
+ puts
+
+ # Custom fields
+ # TODO: read trac.ini instead
+ print "Migrating custom fields"
+ custom_field_map = {}
+ TracTicketCustom.find_by_sql("SELECT DISTINCT name FROM #{TracTicketCustom.table_name}").each do |field|
+ print '.'
+ STDOUT.flush
+ # Redmine custom field name
+ field_name = encode(field.name[0, limit_for(IssueCustomField, 'name')]).humanize
+ # Find if the custom already exists in Redmine
+ f = IssueCustomField.find_by_name(field_name)
+ # Or create a new one
+ f ||= IssueCustomField.create(:name => encode(field.name[0, limit_for(IssueCustomField, 'name')]).humanize,
+ :field_format => 'string')
+
+ next if f.new_record?
+ f.trackers = Tracker.find(:all)
+ f.projects << @target_project
+ custom_field_map[field.name] = f
+ end
+ puts
+
+ # Trac 'resolution' field as a Redmine custom field
+ r = IssueCustomField.find(:first, :conditions => { :name => "Resolution" })
+ r = IssueCustomField.new(:name => 'Resolution',
+ :field_format => 'list',
+ :is_filter => true) if r.nil?
+ r.trackers = Tracker.find(:all)
+ r.projects << @target_project
+ r.possible_values = %w(fixed invalid wontfix duplicate worksforme)
+ custom_field_map['resolution'] = r if r.save
+
+ # Tickets
+ print "Migrating tickets"
+ TracTicket.find(:all, :order => 'id ASC').each do |ticket|
+ print '.'
+ STDOUT.flush
+ i = Issue.new :project => @target_project,
+ :subject => encode(ticket.summary[0, limit_for(Issue, 'subject')]),
+ :description => convert_wiki_text(encode(ticket.description)),
+ :priority => PRIORITY_MAPPING[ticket.priority] || DEFAULT_PRIORITY,
+ :created_on => ticket.time
+ i.author = find_or_create_user(ticket.reporter)
+ i.category = issues_category_map[ticket.component] unless ticket.component.blank?
+ i.fixed_version = version_map[ticket.milestone] unless ticket.milestone.blank?
+ i.status = STATUS_MAPPING[ticket.status] || DEFAULT_STATUS
+ i.tracker = TRACKER_MAPPING[ticket.ticket_type] || DEFAULT_TRACKER
+ i.custom_values << CustomValue.new(:custom_field => custom_field_map['resolution'], :value => ticket.resolution) unless ticket.resolution.blank?
+ i.id = ticket.id unless Issue.exists?(ticket.id)
+ next unless i.save
+ TICKET_MAP[ticket.id] = i.id
+ migrated_tickets += 1
+
+ # Owner
+ unless ticket.owner.blank?
+ i.assigned_to = find_or_create_user(ticket.owner, true)
+ i.save
+ end
+
+ # Comments and status/resolution changes
+ ticket.changes.group_by(&:time).each do |time, changeset|
+ status_change = changeset.select {|change| change.field == 'status'}.first
+ resolution_change = changeset.select {|change| change.field == 'resolution'}.first
+ comment_change = changeset.select {|change| change.field == 'comment'}.first
+
+ n = Journal.new :notes => (comment_change ? convert_wiki_text(encode(comment_change.newvalue)) : ''),
+ :created_on => time
+ n.user = find_or_create_user(changeset.first.author)
+ n.journalized = i
+ if status_change &&
+ STATUS_MAPPING[status_change.oldvalue] &&
+ STATUS_MAPPING[status_change.newvalue] &&
+ (STATUS_MAPPING[status_change.oldvalue] != STATUS_MAPPING[status_change.newvalue])
+ n.details << JournalDetail.new(:property => 'attr',
+ :prop_key => 'status_id',
+ :old_value => STATUS_MAPPING[status_change.oldvalue].id,
+ :value => STATUS_MAPPING[status_change.newvalue].id)
+ end
+ if resolution_change
+ n.details << JournalDetail.new(:property => 'cf',
+ :prop_key => custom_field_map['resolution'].id,
+ :old_value => resolution_change.oldvalue,
+ :value => resolution_change.newvalue)
+ end
+ n.save unless n.details.empty? && n.notes.blank?
+ end
+
+ # Attachments
+ ticket.attachments.each do |attachment|
+ next unless attachment.exist?
+ a = Attachment.new :created_on => attachment.time
+ a.file = attachment
+ a.author = find_or_create_user(attachment.author)
+ a.container = i
+ migrated_ticket_attachments += 1 if a.save
+ end
+
+ # Custom fields
+ ticket.customs.each do |custom|
+ next if custom_field_map[custom.name].nil?
+ v = CustomValue.new :custom_field => custom_field_map[custom.name],
+ :value => custom.value
+ v.customized = i
+ next unless v.save
+ migrated_custom_values += 1
+ end
+ end
+ puts
+
+ # Wiki
+ print "Migrating wiki"
+ @target_project.wiki.destroy if @target_project.wiki
+ @target_project.reload
+ wiki = Wiki.new(:project => @target_project, :start_page => 'WikiStart')
+ if wiki.save
+ TracWikiPage.find(:all, :order => 'name, version').each do |page|
+ print '.'
+ STDOUT.flush
+ p = wiki.find_or_new_page(page.name)
+ p.content = WikiContent.new(:page => p) if p.new_record?
+ p.content.text = page.text
+ p.content.author = find_or_create_user(page.author) unless page.author.blank? || page.author == 'trac'
+ p.content.comments = page.comment
+ p.new_record? ? p.save : p.content.save
+ migrated_wiki_edits += 1 unless p.content.new_record?
+ end
+
+ wiki.reload
+ wiki.pages.each do |page|
+ page.content.text = convert_wiki_text(page.content.text)
+ page.content.save
+ end
+ end
+ puts
+
+ puts
+ puts "Components: #{migrated_components}/#{TracComponent.count}"
+ puts "Milestones: #{migrated_milestones}/#{TracMilestone.count}"
+ puts "Tickets: #{migrated_tickets}/#{TracTicket.count}"
+ puts "Ticket files: #{migrated_ticket_attachments}/" + TracAttachment.count("type = 'ticket'").to_s
+ puts "Custom values: #{migrated_custom_values}/#{TracTicketCustom.count}"
+ puts "Wiki edits: #{migrated_wiki_edits}/#{TracWikiPage.count}"
+ end
+
+ def self.limit_for(klass, attribute)
+ klass.columns_hash[attribute.to_s].limit
+ end
+
+ def self.encoding(charset)
+ @ic = Iconv.new('UTF-8', charset)
+ rescue Iconv::InvalidEncoding
+ puts "Invalid encoding!"
+ return false
+ end
+
+ def self.set_trac_directory(path)
+ @@trac_directory = path
+ raise "This directory doesn't exist!" unless File.directory?(path)
+ raise "#{trac_attachments_directory} doesn't exist!" unless File.directory?(trac_attachments_directory)
+ @@trac_directory
+ rescue Exception => e
+ puts e
+ return false
+ end
+
+ def self.trac_directory
+ @@trac_directory
+ end
+
+ def self.set_trac_adapter(adapter)
+ return false if adapter.blank?
+ raise "Unknown adapter: #{adapter}!" unless %w(sqlite sqlite3 mysql postgresql).include?(adapter)
+ # If adapter is sqlite or sqlite3, make sure that trac.db exists
+ raise "#{trac_db_path} doesn't exist!" if %w(sqlite sqlite3).include?(adapter) && !File.exist?(trac_db_path)
+ @@trac_adapter = adapter
+ rescue Exception => e
+ puts e
+ return false
+ end
+
+ def self.set_trac_db_host(host)
+ return nil if host.blank?
+ @@trac_db_host = host
+ end
+
+ def self.set_trac_db_port(port)
+ return nil if port.to_i == 0
+ @@trac_db_port = port.to_i
+ end
+
+ def self.set_trac_db_name(name)
+ return nil if name.blank?
+ @@trac_db_name = name
+ end
+
+ def self.set_trac_db_username(username)
+ @@trac_db_username = username
+ end
+
+ def self.set_trac_db_password(password)
+ @@trac_db_password = password
+ end
+
+ mattr_reader :trac_directory, :trac_adapter, :trac_db_host, :trac_db_port, :trac_db_name, :trac_db_username, :trac_db_password
+
+ def self.trac_db_path; "#{trac_directory}/db/trac.db" end
+ def self.trac_attachments_directory; "#{trac_directory}/attachments" end
+
+ def self.target_project_identifier(identifier)
+ project = Project.find_by_identifier(identifier)
+ if !project
+ # create the target project
+ project = Project.new :name => identifier.humanize,
+ :description => identifier.humanize
+ project.identifier = identifier
+ puts "Unable to create a project with identifier '#{identifier}'!" unless project.save
+ # enable issues and wiki for the created project
+ project.enabled_module_names = ['issue_tracking', 'wiki']
+ end
+ project.trackers << TRACKER_BUG
+ project.trackers << TRACKER_FEATURE
+ @target_project = project.new_record? ? nil : project
+ end
+
+ def self.connection_params
+ if %w(sqlite sqlite3).include?(trac_adapter)
+ {:adapter => trac_adapter,
+ :database => trac_db_path}
+ else
+ {:adapter => trac_adapter,
+ :database => trac_db_name,
+ :host => trac_db_host,
+ :port => trac_db_port,
+ :username => trac_db_username,
+ :password => trac_db_password}
+ end
+ end
+
+ def self.establish_connection
+ constants.each do |const|
+ klass = const_get(const)
+ next unless klass.respond_to? 'establish_connection'
+ klass.establish_connection connection_params
+ end
+ end
+
+ private
+ def self.encode(text)
+ @ic.iconv text
+ rescue
+ text
+ end
+ end
+
+ puts
+ puts "WARNING: a new project will be added to Redmine during this process."
+ print "Are you sure you want to continue ? [y/N] "
+ break unless STDIN.gets.match(/^y$/i)
+ puts
+
+ def prompt(text, options = {}, &block)
+ default = options[:default] || ''
+ while true
+ print "#{text} [#{default}]: "
+ value = STDIN.gets.chomp!
+ value = default if value.blank?
+ break if yield value
+ end
+ end
+
+ DEFAULT_PORTS = {'mysql' => 3306, 'postgresl' => 5432}
+
+ prompt('Trac directory') {|directory| TracMigrate.set_trac_directory directory}
+ prompt('Trac database adapter (sqlite, sqlite3, mysql, postgresql)', :default => 'sqlite') {|adapter| TracMigrate.set_trac_adapter adapter}
+ unless %w(sqlite sqlite3).include?(TracMigrate.trac_adapter)
+ prompt('Trac database host', :default => 'localhost') {|host| TracMigrate.set_trac_db_host host}
+ prompt('Trac database port', :default => DEFAULT_PORTS[TracMigrate.trac_adapter]) {|port| TracMigrate.set_trac_db_port port}
+ prompt('Trac database name') {|name| TracMigrate.set_trac_db_name name}
+ prompt('Trac database username') {|username| TracMigrate.set_trac_db_username username}
+ prompt('Trac database password') {|password| TracMigrate.set_trac_db_password password}
+ end
+ prompt('Trac database encoding', :default => 'UTF-8') {|encoding| TracMigrate.encoding encoding}
+ prompt('Target project identifier') {|identifier| TracMigrate.target_project_identifier identifier}
+ puts
+
+ TracMigrate.migrate
+ end
+end
diff --git a/rest_sys/lib/tasks/migrate_plugins.rake b/rest_sys/lib/tasks/migrate_plugins.rake
new file mode 100644
index 000000000..61df9c3f0
--- /dev/null
+++ b/rest_sys/lib/tasks/migrate_plugins.rake
@@ -0,0 +1,15 @@
+namespace :db do
+ desc 'Migrates installed plugins.'
+ task :migrate_plugins => :environment do
+ if Rails.respond_to?('plugins')
+ Rails.plugins.each do |plugin|
+ next unless plugin.respond_to?('migrate')
+ puts "Migrating #{plugin.name}..."
+ plugin.migrate
+ end
+ else
+ puts "Undefined method plugins for Rails!"
+ puts "Make sure engines plugin is installed."
+ end
+ end
+end
diff --git a/rest_sys/log/delete.me b/rest_sys/log/delete.me
new file mode 100644
index 000000000..18beddaa8
--- /dev/null
+++ b/rest_sys/log/delete.me
@@ -0,0 +1 @@
+default directory for uploaded files
\ No newline at end of file
diff --git a/rest_sys/public/.htaccess b/rest_sys/public/.htaccess
new file mode 100644
index 000000000..3d3fb88bc
--- /dev/null
+++ b/rest_sys/public/.htaccess
@@ -0,0 +1,55 @@
+# General Apache options
+
+ AddHandler fastcgi-script .fcgi
+
+
+ AddHandler fcgid-script .fcgi
+
+
+ AddHandler cgi-script .cgi
+
+Options +FollowSymLinks +ExecCGI
+
+# If you don't want Rails to look in certain directories,
+# use the following rewrite rules so that Apache won't rewrite certain requests
+#
+# Example:
+# RewriteCond %{REQUEST_URI} ^/notrails.*
+# RewriteRule .* - [L]
+
+# Redirect all requests not available on the filesystem to Rails
+# By default the cgi dispatcher is used which is very slow
+#
+# For better performance replace the dispatcher with the fastcgi one
+#
+# Example:
+# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
+RewriteEngine On
+
+# If your Rails application is accessed via an Alias directive,
+# then you MUST also set the RewriteBase in this htaccess file.
+#
+# Example:
+# Alias /myrailsapp /path/to/myrailsapp/public
+# RewriteBase /myrailsapp
+
+RewriteRule ^$ index.html [QSA]
+RewriteRule ^([^.]+)$ $1.html [QSA]
+RewriteCond %{REQUEST_FILENAME} !-f
+
+ RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
+
+
+ RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
+
+
+ RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
+
+
+# In case Rails experiences terminal errors
+# Instead of displaying this message you can supply a file here which will be rendered instead
+#
+# Example:
+# ErrorDocument 500 /500.html
+
+ErrorDocument 500 "Application error Rails application failed to start properly"
\ No newline at end of file
diff --git a/rest_sys/public/404.html b/rest_sys/public/404.html
new file mode 100644
index 000000000..ddf424b09
--- /dev/null
+++ b/rest_sys/public/404.html
@@ -0,0 +1,23 @@
+
+
+redMine 404 error
+
+
+ Page not found
+ The page you were trying to access doesn't exist or has been removed.
+ Back
+
+
\ No newline at end of file
diff --git a/rest_sys/public/500.html b/rest_sys/public/500.html
new file mode 100644
index 000000000..93eb0f128
--- /dev/null
+++ b/rest_sys/public/500.html
@@ -0,0 +1,24 @@
+
+
+redMine 500 error
+
+
+ Internal error
+ An error occurred on the page you were trying to access.
+ If you continue to experience problems please contact your redMine administrator for assistance.
+ Back
+
+
\ No newline at end of file
diff --git a/rest_sys/public/dispatch.cgi.example b/rest_sys/public/dispatch.cgi.example
new file mode 100755
index 000000000..9730473f2
--- /dev/null
+++ b/rest_sys/public/dispatch.cgi.example
@@ -0,0 +1,10 @@
+#!/usr/bin/ruby
+
+require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
+
+# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
+# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
+require "dispatcher"
+
+ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
+Dispatcher.dispatch
\ No newline at end of file
diff --git a/rest_sys/public/dispatch.fcgi.example b/rest_sys/public/dispatch.fcgi.example
new file mode 100755
index 000000000..f934b3002
--- /dev/null
+++ b/rest_sys/public/dispatch.fcgi.example
@@ -0,0 +1,24 @@
+#!/usr/bin/ruby
+#
+# You may specify the path to the FastCGI crash log (a log of unhandled
+# exceptions which forced the FastCGI instance to exit, great for debugging)
+# and the number of requests to process before running garbage collection.
+#
+# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
+# and the GC period is nil (turned off). A reasonable number of requests
+# could range from 10-100 depending on the memory footprint of your app.
+#
+# Example:
+# # Default log path, normal GC behavior.
+# RailsFCGIHandler.process!
+#
+# # Default log path, 50 requests between GC.
+# RailsFCGIHandler.process! nil, 50
+#
+# # Custom log path, normal GC behavior.
+# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
+#
+require File.dirname(__FILE__) + "/../config/environment"
+require 'fcgi_handler'
+
+RailsFCGIHandler.process!
diff --git a/rest_sys/public/dispatch.rb.example b/rest_sys/public/dispatch.rb.example
new file mode 100755
index 000000000..9730473f2
--- /dev/null
+++ b/rest_sys/public/dispatch.rb.example
@@ -0,0 +1,10 @@
+#!/usr/bin/ruby
+
+require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
+
+# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
+# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
+require "dispatcher"
+
+ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
+Dispatcher.dispatch
\ No newline at end of file
diff --git a/rest_sys/public/favicon.ico b/rest_sys/public/favicon.ico
new file mode 100644
index 000000000..e69de29bb
diff --git a/rest_sys/public/help/wiki_syntax.html b/rest_sys/public/help/wiki_syntax.html
new file mode 100644
index 000000000..f02eb62ab
--- /dev/null
+++ b/rest_sys/public/help/wiki_syntax.html
@@ -0,0 +1,57 @@
+
+
+
+Wiki formatting
+
+
+
+
+
+Wiki Syntax Quick Reference
+
+
+Font Styles
+*Strong* Strong
+_Italic_ Italic
++Underline+ Underline
+-Deleted- Deleted
+??Quote?? Quote
+@Code@ Code
+<pre> lines of code </pre>
+
+ lines
+ of code
+
+
+
+Lists
+* Item 1 * Item 2
+# Item 1 # Item 2 Item 1 Item 2
+
+Headings
+h1. Title 1 Title 1
+h2. Title 2 Title 2
+h3. Title 3 Title 3
+
+Links
+http://foo.bar http://foo.bar
+[[Wiki page]] Wiki page
+Issue #12 Issue #12
+Revision r43 Revision r43
+
+Inline images
+!image_url !
+!attached_image !
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/public/images/1downarrow.png b/rest_sys/public/images/1downarrow.png
new file mode 100644
index 000000000..dd5b65d6a
Binary files /dev/null and b/rest_sys/public/images/1downarrow.png differ
diff --git a/rest_sys/public/images/1uparrow.png b/rest_sys/public/images/1uparrow.png
new file mode 100644
index 000000000..cd514d19c
Binary files /dev/null and b/rest_sys/public/images/1uparrow.png differ
diff --git a/rest_sys/public/images/22x22/authent.png b/rest_sys/public/images/22x22/authent.png
new file mode 100644
index 000000000..d2b29945f
Binary files /dev/null and b/rest_sys/public/images/22x22/authent.png differ
diff --git a/rest_sys/public/images/22x22/comment.png b/rest_sys/public/images/22x22/comment.png
new file mode 100644
index 000000000..e2f4e701c
Binary files /dev/null and b/rest_sys/public/images/22x22/comment.png differ
diff --git a/rest_sys/public/images/22x22/file.png b/rest_sys/public/images/22x22/file.png
new file mode 100644
index 000000000..96c56a2b5
Binary files /dev/null and b/rest_sys/public/images/22x22/file.png differ
diff --git a/rest_sys/public/images/22x22/info.png b/rest_sys/public/images/22x22/info.png
new file mode 100644
index 000000000..cf54e2c6a
Binary files /dev/null and b/rest_sys/public/images/22x22/info.png differ
diff --git a/rest_sys/public/images/22x22/notifications.png b/rest_sys/public/images/22x22/notifications.png
new file mode 100644
index 000000000..972f4a24d
Binary files /dev/null and b/rest_sys/public/images/22x22/notifications.png differ
diff --git a/rest_sys/public/images/22x22/options.png b/rest_sys/public/images/22x22/options.png
new file mode 100644
index 000000000..48da1516c
Binary files /dev/null and b/rest_sys/public/images/22x22/options.png differ
diff --git a/rest_sys/public/images/22x22/package.png b/rest_sys/public/images/22x22/package.png
new file mode 100644
index 000000000..f1a98dcde
Binary files /dev/null and b/rest_sys/public/images/22x22/package.png differ
diff --git a/rest_sys/public/images/22x22/plugin.png b/rest_sys/public/images/22x22/plugin.png
new file mode 100644
index 000000000..455fa6a80
Binary files /dev/null and b/rest_sys/public/images/22x22/plugin.png differ
diff --git a/rest_sys/public/images/22x22/projects.png b/rest_sys/public/images/22x22/projects.png
new file mode 100644
index 000000000..4f023bedb
Binary files /dev/null and b/rest_sys/public/images/22x22/projects.png differ
diff --git a/rest_sys/public/images/22x22/role.png b/rest_sys/public/images/22x22/role.png
new file mode 100644
index 000000000..4de98edd4
Binary files /dev/null and b/rest_sys/public/images/22x22/role.png differ
diff --git a/rest_sys/public/images/22x22/settings.png b/rest_sys/public/images/22x22/settings.png
new file mode 100644
index 000000000..54a3b4730
Binary files /dev/null and b/rest_sys/public/images/22x22/settings.png differ
diff --git a/rest_sys/public/images/22x22/tracker.png b/rest_sys/public/images/22x22/tracker.png
new file mode 100644
index 000000000..f51394186
Binary files /dev/null and b/rest_sys/public/images/22x22/tracker.png differ
diff --git a/rest_sys/public/images/22x22/users.png b/rest_sys/public/images/22x22/users.png
new file mode 100644
index 000000000..92f396207
Binary files /dev/null and b/rest_sys/public/images/22x22/users.png differ
diff --git a/rest_sys/public/images/22x22/workflow.png b/rest_sys/public/images/22x22/workflow.png
new file mode 100644
index 000000000..9d1b9d8b9
Binary files /dev/null and b/rest_sys/public/images/22x22/workflow.png differ
diff --git a/rest_sys/public/images/2downarrow.png b/rest_sys/public/images/2downarrow.png
new file mode 100644
index 000000000..05880f381
Binary files /dev/null and b/rest_sys/public/images/2downarrow.png differ
diff --git a/rest_sys/public/images/2uparrow.png b/rest_sys/public/images/2uparrow.png
new file mode 100644
index 000000000..6a87aabbd
Binary files /dev/null and b/rest_sys/public/images/2uparrow.png differ
diff --git a/rest_sys/public/images/32x32/file.png b/rest_sys/public/images/32x32/file.png
new file mode 100644
index 000000000..1662b5302
Binary files /dev/null and b/rest_sys/public/images/32x32/file.png differ
diff --git a/rest_sys/public/images/add.png b/rest_sys/public/images/add.png
new file mode 100644
index 000000000..db59058e5
Binary files /dev/null and b/rest_sys/public/images/add.png differ
diff --git a/rest_sys/public/images/admin.png b/rest_sys/public/images/admin.png
new file mode 100644
index 000000000..c98330ca1
Binary files /dev/null and b/rest_sys/public/images/admin.png differ
diff --git a/rest_sys/public/images/arrow_bw.png b/rest_sys/public/images/arrow_bw.png
new file mode 100644
index 000000000..2af9e2cd4
Binary files /dev/null and b/rest_sys/public/images/arrow_bw.png differ
diff --git a/rest_sys/public/images/arrow_down.png b/rest_sys/public/images/arrow_down.png
new file mode 100644
index 000000000..ea37f3a9e
Binary files /dev/null and b/rest_sys/public/images/arrow_down.png differ
diff --git a/rest_sys/public/images/arrow_from.png b/rest_sys/public/images/arrow_from.png
new file mode 100644
index 000000000..7d94ad185
Binary files /dev/null and b/rest_sys/public/images/arrow_from.png differ
diff --git a/rest_sys/public/images/arrow_to.png b/rest_sys/public/images/arrow_to.png
new file mode 100644
index 000000000..f021e98c9
Binary files /dev/null and b/rest_sys/public/images/arrow_to.png differ
diff --git a/rest_sys/public/images/attachment.png b/rest_sys/public/images/attachment.png
new file mode 100644
index 000000000..eea26921b
Binary files /dev/null and b/rest_sys/public/images/attachment.png differ
diff --git a/rest_sys/public/images/calendar.png b/rest_sys/public/images/calendar.png
new file mode 100644
index 000000000..619172a99
Binary files /dev/null and b/rest_sys/public/images/calendar.png differ
diff --git a/rest_sys/public/images/cancel.png b/rest_sys/public/images/cancel.png
new file mode 100644
index 000000000..0840438c5
Binary files /dev/null and b/rest_sys/public/images/cancel.png differ
diff --git a/rest_sys/public/images/close.png b/rest_sys/public/images/close.png
new file mode 100644
index 000000000..3501ed4d5
Binary files /dev/null and b/rest_sys/public/images/close.png differ
diff --git a/rest_sys/public/images/close_hl.png b/rest_sys/public/images/close_hl.png
new file mode 100644
index 000000000..a433f7515
Binary files /dev/null and b/rest_sys/public/images/close_hl.png differ
diff --git a/rest_sys/public/images/contentbg.png b/rest_sys/public/images/contentbg.png
new file mode 100644
index 000000000..eb6d75080
Binary files /dev/null and b/rest_sys/public/images/contentbg.png differ
diff --git a/rest_sys/public/images/copy.png b/rest_sys/public/images/copy.png
new file mode 100644
index 000000000..dccaa0614
Binary files /dev/null and b/rest_sys/public/images/copy.png differ
diff --git a/rest_sys/public/images/csv.png b/rest_sys/public/images/csv.png
new file mode 100644
index 000000000..405863116
Binary files /dev/null and b/rest_sys/public/images/csv.png differ
diff --git a/rest_sys/public/images/delete.png b/rest_sys/public/images/delete.png
new file mode 100644
index 000000000..137baa68e
Binary files /dev/null and b/rest_sys/public/images/delete.png differ
diff --git a/rest_sys/public/images/draft.png b/rest_sys/public/images/draft.png
new file mode 100644
index 000000000..9eda38b54
Binary files /dev/null and b/rest_sys/public/images/draft.png differ
diff --git a/rest_sys/public/images/edit.png b/rest_sys/public/images/edit.png
new file mode 100644
index 000000000..0275d91e4
Binary files /dev/null and b/rest_sys/public/images/edit.png differ
diff --git a/rest_sys/public/images/expand.png b/rest_sys/public/images/expand.png
new file mode 100644
index 000000000..3e3aaa441
Binary files /dev/null and b/rest_sys/public/images/expand.png differ
diff --git a/rest_sys/public/images/external.png b/rest_sys/public/images/external.png
new file mode 100644
index 000000000..45df6404f
Binary files /dev/null and b/rest_sys/public/images/external.png differ
diff --git a/rest_sys/public/images/false.png b/rest_sys/public/images/false.png
new file mode 100644
index 000000000..e308ddcd6
Binary files /dev/null and b/rest_sys/public/images/false.png differ
diff --git a/rest_sys/public/images/fav.png b/rest_sys/public/images/fav.png
new file mode 100644
index 000000000..49c0f473a
Binary files /dev/null and b/rest_sys/public/images/fav.png differ
diff --git a/rest_sys/public/images/fav_off.png b/rest_sys/public/images/fav_off.png
new file mode 100644
index 000000000..5b10e9df5
Binary files /dev/null and b/rest_sys/public/images/fav_off.png differ
diff --git a/rest_sys/public/images/feed.png b/rest_sys/public/images/feed.png
new file mode 100644
index 000000000..51dc9778e
Binary files /dev/null and b/rest_sys/public/images/feed.png differ
diff --git a/rest_sys/public/images/file.png b/rest_sys/public/images/file.png
new file mode 100644
index 000000000..f387dd305
Binary files /dev/null and b/rest_sys/public/images/file.png differ
diff --git a/rest_sys/public/images/folder.png b/rest_sys/public/images/folder.png
new file mode 100644
index 000000000..d2ab69ad5
Binary files /dev/null and b/rest_sys/public/images/folder.png differ
diff --git a/rest_sys/public/images/folder_open.png b/rest_sys/public/images/folder_open.png
new file mode 100644
index 000000000..e8e8c412e
Binary files /dev/null and b/rest_sys/public/images/folder_open.png differ
diff --git a/rest_sys/public/images/help.png b/rest_sys/public/images/help.png
new file mode 100644
index 000000000..af4e6ff46
Binary files /dev/null and b/rest_sys/public/images/help.png differ
diff --git a/rest_sys/public/images/history.png b/rest_sys/public/images/history.png
new file mode 100644
index 000000000..c6a9607eb
Binary files /dev/null and b/rest_sys/public/images/history.png differ
diff --git a/rest_sys/public/images/home.png b/rest_sys/public/images/home.png
new file mode 100644
index 000000000..21ee5470e
Binary files /dev/null and b/rest_sys/public/images/home.png differ
diff --git a/rest_sys/public/images/html.png b/rest_sys/public/images/html.png
new file mode 100644
index 000000000..efb32e7c5
Binary files /dev/null and b/rest_sys/public/images/html.png differ
diff --git a/rest_sys/public/images/image.png b/rest_sys/public/images/image.png
new file mode 100644
index 000000000..a22cf7f6a
Binary files /dev/null and b/rest_sys/public/images/image.png differ
diff --git a/rest_sys/public/images/index.png b/rest_sys/public/images/index.png
new file mode 100644
index 000000000..1ada3b2dc
Binary files /dev/null and b/rest_sys/public/images/index.png differ
diff --git a/rest_sys/public/images/jstoolbar/bt_br.png b/rest_sys/public/images/jstoolbar/bt_br.png
new file mode 100644
index 000000000..f8211a997
Binary files /dev/null and b/rest_sys/public/images/jstoolbar/bt_br.png differ
diff --git a/rest_sys/public/images/jstoolbar/bt_code.png b/rest_sys/public/images/jstoolbar/bt_code.png
new file mode 100644
index 000000000..52924abf7
Binary files /dev/null and b/rest_sys/public/images/jstoolbar/bt_code.png differ
diff --git a/rest_sys/public/images/jstoolbar/bt_del.png b/rest_sys/public/images/jstoolbar/bt_del.png
new file mode 100644
index 000000000..c6f3a8b40
Binary files /dev/null and b/rest_sys/public/images/jstoolbar/bt_del.png differ
diff --git a/rest_sys/public/images/jstoolbar/bt_em.png b/rest_sys/public/images/jstoolbar/bt_em.png
new file mode 100644
index 000000000..f08de4f30
Binary files /dev/null and b/rest_sys/public/images/jstoolbar/bt_em.png differ
diff --git a/rest_sys/public/images/jstoolbar/bt_heading.png b/rest_sys/public/images/jstoolbar/bt_heading.png
new file mode 100644
index 000000000..a143f23a7
Binary files /dev/null and b/rest_sys/public/images/jstoolbar/bt_heading.png differ
diff --git a/rest_sys/public/images/jstoolbar/bt_ins.png b/rest_sys/public/images/jstoolbar/bt_ins.png
new file mode 100644
index 000000000..f6697db51
Binary files /dev/null and b/rest_sys/public/images/jstoolbar/bt_ins.png differ
diff --git a/rest_sys/public/images/jstoolbar/bt_link.png b/rest_sys/public/images/jstoolbar/bt_link.png
new file mode 100644
index 000000000..9b3acbae5
Binary files /dev/null and b/rest_sys/public/images/jstoolbar/bt_link.png differ
diff --git a/rest_sys/public/images/jstoolbar/bt_ol.png b/rest_sys/public/images/jstoolbar/bt_ol.png
new file mode 100644
index 000000000..2dfaec7c7
Binary files /dev/null and b/rest_sys/public/images/jstoolbar/bt_ol.png differ
diff --git a/rest_sys/public/images/jstoolbar/bt_quote.png b/rest_sys/public/images/jstoolbar/bt_quote.png
new file mode 100644
index 000000000..25b2b8abe
Binary files /dev/null and b/rest_sys/public/images/jstoolbar/bt_quote.png differ
diff --git a/rest_sys/public/images/jstoolbar/bt_strong.png b/rest_sys/public/images/jstoolbar/bt_strong.png
new file mode 100644
index 000000000..7e200d3f6
Binary files /dev/null and b/rest_sys/public/images/jstoolbar/bt_strong.png differ
diff --git a/rest_sys/public/images/jstoolbar/bt_ul.png b/rest_sys/public/images/jstoolbar/bt_ul.png
new file mode 100644
index 000000000..6e20851ec
Binary files /dev/null and b/rest_sys/public/images/jstoolbar/bt_ul.png differ
diff --git a/rest_sys/public/images/loading.gif b/rest_sys/public/images/loading.gif
new file mode 100644
index 000000000..085ccaeca
Binary files /dev/null and b/rest_sys/public/images/loading.gif differ
diff --git a/rest_sys/public/images/locked.png b/rest_sys/public/images/locked.png
new file mode 100644
index 000000000..c2789e35c
Binary files /dev/null and b/rest_sys/public/images/locked.png differ
diff --git a/rest_sys/public/images/mainbg.png b/rest_sys/public/images/mainbg.png
new file mode 100644
index 000000000..29713c3c1
Binary files /dev/null and b/rest_sys/public/images/mainbg.png differ
diff --git a/rest_sys/public/images/milestone.png b/rest_sys/public/images/milestone.png
new file mode 100644
index 000000000..3df96fc24
Binary files /dev/null and b/rest_sys/public/images/milestone.png differ
diff --git a/rest_sys/public/images/move.png b/rest_sys/public/images/move.png
new file mode 100644
index 000000000..32fdb846d
Binary files /dev/null and b/rest_sys/public/images/move.png differ
diff --git a/rest_sys/public/images/note.png b/rest_sys/public/images/note.png
new file mode 100644
index 000000000..256368397
Binary files /dev/null and b/rest_sys/public/images/note.png differ
diff --git a/rest_sys/public/images/package.png b/rest_sys/public/images/package.png
new file mode 100644
index 000000000..ff629d117
Binary files /dev/null and b/rest_sys/public/images/package.png differ
diff --git a/rest_sys/public/images/pdf.png b/rest_sys/public/images/pdf.png
new file mode 100644
index 000000000..68c9bada8
Binary files /dev/null and b/rest_sys/public/images/pdf.png differ
diff --git a/rest_sys/public/images/projects.png b/rest_sys/public/images/projects.png
new file mode 100644
index 000000000..244c896f0
Binary files /dev/null and b/rest_sys/public/images/projects.png differ
diff --git a/rest_sys/public/images/reload.png b/rest_sys/public/images/reload.png
new file mode 100644
index 000000000..c5eb34ee0
Binary files /dev/null and b/rest_sys/public/images/reload.png differ
diff --git a/rest_sys/public/images/save.png b/rest_sys/public/images/save.png
new file mode 100644
index 000000000..f379d9f34
Binary files /dev/null and b/rest_sys/public/images/save.png differ
diff --git a/rest_sys/public/images/sort_asc.png b/rest_sys/public/images/sort_asc.png
new file mode 100644
index 000000000..e9cb0f4f2
Binary files /dev/null and b/rest_sys/public/images/sort_asc.png differ
diff --git a/rest_sys/public/images/sort_desc.png b/rest_sys/public/images/sort_desc.png
new file mode 100644
index 000000000..fc80a5cc9
Binary files /dev/null and b/rest_sys/public/images/sort_desc.png differ
diff --git a/rest_sys/public/images/stats.png b/rest_sys/public/images/stats.png
new file mode 100644
index 000000000..22ae78ab4
Binary files /dev/null and b/rest_sys/public/images/stats.png differ
diff --git a/rest_sys/public/images/sticky.png b/rest_sys/public/images/sticky.png
new file mode 100644
index 000000000..d32ee63a4
Binary files /dev/null and b/rest_sys/public/images/sticky.png differ
diff --git a/rest_sys/public/images/sub.gif b/rest_sys/public/images/sub.gif
new file mode 100644
index 000000000..52e4065d5
Binary files /dev/null and b/rest_sys/public/images/sub.gif differ
diff --git a/rest_sys/public/images/task_done.png b/rest_sys/public/images/task_done.png
new file mode 100644
index 000000000..2a4c81e9d
Binary files /dev/null and b/rest_sys/public/images/task_done.png differ
diff --git a/rest_sys/public/images/task_late.png b/rest_sys/public/images/task_late.png
new file mode 100644
index 000000000..2e8a40d6e
Binary files /dev/null and b/rest_sys/public/images/task_late.png differ
diff --git a/rest_sys/public/images/task_todo.png b/rest_sys/public/images/task_todo.png
new file mode 100644
index 000000000..43c1eb9b9
Binary files /dev/null and b/rest_sys/public/images/task_todo.png differ
diff --git a/rest_sys/public/images/time.png b/rest_sys/public/images/time.png
new file mode 100644
index 000000000..81aa780e3
Binary files /dev/null and b/rest_sys/public/images/time.png differ
diff --git a/rest_sys/public/images/true.png b/rest_sys/public/images/true.png
new file mode 100644
index 000000000..7cac1eb8c
Binary files /dev/null and b/rest_sys/public/images/true.png differ
diff --git a/rest_sys/public/images/txt.png b/rest_sys/public/images/txt.png
new file mode 100644
index 000000000..2978385e7
Binary files /dev/null and b/rest_sys/public/images/txt.png differ
diff --git a/rest_sys/public/images/unlock.png b/rest_sys/public/images/unlock.png
new file mode 100644
index 000000000..e0d414978
Binary files /dev/null and b/rest_sys/public/images/unlock.png differ
diff --git a/rest_sys/public/images/user.png b/rest_sys/public/images/user.png
new file mode 100644
index 000000000..5f55e7e49
Binary files /dev/null and b/rest_sys/public/images/user.png differ
diff --git a/rest_sys/public/images/user_new.png b/rest_sys/public/images/user_new.png
new file mode 100644
index 000000000..aaa430dea
Binary files /dev/null and b/rest_sys/public/images/user_new.png differ
diff --git a/rest_sys/public/images/user_page.png b/rest_sys/public/images/user_page.png
new file mode 100644
index 000000000..78144862c
Binary files /dev/null and b/rest_sys/public/images/user_page.png differ
diff --git a/rest_sys/public/images/users.png b/rest_sys/public/images/users.png
new file mode 100644
index 000000000..f3a07c3f7
Binary files /dev/null and b/rest_sys/public/images/users.png differ
diff --git a/rest_sys/public/images/warning.png b/rest_sys/public/images/warning.png
new file mode 100644
index 000000000..bbef670b6
Binary files /dev/null and b/rest_sys/public/images/warning.png differ
diff --git a/rest_sys/public/images/zoom_in.png b/rest_sys/public/images/zoom_in.png
new file mode 100644
index 000000000..d9abe7f52
Binary files /dev/null and b/rest_sys/public/images/zoom_in.png differ
diff --git a/rest_sys/public/images/zoom_in_g.png b/rest_sys/public/images/zoom_in_g.png
new file mode 100644
index 000000000..72b271c5e
Binary files /dev/null and b/rest_sys/public/images/zoom_in_g.png differ
diff --git a/rest_sys/public/images/zoom_out.png b/rest_sys/public/images/zoom_out.png
new file mode 100644
index 000000000..906e4a4e5
Binary files /dev/null and b/rest_sys/public/images/zoom_out.png differ
diff --git a/rest_sys/public/images/zoom_out_g.png b/rest_sys/public/images/zoom_out_g.png
new file mode 100644
index 000000000..7f2416be2
Binary files /dev/null and b/rest_sys/public/images/zoom_out_g.png differ
diff --git a/rest_sys/public/javascripts/application.js b/rest_sys/public/javascripts/application.js
new file mode 100644
index 000000000..5ad04e91d
--- /dev/null
+++ b/rest_sys/public/javascripts/application.js
@@ -0,0 +1,120 @@
+function checkAll (id, checked) {
+ var el = document.getElementById(id);
+ for (var i = 0; i < el.elements.length; i++) {
+ if (el.elements[i].disabled==false) {
+ el.elements[i].checked = checked;
+ }
+ }
+}
+
+function addFileField() {
+ var f = document.createElement("input");
+ f.type = "file";
+ f.name = "attachments[]";
+ f.size = 30;
+
+ p = document.getElementById("attachments_p");
+ p.appendChild(document.createElement("br"));
+ p.appendChild(f);
+}
+
+function showTab(name) {
+ var f = $$('div#content .tab-content');
+ for(var i=0; i 0) {
+ Element.show('ajax-indicator');
+ }
+ },
+ onComplete: function(){
+ if ($('ajax-indicator') && Ajax.activeRequestCount == 0) {
+ Element.hide('ajax-indicator');
+ }
+ }
+});
diff --git a/rest_sys/public/javascripts/calendar/calendar-setup.js b/rest_sys/public/javascripts/calendar/calendar-setup.js
new file mode 100644
index 000000000..f2b485430
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/calendar-setup.js
@@ -0,0 +1,200 @@
+/* Copyright Mihai Bazon, 2002, 2003 | http://dynarch.com/mishoo/
+ * ---------------------------------------------------------------------------
+ *
+ * The DHTML Calendar
+ *
+ * Details and latest version at:
+ * http://dynarch.com/mishoo/calendar.epl
+ *
+ * This script is distributed under the GNU Lesser General Public License.
+ * Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
+ *
+ * This file defines helper functions for setting up the calendar. They are
+ * intended to help non-programmers get a working calendar on their site
+ * quickly. This script should not be seen as part of the calendar. It just
+ * shows you what one can do with the calendar, while in the same time
+ * providing a quick and simple method for setting it up. If you need
+ * exhaustive customization of the calendar creation process feel free to
+ * modify this code to suit your needs (this is recommended and much better
+ * than modifying calendar.js itself).
+ */
+
+// $Id: calendar-setup.js,v 1.25 2005/03/07 09:51:33 mishoo Exp $
+
+/**
+ * This function "patches" an input field (or other element) to use a calendar
+ * widget for date selection.
+ *
+ * The "params" is a single object that can have the following properties:
+ *
+ * prop. name | description
+ * -------------------------------------------------------------------------------------------------
+ * inputField | the ID of an input field to store the date
+ * displayArea | the ID of a DIV or other element to show the date
+ * button | ID of a button or other element that will trigger the calendar
+ * eventName | event that will trigger the calendar, without the "on" prefix (default: "click")
+ * ifFormat | date format that will be stored in the input field
+ * daFormat | the date format that will be used to display the date in displayArea
+ * singleClick | (true/false) wether the calendar is in single click mode or not (default: true)
+ * firstDay | numeric: 0 to 6. "0" means display Sunday first, "1" means display Monday first, etc.
+ * align | alignment (default: "Br"); if you don't know what's this see the calendar documentation
+ * range | array with 2 elements. Default: [1900, 2999] -- the range of years available
+ * weekNumbers | (true/false) if it's true (default) the calendar will display week numbers
+ * flat | null or element ID; if not null the calendar will be a flat calendar having the parent with the given ID
+ * flatCallback | function that receives a JS Date object and returns an URL to point the browser to (for flat calendar)
+ * disableFunc | function that receives a JS Date object and should return true if that date has to be disabled in the calendar
+ * onSelect | function that gets called when a date is selected. You don't _have_ to supply this (the default is generally okay)
+ * onClose | function that gets called when the calendar is closed. [default]
+ * onUpdate | function that gets called after the date is updated in the input field. Receives a reference to the calendar.
+ * date | the date that the calendar will be initially displayed to
+ * showsTime | default: false; if true the calendar will include a time selector
+ * timeFormat | the time format; can be "12" or "24", default is "12"
+ * electric | if true (default) then given fields/date areas are updated for each move; otherwise they're updated only on close
+ * step | configures the step of the years in drop-down boxes; default: 2
+ * position | configures the calendar absolute position; default: null
+ * cache | if "true" (but default: "false") it will reuse the same calendar object, where possible
+ * showOthers | if "true" (but default: "false") it will show days from other months too
+ *
+ * None of them is required, they all have default values. However, if you
+ * pass none of "inputField", "displayArea" or "button" you'll get a warning
+ * saying "nothing to setup".
+ */
+Calendar.setup = function (params) {
+ function param_default(pname, def) { if (typeof params[pname] == "undefined") { params[pname] = def; } };
+
+ param_default("inputField", null);
+ param_default("displayArea", null);
+ param_default("button", null);
+ param_default("eventName", "click");
+ param_default("ifFormat", "%Y/%m/%d");
+ param_default("daFormat", "%Y/%m/%d");
+ param_default("singleClick", true);
+ param_default("disableFunc", null);
+ param_default("dateStatusFunc", params["disableFunc"]); // takes precedence if both are defined
+ param_default("dateText", null);
+ param_default("firstDay", null);
+ param_default("align", "Br");
+ param_default("range", [1900, 2999]);
+ param_default("weekNumbers", true);
+ param_default("flat", null);
+ param_default("flatCallback", null);
+ param_default("onSelect", null);
+ param_default("onClose", null);
+ param_default("onUpdate", null);
+ param_default("date", null);
+ param_default("showsTime", false);
+ param_default("timeFormat", "24");
+ param_default("electric", true);
+ param_default("step", 2);
+ param_default("position", null);
+ param_default("cache", false);
+ param_default("showOthers", false);
+ param_default("multiple", null);
+
+ var tmp = ["inputField", "displayArea", "button"];
+ for (var i in tmp) {
+ if (typeof params[tmp[i]] == "string") {
+ params[tmp[i]] = document.getElementById(params[tmp[i]]);
+ }
+ }
+ if (!(params.flat || params.multiple || params.inputField || params.displayArea || params.button)) {
+ alert("Calendar.setup:\n Nothing to setup (no fields found). Please check your code");
+ return false;
+ }
+
+ function onSelect(cal) {
+ var p = cal.params;
+ var update = (cal.dateClicked || p.electric);
+ if (update && p.inputField) {
+ p.inputField.value = cal.date.print(p.ifFormat);
+ if (typeof p.inputField.onchange == "function")
+ p.inputField.onchange();
+ }
+ if (update && p.displayArea)
+ p.displayArea.innerHTML = cal.date.print(p.daFormat);
+ if (update && typeof p.onUpdate == "function")
+ p.onUpdate(cal);
+ if (update && p.flat) {
+ if (typeof p.flatCallback == "function")
+ p.flatCallback(cal);
+ }
+ if (update && p.singleClick && cal.dateClicked)
+ cal.callCloseHandler();
+ };
+
+ if (params.flat != null) {
+ if (typeof params.flat == "string")
+ params.flat = document.getElementById(params.flat);
+ if (!params.flat) {
+ alert("Calendar.setup:\n Flat specified but can't find parent.");
+ return false;
+ }
+ var cal = new Calendar(params.firstDay, params.date, params.onSelect || onSelect);
+ cal.showsOtherMonths = params.showOthers;
+ cal.showsTime = params.showsTime;
+ cal.time24 = (params.timeFormat == "24");
+ cal.params = params;
+ cal.weekNumbers = params.weekNumbers;
+ cal.setRange(params.range[0], params.range[1]);
+ cal.setDateStatusHandler(params.dateStatusFunc);
+ cal.getDateText = params.dateText;
+ if (params.ifFormat) {
+ cal.setDateFormat(params.ifFormat);
+ }
+ if (params.inputField && typeof params.inputField.value == "string") {
+ cal.parseDate(params.inputField.value);
+ }
+ cal.create(params.flat);
+ cal.show();
+ return false;
+ }
+
+ var triggerEl = params.button || params.displayArea || params.inputField;
+ triggerEl["on" + params.eventName] = function() {
+ var dateEl = params.inputField || params.displayArea;
+ var dateFmt = params.inputField ? params.ifFormat : params.daFormat;
+ var mustCreate = false;
+ var cal = window.calendar;
+ if (dateEl)
+ params.date = Date.parseDate(dateEl.value || dateEl.innerHTML, dateFmt);
+ if (!(cal && params.cache)) {
+ window.calendar = cal = new Calendar(params.firstDay,
+ params.date,
+ params.onSelect || onSelect,
+ params.onClose || function(cal) { cal.hide(); });
+ cal.showsTime = params.showsTime;
+ cal.time24 = (params.timeFormat == "24");
+ cal.weekNumbers = params.weekNumbers;
+ mustCreate = true;
+ } else {
+ if (params.date)
+ cal.setDate(params.date);
+ cal.hide();
+ }
+ if (params.multiple) {
+ cal.multiple = {};
+ for (var i = params.multiple.length; --i >= 0;) {
+ var d = params.multiple[i];
+ var ds = d.print("%Y%m%d");
+ cal.multiple[ds] = d;
+ }
+ }
+ cal.showsOtherMonths = params.showOthers;
+ cal.yearStep = params.step;
+ cal.setRange(params.range[0], params.range[1]);
+ cal.params = params;
+ cal.setDateStatusHandler(params.dateStatusFunc);
+ cal.getDateText = params.dateText;
+ cal.setDateFormat(dateFmt);
+ if (mustCreate)
+ cal.create();
+ cal.refresh();
+ if (!params.position)
+ cal.showAtElement(params.button || params.displayArea || params.inputField, params.align);
+ else
+ cal.showAt(params.position[0], params.position[1]);
+ return false;
+ };
+
+ return cal;
+};
diff --git a/rest_sys/public/javascripts/calendar/calendar.js b/rest_sys/public/javascripts/calendar/calendar.js
new file mode 100644
index 000000000..9088e0e89
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/calendar.js
@@ -0,0 +1,1806 @@
+/* Copyright Mihai Bazon, 2002-2005 | www.bazon.net/mishoo
+ * -----------------------------------------------------------
+ *
+ * The DHTML Calendar, version 1.0 "It is happening again"
+ *
+ * Details and latest version at:
+ * www.dynarch.com/projects/calendar
+ *
+ * This script is developed by Dynarch.com. Visit us at www.dynarch.com.
+ *
+ * This script is distributed under the GNU Lesser General Public License.
+ * Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
+ */
+
+// $Id: calendar.js,v 1.51 2005/03/07 16:44:31 mishoo Exp $
+
+/** The Calendar object constructor. */
+Calendar = function (firstDayOfWeek, dateStr, onSelected, onClose) {
+ // member variables
+ this.activeDiv = null;
+ this.currentDateEl = null;
+ this.getDateStatus = null;
+ this.getDateToolTip = null;
+ this.getDateText = null;
+ this.timeout = null;
+ this.onSelected = onSelected || null;
+ this.onClose = onClose || null;
+ this.dragging = false;
+ this.hidden = false;
+ this.minYear = 1970;
+ this.maxYear = 2050;
+ this.dateFormat = Calendar._TT["DEF_DATE_FORMAT"];
+ this.ttDateFormat = Calendar._TT["TT_DATE_FORMAT"];
+ this.isPopup = true;
+ this.weekNumbers = true;
+ this.firstDayOfWeek = typeof firstDayOfWeek == "number" ? firstDayOfWeek : Calendar._FD; // 0 for Sunday, 1 for Monday, etc.
+ this.showsOtherMonths = false;
+ this.dateStr = dateStr;
+ this.ar_days = null;
+ this.showsTime = false;
+ this.time24 = true;
+ this.yearStep = 2;
+ this.hiliteToday = true;
+ this.multiple = null;
+ // HTML elements
+ this.table = null;
+ this.element = null;
+ this.tbody = null;
+ this.firstdayname = null;
+ // Combo boxes
+ this.monthsCombo = null;
+ this.yearsCombo = null;
+ this.hilitedMonth = null;
+ this.activeMonth = null;
+ this.hilitedYear = null;
+ this.activeYear = null;
+ // Information
+ this.dateClicked = false;
+
+ // one-time initializations
+ if (typeof Calendar._SDN == "undefined") {
+ // table of short day names
+ if (typeof Calendar._SDN_len == "undefined")
+ Calendar._SDN_len = 3;
+ var ar = new Array();
+ for (var i = 8; i > 0;) {
+ ar[--i] = Calendar._DN[i].substr(0, Calendar._SDN_len);
+ }
+ Calendar._SDN = ar;
+ // table of short month names
+ if (typeof Calendar._SMN_len == "undefined")
+ Calendar._SMN_len = 3;
+ ar = new Array();
+ for (var i = 12; i > 0;) {
+ ar[--i] = Calendar._MN[i].substr(0, Calendar._SMN_len);
+ }
+ Calendar._SMN = ar;
+ }
+};
+
+// ** constants
+
+/// "static", needed for event handlers.
+Calendar._C = null;
+
+/// detect a special case of "web browser"
+Calendar.is_ie = ( /msie/i.test(navigator.userAgent) &&
+ !/opera/i.test(navigator.userAgent) );
+
+Calendar.is_ie5 = ( Calendar.is_ie && /msie 5\.0/i.test(navigator.userAgent) );
+
+/// detect Opera browser
+Calendar.is_opera = /opera/i.test(navigator.userAgent);
+
+/// detect KHTML-based browsers
+Calendar.is_khtml = /Konqueror|Safari|KHTML/i.test(navigator.userAgent);
+
+// BEGIN: UTILITY FUNCTIONS; beware that these might be moved into a separate
+// library, at some point.
+
+Calendar.getAbsolutePos = function(el) {
+ var SL = 0, ST = 0;
+ var is_div = /^div$/i.test(el.tagName);
+ if (is_div && el.scrollLeft)
+ SL = el.scrollLeft;
+ if (is_div && el.scrollTop)
+ ST = el.scrollTop;
+ var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
+ if (el.offsetParent) {
+ var tmp = this.getAbsolutePos(el.offsetParent);
+ r.x += tmp.x;
+ r.y += tmp.y;
+ }
+ return r;
+};
+
+Calendar.isRelated = function (el, evt) {
+ var related = evt.relatedTarget;
+ if (!related) {
+ var type = evt.type;
+ if (type == "mouseover") {
+ related = evt.fromElement;
+ } else if (type == "mouseout") {
+ related = evt.toElement;
+ }
+ }
+ while (related) {
+ if (related == el) {
+ return true;
+ }
+ related = related.parentNode;
+ }
+ return false;
+};
+
+Calendar.removeClass = function(el, className) {
+ if (!(el && el.className)) {
+ return;
+ }
+ var cls = el.className.split(" ");
+ var ar = new Array();
+ for (var i = cls.length; i > 0;) {
+ if (cls[--i] != className) {
+ ar[ar.length] = cls[i];
+ }
+ }
+ el.className = ar.join(" ");
+};
+
+Calendar.addClass = function(el, className) {
+ Calendar.removeClass(el, className);
+ el.className += " " + className;
+};
+
+// FIXME: the following 2 functions totally suck, are useless and should be replaced immediately.
+Calendar.getElement = function(ev) {
+ var f = Calendar.is_ie ? window.event.srcElement : ev.currentTarget;
+ while (f.nodeType != 1 || /^div$/i.test(f.tagName))
+ f = f.parentNode;
+ return f;
+};
+
+Calendar.getTargetElement = function(ev) {
+ var f = Calendar.is_ie ? window.event.srcElement : ev.target;
+ while (f.nodeType != 1)
+ f = f.parentNode;
+ return f;
+};
+
+Calendar.stopEvent = function(ev) {
+ ev || (ev = window.event);
+ if (Calendar.is_ie) {
+ ev.cancelBubble = true;
+ ev.returnValue = false;
+ } else {
+ ev.preventDefault();
+ ev.stopPropagation();
+ }
+ return false;
+};
+
+Calendar.addEvent = function(el, evname, func) {
+ if (el.attachEvent) { // IE
+ el.attachEvent("on" + evname, func);
+ } else if (el.addEventListener) { // Gecko / W3C
+ el.addEventListener(evname, func, true);
+ } else {
+ el["on" + evname] = func;
+ }
+};
+
+Calendar.removeEvent = function(el, evname, func) {
+ if (el.detachEvent) { // IE
+ el.detachEvent("on" + evname, func);
+ } else if (el.removeEventListener) { // Gecko / W3C
+ el.removeEventListener(evname, func, true);
+ } else {
+ el["on" + evname] = null;
+ }
+};
+
+Calendar.createElement = function(type, parent) {
+ var el = null;
+ if (document.createElementNS) {
+ // use the XHTML namespace; IE won't normally get here unless
+ // _they_ "fix" the DOM2 implementation.
+ el = document.createElementNS("http://www.w3.org/1999/xhtml", type);
+ } else {
+ el = document.createElement(type);
+ }
+ if (typeof parent != "undefined") {
+ parent.appendChild(el);
+ }
+ return el;
+};
+
+// END: UTILITY FUNCTIONS
+
+// BEGIN: CALENDAR STATIC FUNCTIONS
+
+/** Internal -- adds a set of events to make some element behave like a button. */
+Calendar._add_evs = function(el) {
+ with (Calendar) {
+ addEvent(el, "mouseover", dayMouseOver);
+ addEvent(el, "mousedown", dayMouseDown);
+ addEvent(el, "mouseout", dayMouseOut);
+ if (is_ie) {
+ addEvent(el, "dblclick", dayMouseDblClick);
+ el.setAttribute("unselectable", true);
+ }
+ }
+};
+
+Calendar.findMonth = function(el) {
+ if (typeof el.month != "undefined") {
+ return el;
+ } else if (typeof el.parentNode.month != "undefined") {
+ return el.parentNode;
+ }
+ return null;
+};
+
+Calendar.findYear = function(el) {
+ if (typeof el.year != "undefined") {
+ return el;
+ } else if (typeof el.parentNode.year != "undefined") {
+ return el.parentNode;
+ }
+ return null;
+};
+
+Calendar.showMonthsCombo = function () {
+ var cal = Calendar._C;
+ if (!cal) {
+ return false;
+ }
+ var cal = cal;
+ var cd = cal.activeDiv;
+ var mc = cal.monthsCombo;
+ if (cal.hilitedMonth) {
+ Calendar.removeClass(cal.hilitedMonth, "hilite");
+ }
+ if (cal.activeMonth) {
+ Calendar.removeClass(cal.activeMonth, "active");
+ }
+ var mon = cal.monthsCombo.getElementsByTagName("div")[cal.date.getMonth()];
+ Calendar.addClass(mon, "active");
+ cal.activeMonth = mon;
+ var s = mc.style;
+ s.display = "block";
+ if (cd.navtype < 0)
+ s.left = cd.offsetLeft + "px";
+ else {
+ var mcw = mc.offsetWidth;
+ if (typeof mcw == "undefined")
+ // Konqueror brain-dead techniques
+ mcw = 50;
+ s.left = (cd.offsetLeft + cd.offsetWidth - mcw) + "px";
+ }
+ s.top = (cd.offsetTop + cd.offsetHeight) + "px";
+};
+
+Calendar.showYearsCombo = function (fwd) {
+ var cal = Calendar._C;
+ if (!cal) {
+ return false;
+ }
+ var cal = cal;
+ var cd = cal.activeDiv;
+ var yc = cal.yearsCombo;
+ if (cal.hilitedYear) {
+ Calendar.removeClass(cal.hilitedYear, "hilite");
+ }
+ if (cal.activeYear) {
+ Calendar.removeClass(cal.activeYear, "active");
+ }
+ cal.activeYear = null;
+ var Y = cal.date.getFullYear() + (fwd ? 1 : -1);
+ var yr = yc.firstChild;
+ var show = false;
+ for (var i = 12; i > 0; --i) {
+ if (Y >= cal.minYear && Y <= cal.maxYear) {
+ yr.innerHTML = Y;
+ yr.year = Y;
+ yr.style.display = "block";
+ show = true;
+ } else {
+ yr.style.display = "none";
+ }
+ yr = yr.nextSibling;
+ Y += fwd ? cal.yearStep : -cal.yearStep;
+ }
+ if (show) {
+ var s = yc.style;
+ s.display = "block";
+ if (cd.navtype < 0)
+ s.left = cd.offsetLeft + "px";
+ else {
+ var ycw = yc.offsetWidth;
+ if (typeof ycw == "undefined")
+ // Konqueror brain-dead techniques
+ ycw = 50;
+ s.left = (cd.offsetLeft + cd.offsetWidth - ycw) + "px";
+ }
+ s.top = (cd.offsetTop + cd.offsetHeight) + "px";
+ }
+};
+
+// event handlers
+
+Calendar.tableMouseUp = function(ev) {
+ var cal = Calendar._C;
+ if (!cal) {
+ return false;
+ }
+ if (cal.timeout) {
+ clearTimeout(cal.timeout);
+ }
+ var el = cal.activeDiv;
+ if (!el) {
+ return false;
+ }
+ var target = Calendar.getTargetElement(ev);
+ ev || (ev = window.event);
+ Calendar.removeClass(el, "active");
+ if (target == el || target.parentNode == el) {
+ Calendar.cellClick(el, ev);
+ }
+ var mon = Calendar.findMonth(target);
+ var date = null;
+ if (mon) {
+ date = new Date(cal.date);
+ if (mon.month != date.getMonth()) {
+ date.setMonth(mon.month);
+ cal.setDate(date);
+ cal.dateClicked = false;
+ cal.callHandler();
+ }
+ } else {
+ var year = Calendar.findYear(target);
+ if (year) {
+ date = new Date(cal.date);
+ if (year.year != date.getFullYear()) {
+ date.setFullYear(year.year);
+ cal.setDate(date);
+ cal.dateClicked = false;
+ cal.callHandler();
+ }
+ }
+ }
+ with (Calendar) {
+ removeEvent(document, "mouseup", tableMouseUp);
+ removeEvent(document, "mouseover", tableMouseOver);
+ removeEvent(document, "mousemove", tableMouseOver);
+ cal._hideCombos();
+ _C = null;
+ return stopEvent(ev);
+ }
+};
+
+Calendar.tableMouseOver = function (ev) {
+ var cal = Calendar._C;
+ if (!cal) {
+ return;
+ }
+ var el = cal.activeDiv;
+ var target = Calendar.getTargetElement(ev);
+ if (target == el || target.parentNode == el) {
+ Calendar.addClass(el, "hilite active");
+ Calendar.addClass(el.parentNode, "rowhilite");
+ } else {
+ if (typeof el.navtype == "undefined" || (el.navtype != 50 && (el.navtype == 0 || Math.abs(el.navtype) > 2)))
+ Calendar.removeClass(el, "active");
+ Calendar.removeClass(el, "hilite");
+ Calendar.removeClass(el.parentNode, "rowhilite");
+ }
+ ev || (ev = window.event);
+ if (el.navtype == 50 && target != el) {
+ var pos = Calendar.getAbsolutePos(el);
+ var w = el.offsetWidth;
+ var x = ev.clientX;
+ var dx;
+ var decrease = true;
+ if (x > pos.x + w) {
+ dx = x - pos.x - w;
+ decrease = false;
+ } else
+ dx = pos.x - x;
+
+ if (dx < 0) dx = 0;
+ var range = el._range;
+ var current = el._current;
+ var count = Math.floor(dx / 10) % range.length;
+ for (var i = range.length; --i >= 0;)
+ if (range[i] == current)
+ break;
+ while (count-- > 0)
+ if (decrease) {
+ if (--i < 0)
+ i = range.length - 1;
+ } else if ( ++i >= range.length )
+ i = 0;
+ var newval = range[i];
+ el.innerHTML = newval;
+
+ cal.onUpdateTime();
+ }
+ var mon = Calendar.findMonth(target);
+ if (mon) {
+ if (mon.month != cal.date.getMonth()) {
+ if (cal.hilitedMonth) {
+ Calendar.removeClass(cal.hilitedMonth, "hilite");
+ }
+ Calendar.addClass(mon, "hilite");
+ cal.hilitedMonth = mon;
+ } else if (cal.hilitedMonth) {
+ Calendar.removeClass(cal.hilitedMonth, "hilite");
+ }
+ } else {
+ if (cal.hilitedMonth) {
+ Calendar.removeClass(cal.hilitedMonth, "hilite");
+ }
+ var year = Calendar.findYear(target);
+ if (year) {
+ if (year.year != cal.date.getFullYear()) {
+ if (cal.hilitedYear) {
+ Calendar.removeClass(cal.hilitedYear, "hilite");
+ }
+ Calendar.addClass(year, "hilite");
+ cal.hilitedYear = year;
+ } else if (cal.hilitedYear) {
+ Calendar.removeClass(cal.hilitedYear, "hilite");
+ }
+ } else if (cal.hilitedYear) {
+ Calendar.removeClass(cal.hilitedYear, "hilite");
+ }
+ }
+ return Calendar.stopEvent(ev);
+};
+
+Calendar.tableMouseDown = function (ev) {
+ if (Calendar.getTargetElement(ev) == Calendar.getElement(ev)) {
+ return Calendar.stopEvent(ev);
+ }
+};
+
+Calendar.calDragIt = function (ev) {
+ var cal = Calendar._C;
+ if (!(cal && cal.dragging)) {
+ return false;
+ }
+ var posX;
+ var posY;
+ if (Calendar.is_ie) {
+ posY = window.event.clientY + document.body.scrollTop;
+ posX = window.event.clientX + document.body.scrollLeft;
+ } else {
+ posX = ev.pageX;
+ posY = ev.pageY;
+ }
+ cal.hideShowCovered();
+ var st = cal.element.style;
+ st.left = (posX - cal.xOffs) + "px";
+ st.top = (posY - cal.yOffs) + "px";
+ return Calendar.stopEvent(ev);
+};
+
+Calendar.calDragEnd = function (ev) {
+ var cal = Calendar._C;
+ if (!cal) {
+ return false;
+ }
+ cal.dragging = false;
+ with (Calendar) {
+ removeEvent(document, "mousemove", calDragIt);
+ removeEvent(document, "mouseup", calDragEnd);
+ tableMouseUp(ev);
+ }
+ cal.hideShowCovered();
+};
+
+Calendar.dayMouseDown = function(ev) {
+ var el = Calendar.getElement(ev);
+ if (el.disabled) {
+ return false;
+ }
+ var cal = el.calendar;
+ cal.activeDiv = el;
+ Calendar._C = cal;
+ if (el.navtype != 300) with (Calendar) {
+ if (el.navtype == 50) {
+ el._current = el.innerHTML;
+ addEvent(document, "mousemove", tableMouseOver);
+ } else
+ addEvent(document, Calendar.is_ie5 ? "mousemove" : "mouseover", tableMouseOver);
+ addClass(el, "hilite active");
+ addEvent(document, "mouseup", tableMouseUp);
+ } else if (cal.isPopup) {
+ cal._dragStart(ev);
+ }
+ if (el.navtype == -1 || el.navtype == 1) {
+ if (cal.timeout) clearTimeout(cal.timeout);
+ cal.timeout = setTimeout("Calendar.showMonthsCombo()", 250);
+ } else if (el.navtype == -2 || el.navtype == 2) {
+ if (cal.timeout) clearTimeout(cal.timeout);
+ cal.timeout = setTimeout((el.navtype > 0) ? "Calendar.showYearsCombo(true)" : "Calendar.showYearsCombo(false)", 250);
+ } else {
+ cal.timeout = null;
+ }
+ return Calendar.stopEvent(ev);
+};
+
+Calendar.dayMouseDblClick = function(ev) {
+ Calendar.cellClick(Calendar.getElement(ev), ev || window.event);
+ if (Calendar.is_ie) {
+ document.selection.empty();
+ }
+};
+
+Calendar.dayMouseOver = function(ev) {
+ var el = Calendar.getElement(ev);
+ if (Calendar.isRelated(el, ev) || Calendar._C || el.disabled) {
+ return false;
+ }
+ if (el.ttip) {
+ if (el.ttip.substr(0, 1) == "_") {
+ el.ttip = el.caldate.print(el.calendar.ttDateFormat) + el.ttip.substr(1);
+ }
+ el.calendar.tooltips.innerHTML = el.ttip;
+ }
+ if (el.navtype != 300) {
+ Calendar.addClass(el, "hilite");
+ if (el.caldate) {
+ Calendar.addClass(el.parentNode, "rowhilite");
+ }
+ }
+ return Calendar.stopEvent(ev);
+};
+
+Calendar.dayMouseOut = function(ev) {
+ with (Calendar) {
+ var el = getElement(ev);
+ if (isRelated(el, ev) || _C || el.disabled)
+ return false;
+ removeClass(el, "hilite");
+ if (el.caldate)
+ removeClass(el.parentNode, "rowhilite");
+ if (el.calendar)
+ el.calendar.tooltips.innerHTML = _TT["SEL_DATE"];
+ return stopEvent(ev);
+ }
+};
+
+/**
+ * A generic "click" handler :) handles all types of buttons defined in this
+ * calendar.
+ */
+Calendar.cellClick = function(el, ev) {
+ var cal = el.calendar;
+ var closing = false;
+ var newdate = false;
+ var date = null;
+ if (typeof el.navtype == "undefined") {
+ if (cal.currentDateEl) {
+ Calendar.removeClass(cal.currentDateEl, "selected");
+ Calendar.addClass(el, "selected");
+ closing = (cal.currentDateEl == el);
+ if (!closing) {
+ cal.currentDateEl = el;
+ }
+ }
+ cal.date.setDateOnly(el.caldate);
+ date = cal.date;
+ var other_month = !(cal.dateClicked = !el.otherMonth);
+ if (!other_month && !cal.currentDateEl)
+ cal._toggleMultipleDate(new Date(date));
+ else
+ newdate = !el.disabled;
+ // a date was clicked
+ if (other_month)
+ cal._init(cal.firstDayOfWeek, date);
+ } else {
+ if (el.navtype == 200) {
+ Calendar.removeClass(el, "hilite");
+ cal.callCloseHandler();
+ return;
+ }
+ date = new Date(cal.date);
+ if (el.navtype == 0)
+ date.setDateOnly(new Date()); // TODAY
+ // unless "today" was clicked, we assume no date was clicked so
+ // the selected handler will know not to close the calenar when
+ // in single-click mode.
+ // cal.dateClicked = (el.navtype == 0);
+ cal.dateClicked = false;
+ var year = date.getFullYear();
+ var mon = date.getMonth();
+ function setMonth(m) {
+ var day = date.getDate();
+ var max = date.getMonthDays(m);
+ if (day > max) {
+ date.setDate(max);
+ }
+ date.setMonth(m);
+ };
+ switch (el.navtype) {
+ case 400:
+ Calendar.removeClass(el, "hilite");
+ var text = Calendar._TT["ABOUT"];
+ if (typeof text != "undefined") {
+ text += cal.showsTime ? Calendar._TT["ABOUT_TIME"] : "";
+ } else {
+ // FIXME: this should be removed as soon as lang files get updated!
+ text = "Help and about box text is not translated into this language.\n" +
+ "If you know this language and you feel generous please update\n" +
+ "the corresponding file in \"lang\" subdir to match calendar-en.js\n" +
+ "and send it back to to get it into the distribution ;-)\n\n" +
+ "Thank you!\n" +
+ "http://dynarch.com/mishoo/calendar.epl\n";
+ }
+ alert(text);
+ return;
+ case -2:
+ if (year > cal.minYear) {
+ date.setFullYear(year - 1);
+ }
+ break;
+ case -1:
+ if (mon > 0) {
+ setMonth(mon - 1);
+ } else if (year-- > cal.minYear) {
+ date.setFullYear(year);
+ setMonth(11);
+ }
+ break;
+ case 1:
+ if (mon < 11) {
+ setMonth(mon + 1);
+ } else if (year < cal.maxYear) {
+ date.setFullYear(year + 1);
+ setMonth(0);
+ }
+ break;
+ case 2:
+ if (year < cal.maxYear) {
+ date.setFullYear(year + 1);
+ }
+ break;
+ case 100:
+ cal.setFirstDayOfWeek(el.fdow);
+ return;
+ case 50:
+ var range = el._range;
+ var current = el.innerHTML;
+ for (var i = range.length; --i >= 0;)
+ if (range[i] == current)
+ break;
+ if (ev && ev.shiftKey) {
+ if (--i < 0)
+ i = range.length - 1;
+ } else if ( ++i >= range.length )
+ i = 0;
+ var newval = range[i];
+ el.innerHTML = newval;
+ cal.onUpdateTime();
+ return;
+ case 0:
+ // TODAY will bring us here
+ if ((typeof cal.getDateStatus == "function") &&
+ cal.getDateStatus(date, date.getFullYear(), date.getMonth(), date.getDate())) {
+ return false;
+ }
+ break;
+ }
+ if (!date.equalsTo(cal.date)) {
+ cal.setDate(date);
+ newdate = true;
+ } else if (el.navtype == 0)
+ newdate = closing = true;
+ }
+ if (newdate) {
+ ev && cal.callHandler();
+ }
+ if (closing) {
+ Calendar.removeClass(el, "hilite");
+ ev && cal.callCloseHandler();
+ }
+};
+
+// END: CALENDAR STATIC FUNCTIONS
+
+// BEGIN: CALENDAR OBJECT FUNCTIONS
+
+/**
+ * This function creates the calendar inside the given parent. If _par is
+ * null than it creates a popup calendar inside the BODY element. If _par is
+ * an element, be it BODY, then it creates a non-popup calendar (still
+ * hidden). Some properties need to be set before calling this function.
+ */
+Calendar.prototype.create = function (_par) {
+ var parent = null;
+ if (! _par) {
+ // default parent is the document body, in which case we create
+ // a popup calendar.
+ parent = document.getElementsByTagName("body")[0];
+ this.isPopup = true;
+ } else {
+ parent = _par;
+ this.isPopup = false;
+ }
+ this.date = this.dateStr ? new Date(this.dateStr) : new Date();
+
+ var table = Calendar.createElement("table");
+ this.table = table;
+ table.cellSpacing = 0;
+ table.cellPadding = 0;
+ table.calendar = this;
+ Calendar.addEvent(table, "mousedown", Calendar.tableMouseDown);
+
+ var div = Calendar.createElement("div");
+ this.element = div;
+ div.className = "calendar";
+ if (this.isPopup) {
+ div.style.position = "absolute";
+ div.style.display = "none";
+ }
+ div.appendChild(table);
+
+ var thead = Calendar.createElement("thead", table);
+ var cell = null;
+ var row = null;
+
+ var cal = this;
+ var hh = function (text, cs, navtype) {
+ cell = Calendar.createElement("td", row);
+ cell.colSpan = cs;
+ cell.className = "button";
+ if (navtype != 0 && Math.abs(navtype) <= 2)
+ cell.className += " nav";
+ Calendar._add_evs(cell);
+ cell.calendar = cal;
+ cell.navtype = navtype;
+ cell.innerHTML = "" + text + "
";
+ return cell;
+ };
+
+ row = Calendar.createElement("tr", thead);
+ var title_length = 6;
+ (this.isPopup) && --title_length;
+ (this.weekNumbers) && ++title_length;
+
+ hh("?", 1, 400).ttip = Calendar._TT["INFO"];
+ this.title = hh("", title_length, 300);
+ this.title.className = "title";
+ if (this.isPopup) {
+ this.title.ttip = Calendar._TT["DRAG_TO_MOVE"];
+ this.title.style.cursor = "move";
+ hh("×", 1, 200).ttip = Calendar._TT["CLOSE"];
+ }
+
+ row = Calendar.createElement("tr", thead);
+ row.className = "headrow";
+
+ this._nav_py = hh("«", 1, -2);
+ this._nav_py.ttip = Calendar._TT["PREV_YEAR"];
+
+ this._nav_pm = hh("‹", 1, -1);
+ this._nav_pm.ttip = Calendar._TT["PREV_MONTH"];
+
+ this._nav_now = hh(Calendar._TT["TODAY"], this.weekNumbers ? 4 : 3, 0);
+ this._nav_now.ttip = Calendar._TT["GO_TODAY"];
+
+ this._nav_nm = hh("›", 1, 1);
+ this._nav_nm.ttip = Calendar._TT["NEXT_MONTH"];
+
+ this._nav_ny = hh("»", 1, 2);
+ this._nav_ny.ttip = Calendar._TT["NEXT_YEAR"];
+
+ // day names
+ row = Calendar.createElement("tr", thead);
+ row.className = "daynames";
+ if (this.weekNumbers) {
+ cell = Calendar.createElement("td", row);
+ cell.className = "name wn";
+ cell.innerHTML = Calendar._TT["WK"];
+ }
+ for (var i = 7; i > 0; --i) {
+ cell = Calendar.createElement("td", row);
+ if (!i) {
+ cell.navtype = 100;
+ cell.calendar = this;
+ Calendar._add_evs(cell);
+ }
+ }
+ this.firstdayname = (this.weekNumbers) ? row.firstChild.nextSibling : row.firstChild;
+ this._displayWeekdays();
+
+ var tbody = Calendar.createElement("tbody", table);
+ this.tbody = tbody;
+
+ for (i = 6; i > 0; --i) {
+ row = Calendar.createElement("tr", tbody);
+ if (this.weekNumbers) {
+ cell = Calendar.createElement("td", row);
+ }
+ for (var j = 7; j > 0; --j) {
+ cell = Calendar.createElement("td", row);
+ cell.calendar = this;
+ Calendar._add_evs(cell);
+ }
+ }
+
+ if (this.showsTime) {
+ row = Calendar.createElement("tr", tbody);
+ row.className = "time";
+
+ cell = Calendar.createElement("td", row);
+ cell.className = "time";
+ cell.colSpan = 2;
+ cell.innerHTML = Calendar._TT["TIME"] || " ";
+
+ cell = Calendar.createElement("td", row);
+ cell.className = "time";
+ cell.colSpan = this.weekNumbers ? 4 : 3;
+
+ (function(){
+ function makeTimePart(className, init, range_start, range_end) {
+ var part = Calendar.createElement("span", cell);
+ part.className = className;
+ part.innerHTML = init;
+ part.calendar = cal;
+ part.ttip = Calendar._TT["TIME_PART"];
+ part.navtype = 50;
+ part._range = [];
+ if (typeof range_start != "number")
+ part._range = range_start;
+ else {
+ for (var i = range_start; i <= range_end; ++i) {
+ var txt;
+ if (i < 10 && range_end >= 10) txt = '0' + i;
+ else txt = '' + i;
+ part._range[part._range.length] = txt;
+ }
+ }
+ Calendar._add_evs(part);
+ return part;
+ };
+ var hrs = cal.date.getHours();
+ var mins = cal.date.getMinutes();
+ var t12 = !cal.time24;
+ var pm = (hrs > 12);
+ if (t12 && pm) hrs -= 12;
+ var H = makeTimePart("hour", hrs, t12 ? 1 : 0, t12 ? 12 : 23);
+ var span = Calendar.createElement("span", cell);
+ span.innerHTML = ":";
+ span.className = "colon";
+ var M = makeTimePart("minute", mins, 0, 59);
+ var AP = null;
+ cell = Calendar.createElement("td", row);
+ cell.className = "time";
+ cell.colSpan = 2;
+ if (t12)
+ AP = makeTimePart("ampm", pm ? "pm" : "am", ["am", "pm"]);
+ else
+ cell.innerHTML = " ";
+
+ cal.onSetTime = function() {
+ var pm, hrs = this.date.getHours(),
+ mins = this.date.getMinutes();
+ if (t12) {
+ pm = (hrs >= 12);
+ if (pm) hrs -= 12;
+ if (hrs == 0) hrs = 12;
+ AP.innerHTML = pm ? "pm" : "am";
+ }
+ H.innerHTML = (hrs < 10) ? ("0" + hrs) : hrs;
+ M.innerHTML = (mins < 10) ? ("0" + mins) : mins;
+ };
+
+ cal.onUpdateTime = function() {
+ var date = this.date;
+ var h = parseInt(H.innerHTML, 10);
+ if (t12) {
+ if (/pm/i.test(AP.innerHTML) && h < 12)
+ h += 12;
+ else if (/am/i.test(AP.innerHTML) && h == 12)
+ h = 0;
+ }
+ var d = date.getDate();
+ var m = date.getMonth();
+ var y = date.getFullYear();
+ date.setHours(h);
+ date.setMinutes(parseInt(M.innerHTML, 10));
+ date.setFullYear(y);
+ date.setMonth(m);
+ date.setDate(d);
+ this.dateClicked = false;
+ this.callHandler();
+ };
+ })();
+ } else {
+ this.onSetTime = this.onUpdateTime = function() {};
+ }
+
+ var tfoot = Calendar.createElement("tfoot", table);
+
+ row = Calendar.createElement("tr", tfoot);
+ row.className = "footrow";
+
+ cell = hh(Calendar._TT["SEL_DATE"], this.weekNumbers ? 8 : 7, 300);
+ cell.className = "ttip";
+ if (this.isPopup) {
+ cell.ttip = Calendar._TT["DRAG_TO_MOVE"];
+ cell.style.cursor = "move";
+ }
+ this.tooltips = cell;
+
+ div = Calendar.createElement("div", this.element);
+ this.monthsCombo = div;
+ div.className = "combo";
+ for (i = 0; i < Calendar._MN.length; ++i) {
+ var mn = Calendar.createElement("div");
+ mn.className = Calendar.is_ie ? "label-IEfix" : "label";
+ mn.month = i;
+ mn.innerHTML = Calendar._SMN[i];
+ div.appendChild(mn);
+ }
+
+ div = Calendar.createElement("div", this.element);
+ this.yearsCombo = div;
+ div.className = "combo";
+ for (i = 12; i > 0; --i) {
+ var yr = Calendar.createElement("div");
+ yr.className = Calendar.is_ie ? "label-IEfix" : "label";
+ div.appendChild(yr);
+ }
+
+ this._init(this.firstDayOfWeek, this.date);
+ parent.appendChild(this.element);
+};
+
+/** keyboard navigation, only for popup calendars */
+Calendar._keyEvent = function(ev) {
+ var cal = window._dynarch_popupCalendar;
+ if (!cal || cal.multiple)
+ return false;
+ (Calendar.is_ie) && (ev = window.event);
+ var act = (Calendar.is_ie || ev.type == "keypress"),
+ K = ev.keyCode;
+ if (ev.ctrlKey) {
+ switch (K) {
+ case 37: // KEY left
+ act && Calendar.cellClick(cal._nav_pm);
+ break;
+ case 38: // KEY up
+ act && Calendar.cellClick(cal._nav_py);
+ break;
+ case 39: // KEY right
+ act && Calendar.cellClick(cal._nav_nm);
+ break;
+ case 40: // KEY down
+ act && Calendar.cellClick(cal._nav_ny);
+ break;
+ default:
+ return false;
+ }
+ } else switch (K) {
+ case 32: // KEY space (now)
+ Calendar.cellClick(cal._nav_now);
+ break;
+ case 27: // KEY esc
+ act && cal.callCloseHandler();
+ break;
+ case 37: // KEY left
+ case 38: // KEY up
+ case 39: // KEY right
+ case 40: // KEY down
+ if (act) {
+ var prev, x, y, ne, el, step;
+ prev = K == 37 || K == 38;
+ step = (K == 37 || K == 39) ? 1 : 7;
+ function setVars() {
+ el = cal.currentDateEl;
+ var p = el.pos;
+ x = p & 15;
+ y = p >> 4;
+ ne = cal.ar_days[y][x];
+ };setVars();
+ function prevMonth() {
+ var date = new Date(cal.date);
+ date.setDate(date.getDate() - step);
+ cal.setDate(date);
+ };
+ function nextMonth() {
+ var date = new Date(cal.date);
+ date.setDate(date.getDate() + step);
+ cal.setDate(date);
+ };
+ while (1) {
+ switch (K) {
+ case 37: // KEY left
+ if (--x >= 0)
+ ne = cal.ar_days[y][x];
+ else {
+ x = 6;
+ K = 38;
+ continue;
+ }
+ break;
+ case 38: // KEY up
+ if (--y >= 0)
+ ne = cal.ar_days[y][x];
+ else {
+ prevMonth();
+ setVars();
+ }
+ break;
+ case 39: // KEY right
+ if (++x < 7)
+ ne = cal.ar_days[y][x];
+ else {
+ x = 0;
+ K = 40;
+ continue;
+ }
+ break;
+ case 40: // KEY down
+ if (++y < cal.ar_days.length)
+ ne = cal.ar_days[y][x];
+ else {
+ nextMonth();
+ setVars();
+ }
+ break;
+ }
+ break;
+ }
+ if (ne) {
+ if (!ne.disabled)
+ Calendar.cellClick(ne);
+ else if (prev)
+ prevMonth();
+ else
+ nextMonth();
+ }
+ }
+ break;
+ case 13: // KEY enter
+ if (act)
+ Calendar.cellClick(cal.currentDateEl, ev);
+ break;
+ default:
+ return false;
+ }
+ return Calendar.stopEvent(ev);
+};
+
+/**
+ * (RE)Initializes the calendar to the given date and firstDayOfWeek
+ */
+Calendar.prototype._init = function (firstDayOfWeek, date) {
+ var today = new Date(),
+ TY = today.getFullYear(),
+ TM = today.getMonth(),
+ TD = today.getDate();
+ this.table.style.visibility = "hidden";
+ var year = date.getFullYear();
+ if (year < this.minYear) {
+ year = this.minYear;
+ date.setFullYear(year);
+ } else if (year > this.maxYear) {
+ year = this.maxYear;
+ date.setFullYear(year);
+ }
+ this.firstDayOfWeek = firstDayOfWeek;
+ this.date = new Date(date);
+ var month = date.getMonth();
+ var mday = date.getDate();
+ var no_days = date.getMonthDays();
+
+ // calendar voodoo for computing the first day that would actually be
+ // displayed in the calendar, even if it's from the previous month.
+ // WARNING: this is magic. ;-)
+ date.setDate(1);
+ var day1 = (date.getDay() - this.firstDayOfWeek) % 7;
+ if (day1 < 0)
+ day1 += 7;
+ date.setDate(-day1);
+ date.setDate(date.getDate() + 1);
+
+ var row = this.tbody.firstChild;
+ var MN = Calendar._SMN[month];
+ var ar_days = this.ar_days = new Array();
+ var weekend = Calendar._TT["WEEKEND"];
+ var dates = this.multiple ? (this.datesCells = {}) : null;
+ for (var i = 0; i < 6; ++i, row = row.nextSibling) {
+ var cell = row.firstChild;
+ if (this.weekNumbers) {
+ cell.className = "day wn";
+ cell.innerHTML = date.getWeekNumber();
+ cell = cell.nextSibling;
+ }
+ row.className = "daysrow";
+ var hasdays = false, iday, dpos = ar_days[i] = [];
+ for (var j = 0; j < 7; ++j, cell = cell.nextSibling, date.setDate(iday + 1)) {
+ iday = date.getDate();
+ var wday = date.getDay();
+ cell.className = "day";
+ cell.pos = i << 4 | j;
+ dpos[j] = cell;
+ var current_month = (date.getMonth() == month);
+ if (!current_month) {
+ if (this.showsOtherMonths) {
+ cell.className += " othermonth";
+ cell.otherMonth = true;
+ } else {
+ cell.className = "emptycell";
+ cell.innerHTML = " ";
+ cell.disabled = true;
+ continue;
+ }
+ } else {
+ cell.otherMonth = false;
+ hasdays = true;
+ }
+ cell.disabled = false;
+ cell.innerHTML = this.getDateText ? this.getDateText(date, iday) : iday;
+ if (dates)
+ dates[date.print("%Y%m%d")] = cell;
+ if (this.getDateStatus) {
+ var status = this.getDateStatus(date, year, month, iday);
+ if (this.getDateToolTip) {
+ var toolTip = this.getDateToolTip(date, year, month, iday);
+ if (toolTip)
+ cell.title = toolTip;
+ }
+ if (status === true) {
+ cell.className += " disabled";
+ cell.disabled = true;
+ } else {
+ if (/disabled/i.test(status))
+ cell.disabled = true;
+ cell.className += " " + status;
+ }
+ }
+ if (!cell.disabled) {
+ cell.caldate = new Date(date);
+ cell.ttip = "_";
+ if (!this.multiple && current_month
+ && iday == mday && this.hiliteToday) {
+ cell.className += " selected";
+ this.currentDateEl = cell;
+ }
+ if (date.getFullYear() == TY &&
+ date.getMonth() == TM &&
+ iday == TD) {
+ cell.className += " today";
+ cell.ttip += Calendar._TT["PART_TODAY"];
+ }
+ if (weekend.indexOf(wday.toString()) != -1)
+ cell.className += cell.otherMonth ? " oweekend" : " weekend";
+ }
+ }
+ if (!(hasdays || this.showsOtherMonths))
+ row.className = "emptyrow";
+ }
+ this.title.innerHTML = Calendar._MN[month] + ", " + year;
+ this.onSetTime();
+ this.table.style.visibility = "visible";
+ this._initMultipleDates();
+ // PROFILE
+ // this.tooltips.innerHTML = "Generated in " + ((new Date()) - today) + " ms";
+};
+
+Calendar.prototype._initMultipleDates = function() {
+ if (this.multiple) {
+ for (var i in this.multiple) {
+ var cell = this.datesCells[i];
+ var d = this.multiple[i];
+ if (!d)
+ continue;
+ if (cell)
+ cell.className += " selected";
+ }
+ }
+};
+
+Calendar.prototype._toggleMultipleDate = function(date) {
+ if (this.multiple) {
+ var ds = date.print("%Y%m%d");
+ var cell = this.datesCells[ds];
+ if (cell) {
+ var d = this.multiple[ds];
+ if (!d) {
+ Calendar.addClass(cell, "selected");
+ this.multiple[ds] = date;
+ } else {
+ Calendar.removeClass(cell, "selected");
+ delete this.multiple[ds];
+ }
+ }
+ }
+};
+
+Calendar.prototype.setDateToolTipHandler = function (unaryFunction) {
+ this.getDateToolTip = unaryFunction;
+};
+
+/**
+ * Calls _init function above for going to a certain date (but only if the
+ * date is different than the currently selected one).
+ */
+Calendar.prototype.setDate = function (date) {
+ if (!date.equalsTo(this.date)) {
+ this._init(this.firstDayOfWeek, date);
+ }
+};
+
+/**
+ * Refreshes the calendar. Useful if the "disabledHandler" function is
+ * dynamic, meaning that the list of disabled date can change at runtime.
+ * Just * call this function if you think that the list of disabled dates
+ * should * change.
+ */
+Calendar.prototype.refresh = function () {
+ this._init(this.firstDayOfWeek, this.date);
+};
+
+/** Modifies the "firstDayOfWeek" parameter (pass 0 for Synday, 1 for Monday, etc.). */
+Calendar.prototype.setFirstDayOfWeek = function (firstDayOfWeek) {
+ this._init(firstDayOfWeek, this.date);
+ this._displayWeekdays();
+};
+
+/**
+ * Allows customization of what dates are enabled. The "unaryFunction"
+ * parameter must be a function object that receives the date (as a JS Date
+ * object) and returns a boolean value. If the returned value is true then
+ * the passed date will be marked as disabled.
+ */
+Calendar.prototype.setDateStatusHandler = Calendar.prototype.setDisabledHandler = function (unaryFunction) {
+ this.getDateStatus = unaryFunction;
+};
+
+/** Customization of allowed year range for the calendar. */
+Calendar.prototype.setRange = function (a, z) {
+ this.minYear = a;
+ this.maxYear = z;
+};
+
+/** Calls the first user handler (selectedHandler). */
+Calendar.prototype.callHandler = function () {
+ if (this.onSelected) {
+ this.onSelected(this, this.date.print(this.dateFormat));
+ }
+};
+
+/** Calls the second user handler (closeHandler). */
+Calendar.prototype.callCloseHandler = function () {
+ if (this.onClose) {
+ this.onClose(this);
+ }
+ this.hideShowCovered();
+};
+
+/** Removes the calendar object from the DOM tree and destroys it. */
+Calendar.prototype.destroy = function () {
+ var el = this.element.parentNode;
+ el.removeChild(this.element);
+ Calendar._C = null;
+ window._dynarch_popupCalendar = null;
+};
+
+/**
+ * Moves the calendar element to a different section in the DOM tree (changes
+ * its parent).
+ */
+Calendar.prototype.reparent = function (new_parent) {
+ var el = this.element;
+ el.parentNode.removeChild(el);
+ new_parent.appendChild(el);
+};
+
+// This gets called when the user presses a mouse button anywhere in the
+// document, if the calendar is shown. If the click was outside the open
+// calendar this function closes it.
+Calendar._checkCalendar = function(ev) {
+ var calendar = window._dynarch_popupCalendar;
+ if (!calendar) {
+ return false;
+ }
+ var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
+ for (; el != null && el != calendar.element; el = el.parentNode);
+ if (el == null) {
+ // calls closeHandler which should hide the calendar.
+ window._dynarch_popupCalendar.callCloseHandler();
+ return Calendar.stopEvent(ev);
+ }
+};
+
+/** Shows the calendar. */
+Calendar.prototype.show = function () {
+ var rows = this.table.getElementsByTagName("tr");
+ for (var i = rows.length; i > 0;) {
+ var row = rows[--i];
+ Calendar.removeClass(row, "rowhilite");
+ var cells = row.getElementsByTagName("td");
+ for (var j = cells.length; j > 0;) {
+ var cell = cells[--j];
+ Calendar.removeClass(cell, "hilite");
+ Calendar.removeClass(cell, "active");
+ }
+ }
+ this.element.style.display = "block";
+ this.hidden = false;
+ if (this.isPopup) {
+ window._dynarch_popupCalendar = this;
+ Calendar.addEvent(document, "keydown", Calendar._keyEvent);
+ Calendar.addEvent(document, "keypress", Calendar._keyEvent);
+ Calendar.addEvent(document, "mousedown", Calendar._checkCalendar);
+ }
+ this.hideShowCovered();
+};
+
+/**
+ * Hides the calendar. Also removes any "hilite" from the class of any TD
+ * element.
+ */
+Calendar.prototype.hide = function () {
+ if (this.isPopup) {
+ Calendar.removeEvent(document, "keydown", Calendar._keyEvent);
+ Calendar.removeEvent(document, "keypress", Calendar._keyEvent);
+ Calendar.removeEvent(document, "mousedown", Calendar._checkCalendar);
+ }
+ this.element.style.display = "none";
+ this.hidden = true;
+ this.hideShowCovered();
+};
+
+/**
+ * Shows the calendar at a given absolute position (beware that, depending on
+ * the calendar element style -- position property -- this might be relative
+ * to the parent's containing rectangle).
+ */
+Calendar.prototype.showAt = function (x, y) {
+ var s = this.element.style;
+ s.left = x + "px";
+ s.top = y + "px";
+ this.show();
+};
+
+/** Shows the calendar near a given element. */
+Calendar.prototype.showAtElement = function (el, opts) {
+ var self = this;
+ var p = Calendar.getAbsolutePos(el);
+ if (!opts || typeof opts != "string") {
+ this.showAt(p.x, p.y + el.offsetHeight);
+ return true;
+ }
+ function fixPosition(box) {
+ if (box.x < 0)
+ box.x = 0;
+ if (box.y < 0)
+ box.y = 0;
+ var cp = document.createElement("div");
+ var s = cp.style;
+ s.position = "absolute";
+ s.right = s.bottom = s.width = s.height = "0px";
+ document.body.appendChild(cp);
+ var br = Calendar.getAbsolutePos(cp);
+ document.body.removeChild(cp);
+ if (Calendar.is_ie) {
+ br.y += document.body.scrollTop;
+ br.x += document.body.scrollLeft;
+ } else {
+ br.y += window.scrollY;
+ br.x += window.scrollX;
+ }
+ var tmp = box.x + box.width - br.x;
+ if (tmp > 0) box.x -= tmp;
+ tmp = box.y + box.height - br.y;
+ if (tmp > 0) box.y -= tmp;
+ };
+ this.element.style.display = "block";
+ Calendar.continuation_for_the_fucking_khtml_browser = function() {
+ var w = self.element.offsetWidth;
+ var h = self.element.offsetHeight;
+ self.element.style.display = "none";
+ var valign = opts.substr(0, 1);
+ var halign = "l";
+ if (opts.length > 1) {
+ halign = opts.substr(1, 1);
+ }
+ // vertical alignment
+ switch (valign) {
+ case "T": p.y -= h; break;
+ case "B": p.y += el.offsetHeight; break;
+ case "C": p.y += (el.offsetHeight - h) / 2; break;
+ case "t": p.y += el.offsetHeight - h; break;
+ case "b": break; // already there
+ }
+ // horizontal alignment
+ switch (halign) {
+ case "L": p.x -= w; break;
+ case "R": p.x += el.offsetWidth; break;
+ case "C": p.x += (el.offsetWidth - w) / 2; break;
+ case "l": p.x += el.offsetWidth - w; break;
+ case "r": break; // already there
+ }
+ p.width = w;
+ p.height = h + 40;
+ self.monthsCombo.style.display = "none";
+ fixPosition(p);
+ self.showAt(p.x, p.y);
+ };
+ if (Calendar.is_khtml)
+ setTimeout("Calendar.continuation_for_the_fucking_khtml_browser()", 10);
+ else
+ Calendar.continuation_for_the_fucking_khtml_browser();
+};
+
+/** Customizes the date format. */
+Calendar.prototype.setDateFormat = function (str) {
+ this.dateFormat = str;
+};
+
+/** Customizes the tooltip date format. */
+Calendar.prototype.setTtDateFormat = function (str) {
+ this.ttDateFormat = str;
+};
+
+/**
+ * Tries to identify the date represented in a string. If successful it also
+ * calls this.setDate which moves the calendar to the given date.
+ */
+Calendar.prototype.parseDate = function(str, fmt) {
+ if (!fmt)
+ fmt = this.dateFormat;
+ this.setDate(Date.parseDate(str, fmt));
+};
+
+Calendar.prototype.hideShowCovered = function () {
+ if (!Calendar.is_ie && !Calendar.is_opera)
+ return;
+ function getVisib(obj){
+ var value = obj.style.visibility;
+ if (!value) {
+ if (document.defaultView && typeof (document.defaultView.getComputedStyle) == "function") { // Gecko, W3C
+ if (!Calendar.is_khtml)
+ value = document.defaultView.
+ getComputedStyle(obj, "").getPropertyValue("visibility");
+ else
+ value = '';
+ } else if (obj.currentStyle) { // IE
+ value = obj.currentStyle.visibility;
+ } else
+ value = '';
+ }
+ return value;
+ };
+
+ var tags = new Array("applet", "iframe", "select");
+ var el = this.element;
+
+ var p = Calendar.getAbsolutePos(el);
+ var EX1 = p.x;
+ var EX2 = el.offsetWidth + EX1;
+ var EY1 = p.y;
+ var EY2 = el.offsetHeight + EY1;
+
+ for (var k = tags.length; k > 0; ) {
+ var ar = document.getElementsByTagName(tags[--k]);
+ var cc = null;
+
+ for (var i = ar.length; i > 0;) {
+ cc = ar[--i];
+
+ p = Calendar.getAbsolutePos(cc);
+ var CX1 = p.x;
+ var CX2 = cc.offsetWidth + CX1;
+ var CY1 = p.y;
+ var CY2 = cc.offsetHeight + CY1;
+
+ if (this.hidden || (CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)) {
+ if (!cc.__msh_save_visibility) {
+ cc.__msh_save_visibility = getVisib(cc);
+ }
+ cc.style.visibility = cc.__msh_save_visibility;
+ } else {
+ if (!cc.__msh_save_visibility) {
+ cc.__msh_save_visibility = getVisib(cc);
+ }
+ cc.style.visibility = "hidden";
+ }
+ }
+ }
+};
+
+/** Internal function; it displays the bar with the names of the weekday. */
+Calendar.prototype._displayWeekdays = function () {
+ var fdow = this.firstDayOfWeek;
+ var cell = this.firstdayname;
+ var weekend = Calendar._TT["WEEKEND"];
+ for (var i = 0; i < 7; ++i) {
+ cell.className = "day name";
+ var realday = (i + fdow) % 7;
+ if (i) {
+ cell.ttip = Calendar._TT["DAY_FIRST"].replace("%s", Calendar._DN[realday]);
+ cell.navtype = 100;
+ cell.calendar = this;
+ cell.fdow = realday;
+ Calendar._add_evs(cell);
+ }
+ if (weekend.indexOf(realday.toString()) != -1) {
+ Calendar.addClass(cell, "weekend");
+ }
+ cell.innerHTML = Calendar._SDN[(i + fdow) % 7];
+ cell = cell.nextSibling;
+ }
+};
+
+/** Internal function. Hides all combo boxes that might be displayed. */
+Calendar.prototype._hideCombos = function () {
+ this.monthsCombo.style.display = "none";
+ this.yearsCombo.style.display = "none";
+};
+
+/** Internal function. Starts dragging the element. */
+Calendar.prototype._dragStart = function (ev) {
+ if (this.dragging) {
+ return;
+ }
+ this.dragging = true;
+ var posX;
+ var posY;
+ if (Calendar.is_ie) {
+ posY = window.event.clientY + document.body.scrollTop;
+ posX = window.event.clientX + document.body.scrollLeft;
+ } else {
+ posY = ev.clientY + window.scrollY;
+ posX = ev.clientX + window.scrollX;
+ }
+ var st = this.element.style;
+ this.xOffs = posX - parseInt(st.left);
+ this.yOffs = posY - parseInt(st.top);
+ with (Calendar) {
+ addEvent(document, "mousemove", calDragIt);
+ addEvent(document, "mouseup", calDragEnd);
+ }
+};
+
+// BEGIN: DATE OBJECT PATCHES
+
+/** Adds the number of days array to the Date object. */
+Date._MD = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
+
+/** Constants used for time computations */
+Date.SECOND = 1000 /* milliseconds */;
+Date.MINUTE = 60 * Date.SECOND;
+Date.HOUR = 60 * Date.MINUTE;
+Date.DAY = 24 * Date.HOUR;
+Date.WEEK = 7 * Date.DAY;
+
+Date.parseDate = function(str, fmt) {
+ var today = new Date();
+ var y = 0;
+ var m = -1;
+ var d = 0;
+ var a = str.split(/\W+/);
+ var b = fmt.match(/%./g);
+ var i = 0, j = 0;
+ var hr = 0;
+ var min = 0;
+ for (i = 0; i < a.length; ++i) {
+ if (!a[i])
+ continue;
+ switch (b[i]) {
+ case "%d":
+ case "%e":
+ d = parseInt(a[i], 10);
+ break;
+
+ case "%m":
+ m = parseInt(a[i], 10) - 1;
+ break;
+
+ case "%Y":
+ case "%y":
+ y = parseInt(a[i], 10);
+ (y < 100) && (y += (y > 29) ? 1900 : 2000);
+ break;
+
+ case "%b":
+ case "%B":
+ for (j = 0; j < 12; ++j) {
+ if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { m = j; break; }
+ }
+ break;
+
+ case "%H":
+ case "%I":
+ case "%k":
+ case "%l":
+ hr = parseInt(a[i], 10);
+ break;
+
+ case "%P":
+ case "%p":
+ if (/pm/i.test(a[i]) && hr < 12)
+ hr += 12;
+ else if (/am/i.test(a[i]) && hr >= 12)
+ hr -= 12;
+ break;
+
+ case "%M":
+ min = parseInt(a[i], 10);
+ break;
+ }
+ }
+ if (isNaN(y)) y = today.getFullYear();
+ if (isNaN(m)) m = today.getMonth();
+ if (isNaN(d)) d = today.getDate();
+ if (isNaN(hr)) hr = today.getHours();
+ if (isNaN(min)) min = today.getMinutes();
+ if (y != 0 && m != -1 && d != 0)
+ return new Date(y, m, d, hr, min, 0);
+ y = 0; m = -1; d = 0;
+ for (i = 0; i < a.length; ++i) {
+ if (a[i].search(/[a-zA-Z]+/) != -1) {
+ var t = -1;
+ for (j = 0; j < 12; ++j) {
+ if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { t = j; break; }
+ }
+ if (t != -1) {
+ if (m != -1) {
+ d = m+1;
+ }
+ m = t;
+ }
+ } else if (parseInt(a[i], 10) <= 12 && m == -1) {
+ m = a[i]-1;
+ } else if (parseInt(a[i], 10) > 31 && y == 0) {
+ y = parseInt(a[i], 10);
+ (y < 100) && (y += (y > 29) ? 1900 : 2000);
+ } else if (d == 0) {
+ d = a[i];
+ }
+ }
+ if (y == 0)
+ y = today.getFullYear();
+ if (m != -1 && d != 0)
+ return new Date(y, m, d, hr, min, 0);
+ return today;
+};
+
+/** Returns the number of days in the current month */
+Date.prototype.getMonthDays = function(month) {
+ var year = this.getFullYear();
+ if (typeof month == "undefined") {
+ month = this.getMonth();
+ }
+ if (((0 == (year%4)) && ( (0 != (year%100)) || (0 == (year%400)))) && month == 1) {
+ return 29;
+ } else {
+ return Date._MD[month];
+ }
+};
+
+/** Returns the number of day in the year. */
+Date.prototype.getDayOfYear = function() {
+ var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
+ var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
+ var time = now - then;
+ return Math.floor(time / Date.DAY);
+};
+
+/** Returns the number of the week in year, as defined in ISO 8601. */
+Date.prototype.getWeekNumber = function() {
+ var d = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
+ var DoW = d.getDay();
+ d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu
+ var ms = d.valueOf(); // GMT
+ d.setMonth(0);
+ d.setDate(4); // Thu in Week 1
+ return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1;
+};
+
+/** Checks date and time equality */
+Date.prototype.equalsTo = function(date) {
+ return ((this.getFullYear() == date.getFullYear()) &&
+ (this.getMonth() == date.getMonth()) &&
+ (this.getDate() == date.getDate()) &&
+ (this.getHours() == date.getHours()) &&
+ (this.getMinutes() == date.getMinutes()));
+};
+
+/** Set only the year, month, date parts (keep existing time) */
+Date.prototype.setDateOnly = function(date) {
+ var tmp = new Date(date);
+ this.setDate(1);
+ this.setFullYear(tmp.getFullYear());
+ this.setMonth(tmp.getMonth());
+ this.setDate(tmp.getDate());
+};
+
+/** Prints the date in a string according to the given format. */
+Date.prototype.print = function (str) {
+ var m = this.getMonth();
+ var d = this.getDate();
+ var y = this.getFullYear();
+ var wn = this.getWeekNumber();
+ var w = this.getDay();
+ var s = {};
+ var hr = this.getHours();
+ var pm = (hr >= 12);
+ var ir = (pm) ? (hr - 12) : hr;
+ var dy = this.getDayOfYear();
+ if (ir == 0)
+ ir = 12;
+ var min = this.getMinutes();
+ var sec = this.getSeconds();
+ s["%a"] = Calendar._SDN[w]; // abbreviated weekday name [FIXME: I18N]
+ s["%A"] = Calendar._DN[w]; // full weekday name
+ s["%b"] = Calendar._SMN[m]; // abbreviated month name [FIXME: I18N]
+ s["%B"] = Calendar._MN[m]; // full month name
+ // FIXME: %c : preferred date and time representation for the current locale
+ s["%C"] = 1 + Math.floor(y / 100); // the century number
+ s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31)
+ s["%e"] = d; // the day of the month (range 1 to 31)
+ // FIXME: %D : american date style: %m/%d/%y
+ // FIXME: %E, %F, %G, %g, %h (man strftime)
+ s["%H"] = (hr < 10) ? ("0" + hr) : hr; // hour, range 00 to 23 (24h format)
+ s["%I"] = (ir < 10) ? ("0" + ir) : ir; // hour, range 01 to 12 (12h format)
+ s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366)
+ s["%k"] = hr; // hour, range 0 to 23 (24h format)
+ s["%l"] = ir; // hour, range 1 to 12 (12h format)
+ s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12
+ s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59
+ s["%n"] = "\n"; // a newline character
+ s["%p"] = pm ? "PM" : "AM";
+ s["%P"] = pm ? "pm" : "am";
+ // FIXME: %r : the time in am/pm notation %I:%M:%S %p
+ // FIXME: %R : the time in 24-hour notation %H:%M
+ s["%s"] = Math.floor(this.getTime() / 1000);
+ s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59
+ s["%t"] = "\t"; // a tab character
+ // FIXME: %T : the time in 24-hour notation (%H:%M:%S)
+ s["%U"] = s["%W"] = s["%V"] = (wn < 10) ? ("0" + wn) : wn;
+ s["%u"] = w + 1; // the day of the week (range 1 to 7, 1 = MON)
+ s["%w"] = w; // the day of the week (range 0 to 6, 0 = SUN)
+ // FIXME: %x : preferred date representation for the current locale without the time
+ // FIXME: %X : preferred time representation for the current locale without the date
+ s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99)
+ s["%Y"] = y; // year with the century
+ s["%%"] = "%"; // a literal '%' character
+
+ var re = /%./g;
+ if (!Calendar.is_ie5 && !Calendar.is_khtml)
+ return str.replace(re, function (par) { return s[par] || par; });
+
+ var a = str.match(re);
+ for (var i = 0; i < a.length; i++) {
+ var tmp = s[a[i]];
+ if (tmp) {
+ re = new RegExp(a[i], 'g');
+ str = str.replace(re, tmp);
+ }
+ }
+
+ return str;
+};
+
+Date.prototype.__msh_oldSetFullYear = Date.prototype.setFullYear;
+Date.prototype.setFullYear = function(y) {
+ var d = new Date(this);
+ d.__msh_oldSetFullYear(y);
+ if (d.getMonth() != this.getMonth())
+ this.setDate(28);
+ this.__msh_oldSetFullYear(y);
+};
+
+// END: DATE OBJECT PATCHES
+
+
+// global object that remembers the calendar
+window._dynarch_popupCalendar = null;
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-bg.js b/rest_sys/public/javascripts/calendar/lang/calendar-bg.js
new file mode 100644
index 000000000..edc870e3b
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-bg.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar BG language
+// Author: Nikolay Solakov,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("ÐеделÑ",
+ "Понеделник",
+ "Вторник",
+ "СрÑда",
+ "Четвъртък",
+ "Петък",
+ "Събота",
+ "ÐеделÑ");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("Ðед",
+ "Пон",
+ "Вто",
+ "СрÑ",
+ "Чет",
+ "Пет",
+ "Съб",
+ "Ðед");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 1;
+
+// full month names
+Calendar._MN = new Array
+("Януари",
+ "Февруари",
+ "Март",
+ "Ðприл",
+ "Май",
+ "Юни",
+ "Юли",
+ "ÐвгуÑÑ‚",
+ "Септември",
+ "Октомври",
+ "Ðоември",
+ "Декември");
+
+// short month names
+Calendar._SMN = new Array
+("Яну",
+ "Фев",
+ "Мар",
+ "Ðпр",
+ "Май",
+ "Юни",
+ "Юли",
+ "Ðвг",
+ "Сеп",
+ "Окт",
+ "Ðое",
+ "Дек");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "За календара";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Избор на дата:\n" +
+"- Използвайте \xab, \xbb за избор на година\n" +
+"- Използвайте " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " за избор на меÑец\n" +
+"- Задръжте натиÑнат бутона за ÑпиÑък Ñ Ð³Ð¾Ð´Ð¸Ð½Ð¸/меÑеци.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Избор на чаÑ:\n" +
+"- Кликнете на чиÑлата от чаÑа за да ги увеличите\n" +
+"- или Shift-click за намалÑването им\n" +
+"- или кликнете и влачете за по-бърза промÑна.";
+
+Calendar._TT["PREV_YEAR"] = "Предишна година (задръжте за ÑпиÑък)";
+Calendar._TT["PREV_MONTH"] = "Предишен меÑец (задръжте за ÑпиÑък)";
+Calendar._TT["GO_TODAY"] = "Днешна дата";
+Calendar._TT["NEXT_MONTH"] = "Следващ меÑец (задръжте за ÑпиÑък)";
+Calendar._TT["NEXT_YEAR"] = "Следваща година (задръжте за ÑпиÑък)";
+Calendar._TT["SEL_DATE"] = "Избор на дата";
+Calendar._TT["DRAG_TO_MOVE"] = "Дръпнете за премеÑтване";
+Calendar._TT["PART_TODAY"] = " (днеÑ)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Седмицата започва Ñ %s";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "Затвори";
+Calendar._TT["TODAY"] = "ДнеÑ";
+Calendar._TT["TIME_PART"] = "(Shift-)Click или влачене за промÑна на ÑтойноÑÑ‚";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "Ñедм";
+Calendar._TT["TIME"] = "ЧаÑ:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-cs.js b/rest_sys/public/javascripts/calendar/lang/calendar-cs.js
new file mode 100644
index 000000000..406ac6695
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-cs.js
@@ -0,0 +1,69 @@
+/*
+ calendar-cs-win.js
+ language: Czech
+ encoding: windows-1250
+ author: Lubos Jerabek (xnet@seznam.cz)
+ Jan Uhlir (espinosa@centrum.cz)
+*/
+
+// ** I18N
+Calendar._DN = new Array('NedÄ›le','PondÄ›lÃ','Úterý','StÅ™eda','ÄŒtvrtek','Pátek','Sobota','NedÄ›le');
+Calendar._SDN = new Array('Ne','Po','Út','St','Čt','Pá','So','Ne');
+Calendar._MN = new Array('Leden','Únor','BÅ™ezen','Duben','KvÄ›ten','ÄŒerven','ÄŒervenec','Srpen','ZářÃ','ŘÃjen','Listopad','Prosinec');
+Calendar._SMN = new Array('Led','Úno','BÅ™e','Dub','KvÄ›','ÄŒrv','ÄŒvc','Srp','Zář','ŘÃj','Lis','Pro');
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 1;
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "O komponentě kalendář";
+Calendar._TT["TOGGLE"] = "ZmÄ›na prvnÃho dne v týdnu";
+Calendar._TT["PREV_YEAR"] = "Předchozà rok (přidrž pro menu)";
+Calendar._TT["PREV_MONTH"] = "PÅ™edchozà mÄ›sÃc (pÅ™idrž pro menu)";
+Calendar._TT["GO_TODAY"] = "Dnešnà datum";
+Calendar._TT["NEXT_MONTH"] = "Dalšà mÄ›sÃc (pÅ™idrž pro menu)";
+Calendar._TT["NEXT_YEAR"] = "Dalšà rok (přidrž pro menu)";
+Calendar._TT["SEL_DATE"] = "Vyber datum";
+Calendar._TT["DRAG_TO_MOVE"] = "Chyť a táhni, pro přesun";
+Calendar._TT["PART_TODAY"] = " (dnes)";
+Calendar._TT["MON_FIRST"] = "Ukaž jako prvnà PondÄ›lÃ";
+//Calendar._TT["SUN_FIRST"] = "Ukaž jako prvnà Neděli";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Výběr datumu:\n" +
+"- Use the \xab, \xbb buttons to select year\n" +
+"- Použijte tlaÄÃtka " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " k výbÄ›ru mÄ›sÃce\n" +
+"- Podržte tlaÄÃtko myÅ¡i na jakémkoliv z tÄ›ch tlaÄÃtek pro rychlejšà výbÄ›r.";
+
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"VýbÄ›r Äasu:\n" +
+"- KliknÄ›te na jakoukoliv z Äástà výbÄ›ru Äasu pro zvýšenÃ.\n" +
+"- nebo Shift-click pro snÞenÃ\n" +
+"- nebo klikněte a táhněte pro rychlejšà výběr.";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Zobraz %s prvnÃ";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "ZavÅ™Ãt";
+Calendar._TT["TODAY"] = "Dnes";
+Calendar._TT["TIME_PART"] = "(Shift-)Klikni nebo táhni pro změnu hodnoty";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "d.m.yy";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "wk";
+Calendar._TT["TIME"] = "ÄŒas:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-de.js b/rest_sys/public/javascripts/calendar/lang/calendar-de.js
new file mode 100644
index 000000000..c320699ca
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-de.js
@@ -0,0 +1,128 @@
+// ** I18N
+
+// Calendar DE language
+// Author: Jack (tR),
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("Sonntag",
+ "Montag",
+ "Dienstag",
+ "Mittwoch",
+ "Donnerstag",
+ "Freitag",
+ "Samstag",
+ "Sonntag");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 1;
+
+// short day names
+Calendar._SDN = new Array
+("So",
+ "Mo",
+ "Di",
+ "Mi",
+ "Do",
+ "Fr",
+ "Sa",
+ "So");
+
+// full month names
+Calendar._MN = new Array
+("Januar",
+ "Februar",
+ "M\u00e4rz",
+ "April",
+ "Mai",
+ "Juni",
+ "Juli",
+ "August",
+ "September",
+ "Oktober",
+ "November",
+ "Dezember");
+
+// short month names
+Calendar._SMN = new Array
+("Jan",
+ "Feb",
+ "M\u00e4r",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Okt",
+ "Nov",
+ "Dez");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "\u00DCber dieses Kalendarmodul";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Datum ausw\u00e4hlen:\n" +
+"- Benutzen Sie die \xab, \xbb Buttons um das Jahr zu w\u00e4hlen\n" +
+"- Benutzen Sie die " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " Buttons um den Monat zu w\u00e4hlen\n" +
+"- F\u00fcr eine Schnellauswahl halten Sie die Maustaste \u00fcber diesen Buttons fest.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Zeit ausw\u00e4hlen:\n" +
+"- Klicken Sie auf die Teile der Uhrzeit, um diese zu erh\u00F6hen\n" +
+"- oder klicken Sie mit festgehaltener Shift-Taste um diese zu verringern\n" +
+"- oder klicken und festhalten f\u00fcr Schnellauswahl.";
+
+Calendar._TT["TOGGLE"] = "Ersten Tag der Woche w\u00e4hlen";
+Calendar._TT["PREV_YEAR"] = "Voriges Jahr (Festhalten f\u00fcr Schnellauswahl)";
+Calendar._TT["PREV_MONTH"] = "Voriger Monat (Festhalten f\u00fcr Schnellauswahl)";
+Calendar._TT["GO_TODAY"] = "Heute ausw\u00e4hlen";
+Calendar._TT["NEXT_MONTH"] = "N\u00e4chst. Monat (Festhalten f\u00fcr Schnellauswahl)";
+Calendar._TT["NEXT_YEAR"] = "N\u00e4chst. Jahr (Festhalten f\u00fcr Schnellauswahl)";
+Calendar._TT["SEL_DATE"] = "Datum ausw\u00e4hlen";
+Calendar._TT["DRAG_TO_MOVE"] = "Zum Bewegen festhalten";
+Calendar._TT["PART_TODAY"] = " (Heute)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Woche beginnt mit %s ";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "Schlie\u00dfen";
+Calendar._TT["TODAY"] = "Heute";
+Calendar._TT["TIME_PART"] = "(Shift-)Klick oder Festhalten und Ziehen um den Wert zu \u00e4ndern";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%d.%m.%Y";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "wk";
+Calendar._TT["TIME"] = "Zeit:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-en.js b/rest_sys/public/javascripts/calendar/lang/calendar-en.js
new file mode 100644
index 000000000..0dbde793d
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-en.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar EN language
+// Author: Mihai Bazon,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("Sunday",
+ "Monday",
+ "Tuesday",
+ "Wednesday",
+ "Thursday",
+ "Friday",
+ "Saturday",
+ "Sunday");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("Sun",
+ "Mon",
+ "Tue",
+ "Wed",
+ "Thu",
+ "Fri",
+ "Sat",
+ "Sun");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 0;
+
+// full month names
+Calendar._MN = new Array
+("January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December");
+
+// short month names
+Calendar._SMN = new Array
+("Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "About the calendar";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Date selection:\n" +
+"- Use the \xab, \xbb buttons to select year\n" +
+"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
+"- Hold mouse button on any of the above buttons for faster selection.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Time selection:\n" +
+"- Click on any of the time parts to increase it\n" +
+"- or Shift-click to decrease it\n" +
+"- or click and drag for faster selection.";
+
+Calendar._TT["PREV_YEAR"] = "Prev. year (hold for menu)";
+Calendar._TT["PREV_MONTH"] = "Prev. month (hold for menu)";
+Calendar._TT["GO_TODAY"] = "Go Today";
+Calendar._TT["NEXT_MONTH"] = "Next month (hold for menu)";
+Calendar._TT["NEXT_YEAR"] = "Next year (hold for menu)";
+Calendar._TT["SEL_DATE"] = "Select date";
+Calendar._TT["DRAG_TO_MOVE"] = "Drag to move";
+Calendar._TT["PART_TODAY"] = " (today)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Display %s first";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "Close";
+Calendar._TT["TODAY"] = "Today";
+Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "wk";
+Calendar._TT["TIME"] = "Time:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-es.js b/rest_sys/public/javascripts/calendar/lang/calendar-es.js
new file mode 100644
index 000000000..11d0b53d5
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-es.js
@@ -0,0 +1,129 @@
+// ** I18N
+
+// Calendar ES (spanish) language
+// Author: Mihai Bazon,
+// Updater: Servilio Afre Puentes
+// Updated: 2004-06-03
+// Encoding: utf-8
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("Domingo",
+ "Lunes",
+ "Martes",
+ "Miércoles",
+ "Jueves",
+ "Viernes",
+ "Sábado",
+ "Domingo");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("Dom",
+ "Lun",
+ "Mar",
+ "Mié",
+ "Jue",
+ "Vie",
+ "Sáb",
+ "Dom");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 1;
+
+// full month names
+Calendar._MN = new Array
+("Enero",
+ "Febrero",
+ "Marzo",
+ "Abril",
+ "Mayo",
+ "Junio",
+ "Julio",
+ "Agosto",
+ "Septiembre",
+ "Octubre",
+ "Noviembre",
+ "Diciembre");
+
+// short month names
+Calendar._SMN = new Array
+("Ene",
+ "Feb",
+ "Mar",
+ "Abr",
+ "May",
+ "Jun",
+ "Jul",
+ "Ago",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dic");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "Acerca del calendario";
+
+Calendar._TT["ABOUT"] =
+"Selector DHTML de Fecha/Hora\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"Para conseguir la última versión visite: http://www.dynarch.com/projects/calendar/\n" +
+"Distribuido bajo licencia GNU LGPL. Visite http://gnu.org/licenses/lgpl.html para más detalles." +
+"\n\n" +
+"Selección de fecha:\n" +
+"- Use los botones \xab, \xbb para seleccionar el año\n" +
+"- Use los botones " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " para seleccionar el mes\n" +
+"- Mantenga pulsado el ratón en cualquiera de estos botones para una selección rápida.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Selección de hora:\n" +
+"- Pulse en cualquiera de las partes de la hora para incrementarla\n" +
+"- o pulse las mayúsculas mientras hace clic para decrementarla\n" +
+"- o haga clic y arrastre el ratón para una selección más rápida.";
+
+Calendar._TT["PREV_YEAR"] = "Año anterior (mantener para menú)";
+Calendar._TT["PREV_MONTH"] = "Mes anterior (mantener para menú)";
+Calendar._TT["GO_TODAY"] = "Ir a hoy";
+Calendar._TT["NEXT_MONTH"] = "Mes siguiente (mantener para menú)";
+Calendar._TT["NEXT_YEAR"] = "Año siguiente (mantener para menú)";
+Calendar._TT["SEL_DATE"] = "Seleccionar fecha";
+Calendar._TT["DRAG_TO_MOVE"] = "Arrastrar para mover";
+Calendar._TT["PART_TODAY"] = " (hoy)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Hacer %s primer dÃa de la semana";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "Cerrar";
+Calendar._TT["TODAY"] = "Hoy";
+Calendar._TT["TIME_PART"] = "(Mayúscula-)Clic o arrastre para cambiar valor";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%d/%m/%Y";
+Calendar._TT["TT_DATE_FORMAT"] = "%A, %e de %B de %Y";
+
+Calendar._TT["WK"] = "sem";
+Calendar._TT["TIME"] = "Hora:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-fr.js b/rest_sys/public/javascripts/calendar/lang/calendar-fr.js
new file mode 100644
index 000000000..ee2a486fd
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-fr.js
@@ -0,0 +1,129 @@
+// ** I18N
+
+// Calendar EN language
+// Author: Mihai Bazon,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// Translator: David Duret, from previous french version
+
+// full day names
+Calendar._DN = new Array
+("Dimanche",
+ "Lundi",
+ "Mardi",
+ "Mercredi",
+ "Jeudi",
+ "Vendredi",
+ "Samedi",
+ "Dimanche");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("Dim",
+ "Lun",
+ "Mar",
+ "Mer",
+ "Jeu",
+ "Ven",
+ "Sam",
+ "Dim");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 1;
+
+// full month names
+Calendar._MN = new Array
+("Janvier",
+ "Février",
+ "Mars",
+ "Avril",
+ "Mai",
+ "Juin",
+ "Juillet",
+ "Août",
+ "Septembre",
+ "Octobre",
+ "Novembre",
+ "Décembre");
+
+// short month names
+Calendar._SMN = new Array
+("Jan",
+ "Fev",
+ "Mar",
+ "Avr",
+ "Mai",
+ "Juin",
+ "Juil",
+ "Aout",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "A propos du calendrier";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Heure Selecteur\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"Pour la derniere version visitez : http://www.dynarch.com/projects/calendar/\n" +
+"Distribué par GNU LGPL. Voir http://gnu.org/licenses/lgpl.html pour les details." +
+"\n\n" +
+"Selection de la date :\n" +
+"- Utiliser les bouttons \xab, \xbb pour selectionner l\'annee\n" +
+"- Utiliser les bouttons " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " pour selectionner les mois\n" +
+"- Garder la souris sur n'importe quels boutons pour une selection plus rapide";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Selection de l\'heure :\n" +
+"- Cliquer sur heures ou minutes pour incrementer\n" +
+"- ou Maj-clic pour decrementer\n" +
+"- ou clic et glisser-deplacer pour une selection plus rapide";
+
+Calendar._TT["PREV_YEAR"] = "Année préc. (maintenir pour menu)";
+Calendar._TT["PREV_MONTH"] = "Mois préc. (maintenir pour menu)";
+Calendar._TT["GO_TODAY"] = "Atteindre la date du jour";
+Calendar._TT["NEXT_MONTH"] = "Mois suiv. (maintenir pour menu)";
+Calendar._TT["NEXT_YEAR"] = "Année suiv. (maintenir pour menu)";
+Calendar._TT["SEL_DATE"] = "Sélectionner une date";
+Calendar._TT["DRAG_TO_MOVE"] = "Déplacer";
+Calendar._TT["PART_TODAY"] = " (Aujourd'hui)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Afficher %s en premier";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "Fermer";
+Calendar._TT["TODAY"] = "Aujourd'hui";
+Calendar._TT["TIME_PART"] = "(Maj-)Clic ou glisser pour modifier la valeur";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%d/%m/%Y";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "Sem.";
+Calendar._TT["TIME"] = "Heure :";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-he.js b/rest_sys/public/javascripts/calendar/lang/calendar-he.js
new file mode 100644
index 000000000..bd92e0073
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-he.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar HE language
+// Author: Saggi Mizrahi
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("ר×שון",
+ "×©× ×™",
+ "שלישי",
+ "רביעי",
+ "חמישי",
+ "שישי",
+ "שבת",
+ "ר×שון");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("×",
+ "ב",
+ "×’",
+ "ד",
+ "×”",
+ "ו",
+ "ש",
+ "×");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 0;
+
+// full month names
+Calendar._MN = new Array
+("×™× ×•×ר",
+ "פברו×ר",
+ "מרץ",
+ "×פריל",
+ "מ××™",
+ "×™×•× ×™",
+ "יולי",
+ "×וגוסט",
+ "ספטמבר",
+ "×וקטובר",
+ "× ×•×‘×ž×‘×¨",
+ "דצמבר");
+
+// short month names
+Calendar._SMN = new Array
+("×™× ×•'",
+ "פבו'",
+ "מרץ",
+ "×פר'",
+ "מ××™",
+ "×™×•× '",
+ "יול'",
+ "×וג'",
+ "ספט'",
+ "×וקט'",
+ "× ×•×‘'",
+ "דצמ'");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "×ודות לוח ×”×©× ×”";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Date selection:\n" +
+"- Use the \xab, \xbb buttons to select year\n" +
+"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
+"- Hold mouse button on any of the above buttons for faster selection.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Time selection:\n" +
+"- Click on any of the time parts to increase it\n" +
+"- or Shift-click to decrease it\n" +
+"- or click and drag for faster selection.";
+
+Calendar._TT["PREV_YEAR"] = "×©× ×” קודמת (×”×—×–×§ לתפריט)";
+Calendar._TT["PREV_MONTH"] = "חודש ×§×•×“× (×”×—×–×§ לתפריט)";
+Calendar._TT["GO_TODAY"] = "לך להיו×";
+Calendar._TT["NEXT_MONTH"] = "חודש ×”×‘× (×”×—×–×§ לתפריט)";
+Calendar._TT["NEXT_YEAR"] = "×©× ×” הב××” (×”×—×–×§ לתפריט)";
+Calendar._TT["SEL_DATE"] = "בחר ת×ריך";
+Calendar._TT["DRAG_TO_MOVE"] = "משוך כדי להזיז";
+Calendar._TT["PART_TODAY"] = " (היו×)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "הצג %s קוד×";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "6,7";
+
+Calendar._TT["CLOSE"] = "סגור";
+Calendar._TT["TODAY"] = "היו×";
+Calendar._TT["TIME_PART"] = "(Shift-)לחץ ×ו משוך כדי ×œ×©× ×•×ª ×ת הערך";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%d-%m-%Y";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "wk";
+Calendar._TT["TIME"] = "זמן:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-it.js b/rest_sys/public/javascripts/calendar/lang/calendar-it.js
new file mode 100644
index 000000000..fbc80c935
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-it.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar EN language
+// Author: Mihai Bazon,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("Domenica",
+ "Lunedì",
+ "Martedì",
+ "Mercoledì",
+ "Giovedì",
+ "Venerdì",
+ "Sabato",
+ "Domenica");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("Dom",
+ "Lun",
+ "Mar",
+ "Mer",
+ "Gio",
+ "Ven",
+ "Sab",
+ "Dom");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 1;
+
+// full month names
+Calendar._MN = new Array
+("Gennaio",
+ "Febbraio",
+ "Marzo",
+ "Aprile",
+ "Maggio",
+ "Giugno",
+ "Luglio",
+ "Agosto",
+ "Settembre",
+ "Ottobre",
+ "Novembre",
+ "Dicembre");
+
+// short month names
+Calendar._SMN = new Array
+("Gen",
+ "Feb",
+ "Mar",
+ "Apr",
+ "Mag",
+ "Giu",
+ "Lug",
+ "Ago",
+ "Set",
+ "Ott",
+ "Nov",
+ "Dic");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "Informazioni sul calendario";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Date selection:\n" +
+"- Use the \xab, \xbb buttons to select year\n" +
+"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
+"- Hold mouse button on any of the above buttons for faster selection.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Time selection:\n" +
+"- Click on any of the time parts to increase it\n" +
+"- or Shift-click to decrease it\n" +
+"- or click and drag for faster selection.";
+
+Calendar._TT["PREV_YEAR"] = "Anno prec. (tieni premuto per menu)";
+Calendar._TT["PREV_MONTH"] = "Mese prec. (tieni premuto per menu)";
+Calendar._TT["GO_TODAY"] = "Oggi";
+Calendar._TT["NEXT_MONTH"] = "Mese succ. (tieni premuto per menu)";
+Calendar._TT["NEXT_YEAR"] = "Anno succ. (tieni premuto per menu)";
+Calendar._TT["SEL_DATE"] = "Seleziona data";
+Calendar._TT["DRAG_TO_MOVE"] = "Trascina per spostare";
+Calendar._TT["PART_TODAY"] = " (oggi)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Mostra %s per primo";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "Chiudi";
+Calendar._TT["TODAY"] = "Oggi";
+Calendar._TT["TIME_PART"] = "(Shift-)Click o trascina per modificare";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "sett";
+Calendar._TT["TIME"] = "Ora:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-ja.js b/rest_sys/public/javascripts/calendar/lang/calendar-ja.js
new file mode 100644
index 000000000..24bde0f30
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-ja.js
@@ -0,0 +1,87 @@
+// ** I18N
+
+// Calendar EN language
+// Author: Mihai Bazon,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array ("日曜日", "月曜日", "ç«æ›œæ—¥", "水曜日", "木曜日", "金曜日", "土曜日");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array ("æ—¥", "月", "ç«", "æ°´", "木", "金", "土");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 0;
+
+// full month names
+Calendar._MN = new Array ("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月");
+
+// short month names
+Calendar._SMN = new Array ("1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "ã“ã®ã‚«ãƒ¬ãƒ³ãƒ€ãƒ¼ã«ã¤ã„ã¦";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"日付ã®é¸æŠžæ–¹æ³•:\n" +
+"- \xab, \xbb ボタンã§å¹´ã‚’é¸æŠžã€‚\n" +
+"- " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " ボタンã§å¹´ã‚’é¸æŠžã€‚\n" +
+"- 上記ボタンã®é•·æŠ¼ã—ã§ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‹ã‚‰é¸æŠžã€‚";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Time selection:\n" +
+"- Click on any of the time parts to increase it\n" +
+"- or Shift-click to decrease it\n" +
+"- or click and drag for faster selection.";
+
+Calendar._TT["PREV_YEAR"] = "å‰å¹´ (長押ã—ã§ãƒ¡ãƒ‹ãƒ¥ãƒ¼è¡¨ç¤º)";
+Calendar._TT["PREV_MONTH"] = "翌年 (長押ã—ã§ãƒ¡ãƒ‹ãƒ¥ãƒ¼è¡¨ç¤º)";
+Calendar._TT["GO_TODAY"] = "ä»Šæ—¥ã®æ—¥ä»˜ã‚’é¸æŠž";
+Calendar._TT["NEXT_MONTH"] = "剿œˆ (長押ã—ã§ãƒ¡ãƒ‹ãƒ¥ãƒ¼è¡¨ç¤º)";
+Calendar._TT["NEXT_YEAR"] = "翌月 (長押ã—ã§ãƒ¡ãƒ‹ãƒ¥ãƒ¼è¡¨ç¤º)";
+Calendar._TT["SEL_DATE"] = "æ—¥ä»˜ã‚’é¸æŠžã—ã¦ãã ã•ã„";
+Calendar._TT["DRAG_TO_MOVE"] = "ドラッグã§ç§»å‹•";
+Calendar._TT["PART_TODAY"] = " (今日)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "%så§‹ã¾ã‚Šã§è¡¨ç¤º";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "é–‰ã˜ã‚‹";
+Calendar._TT["TODAY"] = "今日";
+Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
+Calendar._TT["TT_DATE_FORMAT"] = "%b%eæ—¥(%a)";
+
+Calendar._TT["WK"] = "週";
+Calendar._TT["TIME"] = "Time:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-ko.js b/rest_sys/public/javascripts/calendar/lang/calendar-ko.js
new file mode 100644
index 000000000..016453bfc
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-ko.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar EN language
+// Author: Mihai Bazon,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("ì¼ìš”ì¼",
+ "월요ì¼",
+ "화요ì¼",
+ "수요ì¼",
+ "목요ì¼",
+ "금요ì¼",
+ "í† ìš”ì¼",
+ "ì¼ìš”ì¼");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("ì¼",
+ "ì›”",
+ "í™”",
+ "수",
+ "목",
+ "금",
+ "í† ",
+ "ì¼");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 0;
+
+// full month names
+Calendar._MN = new Array
+("1ì›”",
+ "2ì›”",
+ "3ì›”",
+ "4ì›”",
+ "5ì›”",
+ "6ì›”",
+ "7ì›”",
+ "8ì›”",
+ "9ì›”",
+ "10ì›”",
+ "11ì›”",
+ "12ì›”");
+
+// short month names
+Calendar._SMN = new Array
+("1ì›”",
+ "2ì›”",
+ "3ì›”",
+ "4ì›”",
+ "5ì›”",
+ "6ì›”",
+ "7ì›”",
+ "8ì›”",
+ "9ì›”",
+ "10ì›”",
+ "11ì›”",
+ "12ì›”");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "About the calendar";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Date selection:\n" +
+"- Use the \xab, \xbb buttons to select year\n" +
+"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
+"- Hold mouse button on any of the above buttons for faster selection.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Time selection:\n" +
+"- Click on any of the time parts to increase it\n" +
+"- or Shift-click to decrease it\n" +
+"- or click and drag for faster selection.";
+
+Calendar._TT["PREV_YEAR"] = "ì´ì „ í•´";
+Calendar._TT["PREV_MONTH"] = "ì´ì „ 달";
+Calendar._TT["GO_TODAY"] = "오늘로 ì´ë™";
+Calendar._TT["NEXT_MONTH"] = "ë‹¤ìŒ ë‹¬";
+Calendar._TT["NEXT_YEAR"] = "ë‹¤ìŒ í•´";
+Calendar._TT["SEL_DATE"] = "ë‚ ì§œ ì„ íƒ";
+Calendar._TT["DRAG_TO_MOVE"] = "ì´ë™(드래그)";
+Calendar._TT["PART_TODAY"] = " (오늘)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "[%s]ì„ ì²˜ìŒìœ¼ë¡œ";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "닫기";
+Calendar._TT["TODAY"] = "오늘";
+Calendar._TT["TIME_PART"] = "(Shift-)í´ë¦ or drag to change value";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "주";
+Calendar._TT["TIME"] = "Time:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-nl.js b/rest_sys/public/javascripts/calendar/lang/calendar-nl.js
new file mode 100644
index 000000000..69a0d8d52
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-nl.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar NL language
+// Author: Linda van den Brink,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("Zondag",
+ "Maandag",
+ "Dinsdag",
+ "Woensdag",
+ "Donderdag",
+ "Vrijdag",
+ "Zaterdag",
+ "Zondag");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("Zo",
+ "Ma",
+ "Di",
+ "Wo",
+ "Do",
+ "Vr",
+ "Za",
+ "Zo");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 0;
+
+// full month names
+Calendar._MN = new Array
+("Januari",
+ "Februari",
+ "Maart",
+ "April",
+ "Mei",
+ "Juni",
+ "Juli",
+ "Augustus",
+ "September",
+ "Oktober",
+ "November",
+ "December");
+
+// short month names
+Calendar._SMN = new Array
+("Jan",
+ "Feb",
+ "Maa",
+ "Apr",
+ "Mei",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Okt",
+ "Nov",
+ "Dec");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "Over de kalender";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Datum selectie:\n" +
+"- Gebruik de \xab, \xbb knoppen om het jaar te selecteren\n" +
+"- Gebruik de " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " knoppen om de maand te selecteren\n" +
+"- Houd de muisknop ingedrukt op een van de knoppen voor snellere selectie.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Tijd selectie:\n" +
+"- Klik op een deel van de tijd om het te verhogen\n" +
+"- of Shift-click om het te verlagen\n" +
+"- of klik en sleep voor snellere selectie.";
+
+Calendar._TT["PREV_YEAR"] = "Vorig jaar (vasthouden voor menu)";
+Calendar._TT["PREV_MONTH"] = "Vorige maand (vasthouden voor menu)";
+Calendar._TT["GO_TODAY"] = "Ga naar vandaag";
+Calendar._TT["NEXT_MONTH"] = "Volgende maand (vasthouden voor menu)";
+Calendar._TT["NEXT_YEAR"] = "Volgend jaar(vasthouden voor menu)";
+Calendar._TT["SEL_DATE"] = "Selecteer datum";
+Calendar._TT["DRAG_TO_MOVE"] = "Sleep om te verplaatsen";
+Calendar._TT["PART_TODAY"] = " (vandaag)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Toon %s eerst";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "Sluiten";
+Calendar._TT["TODAY"] = "Vandaag";
+Calendar._TT["TIME_PART"] = "(Shift-)klik of sleep om waarde te wijzigen";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "wk";
+Calendar._TT["TIME"] = "Tijd:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-pl.js b/rest_sys/public/javascripts/calendar/lang/calendar-pl.js
new file mode 100644
index 000000000..32273d674
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-pl.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar EN language
+// Author: Mihai Bazon,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("Niedziela",
+ "Poniedziałek",
+ "Wtorek",
+ "Åšroda",
+ "Czwartek",
+ "PiÄ…tek",
+ "Sobota",
+ "Niedziela");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("Nie",
+ "Pon",
+ "Wto",
+ "Åšro",
+ "Czw",
+ "PiÄ…",
+ "Sob",
+ "Nie");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 1;
+
+// full month names
+Calendar._MN = new Array
+("Styczeń",
+ "Luty",
+ "Marzec",
+ "Kwiecień",
+ "Maj",
+ "Czerwiec",
+ "Lipiec",
+ "Sierpień",
+ "Wrzesień",
+ "Październik",
+ "Listopad",
+ "Grudzień");
+
+// short month names
+Calendar._SMN = new Array
+("Sty",
+ "Lut",
+ "Mar",
+ "Kwi",
+ "Maj",
+ "Cze",
+ "Lip",
+ "Sie",
+ "Wrz",
+ "Paź",
+ "Lis",
+ "Gru");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "O kalendarzu";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"Po ostatnią wersję odwiedź: http://www.dynarch.com/projects/calendar/\n" +
+"Rozpowszechniany pod licencją GNU LGPL. Zobacz: http://gnu.org/licenses/lgpl.html z celu zapoznania się ze szczegółami." +
+"\n\n" +
+"Wybór daty:\n" +
+"- Użyj \xab, \xbb przycisków by zaznaczyć rok\n" +
+"- Użyj " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " przycisków by zaznaczyć miesiąc\n" +
+"- Trzymaj wciśnięty przycisk myszy na każdym z powyższych przycisków by przyśpieszyć zaznaczanie.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Wybór czasu:\n" +
+"- Kliknij na każdym przedziale czasu aby go powiększyć\n" +
+"- lub kliknij z przyciskiem Shift by go zmniejszyć\n" +
+"- lub kliknij i przeciÄ…gnij dla szybszego zaznaczenia.";
+
+Calendar._TT["PREV_YEAR"] = "Poprz. rok (przytrzymaj dla menu)";
+Calendar._TT["PREV_MONTH"] = "Poprz. miesiÄ…c (przytrzymaj dla menu)";
+Calendar._TT["GO_TODAY"] = "Idź do Dzisiaj";
+Calendar._TT["NEXT_MONTH"] = "Następny miesiąc(przytrzymaj dla menu)";
+Calendar._TT["NEXT_YEAR"] = "Następny rok (przytrzymaj dla menu)";
+Calendar._TT["SEL_DATE"] = "Zaznacz datÄ™";
+Calendar._TT["DRAG_TO_MOVE"] = "Przeciągnij by przenieść";
+Calendar._TT["PART_TODAY"] = " (dzisiaj)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Pokaż %s pierwszy";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "Zamknij";
+Calendar._TT["TODAY"] = "Dzisiaj";
+Calendar._TT["TIME_PART"] = "(Shift-)Kliknij lub upuść by zmienić wartość";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%R-%m-%d";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "wk";
+Calendar._TT["TIME"] = "Czas:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-pt-br.js b/rest_sys/public/javascripts/calendar/lang/calendar-pt-br.js
new file mode 100644
index 000000000..5d4d014ce
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-pt-br.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar pt_BR language
+// Author: Adalberto Machado,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("Domingo",
+ "Segunda",
+ "Terca",
+ "Quarta",
+ "Quinta",
+ "Sexta",
+ "Sabado",
+ "Domingo");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("Dom",
+ "Seg",
+ "Ter",
+ "Qua",
+ "Qui",
+ "Sex",
+ "Sab",
+ "Dom");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 1;
+
+// full month names
+Calendar._MN = new Array
+("Janeiro",
+ "Fevereiro",
+ "Marco",
+ "Abril",
+ "Maio",
+ "Junho",
+ "Julho",
+ "Agosto",
+ "Setembro",
+ "Outubro",
+ "Novembro",
+ "Dezembro");
+
+// short month names
+Calendar._SMN = new Array
+("Jan",
+ "Fev",
+ "Mar",
+ "Abr",
+ "Mai",
+ "Jun",
+ "Jul",
+ "Ago",
+ "Set",
+ "Out",
+ "Nov",
+ "Dez");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "Sobre o calendario";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"Ultima versao visite: http://www.dynarch.com/projects/calendar/\n" +
+"Distribuido sobre GNU LGPL. Veja http://gnu.org/licenses/lgpl.html para detalhes." +
+"\n\n" +
+"Selecao de data:\n" +
+"- Use os botoes \xab, \xbb para selecionar o ano\n" +
+"- Use os botoes " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " para selecionar o mes\n" +
+"- Segure o botao do mouse em qualquer um desses botoes para selecao rapida.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Selecao de hora:\n" +
+"- Clique em qualquer parte da hora para incrementar\n" +
+"- ou Shift-click para decrementar\n" +
+"- ou clique e segure para selecao rapida.";
+
+Calendar._TT["PREV_YEAR"] = "Ant. ano (segure para menu)";
+Calendar._TT["PREV_MONTH"] = "Ant. mes (segure para menu)";
+Calendar._TT["GO_TODAY"] = "Hoje";
+Calendar._TT["NEXT_MONTH"] = "Prox. mes (segure para menu)";
+Calendar._TT["NEXT_YEAR"] = "Prox. ano (segure para menu)";
+Calendar._TT["SEL_DATE"] = "Selecione a data";
+Calendar._TT["DRAG_TO_MOVE"] = "Arraste para mover";
+Calendar._TT["PART_TODAY"] = " (hoje)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Mostre %s primeiro";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "Fechar";
+Calendar._TT["TODAY"] = "Hoje";
+Calendar._TT["TIME_PART"] = "(Shift-)Click ou arraste para mudar valor";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%d/%m/%Y";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %e %b";
+
+Calendar._TT["WK"] = "sm";
+Calendar._TT["TIME"] = "Hora:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-pt.js b/rest_sys/public/javascripts/calendar/lang/calendar-pt.js
new file mode 100644
index 000000000..5d4d014ce
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-pt.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar pt_BR language
+// Author: Adalberto Machado,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("Domingo",
+ "Segunda",
+ "Terca",
+ "Quarta",
+ "Quinta",
+ "Sexta",
+ "Sabado",
+ "Domingo");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("Dom",
+ "Seg",
+ "Ter",
+ "Qua",
+ "Qui",
+ "Sex",
+ "Sab",
+ "Dom");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 1;
+
+// full month names
+Calendar._MN = new Array
+("Janeiro",
+ "Fevereiro",
+ "Marco",
+ "Abril",
+ "Maio",
+ "Junho",
+ "Julho",
+ "Agosto",
+ "Setembro",
+ "Outubro",
+ "Novembro",
+ "Dezembro");
+
+// short month names
+Calendar._SMN = new Array
+("Jan",
+ "Fev",
+ "Mar",
+ "Abr",
+ "Mai",
+ "Jun",
+ "Jul",
+ "Ago",
+ "Set",
+ "Out",
+ "Nov",
+ "Dez");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "Sobre o calendario";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"Ultima versao visite: http://www.dynarch.com/projects/calendar/\n" +
+"Distribuido sobre GNU LGPL. Veja http://gnu.org/licenses/lgpl.html para detalhes." +
+"\n\n" +
+"Selecao de data:\n" +
+"- Use os botoes \xab, \xbb para selecionar o ano\n" +
+"- Use os botoes " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " para selecionar o mes\n" +
+"- Segure o botao do mouse em qualquer um desses botoes para selecao rapida.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Selecao de hora:\n" +
+"- Clique em qualquer parte da hora para incrementar\n" +
+"- ou Shift-click para decrementar\n" +
+"- ou clique e segure para selecao rapida.";
+
+Calendar._TT["PREV_YEAR"] = "Ant. ano (segure para menu)";
+Calendar._TT["PREV_MONTH"] = "Ant. mes (segure para menu)";
+Calendar._TT["GO_TODAY"] = "Hoje";
+Calendar._TT["NEXT_MONTH"] = "Prox. mes (segure para menu)";
+Calendar._TT["NEXT_YEAR"] = "Prox. ano (segure para menu)";
+Calendar._TT["SEL_DATE"] = "Selecione a data";
+Calendar._TT["DRAG_TO_MOVE"] = "Arraste para mover";
+Calendar._TT["PART_TODAY"] = " (hoje)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Mostre %s primeiro";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "Fechar";
+Calendar._TT["TODAY"] = "Hoje";
+Calendar._TT["TIME_PART"] = "(Shift-)Click ou arraste para mudar valor";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%d/%m/%Y";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %e %b";
+
+Calendar._TT["WK"] = "sm";
+Calendar._TT["TIME"] = "Hora:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-ro.js b/rest_sys/public/javascripts/calendar/lang/calendar-ro.js
new file mode 100644
index 000000000..fa34ab1ea
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-ro.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar EN language
+// Author: Mihai Bazon,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("Duminica",
+ "Luni",
+ "Marti",
+ "Miercuri",
+ "Joi",
+ "Vineri",
+ "Sambata",
+ "Duminica");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("Dum",
+ "Lun",
+ "Mar",
+ "Mie",
+ "Joi",
+ "Vin",
+ "Sam",
+ "Dum");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 0;
+
+// full month names
+Calendar._MN = new Array
+("Ianuarie",
+ "Februarie",
+ "Martie",
+ "Aprilie",
+ "Mai",
+ "Iunie",
+ "Iulie",
+ "August",
+ "Septembrie",
+ "Octombrie",
+ "Noiembrie",
+ "Decembrie");
+
+// short month names
+Calendar._SMN = new Array
+("Ian",
+ "Feb",
+ "Mar",
+ "Apr",
+ "Mai",
+ "Iun",
+ "Iul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Noi",
+ "Dec");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "Despre calendar";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Selectare data:\n" +
+"- Folositi butoanele \xab, \xbb pentru a selecta anul\n" +
+"- Folositi butoanele " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " pentru a selecta luna\n" +
+"- Lasati apasat butonul pentru o selectie mai rapida.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Selectare timp:\n" +
+"- Click pe campul de timp pentru a majora timpul\n" +
+"- sau Shift-Click pentru a micsora\n" +
+"- sau click si drag pentru manipulare rapida.";
+
+Calendar._TT["PREV_YEAR"] = "Anul precedent (apasati pentru meniu)";
+Calendar._TT["PREV_MONTH"] = "Luna precedenta (apasati pentru meniu)";
+Calendar._TT["GO_TODAY"] = "Data de azi";
+Calendar._TT["NEXT_MONTH"] = "Luna viitoare (apasati pentru meniu)";
+Calendar._TT["NEXT_YEAR"] = "Anul viitor (apasati pentru meniu)";
+Calendar._TT["SEL_DATE"] = "Selectie data";
+Calendar._TT["DRAG_TO_MOVE"] = "Drag pentru a muta";
+Calendar._TT["PART_TODAY"] = " (azi)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Vizualizeaza %s prima";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "inchide";
+Calendar._TT["TODAY"] = "Azi";
+Calendar._TT["TIME_PART"] = "(Shift-)Click sau drag pentru a schimba valoarea";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%A-%l-%z";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "sapt";
+Calendar._TT["TIME"] = "Ora:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-ru.js b/rest_sys/public/javascripts/calendar/lang/calendar-ru.js
new file mode 100644
index 000000000..6274cc892
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-ru.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar RU language
+// Translation: Sly Golovanov, http://golovanov.net,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("воÑкреÑенье",
+ "понедельник",
+ "вторник",
+ "Ñреда",
+ "четверг",
+ "пÑтница",
+ "Ñуббота",
+ "воÑкреÑенье");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("вÑк",
+ "пон",
+ "втр",
+ "Ñрд",
+ "чет",
+ "пÑÑ‚",
+ "Ñуб",
+ "вÑк");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 1;
+
+// full month names
+Calendar._MN = new Array
+("Ñнварь",
+ "февраль",
+ "март",
+ "апрель",
+ "май",
+ "июнь",
+ "июль",
+ "авгуÑÑ‚",
+ "ÑентÑбрь",
+ "октÑбрь",
+ "ноÑбрь",
+ "декабрь");
+
+// short month names
+Calendar._SMN = new Array
+("Ñнв",
+ "фев",
+ "мар",
+ "апр",
+ "май",
+ "июн",
+ "июл",
+ "авг",
+ "Ñен",
+ "окт",
+ "ноÑ",
+ "дек");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "О календаре...";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Как выбрать дату:\n" +
+"- При помощи кнопок \xab, \xbb можно выбрать год\n" +
+"- При помощи кнопок " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " можно выбрать меÑÑц\n" +
+"- Подержите Ñти кнопки нажатыми, чтобы поÑвилоÑÑŒ меню быÑтрого выбора.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Как выбрать времÑ:\n" +
+"- При клике на чаÑах или минутах они увеличиваютÑÑ\n" +
+"- при клике Ñ Ð½Ð°Ð¶Ð°Ñ‚Ð¾Ð¹ клавишей Shift они уменьшаютÑÑ\n" +
+"- еÑли нажать и двигать мышкой влево/вправо, они будут менÑтьÑÑ Ð±Ñ‹Ñтрее.";
+
+Calendar._TT["PREV_YEAR"] = "Ðа год назад (удерживать Ð´Ð»Ñ Ð¼ÐµÐ½ÑŽ)";
+Calendar._TT["PREV_MONTH"] = "Ðа меÑÑц назад (удерживать Ð´Ð»Ñ Ð¼ÐµÐ½ÑŽ)";
+Calendar._TT["GO_TODAY"] = "СегоднÑ";
+Calendar._TT["NEXT_MONTH"] = "Ðа меÑÑц вперед (удерживать Ð´Ð»Ñ Ð¼ÐµÐ½ÑŽ)";
+Calendar._TT["NEXT_YEAR"] = "Ðа год вперед (удерживать Ð´Ð»Ñ Ð¼ÐµÐ½ÑŽ)";
+Calendar._TT["SEL_DATE"] = "Выберите дату";
+Calendar._TT["DRAG_TO_MOVE"] = "ПеретаÑкивайте мышкой";
+Calendar._TT["PART_TODAY"] = " (ÑегоднÑ)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Первый день недели будет %s";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "Закрыть";
+Calendar._TT["TODAY"] = "СегоднÑ";
+Calendar._TT["TIME_PART"] = "(Shift-)клик или нажать и двигать";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
+Calendar._TT["TT_DATE_FORMAT"] = "%e %b, %a";
+
+Calendar._TT["WK"] = "нед";
+Calendar._TT["TIME"] = "ВремÑ:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-sr.js b/rest_sys/public/javascripts/calendar/lang/calendar-sr.js
new file mode 100644
index 000000000..626cbdc64
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-sr.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar SR language
+// Author: Dragan Matic,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("Nedelja",
+ "Ponedeljak",
+ "Utorak",
+ "Sreda",
+ "ÄŒetvrtak",
+ "Petak",
+ "Subota",
+ "Nedelja");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("Ned",
+ "Pon",
+ "Uto",
+ "Sre",
+ "ÄŒet",
+ "Pet",
+ "Sub",
+ "Ned");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 0;
+
+// full month names
+Calendar._MN = new Array
+("Januar",
+ "Februar",
+ "Mart",
+ "April",
+ "Maj",
+ "Jun",
+ "Jul",
+ "Avgust",
+ "Septembar",
+ "Oktobar",
+ "Novembar",
+ "Decembar");
+
+// short month names
+Calendar._SMN = new Array
+("Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "Maj",
+ "Jun",
+ "Jul",
+ "Avg",
+ "Sep",
+ "Okt",
+ "Nov",
+ "Dec");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "O kalendaru";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Date selection:\n" +
+"- Use the \xab, \xbb buttons to select year\n" +
+"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
+"- Hold mouse button on any of the above buttons for faster selection.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Time selection:\n" +
+"- Click on any of the time parts to increase it\n" +
+"- or Shift-click to decrease it\n" +
+"- or click and drag for faster selection.";
+
+Calendar._TT["PREV_YEAR"] = "Preth. godina (hold for menu)";
+Calendar._TT["PREV_MONTH"] = "Preth. mesec (hold for menu)";
+Calendar._TT["GO_TODAY"] = "Na današnji dan";
+Calendar._TT["NEXT_MONTH"] = "Naredni mesec (hold for menu)";
+Calendar._TT["NEXT_YEAR"] = "Naredna godina (hold for menu)";
+Calendar._TT["SEL_DATE"] = "Izbor datuma";
+Calendar._TT["DRAG_TO_MOVE"] = "Prevucite za izmenu";
+Calendar._TT["PART_TODAY"] = " (danas)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Prikazi %s prvo";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "Close";
+Calendar._TT["TODAY"] = "Danas";
+Calendar._TT["TIME_PART"] = "(Shift-)Klik ili prevlaÄenje za izmenu vrednosti";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%d-%m-%Y";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "wk";
+Calendar._TT["TIME"] = "Vreme:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-sv.js b/rest_sys/public/javascripts/calendar/lang/calendar-sv.js
new file mode 100644
index 000000000..7e73d7926
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-sv.js
@@ -0,0 +1,84 @@
+// ** I18N
+
+// full day names
+Calendar._DN = new Array
+("Söndag",
+ "MÃ¥ndag",
+ "Tisdag",
+ "Onsdag",
+ "Torsdag",
+ "Fredag",
+ "Lördag",
+ "Söndag");
+
+Calendar._SDN_len = 3; // short day name length
+Calendar._SMN_len = 3; // short month name length
+
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 0;
+
+// full month names
+Calendar._MN = new Array
+("Januari",
+ "Februari",
+ "Mars",
+ "April",
+ "Maj",
+ "Juni",
+ "Juli",
+ "Augusti",
+ "September",
+ "Oktober",
+ "November",
+ "December");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "About the calendar";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Date selection:\n" +
+"- Use the \xab, \xbb buttons to select year\n" +
+"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
+"- Hold mouse button on any of the above buttons for faster selection.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Time selection:\n" +
+"- Click on any of the time parts to increase it\n" +
+"- or Shift-click to decrease it\n" +
+"- or click and drag for faster selection.";
+
+Calendar._TT["PREV_YEAR"] = "Prev. year (hold for menu)";
+Calendar._TT["PREV_MONTH"] = "Prev. month (hold for menu)";
+Calendar._TT["GO_TODAY"] = "Go Today";
+Calendar._TT["NEXT_MONTH"] = "Next month (hold for menu)";
+Calendar._TT["NEXT_YEAR"] = "Next year (hold for menu)";
+Calendar._TT["SEL_DATE"] = "Select date";
+Calendar._TT["DRAG_TO_MOVE"] = "Drag to move";
+Calendar._TT["PART_TODAY"] = " (today)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Display %s first";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "Close";
+Calendar._TT["TODAY"] = "Today";
+Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "wk";
+Calendar._TT["TIME"] = "Time:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-zh-tw.js b/rest_sys/public/javascripts/calendar/lang/calendar-zh-tw.js
new file mode 100644
index 000000000..c48d25b0e
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-zh-tw.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar EN language
+// Author: Mihai Bazon,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("星期日",
+ "星期一",
+ "星期二",
+ "星期三",
+ "星期四",
+ "星期五",
+ "星期å…",
+ "星期日");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("æ—¥",
+ "一",
+ "二",
+ "三",
+ "å››",
+ "五",
+ "å…",
+ "æ—¥");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 0;
+
+// full month names
+Calendar._MN = new Array
+("一月",
+ "二月",
+ "三月",
+ "四月",
+ "五月",
+ "å…æœˆ",
+ "七月",
+ "八月",
+ "乿œˆ",
+ "åæœˆ",
+ "å一月",
+ "å二月");
+
+// short month names
+Calendar._SMN = new Array
+("一月",
+ "二月",
+ "三月",
+ "四月",
+ "五月",
+ "å…æœˆ",
+ "七月",
+ "八月",
+ "乿œˆ",
+ "åæœˆ",
+ "å一月",
+ "å二月");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "關於 calendar";
+
+Calendar._TT["ABOUT"] =
+"DHTML 日期/時間 鏿“‡å™¨\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"最For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Date selection:\n" +
+"- Use the \xab, \xbb buttons to select year\n" +
+"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
+"- Hold mouse button on any of the above buttons for faster selection.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"æ™‚é–“é¸æ“‡æ–¹å¼ï¼š\n" +
+"- ã€Œå–®æ“Šã€æ™‚分秒為éžå¢ž\n" +
+"- 或 「Shift-單擊ã€ç‚ºéžæ¸›\n" +
+"- 或 「單擊且拖拉ã€ç‚ºå¿«é€Ÿé¸æ“‡";
+
+Calendar._TT["PREV_YEAR"] = "å‰ä¸€å¹´ (按ä½ä¸æ”¾å¯é¡¯ç¤ºé¸å–®)";
+Calendar._TT["PREV_MONTH"] = "å‰ä¸€å€‹æœˆ (按ä½ä¸æ”¾å¯é¡¯ç¤ºé¸å–®)";
+Calendar._TT["GO_TODAY"] = "鏿“‡ä»Šå¤©";
+Calendar._TT["NEXT_MONTH"] = "後一個月 (按ä½ä¸æ”¾å¯é¡¯ç¤ºé¸å–®)";
+Calendar._TT["NEXT_YEAR"] = "下一年 (按ä½ä¸æ”¾å¯é¡¯å¼é¸å–®)";
+Calendar._TT["SEL_DATE"] = "è«‹é»žé¸æ—¥æœŸ";
+Calendar._TT["DRAG_TO_MOVE"] = "按ä½ä¸æ”¾å¯æ‹–拉視窗";
+Calendar._TT["PART_TODAY"] = " (今天)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "以 %s åšç‚ºä¸€é€±çš„首日";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "關閉視窗";
+Calendar._TT["TODAY"] = "今天";
+Calendar._TT["TIME_PART"] = "(Shift-)åŠ ã€Œå–®æ“Šã€æˆ–「拖拉ã€å¯è®Šæ›´å€¼";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
+Calendar._TT["TT_DATE_FORMAT"] = "星期 %a, %b %e 日";
+
+Calendar._TT["WK"] = "週";
+Calendar._TT["TIME"] = "時間:";
diff --git a/rest_sys/public/javascripts/calendar/lang/calendar-zh.js b/rest_sys/public/javascripts/calendar/lang/calendar-zh.js
new file mode 100644
index 000000000..ddb092bfa
--- /dev/null
+++ b/rest_sys/public/javascripts/calendar/lang/calendar-zh.js
@@ -0,0 +1,127 @@
+// ** I18N
+
+// Calendar Chinese language
+// Author: Andy Wu,
+// Encoding: any
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible. We strongly believe that
+// Unicode is the answer to a real internationalized world. Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
+Calendar._DN = new Array
+("星期日",
+ "星期一",
+ "星期二",
+ "星期三",
+ "星期四",
+ "星期五",
+ "星期å…",
+ "星期日");
+
+// Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary. We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+// Calendar._SDN_len = N; // short day name length
+// Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
+
+// short day names
+Calendar._SDN = new Array
+("æ—¥",
+ "一",
+ "二",
+ "三",
+ "å››",
+ "五",
+ "å…",
+ "æ—¥");
+
+// First day of the week. "0" means display Sunday first, "1" means display
+// Monday first, etc.
+Calendar._FD = 0;
+
+// full month names
+Calendar._MN = new Array
+("1月",
+ "2月",
+ "3月",
+ "4月",
+ "5月",
+ "6月",
+ "7月",
+ "8月",
+ "9月",
+ "10月",
+ "11月",
+ "12月");
+
+// short month names
+Calendar._SMN = new Array
+("1月",
+ "2月",
+ "3月",
+ "4月",
+ "5月",
+ "6月",
+ "7月",
+ "8月",
+ "9月",
+ "10月",
+ "11月",
+ "12月");
+
+// tooltips
+Calendar._TT = {};
+Calendar._TT["INFO"] = "关于日历";
+
+Calendar._TT["ABOUT"] =
+"DHTML Date/Time Selector\n" +
+"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
+"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
+"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
+"\n\n" +
+"Date selection:\n" +
+"- Use the \xab, \xbb buttons to select year\n" +
+"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
+"- Hold mouse button on any of the above buttons for faster selection.";
+Calendar._TT["ABOUT_TIME"] = "\n\n" +
+"Time selection:\n" +
+"- Click on any of the time parts to increase it\n" +
+"- or Shift-click to decrease it\n" +
+"- or click and drag for faster selection.";
+
+Calendar._TT["PREV_YEAR"] = "上年 (hold for menu)";
+Calendar._TT["PREV_MONTH"] = "上月 (hold for menu)";
+Calendar._TT["GO_TODAY"] = "回到今天";
+Calendar._TT["NEXT_MONTH"] = "下月 (hold for menu)";
+Calendar._TT["NEXT_YEAR"] = "下年 (hold for menu)";
+Calendar._TT["SEL_DATE"] = "选择日期";
+Calendar._TT["DRAG_TO_MOVE"] = "拖动";
+Calendar._TT["PART_TODAY"] = " (今日)";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "Display %s first";
+
+// This may be locale-dependent. It specifies the week-end days, as an array
+// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
+Calendar._TT["CLOSE"] = "å…³é—";
+Calendar._TT["TODAY"] = "今天";
+Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value";
+
+// date formats
+Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
+Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
+
+Calendar._TT["WK"] = "wk";
+Calendar._TT["TIME"] = "Time:";
diff --git a/rest_sys/public/javascripts/context_menu.js b/rest_sys/public/javascripts/context_menu.js
new file mode 100644
index 000000000..2e8108616
--- /dev/null
+++ b/rest_sys/public/javascripts/context_menu.js
@@ -0,0 +1,44 @@
+ContextMenu = Class.create();
+ContextMenu.prototype = {
+ initialize: function (options) {
+ this.options = Object.extend({selector: '.hascontextmenu'}, options || { });
+
+ Event.observe(document, 'click', function(e){
+ var t = Event.findElement(e, 'a');
+ if ((t != document) && (Element.hasClassName(t, 'disabled') || Element.hasClassName(t, 'submenu'))) {
+ Event.stop(e);
+ } else {
+ $('context-menu').hide();
+ if (this.selection) {
+ this.selection.removeClassName('context-menu-selection');
+ }
+ }
+
+ }.bind(this));
+
+ $$(this.options.selector).invoke('observe', (window.opera ? 'click' : 'contextmenu'), function(e){
+ if (window.opera && !e.ctrlKey) {
+ return;
+ }
+ this.show(e);
+ }.bind(this));
+
+ },
+ show: function(e) {
+ Event.stop(e);
+ Element.hide('context-menu');
+ if (this.selection) {
+ this.selection.removeClassName('context-menu-selection');
+ }
+ $('context-menu').style['left'] = (Event.pointerX(e) + 'px');
+ $('context-menu').style['top'] = (Event.pointerY(e) + 'px');
+ Element.update('context-menu', '');
+
+ var tr = Event.findElement(e, 'tr');
+ tr.addClassName('context-menu-selection');
+ this.selection = tr;
+ var id = tr.id.substring(6, tr.id.length);
+ /* TODO: do not hard code path */
+ new Ajax.Updater({success:'context-menu'}, '../../issues/context_menu/' + id, {asynchronous:true, evalScripts:true, onComplete:function(request){Effect.Appear('context-menu', {duration: 0.20})}})
+ }
+}
diff --git a/rest_sys/public/javascripts/controls.js b/rest_sys/public/javascripts/controls.js
new file mode 100644
index 000000000..8c273f874
--- /dev/null
+++ b/rest_sys/public/javascripts/controls.js
@@ -0,0 +1,833 @@
+// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005, 2006 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
+// (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com)
+// Contributors:
+// Richard Livsey
+// Rahul Bhargava
+// Rob Wills
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+// Autocompleter.Base handles all the autocompletion functionality
+// that's independent of the data source for autocompletion. This
+// includes drawing the autocompletion menu, observing keyboard
+// and mouse events, and similar.
+//
+// Specific autocompleters need to provide, at the very least,
+// a getUpdatedChoices function that will be invoked every time
+// the text inside the monitored textbox changes. This method
+// should get the text for which to provide autocompletion by
+// invoking this.getToken(), NOT by directly accessing
+// this.element.value. This is to allow incremental tokenized
+// autocompletion. Specific auto-completion logic (AJAX, etc)
+// belongs in getUpdatedChoices.
+//
+// Tokenized incremental autocompletion is enabled automatically
+// when an autocompleter is instantiated with the 'tokens' option
+// in the options parameter, e.g.:
+// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' });
+// will incrementally autocomplete with a comma as the token.
+// Additionally, ',' in the above example can be replaced with
+// a token array, e.g. { tokens: [',', '\n'] } which
+// enables autocompletion on multiple tokens. This is most
+// useful when one of the tokens is \n (a newline), as it
+// allows smart autocompletion after linebreaks.
+
+if(typeof Effect == 'undefined')
+ throw("controls.js requires including script.aculo.us' effects.js library");
+
+var Autocompleter = {}
+Autocompleter.Base = function() {};
+Autocompleter.Base.prototype = {
+ baseInitialize: function(element, update, options) {
+ this.element = $(element);
+ this.update = $(update);
+ this.hasFocus = false;
+ this.changed = false;
+ this.active = false;
+ this.index = 0;
+ this.entryCount = 0;
+
+ if(this.setOptions)
+ this.setOptions(options);
+ else
+ this.options = options || {};
+
+ this.options.paramName = this.options.paramName || this.element.name;
+ this.options.tokens = this.options.tokens || [];
+ this.options.frequency = this.options.frequency || 0.4;
+ this.options.minChars = this.options.minChars || 1;
+ this.options.onShow = this.options.onShow ||
+ function(element, update){
+ if(!update.style.position || update.style.position=='absolute') {
+ update.style.position = 'absolute';
+ Position.clone(element, update, {
+ setHeight: false,
+ offsetTop: element.offsetHeight
+ });
+ }
+ Effect.Appear(update,{duration:0.15});
+ };
+ this.options.onHide = this.options.onHide ||
+ function(element, update){ new Effect.Fade(update,{duration:0.15}) };
+
+ if(typeof(this.options.tokens) == 'string')
+ this.options.tokens = new Array(this.options.tokens);
+
+ this.observer = null;
+
+ this.element.setAttribute('autocomplete','off');
+
+ Element.hide(this.update);
+
+ Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this));
+ Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this));
+ },
+
+ show: function() {
+ if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
+ if(!this.iefix &&
+ (navigator.appVersion.indexOf('MSIE')>0) &&
+ (navigator.userAgent.indexOf('Opera')<0) &&
+ (Element.getStyle(this.update, 'position')=='absolute')) {
+ new Insertion.After(this.update,
+ '');
+ this.iefix = $(this.update.id+'_iefix');
+ }
+ if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
+ },
+
+ fixIEOverlapping: function() {
+ Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
+ this.iefix.style.zIndex = 1;
+ this.update.style.zIndex = 2;
+ Element.show(this.iefix);
+ },
+
+ hide: function() {
+ this.stopIndicator();
+ if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
+ if(this.iefix) Element.hide(this.iefix);
+ },
+
+ startIndicator: function() {
+ if(this.options.indicator) Element.show(this.options.indicator);
+ },
+
+ stopIndicator: function() {
+ if(this.options.indicator) Element.hide(this.options.indicator);
+ },
+
+ onKeyPress: function(event) {
+ if(this.active)
+ switch(event.keyCode) {
+ case Event.KEY_TAB:
+ case Event.KEY_RETURN:
+ this.selectEntry();
+ Event.stop(event);
+ case Event.KEY_ESC:
+ this.hide();
+ this.active = false;
+ Event.stop(event);
+ return;
+ case Event.KEY_LEFT:
+ case Event.KEY_RIGHT:
+ return;
+ case Event.KEY_UP:
+ this.markPrevious();
+ this.render();
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
+ return;
+ case Event.KEY_DOWN:
+ this.markNext();
+ this.render();
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
+ return;
+ }
+ else
+ if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
+ (navigator.appVersion.indexOf('AppleWebKit') > 0 && event.keyCode == 0)) return;
+
+ this.changed = true;
+ this.hasFocus = true;
+
+ if(this.observer) clearTimeout(this.observer);
+ this.observer =
+ setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
+ },
+
+ activate: function() {
+ this.changed = false;
+ this.hasFocus = true;
+ this.getUpdatedChoices();
+ },
+
+ onHover: function(event) {
+ var element = Event.findElement(event, 'LI');
+ if(this.index != element.autocompleteIndex)
+ {
+ this.index = element.autocompleteIndex;
+ this.render();
+ }
+ Event.stop(event);
+ },
+
+ onClick: function(event) {
+ var element = Event.findElement(event, 'LI');
+ this.index = element.autocompleteIndex;
+ this.selectEntry();
+ this.hide();
+ },
+
+ onBlur: function(event) {
+ // needed to make click events working
+ setTimeout(this.hide.bind(this), 250);
+ this.hasFocus = false;
+ this.active = false;
+ },
+
+ render: function() {
+ if(this.entryCount > 0) {
+ for (var i = 0; i < this.entryCount; i++)
+ this.index==i ?
+ Element.addClassName(this.getEntry(i),"selected") :
+ Element.removeClassName(this.getEntry(i),"selected");
+
+ if(this.hasFocus) {
+ this.show();
+ this.active = true;
+ }
+ } else {
+ this.active = false;
+ this.hide();
+ }
+ },
+
+ markPrevious: function() {
+ if(this.index > 0) this.index--
+ else this.index = this.entryCount-1;
+ this.getEntry(this.index).scrollIntoView(true);
+ },
+
+ markNext: function() {
+ if(this.index < this.entryCount-1) this.index++
+ else this.index = 0;
+ this.getEntry(this.index).scrollIntoView(false);
+ },
+
+ getEntry: function(index) {
+ return this.update.firstChild.childNodes[index];
+ },
+
+ getCurrentEntry: function() {
+ return this.getEntry(this.index);
+ },
+
+ selectEntry: function() {
+ this.active = false;
+ this.updateElement(this.getCurrentEntry());
+ },
+
+ updateElement: function(selectedElement) {
+ if (this.options.updateElement) {
+ this.options.updateElement(selectedElement);
+ return;
+ }
+ var value = '';
+ if (this.options.select) {
+ var nodes = document.getElementsByClassName(this.options.select, selectedElement) || [];
+ if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
+ } else
+ value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
+
+ var lastTokenPos = this.findLastToken();
+ if (lastTokenPos != -1) {
+ var newValue = this.element.value.substr(0, lastTokenPos + 1);
+ var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/);
+ if (whitespace)
+ newValue += whitespace[0];
+ this.element.value = newValue + value;
+ } else {
+ this.element.value = value;
+ }
+ this.element.focus();
+
+ if (this.options.afterUpdateElement)
+ this.options.afterUpdateElement(this.element, selectedElement);
+ },
+
+ updateChoices: function(choices) {
+ if(!this.changed && this.hasFocus) {
+ this.update.innerHTML = choices;
+ Element.cleanWhitespace(this.update);
+ Element.cleanWhitespace(this.update.down());
+
+ if(this.update.firstChild && this.update.down().childNodes) {
+ this.entryCount =
+ this.update.down().childNodes.length;
+ for (var i = 0; i < this.entryCount; i++) {
+ var entry = this.getEntry(i);
+ entry.autocompleteIndex = i;
+ this.addObservers(entry);
+ }
+ } else {
+ this.entryCount = 0;
+ }
+
+ this.stopIndicator();
+ this.index = 0;
+
+ if(this.entryCount==1 && this.options.autoSelect) {
+ this.selectEntry();
+ this.hide();
+ } else {
+ this.render();
+ }
+ }
+ },
+
+ addObservers: function(element) {
+ Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
+ Event.observe(element, "click", this.onClick.bindAsEventListener(this));
+ },
+
+ onObserverEvent: function() {
+ this.changed = false;
+ if(this.getToken().length>=this.options.minChars) {
+ this.startIndicator();
+ this.getUpdatedChoices();
+ } else {
+ this.active = false;
+ this.hide();
+ }
+ },
+
+ getToken: function() {
+ var tokenPos = this.findLastToken();
+ if (tokenPos != -1)
+ var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,'');
+ else
+ var ret = this.element.value;
+
+ return /\n/.test(ret) ? '' : ret;
+ },
+
+ findLastToken: function() {
+ var lastTokenPos = -1;
+
+ for (var i=0; i lastTokenPos)
+ lastTokenPos = thisTokenPos;
+ }
+ return lastTokenPos;
+ }
+}
+
+Ajax.Autocompleter = Class.create();
+Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {
+ initialize: function(element, update, url, options) {
+ this.baseInitialize(element, update, options);
+ this.options.asynchronous = true;
+ this.options.onComplete = this.onComplete.bind(this);
+ this.options.defaultParams = this.options.parameters || null;
+ this.url = url;
+ },
+
+ getUpdatedChoices: function() {
+ entry = encodeURIComponent(this.options.paramName) + '=' +
+ encodeURIComponent(this.getToken());
+
+ this.options.parameters = this.options.callback ?
+ this.options.callback(this.element, entry) : entry;
+
+ if(this.options.defaultParams)
+ this.options.parameters += '&' + this.options.defaultParams;
+
+ new Ajax.Request(this.url, this.options);
+ },
+
+ onComplete: function(request) {
+ this.updateChoices(request.responseText);
+ }
+
+});
+
+// The local array autocompleter. Used when you'd prefer to
+// inject an array of autocompletion options into the page, rather
+// than sending out Ajax queries, which can be quite slow sometimes.
+//
+// The constructor takes four parameters. The first two are, as usual,
+// the id of the monitored textbox, and id of the autocompletion menu.
+// The third is the array you want to autocomplete from, and the fourth
+// is the options block.
+//
+// Extra local autocompletion options:
+// - choices - How many autocompletion choices to offer
+//
+// - partialSearch - If false, the autocompleter will match entered
+// text only at the beginning of strings in the
+// autocomplete array. Defaults to true, which will
+// match text at the beginning of any *word* in the
+// strings in the autocomplete array. If you want to
+// search anywhere in the string, additionally set
+// the option fullSearch to true (default: off).
+//
+// - fullSsearch - Search anywhere in autocomplete array strings.
+//
+// - partialChars - How many characters to enter before triggering
+// a partial match (unlike minChars, which defines
+// how many characters are required to do any match
+// at all). Defaults to 2.
+//
+// - ignoreCase - Whether to ignore case when autocompleting.
+// Defaults to true.
+//
+// It's possible to pass in a custom function as the 'selector'
+// option, if you prefer to write your own autocompletion logic.
+// In that case, the other options above will not apply unless
+// you support them.
+
+Autocompleter.Local = Class.create();
+Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), {
+ initialize: function(element, update, array, options) {
+ this.baseInitialize(element, update, options);
+ this.options.array = array;
+ },
+
+ getUpdatedChoices: function() {
+ this.updateChoices(this.options.selector(this));
+ },
+
+ setOptions: function(options) {
+ this.options = Object.extend({
+ choices: 10,
+ partialSearch: true,
+ partialChars: 2,
+ ignoreCase: true,
+ fullSearch: false,
+ selector: function(instance) {
+ var ret = []; // Beginning matches
+ var partial = []; // Inside matches
+ var entry = instance.getToken();
+ var count = 0;
+
+ for (var i = 0; i < instance.options.array.length &&
+ ret.length < instance.options.choices ; i++) {
+
+ var elem = instance.options.array[i];
+ var foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase()) :
+ elem.indexOf(entry);
+
+ while (foundPos != -1) {
+ if (foundPos == 0 && elem.length != entry.length) {
+ ret.push("" + elem.substr(0, entry.length) + " " +
+ elem.substr(entry.length) + " ");
+ break;
+ } else if (entry.length >= instance.options.partialChars &&
+ instance.options.partialSearch && foundPos != -1) {
+ if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
+ partial.push("" + elem.substr(0, foundPos) + "" +
+ elem.substr(foundPos, entry.length) + " " + elem.substr(
+ foundPos + entry.length) + " ");
+ break;
+ }
+ }
+
+ foundPos = instance.options.ignoreCase ?
+ elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
+ elem.indexOf(entry, foundPos + 1);
+
+ }
+ }
+ if (partial.length)
+ ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
+ return "";
+ }
+ }, options || {});
+ }
+});
+
+// AJAX in-place editor
+//
+// see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
+
+// Use this if you notice weird scrolling problems on some browsers,
+// the DOM might be a bit confused when this gets called so do this
+// waits 1 ms (with setTimeout) until it does the activation
+Field.scrollFreeActivate = function(field) {
+ setTimeout(function() {
+ Field.activate(field);
+ }, 1);
+}
+
+Ajax.InPlaceEditor = Class.create();
+Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99";
+Ajax.InPlaceEditor.prototype = {
+ initialize: function(element, url, options) {
+ this.url = url;
+ this.element = $(element);
+
+ this.options = Object.extend({
+ paramName: "value",
+ okButton: true,
+ okText: "ok",
+ cancelLink: true,
+ cancelText: "cancel",
+ savingText: "Saving...",
+ clickToEditText: "Click to edit",
+ okText: "ok",
+ rows: 1,
+ onComplete: function(transport, element) {
+ new Effect.Highlight(element, {startcolor: this.options.highlightcolor});
+ },
+ onFailure: function(transport) {
+ alert("Error communicating with the server: " + transport.responseText.stripTags());
+ },
+ callback: function(form) {
+ return Form.serialize(form);
+ },
+ handleLineBreaks: true,
+ loadingText: 'Loading...',
+ savingClassName: 'inplaceeditor-saving',
+ loadingClassName: 'inplaceeditor-loading',
+ formClassName: 'inplaceeditor-form',
+ highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
+ highlightendcolor: "#FFFFFF",
+ externalControl: null,
+ submitOnBlur: false,
+ ajaxOptions: {},
+ evalScripts: false
+ }, options || {});
+
+ if(!this.options.formId && this.element.id) {
+ this.options.formId = this.element.id + "-inplaceeditor";
+ if ($(this.options.formId)) {
+ // there's already a form with that name, don't specify an id
+ this.options.formId = null;
+ }
+ }
+
+ if (this.options.externalControl) {
+ this.options.externalControl = $(this.options.externalControl);
+ }
+
+ this.originalBackground = Element.getStyle(this.element, 'background-color');
+ if (!this.originalBackground) {
+ this.originalBackground = "transparent";
+ }
+
+ this.element.title = this.options.clickToEditText;
+
+ this.onclickListener = this.enterEditMode.bindAsEventListener(this);
+ this.mouseoverListener = this.enterHover.bindAsEventListener(this);
+ this.mouseoutListener = this.leaveHover.bindAsEventListener(this);
+ Event.observe(this.element, 'click', this.onclickListener);
+ Event.observe(this.element, 'mouseover', this.mouseoverListener);
+ Event.observe(this.element, 'mouseout', this.mouseoutListener);
+ if (this.options.externalControl) {
+ Event.observe(this.options.externalControl, 'click', this.onclickListener);
+ Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener);
+ Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener);
+ }
+ },
+ enterEditMode: function(evt) {
+ if (this.saving) return;
+ if (this.editing) return;
+ this.editing = true;
+ this.onEnterEditMode();
+ if (this.options.externalControl) {
+ Element.hide(this.options.externalControl);
+ }
+ Element.hide(this.element);
+ this.createForm();
+ this.element.parentNode.insertBefore(this.form, this.element);
+ if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField);
+ // stop the event to avoid a page refresh in Safari
+ if (evt) {
+ Event.stop(evt);
+ }
+ return false;
+ },
+ createForm: function() {
+ this.form = document.createElement("form");
+ this.form.id = this.options.formId;
+ Element.addClassName(this.form, this.options.formClassName)
+ this.form.onsubmit = this.onSubmit.bind(this);
+
+ this.createEditField();
+
+ if (this.options.textarea) {
+ var br = document.createElement("br");
+ this.form.appendChild(br);
+ }
+
+ if (this.options.okButton) {
+ okButton = document.createElement("input");
+ okButton.type = "submit";
+ okButton.value = this.options.okText;
+ okButton.className = 'editor_ok_button';
+ this.form.appendChild(okButton);
+ }
+
+ if (this.options.cancelLink) {
+ cancelLink = document.createElement("a");
+ cancelLink.href = "#";
+ cancelLink.appendChild(document.createTextNode(this.options.cancelText));
+ cancelLink.onclick = this.onclickCancel.bind(this);
+ cancelLink.className = 'editor_cancel';
+ this.form.appendChild(cancelLink);
+ }
+ },
+ hasHTMLLineBreaks: function(string) {
+ if (!this.options.handleLineBreaks) return false;
+ return string.match(/ /i);
+ },
+ convertHTMLLineBreaks: function(string) {
+ return string.replace(/ /gi, "\n").replace(/ /gi, "\n").replace(/<\/p>/gi, "\n").replace(//gi, "");
+ },
+ createEditField: function() {
+ var text;
+ if(this.options.loadTextURL) {
+ text = this.options.loadingText;
+ } else {
+ text = this.getText();
+ }
+
+ var obj = this;
+
+ if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
+ this.options.textarea = false;
+ var textField = document.createElement("input");
+ textField.obj = this;
+ textField.type = "text";
+ textField.name = this.options.paramName;
+ textField.value = text;
+ textField.style.backgroundColor = this.options.highlightcolor;
+ textField.className = 'editor_field';
+ var size = this.options.size || this.options.cols || 0;
+ if (size != 0) textField.size = size;
+ if (this.options.submitOnBlur)
+ textField.onblur = this.onSubmit.bind(this);
+ this.editField = textField;
+ } else {
+ this.options.textarea = true;
+ var textArea = document.createElement("textarea");
+ textArea.obj = this;
+ textArea.name = this.options.paramName;
+ textArea.value = this.convertHTMLLineBreaks(text);
+ textArea.rows = this.options.rows;
+ textArea.cols = this.options.cols || 40;
+ textArea.className = 'editor_field';
+ if (this.options.submitOnBlur)
+ textArea.onblur = this.onSubmit.bind(this);
+ this.editField = textArea;
+ }
+
+ if(this.options.loadTextURL) {
+ this.loadExternalText();
+ }
+ this.form.appendChild(this.editField);
+ },
+ getText: function() {
+ return this.element.innerHTML;
+ },
+ loadExternalText: function() {
+ Element.addClassName(this.form, this.options.loadingClassName);
+ this.editField.disabled = true;
+ new Ajax.Request(
+ this.options.loadTextURL,
+ Object.extend({
+ asynchronous: true,
+ onComplete: this.onLoadedExternalText.bind(this)
+ }, this.options.ajaxOptions)
+ );
+ },
+ onLoadedExternalText: function(transport) {
+ Element.removeClassName(this.form, this.options.loadingClassName);
+ this.editField.disabled = false;
+ this.editField.value = transport.responseText.stripTags();
+ Field.scrollFreeActivate(this.editField);
+ },
+ onclickCancel: function() {
+ this.onComplete();
+ this.leaveEditMode();
+ return false;
+ },
+ onFailure: function(transport) {
+ this.options.onFailure(transport);
+ if (this.oldInnerHTML) {
+ this.element.innerHTML = this.oldInnerHTML;
+ this.oldInnerHTML = null;
+ }
+ return false;
+ },
+ onSubmit: function() {
+ // onLoading resets these so we need to save them away for the Ajax call
+ var form = this.form;
+ var value = this.editField.value;
+
+ // do this first, sometimes the ajax call returns before we get a chance to switch on Saving...
+ // which means this will actually switch on Saving... *after* we've left edit mode causing Saving...
+ // to be displayed indefinitely
+ this.onLoading();
+
+ if (this.options.evalScripts) {
+ new Ajax.Request(
+ this.url, Object.extend({
+ parameters: this.options.callback(form, value),
+ onComplete: this.onComplete.bind(this),
+ onFailure: this.onFailure.bind(this),
+ asynchronous:true,
+ evalScripts:true
+ }, this.options.ajaxOptions));
+ } else {
+ new Ajax.Updater(
+ { success: this.element,
+ // don't update on failure (this could be an option)
+ failure: null },
+ this.url, Object.extend({
+ parameters: this.options.callback(form, value),
+ onComplete: this.onComplete.bind(this),
+ onFailure: this.onFailure.bind(this)
+ }, this.options.ajaxOptions));
+ }
+ // stop the event to avoid a page refresh in Safari
+ if (arguments.length > 1) {
+ Event.stop(arguments[0]);
+ }
+ return false;
+ },
+ onLoading: function() {
+ this.saving = true;
+ this.removeForm();
+ this.leaveHover();
+ this.showSaving();
+ },
+ showSaving: function() {
+ this.oldInnerHTML = this.element.innerHTML;
+ this.element.innerHTML = this.options.savingText;
+ Element.addClassName(this.element, this.options.savingClassName);
+ this.element.style.backgroundColor = this.originalBackground;
+ Element.show(this.element);
+ },
+ removeForm: function() {
+ if(this.form) {
+ if (this.form.parentNode) Element.remove(this.form);
+ this.form = null;
+ }
+ },
+ enterHover: function() {
+ if (this.saving) return;
+ this.element.style.backgroundColor = this.options.highlightcolor;
+ if (this.effect) {
+ this.effect.cancel();
+ }
+ Element.addClassName(this.element, this.options.hoverClassName)
+ },
+ leaveHover: function() {
+ if (this.options.backgroundColor) {
+ this.element.style.backgroundColor = this.oldBackground;
+ }
+ Element.removeClassName(this.element, this.options.hoverClassName)
+ if (this.saving) return;
+ this.effect = new Effect.Highlight(this.element, {
+ startcolor: this.options.highlightcolor,
+ endcolor: this.options.highlightendcolor,
+ restorecolor: this.originalBackground
+ });
+ },
+ leaveEditMode: function() {
+ Element.removeClassName(this.element, this.options.savingClassName);
+ this.removeForm();
+ this.leaveHover();
+ this.element.style.backgroundColor = this.originalBackground;
+ Element.show(this.element);
+ if (this.options.externalControl) {
+ Element.show(this.options.externalControl);
+ }
+ this.editing = false;
+ this.saving = false;
+ this.oldInnerHTML = null;
+ this.onLeaveEditMode();
+ },
+ onComplete: function(transport) {
+ this.leaveEditMode();
+ this.options.onComplete.bind(this)(transport, this.element);
+ },
+ onEnterEditMode: function() {},
+ onLeaveEditMode: function() {},
+ dispose: function() {
+ if (this.oldInnerHTML) {
+ this.element.innerHTML = this.oldInnerHTML;
+ }
+ this.leaveEditMode();
+ Event.stopObserving(this.element, 'click', this.onclickListener);
+ Event.stopObserving(this.element, 'mouseover', this.mouseoverListener);
+ Event.stopObserving(this.element, 'mouseout', this.mouseoutListener);
+ if (this.options.externalControl) {
+ Event.stopObserving(this.options.externalControl, 'click', this.onclickListener);
+ Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener);
+ Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener);
+ }
+ }
+};
+
+Ajax.InPlaceCollectionEditor = Class.create();
+Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype);
+Object.extend(Ajax.InPlaceCollectionEditor.prototype, {
+ createEditField: function() {
+ if (!this.cached_selectTag) {
+ var selectTag = document.createElement("select");
+ var collection = this.options.collection || [];
+ var optionTag;
+ collection.each(function(e,i) {
+ optionTag = document.createElement("option");
+ optionTag.value = (e instanceof Array) ? e[0] : e;
+ if((typeof this.options.value == 'undefined') &&
+ ((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected = true;
+ if(this.options.value==optionTag.value) optionTag.selected = true;
+ optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e));
+ selectTag.appendChild(optionTag);
+ }.bind(this));
+ this.cached_selectTag = selectTag;
+ }
+
+ this.editField = this.cached_selectTag;
+ if(this.options.loadTextURL) this.loadExternalText();
+ this.form.appendChild(this.editField);
+ this.options.callback = function(form, value) {
+ return "value=" + encodeURIComponent(value);
+ }
+ }
+});
+
+// Delayed observer, like Form.Element.Observer,
+// but waits for delay after last key input
+// Ideal for live-search fields
+
+Form.Element.DelayedObserver = Class.create();
+Form.Element.DelayedObserver.prototype = {
+ initialize: function(element, delay, callback) {
+ this.delay = delay || 0.5;
+ this.element = $(element);
+ this.callback = callback;
+ this.timer = null;
+ this.lastValue = $F(this.element);
+ Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
+ },
+ delayedListener: function(event) {
+ if(this.lastValue == $F(this.element)) return;
+ if(this.timer) clearTimeout(this.timer);
+ this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);
+ this.lastValue = $F(this.element);
+ },
+ onTimerEvent: function() {
+ this.timer = null;
+ this.callback(this.element, $F(this.element));
+ }
+};
diff --git a/rest_sys/public/javascripts/dragdrop.js b/rest_sys/public/javascripts/dragdrop.js
new file mode 100644
index 000000000..c71ddb827
--- /dev/null
+++ b/rest_sys/public/javascripts/dragdrop.js
@@ -0,0 +1,942 @@
+// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// (c) 2005, 2006 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+if(typeof Effect == 'undefined')
+ throw("dragdrop.js requires including script.aculo.us' effects.js library");
+
+var Droppables = {
+ drops: [],
+
+ remove: function(element) {
+ this.drops = this.drops.reject(function(d) { return d.element==$(element) });
+ },
+
+ add: function(element) {
+ element = $(element);
+ var options = Object.extend({
+ greedy: true,
+ hoverclass: null,
+ tree: false
+ }, arguments[1] || {});
+
+ // cache containers
+ if(options.containment) {
+ options._containers = [];
+ var containment = options.containment;
+ if((typeof containment == 'object') &&
+ (containment.constructor == Array)) {
+ containment.each( function(c) { options._containers.push($(c)) });
+ } else {
+ options._containers.push($(containment));
+ }
+ }
+
+ if(options.accept) options.accept = [options.accept].flatten();
+
+ Element.makePositioned(element); // fix IE
+ options.element = element;
+
+ this.drops.push(options);
+ },
+
+ findDeepestChild: function(drops) {
+ deepest = drops[0];
+
+ for (i = 1; i < drops.length; ++i)
+ if (Element.isParent(drops[i].element, deepest.element))
+ deepest = drops[i];
+
+ return deepest;
+ },
+
+ isContained: function(element, drop) {
+ var containmentNode;
+ if(drop.tree) {
+ containmentNode = element.treeNode;
+ } else {
+ containmentNode = element.parentNode;
+ }
+ return drop._containers.detect(function(c) { return containmentNode == c });
+ },
+
+ isAffected: function(point, element, drop) {
+ return (
+ (drop.element!=element) &&
+ ((!drop._containers) ||
+ this.isContained(element, drop)) &&
+ ((!drop.accept) ||
+ (Element.classNames(element).detect(
+ function(v) { return drop.accept.include(v) } ) )) &&
+ Position.within(drop.element, point[0], point[1]) );
+ },
+
+ deactivate: function(drop) {
+ if(drop.hoverclass)
+ Element.removeClassName(drop.element, drop.hoverclass);
+ this.last_active = null;
+ },
+
+ activate: function(drop) {
+ if(drop.hoverclass)
+ Element.addClassName(drop.element, drop.hoverclass);
+ this.last_active = drop;
+ },
+
+ show: function(point, element) {
+ if(!this.drops.length) return;
+ var affected = [];
+
+ if(this.last_active) this.deactivate(this.last_active);
+ this.drops.each( function(drop) {
+ if(Droppables.isAffected(point, element, drop))
+ affected.push(drop);
+ });
+
+ if(affected.length>0) {
+ drop = Droppables.findDeepestChild(affected);
+ Position.within(drop.element, point[0], point[1]);
+ if(drop.onHover)
+ drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
+
+ Droppables.activate(drop);
+ }
+ },
+
+ fire: function(event, element) {
+ if(!this.last_active) return;
+ Position.prepare();
+
+ if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
+ if (this.last_active.onDrop)
+ this.last_active.onDrop(element, this.last_active.element, event);
+ },
+
+ reset: function() {
+ if(this.last_active)
+ this.deactivate(this.last_active);
+ }
+}
+
+var Draggables = {
+ drags: [],
+ observers: [],
+
+ register: function(draggable) {
+ if(this.drags.length == 0) {
+ this.eventMouseUp = this.endDrag.bindAsEventListener(this);
+ this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
+ this.eventKeypress = this.keyPress.bindAsEventListener(this);
+
+ Event.observe(document, "mouseup", this.eventMouseUp);
+ Event.observe(document, "mousemove", this.eventMouseMove);
+ Event.observe(document, "keypress", this.eventKeypress);
+ }
+ this.drags.push(draggable);
+ },
+
+ unregister: function(draggable) {
+ this.drags = this.drags.reject(function(d) { return d==draggable });
+ if(this.drags.length == 0) {
+ Event.stopObserving(document, "mouseup", this.eventMouseUp);
+ Event.stopObserving(document, "mousemove", this.eventMouseMove);
+ Event.stopObserving(document, "keypress", this.eventKeypress);
+ }
+ },
+
+ activate: function(draggable) {
+ if(draggable.options.delay) {
+ this._timeout = setTimeout(function() {
+ Draggables._timeout = null;
+ window.focus();
+ Draggables.activeDraggable = draggable;
+ }.bind(this), draggable.options.delay);
+ } else {
+ window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
+ this.activeDraggable = draggable;
+ }
+ },
+
+ deactivate: function() {
+ this.activeDraggable = null;
+ },
+
+ updateDrag: function(event) {
+ if(!this.activeDraggable) return;
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ // Mozilla-based browsers fire successive mousemove events with
+ // the same coordinates, prevent needless redrawing (moz bug?)
+ if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
+ this._lastPointer = pointer;
+
+ this.activeDraggable.updateDrag(event, pointer);
+ },
+
+ endDrag: function(event) {
+ if(this._timeout) {
+ clearTimeout(this._timeout);
+ this._timeout = null;
+ }
+ if(!this.activeDraggable) return;
+ this._lastPointer = null;
+ this.activeDraggable.endDrag(event);
+ this.activeDraggable = null;
+ },
+
+ keyPress: function(event) {
+ if(this.activeDraggable)
+ this.activeDraggable.keyPress(event);
+ },
+
+ addObserver: function(observer) {
+ this.observers.push(observer);
+ this._cacheObserverCallbacks();
+ },
+
+ removeObserver: function(element) { // element instead of observer fixes mem leaks
+ this.observers = this.observers.reject( function(o) { return o.element==element });
+ this._cacheObserverCallbacks();
+ },
+
+ notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
+ if(this[eventName+'Count'] > 0)
+ this.observers.each( function(o) {
+ if(o[eventName]) o[eventName](eventName, draggable, event);
+ });
+ if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
+ },
+
+ _cacheObserverCallbacks: function() {
+ ['onStart','onEnd','onDrag'].each( function(eventName) {
+ Draggables[eventName+'Count'] = Draggables.observers.select(
+ function(o) { return o[eventName]; }
+ ).length;
+ });
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+
+var Draggable = Class.create();
+Draggable._dragging = {};
+
+Draggable.prototype = {
+ initialize: function(element) {
+ var defaults = {
+ handle: false,
+ reverteffect: function(element, top_offset, left_offset) {
+ var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
+ new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur,
+ queue: {scope:'_draggable', position:'end'}
+ });
+ },
+ endeffect: function(element) {
+ var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0;
+ new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
+ queue: {scope:'_draggable', position:'end'},
+ afterFinish: function(){
+ Draggable._dragging[element] = false
+ }
+ });
+ },
+ zindex: 1000,
+ revert: false,
+ scroll: false,
+ scrollSensitivity: 20,
+ scrollSpeed: 15,
+ snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] }
+ delay: 0
+ };
+
+ if(!arguments[1] || typeof arguments[1].endeffect == 'undefined')
+ Object.extend(defaults, {
+ starteffect: function(element) {
+ element._opacity = Element.getOpacity(element);
+ Draggable._dragging[element] = true;
+ new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
+ }
+ });
+
+ var options = Object.extend(defaults, arguments[1] || {});
+
+ this.element = $(element);
+
+ if(options.handle && (typeof options.handle == 'string'))
+ this.handle = this.element.down('.'+options.handle, 0);
+
+ if(!this.handle) this.handle = $(options.handle);
+ if(!this.handle) this.handle = this.element;
+
+ if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
+ options.scroll = $(options.scroll);
+ this._isScrollChild = Element.childOf(this.element, options.scroll);
+ }
+
+ Element.makePositioned(this.element); // fix IE
+
+ this.delta = this.currentDelta();
+ this.options = options;
+ this.dragging = false;
+
+ this.eventMouseDown = this.initDrag.bindAsEventListener(this);
+ Event.observe(this.handle, "mousedown", this.eventMouseDown);
+
+ Draggables.register(this);
+ },
+
+ destroy: function() {
+ Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
+ Draggables.unregister(this);
+ },
+
+ currentDelta: function() {
+ return([
+ parseInt(Element.getStyle(this.element,'left') || '0'),
+ parseInt(Element.getStyle(this.element,'top') || '0')]);
+ },
+
+ initDrag: function(event) {
+ if(typeof Draggable._dragging[this.element] != 'undefined' &&
+ Draggable._dragging[this.element]) return;
+ if(Event.isLeftClick(event)) {
+ // abort on form elements, fixes a Firefox issue
+ var src = Event.element(event);
+ if(src.tagName && (
+ src.tagName=='INPUT' ||
+ src.tagName=='SELECT' ||
+ src.tagName=='OPTION' ||
+ src.tagName=='BUTTON' ||
+ src.tagName=='TEXTAREA')) return;
+
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var pos = Position.cumulativeOffset(this.element);
+ this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
+
+ Draggables.activate(this);
+ Event.stop(event);
+ }
+ },
+
+ startDrag: function(event) {
+ this.dragging = true;
+
+ if(this.options.zindex) {
+ this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
+ this.element.style.zIndex = this.options.zindex;
+ }
+
+ if(this.options.ghosting) {
+ this._clone = this.element.cloneNode(true);
+ Position.absolutize(this.element);
+ this.element.parentNode.insertBefore(this._clone, this.element);
+ }
+
+ if(this.options.scroll) {
+ if (this.options.scroll == window) {
+ var where = this._getWindowScroll(this.options.scroll);
+ this.originalScrollLeft = where.left;
+ this.originalScrollTop = where.top;
+ } else {
+ this.originalScrollLeft = this.options.scroll.scrollLeft;
+ this.originalScrollTop = this.options.scroll.scrollTop;
+ }
+ }
+
+ Draggables.notify('onStart', this, event);
+
+ if(this.options.starteffect) this.options.starteffect(this.element);
+ },
+
+ updateDrag: function(event, pointer) {
+ if(!this.dragging) this.startDrag(event);
+ Position.prepare();
+ Droppables.show(pointer, this.element);
+ Draggables.notify('onDrag', this, event);
+
+ this.draw(pointer);
+ if(this.options.change) this.options.change(this);
+
+ if(this.options.scroll) {
+ this.stopScrolling();
+
+ var p;
+ if (this.options.scroll == window) {
+ with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
+ } else {
+ p = Position.page(this.options.scroll);
+ p[0] += this.options.scroll.scrollLeft + Position.deltaX;
+ p[1] += this.options.scroll.scrollTop + Position.deltaY;
+ p.push(p[0]+this.options.scroll.offsetWidth);
+ p.push(p[1]+this.options.scroll.offsetHeight);
+ }
+ var speed = [0,0];
+ if(pointer[0] < (p[0]+this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[0]+this.options.scrollSensitivity);
+ if(pointer[1] < (p[1]+this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[1]+this.options.scrollSensitivity);
+ if(pointer[0] > (p[2]-this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[2]-this.options.scrollSensitivity);
+ if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);
+ this.startScrolling(speed);
+ }
+
+ // fix AppleWebKit rendering
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+
+ Event.stop(event);
+ },
+
+ finishDrag: function(event, success) {
+ this.dragging = false;
+
+ if(this.options.ghosting) {
+ Position.relativize(this.element);
+ Element.remove(this._clone);
+ this._clone = null;
+ }
+
+ if(success) Droppables.fire(event, this.element);
+ Draggables.notify('onEnd', this, event);
+
+ var revert = this.options.revert;
+ if(revert && typeof revert == 'function') revert = revert(this.element);
+
+ var d = this.currentDelta();
+ if(revert && this.options.reverteffect) {
+ this.options.reverteffect(this.element,
+ d[1]-this.delta[1], d[0]-this.delta[0]);
+ } else {
+ this.delta = d;
+ }
+
+ if(this.options.zindex)
+ this.element.style.zIndex = this.originalZ;
+
+ if(this.options.endeffect)
+ this.options.endeffect(this.element);
+
+ Draggables.deactivate(this);
+ Droppables.reset();
+ },
+
+ keyPress: function(event) {
+ if(event.keyCode!=Event.KEY_ESC) return;
+ this.finishDrag(event, false);
+ Event.stop(event);
+ },
+
+ endDrag: function(event) {
+ if(!this.dragging) return;
+ this.stopScrolling();
+ this.finishDrag(event, true);
+ Event.stop(event);
+ },
+
+ draw: function(point) {
+ var pos = Position.cumulativeOffset(this.element);
+ if(this.options.ghosting) {
+ var r = Position.realOffset(this.element);
+ pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
+ }
+
+ var d = this.currentDelta();
+ pos[0] -= d[0]; pos[1] -= d[1];
+
+ if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
+ pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
+ pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
+ }
+
+ var p = [0,1].map(function(i){
+ return (point[i]-pos[i]-this.offset[i])
+ }.bind(this));
+
+ if(this.options.snap) {
+ if(typeof this.options.snap == 'function') {
+ p = this.options.snap(p[0],p[1],this);
+ } else {
+ if(this.options.snap instanceof Array) {
+ p = p.map( function(v, i) {
+ return Math.round(v/this.options.snap[i])*this.options.snap[i] }.bind(this))
+ } else {
+ p = p.map( function(v) {
+ return Math.round(v/this.options.snap)*this.options.snap }.bind(this))
+ }
+ }}
+
+ var style = this.element.style;
+ if((!this.options.constraint) || (this.options.constraint=='horizontal'))
+ style.left = p[0] + "px";
+ if((!this.options.constraint) || (this.options.constraint=='vertical'))
+ style.top = p[1] + "px";
+
+ if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
+ },
+
+ stopScrolling: function() {
+ if(this.scrollInterval) {
+ clearInterval(this.scrollInterval);
+ this.scrollInterval = null;
+ Draggables._lastScrollPointer = null;
+ }
+ },
+
+ startScrolling: function(speed) {
+ if(!(speed[0] || speed[1])) return;
+ this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
+ this.lastScrolled = new Date();
+ this.scrollInterval = setInterval(this.scroll.bind(this), 10);
+ },
+
+ scroll: function() {
+ var current = new Date();
+ var delta = current - this.lastScrolled;
+ this.lastScrolled = current;
+ if(this.options.scroll == window) {
+ with (this._getWindowScroll(this.options.scroll)) {
+ if (this.scrollSpeed[0] || this.scrollSpeed[1]) {
+ var d = delta / 1000;
+ this.options.scroll.scrollTo( left + d*this.scrollSpeed[0], top + d*this.scrollSpeed[1] );
+ }
+ }
+ } else {
+ this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
+ this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000;
+ }
+
+ Position.prepare();
+ Droppables.show(Draggables._lastPointer, this.element);
+ Draggables.notify('onDrag', this);
+ if (this._isScrollChild) {
+ Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer);
+ Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000;
+ Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000;
+ if (Draggables._lastScrollPointer[0] < 0)
+ Draggables._lastScrollPointer[0] = 0;
+ if (Draggables._lastScrollPointer[1] < 0)
+ Draggables._lastScrollPointer[1] = 0;
+ this.draw(Draggables._lastScrollPointer);
+ }
+
+ if(this.options.change) this.options.change(this);
+ },
+
+ _getWindowScroll: function(w) {
+ var T, L, W, H;
+ with (w.document) {
+ if (w.document.documentElement && documentElement.scrollTop) {
+ T = documentElement.scrollTop;
+ L = documentElement.scrollLeft;
+ } else if (w.document.body) {
+ T = body.scrollTop;
+ L = body.scrollLeft;
+ }
+ if (w.innerWidth) {
+ W = w.innerWidth;
+ H = w.innerHeight;
+ } else if (w.document.documentElement && documentElement.clientWidth) {
+ W = documentElement.clientWidth;
+ H = documentElement.clientHeight;
+ } else {
+ W = body.offsetWidth;
+ H = body.offsetHeight
+ }
+ }
+ return { top: T, left: L, width: W, height: H };
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+
+var SortableObserver = Class.create();
+SortableObserver.prototype = {
+ initialize: function(element, observer) {
+ this.element = $(element);
+ this.observer = observer;
+ this.lastValue = Sortable.serialize(this.element);
+ },
+
+ onStart: function() {
+ this.lastValue = Sortable.serialize(this.element);
+ },
+
+ onEnd: function() {
+ Sortable.unmark();
+ if(this.lastValue != Sortable.serialize(this.element))
+ this.observer(this.element)
+ }
+}
+
+var Sortable = {
+ SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
+
+ sortables: {},
+
+ _findRootElement: function(element) {
+ while (element.tagName != "BODY") {
+ if(element.id && Sortable.sortables[element.id]) return element;
+ element = element.parentNode;
+ }
+ },
+
+ options: function(element) {
+ element = Sortable._findRootElement($(element));
+ if(!element) return;
+ return Sortable.sortables[element.id];
+ },
+
+ destroy: function(element){
+ var s = Sortable.options(element);
+
+ if(s) {
+ Draggables.removeObserver(s.element);
+ s.droppables.each(function(d){ Droppables.remove(d) });
+ s.draggables.invoke('destroy');
+
+ delete Sortable.sortables[s.element.id];
+ }
+ },
+
+ create: function(element) {
+ element = $(element);
+ var options = Object.extend({
+ element: element,
+ tag: 'li', // assumes li children, override with tag: 'tagname'
+ dropOnEmpty: false,
+ tree: false,
+ treeTag: 'ul',
+ overlap: 'vertical', // one of 'vertical', 'horizontal'
+ constraint: 'vertical', // one of 'vertical', 'horizontal', false
+ containment: element, // also takes array of elements (or id's); or false
+ handle: false, // or a CSS class
+ only: false,
+ delay: 0,
+ hoverclass: null,
+ ghosting: false,
+ scroll: false,
+ scrollSensitivity: 20,
+ scrollSpeed: 15,
+ format: this.SERIALIZE_RULE,
+ onChange: Prototype.emptyFunction,
+ onUpdate: Prototype.emptyFunction
+ }, arguments[1] || {});
+
+ // clear any old sortable with same element
+ this.destroy(element);
+
+ // build options for the draggables
+ var options_for_draggable = {
+ revert: true,
+ scroll: options.scroll,
+ scrollSpeed: options.scrollSpeed,
+ scrollSensitivity: options.scrollSensitivity,
+ delay: options.delay,
+ ghosting: options.ghosting,
+ constraint: options.constraint,
+ handle: options.handle };
+
+ if(options.starteffect)
+ options_for_draggable.starteffect = options.starteffect;
+
+ if(options.reverteffect)
+ options_for_draggable.reverteffect = options.reverteffect;
+ else
+ if(options.ghosting) options_for_draggable.reverteffect = function(element) {
+ element.style.top = 0;
+ element.style.left = 0;
+ };
+
+ if(options.endeffect)
+ options_for_draggable.endeffect = options.endeffect;
+
+ if(options.zindex)
+ options_for_draggable.zindex = options.zindex;
+
+ // build options for the droppables
+ var options_for_droppable = {
+ overlap: options.overlap,
+ containment: options.containment,
+ tree: options.tree,
+ hoverclass: options.hoverclass,
+ onHover: Sortable.onHover
+ }
+
+ var options_for_tree = {
+ onHover: Sortable.onEmptyHover,
+ overlap: options.overlap,
+ containment: options.containment,
+ hoverclass: options.hoverclass
+ }
+
+ // fix for gecko engine
+ Element.cleanWhitespace(element);
+
+ options.draggables = [];
+ options.droppables = [];
+
+ // drop on empty handling
+ if(options.dropOnEmpty || options.tree) {
+ Droppables.add(element, options_for_tree);
+ options.droppables.push(element);
+ }
+
+ (this.findElements(element, options) || []).each( function(e) {
+ // handles are per-draggable
+ var handle = options.handle ?
+ $(e).down('.'+options.handle,0) : e;
+ options.draggables.push(
+ new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
+ Droppables.add(e, options_for_droppable);
+ if(options.tree) e.treeNode = element;
+ options.droppables.push(e);
+ });
+
+ if(options.tree) {
+ (Sortable.findTreeElements(element, options) || []).each( function(e) {
+ Droppables.add(e, options_for_tree);
+ e.treeNode = element;
+ options.droppables.push(e);
+ });
+ }
+
+ // keep reference
+ this.sortables[element.id] = options;
+
+ // for onupdate
+ Draggables.addObserver(new SortableObserver(element, options.onUpdate));
+
+ },
+
+ // return all suitable-for-sortable elements in a guaranteed order
+ findElements: function(element, options) {
+ return Element.findChildren(
+ element, options.only, options.tree ? true : false, options.tag);
+ },
+
+ findTreeElements: function(element, options) {
+ return Element.findChildren(
+ element, options.only, options.tree ? true : false, options.treeTag);
+ },
+
+ onHover: function(element, dropon, overlap) {
+ if(Element.isParent(dropon, element)) return;
+
+ if(overlap > .33 && overlap < .66 && Sortable.options(dropon).tree) {
+ return;
+ } else if(overlap>0.5) {
+ Sortable.mark(dropon, 'before');
+ if(dropon.previousSibling != element) {
+ var oldParentNode = element.parentNode;
+ element.style.visibility = "hidden"; // fix gecko rendering
+ dropon.parentNode.insertBefore(element, dropon);
+ if(dropon.parentNode!=oldParentNode)
+ Sortable.options(oldParentNode).onChange(element);
+ Sortable.options(dropon.parentNode).onChange(element);
+ }
+ } else {
+ Sortable.mark(dropon, 'after');
+ var nextElement = dropon.nextSibling || null;
+ if(nextElement != element) {
+ var oldParentNode = element.parentNode;
+ element.style.visibility = "hidden"; // fix gecko rendering
+ dropon.parentNode.insertBefore(element, nextElement);
+ if(dropon.parentNode!=oldParentNode)
+ Sortable.options(oldParentNode).onChange(element);
+ Sortable.options(dropon.parentNode).onChange(element);
+ }
+ }
+ },
+
+ onEmptyHover: function(element, dropon, overlap) {
+ var oldParentNode = element.parentNode;
+ var droponOptions = Sortable.options(dropon);
+
+ if(!Element.isParent(dropon, element)) {
+ var index;
+
+ var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
+ var child = null;
+
+ if(children) {
+ var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap);
+
+ for (index = 0; index < children.length; index += 1) {
+ if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) {
+ offset -= Element.offsetSize (children[index], droponOptions.overlap);
+ } else if (offset - (Element.offsetSize (children[index], droponOptions.overlap) / 2) >= 0) {
+ child = index + 1 < children.length ? children[index + 1] : null;
+ break;
+ } else {
+ child = children[index];
+ break;
+ }
+ }
+ }
+
+ dropon.insertBefore(element, child);
+
+ Sortable.options(oldParentNode).onChange(element);
+ droponOptions.onChange(element);
+ }
+ },
+
+ unmark: function() {
+ if(Sortable._marker) Sortable._marker.hide();
+ },
+
+ mark: function(dropon, position) {
+ // mark on ghosting only
+ var sortable = Sortable.options(dropon.parentNode);
+ if(sortable && !sortable.ghosting) return;
+
+ if(!Sortable._marker) {
+ Sortable._marker =
+ ($('dropmarker') || Element.extend(document.createElement('DIV'))).
+ hide().addClassName('dropmarker').setStyle({position:'absolute'});
+ document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
+ }
+ var offsets = Position.cumulativeOffset(dropon);
+ Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'});
+
+ if(position=='after')
+ if(sortable.overlap == 'horizontal')
+ Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'});
+ else
+ Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'});
+
+ Sortable._marker.show();
+ },
+
+ _tree: function(element, options, parent) {
+ var children = Sortable.findElements(element, options) || [];
+
+ for (var i = 0; i < children.length; ++i) {
+ var match = children[i].id.match(options.format);
+
+ if (!match) continue;
+
+ var child = {
+ id: encodeURIComponent(match ? match[1] : null),
+ element: element,
+ parent: parent,
+ children: [],
+ position: parent.children.length,
+ container: $(children[i]).down(options.treeTag)
+ }
+
+ /* Get the element containing the children and recurse over it */
+ if (child.container)
+ this._tree(child.container, options, child)
+
+ parent.children.push (child);
+ }
+
+ return parent;
+ },
+
+ tree: function(element) {
+ element = $(element);
+ var sortableOptions = this.options(element);
+ var options = Object.extend({
+ tag: sortableOptions.tag,
+ treeTag: sortableOptions.treeTag,
+ only: sortableOptions.only,
+ name: element.id,
+ format: sortableOptions.format
+ }, arguments[1] || {});
+
+ var root = {
+ id: null,
+ parent: null,
+ children: [],
+ container: element,
+ position: 0
+ }
+
+ return Sortable._tree(element, options, root);
+ },
+
+ /* Construct a [i] index for a particular node */
+ _constructIndex: function(node) {
+ var index = '';
+ do {
+ if (node.id) index = '[' + node.position + ']' + index;
+ } while ((node = node.parent) != null);
+ return index;
+ },
+
+ sequence: function(element) {
+ element = $(element);
+ var options = Object.extend(this.options(element), arguments[1] || {});
+
+ return $(this.findElements(element, options) || []).map( function(item) {
+ return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
+ });
+ },
+
+ setSequence: function(element, new_sequence) {
+ element = $(element);
+ var options = Object.extend(this.options(element), arguments[2] || {});
+
+ var nodeMap = {};
+ this.findElements(element, options).each( function(n) {
+ if (n.id.match(options.format))
+ nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];
+ n.parentNode.removeChild(n);
+ });
+
+ new_sequence.each(function(ident) {
+ var n = nodeMap[ident];
+ if (n) {
+ n[1].appendChild(n[0]);
+ delete nodeMap[ident];
+ }
+ });
+ },
+
+ serialize: function(element) {
+ element = $(element);
+ var options = Object.extend(Sortable.options(element), arguments[1] || {});
+ var name = encodeURIComponent(
+ (arguments[1] && arguments[1].name) ? arguments[1].name : element.id);
+
+ if (options.tree) {
+ return Sortable.tree(element, arguments[1]).children.map( function (item) {
+ return [name + Sortable._constructIndex(item) + "[id]=" +
+ encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
+ }).flatten().join('&');
+ } else {
+ return Sortable.sequence(element, arguments[1]).map( function(item) {
+ return name + "[]=" + encodeURIComponent(item);
+ }).join('&');
+ }
+ }
+}
+
+// Returns true if child is contained within element
+Element.isParent = function(child, element) {
+ if (!child.parentNode || child == element) return false;
+ if (child.parentNode == element) return true;
+ return Element.isParent(child.parentNode, element);
+}
+
+Element.findChildren = function(element, only, recursive, tagName) {
+ if(!element.hasChildNodes()) return null;
+ tagName = tagName.toUpperCase();
+ if(only) only = [only].flatten();
+ var elements = [];
+ $A(element.childNodes).each( function(e) {
+ if(e.tagName && e.tagName.toUpperCase()==tagName &&
+ (!only || (Element.classNames(e).detect(function(v) { return only.include(v) }))))
+ elements.push(e);
+ if(recursive) {
+ var grandchildren = Element.findChildren(e, only, recursive, tagName);
+ if(grandchildren) elements.push(grandchildren);
+ }
+ });
+
+ return (elements.length>0 ? elements.flatten() : []);
+}
+
+Element.offsetSize = function (element, type) {
+ return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
+}
diff --git a/rest_sys/public/javascripts/effects.js b/rest_sys/public/javascripts/effects.js
new file mode 100644
index 000000000..3b02eda2b
--- /dev/null
+++ b/rest_sys/public/javascripts/effects.js
@@ -0,0 +1,1088 @@
+// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// Contributors:
+// Justin Palmer (http://encytemedia.com/)
+// Mark Pilgrim (http://diveintomark.org/)
+// Martin Bialasinki
+//
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
+
+// converts rgb() and #xxx to #xxxxxx format,
+// returns self (or first argument) if not convertable
+String.prototype.parseColor = function() {
+ var color = '#';
+ if(this.slice(0,4) == 'rgb(') {
+ var cols = this.slice(4,this.length-1).split(',');
+ var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
+ } else {
+ if(this.slice(0,1) == '#') {
+ if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();
+ if(this.length==7) color = this.toLowerCase();
+ }
+ }
+ return(color.length==7 ? color : (arguments[0] || this));
+}
+
+/*--------------------------------------------------------------------------*/
+
+Element.collectTextNodes = function(element) {
+ return $A($(element).childNodes).collect( function(node) {
+ return (node.nodeType==3 ? node.nodeValue :
+ (node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
+ }).flatten().join('');
+}
+
+Element.collectTextNodesIgnoreClass = function(element, className) {
+ return $A($(element).childNodes).collect( function(node) {
+ return (node.nodeType==3 ? node.nodeValue :
+ ((node.hasChildNodes() && !Element.hasClassName(node,className)) ?
+ Element.collectTextNodesIgnoreClass(node, className) : ''));
+ }).flatten().join('');
+}
+
+Element.setContentZoom = function(element, percent) {
+ element = $(element);
+ element.setStyle({fontSize: (percent/100) + 'em'});
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+ return element;
+}
+
+Element.getOpacity = function(element){
+ element = $(element);
+ var opacity;
+ if (opacity = element.getStyle('opacity'))
+ return parseFloat(opacity);
+ if (opacity = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
+ if(opacity[1]) return parseFloat(opacity[1]) / 100;
+ return 1.0;
+}
+
+Element.setOpacity = function(element, value){
+ element= $(element);
+ if (value == 1){
+ element.setStyle({ opacity:
+ (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ?
+ 0.999999 : 1.0 });
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
+ element.setStyle({filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});
+ } else {
+ if(value < 0.00001) value = 0;
+ element.setStyle({opacity: value});
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
+ element.setStyle(
+ { filter: element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') +
+ 'alpha(opacity='+value*100+')' });
+ }
+ return element;
+}
+
+Element.getInlineOpacity = function(element){
+ return $(element).style.opacity || '';
+}
+
+Element.forceRerendering = function(element) {
+ try {
+ element = $(element);
+ var n = document.createTextNode(' ');
+ element.appendChild(n);
+ element.removeChild(n);
+ } catch(e) { }
+};
+
+/*--------------------------------------------------------------------------*/
+
+Array.prototype.call = function() {
+ var args = arguments;
+ this.each(function(f){ f.apply(this, args) });
+}
+
+/*--------------------------------------------------------------------------*/
+
+var Effect = {
+ _elementDoesNotExistError: {
+ name: 'ElementDoesNotExistError',
+ message: 'The specified DOM element does not exist, but is required for this effect to operate'
+ },
+ tagifyText: function(element) {
+ if(typeof Builder == 'undefined')
+ throw("Effect.tagifyText requires including script.aculo.us' builder.js library");
+
+ var tagifyStyle = 'position:relative';
+ if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1';
+
+ element = $(element);
+ $A(element.childNodes).each( function(child) {
+ if(child.nodeType==3) {
+ child.nodeValue.toArray().each( function(character) {
+ element.insertBefore(
+ Builder.node('span',{style: tagifyStyle},
+ character == ' ' ? String.fromCharCode(160) : character),
+ child);
+ });
+ Element.remove(child);
+ }
+ });
+ },
+ multiple: function(element, effect) {
+ var elements;
+ if(((typeof element == 'object') ||
+ (typeof element == 'function')) &&
+ (element.length))
+ elements = element;
+ else
+ elements = $(element).childNodes;
+
+ var options = Object.extend({
+ speed: 0.1,
+ delay: 0.0
+ }, arguments[2] || {});
+ var masterDelay = options.delay;
+
+ $A(elements).each( function(element, index) {
+ new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
+ });
+ },
+ PAIRS: {
+ 'slide': ['SlideDown','SlideUp'],
+ 'blind': ['BlindDown','BlindUp'],
+ 'appear': ['Appear','Fade']
+ },
+ toggle: function(element, effect) {
+ element = $(element);
+ effect = (effect || 'appear').toLowerCase();
+ var options = Object.extend({
+ queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
+ }, arguments[2] || {});
+ Effect[element.visible() ?
+ Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
+ }
+};
+
+var Effect2 = Effect; // deprecated
+
+/* ------------- transitions ------------- */
+
+Effect.Transitions = {
+ linear: Prototype.K,
+ sinoidal: function(pos) {
+ return (-Math.cos(pos*Math.PI)/2) + 0.5;
+ },
+ reverse: function(pos) {
+ return 1-pos;
+ },
+ flicker: function(pos) {
+ return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
+ },
+ wobble: function(pos) {
+ return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
+ },
+ pulse: function(pos, pulses) {
+ pulses = pulses || 5;
+ return (
+ Math.round((pos % (1/pulses)) * pulses) == 0 ?
+ ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) :
+ 1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2))
+ );
+ },
+ none: function(pos) {
+ return 0;
+ },
+ full: function(pos) {
+ return 1;
+ }
+};
+
+/* ------------- core effects ------------- */
+
+Effect.ScopedQueue = Class.create();
+Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
+ initialize: function() {
+ this.effects = [];
+ this.interval = null;
+ },
+ _each: function(iterator) {
+ this.effects._each(iterator);
+ },
+ add: function(effect) {
+ var timestamp = new Date().getTime();
+
+ var position = (typeof effect.options.queue == 'string') ?
+ effect.options.queue : effect.options.queue.position;
+
+ switch(position) {
+ case 'front':
+ // move unstarted effects after this effect
+ this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
+ e.startOn += effect.finishOn;
+ e.finishOn += effect.finishOn;
+ });
+ break;
+ case 'with-last':
+ timestamp = this.effects.pluck('startOn').max() || timestamp;
+ break;
+ case 'end':
+ // start effect after last queued effect has finished
+ timestamp = this.effects.pluck('finishOn').max() || timestamp;
+ break;
+ }
+
+ effect.startOn += timestamp;
+ effect.finishOn += timestamp;
+
+ if(!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))
+ this.effects.push(effect);
+
+ if(!this.interval)
+ this.interval = setInterval(this.loop.bind(this), 40);
+ },
+ remove: function(effect) {
+ this.effects = this.effects.reject(function(e) { return e==effect });
+ if(this.effects.length == 0) {
+ clearInterval(this.interval);
+ this.interval = null;
+ }
+ },
+ loop: function() {
+ var timePos = new Date().getTime();
+ this.effects.invoke('loop', timePos);
+ }
+});
+
+Effect.Queues = {
+ instances: $H(),
+ get: function(queueName) {
+ if(typeof queueName != 'string') return queueName;
+
+ if(!this.instances[queueName])
+ this.instances[queueName] = new Effect.ScopedQueue();
+
+ return this.instances[queueName];
+ }
+}
+Effect.Queue = Effect.Queues.get('global');
+
+Effect.DefaultOptions = {
+ transition: Effect.Transitions.sinoidal,
+ duration: 1.0, // seconds
+ fps: 25.0, // max. 25fps due to Effect.Queue implementation
+ sync: false, // true for combining
+ from: 0.0,
+ to: 1.0,
+ delay: 0.0,
+ queue: 'parallel'
+}
+
+Effect.Base = function() {};
+Effect.Base.prototype = {
+ position: null,
+ start: function(options) {
+ this.options = Object.extend(Object.extend({},Effect.DefaultOptions), options || {});
+ this.currentFrame = 0;
+ this.state = 'idle';
+ this.startOn = this.options.delay*1000;
+ this.finishOn = this.startOn + (this.options.duration*1000);
+ this.event('beforeStart');
+ if(!this.options.sync)
+ Effect.Queues.get(typeof this.options.queue == 'string' ?
+ 'global' : this.options.queue.scope).add(this);
+ },
+ loop: function(timePos) {
+ if(timePos >= this.startOn) {
+ if(timePos >= this.finishOn) {
+ this.render(1.0);
+ this.cancel();
+ this.event('beforeFinish');
+ if(this.finish) this.finish();
+ this.event('afterFinish');
+ return;
+ }
+ var pos = (timePos - this.startOn) / (this.finishOn - this.startOn);
+ var frame = Math.round(pos * this.options.fps * this.options.duration);
+ if(frame > this.currentFrame) {
+ this.render(pos);
+ this.currentFrame = frame;
+ }
+ }
+ },
+ render: function(pos) {
+ if(this.state == 'idle') {
+ this.state = 'running';
+ this.event('beforeSetup');
+ if(this.setup) this.setup();
+ this.event('afterSetup');
+ }
+ if(this.state == 'running') {
+ if(this.options.transition) pos = this.options.transition(pos);
+ pos *= (this.options.to-this.options.from);
+ pos += this.options.from;
+ this.position = pos;
+ this.event('beforeUpdate');
+ if(this.update) this.update(pos);
+ this.event('afterUpdate');
+ }
+ },
+ cancel: function() {
+ if(!this.options.sync)
+ Effect.Queues.get(typeof this.options.queue == 'string' ?
+ 'global' : this.options.queue.scope).remove(this);
+ this.state = 'finished';
+ },
+ event: function(eventName) {
+ if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
+ if(this.options[eventName]) this.options[eventName](this);
+ },
+ inspect: function() {
+ return '#';
+ }
+}
+
+Effect.Parallel = Class.create();
+Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), {
+ initialize: function(effects) {
+ this.effects = effects || [];
+ this.start(arguments[1]);
+ },
+ update: function(position) {
+ this.effects.invoke('render', position);
+ },
+ finish: function(position) {
+ this.effects.each( function(effect) {
+ effect.render(1.0);
+ effect.cancel();
+ effect.event('beforeFinish');
+ if(effect.finish) effect.finish(position);
+ effect.event('afterFinish');
+ });
+ }
+});
+
+Effect.Event = Class.create();
+Object.extend(Object.extend(Effect.Event.prototype, Effect.Base.prototype), {
+ initialize: function() {
+ var options = Object.extend({
+ duration: 0
+ }, arguments[0] || {});
+ this.start(options);
+ },
+ update: Prototype.emptyFunction
+});
+
+Effect.Opacity = Class.create();
+Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
+ initialize: function(element) {
+ this.element = $(element);
+ if(!this.element) throw(Effect._elementDoesNotExistError);
+ // make this work on IE on elements without 'layout'
+ if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout))
+ this.element.setStyle({zoom: 1});
+ var options = Object.extend({
+ from: this.element.getOpacity() || 0.0,
+ to: 1.0
+ }, arguments[1] || {});
+ this.start(options);
+ },
+ update: function(position) {
+ this.element.setOpacity(position);
+ }
+});
+
+Effect.Move = Class.create();
+Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {
+ initialize: function(element) {
+ this.element = $(element);
+ if(!this.element) throw(Effect._elementDoesNotExistError);
+ var options = Object.extend({
+ x: 0,
+ y: 0,
+ mode: 'relative'
+ }, arguments[1] || {});
+ this.start(options);
+ },
+ setup: function() {
+ // Bug in Opera: Opera returns the "real" position of a static element or
+ // relative element that does not have top/left explicitly set.
+ // ==> Always set top and left for position relative elements in your stylesheets
+ // (to 0 if you do not need them)
+ this.element.makePositioned();
+ this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
+ this.originalTop = parseFloat(this.element.getStyle('top') || '0');
+ if(this.options.mode == 'absolute') {
+ // absolute movement, so we need to calc deltaX and deltaY
+ this.options.x = this.options.x - this.originalLeft;
+ this.options.y = this.options.y - this.originalTop;
+ }
+ },
+ update: function(position) {
+ this.element.setStyle({
+ left: Math.round(this.options.x * position + this.originalLeft) + 'px',
+ top: Math.round(this.options.y * position + this.originalTop) + 'px'
+ });
+ }
+});
+
+// for backwards compatibility
+Effect.MoveBy = function(element, toTop, toLeft) {
+ return new Effect.Move(element,
+ Object.extend({ x: toLeft, y: toTop }, arguments[3] || {}));
+};
+
+Effect.Scale = Class.create();
+Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
+ initialize: function(element, percent) {
+ this.element = $(element);
+ if(!this.element) throw(Effect._elementDoesNotExistError);
+ var options = Object.extend({
+ scaleX: true,
+ scaleY: true,
+ scaleContent: true,
+ scaleFromCenter: false,
+ scaleMode: 'box', // 'box' or 'contents' or {} with provided values
+ scaleFrom: 100.0,
+ scaleTo: percent
+ }, arguments[2] || {});
+ this.start(options);
+ },
+ setup: function() {
+ this.restoreAfterFinish = this.options.restoreAfterFinish || false;
+ this.elementPositioning = this.element.getStyle('position');
+
+ this.originalStyle = {};
+ ['top','left','width','height','fontSize'].each( function(k) {
+ this.originalStyle[k] = this.element.style[k];
+ }.bind(this));
+
+ this.originalTop = this.element.offsetTop;
+ this.originalLeft = this.element.offsetLeft;
+
+ var fontSize = this.element.getStyle('font-size') || '100%';
+ ['em','px','%','pt'].each( function(fontSizeType) {
+ if(fontSize.indexOf(fontSizeType)>0) {
+ this.fontSize = parseFloat(fontSize);
+ this.fontSizeType = fontSizeType;
+ }
+ }.bind(this));
+
+ this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
+
+ this.dims = null;
+ if(this.options.scaleMode=='box')
+ this.dims = [this.element.offsetHeight, this.element.offsetWidth];
+ if(/^content/.test(this.options.scaleMode))
+ this.dims = [this.element.scrollHeight, this.element.scrollWidth];
+ if(!this.dims)
+ this.dims = [this.options.scaleMode.originalHeight,
+ this.options.scaleMode.originalWidth];
+ },
+ update: function(position) {
+ var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
+ if(this.options.scaleContent && this.fontSize)
+ this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });
+ this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
+ },
+ finish: function(position) {
+ if(this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
+ },
+ setDimensions: function(height, width) {
+ var d = {};
+ if(this.options.scaleX) d.width = Math.round(width) + 'px';
+ if(this.options.scaleY) d.height = Math.round(height) + 'px';
+ if(this.options.scaleFromCenter) {
+ var topd = (height - this.dims[0])/2;
+ var leftd = (width - this.dims[1])/2;
+ if(this.elementPositioning == 'absolute') {
+ if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
+ if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
+ } else {
+ if(this.options.scaleY) d.top = -topd + 'px';
+ if(this.options.scaleX) d.left = -leftd + 'px';
+ }
+ }
+ this.element.setStyle(d);
+ }
+});
+
+Effect.Highlight = Class.create();
+Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
+ initialize: function(element) {
+ this.element = $(element);
+ if(!this.element) throw(Effect._elementDoesNotExistError);
+ var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
+ this.start(options);
+ },
+ setup: function() {
+ // Prevent executing on elements not in the layout flow
+ if(this.element.getStyle('display')=='none') { this.cancel(); return; }
+ // Disable background image during the effect
+ this.oldStyle = {
+ backgroundImage: this.element.getStyle('background-image') };
+ this.element.setStyle({backgroundImage: 'none'});
+ if(!this.options.endcolor)
+ this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff');
+ if(!this.options.restorecolor)
+ this.options.restorecolor = this.element.getStyle('background-color');
+ // init color calculations
+ this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
+ this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
+ },
+ update: function(position) {
+ this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
+ return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) });
+ },
+ finish: function() {
+ this.element.setStyle(Object.extend(this.oldStyle, {
+ backgroundColor: this.options.restorecolor
+ }));
+ }
+});
+
+Effect.ScrollTo = Class.create();
+Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
+ initialize: function(element) {
+ this.element = $(element);
+ this.start(arguments[1] || {});
+ },
+ setup: function() {
+ Position.prepare();
+ var offsets = Position.cumulativeOffset(this.element);
+ if(this.options.offset) offsets[1] += this.options.offset;
+ var max = window.innerHeight ?
+ window.height - window.innerHeight :
+ document.body.scrollHeight -
+ (document.documentElement.clientHeight ?
+ document.documentElement.clientHeight : document.body.clientHeight);
+ this.scrollStart = Position.deltaY;
+ this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart;
+ },
+ update: function(position) {
+ Position.prepare();
+ window.scrollTo(Position.deltaX,
+ this.scrollStart + (position*this.delta));
+ }
+});
+
+/* ------------- combination effects ------------- */
+
+Effect.Fade = function(element) {
+ element = $(element);
+ var oldOpacity = element.getInlineOpacity();
+ var options = Object.extend({
+ from: element.getOpacity() || 1.0,
+ to: 0.0,
+ afterFinishInternal: function(effect) {
+ if(effect.options.to!=0) return;
+ effect.element.hide().setStyle({opacity: oldOpacity});
+ }}, arguments[1] || {});
+ return new Effect.Opacity(element,options);
+}
+
+Effect.Appear = function(element) {
+ element = $(element);
+ var options = Object.extend({
+ from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0),
+ to: 1.0,
+ // force Safari to render floated elements properly
+ afterFinishInternal: function(effect) {
+ effect.element.forceRerendering();
+ },
+ beforeSetup: function(effect) {
+ effect.element.setOpacity(effect.options.from).show();
+ }}, arguments[1] || {});
+ return new Effect.Opacity(element,options);
+}
+
+Effect.Puff = function(element) {
+ element = $(element);
+ var oldStyle = {
+ opacity: element.getInlineOpacity(),
+ position: element.getStyle('position'),
+ top: element.style.top,
+ left: element.style.left,
+ width: element.style.width,
+ height: element.style.height
+ };
+ return new Effect.Parallel(
+ [ new Effect.Scale(element, 200,
+ { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
+ new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
+ Object.extend({ duration: 1.0,
+ beforeSetupInternal: function(effect) {
+ Position.absolutize(effect.effects[0].element)
+ },
+ afterFinishInternal: function(effect) {
+ effect.effects[0].element.hide().setStyle(oldStyle); }
+ }, arguments[1] || {})
+ );
+}
+
+Effect.BlindUp = function(element) {
+ element = $(element);
+ element.makeClipping();
+ return new Effect.Scale(element, 0,
+ Object.extend({ scaleContent: false,
+ scaleX: false,
+ restoreAfterFinish: true,
+ afterFinishInternal: function(effect) {
+ effect.element.hide().undoClipping();
+ }
+ }, arguments[1] || {})
+ );
+}
+
+Effect.BlindDown = function(element) {
+ element = $(element);
+ var elementDimensions = element.getDimensions();
+ return new Effect.Scale(element, 100, Object.extend({
+ scaleContent: false,
+ scaleX: false,
+ scaleFrom: 0,
+ scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
+ restoreAfterFinish: true,
+ afterSetup: function(effect) {
+ effect.element.makeClipping().setStyle({height: '0px'}).show();
+ },
+ afterFinishInternal: function(effect) {
+ effect.element.undoClipping();
+ }
+ }, arguments[1] || {}));
+}
+
+Effect.SwitchOff = function(element) {
+ element = $(element);
+ var oldOpacity = element.getInlineOpacity();
+ return new Effect.Appear(element, Object.extend({
+ duration: 0.4,
+ from: 0,
+ transition: Effect.Transitions.flicker,
+ afterFinishInternal: function(effect) {
+ new Effect.Scale(effect.element, 1, {
+ duration: 0.3, scaleFromCenter: true,
+ scaleX: false, scaleContent: false, restoreAfterFinish: true,
+ beforeSetup: function(effect) {
+ effect.element.makePositioned().makeClipping();
+ },
+ afterFinishInternal: function(effect) {
+ effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity});
+ }
+ })
+ }
+ }, arguments[1] || {}));
+}
+
+Effect.DropOut = function(element) {
+ element = $(element);
+ var oldStyle = {
+ top: element.getStyle('top'),
+ left: element.getStyle('left'),
+ opacity: element.getInlineOpacity() };
+ return new Effect.Parallel(
+ [ new Effect.Move(element, {x: 0, y: 100, sync: true }),
+ new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
+ Object.extend(
+ { duration: 0.5,
+ beforeSetup: function(effect) {
+ effect.effects[0].element.makePositioned();
+ },
+ afterFinishInternal: function(effect) {
+ effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);
+ }
+ }, arguments[1] || {}));
+}
+
+Effect.Shake = function(element) {
+ element = $(element);
+ var oldStyle = {
+ top: element.getStyle('top'),
+ left: element.getStyle('left') };
+ return new Effect.Move(element,
+ { x: 20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) {
+ new Effect.Move(effect.element,
+ { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) {
+ effect.element.undoPositioned().setStyle(oldStyle);
+ }}) }}) }}) }}) }}) }});
+}
+
+Effect.SlideDown = function(element) {
+ element = $(element).cleanWhitespace();
+ // SlideDown need to have the content of the element wrapped in a container element with fixed height!
+ var oldInnerBottom = element.down().getStyle('bottom');
+ var elementDimensions = element.getDimensions();
+ return new Effect.Scale(element, 100, Object.extend({
+ scaleContent: false,
+ scaleX: false,
+ scaleFrom: window.opera ? 0 : 1,
+ scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
+ restoreAfterFinish: true,
+ afterSetup: function(effect) {
+ effect.element.makePositioned();
+ effect.element.down().makePositioned();
+ if(window.opera) effect.element.setStyle({top: ''});
+ effect.element.makeClipping().setStyle({height: '0px'}).show();
+ },
+ afterUpdateInternal: function(effect) {
+ effect.element.down().setStyle({bottom:
+ (effect.dims[0] - effect.element.clientHeight) + 'px' });
+ },
+ afterFinishInternal: function(effect) {
+ effect.element.undoClipping().undoPositioned();
+ effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
+ }, arguments[1] || {})
+ );
+}
+
+Effect.SlideUp = function(element) {
+ element = $(element).cleanWhitespace();
+ var oldInnerBottom = element.down().getStyle('bottom');
+ return new Effect.Scale(element, window.opera ? 0 : 1,
+ Object.extend({ scaleContent: false,
+ scaleX: false,
+ scaleMode: 'box',
+ scaleFrom: 100,
+ restoreAfterFinish: true,
+ beforeStartInternal: function(effect) {
+ effect.element.makePositioned();
+ effect.element.down().makePositioned();
+ if(window.opera) effect.element.setStyle({top: ''});
+ effect.element.makeClipping().show();
+ },
+ afterUpdateInternal: function(effect) {
+ effect.element.down().setStyle({bottom:
+ (effect.dims[0] - effect.element.clientHeight) + 'px' });
+ },
+ afterFinishInternal: function(effect) {
+ effect.element.hide().undoClipping().undoPositioned().setStyle({bottom: oldInnerBottom});
+ effect.element.down().undoPositioned();
+ }
+ }, arguments[1] || {})
+ );
+}
+
+// Bug in opera makes the TD containing this element expand for a instance after finish
+Effect.Squish = function(element) {
+ return new Effect.Scale(element, window.opera ? 1 : 0, {
+ restoreAfterFinish: true,
+ beforeSetup: function(effect) {
+ effect.element.makeClipping();
+ },
+ afterFinishInternal: function(effect) {
+ effect.element.hide().undoClipping();
+ }
+ });
+}
+
+Effect.Grow = function(element) {
+ element = $(element);
+ var options = Object.extend({
+ direction: 'center',
+ moveTransition: Effect.Transitions.sinoidal,
+ scaleTransition: Effect.Transitions.sinoidal,
+ opacityTransition: Effect.Transitions.full
+ }, arguments[1] || {});
+ var oldStyle = {
+ top: element.style.top,
+ left: element.style.left,
+ height: element.style.height,
+ width: element.style.width,
+ opacity: element.getInlineOpacity() };
+
+ var dims = element.getDimensions();
+ var initialMoveX, initialMoveY;
+ var moveX, moveY;
+
+ switch (options.direction) {
+ case 'top-left':
+ initialMoveX = initialMoveY = moveX = moveY = 0;
+ break;
+ case 'top-right':
+ initialMoveX = dims.width;
+ initialMoveY = moveY = 0;
+ moveX = -dims.width;
+ break;
+ case 'bottom-left':
+ initialMoveX = moveX = 0;
+ initialMoveY = dims.height;
+ moveY = -dims.height;
+ break;
+ case 'bottom-right':
+ initialMoveX = dims.width;
+ initialMoveY = dims.height;
+ moveX = -dims.width;
+ moveY = -dims.height;
+ break;
+ case 'center':
+ initialMoveX = dims.width / 2;
+ initialMoveY = dims.height / 2;
+ moveX = -dims.width / 2;
+ moveY = -dims.height / 2;
+ break;
+ }
+
+ return new Effect.Move(element, {
+ x: initialMoveX,
+ y: initialMoveY,
+ duration: 0.01,
+ beforeSetup: function(effect) {
+ effect.element.hide().makeClipping().makePositioned();
+ },
+ afterFinishInternal: function(effect) {
+ new Effect.Parallel(
+ [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
+ new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }),
+ new Effect.Scale(effect.element, 100, {
+ scaleMode: { originalHeight: dims.height, originalWidth: dims.width },
+ sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
+ ], Object.extend({
+ beforeSetup: function(effect) {
+ effect.effects[0].element.setStyle({height: '0px'}).show();
+ },
+ afterFinishInternal: function(effect) {
+ effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);
+ }
+ }, options)
+ )
+ }
+ });
+}
+
+Effect.Shrink = function(element) {
+ element = $(element);
+ var options = Object.extend({
+ direction: 'center',
+ moveTransition: Effect.Transitions.sinoidal,
+ scaleTransition: Effect.Transitions.sinoidal,
+ opacityTransition: Effect.Transitions.none
+ }, arguments[1] || {});
+ var oldStyle = {
+ top: element.style.top,
+ left: element.style.left,
+ height: element.style.height,
+ width: element.style.width,
+ opacity: element.getInlineOpacity() };
+
+ var dims = element.getDimensions();
+ var moveX, moveY;
+
+ switch (options.direction) {
+ case 'top-left':
+ moveX = moveY = 0;
+ break;
+ case 'top-right':
+ moveX = dims.width;
+ moveY = 0;
+ break;
+ case 'bottom-left':
+ moveX = 0;
+ moveY = dims.height;
+ break;
+ case 'bottom-right':
+ moveX = dims.width;
+ moveY = dims.height;
+ break;
+ case 'center':
+ moveX = dims.width / 2;
+ moveY = dims.height / 2;
+ break;
+ }
+
+ return new Effect.Parallel(
+ [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),
+ new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
+ new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
+ ], Object.extend({
+ beforeStartInternal: function(effect) {
+ effect.effects[0].element.makePositioned().makeClipping();
+ },
+ afterFinishInternal: function(effect) {
+ effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); }
+ }, options)
+ );
+}
+
+Effect.Pulsate = function(element) {
+ element = $(element);
+ var options = arguments[1] || {};
+ var oldOpacity = element.getInlineOpacity();
+ var transition = options.transition || Effect.Transitions.sinoidal;
+ var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos, options.pulses)) };
+ reverser.bind(transition);
+ return new Effect.Opacity(element,
+ Object.extend(Object.extend({ duration: 2.0, from: 0,
+ afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
+ }, options), {transition: reverser}));
+}
+
+Effect.Fold = function(element) {
+ element = $(element);
+ var oldStyle = {
+ top: element.style.top,
+ left: element.style.left,
+ width: element.style.width,
+ height: element.style.height };
+ element.makeClipping();
+ return new Effect.Scale(element, 5, Object.extend({
+ scaleContent: false,
+ scaleX: false,
+ afterFinishInternal: function(effect) {
+ new Effect.Scale(element, 1, {
+ scaleContent: false,
+ scaleY: false,
+ afterFinishInternal: function(effect) {
+ effect.element.hide().undoClipping().setStyle(oldStyle);
+ } });
+ }}, arguments[1] || {}));
+};
+
+Effect.Morph = Class.create();
+Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {
+ initialize: function(element) {
+ this.element = $(element);
+ if(!this.element) throw(Effect._elementDoesNotExistError);
+ var options = Object.extend({
+ style: ''
+ }, arguments[1] || {});
+ this.start(options);
+ },
+ setup: function(){
+ function parseColor(color){
+ if(!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
+ color = color.parseColor();
+ return $R(0,2).map(function(i){
+ return parseInt( color.slice(i*2+1,i*2+3), 16 )
+ });
+ }
+ this.transforms = this.options.style.parseStyle().map(function(property){
+ var originalValue = this.element.getStyle(property[0]);
+ return $H({
+ style: property[0],
+ originalValue: property[1].unit=='color' ?
+ parseColor(originalValue) : parseFloat(originalValue || 0),
+ targetValue: property[1].unit=='color' ?
+ parseColor(property[1].value) : property[1].value,
+ unit: property[1].unit
+ });
+ }.bind(this)).reject(function(transform){
+ return (
+ (transform.originalValue == transform.targetValue) ||
+ (
+ transform.unit != 'color' &&
+ (isNaN(transform.originalValue) || isNaN(transform.targetValue))
+ )
+ )
+ });
+ },
+ update: function(position) {
+ var style = $H(), value = null;
+ this.transforms.each(function(transform){
+ value = transform.unit=='color' ?
+ $R(0,2).inject('#',function(m,v,i){
+ return m+(Math.round(transform.originalValue[i]+
+ (transform.targetValue[i] - transform.originalValue[i])*position)).toColorPart() }) :
+ transform.originalValue + Math.round(
+ ((transform.targetValue - transform.originalValue) * position) * 1000)/1000 + transform.unit;
+ style[transform.style] = value;
+ });
+ this.element.setStyle(style);
+ }
+});
+
+Effect.Transform = Class.create();
+Object.extend(Effect.Transform.prototype, {
+ initialize: function(tracks){
+ this.tracks = [];
+ this.options = arguments[1] || {};
+ this.addTracks(tracks);
+ },
+ addTracks: function(tracks){
+ tracks.each(function(track){
+ var data = $H(track).values().first();
+ this.tracks.push($H({
+ ids: $H(track).keys().first(),
+ effect: Effect.Morph,
+ options: { style: data }
+ }));
+ }.bind(this));
+ return this;
+ },
+ play: function(){
+ return new Effect.Parallel(
+ this.tracks.map(function(track){
+ var elements = [$(track.ids) || $$(track.ids)].flatten();
+ return elements.map(function(e){ return new track.effect(e, Object.extend({ sync:true }, track.options)) });
+ }).flatten(),
+ this.options
+ );
+ }
+});
+
+Element.CSS_PROPERTIES = ['azimuth', 'backgroundAttachment', 'backgroundColor', 'backgroundImage',
+ 'backgroundPosition', 'backgroundRepeat', 'borderBottomColor', 'borderBottomStyle',
+ 'borderBottomWidth', 'borderCollapse', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth',
+ 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderSpacing', 'borderTopColor',
+ 'borderTopStyle', 'borderTopWidth', 'bottom', 'captionSide', 'clear', 'clip', 'color', 'content',
+ 'counterIncrement', 'counterReset', 'cssFloat', 'cueAfter', 'cueBefore', 'cursor', 'direction',
+ 'display', 'elevation', 'emptyCells', 'fontFamily', 'fontSize', 'fontSizeAdjust', 'fontStretch',
+ 'fontStyle', 'fontVariant', 'fontWeight', 'height', 'left', 'letterSpacing', 'lineHeight',
+ 'listStyleImage', 'listStylePosition', 'listStyleType', 'marginBottom', 'marginLeft', 'marginRight',
+ 'marginTop', 'markerOffset', 'marks', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'opacity',
+ 'orphans', 'outlineColor', 'outlineOffset', 'outlineStyle', 'outlineWidth', 'overflowX', 'overflowY',
+ 'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop', 'page', 'pageBreakAfter', 'pageBreakBefore',
+ 'pageBreakInside', 'pauseAfter', 'pauseBefore', 'pitch', 'pitchRange', 'position', 'quotes',
+ 'richness', 'right', 'size', 'speakHeader', 'speakNumeral', 'speakPunctuation', 'speechRate', 'stress',
+ 'tableLayout', 'textAlign', 'textDecoration', 'textIndent', 'textShadow', 'textTransform', 'top',
+ 'unicodeBidi', 'verticalAlign', 'visibility', 'voiceFamily', 'volume', 'whiteSpace', 'widows',
+ 'width', 'wordSpacing', 'zIndex'];
+
+Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
+
+String.prototype.parseStyle = function(){
+ var element = Element.extend(document.createElement('div'));
+ element.innerHTML = '
';
+ var style = element.down().style, styleRules = $H();
+
+ Element.CSS_PROPERTIES.each(function(property){
+ if(style[property]) styleRules[property] = style[property];
+ });
+
+ var result = $H();
+
+ styleRules.each(function(pair){
+ var property = pair[0], value = pair[1], unit = null;
+
+ if(value.parseColor('#zzzzzz') != '#zzzzzz') {
+ value = value.parseColor();
+ unit = 'color';
+ } else if(Element.CSS_LENGTH.test(value))
+ var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/),
+ value = parseFloat(components[1]), unit = (components.length == 3) ? components[2] : null;
+
+ result[property.underscore().dasherize()] = $H({ value:value, unit:unit });
+ }.bind(this));
+
+ return result;
+};
+
+Element.morph = function(element, style) {
+ new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || {}));
+ return element;
+};
+
+['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom',
+ 'collectTextNodes','collectTextNodesIgnoreClass','morph'].each(
+ function(f) { Element.Methods[f] = Element[f]; }
+);
+
+Element.Methods.visualEffect = function(element, effect, options) {
+ s = effect.gsub(/_/, '-').camelize();
+ effect_class = s.charAt(0).toUpperCase() + s.substring(1);
+ new Effect[effect_class](element, options);
+ return $(element);
+};
+
+Element.addMethods();
\ No newline at end of file
diff --git a/rest_sys/public/javascripts/jstoolbar.js b/rest_sys/public/javascripts/jstoolbar.js
new file mode 100644
index 000000000..fd4611e2d
--- /dev/null
+++ b/rest_sys/public/javascripts/jstoolbar.js
@@ -0,0 +1,468 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * This file is part of DotClear.
+ * Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All
+ * rights reserved.
+ *
+ * DotClear is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * DotClear is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with DotClear; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * ***** END LICENSE BLOCK *****
+*/
+
+/* Modified by JP LANG for textile formatting */
+
+function jsToolBar(textarea) {
+ if (!document.createElement) { return; }
+
+ if (!textarea) { return; }
+
+ if ((typeof(document["selection"]) == "undefined")
+ && (typeof(textarea["setSelectionRange"]) == "undefined")) {
+ return;
+ }
+
+ this.textarea = textarea;
+
+ this.editor = document.createElement('div');
+ this.editor.className = 'jstEditor';
+
+ this.textarea.parentNode.insertBefore(this.editor,this.textarea);
+ this.editor.appendChild(this.textarea);
+
+ this.toolbar = document.createElement("div");
+ this.toolbar.className = 'jstElements';
+ this.editor.parentNode.insertBefore(this.toolbar,this.editor);
+
+ // Dragable resizing (only for gecko)
+ if (this.editor.addEventListener)
+ {
+ this.handle = document.createElement('div');
+ this.handle.className = 'jstHandle';
+ var dragStart = this.resizeDragStart;
+ var This = this;
+ this.handle.addEventListener('mousedown',function(event) { dragStart.call(This,event); },false);
+ // fix memory leak in Firefox (bug #241518)
+ window.addEventListener('unload',function() {
+ var del = This.handle.parentNode.removeChild(This.handle);
+ delete(This.handle);
+ },false);
+
+ this.editor.parentNode.insertBefore(this.handle,this.editor.nextSibling);
+ }
+
+ this.context = null;
+ this.toolNodes = {}; // lorsque la toolbar est dessinée , cet objet est garni
+ // de raccourcis vers les éléments DOM correspondants aux outils.
+}
+
+function jsButton(title, fn, scope, className) {
+ this.title = title || null;
+ this.fn = fn || function(){};
+ this.scope = scope || null;
+ this.className = className || null;
+}
+jsButton.prototype.draw = function() {
+ if (!this.scope) return null;
+
+ var button = document.createElement('button');
+ button.setAttribute('type','button');
+ if (this.className) button.className = this.className;
+ button.title = this.title;
+ var span = document.createElement('span');
+ span.appendChild(document.createTextNode(this.title));
+ button.appendChild(span);
+
+ if (this.icon != undefined) {
+ button.style.backgroundImage = 'url('+this.icon+')';
+ }
+ if (typeof(this.fn) == 'function') {
+ var This = this;
+ button.onclick = function() { try { This.fn.apply(This.scope, arguments) } catch (e) {} return false; };
+ }
+ return button;
+}
+
+function jsSpace(id) {
+ this.id = id || null;
+ this.width = null;
+}
+jsSpace.prototype.draw = function() {
+ var span = document.createElement('span');
+ if (this.id) span.id = this.id;
+ span.appendChild(document.createTextNode(String.fromCharCode(160)));
+ span.className = 'jstSpacer';
+ if (this.width) span.style.marginRight = this.width+'px';
+
+ return span;
+}
+
+function jsCombo(title, options, scope, fn, className) {
+ this.title = title || null;
+ this.options = options || null;
+ this.scope = scope || null;
+ this.fn = fn || function(){};
+ this.className = className || null;
+}
+jsCombo.prototype.draw = function() {
+ if (!this.scope || !this.options) return null;
+
+ var select = document.createElement('select');
+ if (this.className) select.className = className;
+ select.title = this.title;
+
+ for (var o in this.options) {
+ //var opt = this.options[o];
+ var option = document.createElement('option');
+ option.value = o;
+ option.appendChild(document.createTextNode(this.options[o]));
+ select.appendChild(option);
+ }
+
+ var This = this;
+ select.onchange = function() {
+ try {
+ This.fn.call(This.scope, this.value);
+ } catch (e) { alert(e); }
+
+ return false;
+ }
+
+ return select;
+}
+
+
+jsToolBar.prototype = {
+ base_url: '',
+ mode: 'wiki',
+ elements: {},
+
+ getMode: function() {
+ return this.mode;
+ },
+
+ setMode: function(mode) {
+ this.mode = mode || 'wiki';
+ },
+
+ switchMode: function(mode) {
+ mode = mode || 'wiki';
+ this.draw(mode);
+ },
+
+ button: function(toolName) {
+ var tool = this.elements[toolName];
+ if (typeof tool.fn[this.mode] != 'function') return null;
+ var b = new jsButton(tool.title, tool.fn[this.mode], this, 'jstb_'+toolName);
+ if (tool.icon != undefined) b.icon = tool.icon;
+ return b;
+ },
+ space: function(toolName) {
+ var tool = new jsSpace(toolName)
+ if (this.elements[toolName].width !== undefined)
+ tool.width = this.elements[toolName].width;
+ return tool;
+ },
+ combo: function(toolName) {
+ var tool = this.elements[toolName];
+ var length = tool[this.mode].list.length;
+
+ if (typeof tool[this.mode].fn != 'function' || length == 0) {
+ return null;
+ } else {
+ var options = {};
+ for (var i=0; i < length; i++) {
+ var opt = tool[this.mode].list[i];
+ options[opt] = tool.options[opt];
+ }
+ return new jsCombo(tool.title, options, this, tool[this.mode].fn);
+ }
+ },
+ draw: function(mode) {
+ this.setMode(mode);
+
+ // Empty toolbar
+ while (this.toolbar.hasChildNodes()) {
+ this.toolbar.removeChild(this.toolbar.firstChild)
+ }
+ this.toolNodes = {}; // vide les raccourcis DOM/**/
+
+ // Draw toolbar elements
+ var b, tool, newTool;
+
+ for (var i in this.elements) {
+ b = this.elements[i];
+
+ var disabled =
+ b.type == undefined || b.type == ''
+ || (b.disabled != undefined && b.disabled)
+ || (b.context != undefined && b.context != null && b.context != this.context);
+
+ if (!disabled && typeof this[b.type] == 'function') {
+ tool = this[b.type](i);
+ if (tool) newTool = tool.draw();
+ if (newTool) {
+ this.toolNodes[i] = newTool; //mémorise l'accès DOM pour usage éventuel ultérieur
+ this.toolbar.appendChild(newTool);
+ }
+ }
+ }
+ },
+
+ singleTag: function(stag,etag) {
+ stag = stag || null;
+ etag = etag || stag;
+
+ if (!stag || !etag) { return; }
+
+ this.encloseSelection(stag,etag);
+ },
+
+ encloseSelection: function(prefix, suffix, fn) {
+ this.textarea.focus();
+
+ prefix = prefix || '';
+ suffix = suffix || '';
+
+ var start, end, sel, scrollPos, subst, res;
+
+ if (typeof(document["selection"]) != "undefined") {
+ sel = document.selection.createRange().text;
+ } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
+ start = this.textarea.selectionStart;
+ end = this.textarea.selectionEnd;
+ scrollPos = this.textarea.scrollTop;
+ sel = this.textarea.value.substring(start, end);
+ }
+
+ if (sel.match(/ $/)) { // exclude ending space char, if any
+ sel = sel.substring(0, sel.length - 1);
+ suffix = suffix + " ";
+ }
+
+ if (typeof(fn) == 'function') {
+ res = (sel) ? fn.call(this,sel) : fn('');
+ } else {
+ res = (sel) ? sel : '';
+ }
+
+ subst = prefix + res + suffix;
+
+ if (typeof(document["selection"]) != "undefined") {
+ document.selection.createRange().text = subst;
+ var range = this.textarea.createTextRange();
+ range.collapse(false);
+ range.move('character', -suffix.length);
+ range.select();
+// this.textarea.caretPos -= suffix.length;
+ } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
+ this.textarea.value = this.textarea.value.substring(0, start) + subst +
+ this.textarea.value.substring(end);
+ if (sel) {
+ this.textarea.setSelectionRange(start + subst.length, start + subst.length);
+ } else {
+ this.textarea.setSelectionRange(start + prefix.length, start + prefix.length);
+ }
+ this.textarea.scrollTop = scrollPos;
+ }
+ },
+
+ stripBaseURL: function(url) {
+ if (this.base_url != '') {
+ var pos = url.indexOf(this.base_url);
+ if (pos == 0) {
+ url = url.substr(this.base_url.length);
+ }
+ }
+
+ return url;
+ }
+};
+
+/** Resizer
+-------------------------------------------------------- */
+jsToolBar.prototype.resizeSetStartH = function() {
+ this.dragStartH = this.textarea.offsetHeight + 0;
+};
+jsToolBar.prototype.resizeDragStart = function(event) {
+ var This = this;
+ this.dragStartY = event.clientY;
+ this.resizeSetStartH();
+ document.addEventListener('mousemove', this.dragMoveHdlr=function(event){This.resizeDragMove(event);}, false);
+ document.addEventListener('mouseup', this.dragStopHdlr=function(event){This.resizeDragStop(event);}, false);
+};
+
+jsToolBar.prototype.resizeDragMove = function(event) {
+ this.textarea.style.height = (this.dragStartH+event.clientY-this.dragStartY)+'px';
+};
+
+jsToolBar.prototype.resizeDragStop = function(event) {
+ document.removeEventListener('mousemove', this.dragMoveHdlr, false);
+ document.removeEventListener('mouseup', this.dragStopHdlr, false);
+};
+
+// Elements definition ------------------------------------
+
+// strong
+jsToolBar.prototype.elements.strong = {
+ type: 'button',
+ title: 'Strong emphasis',
+ fn: {
+ wiki: function() { this.singleTag('*') }
+ }
+}
+
+// em
+jsToolBar.prototype.elements.em = {
+ type: 'button',
+ title: 'Emphasis',
+ fn: {
+ wiki: function() { this.singleTag("_") }
+ }
+}
+
+// ins
+jsToolBar.prototype.elements.ins = {
+ type: 'button',
+ title: 'Inserted',
+ fn: {
+ wiki: function() { this.singleTag('+') }
+ }
+}
+
+// del
+jsToolBar.prototype.elements.del = {
+ type: 'button',
+ title: 'Deleted',
+ fn: {
+ wiki: function() { this.singleTag('-') }
+ }
+}
+
+// quote
+jsToolBar.prototype.elements.quote = {
+ type: 'button',
+ title: 'Inline quote',
+ fn: {
+ wiki: function() { this.singleTag('??') }
+ }
+}
+
+// code
+jsToolBar.prototype.elements.code = {
+ type: 'button',
+ title: 'Code',
+ fn: {
+ wiki: function() { this.singleTag('@') }
+ }
+}
+
+// spacer
+jsToolBar.prototype.elements.space1 = {type: 'space'}
+
+// heading
+jsToolBar.prototype.elements.heading = {
+ type: 'button',
+ title: 'Heading',
+ fn: {
+ wiki: function() {
+ this.encloseSelection('','',function(str) {
+ str = str.replace(/\r/g,'');
+ return 'h2. '+str.replace(/\n/g,"\n* ");
+ });
+ }
+ }
+}
+
+// br
+//jsToolBar.prototype.elements.br = {
+// type: 'button',
+// title: 'Line break',
+// fn: {
+// wiki: function() { this.encloseSelection("%%%\n",'') }
+// }
+//}
+
+// spacer
+jsToolBar.prototype.elements.space2 = {type: 'space'}
+
+// ul
+jsToolBar.prototype.elements.ul = {
+ type: 'button',
+ title: 'Unordered list',
+ fn: {
+ wiki: function() {
+ this.encloseSelection('','',function(str) {
+ str = str.replace(/\r/g,'');
+ return '* '+str.replace(/\n/g,"\n* ");
+ });
+ }
+ }
+}
+
+// ol
+jsToolBar.prototype.elements.ol = {
+ type: 'button',
+ title: 'Ordered list',
+ fn: {
+ wiki: function() {
+ this.encloseSelection('','',function(str) {
+ str = str.replace(/\r/g,'');
+ return '# '+str.replace(/\n/g,"\n# ");
+ });
+ }
+ }
+}
+
+// spacer
+jsToolBar.prototype.elements.space3 = {type: 'space'}
+
+// link
+/*
+jsToolBar.prototype.elements.link = {
+ type: 'button',
+ title: 'Link',
+ fn: {},
+ href_prompt: 'Please give page URL:',
+ hreflang_prompt: 'Language of this page:',
+ default_hreflang: '',
+ prompt: function(href,hreflang) {
+ href = href || '';
+ hreflang = hreflang || this.elements.link.default_hreflang;
+
+ href = window.prompt(this.elements.link.href_prompt,href);
+ if (!href) { return false; }
+
+ hreflang = ""
+
+ return { href: this.stripBaseURL(href), hreflang: hreflang };
+ }
+}
+
+jsToolBar.prototype.elements.link.fn.wiki = function() {
+ var link = this.elements.link.prompt.call(this);
+ if (link) {
+ var stag = '"';
+ var etag = '":'+link.href;
+ this.encloseSelection(stag,etag);
+ }
+};
+*/
+// link or wiki page
+jsToolBar.prototype.elements.link = {
+ type: 'button',
+ title: 'Link',
+ fn: {
+ wiki: function() { this.encloseSelection("[[", "]]") }
+ }
+}
diff --git a/rest_sys/public/javascripts/prototype.js b/rest_sys/public/javascripts/prototype.js
new file mode 100644
index 000000000..2735d10dc
--- /dev/null
+++ b/rest_sys/public/javascripts/prototype.js
@@ -0,0 +1,2515 @@
+/* Prototype JavaScript framework, version 1.5.0
+ * (c) 2005-2007 Sam Stephenson
+ *
+ * Prototype is freely distributable under the terms of an MIT-style license.
+ * For details, see the Prototype web site: http://prototype.conio.net/
+ *
+/*--------------------------------------------------------------------------*/
+
+var Prototype = {
+ Version: '1.5.0',
+ BrowserFeatures: {
+ XPath: !!document.evaluate
+ },
+
+ ScriptFragment: '(?:)((\n|\r|.)*?)(?:<\/script>)',
+ emptyFunction: function() {},
+ K: function(x) { return x }
+}
+
+var Class = {
+ create: function() {
+ return function() {
+ this.initialize.apply(this, arguments);
+ }
+ }
+}
+
+var Abstract = new Object();
+
+Object.extend = function(destination, source) {
+ for (var property in source) {
+ destination[property] = source[property];
+ }
+ return destination;
+}
+
+Object.extend(Object, {
+ inspect: function(object) {
+ try {
+ if (object === undefined) return 'undefined';
+ if (object === null) return 'null';
+ return object.inspect ? object.inspect() : object.toString();
+ } catch (e) {
+ if (e instanceof RangeError) return '...';
+ throw e;
+ }
+ },
+
+ keys: function(object) {
+ var keys = [];
+ for (var property in object)
+ keys.push(property);
+ return keys;
+ },
+
+ values: function(object) {
+ var values = [];
+ for (var property in object)
+ values.push(object[property]);
+ return values;
+ },
+
+ clone: function(object) {
+ return Object.extend({}, object);
+ }
+});
+
+Function.prototype.bind = function() {
+ var __method = this, args = $A(arguments), object = args.shift();
+ return function() {
+ return __method.apply(object, args.concat($A(arguments)));
+ }
+}
+
+Function.prototype.bindAsEventListener = function(object) {
+ var __method = this, args = $A(arguments), object = args.shift();
+ return function(event) {
+ return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments)));
+ }
+}
+
+Object.extend(Number.prototype, {
+ toColorPart: function() {
+ var digits = this.toString(16);
+ if (this < 16) return '0' + digits;
+ return digits;
+ },
+
+ succ: function() {
+ return this + 1;
+ },
+
+ times: function(iterator) {
+ $R(0, this, true).each(iterator);
+ return this;
+ }
+});
+
+var Try = {
+ these: function() {
+ var returnValue;
+
+ for (var i = 0, length = arguments.length; i < length; i++) {
+ var lambda = arguments[i];
+ try {
+ returnValue = lambda();
+ break;
+ } catch (e) {}
+ }
+
+ return returnValue;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+
+var PeriodicalExecuter = Class.create();
+PeriodicalExecuter.prototype = {
+ initialize: function(callback, frequency) {
+ this.callback = callback;
+ this.frequency = frequency;
+ this.currentlyExecuting = false;
+
+ this.registerCallback();
+ },
+
+ registerCallback: function() {
+ this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
+ },
+
+ stop: function() {
+ if (!this.timer) return;
+ clearInterval(this.timer);
+ this.timer = null;
+ },
+
+ onTimerEvent: function() {
+ if (!this.currentlyExecuting) {
+ try {
+ this.currentlyExecuting = true;
+ this.callback(this);
+ } finally {
+ this.currentlyExecuting = false;
+ }
+ }
+ }
+}
+String.interpret = function(value){
+ return value == null ? '' : String(value);
+}
+
+Object.extend(String.prototype, {
+ gsub: function(pattern, replacement) {
+ var result = '', source = this, match;
+ replacement = arguments.callee.prepareReplacement(replacement);
+
+ while (source.length > 0) {
+ if (match = source.match(pattern)) {
+ result += source.slice(0, match.index);
+ result += String.interpret(replacement(match));
+ source = source.slice(match.index + match[0].length);
+ } else {
+ result += source, source = '';
+ }
+ }
+ return result;
+ },
+
+ sub: function(pattern, replacement, count) {
+ replacement = this.gsub.prepareReplacement(replacement);
+ count = count === undefined ? 1 : count;
+
+ return this.gsub(pattern, function(match) {
+ if (--count < 0) return match[0];
+ return replacement(match);
+ });
+ },
+
+ scan: function(pattern, iterator) {
+ this.gsub(pattern, iterator);
+ return this;
+ },
+
+ truncate: function(length, truncation) {
+ length = length || 30;
+ truncation = truncation === undefined ? '...' : truncation;
+ return this.length > length ?
+ this.slice(0, length - truncation.length) + truncation : this;
+ },
+
+ strip: function() {
+ return this.replace(/^\s+/, '').replace(/\s+$/, '');
+ },
+
+ stripTags: function() {
+ return this.replace(/<\/?[^>]+>/gi, '');
+ },
+
+ stripScripts: function() {
+ return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
+ },
+
+ extractScripts: function() {
+ var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
+ var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
+ return (this.match(matchAll) || []).map(function(scriptTag) {
+ return (scriptTag.match(matchOne) || ['', ''])[1];
+ });
+ },
+
+ evalScripts: function() {
+ return this.extractScripts().map(function(script) { return eval(script) });
+ },
+
+ escapeHTML: function() {
+ var div = document.createElement('div');
+ var text = document.createTextNode(this);
+ div.appendChild(text);
+ return div.innerHTML;
+ },
+
+ unescapeHTML: function() {
+ var div = document.createElement('div');
+ div.innerHTML = this.stripTags();
+ return div.childNodes[0] ? (div.childNodes.length > 1 ?
+ $A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) :
+ div.childNodes[0].nodeValue) : '';
+ },
+
+ toQueryParams: function(separator) {
+ var match = this.strip().match(/([^?#]*)(#.*)?$/);
+ if (!match) return {};
+
+ return match[1].split(separator || '&').inject({}, function(hash, pair) {
+ if ((pair = pair.split('='))[0]) {
+ var name = decodeURIComponent(pair[0]);
+ var value = pair[1] ? decodeURIComponent(pair[1]) : undefined;
+
+ if (hash[name] !== undefined) {
+ if (hash[name].constructor != Array)
+ hash[name] = [hash[name]];
+ if (value) hash[name].push(value);
+ }
+ else hash[name] = value;
+ }
+ return hash;
+ });
+ },
+
+ toArray: function() {
+ return this.split('');
+ },
+
+ succ: function() {
+ return this.slice(0, this.length - 1) +
+ String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
+ },
+
+ camelize: function() {
+ var parts = this.split('-'), len = parts.length;
+ if (len == 1) return parts[0];
+
+ var camelized = this.charAt(0) == '-'
+ ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
+ : parts[0];
+
+ for (var i = 1; i < len; i++)
+ camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
+
+ return camelized;
+ },
+
+ capitalize: function(){
+ return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
+ },
+
+ underscore: function() {
+ return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
+ },
+
+ dasherize: function() {
+ return this.gsub(/_/,'-');
+ },
+
+ inspect: function(useDoubleQuotes) {
+ var escapedString = this.replace(/\\/g, '\\\\');
+ if (useDoubleQuotes)
+ return '"' + escapedString.replace(/"/g, '\\"') + '"';
+ else
+ return "'" + escapedString.replace(/'/g, '\\\'') + "'";
+ }
+});
+
+String.prototype.gsub.prepareReplacement = function(replacement) {
+ if (typeof replacement == 'function') return replacement;
+ var template = new Template(replacement);
+ return function(match) { return template.evaluate(match) };
+}
+
+String.prototype.parseQuery = String.prototype.toQueryParams;
+
+var Template = Class.create();
+Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
+Template.prototype = {
+ initialize: function(template, pattern) {
+ this.template = template.toString();
+ this.pattern = pattern || Template.Pattern;
+ },
+
+ evaluate: function(object) {
+ return this.template.gsub(this.pattern, function(match) {
+ var before = match[1];
+ if (before == '\\') return match[2];
+ return before + String.interpret(object[match[3]]);
+ });
+ }
+}
+
+var $break = new Object();
+var $continue = new Object();
+
+var Enumerable = {
+ each: function(iterator) {
+ var index = 0;
+ try {
+ this._each(function(value) {
+ try {
+ iterator(value, index++);
+ } catch (e) {
+ if (e != $continue) throw e;
+ }
+ });
+ } catch (e) {
+ if (e != $break) throw e;
+ }
+ return this;
+ },
+
+ eachSlice: function(number, iterator) {
+ var index = -number, slices = [], array = this.toArray();
+ while ((index += number) < array.length)
+ slices.push(array.slice(index, index+number));
+ return slices.map(iterator);
+ },
+
+ all: function(iterator) {
+ var result = true;
+ this.each(function(value, index) {
+ result = result && !!(iterator || Prototype.K)(value, index);
+ if (!result) throw $break;
+ });
+ return result;
+ },
+
+ any: function(iterator) {
+ var result = false;
+ this.each(function(value, index) {
+ if (result = !!(iterator || Prototype.K)(value, index))
+ throw $break;
+ });
+ return result;
+ },
+
+ collect: function(iterator) {
+ var results = [];
+ this.each(function(value, index) {
+ results.push((iterator || Prototype.K)(value, index));
+ });
+ return results;
+ },
+
+ detect: function(iterator) {
+ var result;
+ this.each(function(value, index) {
+ if (iterator(value, index)) {
+ result = value;
+ throw $break;
+ }
+ });
+ return result;
+ },
+
+ findAll: function(iterator) {
+ var results = [];
+ this.each(function(value, index) {
+ if (iterator(value, index))
+ results.push(value);
+ });
+ return results;
+ },
+
+ grep: function(pattern, iterator) {
+ var results = [];
+ this.each(function(value, index) {
+ var stringValue = value.toString();
+ if (stringValue.match(pattern))
+ results.push((iterator || Prototype.K)(value, index));
+ })
+ return results;
+ },
+
+ include: function(object) {
+ var found = false;
+ this.each(function(value) {
+ if (value == object) {
+ found = true;
+ throw $break;
+ }
+ });
+ return found;
+ },
+
+ inGroupsOf: function(number, fillWith) {
+ fillWith = fillWith === undefined ? null : fillWith;
+ return this.eachSlice(number, function(slice) {
+ while(slice.length < number) slice.push(fillWith);
+ return slice;
+ });
+ },
+
+ inject: function(memo, iterator) {
+ this.each(function(value, index) {
+ memo = iterator(memo, value, index);
+ });
+ return memo;
+ },
+
+ invoke: function(method) {
+ var args = $A(arguments).slice(1);
+ return this.map(function(value) {
+ return value[method].apply(value, args);
+ });
+ },
+
+ max: function(iterator) {
+ var result;
+ this.each(function(value, index) {
+ value = (iterator || Prototype.K)(value, index);
+ if (result == undefined || value >= result)
+ result = value;
+ });
+ return result;
+ },
+
+ min: function(iterator) {
+ var result;
+ this.each(function(value, index) {
+ value = (iterator || Prototype.K)(value, index);
+ if (result == undefined || value < result)
+ result = value;
+ });
+ return result;
+ },
+
+ partition: function(iterator) {
+ var trues = [], falses = [];
+ this.each(function(value, index) {
+ ((iterator || Prototype.K)(value, index) ?
+ trues : falses).push(value);
+ });
+ return [trues, falses];
+ },
+
+ pluck: function(property) {
+ var results = [];
+ this.each(function(value, index) {
+ results.push(value[property]);
+ });
+ return results;
+ },
+
+ reject: function(iterator) {
+ var results = [];
+ this.each(function(value, index) {
+ if (!iterator(value, index))
+ results.push(value);
+ });
+ return results;
+ },
+
+ sortBy: function(iterator) {
+ return this.map(function(value, index) {
+ return {value: value, criteria: iterator(value, index)};
+ }).sort(function(left, right) {
+ var a = left.criteria, b = right.criteria;
+ return a < b ? -1 : a > b ? 1 : 0;
+ }).pluck('value');
+ },
+
+ toArray: function() {
+ return this.map();
+ },
+
+ zip: function() {
+ var iterator = Prototype.K, args = $A(arguments);
+ if (typeof args.last() == 'function')
+ iterator = args.pop();
+
+ var collections = [this].concat(args).map($A);
+ return this.map(function(value, index) {
+ return iterator(collections.pluck(index));
+ });
+ },
+
+ size: function() {
+ return this.toArray().length;
+ },
+
+ inspect: function() {
+ return '#';
+ }
+}
+
+Object.extend(Enumerable, {
+ map: Enumerable.collect,
+ find: Enumerable.detect,
+ select: Enumerable.findAll,
+ member: Enumerable.include,
+ entries: Enumerable.toArray
+});
+var $A = Array.from = function(iterable) {
+ if (!iterable) return [];
+ if (iterable.toArray) {
+ return iterable.toArray();
+ } else {
+ var results = [];
+ for (var i = 0, length = iterable.length; i < length; i++)
+ results.push(iterable[i]);
+ return results;
+ }
+}
+
+Object.extend(Array.prototype, Enumerable);
+
+if (!Array.prototype._reverse)
+ Array.prototype._reverse = Array.prototype.reverse;
+
+Object.extend(Array.prototype, {
+ _each: function(iterator) {
+ for (var i = 0, length = this.length; i < length; i++)
+ iterator(this[i]);
+ },
+
+ clear: function() {
+ this.length = 0;
+ return this;
+ },
+
+ first: function() {
+ return this[0];
+ },
+
+ last: function() {
+ return this[this.length - 1];
+ },
+
+ compact: function() {
+ return this.select(function(value) {
+ return value != null;
+ });
+ },
+
+ flatten: function() {
+ return this.inject([], function(array, value) {
+ return array.concat(value && value.constructor == Array ?
+ value.flatten() : [value]);
+ });
+ },
+
+ without: function() {
+ var values = $A(arguments);
+ return this.select(function(value) {
+ return !values.include(value);
+ });
+ },
+
+ indexOf: function(object) {
+ for (var i = 0, length = this.length; i < length; i++)
+ if (this[i] == object) return i;
+ return -1;
+ },
+
+ reverse: function(inline) {
+ return (inline !== false ? this : this.toArray())._reverse();
+ },
+
+ reduce: function() {
+ return this.length > 1 ? this : this[0];
+ },
+
+ uniq: function() {
+ return this.inject([], function(array, value) {
+ return array.include(value) ? array : array.concat([value]);
+ });
+ },
+
+ clone: function() {
+ return [].concat(this);
+ },
+
+ size: function() {
+ return this.length;
+ },
+
+ inspect: function() {
+ return '[' + this.map(Object.inspect).join(', ') + ']';
+ }
+});
+
+Array.prototype.toArray = Array.prototype.clone;
+
+function $w(string){
+ string = string.strip();
+ return string ? string.split(/\s+/) : [];
+}
+
+if(window.opera){
+ Array.prototype.concat = function(){
+ var array = [];
+ for(var i = 0, length = this.length; i < length; i++) array.push(this[i]);
+ for(var i = 0, length = arguments.length; i < length; i++) {
+ if(arguments[i].constructor == Array) {
+ for(var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
+ array.push(arguments[i][j]);
+ } else {
+ array.push(arguments[i]);
+ }
+ }
+ return array;
+ }
+}
+var Hash = function(obj) {
+ Object.extend(this, obj || {});
+};
+
+Object.extend(Hash, {
+ toQueryString: function(obj) {
+ var parts = [];
+
+ this.prototype._each.call(obj, function(pair) {
+ if (!pair.key) return;
+
+ if (pair.value && pair.value.constructor == Array) {
+ var values = pair.value.compact();
+ if (values.length < 2) pair.value = values.reduce();
+ else {
+ key = encodeURIComponent(pair.key);
+ values.each(function(value) {
+ value = value != undefined ? encodeURIComponent(value) : '';
+ parts.push(key + '=' + encodeURIComponent(value));
+ });
+ return;
+ }
+ }
+ if (pair.value == undefined) pair[1] = '';
+ parts.push(pair.map(encodeURIComponent).join('='));
+ });
+
+ return parts.join('&');
+ }
+});
+
+Object.extend(Hash.prototype, Enumerable);
+Object.extend(Hash.prototype, {
+ _each: function(iterator) {
+ for (var key in this) {
+ var value = this[key];
+ if (value && value == Hash.prototype[key]) continue;
+
+ var pair = [key, value];
+ pair.key = key;
+ pair.value = value;
+ iterator(pair);
+ }
+ },
+
+ keys: function() {
+ return this.pluck('key');
+ },
+
+ values: function() {
+ return this.pluck('value');
+ },
+
+ merge: function(hash) {
+ return $H(hash).inject(this, function(mergedHash, pair) {
+ mergedHash[pair.key] = pair.value;
+ return mergedHash;
+ });
+ },
+
+ remove: function() {
+ var result;
+ for(var i = 0, length = arguments.length; i < length; i++) {
+ var value = this[arguments[i]];
+ if (value !== undefined){
+ if (result === undefined) result = value;
+ else {
+ if (result.constructor != Array) result = [result];
+ result.push(value)
+ }
+ }
+ delete this[arguments[i]];
+ }
+ return result;
+ },
+
+ toQueryString: function() {
+ return Hash.toQueryString(this);
+ },
+
+ inspect: function() {
+ return '#';
+ }
+});
+
+function $H(object) {
+ if (object && object.constructor == Hash) return object;
+ return new Hash(object);
+};
+ObjectRange = Class.create();
+Object.extend(ObjectRange.prototype, Enumerable);
+Object.extend(ObjectRange.prototype, {
+ initialize: function(start, end, exclusive) {
+ this.start = start;
+ this.end = end;
+ this.exclusive = exclusive;
+ },
+
+ _each: function(iterator) {
+ var value = this.start;
+ while (this.include(value)) {
+ iterator(value);
+ value = value.succ();
+ }
+ },
+
+ include: function(value) {
+ if (value < this.start)
+ return false;
+ if (this.exclusive)
+ return value < this.end;
+ return value <= this.end;
+ }
+});
+
+var $R = function(start, end, exclusive) {
+ return new ObjectRange(start, end, exclusive);
+}
+
+var Ajax = {
+ getTransport: function() {
+ return Try.these(
+ function() {return new XMLHttpRequest()},
+ function() {return new ActiveXObject('Msxml2.XMLHTTP')},
+ function() {return new ActiveXObject('Microsoft.XMLHTTP')}
+ ) || false;
+ },
+
+ activeRequestCount: 0
+}
+
+Ajax.Responders = {
+ responders: [],
+
+ _each: function(iterator) {
+ this.responders._each(iterator);
+ },
+
+ register: function(responder) {
+ if (!this.include(responder))
+ this.responders.push(responder);
+ },
+
+ unregister: function(responder) {
+ this.responders = this.responders.without(responder);
+ },
+
+ dispatch: function(callback, request, transport, json) {
+ this.each(function(responder) {
+ if (typeof responder[callback] == 'function') {
+ try {
+ responder[callback].apply(responder, [request, transport, json]);
+ } catch (e) {}
+ }
+ });
+ }
+};
+
+Object.extend(Ajax.Responders, Enumerable);
+
+Ajax.Responders.register({
+ onCreate: function() {
+ Ajax.activeRequestCount++;
+ },
+ onComplete: function() {
+ Ajax.activeRequestCount--;
+ }
+});
+
+Ajax.Base = function() {};
+Ajax.Base.prototype = {
+ setOptions: function(options) {
+ this.options = {
+ method: 'post',
+ asynchronous: true,
+ contentType: 'application/x-www-form-urlencoded',
+ encoding: 'UTF-8',
+ parameters: ''
+ }
+ Object.extend(this.options, options || {});
+
+ this.options.method = this.options.method.toLowerCase();
+ if (typeof this.options.parameters == 'string')
+ this.options.parameters = this.options.parameters.toQueryParams();
+ }
+}
+
+Ajax.Request = Class.create();
+Ajax.Request.Events =
+ ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
+
+Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
+ _complete: false,
+
+ initialize: function(url, options) {
+ this.transport = Ajax.getTransport();
+ this.setOptions(options);
+ this.request(url);
+ },
+
+ request: function(url) {
+ this.url = url;
+ this.method = this.options.method;
+ var params = this.options.parameters;
+
+ if (!['get', 'post'].include(this.method)) {
+ // simulate other verbs over post
+ params['_method'] = this.method;
+ this.method = 'post';
+ }
+
+ params = Hash.toQueryString(params);
+ if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_='
+
+ // when GET, append parameters to URL
+ if (this.method == 'get' && params)
+ this.url += (this.url.indexOf('?') > -1 ? '&' : '?') + params;
+
+ try {
+ Ajax.Responders.dispatch('onCreate', this, this.transport);
+
+ this.transport.open(this.method.toUpperCase(), this.url,
+ this.options.asynchronous);
+
+ if (this.options.asynchronous)
+ setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10);
+
+ this.transport.onreadystatechange = this.onStateChange.bind(this);
+ this.setRequestHeaders();
+
+ var body = this.method == 'post' ? (this.options.postBody || params) : null;
+
+ this.transport.send(body);
+
+ /* Force Firefox to handle ready state 4 for synchronous requests */
+ if (!this.options.asynchronous && this.transport.overrideMimeType)
+ this.onStateChange();
+
+ }
+ catch (e) {
+ this.dispatchException(e);
+ }
+ },
+
+ onStateChange: function() {
+ var readyState = this.transport.readyState;
+ if (readyState > 1 && !((readyState == 4) && this._complete))
+ this.respondToReadyState(this.transport.readyState);
+ },
+
+ setRequestHeaders: function() {
+ var headers = {
+ 'X-Requested-With': 'XMLHttpRequest',
+ 'X-Prototype-Version': Prototype.Version,
+ 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
+ };
+
+ if (this.method == 'post') {
+ headers['Content-type'] = this.options.contentType +
+ (this.options.encoding ? '; charset=' + this.options.encoding : '');
+
+ /* Force "Connection: close" for older Mozilla browsers to work
+ * around a bug where XMLHttpRequest sends an incorrect
+ * Content-length header. See Mozilla Bugzilla #246651.
+ */
+ if (this.transport.overrideMimeType &&
+ (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
+ headers['Connection'] = 'close';
+ }
+
+ // user-defined headers
+ if (typeof this.options.requestHeaders == 'object') {
+ var extras = this.options.requestHeaders;
+
+ if (typeof extras.push == 'function')
+ for (var i = 0, length = extras.length; i < length; i += 2)
+ headers[extras[i]] = extras[i+1];
+ else
+ $H(extras).each(function(pair) { headers[pair.key] = pair.value });
+ }
+
+ for (var name in headers)
+ this.transport.setRequestHeader(name, headers[name]);
+ },
+
+ success: function() {
+ return !this.transport.status
+ || (this.transport.status >= 200 && this.transport.status < 300);
+ },
+
+ respondToReadyState: function(readyState) {
+ var state = Ajax.Request.Events[readyState];
+ var transport = this.transport, json = this.evalJSON();
+
+ if (state == 'Complete') {
+ try {
+ this._complete = true;
+ (this.options['on' + this.transport.status]
+ || this.options['on' + (this.success() ? 'Success' : 'Failure')]
+ || Prototype.emptyFunction)(transport, json);
+ } catch (e) {
+ this.dispatchException(e);
+ }
+
+ if ((this.getHeader('Content-type') || 'text/javascript').strip().
+ match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i))
+ this.evalResponse();
+ }
+
+ try {
+ (this.options['on' + state] || Prototype.emptyFunction)(transport, json);
+ Ajax.Responders.dispatch('on' + state, this, transport, json);
+ } catch (e) {
+ this.dispatchException(e);
+ }
+
+ if (state == 'Complete') {
+ // avoid memory leak in MSIE: clean up
+ this.transport.onreadystatechange = Prototype.emptyFunction;
+ }
+ },
+
+ getHeader: function(name) {
+ try {
+ return this.transport.getResponseHeader(name);
+ } catch (e) { return null }
+ },
+
+ evalJSON: function() {
+ try {
+ var json = this.getHeader('X-JSON');
+ return json ? eval('(' + json + ')') : null;
+ } catch (e) { return null }
+ },
+
+ evalResponse: function() {
+ try {
+ return eval(this.transport.responseText);
+ } catch (e) {
+ this.dispatchException(e);
+ }
+ },
+
+ dispatchException: function(exception) {
+ (this.options.onException || Prototype.emptyFunction)(this, exception);
+ Ajax.Responders.dispatch('onException', this, exception);
+ }
+});
+
+Ajax.Updater = Class.create();
+
+Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
+ initialize: function(container, url, options) {
+ this.container = {
+ success: (container.success || container),
+ failure: (container.failure || (container.success ? null : container))
+ }
+
+ this.transport = Ajax.getTransport();
+ this.setOptions(options);
+
+ var onComplete = this.options.onComplete || Prototype.emptyFunction;
+ this.options.onComplete = (function(transport, param) {
+ this.updateContent();
+ onComplete(transport, param);
+ }).bind(this);
+
+ this.request(url);
+ },
+
+ updateContent: function() {
+ var receiver = this.container[this.success() ? 'success' : 'failure'];
+ var response = this.transport.responseText;
+
+ if (!this.options.evalScripts) response = response.stripScripts();
+
+ if (receiver = $(receiver)) {
+ if (this.options.insertion)
+ new this.options.insertion(receiver, response);
+ else
+ receiver.update(response);
+ }
+
+ if (this.success()) {
+ if (this.onComplete)
+ setTimeout(this.onComplete.bind(this), 10);
+ }
+ }
+});
+
+Ajax.PeriodicalUpdater = Class.create();
+Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), {
+ initialize: function(container, url, options) {
+ this.setOptions(options);
+ this.onComplete = this.options.onComplete;
+
+ this.frequency = (this.options.frequency || 2);
+ this.decay = (this.options.decay || 1);
+
+ this.updater = {};
+ this.container = container;
+ this.url = url;
+
+ this.start();
+ },
+
+ start: function() {
+ this.options.onComplete = this.updateComplete.bind(this);
+ this.onTimerEvent();
+ },
+
+ stop: function() {
+ this.updater.options.onComplete = undefined;
+ clearTimeout(this.timer);
+ (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
+ },
+
+ updateComplete: function(request) {
+ if (this.options.decay) {
+ this.decay = (request.responseText == this.lastText ?
+ this.decay * this.options.decay : 1);
+
+ this.lastText = request.responseText;
+ }
+ this.timer = setTimeout(this.onTimerEvent.bind(this),
+ this.decay * this.frequency * 1000);
+ },
+
+ onTimerEvent: function() {
+ this.updater = new Ajax.Updater(this.container, this.url, this.options);
+ }
+});
+function $(element) {
+ if (arguments.length > 1) {
+ for (var i = 0, elements = [], length = arguments.length; i < length; i++)
+ elements.push($(arguments[i]));
+ return elements;
+ }
+ if (typeof element == 'string')
+ element = document.getElementById(element);
+ return Element.extend(element);
+}
+
+if (Prototype.BrowserFeatures.XPath) {
+ document._getElementsByXPath = function(expression, parentElement) {
+ var results = [];
+ var query = document.evaluate(expression, $(parentElement) || document,
+ null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+ for (var i = 0, length = query.snapshotLength; i < length; i++)
+ results.push(query.snapshotItem(i));
+ return results;
+ };
+}
+
+document.getElementsByClassName = function(className, parentElement) {
+ if (Prototype.BrowserFeatures.XPath) {
+ var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]";
+ return document._getElementsByXPath(q, parentElement);
+ } else {
+ var children = ($(parentElement) || document.body).getElementsByTagName('*');
+ var elements = [], child;
+ for (var i = 0, length = children.length; i < length; i++) {
+ child = children[i];
+ if (Element.hasClassName(child, className))
+ elements.push(Element.extend(child));
+ }
+ return elements;
+ }
+};
+
+/*--------------------------------------------------------------------------*/
+
+if (!window.Element)
+ var Element = new Object();
+
+Element.extend = function(element) {
+ if (!element || _nativeExtensions || element.nodeType == 3) return element;
+
+ if (!element._extended && element.tagName && element != window) {
+ var methods = Object.clone(Element.Methods), cache = Element.extend.cache;
+
+ if (element.tagName == 'FORM')
+ Object.extend(methods, Form.Methods);
+ if (['INPUT', 'TEXTAREA', 'SELECT'].include(element.tagName))
+ Object.extend(methods, Form.Element.Methods);
+
+ Object.extend(methods, Element.Methods.Simulated);
+
+ for (var property in methods) {
+ var value = methods[property];
+ if (typeof value == 'function' && !(property in element))
+ element[property] = cache.findOrStore(value);
+ }
+ }
+
+ element._extended = true;
+ return element;
+};
+
+Element.extend.cache = {
+ findOrStore: function(value) {
+ return this[value] = this[value] || function() {
+ return value.apply(null, [this].concat($A(arguments)));
+ }
+ }
+};
+
+Element.Methods = {
+ visible: function(element) {
+ return $(element).style.display != 'none';
+ },
+
+ toggle: function(element) {
+ element = $(element);
+ Element[Element.visible(element) ? 'hide' : 'show'](element);
+ return element;
+ },
+
+ hide: function(element) {
+ $(element).style.display = 'none';
+ return element;
+ },
+
+ show: function(element) {
+ $(element).style.display = '';
+ return element;
+ },
+
+ remove: function(element) {
+ element = $(element);
+ element.parentNode.removeChild(element);
+ return element;
+ },
+
+ update: function(element, html) {
+ html = typeof html == 'undefined' ? '' : html.toString();
+ $(element).innerHTML = html.stripScripts();
+ setTimeout(function() {html.evalScripts()}, 10);
+ return element;
+ },
+
+ replace: function(element, html) {
+ element = $(element);
+ html = typeof html == 'undefined' ? '' : html.toString();
+ if (element.outerHTML) {
+ element.outerHTML = html.stripScripts();
+ } else {
+ var range = element.ownerDocument.createRange();
+ range.selectNodeContents(element);
+ element.parentNode.replaceChild(
+ range.createContextualFragment(html.stripScripts()), element);
+ }
+ setTimeout(function() {html.evalScripts()}, 10);
+ return element;
+ },
+
+ inspect: function(element) {
+ element = $(element);
+ var result = '<' + element.tagName.toLowerCase();
+ $H({'id': 'id', 'className': 'class'}).each(function(pair) {
+ var property = pair.first(), attribute = pair.last();
+ var value = (element[property] || '').toString();
+ if (value) result += ' ' + attribute + '=' + value.inspect(true);
+ });
+ return result + '>';
+ },
+
+ recursivelyCollect: function(element, property) {
+ element = $(element);
+ var elements = [];
+ while (element = element[property])
+ if (element.nodeType == 1)
+ elements.push(Element.extend(element));
+ return elements;
+ },
+
+ ancestors: function(element) {
+ return $(element).recursivelyCollect('parentNode');
+ },
+
+ descendants: function(element) {
+ return $A($(element).getElementsByTagName('*'));
+ },
+
+ immediateDescendants: function(element) {
+ if (!(element = $(element).firstChild)) return [];
+ while (element && element.nodeType != 1) element = element.nextSibling;
+ if (element) return [element].concat($(element).nextSiblings());
+ return [];
+ },
+
+ previousSiblings: function(element) {
+ return $(element).recursivelyCollect('previousSibling');
+ },
+
+ nextSiblings: function(element) {
+ return $(element).recursivelyCollect('nextSibling');
+ },
+
+ siblings: function(element) {
+ element = $(element);
+ return element.previousSiblings().reverse().concat(element.nextSiblings());
+ },
+
+ match: function(element, selector) {
+ if (typeof selector == 'string')
+ selector = new Selector(selector);
+ return selector.match($(element));
+ },
+
+ up: function(element, expression, index) {
+ return Selector.findElement($(element).ancestors(), expression, index);
+ },
+
+ down: function(element, expression, index) {
+ return Selector.findElement($(element).descendants(), expression, index);
+ },
+
+ previous: function(element, expression, index) {
+ return Selector.findElement($(element).previousSiblings(), expression, index);
+ },
+
+ next: function(element, expression, index) {
+ return Selector.findElement($(element).nextSiblings(), expression, index);
+ },
+
+ getElementsBySelector: function() {
+ var args = $A(arguments), element = $(args.shift());
+ return Selector.findChildElements(element, args);
+ },
+
+ getElementsByClassName: function(element, className) {
+ return document.getElementsByClassName(className, element);
+ },
+
+ readAttribute: function(element, name) {
+ element = $(element);
+ if (document.all && !window.opera) {
+ var t = Element._attributeTranslations;
+ if (t.values[name]) return t.values[name](element, name);
+ if (t.names[name]) name = t.names[name];
+ var attribute = element.attributes[name];
+ if(attribute) return attribute.nodeValue;
+ }
+ return element.getAttribute(name);
+ },
+
+ getHeight: function(element) {
+ return $(element).getDimensions().height;
+ },
+
+ getWidth: function(element) {
+ return $(element).getDimensions().width;
+ },
+
+ classNames: function(element) {
+ return new Element.ClassNames(element);
+ },
+
+ hasClassName: function(element, className) {
+ if (!(element = $(element))) return;
+ var elementClassName = element.className;
+ if (elementClassName.length == 0) return false;
+ if (elementClassName == className ||
+ elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
+ return true;
+ return false;
+ },
+
+ addClassName: function(element, className) {
+ if (!(element = $(element))) return;
+ Element.classNames(element).add(className);
+ return element;
+ },
+
+ removeClassName: function(element, className) {
+ if (!(element = $(element))) return;
+ Element.classNames(element).remove(className);
+ return element;
+ },
+
+ toggleClassName: function(element, className) {
+ if (!(element = $(element))) return;
+ Element.classNames(element)[element.hasClassName(className) ? 'remove' : 'add'](className);
+ return element;
+ },
+
+ observe: function() {
+ Event.observe.apply(Event, arguments);
+ return $A(arguments).first();
+ },
+
+ stopObserving: function() {
+ Event.stopObserving.apply(Event, arguments);
+ return $A(arguments).first();
+ },
+
+ // removes whitespace-only text node children
+ cleanWhitespace: function(element) {
+ element = $(element);
+ var node = element.firstChild;
+ while (node) {
+ var nextNode = node.nextSibling;
+ if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
+ element.removeChild(node);
+ node = nextNode;
+ }
+ return element;
+ },
+
+ empty: function(element) {
+ return $(element).innerHTML.match(/^\s*$/);
+ },
+
+ descendantOf: function(element, ancestor) {
+ element = $(element), ancestor = $(ancestor);
+ while (element = element.parentNode)
+ if (element == ancestor) return true;
+ return false;
+ },
+
+ scrollTo: function(element) {
+ element = $(element);
+ var pos = Position.cumulativeOffset(element);
+ window.scrollTo(pos[0], pos[1]);
+ return element;
+ },
+
+ getStyle: function(element, style) {
+ element = $(element);
+ if (['float','cssFloat'].include(style))
+ style = (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat');
+ style = style.camelize();
+ var value = element.style[style];
+ if (!value) {
+ if (document.defaultView && document.defaultView.getComputedStyle) {
+ var css = document.defaultView.getComputedStyle(element, null);
+ value = css ? css[style] : null;
+ } else if (element.currentStyle) {
+ value = element.currentStyle[style];
+ }
+ }
+
+ if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none'))
+ value = element['offset'+style.capitalize()] + 'px';
+
+ if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
+ if (Element.getStyle(element, 'position') == 'static') value = 'auto';
+ if(style == 'opacity') {
+ if(value) return parseFloat(value);
+ if(value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
+ if(value[1]) return parseFloat(value[1]) / 100;
+ return 1.0;
+ }
+ return value == 'auto' ? null : value;
+ },
+
+ setStyle: function(element, style) {
+ element = $(element);
+ for (var name in style) {
+ var value = style[name];
+ if(name == 'opacity') {
+ if (value == 1) {
+ value = (/Gecko/.test(navigator.userAgent) &&
+ !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : 1.0;
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
+ element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'');
+ } else if(value == '') {
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
+ element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'');
+ } else {
+ if(value < 0.00001) value = 0;
+ if(/MSIE/.test(navigator.userAgent) && !window.opera)
+ element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') +
+ 'alpha(opacity='+value*100+')';
+ }
+ } else if(['float','cssFloat'].include(name)) name = (typeof element.style.styleFloat != 'undefined') ? 'styleFloat' : 'cssFloat';
+ element.style[name.camelize()] = value;
+ }
+ return element;
+ },
+
+ getDimensions: function(element) {
+ element = $(element);
+ var display = $(element).getStyle('display');
+ if (display != 'none' && display != null) // Safari bug
+ return {width: element.offsetWidth, height: element.offsetHeight};
+
+ // All *Width and *Height properties give 0 on elements with display none,
+ // so enable the element temporarily
+ var els = element.style;
+ var originalVisibility = els.visibility;
+ var originalPosition = els.position;
+ var originalDisplay = els.display;
+ els.visibility = 'hidden';
+ els.position = 'absolute';
+ els.display = 'block';
+ var originalWidth = element.clientWidth;
+ var originalHeight = element.clientHeight;
+ els.display = originalDisplay;
+ els.position = originalPosition;
+ els.visibility = originalVisibility;
+ return {width: originalWidth, height: originalHeight};
+ },
+
+ makePositioned: function(element) {
+ element = $(element);
+ var pos = Element.getStyle(element, 'position');
+ if (pos == 'static' || !pos) {
+ element._madePositioned = true;
+ element.style.position = 'relative';
+ // Opera returns the offset relative to the positioning context, when an
+ // element is position relative but top and left have not been defined
+ if (window.opera) {
+ element.style.top = 0;
+ element.style.left = 0;
+ }
+ }
+ return element;
+ },
+
+ undoPositioned: function(element) {
+ element = $(element);
+ if (element._madePositioned) {
+ element._madePositioned = undefined;
+ element.style.position =
+ element.style.top =
+ element.style.left =
+ element.style.bottom =
+ element.style.right = '';
+ }
+ return element;
+ },
+
+ makeClipping: function(element) {
+ element = $(element);
+ if (element._overflow) return element;
+ element._overflow = element.style.overflow || 'auto';
+ if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden')
+ element.style.overflow = 'hidden';
+ return element;
+ },
+
+ undoClipping: function(element) {
+ element = $(element);
+ if (!element._overflow) return element;
+ element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;
+ element._overflow = null;
+ return element;
+ }
+};
+
+Object.extend(Element.Methods, {childOf: Element.Methods.descendantOf});
+
+Element._attributeTranslations = {};
+
+Element._attributeTranslations.names = {
+ colspan: "colSpan",
+ rowspan: "rowSpan",
+ valign: "vAlign",
+ datetime: "dateTime",
+ accesskey: "accessKey",
+ tabindex: "tabIndex",
+ enctype: "encType",
+ maxlength: "maxLength",
+ readonly: "readOnly",
+ longdesc: "longDesc"
+};
+
+Element._attributeTranslations.values = {
+ _getAttr: function(element, attribute) {
+ return element.getAttribute(attribute, 2);
+ },
+
+ _flag: function(element, attribute) {
+ return $(element).hasAttribute(attribute) ? attribute : null;
+ },
+
+ style: function(element) {
+ return element.style.cssText.toLowerCase();
+ },
+
+ title: function(element) {
+ var node = element.getAttributeNode('title');
+ return node.specified ? node.nodeValue : null;
+ }
+};
+
+Object.extend(Element._attributeTranslations.values, {
+ href: Element._attributeTranslations.values._getAttr,
+ src: Element._attributeTranslations.values._getAttr,
+ disabled: Element._attributeTranslations.values._flag,
+ checked: Element._attributeTranslations.values._flag,
+ readonly: Element._attributeTranslations.values._flag,
+ multiple: Element._attributeTranslations.values._flag
+});
+
+Element.Methods.Simulated = {
+ hasAttribute: function(element, attribute) {
+ var t = Element._attributeTranslations;
+ attribute = t.names[attribute] || attribute;
+ return $(element).getAttributeNode(attribute).specified;
+ }
+};
+
+// IE is missing .innerHTML support for TABLE-related elements
+if (document.all && !window.opera){
+ Element.Methods.update = function(element, html) {
+ element = $(element);
+ html = typeof html == 'undefined' ? '' : html.toString();
+ var tagName = element.tagName.toUpperCase();
+ if (['THEAD','TBODY','TR','TD'].include(tagName)) {
+ var div = document.createElement('div');
+ switch (tagName) {
+ case 'THEAD':
+ case 'TBODY':
+ div.innerHTML = '' + html.stripScripts() + '
';
+ depth = 2;
+ break;
+ case 'TR':
+ div.innerHTML = '' + html.stripScripts() + '
';
+ depth = 3;
+ break;
+ case 'TD':
+ div.innerHTML = '' + html.stripScripts() + '
';
+ depth = 4;
+ }
+ $A(element.childNodes).each(function(node){
+ element.removeChild(node)
+ });
+ depth.times(function(){ div = div.firstChild });
+
+ $A(div.childNodes).each(
+ function(node){ element.appendChild(node) });
+ } else {
+ element.innerHTML = html.stripScripts();
+ }
+ setTimeout(function() {html.evalScripts()}, 10);
+ return element;
+ }
+};
+
+Object.extend(Element, Element.Methods);
+
+var _nativeExtensions = false;
+
+if(/Konqueror|Safari|KHTML/.test(navigator.userAgent))
+ ['', 'Form', 'Input', 'TextArea', 'Select'].each(function(tag) {
+ var className = 'HTML' + tag + 'Element';
+ if(window[className]) return;
+ var klass = window[className] = {};
+ klass.prototype = document.createElement(tag ? tag.toLowerCase() : 'div').__proto__;
+ });
+
+Element.addMethods = function(methods) {
+ Object.extend(Element.Methods, methods || {});
+
+ function copy(methods, destination, onlyIfAbsent) {
+ onlyIfAbsent = onlyIfAbsent || false;
+ var cache = Element.extend.cache;
+ for (var property in methods) {
+ var value = methods[property];
+ if (!onlyIfAbsent || !(property in destination))
+ destination[property] = cache.findOrStore(value);
+ }
+ }
+
+ if (typeof HTMLElement != 'undefined') {
+ copy(Element.Methods, HTMLElement.prototype);
+ copy(Element.Methods.Simulated, HTMLElement.prototype, true);
+ copy(Form.Methods, HTMLFormElement.prototype);
+ [HTMLInputElement, HTMLTextAreaElement, HTMLSelectElement].each(function(klass) {
+ copy(Form.Element.Methods, klass.prototype);
+ });
+ _nativeExtensions = true;
+ }
+}
+
+var Toggle = new Object();
+Toggle.display = Element.toggle;
+
+/*--------------------------------------------------------------------------*/
+
+Abstract.Insertion = function(adjacency) {
+ this.adjacency = adjacency;
+}
+
+Abstract.Insertion.prototype = {
+ initialize: function(element, content) {
+ this.element = $(element);
+ this.content = content.stripScripts();
+
+ if (this.adjacency && this.element.insertAdjacentHTML) {
+ try {
+ this.element.insertAdjacentHTML(this.adjacency, this.content);
+ } catch (e) {
+ var tagName = this.element.tagName.toUpperCase();
+ if (['TBODY', 'TR'].include(tagName)) {
+ this.insertContent(this.contentFromAnonymousTable()._reverse());
+ } else {
+ throw e;
+ }
+ }
+ } else {
+ this.range = this.element.ownerDocument.createRange();
+ if (this.initializeRange) this.initializeRange();
+ this.insertContent([this.range.createContextualFragment(this.content)]);
+ }
+
+ setTimeout(function() {content.evalScripts()}, 10);
+ },
+
+ contentFromAnonymousTable: function() {
+ var div = document.createElement('div');
+ div.innerHTML = '';
+ return $A(div.childNodes[0].childNodes[0].childNodes);
+ }
+}
+
+var Insertion = new Object();
+
+Insertion.Before = Class.create();
+Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), {
+ initializeRange: function() {
+ this.range.setStartBefore(this.element);
+ },
+
+ insertContent: function(fragments) {
+ fragments.each((function(fragment) {
+ this.element.parentNode.insertBefore(fragment, this.element);
+ }).bind(this));
+ }
+});
+
+Insertion.Top = Class.create();
+Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), {
+ initializeRange: function() {
+ this.range.selectNodeContents(this.element);
+ this.range.collapse(true);
+ },
+
+ insertContent: function(fragments) {
+ fragments.reverse(false).each((function(fragment) {
+ this.element.insertBefore(fragment, this.element.firstChild);
+ }).bind(this));
+ }
+});
+
+Insertion.Bottom = Class.create();
+Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), {
+ initializeRange: function() {
+ this.range.selectNodeContents(this.element);
+ this.range.collapse(this.element);
+ },
+
+ insertContent: function(fragments) {
+ fragments.each((function(fragment) {
+ this.element.appendChild(fragment);
+ }).bind(this));
+ }
+});
+
+Insertion.After = Class.create();
+Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), {
+ initializeRange: function() {
+ this.range.setStartAfter(this.element);
+ },
+
+ insertContent: function(fragments) {
+ fragments.each((function(fragment) {
+ this.element.parentNode.insertBefore(fragment,
+ this.element.nextSibling);
+ }).bind(this));
+ }
+});
+
+/*--------------------------------------------------------------------------*/
+
+Element.ClassNames = Class.create();
+Element.ClassNames.prototype = {
+ initialize: function(element) {
+ this.element = $(element);
+ },
+
+ _each: function(iterator) {
+ this.element.className.split(/\s+/).select(function(name) {
+ return name.length > 0;
+ })._each(iterator);
+ },
+
+ set: function(className) {
+ this.element.className = className;
+ },
+
+ add: function(classNameToAdd) {
+ if (this.include(classNameToAdd)) return;
+ this.set($A(this).concat(classNameToAdd).join(' '));
+ },
+
+ remove: function(classNameToRemove) {
+ if (!this.include(classNameToRemove)) return;
+ this.set($A(this).without(classNameToRemove).join(' '));
+ },
+
+ toString: function() {
+ return $A(this).join(' ');
+ }
+};
+
+Object.extend(Element.ClassNames.prototype, Enumerable);
+var Selector = Class.create();
+Selector.prototype = {
+ initialize: function(expression) {
+ this.params = {classNames: []};
+ this.expression = expression.toString().strip();
+ this.parseExpression();
+ this.compileMatcher();
+ },
+
+ parseExpression: function() {
+ function abort(message) { throw 'Parse error in selector: ' + message; }
+
+ if (this.expression == '') abort('empty expression');
+
+ var params = this.params, expr = this.expression, match, modifier, clause, rest;
+ while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) {
+ params.attributes = params.attributes || [];
+ params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''});
+ expr = match[1];
+ }
+
+ if (expr == '*') return this.params.wildcard = true;
+
+ while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) {
+ modifier = match[1], clause = match[2], rest = match[3];
+ switch (modifier) {
+ case '#': params.id = clause; break;
+ case '.': params.classNames.push(clause); break;
+ case '':
+ case undefined: params.tagName = clause.toUpperCase(); break;
+ default: abort(expr.inspect());
+ }
+ expr = rest;
+ }
+
+ if (expr.length > 0) abort(expr.inspect());
+ },
+
+ buildMatchExpression: function() {
+ var params = this.params, conditions = [], clause;
+
+ if (params.wildcard)
+ conditions.push('true');
+ if (clause = params.id)
+ conditions.push('element.readAttribute("id") == ' + clause.inspect());
+ if (clause = params.tagName)
+ conditions.push('element.tagName.toUpperCase() == ' + clause.inspect());
+ if ((clause = params.classNames).length > 0)
+ for (var i = 0, length = clause.length; i < length; i++)
+ conditions.push('element.hasClassName(' + clause[i].inspect() + ')');
+ if (clause = params.attributes) {
+ clause.each(function(attribute) {
+ var value = 'element.readAttribute(' + attribute.name.inspect() + ')';
+ var splitValueBy = function(delimiter) {
+ return value + ' && ' + value + '.split(' + delimiter.inspect() + ')';
+ }
+
+ switch (attribute.operator) {
+ case '=': conditions.push(value + ' == ' + attribute.value.inspect()); break;
+ case '~=': conditions.push(splitValueBy(' ') + '.include(' + attribute.value.inspect() + ')'); break;
+ case '|=': conditions.push(
+ splitValueBy('-') + '.first().toUpperCase() == ' + attribute.value.toUpperCase().inspect()
+ ); break;
+ case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break;
+ case '':
+ case undefined: conditions.push('element.hasAttribute(' + attribute.name.inspect() + ')'); break;
+ default: throw 'Unknown operator ' + attribute.operator + ' in selector';
+ }
+ });
+ }
+
+ return conditions.join(' && ');
+ },
+
+ compileMatcher: function() {
+ this.match = new Function('element', 'if (!element.tagName) return false; \
+ element = $(element); \
+ return ' + this.buildMatchExpression());
+ },
+
+ findElements: function(scope) {
+ var element;
+
+ if (element = $(this.params.id))
+ if (this.match(element))
+ if (!scope || Element.childOf(element, scope))
+ return [element];
+
+ scope = (scope || document).getElementsByTagName(this.params.tagName || '*');
+
+ var results = [];
+ for (var i = 0, length = scope.length; i < length; i++)
+ if (this.match(element = scope[i]))
+ results.push(Element.extend(element));
+
+ return results;
+ },
+
+ toString: function() {
+ return this.expression;
+ }
+}
+
+Object.extend(Selector, {
+ matchElements: function(elements, expression) {
+ var selector = new Selector(expression);
+ return elements.select(selector.match.bind(selector)).map(Element.extend);
+ },
+
+ findElement: function(elements, expression, index) {
+ if (typeof expression == 'number') index = expression, expression = false;
+ return Selector.matchElements(elements, expression || '*')[index || 0];
+ },
+
+ findChildElements: function(element, expressions) {
+ return expressions.map(function(expression) {
+ return expression.match(/[^\s"]+(?:"[^"]*"[^\s"]+)*/g).inject([null], function(results, expr) {
+ var selector = new Selector(expr);
+ return results.inject([], function(elements, result) {
+ return elements.concat(selector.findElements(result || element));
+ });
+ });
+ }).flatten();
+ }
+});
+
+function $$() {
+ return Selector.findChildElements(document, $A(arguments));
+}
+var Form = {
+ reset: function(form) {
+ $(form).reset();
+ return form;
+ },
+
+ serializeElements: function(elements, getHash) {
+ var data = elements.inject({}, function(result, element) {
+ if (!element.disabled && element.name) {
+ var key = element.name, value = $(element).getValue();
+ if (value != undefined) {
+ if (result[key]) {
+ if (result[key].constructor != Array) result[key] = [result[key]];
+ result[key].push(value);
+ }
+ else result[key] = value;
+ }
+ }
+ return result;
+ });
+
+ return getHash ? data : Hash.toQueryString(data);
+ }
+};
+
+Form.Methods = {
+ serialize: function(form, getHash) {
+ return Form.serializeElements(Form.getElements(form), getHash);
+ },
+
+ getElements: function(form) {
+ return $A($(form).getElementsByTagName('*')).inject([],
+ function(elements, child) {
+ if (Form.Element.Serializers[child.tagName.toLowerCase()])
+ elements.push(Element.extend(child));
+ return elements;
+ }
+ );
+ },
+
+ getInputs: function(form, typeName, name) {
+ form = $(form);
+ var inputs = form.getElementsByTagName('input');
+
+ if (!typeName && !name) return $A(inputs).map(Element.extend);
+
+ for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {
+ var input = inputs[i];
+ if ((typeName && input.type != typeName) || (name && input.name != name))
+ continue;
+ matchingInputs.push(Element.extend(input));
+ }
+
+ return matchingInputs;
+ },
+
+ disable: function(form) {
+ form = $(form);
+ form.getElements().each(function(element) {
+ element.blur();
+ element.disabled = 'true';
+ });
+ return form;
+ },
+
+ enable: function(form) {
+ form = $(form);
+ form.getElements().each(function(element) {
+ element.disabled = '';
+ });
+ return form;
+ },
+
+ findFirstElement: function(form) {
+ return $(form).getElements().find(function(element) {
+ return element.type != 'hidden' && !element.disabled &&
+ ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
+ });
+ },
+
+ focusFirstElement: function(form) {
+ form = $(form);
+ form.findFirstElement().activate();
+ return form;
+ }
+}
+
+Object.extend(Form, Form.Methods);
+
+/*--------------------------------------------------------------------------*/
+
+Form.Element = {
+ focus: function(element) {
+ $(element).focus();
+ return element;
+ },
+
+ select: function(element) {
+ $(element).select();
+ return element;
+ }
+}
+
+Form.Element.Methods = {
+ serialize: function(element) {
+ element = $(element);
+ if (!element.disabled && element.name) {
+ var value = element.getValue();
+ if (value != undefined) {
+ var pair = {};
+ pair[element.name] = value;
+ return Hash.toQueryString(pair);
+ }
+ }
+ return '';
+ },
+
+ getValue: function(element) {
+ element = $(element);
+ var method = element.tagName.toLowerCase();
+ return Form.Element.Serializers[method](element);
+ },
+
+ clear: function(element) {
+ $(element).value = '';
+ return element;
+ },
+
+ present: function(element) {
+ return $(element).value != '';
+ },
+
+ activate: function(element) {
+ element = $(element);
+ element.focus();
+ if (element.select && ( element.tagName.toLowerCase() != 'input' ||
+ !['button', 'reset', 'submit'].include(element.type) ) )
+ element.select();
+ return element;
+ },
+
+ disable: function(element) {
+ element = $(element);
+ element.disabled = true;
+ return element;
+ },
+
+ enable: function(element) {
+ element = $(element);
+ element.blur();
+ element.disabled = false;
+ return element;
+ }
+}
+
+Object.extend(Form.Element, Form.Element.Methods);
+var Field = Form.Element;
+var $F = Form.Element.getValue;
+
+/*--------------------------------------------------------------------------*/
+
+Form.Element.Serializers = {
+ input: function(element) {
+ switch (element.type.toLowerCase()) {
+ case 'checkbox':
+ case 'radio':
+ return Form.Element.Serializers.inputSelector(element);
+ default:
+ return Form.Element.Serializers.textarea(element);
+ }
+ },
+
+ inputSelector: function(element) {
+ return element.checked ? element.value : null;
+ },
+
+ textarea: function(element) {
+ return element.value;
+ },
+
+ select: function(element) {
+ return this[element.type == 'select-one' ?
+ 'selectOne' : 'selectMany'](element);
+ },
+
+ selectOne: function(element) {
+ var index = element.selectedIndex;
+ return index >= 0 ? this.optionValue(element.options[index]) : null;
+ },
+
+ selectMany: function(element) {
+ var values, length = element.length;
+ if (!length) return null;
+
+ for (var i = 0, values = []; i < length; i++) {
+ var opt = element.options[i];
+ if (opt.selected) values.push(this.optionValue(opt));
+ }
+ return values;
+ },
+
+ optionValue: function(opt) {
+ // extend element because hasAttribute may not be native
+ return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text;
+ }
+}
+
+/*--------------------------------------------------------------------------*/
+
+Abstract.TimedObserver = function() {}
+Abstract.TimedObserver.prototype = {
+ initialize: function(element, frequency, callback) {
+ this.frequency = frequency;
+ this.element = $(element);
+ this.callback = callback;
+
+ this.lastValue = this.getValue();
+ this.registerCallback();
+ },
+
+ registerCallback: function() {
+ setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
+ },
+
+ onTimerEvent: function() {
+ var value = this.getValue();
+ var changed = ('string' == typeof this.lastValue && 'string' == typeof value
+ ? this.lastValue != value : String(this.lastValue) != String(value));
+ if (changed) {
+ this.callback(this.element, value);
+ this.lastValue = value;
+ }
+ }
+}
+
+Form.Element.Observer = Class.create();
+Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
+ getValue: function() {
+ return Form.Element.getValue(this.element);
+ }
+});
+
+Form.Observer = Class.create();
+Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
+ getValue: function() {
+ return Form.serialize(this.element);
+ }
+});
+
+/*--------------------------------------------------------------------------*/
+
+Abstract.EventObserver = function() {}
+Abstract.EventObserver.prototype = {
+ initialize: function(element, callback) {
+ this.element = $(element);
+ this.callback = callback;
+
+ this.lastValue = this.getValue();
+ if (this.element.tagName.toLowerCase() == 'form')
+ this.registerFormCallbacks();
+ else
+ this.registerCallback(this.element);
+ },
+
+ onElementEvent: function() {
+ var value = this.getValue();
+ if (this.lastValue != value) {
+ this.callback(this.element, value);
+ this.lastValue = value;
+ }
+ },
+
+ registerFormCallbacks: function() {
+ Form.getElements(this.element).each(this.registerCallback.bind(this));
+ },
+
+ registerCallback: function(element) {
+ if (element.type) {
+ switch (element.type.toLowerCase()) {
+ case 'checkbox':
+ case 'radio':
+ Event.observe(element, 'click', this.onElementEvent.bind(this));
+ break;
+ default:
+ Event.observe(element, 'change', this.onElementEvent.bind(this));
+ break;
+ }
+ }
+ }
+}
+
+Form.Element.EventObserver = Class.create();
+Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
+ getValue: function() {
+ return Form.Element.getValue(this.element);
+ }
+});
+
+Form.EventObserver = Class.create();
+Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
+ getValue: function() {
+ return Form.serialize(this.element);
+ }
+});
+if (!window.Event) {
+ var Event = new Object();
+}
+
+Object.extend(Event, {
+ KEY_BACKSPACE: 8,
+ KEY_TAB: 9,
+ KEY_RETURN: 13,
+ KEY_ESC: 27,
+ KEY_LEFT: 37,
+ KEY_UP: 38,
+ KEY_RIGHT: 39,
+ KEY_DOWN: 40,
+ KEY_DELETE: 46,
+ KEY_HOME: 36,
+ KEY_END: 35,
+ KEY_PAGEUP: 33,
+ KEY_PAGEDOWN: 34,
+
+ element: function(event) {
+ return event.target || event.srcElement;
+ },
+
+ isLeftClick: function(event) {
+ return (((event.which) && (event.which == 1)) ||
+ ((event.button) && (event.button == 1)));
+ },
+
+ pointerX: function(event) {
+ return event.pageX || (event.clientX +
+ (document.documentElement.scrollLeft || document.body.scrollLeft));
+ },
+
+ pointerY: function(event) {
+ return event.pageY || (event.clientY +
+ (document.documentElement.scrollTop || document.body.scrollTop));
+ },
+
+ stop: function(event) {
+ if (event.preventDefault) {
+ event.preventDefault();
+ event.stopPropagation();
+ } else {
+ event.returnValue = false;
+ event.cancelBubble = true;
+ }
+ },
+
+ // find the first node with the given tagName, starting from the
+ // node the event was triggered on; traverses the DOM upwards
+ findElement: function(event, tagName) {
+ var element = Event.element(event);
+ while (element.parentNode && (!element.tagName ||
+ (element.tagName.toUpperCase() != tagName.toUpperCase())))
+ element = element.parentNode;
+ return element;
+ },
+
+ observers: false,
+
+ _observeAndCache: function(element, name, observer, useCapture) {
+ if (!this.observers) this.observers = [];
+ if (element.addEventListener) {
+ this.observers.push([element, name, observer, useCapture]);
+ element.addEventListener(name, observer, useCapture);
+ } else if (element.attachEvent) {
+ this.observers.push([element, name, observer, useCapture]);
+ element.attachEvent('on' + name, observer);
+ }
+ },
+
+ unloadCache: function() {
+ if (!Event.observers) return;
+ for (var i = 0, length = Event.observers.length; i < length; i++) {
+ Event.stopObserving.apply(this, Event.observers[i]);
+ Event.observers[i][0] = null;
+ }
+ Event.observers = false;
+ },
+
+ observe: function(element, name, observer, useCapture) {
+ element = $(element);
+ useCapture = useCapture || false;
+
+ if (name == 'keypress' &&
+ (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
+ || element.attachEvent))
+ name = 'keydown';
+
+ Event._observeAndCache(element, name, observer, useCapture);
+ },
+
+ stopObserving: function(element, name, observer, useCapture) {
+ element = $(element);
+ useCapture = useCapture || false;
+
+ if (name == 'keypress' &&
+ (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
+ || element.detachEvent))
+ name = 'keydown';
+
+ if (element.removeEventListener) {
+ element.removeEventListener(name, observer, useCapture);
+ } else if (element.detachEvent) {
+ try {
+ element.detachEvent('on' + name, observer);
+ } catch (e) {}
+ }
+ }
+});
+
+/* prevent memory leaks in IE */
+if (navigator.appVersion.match(/\bMSIE\b/))
+ Event.observe(window, 'unload', Event.unloadCache, false);
+var Position = {
+ // set to true if needed, warning: firefox performance problems
+ // NOT neeeded for page scrolling, only if draggable contained in
+ // scrollable elements
+ includeScrollOffsets: false,
+
+ // must be called before calling withinIncludingScrolloffset, every time the
+ // page is scrolled
+ prepare: function() {
+ this.deltaX = window.pageXOffset
+ || document.documentElement.scrollLeft
+ || document.body.scrollLeft
+ || 0;
+ this.deltaY = window.pageYOffset
+ || document.documentElement.scrollTop
+ || document.body.scrollTop
+ || 0;
+ },
+
+ realOffset: function(element) {
+ var valueT = 0, valueL = 0;
+ do {
+ valueT += element.scrollTop || 0;
+ valueL += element.scrollLeft || 0;
+ element = element.parentNode;
+ } while (element);
+ return [valueL, valueT];
+ },
+
+ cumulativeOffset: function(element) {
+ var valueT = 0, valueL = 0;
+ do {
+ valueT += element.offsetTop || 0;
+ valueL += element.offsetLeft || 0;
+ element = element.offsetParent;
+ } while (element);
+ return [valueL, valueT];
+ },
+
+ positionedOffset: function(element) {
+ var valueT = 0, valueL = 0;
+ do {
+ valueT += element.offsetTop || 0;
+ valueL += element.offsetLeft || 0;
+ element = element.offsetParent;
+ if (element) {
+ if(element.tagName=='BODY') break;
+ var p = Element.getStyle(element, 'position');
+ if (p == 'relative' || p == 'absolute') break;
+ }
+ } while (element);
+ return [valueL, valueT];
+ },
+
+ offsetParent: function(element) {
+ if (element.offsetParent) return element.offsetParent;
+ if (element == document.body) return element;
+
+ while ((element = element.parentNode) && element != document.body)
+ if (Element.getStyle(element, 'position') != 'static')
+ return element;
+
+ return document.body;
+ },
+
+ // caches x/y coordinate pair to use with overlap
+ within: function(element, x, y) {
+ if (this.includeScrollOffsets)
+ return this.withinIncludingScrolloffsets(element, x, y);
+ this.xcomp = x;
+ this.ycomp = y;
+ this.offset = this.cumulativeOffset(element);
+
+ return (y >= this.offset[1] &&
+ y < this.offset[1] + element.offsetHeight &&
+ x >= this.offset[0] &&
+ x < this.offset[0] + element.offsetWidth);
+ },
+
+ withinIncludingScrolloffsets: function(element, x, y) {
+ var offsetcache = this.realOffset(element);
+
+ this.xcomp = x + offsetcache[0] - this.deltaX;
+ this.ycomp = y + offsetcache[1] - this.deltaY;
+ this.offset = this.cumulativeOffset(element);
+
+ return (this.ycomp >= this.offset[1] &&
+ this.ycomp < this.offset[1] + element.offsetHeight &&
+ this.xcomp >= this.offset[0] &&
+ this.xcomp < this.offset[0] + element.offsetWidth);
+ },
+
+ // within must be called directly before
+ overlap: function(mode, element) {
+ if (!mode) return 0;
+ if (mode == 'vertical')
+ return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
+ element.offsetHeight;
+ if (mode == 'horizontal')
+ return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
+ element.offsetWidth;
+ },
+
+ page: function(forElement) {
+ var valueT = 0, valueL = 0;
+
+ var element = forElement;
+ do {
+ valueT += element.offsetTop || 0;
+ valueL += element.offsetLeft || 0;
+
+ // Safari fix
+ if (element.offsetParent==document.body)
+ if (Element.getStyle(element,'position')=='absolute') break;
+
+ } while (element = element.offsetParent);
+
+ element = forElement;
+ do {
+ if (!window.opera || element.tagName=='BODY') {
+ valueT -= element.scrollTop || 0;
+ valueL -= element.scrollLeft || 0;
+ }
+ } while (element = element.parentNode);
+
+ return [valueL, valueT];
+ },
+
+ clone: function(source, target) {
+ var options = Object.extend({
+ setLeft: true,
+ setTop: true,
+ setWidth: true,
+ setHeight: true,
+ offsetTop: 0,
+ offsetLeft: 0
+ }, arguments[2] || {})
+
+ // find page position of source
+ source = $(source);
+ var p = Position.page(source);
+
+ // find coordinate system to use
+ target = $(target);
+ var delta = [0, 0];
+ var parent = null;
+ // delta [0,0] will do fine with position: fixed elements,
+ // position:absolute needs offsetParent deltas
+ if (Element.getStyle(target,'position') == 'absolute') {
+ parent = Position.offsetParent(target);
+ delta = Position.page(parent);
+ }
+
+ // correct by body offsets (fixes Safari)
+ if (parent == document.body) {
+ delta[0] -= document.body.offsetLeft;
+ delta[1] -= document.body.offsetTop;
+ }
+
+ // set position
+ if(options.setLeft) target.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px';
+ if(options.setTop) target.style.top = (p[1] - delta[1] + options.offsetTop) + 'px';
+ if(options.setWidth) target.style.width = source.offsetWidth + 'px';
+ if(options.setHeight) target.style.height = source.offsetHeight + 'px';
+ },
+
+ absolutize: function(element) {
+ element = $(element);
+ if (element.style.position == 'absolute') return;
+ Position.prepare();
+
+ var offsets = Position.positionedOffset(element);
+ var top = offsets[1];
+ var left = offsets[0];
+ var width = element.clientWidth;
+ var height = element.clientHeight;
+
+ element._originalLeft = left - parseFloat(element.style.left || 0);
+ element._originalTop = top - parseFloat(element.style.top || 0);
+ element._originalWidth = element.style.width;
+ element._originalHeight = element.style.height;
+
+ element.style.position = 'absolute';
+ element.style.top = top + 'px';
+ element.style.left = left + 'px';
+ element.style.width = width + 'px';
+ element.style.height = height + 'px';
+ },
+
+ relativize: function(element) {
+ element = $(element);
+ if (element.style.position == 'relative') return;
+ Position.prepare();
+
+ element.style.position = 'relative';
+ var top = parseFloat(element.style.top || 0) - (element._originalTop || 0);
+ var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
+
+ element.style.top = top + 'px';
+ element.style.left = left + 'px';
+ element.style.height = element._originalHeight;
+ element.style.width = element._originalWidth;
+ }
+}
+
+// Safari returns margins on body which is incorrect if the child is absolutely
+// positioned. For performance reasons, redefine Position.cumulativeOffset for
+// KHTML/WebKit only.
+if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
+ Position.cumulativeOffset = function(element) {
+ var valueT = 0, valueL = 0;
+ do {
+ valueT += element.offsetTop || 0;
+ valueL += element.offsetLeft || 0;
+ if (element.offsetParent == document.body)
+ if (Element.getStyle(element, 'position') == 'absolute') break;
+
+ element = element.offsetParent;
+ } while (element);
+
+ return [valueL, valueT];
+ }
+}
+
+Element.addMethods();
\ No newline at end of file
diff --git a/rest_sys/public/javascripts/select_list_move.js b/rest_sys/public/javascripts/select_list_move.js
new file mode 100644
index 000000000..1ced88232
--- /dev/null
+++ b/rest_sys/public/javascripts/select_list_move.js
@@ -0,0 +1,55 @@
+var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
+
+function addOption(theSel, theText, theValue)
+{
+ var newOpt = new Option(theText, theValue);
+ var selLength = theSel.length;
+ theSel.options[selLength] = newOpt;
+}
+
+function deleteOption(theSel, theIndex)
+{
+ var selLength = theSel.length;
+ if(selLength>0)
+ {
+ theSel.options[theIndex] = null;
+ }
+}
+
+function moveOptions(theSelFrom, theSelTo)
+{
+
+ var selLength = theSelFrom.length;
+ var selectedText = new Array();
+ var selectedValues = new Array();
+ var selectedCount = 0;
+
+ var i;
+
+ for(i=selLength-1; i>=0; i--)
+ {
+ if(theSelFrom.options[i].selected)
+ {
+ selectedText[selectedCount] = theSelFrom.options[i].text;
+ selectedValues[selectedCount] = theSelFrom.options[i].value;
+ deleteOption(theSelFrom, i);
+ selectedCount++;
+ }
+ }
+
+ for(i=selectedCount-1; i>=0; i--)
+ {
+ addOption(theSelTo, selectedText[i], selectedValues[i]);
+ }
+
+ if(NS4) history.go(0);
+}
+
+function selectAllOptions(id)
+{
+ var select = $(id);
+ for (var i=0; ibody #content {
+height: auto;
+min-height: 600px;
+}
+
+#main.nosidebar #sidebar{ display: none; }
+#main.nosidebar #content{ width: auto; border-right: 0; }
+
+#footer {clear: both; border-top: 1px solid #bbb; font-size: 0.9em; color: #aaa; padding: 5px; text-align:center; background:#fff;}
+
+#login-form table {margin-top:5em; padding:1em; margin-left: auto; margin-right: auto; border: 2px solid #FDBF3B; background-color:#FFEBC1; }
+#login-form table td {padding: 6px;}
+#login-form label {font-weight: bold;}
+
+.clear:after{ content: "."; display: block; height: 0; clear: both; visibility: hidden; }
+
+/***** Links *****/
+a, a:link, a:visited{ color: #2A5685; text-decoration: none; }
+a:hover, a:active{ color: #c61a1a; text-decoration: underline;}
+a img{ border: 0; }
+
+/***** Tables *****/
+table.list { border: 1px solid #e4e4e4; border-collapse: collapse; width: 100%; margin-bottom: 4px; }
+table.list th { background-color:#EEEEEE; padding: 4px; white-space:nowrap; }
+table.list td { overflow: hidden; text-overflow: ellipsis; vertical-align: top;}
+table.list td.id { width: 2%; text-align: center;}
+table.list td.checkbox { width: 15px; padding: 0px;}
+
+tr.issue { text-align: center; white-space: nowrap; }
+tr.issue td.subject, tr.issue td.category { white-space: normal; }
+tr.issue td.subject { text-align: left; }
+tr.issue td.done_ratio table.progress { margin-left:auto; margin-right: auto;}
+
+tr.message { height: 2.6em; }
+tr.message td.last_message { font-size: 80%; }
+tr.message.locked td.subject a { background-image: url(../images/locked.png); }
+tr.message.sticky td.subject a { background-image: url(../images/sticky.png); font-weight: bold; }
+
+table.list tbody tr:hover { background-color:#ffffdd; }
+table td {padding:2px;}
+table p {margin:0;}
+.odd {background-color:#f6f7f8;}
+.even {background-color: #fff;}
+
+.highlight { background-color: #FCFD8D;}
+.highlight.token-1 { background-color: #faa;}
+.highlight.token-2 { background-color: #afa;}
+.highlight.token-3 { background-color: #aaf;}
+
+.box{
+padding:6px;
+margin-bottom: 10px;
+background-color:#f6f6f6;
+color:#505050;
+line-height:1.5em;
+border: 1px solid #e4e4e4;
+}
+
+div.square {
+ border: 1px solid #999;
+ float: left;
+ margin: .3em .4em 0 .4em;
+ overflow: hidden;
+ width: .6em; height: .6em;
+}
+
+.contextual {float:right; white-space: nowrap; line-height:1.4em;margin-top:5px;font-size:0.9em;}
+.contextual input {font-size:0.9em;}
+
+.splitcontentleft{float:left; width:49%;}
+.splitcontentright{float:right; width:49%;}
+form {display: inline;}
+input, select {vertical-align: middle; margin-top: 1px; margin-bottom: 1px;}
+fieldset {border: 1px solid #e4e4e4; margin:0;}
+legend {color: #484848;}
+hr { width: 100%; height: 1px; background: #ccc; border: 0;}
+textarea.wiki-edit { width: 99%; }
+li p {margin-top: 0;}
+div.issue {background:#ffffdd; padding:6px; margin-bottom:6px;border: 1px solid #d7d7d7;}
+.autoscroll {overflow-x: auto; padding:1px; width:100%;}
+#user_firstname, #user_lastname, #user_mail, #my_account_form select { width: 90%; }
+
+/***** Tabular forms ******/
+.tabular p{
+margin: 0;
+padding: 5px 0 8px 0;
+padding-left: 180px; /*width of left column containing the label elements*/
+height: 1%;
+clear:left;
+}
+
+.tabular label{
+font-weight: bold;
+float: left;
+text-align: right;
+margin-left: -180px; /*width of left column*/
+width: 175px; /*width of labels. Should be smaller than left column to create some right
+margin*/
+}
+
+.tabular label.floating{
+font-weight: normal;
+margin-left: 0px;
+text-align: left;
+width: 200px;
+}
+
+#preview fieldset {margin-top: 1em; background: url(../images/draft.png)}
+
+.tabular.settings p{ padding-left: 300px; }
+.tabular.settings label{ margin-left: -300px; width: 295px; }
+
+.required {color: #bb0000;}
+.summary {font-style: italic;}
+
+div.attachments p { margin:4px 0 2px 0; }
+
+/***** Flash & error messages ****/
+#errorExplanation, div.flash, .nodata {
+ padding: 4px 4px 4px 30px;
+ margin-bottom: 12px;
+ font-size: 1.1em;
+ border: 2px solid;
+}
+
+div.flash {margin-top: 8px;}
+
+div.flash.error, #errorExplanation {
+ background: url(../images/false.png) 8px 5px no-repeat;
+ background-color: #ffe3e3;
+ border-color: #dd0000;
+ color: #550000;
+}
+
+div.flash.notice {
+ background: url(../images/true.png) 8px 5px no-repeat;
+ background-color: #dfffdf;
+ border-color: #9fcf9f;
+ color: #005f00;
+}
+
+.nodata {
+ text-align: center;
+ background-color: #FFEBC1;
+ border-color: #FDBF3B;
+ color: #A6750C;
+}
+
+#errorExplanation ul { font-size: 0.9em;}
+
+/***** Ajax indicator ******/
+#ajax-indicator {
+position: absolute; /* fixed not supported by IE */
+background-color:#eee;
+border: 1px solid #bbb;
+top:35%;
+left:40%;
+width:20%;
+font-weight:bold;
+text-align:center;
+padding:0.6em;
+z-index:100;
+filter:alpha(opacity=50);
+-moz-opacity:0.5;
+opacity: 0.5;
+-khtml-opacity: 0.5;
+}
+
+html>body #ajax-indicator { position: fixed; }
+
+#ajax-indicator span {
+background-position: 0% 40%;
+background-repeat: no-repeat;
+background-image: url(../images/loading.gif);
+padding-left: 26px;
+vertical-align: bottom;
+}
+
+/***** Calendar *****/
+table.cal {border-collapse: collapse; width: 100%; margin: 8px 0 6px 0;border: 1px solid #d7d7d7;}
+table.cal thead th {width: 14%;}
+table.cal tbody tr {height: 100px;}
+table.cal th { background-color:#EEEEEE; padding: 4px; }
+table.cal td {border: 1px solid #d7d7d7; vertical-align: top; font-size: 0.9em;}
+table.cal td p.day-num {font-size: 1.1em; text-align:right;}
+table.cal td.odd p.day-num {color: #bbb;}
+table.cal td.today {background:#ffffdd;}
+table.cal td.today p.day-num {font-weight: bold;}
+
+/***** Tooltips ******/
+.tooltip{position:relative;z-index:24;}
+.tooltip:hover{z-index:25;color:#000;}
+.tooltip span.tip{display: none; text-align:left;}
+
+div.tooltip:hover span.tip{
+display:block;
+position:absolute;
+top:12px; left:24px; width:270px;
+border:1px solid #555;
+background-color:#fff;
+padding: 4px;
+font-size: 0.8em;
+color:#505050;
+}
+
+/***** Progress bar *****/
+table.progress {
+ border: 1px solid #D7D7D7;
+ border-collapse: collapse;
+ border-spacing: 0pt;
+ empty-cells: show;
+ text-align: center;
+ float:left;
+ margin: 1px 6px 1px 0px;
+}
+
+table.progress td { height: 0.9em; }
+table.progress td.closed { background: #BAE0BA none repeat scroll 0%; }
+table.progress td.done { background: #DEF0DE none repeat scroll 0%; }
+table.progress td.open { background: #FFF none repeat scroll 0%; }
+p.pourcent {font-size: 80%;}
+p.progress-info {clear: left; font-style: italic; font-size: 80%;}
+
+div#status_by { float:right; width:380px; margin-left: 16px; margin-bottom: 16px; }
+
+/***** Tabs *****/
+#content .tabs{height: 2.6em;}
+#content .tabs ul{margin:0;}
+#content .tabs ul li{
+float:left;
+list-style-type:none;
+white-space:nowrap;
+margin-right:8px;
+background:#fff;
+}
+#content .tabs ul li a{
+display:block;
+font-size: 0.9em;
+text-decoration:none;
+line-height:1em;
+padding:4px;
+border: 1px solid #c0c0c0;
+}
+
+#content .tabs ul li a.selected, #content .tabs ul li a:hover{
+background-color: #507AAA;
+border: 1px solid #507AAA;
+color: #fff;
+text-decoration:none;
+}
+
+/***** Diff *****/
+.diff_out { background: #fcc; }
+.diff_in { background: #cfc; }
+
+/***** Wiki *****/
+div.wiki table {
+ border: 1px solid #505050;
+ border-collapse: collapse;
+}
+
+div.wiki table, div.wiki td, div.wiki th {
+ border: 1px solid #bbb;
+ padding: 4px;
+}
+
+div.wiki .external {
+ background-position: 0% 60%;
+ background-repeat: no-repeat;
+ padding-left: 12px;
+ background-image: url(../images/external.png);
+}
+
+div.wiki a.new {
+ color: #b73535;
+}
+
+div.wiki pre {
+ margin: 1em 1em 1em 1.6em;
+ padding: 2px;
+ background-color: #fafafa;
+ border: 1px solid #dadada;
+ width:95%;
+ overflow-x: auto;
+}
+
+div.wiki div.toc {
+ background-color: #ffffdd;
+ border: 1px solid #e4e4e4;
+ padding: 4px;
+ line-height: 1.2em;
+ margin-bottom: 12px;
+ margin-right: 12px;
+ display: table
+}
+* html div.wiki div.toc { width: 50%; } /* IE6 doesn't autosize div */
+
+div.wiki div.toc.right { float: right; margin-left: 12px; margin-right: 0; width: auto; }
+div.wiki div.toc.left { float: left; margin-right: 12px; margin-left: 0; width: auto; }
+
+div.wiki div.toc a {
+ display: block;
+ font-size: 0.9em;
+ font-weight: normal;
+ text-decoration: none;
+ color: #606060;
+}
+div.wiki div.toc a:hover { color: #c61a1a; text-decoration: underline;}
+
+div.wiki div.toc a.heading2 { margin-left: 6px; }
+div.wiki div.toc a.heading3 { margin-left: 12px; font-size: 0.8em; }
+
+/***** My page layout *****/
+.block-receiver {
+border:1px dashed #c0c0c0;
+margin-bottom: 20px;
+padding: 15px 0 15px 0;
+}
+
+.mypage-box {
+margin:0 0 20px 0;
+color:#505050;
+line-height:1.5em;
+}
+
+.handle {
+cursor: move;
+}
+
+a.close-icon {
+display:block;
+margin-top:3px;
+overflow:hidden;
+width:12px;
+height:12px;
+background-repeat: no-repeat;
+cursor:pointer;
+background-image:url('../images/close.png');
+}
+
+a.close-icon:hover {
+background-image:url('../images/close_hl.png');
+}
+
+/***** Gantt chart *****/
+.gantt_hdr {
+ position:absolute;
+ top:0;
+ height:16px;
+ border-top: 1px solid #c0c0c0;
+ border-bottom: 1px solid #c0c0c0;
+ border-right: 1px solid #c0c0c0;
+ text-align: center;
+ overflow: hidden;
+}
+
+.task {
+ position: absolute;
+ height:8px;
+ font-size:0.8em;
+ color:#888;
+ padding:0;
+ margin:0;
+ line-height:0.8em;
+}
+
+.task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; }
+.task_done { background:#66f url(../images/task_done.png); border: 1px solid #66f; }
+.task_todo { background:#aaa url(../images/task_todo.png); border: 1px solid #aaa; }
+.milestone { background-image:url(../images/milestone.png); background-repeat: no-repeat; border: 0; }
+
+/***** Icons *****/
+.icon {
+background-position: 0% 40%;
+background-repeat: no-repeat;
+padding-left: 20px;
+padding-top: 2px;
+padding-bottom: 3px;
+}
+
+.icon22 {
+background-position: 0% 40%;
+background-repeat: no-repeat;
+padding-left: 26px;
+line-height: 22px;
+vertical-align: middle;
+}
+
+.icon-add { background-image: url(../images/add.png); }
+.icon-edit { background-image: url(../images/edit.png); }
+.icon-copy { background-image: url(../images/copy.png); }
+.icon-del { background-image: url(../images/delete.png); }
+.icon-move { background-image: url(../images/move.png); }
+.icon-save { background-image: url(../images/save.png); }
+.icon-cancel { background-image: url(../images/cancel.png); }
+.icon-pdf { background-image: url(../images/pdf.png); }
+.icon-csv { background-image: url(../images/csv.png); }
+.icon-html { background-image: url(../images/html.png); }
+.icon-image { background-image: url(../images/image.png); }
+.icon-txt { background-image: url(../images/txt.png); }
+.icon-file { background-image: url(../images/file.png); }
+.icon-folder { background-image: url(../images/folder.png); }
+.open .icon-folder { background-image: url(../images/folder_open.png); }
+.icon-package { background-image: url(../images/package.png); }
+.icon-home { background-image: url(../images/home.png); }
+.icon-user { background-image: url(../images/user.png); }
+.icon-mypage { background-image: url(../images/user_page.png); }
+.icon-admin { background-image: url(../images/admin.png); }
+.icon-projects { background-image: url(../images/projects.png); }
+.icon-logout { background-image: url(../images/logout.png); }
+.icon-help { background-image: url(../images/help.png); }
+.icon-attachment { background-image: url(../images/attachment.png); }
+.icon-index { background-image: url(../images/index.png); }
+.icon-history { background-image: url(../images/history.png); }
+.icon-feed { background-image: url(../images/feed.png); }
+.icon-time { background-image: url(../images/time.png); }
+.icon-stats { background-image: url(../images/stats.png); }
+.icon-warning { background-image: url(../images/warning.png); }
+.icon-fav { background-image: url(../images/fav.png); }
+.icon-fav-off { background-image: url(../images/fav_off.png); }
+.icon-reload { background-image: url(../images/reload.png); }
+.icon-lock { background-image: url(../images/locked.png); }
+.icon-unlock { background-image: url(../images/unlock.png); }
+.icon-note { background-image: url(../images/note.png); }
+.icon-checked { background-image: url(../images/true.png); }
+
+.icon22-projects { background-image: url(../images/22x22/projects.png); }
+.icon22-users { background-image: url(../images/22x22/users.png); }
+.icon22-tracker { background-image: url(../images/22x22/tracker.png); }
+.icon22-role { background-image: url(../images/22x22/role.png); }
+.icon22-workflow { background-image: url(../images/22x22/workflow.png); }
+.icon22-options { background-image: url(../images/22x22/options.png); }
+.icon22-notifications { background-image: url(../images/22x22/notifications.png); }
+.icon22-authent { background-image: url(../images/22x22/authent.png); }
+.icon22-info { background-image: url(../images/22x22/info.png); }
+.icon22-comment { background-image: url(../images/22x22/comment.png); }
+.icon22-package { background-image: url(../images/22x22/package.png); }
+.icon22-settings { background-image: url(../images/22x22/settings.png); }
+.icon22-plugin { background-image: url(../images/22x22/plugin.png); }
+
+/***** Media print specific styles *****/
+@media print {
+ #top-menu, #header, #main-menu, #sidebar, #footer, .contextual { display:none; }
+ #main { background: #fff; }
+ #content { width: 99%; margin: 0; padding: 0; border: 0; background: #fff; }
+}
diff --git a/rest_sys/public/stylesheets/calendar.css b/rest_sys/public/stylesheets/calendar.css
new file mode 100644
index 000000000..842dbf71a
--- /dev/null
+++ b/rest_sys/public/stylesheets/calendar.css
@@ -0,0 +1,237 @@
+/* The main calendar widget. DIV containing a table. */
+
+img.calendar-trigger {
+ cursor: pointer;
+ vertical-align: middle;
+ margin-left: 4px;
+}
+
+div.calendar { position: relative; z-index: 15;}
+
+.calendar, .calendar table {
+ border: 1px solid #556;
+ font-size: 11px;
+ color: #000;
+ cursor: default;
+ background: #fafbfc;
+ font-family: tahoma,verdana,sans-serif;
+}
+
+/* Header part -- contains navigation buttons and day names. */
+
+.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */
+ text-align: center; /* They are the navigation buttons */
+ padding: 2px; /* Make the buttons seem like they're pressing */
+}
+
+.calendar .nav {
+ background: #467aa7;
+}
+
+.calendar thead .title { /* This holds the current "month, year" */
+ font-weight: bold; /* Pressing it will take you to the current date */
+ text-align: center;
+ background: #fff;
+ color: #000;
+ padding: 2px;
+}
+
+.calendar thead .headrow { /* Row containing navigation buttons */
+ background: #467aa7;
+ color: #fff;
+}
+
+.calendar thead .daynames { /* Row containing the day names */
+ background: #bdf;
+}
+
+.calendar thead .name { /* Cells containing the day names */
+ border-bottom: 1px solid #556;
+ padding: 2px;
+ text-align: center;
+ color: #000;
+}
+
+.calendar thead .weekend { /* How a weekend day name shows in header */
+ color: #a66;
+}
+
+.calendar thead .hilite { /* How do the buttons in header appear when hover */
+ background-color: #80b0da;
+ color: #000;
+ padding: 1px;
+}
+
+.calendar thead .active { /* Active (pressed) buttons in header */
+ background-color: #77c;
+ padding: 2px 0px 0px 2px;
+}
+
+/* The body part -- contains all the days in month. */
+
+.calendar tbody .day { /* Cells containing month days dates */
+ width: 2em;
+ color: #456;
+ text-align: right;
+ padding: 2px 4px 2px 2px;
+}
+.calendar tbody .day.othermonth {
+ font-size: 80%;
+ color: #bbb;
+}
+.calendar tbody .day.othermonth.oweekend {
+ color: #fbb;
+}
+
+.calendar table .wn {
+ padding: 2px 3px 2px 2px;
+ border-right: 1px solid #000;
+ background: #bdf;
+}
+
+.calendar tbody .rowhilite td {
+ background: #def;
+}
+
+.calendar tbody .rowhilite td.wn {
+ background: #80b0da;
+}
+
+.calendar tbody td.hilite { /* Hovered cells */
+ background: #80b0da;
+ padding: 1px 3px 1px 1px;
+ border: 1px solid #bbb;
+}
+
+.calendar tbody td.active { /* Active (pressed) cells */
+ background: #cde;
+ padding: 2px 2px 0px 2px;
+}
+
+.calendar tbody td.selected { /* Cell showing today date */
+ font-weight: bold;
+ border: 1px solid #000;
+ padding: 1px 3px 1px 1px;
+ background: #fff;
+ color: #000;
+}
+
+.calendar tbody td.weekend { /* Cells showing weekend days */
+ color: #a66;
+}
+
+.calendar tbody td.today { /* Cell showing selected date */
+ font-weight: bold;
+ color: #f00;
+}
+
+.calendar tbody .disabled { color: #999; }
+
+.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */
+ visibility: hidden;
+}
+
+.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */
+ display: none;
+}
+
+/* The footer part -- status bar and "Close" button */
+
+.calendar tfoot .footrow { /* The in footer (only one right now) */
+ text-align: center;
+ background: #556;
+ color: #fff;
+}
+
+.calendar tfoot .ttip { /* Tooltip (status bar) cell */
+ background: #fff;
+ color: #445;
+ border-top: 1px solid #556;
+ padding: 1px;
+}
+
+.calendar tfoot .hilite { /* Hover style for buttons in footer */
+ background: #aaf;
+ border: 1px solid #04f;
+ color: #000;
+ padding: 1px;
+}
+
+.calendar tfoot .active { /* Active (pressed) style for buttons in footer */
+ background: #77c;
+ padding: 2px 0px 0px 2px;
+}
+
+/* Combo boxes (menus that display months/years for direct selection) */
+
+.calendar .combo {
+ position: absolute;
+ display: none;
+ top: 0px;
+ left: 0px;
+ width: 4em;
+ cursor: default;
+ border: 1px solid #655;
+ background: #def;
+ color: #000;
+ font-size: 90%;
+ z-index: 100;
+}
+
+.calendar .combo .label,
+.calendar .combo .label-IEfix {
+ text-align: center;
+ padding: 1px;
+}
+
+.calendar .combo .label-IEfix {
+ width: 4em;
+}
+
+.calendar .combo .hilite {
+ background: #acf;
+}
+
+.calendar .combo .active {
+ border-top: 1px solid #46a;
+ border-bottom: 1px solid #46a;
+ background: #eef;
+ font-weight: bold;
+}
+
+.calendar td.time {
+ border-top: 1px solid #000;
+ padding: 1px 0px;
+ text-align: center;
+ background-color: #f4f0e8;
+}
+
+.calendar td.time .hour,
+.calendar td.time .minute,
+.calendar td.time .ampm {
+ padding: 0px 3px 0px 4px;
+ border: 1px solid #889;
+ font-weight: bold;
+ background-color: #fff;
+}
+
+.calendar td.time .ampm {
+ text-align: center;
+}
+
+.calendar td.time .colon {
+ padding: 0px 2px 0px 3px;
+ font-weight: bold;
+}
+
+.calendar td.time span.hilite {
+ border-color: #000;
+ background-color: #667;
+ color: #fff;
+}
+
+.calendar td.time span.active {
+ border-color: #f00;
+ background-color: #000;
+ color: #0f0;
+}
diff --git a/rest_sys/public/stylesheets/context_menu.css b/rest_sys/public/stylesheets/context_menu.css
new file mode 100644
index 000000000..69acf7b73
--- /dev/null
+++ b/rest_sys/public/stylesheets/context_menu.css
@@ -0,0 +1,52 @@
+#context-menu { position: absolute; z-index: 10;}
+
+#context-menu ul, #context-menu li, #context-menu a {
+ display:block;
+ margin:0;
+ padding:0;
+ border:0;
+}
+
+#context-menu ul {
+ width:150px;
+ border-top:1px solid #ddd;
+ border-left:1px solid #ddd;
+ border-bottom:1px solid #777;
+ border-right:1px solid #777;
+ background:white;
+ list-style:none;
+}
+
+#context-menu li {
+ position:relative;
+ padding:1px;
+ z-index:9;
+}
+#context-menu li.folder ul {
+ position:absolute;
+ left:128px; /* IE */
+ top:-2px;
+}
+#context-menu li.folder>ul { left:148px; }
+
+#context-menu a {
+ border:1px solid white;
+ text-decoration:none;
+ background-repeat: no-repeat;
+ background-position: 1px 50%;
+ padding: 2px 0px 2px 20px;
+ width:100%; /* IE */
+}
+#context-menu li>a { width:auto; } /* others */
+#context-menu a.disabled, #context-menu a.disabled:hover {color: #ccc;}
+#context-menu li a.submenu { background:url("../images/sub.gif") right no-repeat; }
+#context-menu a:hover { border-color:gray; background-color:#eee; color:#2A5685; }
+#context-menu li.folder a:hover { background-color:#eee; }
+#context-menu li.folder:hover { z-index:10; }
+#context-menu ul ul, #context-menu li:hover ul ul { display:none; }
+#context-menu li:hover ul, #context-menu li:hover li:hover ul { display:block; }
+
+/* selected element */
+.context-menu-selection { background-color:#507AAA !important; color:#f8f8f8 !important; }
+.context-menu-selection a, .context-menu-selection a:hover { color:#f8f8f8 !important; }
+.context-menu-selection:hover { background-color:#507AAA !important; color:#f8f8f8 !important; }
diff --git a/rest_sys/public/stylesheets/csshover.htc b/rest_sys/public/stylesheets/csshover.htc
new file mode 100644
index 000000000..3ba936ac3
--- /dev/null
+++ b/rest_sys/public/stylesheets/csshover.htc
@@ -0,0 +1,120 @@
+
+
\ No newline at end of file
diff --git a/rest_sys/public/stylesheets/jstoolbar.css b/rest_sys/public/stylesheets/jstoolbar.css
new file mode 100644
index 000000000..62976e537
--- /dev/null
+++ b/rest_sys/public/stylesheets/jstoolbar.css
@@ -0,0 +1,81 @@
+.jstEditor {
+ padding-left: 0px;
+}
+.jstEditor textarea, .jstEditor iframe {
+ margin: 0;
+}
+
+.jstHandle {
+ height: 10px;
+ font-size: 0.1em;
+ cursor: s-resize;
+ /*background: transparent url(img/resizer.png) no-repeat 45% 50%;*/
+}
+
+.jstElements {
+ padding: 3px 3px;
+}
+
+.jstElements button {
+ margin-right : 6px;
+ width : 24px;
+ height: 24px;
+ padding: 4px;
+ border-style: solid;
+ border-width: 1px;
+ border-color: #ddd;
+ background-color : #f7f7f7;
+ background-position : 50% 50%;
+ background-repeat: no-repeat;
+}
+.jstElements button:hover {
+ border-color : #000;
+}
+.jstElements button span {
+ display : none;
+}
+.jstElements span {
+ display : inline;
+}
+
+.jstSpacer {
+ width : 0px;
+ font-size: 1px;
+ margin-right: 4px;
+}
+
+/* Buttons
+-------------------------------------------------------- */
+.jstb_strong {
+ background-image: url(../images/jstoolbar/bt_strong.png);
+}
+.jstb_em {
+ background-image: url(../images/jstoolbar/bt_em.png);
+}
+.jstb_ins {
+ background-image: url(../images/jstoolbar/bt_ins.png);
+}
+.jstb_del {
+ background-image: url(../images/jstoolbar/bt_del.png);
+}
+.jstb_quote {
+ background-image: url(../images/jstoolbar/bt_quote.png);
+}
+.jstb_code {
+ background-image: url(../images/jstoolbar/bt_code.png);
+}
+.jstb_br {
+ background-image: url(../images/jstoolbar/bt_br.png);
+}
+.jstb_heading {
+ background-image: url(../images/jstoolbar/bt_heading.png);
+}
+.jstb_ul {
+ background-image: url(../images/jstoolbar/bt_ul.png);
+}
+.jstb_ol {
+ background-image: url(../images/jstoolbar/bt_ol.png);
+}
+.jstb_link {
+ background-image: url(../images/jstoolbar/bt_link.png);
+}
diff --git a/rest_sys/public/stylesheets/scm.css b/rest_sys/public/stylesheets/scm.css
new file mode 100644
index 000000000..c3dc307d6
--- /dev/null
+++ b/rest_sys/public/stylesheets/scm.css
@@ -0,0 +1,144 @@
+
+table.filecontent { border: 1px solid #ccc; border-collapse: collapse; width:98%; }
+table.filecontent th { border: 1px solid #ccc; background-color: #eee; }
+table.filecontent th.filename { background-color: #ddc; text-align: left; }
+table.filecontent tr.spacing { border: 1px solid #d7d7d7; }
+table.filecontent th.line-num {
+ border: 1px solid #d7d7d7;
+ font-size: 0.8em;
+ text-align: right;
+ width: 2%;
+ padding-right: 3px;
+}
+
+/* 12 different colors for the annonate view */
+table.annotate tr.bloc-0 {background: #FFFFBF;}
+table.annotate tr.bloc-1 {background: #EABFFF;}
+table.annotate tr.bloc-2 {background: #BFFFFF;}
+table.annotate tr.bloc-3 {background: #FFD9BF;}
+table.annotate tr.bloc-4 {background: #E6FFBF;}
+table.annotate tr.bloc-5 {background: #BFCFFF;}
+table.annotate tr.bloc-6 {background: #FFBFEF;}
+table.annotate tr.bloc-7 {background: #FFE6BF;}
+table.annotate tr.bloc-8 {background: #FFE680;}
+table.annotate tr.bloc-9 {background: #AA80FF;}
+table.annotate tr.bloc-10 {background: #FFBFDC;}
+table.annotate tr.bloc-11 {background: #BFE4FF;}
+
+table.annotate td.revision {
+ text-align: center;
+ width: 2%;
+ padding-left: 1em;
+ background: inherit;
+}
+
+table.annotate td.author {
+ text-align: center;
+ border-right: 1px solid #d7d7d7;
+ white-space: nowrap;
+ padding-left: 1em;
+ padding-right: 1em;
+ width: 3%;
+ background: inherit;
+}
+
+table.annotate td.line-code { background-color: #fafafa; }
+
+div.action_M { background: #fd8 }
+div.action_D { background: #f88 }
+div.action_A { background: #bfb }
+
+/************* Coderay styles *************/
+
+table.CodeRay {
+ background-color: #fafafa;
+}
+.CodeRay pre { margin: 0px }
+
+span.CodeRay { white-space: pre; border: 0px; padding: 2px }
+
+.CodeRay .no { padding: 0px 4px }
+.CodeRay .code { }
+
+ol.CodeRay { font-size: 10pt }
+ol.CodeRay li { white-space: pre }
+
+.CodeRay .code pre { overflow: auto }
+
+.CodeRay .debug { color:white ! important; background:blue ! important; }
+
+.CodeRay .af { color:#00C }
+.CodeRay .an { color:#007 }
+.CodeRay .av { color:#700 }
+.CodeRay .aw { color:#C00 }
+.CodeRay .bi { color:#509; font-weight:bold }
+.CodeRay .c { color:#666; }
+
+.CodeRay .ch { color:#04D }
+.CodeRay .ch .k { color:#04D }
+.CodeRay .ch .dl { color:#039 }
+
+.CodeRay .cl { color:#B06; font-weight:bold }
+.CodeRay .co { color:#036; font-weight:bold }
+.CodeRay .cr { color:#0A0 }
+.CodeRay .cv { color:#369 }
+.CodeRay .df { color:#099; font-weight:bold }
+.CodeRay .di { color:#088; font-weight:bold }
+.CodeRay .dl { color:black }
+.CodeRay .do { color:#970 }
+.CodeRay .ds { color:#D42; font-weight:bold }
+.CodeRay .e { color:#666; font-weight:bold }
+.CodeRay .en { color:#800; font-weight:bold }
+.CodeRay .er { color:#F00; background-color:#FAA }
+.CodeRay .ex { color:#F00; font-weight:bold }
+.CodeRay .fl { color:#60E; font-weight:bold }
+.CodeRay .fu { color:#06B; font-weight:bold }
+.CodeRay .gv { color:#d70; font-weight:bold }
+.CodeRay .hx { color:#058; font-weight:bold }
+.CodeRay .i { color:#00D; font-weight:bold }
+.CodeRay .ic { color:#B44; font-weight:bold }
+
+.CodeRay .il { background: #eee }
+.CodeRay .il .il { background: #ddd }
+.CodeRay .il .il .il { background: #ccc }
+.CodeRay .il .idl { font-weight: bold; color: #888 }
+
+.CodeRay .in { color:#B2B; font-weight:bold }
+.CodeRay .iv { color:#33B }
+.CodeRay .la { color:#970; font-weight:bold }
+.CodeRay .lv { color:#963 }
+.CodeRay .oc { color:#40E; font-weight:bold }
+.CodeRay .of { color:#000; font-weight:bold }
+.CodeRay .op { }
+.CodeRay .pc { color:#038; font-weight:bold }
+.CodeRay .pd { color:#369; font-weight:bold }
+.CodeRay .pp { color:#579 }
+.CodeRay .pt { color:#339; font-weight:bold }
+.CodeRay .r { color:#080; font-weight:bold }
+
+.CodeRay .rx { background-color:#fff0ff }
+.CodeRay .rx .k { color:#808 }
+.CodeRay .rx .dl { color:#404 }
+.CodeRay .rx .mod { color:#C2C }
+.CodeRay .rx .fu { color:#404; font-weight: bold }
+
+.CodeRay .s { background-color:#fff0f0 }
+.CodeRay .s .s { background-color:#ffe0e0 }
+.CodeRay .s .s .s { background-color:#ffd0d0 }
+.CodeRay .s .k { color:#D20 }
+.CodeRay .s .dl { color:#710 }
+
+.CodeRay .sh { background-color:#f0fff0 }
+.CodeRay .sh .k { color:#2B2 }
+.CodeRay .sh .dl { color:#161 }
+
+.CodeRay .sy { color:#A60 }
+.CodeRay .sy .k { color:#A60 }
+.CodeRay .sy .dl { color:#630 }
+
+.CodeRay .ta { color:#070 }
+.CodeRay .tf { color:#070; font-weight:bold }
+.CodeRay .ts { color:#D70; font-weight:bold }
+.CodeRay .ty { color:#339; font-weight:bold }
+.CodeRay .v { color:#036 }
+.CodeRay .xt { color:#444 }
diff --git a/rest_sys/public/themes/README b/rest_sys/public/themes/README
new file mode 100644
index 000000000..1af3d1992
--- /dev/null
+++ b/rest_sys/public/themes/README
@@ -0,0 +1 @@
+Put your Redmine themes here.
diff --git a/rest_sys/public/themes/alternate/stylesheets/application.css b/rest_sys/public/themes/alternate/stylesheets/application.css
new file mode 100644
index 000000000..af787ae71
--- /dev/null
+++ b/rest_sys/public/themes/alternate/stylesheets/application.css
@@ -0,0 +1,69 @@
+@import url(../../../stylesheets/application.css);
+
+body { background-color:#EEEEEE; }
+#header, #top-menu { margin: 0px 10px 0px 11px; }
+#main { background: #EEEEEE; margin: 8px 10px 0px 10px; }
+#content { background: #fff; border-right: 1px solid #bbb; border-bottom: 1px solid #bbb; border-left: 1px solid #d7d7d7; border-top: 1px solid #d7d7d7; }
+#footer { background-color:#EEEEEE; border: 0px; }
+
+/* Headers */
+h2, h3, h4, .wiki h1, .wiki h2, .wiki h3 {border-bottom: 0px;}
+
+/* Menu */
+#main-menu li a { background-color: #507AAA; font-weight: bold;}
+#main-menu li a:hover { background: #507AAA; text-decoration: underline; }
+
+/* Tables */
+table.list tbody td, table.list tbody tr:hover td { border: solid 1px #d7d7d7; }
+table.list thead th {
+ border-width: 1px;
+ border-style: solid;
+ border-top-color: #d7d7d7;
+ border-right-color: #d7d7d7;
+ border-left-color: #d7d7d7;
+ border-bottom-color: #999999;
+}
+
+/* Issues grid styles by priorities (provided by Wynn Netherland) */
+table.list tr.issue a { color: #666; }
+
+tr.odd.priority-5, table.list tbody tr.odd.priority-5:hover { color: #900; font-weight: bold; }
+tr.odd.priority-5 { background: #ffc4c4; }
+tr.even.priority-5, table.list tbody tr.even.priority-5:hover { color: #900; font-weight: bold; }
+tr.even.priority-5 { background: #ffd4d4; }
+tr.priority-5 a, tr.priority-5:hover a { color: #900; }
+tr.odd.priority-5 td, tr.even.priority-5 td { border-color: #ffb4b4; }
+
+tr.odd.priority-4, table.list tbody tr.odd.priority-4:hover { color: #900; }
+tr.odd.priority-4 { background: #ffc4c4; }
+tr.even.priority-4, table.list tbody tr.even.priority-4:hover { color: #900; }
+tr.even.priority-4 { background: #ffd4d4; }
+tr.priority-4 a { color: #900; }
+tr.odd.priority-4 td, tr.even.priority-4 td { border-color: #ffb4b4; }
+
+tr.odd.priority-3, table.list tbody tr.odd.priority-3:hover { color: #900; }
+tr.odd.priority-3 { background: #fee; }
+tr.even.priority-3, table.list tbody tr.even.priority-3:hover { color: #900; }
+tr.even.priority-3 { background: #fff2f2; }
+tr.priority-3 a { color: #900; }
+tr.odd.priority-3 td, tr.even.priority-3 td { border-color: #fcc; }
+
+tr.odd.priority-1, table.list tbody tr.odd.priority-1:hover { color: #559; }
+tr.odd.priority-1 { background: #eaf7ff; }
+tr.even.priority-1, table.list tbody tr.even.priority-1:hover { color: #559; }
+tr.even.priority-1 { background: #f2faff; }
+tr.priority-1 a { color: #559; }
+tr.odd.priority-1 td, tr.even.priority-1 td { border-color: #add7f3; }
+
+/* Buttons */
+input[type="button"], input[type="submit"], input[type="reset"] { background-color: #f2f2f2; color: #222222; border: 1px outset #cccccc; }
+input[type="button"]:hover, input[type="submit"]:hover, input[type="reset"]:hover { background-color: #ccccbb; }
+
+/* Fields */
+input[type="text"], textarea, select { padding: 2px; border: 1px solid #d7d7d7; }
+input[type="text"] { padding: 3px; }
+input[type="text"]:focus, textarea:focus, select:focus { border: 1px solid #888866; }
+option { border-bottom: 1px dotted #d7d7d7; }
+
+/* Misc */
+.box { background-color: #fcfcfc; }
diff --git a/rest_sys/public/themes/classic/stylesheets/application.css b/rest_sys/public/themes/classic/stylesheets/application.css
new file mode 100644
index 000000000..6bb148210
--- /dev/null
+++ b/rest_sys/public/themes/classic/stylesheets/application.css
@@ -0,0 +1,39 @@
+@import url(../../../stylesheets/application.css);
+
+body{ color:#303030; background:#e8eaec; }
+
+#top-menu { font-size: 80%; height: 2em; padding-top: 0.5em; background-color: #578bb8; }
+#top-menu a { font-weight: bold; }
+#header { background: #467aa7; height:5.8em; padding: 10px 0 0 0; }
+#header h1 { margin-left: 6px; }
+#quick-search { margin-right: 6px; }
+#main-menu { background-color: #578bb8; left: 0; border-top: 1px solid #fff; width: 100%; }
+#main-menu li { margin: 0; padding: 0; }
+#main-menu li a { background-color: #578bb8; border-right: 1px solid #fff; font-size: 80%; padding: 4px 8px 4px 8px; font-weight: bold; }
+#main-menu li a:hover { background-color: #80b0da; color: #ffffff; }
+
+#footer { background-color: #578bb8; border: 0; color: #fff;}
+#footer a { color: #fff; font-weight: bold; }
+
+#main { font:90% Verdana,Tahoma,Arial,sans-serif; background: #e8eaec; }
+#main a { font-weight: bold; color: #467aa7;}
+#main a:hover { color: #2a5a8a; text-decoration: underline; }
+#content { background: #fff; }
+
+h2, h3, h4, .wiki h1, .wiki h2, .wiki h3 { border-bottom: 0px; color:#606060; font-family: Trebuchet MS,Georgia,"Times New Roman",serif; }
+h2, .wiki h1 { letter-spacing:-1px; }
+h4 { border-bottom: dotted 1px #c0c0c0; }
+
+#top-menu a.home, #top-menu a.mypage, #top-menu a.projects, #top-menu a.admin, #top-menu a.help {
+ background-position: 0% 40%;
+ background-repeat: no-repeat;
+ padding-left: 20px;
+ padding-top: 2px;
+ padding-bottom: 3px;
+}
+
+#top-menu a.home { background-image: url(../../../images/home.png); }
+#top-menu a.mypage { background-image: url(../../../images/user_page.png); }
+#top-menu a.projects { background-image: url(../../../images/projects.png); }
+#top-menu a.admin { background-image: url(../../../images/admin.png); }
+#top-menu a.help { background-image: url(../../../images/help.png); }
diff --git a/rest_sys/script/about b/rest_sys/script/about
new file mode 100755
index 000000000..7b07d46a3
--- /dev/null
+++ b/rest_sys/script/about
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../config/boot'
+require 'commands/about'
\ No newline at end of file
diff --git a/rest_sys/script/breakpointer b/rest_sys/script/breakpointer
new file mode 100755
index 000000000..64af76edd
--- /dev/null
+++ b/rest_sys/script/breakpointer
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../config/boot'
+require 'commands/breakpointer'
\ No newline at end of file
diff --git a/rest_sys/script/console b/rest_sys/script/console
new file mode 100755
index 000000000..42f28f7d6
--- /dev/null
+++ b/rest_sys/script/console
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../config/boot'
+require 'commands/console'
\ No newline at end of file
diff --git a/rest_sys/script/destroy b/rest_sys/script/destroy
new file mode 100755
index 000000000..fa0e6fcd0
--- /dev/null
+++ b/rest_sys/script/destroy
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../config/boot'
+require 'commands/destroy'
\ No newline at end of file
diff --git a/rest_sys/script/generate b/rest_sys/script/generate
new file mode 100755
index 000000000..ef976e09f
--- /dev/null
+++ b/rest_sys/script/generate
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../config/boot'
+require 'commands/generate'
\ No newline at end of file
diff --git a/rest_sys/script/performance/benchmarker b/rest_sys/script/performance/benchmarker
new file mode 100755
index 000000000..c842d35d3
--- /dev/null
+++ b/rest_sys/script/performance/benchmarker
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../../config/boot'
+require 'commands/performance/benchmarker'
diff --git a/rest_sys/script/performance/profiler b/rest_sys/script/performance/profiler
new file mode 100755
index 000000000..d855ac8b1
--- /dev/null
+++ b/rest_sys/script/performance/profiler
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../../config/boot'
+require 'commands/performance/profiler'
diff --git a/rest_sys/script/plugin b/rest_sys/script/plugin
new file mode 100755
index 000000000..26ca64c06
--- /dev/null
+++ b/rest_sys/script/plugin
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../config/boot'
+require 'commands/plugin'
\ No newline at end of file
diff --git a/rest_sys/script/process/reaper b/rest_sys/script/process/reaper
new file mode 100755
index 000000000..c77f04535
--- /dev/null
+++ b/rest_sys/script/process/reaper
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../../config/boot'
+require 'commands/process/reaper'
diff --git a/rest_sys/script/process/spawner b/rest_sys/script/process/spawner
new file mode 100755
index 000000000..7118f3983
--- /dev/null
+++ b/rest_sys/script/process/spawner
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../../config/boot'
+require 'commands/process/spawner'
diff --git a/rest_sys/script/process/spinner b/rest_sys/script/process/spinner
new file mode 100755
index 000000000..6816b32ef
--- /dev/null
+++ b/rest_sys/script/process/spinner
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../../config/boot'
+require 'commands/process/spinner'
diff --git a/rest_sys/script/runner b/rest_sys/script/runner
new file mode 100755
index 000000000..ccc30f9d2
--- /dev/null
+++ b/rest_sys/script/runner
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../config/boot'
+require 'commands/runner'
\ No newline at end of file
diff --git a/rest_sys/script/server b/rest_sys/script/server
new file mode 100755
index 000000000..dfabcb881
--- /dev/null
+++ b/rest_sys/script/server
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../config/boot'
+require 'commands/server'
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/attachments.yml b/rest_sys/test/fixtures/attachments.yml
new file mode 100644
index 000000000..764948755
--- /dev/null
+++ b/rest_sys/test/fixtures/attachments.yml
@@ -0,0 +1,26 @@
+---
+attachments_001:
+ created_on: 2006-07-19 21:07:27 +02:00
+ downloads: 0
+ content_type: text/plain
+ disk_filename: 060719210727_error281.txt
+ container_id: 3
+ digest: b91e08d0cf966d5c6ff411bd8c4cc3a2
+ id: 1
+ container_type: Issue
+ filesize: 28
+ filename: error281.txt
+ author_id: 2
+attachments_002:
+ created_on: 2006-07-19 21:07:27 +02:00
+ downloads: 0
+ content_type: text/plain
+ disk_filename: 060719210727_document.txt
+ container_id: 1
+ digest: b91e08d0cf966d5c6ff411bd8c4cc3a2
+ id: 2
+ container_type: Document
+ filesize: 28
+ filename: document.txt
+ author_id: 2
+
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/auth_sources.yml b/rest_sys/test/fixtures/auth_sources.yml
new file mode 100644
index 000000000..086c00f62
--- /dev/null
+++ b/rest_sys/test/fixtures/auth_sources.yml
@@ -0,0 +1,2 @@
+--- {}
+
diff --git a/rest_sys/test/fixtures/boards.yml b/rest_sys/test/fixtures/boards.yml
new file mode 100644
index 000000000..b6b42aaa3
--- /dev/null
+++ b/rest_sys/test/fixtures/boards.yml
@@ -0,0 +1,19 @@
+---
+boards_001:
+ name: Help
+ project_id: 1
+ topics_count: 2
+ id: 1
+ description: Help board
+ position: 1
+ last_message_id: 5
+ messages_count: 5
+boards_002:
+ name: Discussion
+ project_id: 1
+ topics_count: 0
+ id: 2
+ description: Discussion board
+ position: 2
+ last_message_id:
+ messages_count: 0
diff --git a/rest_sys/test/fixtures/changes.yml b/rest_sys/test/fixtures/changes.yml
new file mode 100644
index 000000000..30acbd02d
--- /dev/null
+++ b/rest_sys/test/fixtures/changes.yml
@@ -0,0 +1,16 @@
+---
+changes_001:
+ id: 1
+ changeset_id: 100
+ action: A
+ path: /test/some/path/in/the/repo
+ from_path:
+ from_revision:
+changes_002:
+ id: 2
+ changeset_id: 100
+ action: A
+ path: /test/some/path/elsewhere/in/the/repo
+ from_path:
+ from_revision:
+
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/changesets.yml b/rest_sys/test/fixtures/changesets.yml
new file mode 100644
index 000000000..3b47eecd8
--- /dev/null
+++ b/rest_sys/test/fixtures/changesets.yml
@@ -0,0 +1,38 @@
+---
+changesets_001:
+ commit_date: 2007-04-11
+ committed_on: 2007-04-11 15:14:44 +02:00
+ revision: 1
+ id: 100
+ comments: My very first commit
+ repository_id: 10
+ committer: dlopper
+changesets_002:
+ commit_date: 2007-04-12
+ committed_on: 2007-04-12 15:14:44 +02:00
+ revision: 2
+ id: 101
+ comments: 'This commit fixes #1, #2 and references #1 & #3'
+ repository_id: 10
+ committer: dlopper
+changesets_003:
+ commit_date: 2007-04-12
+ committed_on: 2007-04-12 15:14:44 +02:00
+ revision: 3
+ id: 102
+ comments: |-
+ A commit with wrong issue ids
+ IssueID 666 3
+ repository_id: 10
+ committer: dlopper
+changesets_004:
+ commit_date: 2007-04-12
+ committed_on: 2007-04-12 15:14:44 +02:00
+ revision: 4
+ id: 103
+ comments: |-
+ A commit with an issue id of an other project
+ IssueID 4 2
+ repository_id: 10
+ committer: dlopper
+
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/comments.yml b/rest_sys/test/fixtures/comments.yml
new file mode 100644
index 000000000..b60a68b84
--- /dev/null
+++ b/rest_sys/test/fixtures/comments.yml
@@ -0,0 +1,10 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+comments_001:
+ commented_type: News
+ commented_id: 1
+ id: 1
+ author_id: 1
+ comments: my first comment
+ created_on: 2006-12-10 18:10:10 +01:00
+ updated_on: 2006-12-10 18:10:10 +01:00
+
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/custom_fields.yml b/rest_sys/test/fixtures/custom_fields.yml
new file mode 100644
index 000000000..e73e6de96
--- /dev/null
+++ b/rest_sys/test/fixtures/custom_fields.yml
@@ -0,0 +1,58 @@
+---
+custom_fields_001:
+ name: Database
+ min_length: 0
+ regexp: ""
+ is_for_all: false
+ type: IssueCustomField
+ max_length: 0
+ possible_values: MySQL|PostgreSQL|Oracle
+ id: 1
+ is_required: false
+ field_format: list
+custom_fields_002:
+ name: Searchable field
+ min_length: 1
+ regexp: ""
+ is_for_all: true
+ type: IssueCustomField
+ max_length: 100
+ possible_values: ""
+ id: 2
+ is_required: false
+ field_format: string
+ searchable: true
+custom_fields_003:
+ name: Development status
+ min_length: 0
+ regexp: ""
+ is_for_all: false
+ type: ProjectCustomField
+ max_length: 0
+ possible_values: Stable|Beta|Alpha|Planning
+ id: 3
+ is_required: true
+ field_format: list
+custom_fields_004:
+ name: Phone number
+ min_length: 0
+ regexp: ""
+ is_for_all: false
+ type: UserCustomField
+ max_length: 0
+ possible_values: ""
+ id: 4
+ is_required: false
+ field_format: string
+custom_fields_005:
+ name: Money
+ min_length: 0
+ regexp: ""
+ is_for_all: false
+ type: UserCustomField
+ max_length: 0
+ possible_values: ""
+ id: 5
+ is_required: false
+ field_format: float
+
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/custom_fields_projects.yml b/rest_sys/test/fixtures/custom_fields_projects.yml
new file mode 100644
index 000000000..086c00f62
--- /dev/null
+++ b/rest_sys/test/fixtures/custom_fields_projects.yml
@@ -0,0 +1,2 @@
+--- {}
+
diff --git a/rest_sys/test/fixtures/custom_fields_trackers.yml b/rest_sys/test/fixtures/custom_fields_trackers.yml
new file mode 100644
index 000000000..cb06d2fcf
--- /dev/null
+++ b/rest_sys/test/fixtures/custom_fields_trackers.yml
@@ -0,0 +1,10 @@
+---
+custom_fields_trackers_001:
+ custom_field_id: 1
+ tracker_id: 1
+custom_fields_trackers_002:
+ custom_field_id: 2
+ tracker_id: 1
+custom_fields_trackers_003:
+ custom_field_id: 2
+ tracker_id: 3
diff --git a/rest_sys/test/fixtures/custom_values.yml b/rest_sys/test/fixtures/custom_values.yml
new file mode 100644
index 000000000..572142889
--- /dev/null
+++ b/rest_sys/test/fixtures/custom_values.yml
@@ -0,0 +1,56 @@
+---
+custom_values_006:
+ customized_type: Issue
+ custom_field_id: 2
+ customized_id: 3
+ id: 9
+ value: "125"
+custom_values_007:
+ customized_type: Project
+ custom_field_id: 3
+ customized_id: 1
+ id: 10
+ value: Stable
+custom_values_001:
+ customized_type: User
+ custom_field_id: 4
+ customized_id: 3
+ id: 2
+ value: ""
+custom_values_002:
+ customized_type: User
+ custom_field_id: 4
+ customized_id: 4
+ id: 3
+ value: 01 23 45 67 89
+custom_values_003:
+ customized_type: User
+ custom_field_id: 4
+ customized_id: 2
+ id: 4
+ value: ""
+custom_values_004:
+ customized_type: Issue
+ custom_field_id: 2
+ customized_id: 1
+ id: 7
+ value: "125"
+custom_values_005:
+ customized_type: Issue
+ custom_field_id: 2
+ customized_id: 2
+ id: 8
+ value: ""
+custom_values_008:
+ customized_type: Issue
+ custom_field_id: 1
+ customized_id: 3
+ id: 11
+ value: "MySQL"
+custom_values_009:
+ customized_type: Issue
+ custom_field_id: 2
+ customized_id: 3
+ id: 12
+ value: "this is a stringforcustomfield search"
+
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/documents.yml b/rest_sys/test/fixtures/documents.yml
new file mode 100644
index 000000000..0dbca2a4f
--- /dev/null
+++ b/rest_sys/test/fixtures/documents.yml
@@ -0,0 +1,7 @@
+documents_001:
+ created_on: 2007-01-27 15:08:27 +01:00
+ project_id: 1
+ title: "Test document"
+ id: 1
+ description: "Document description"
+ category_id: 1
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/enabled_modules.yml b/rest_sys/test/fixtures/enabled_modules.yml
new file mode 100644
index 000000000..8d1565534
--- /dev/null
+++ b/rest_sys/test/fixtures/enabled_modules.yml
@@ -0,0 +1,42 @@
+---
+enabled_modules_001:
+ name: issue_tracking
+ project_id: 1
+ id: 1
+enabled_modules_002:
+ name: time_tracking
+ project_id: 1
+ id: 2
+enabled_modules_003:
+ name: news
+ project_id: 1
+ id: 3
+enabled_modules_004:
+ name: documents
+ project_id: 1
+ id: 4
+enabled_modules_005:
+ name: files
+ project_id: 1
+ id: 5
+enabled_modules_006:
+ name: wiki
+ project_id: 1
+ id: 6
+enabled_modules_007:
+ name: repository
+ project_id: 1
+ id: 7
+enabled_modules_008:
+ name: boards
+ project_id: 1
+ id: 8
+enabled_modules_009:
+ name: repository
+ project_id: 3
+ id: 9
+enabled_modules_010:
+ name: wiki
+ project_id: 3
+ id: 10
+
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/enumerations.yml b/rest_sys/test/fixtures/enumerations.yml
new file mode 100644
index 000000000..eeef99b5b
--- /dev/null
+++ b/rest_sys/test/fixtures/enumerations.yml
@@ -0,0 +1,33 @@
+---
+enumerations_001:
+ name: Uncategorized
+ id: 1
+ opt: DCAT
+enumerations_002:
+ name: User documentation
+ id: 2
+ opt: DCAT
+enumerations_003:
+ name: Technical documentation
+ id: 3
+ opt: DCAT
+enumerations_004:
+ name: Low
+ id: 4
+ opt: IPRI
+enumerations_005:
+ name: Normal
+ id: 5
+ opt: IPRI
+enumerations_006:
+ name: High
+ id: 6
+ opt: IPRI
+enumerations_007:
+ name: Urgent
+ id: 7
+ opt: IPRI
+enumerations_008:
+ name: Immediate
+ id: 8
+ opt: IPRI
diff --git a/rest_sys/test/fixtures/files/testfile.txt b/rest_sys/test/fixtures/files/testfile.txt
new file mode 100644
index 000000000..4b2a49c69
--- /dev/null
+++ b/rest_sys/test/fixtures/files/testfile.txt
@@ -0,0 +1 @@
+this is a text file for upload tests
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/issue_categories.yml b/rest_sys/test/fixtures/issue_categories.yml
new file mode 100644
index 000000000..6c2a07b58
--- /dev/null
+++ b/rest_sys/test/fixtures/issue_categories.yml
@@ -0,0 +1,11 @@
+---
+issue_categories_001:
+ name: Printing
+ project_id: 1
+ assigned_to_id: 2
+ id: 1
+issue_categories_002:
+ name: Recipes
+ project_id: 1
+ assigned_to_id:
+ id: 2
diff --git a/rest_sys/test/fixtures/issue_statuses.yml b/rest_sys/test/fixtures/issue_statuses.yml
new file mode 100644
index 000000000..c7b10ba07
--- /dev/null
+++ b/rest_sys/test/fixtures/issue_statuses.yml
@@ -0,0 +1,31 @@
+---
+issue_statuses_006:
+ name: Rejected
+ is_default: false
+ is_closed: true
+ id: 6
+issue_statuses_001:
+ name: New
+ is_default: true
+ is_closed: false
+ id: 1
+issue_statuses_002:
+ name: Assigned
+ is_default: false
+ is_closed: false
+ id: 2
+issue_statuses_003:
+ name: Resolved
+ is_default: false
+ is_closed: false
+ id: 3
+issue_statuses_004:
+ name: Feedback
+ is_default: false
+ is_closed: false
+ id: 4
+issue_statuses_005:
+ name: Closed
+ is_default: false
+ is_closed: true
+ id: 5
diff --git a/rest_sys/test/fixtures/issues.yml b/rest_sys/test/fixtures/issues.yml
new file mode 100644
index 000000000..fc5b48dee
--- /dev/null
+++ b/rest_sys/test/fixtures/issues.yml
@@ -0,0 +1,60 @@
+---
+issues_001:
+ created_on: <%= 3.days.ago.to_date.to_s(:db) %>
+ project_id: 1
+ updated_on: <%= 1.day.ago.to_date.to_s(:db) %>
+ priority_id: 4
+ subject: Can't print recipes
+ id: 1
+ fixed_version_id:
+ category_id: 1
+ description: Unable to print recipes
+ tracker_id: 1
+ assigned_to_id:
+ author_id: 2
+ status_id: 1
+issues_002:
+ created_on: 2006-07-19 21:04:21 +02:00
+ project_id: 1
+ updated_on: 2006-07-19 21:09:50 +02:00
+ priority_id: 5
+ subject: Add ingredients categories
+ id: 2
+ fixed_version_id:
+ category_id:
+ description: Ingredients should be classified by categories
+ tracker_id: 2
+ assigned_to_id: 3
+ author_id: 2
+ status_id: 2
+issues_003:
+ created_on: 2006-07-19 21:07:27 +02:00
+ project_id: 1
+ updated_on: 2006-07-19 21:07:27 +02:00
+ priority_id: 4
+ subject: Error 281 when updating a recipe
+ id: 3
+ fixed_version_id:
+ category_id:
+ description: Error 281 is encountered when saving a recipe
+ tracker_id: 1
+ assigned_to_id:
+ author_id: 2
+ status_id: 1
+ start_date: <%= 1.day.from_now.to_date.to_s(:db) %>
+ due_date: <%= 40.day.ago.to_date.to_s(:db) %>
+issues_004:
+ created_on: 2006-07-19 21:07:27 +02:00
+ project_id: 2
+ updated_on: 2006-07-19 21:07:27 +02:00
+ priority_id: 4
+ subject: Issue on project 2
+ id: 4
+ fixed_version_id:
+ category_id:
+ description: Issue on project 2
+ tracker_id: 1
+ assigned_to_id:
+ author_id: 2
+ status_id: 1
+
diff --git a/rest_sys/test/fixtures/journal_details.yml b/rest_sys/test/fixtures/journal_details.yml
new file mode 100644
index 000000000..058abd112
--- /dev/null
+++ b/rest_sys/test/fixtures/journal_details.yml
@@ -0,0 +1,15 @@
+---
+journal_details_001:
+ old_value: "1"
+ property: attr
+ id: 1
+ value: "2"
+ prop_key: status_id
+ journal_id: 1
+journal_details_002:
+ old_value: "40"
+ property: attr
+ id: 2
+ value: "30"
+ prop_key: done_ratio
+ journal_id: 1
diff --git a/rest_sys/test/fixtures/journals.yml b/rest_sys/test/fixtures/journals.yml
new file mode 100644
index 000000000..0de938168
--- /dev/null
+++ b/rest_sys/test/fixtures/journals.yml
@@ -0,0 +1,8 @@
+---
+journals_001:
+ created_on: <%= 2.days.ago.to_date.to_s(:db) %>
+ notes: "Journal notes"
+ id: 1
+ journalized_type: Issue
+ user_id: 1
+ journalized_id: 1
diff --git a/rest_sys/test/fixtures/mail_handler/add_note_to_issue.txt b/rest_sys/test/fixtures/mail_handler/add_note_to_issue.txt
new file mode 100644
index 000000000..4fc6b68fb
--- /dev/null
+++ b/rest_sys/test/fixtures/mail_handler/add_note_to_issue.txt
@@ -0,0 +1,14 @@
+x-sender:
+x-receiver:
+Received: from somenet.foo ([127.0.0.1]) by somenet.foo;
+ Sun, 25 Feb 2007 09:57:56 GMT
+Date: Sun, 25 Feb 2007 10:57:56 +0100
+From: jsmith@somenet.foo
+To: redmine@somenet.foo
+Message-Id: <45e15df440c00_b90238570a27b@osiris.tmail>
+In-Reply-To: <45e15df440c29_b90238570a27b@osiris.tmail>
+Subject: [Cookbook - Feature #2]
+Mime-Version: 1.0
+Content-Type: text/plain; charset=utf-8
+
+Note added by mail
diff --git a/rest_sys/test/fixtures/members.yml b/rest_sys/test/fixtures/members.yml
new file mode 100644
index 000000000..2c9209131
--- /dev/null
+++ b/rest_sys/test/fixtures/members.yml
@@ -0,0 +1,27 @@
+---
+members_001:
+ created_on: 2006-07-19 19:35:33 +02:00
+ project_id: 1
+ role_id: 1
+ id: 1
+ user_id: 2
+members_002:
+ created_on: 2006-07-19 19:35:36 +02:00
+ project_id: 1
+ role_id: 2
+ id: 2
+ user_id: 3
+members_003:
+ created_on: 2006-07-19 19:35:36 +02:00
+ project_id: 2
+ role_id: 2
+ id: 3
+ user_id: 2
+members_004:
+ id: 4
+ created_on: 2006-07-19 19:35:36 +02:00
+ project_id: 1
+ role_id: 2
+ # Locked user
+ user_id: 5
+
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/messages.yml b/rest_sys/test/fixtures/messages.yml
new file mode 100644
index 000000000..5bb2438dd
--- /dev/null
+++ b/rest_sys/test/fixtures/messages.yml
@@ -0,0 +1,57 @@
+---
+messages_001:
+ created_on: 2007-05-12 17:15:32 +02:00
+ updated_on: 2007-05-12 17:15:32 +02:00
+ subject: First post
+ id: 1
+ replies_count: 2
+ last_reply_id: 3
+ content: "This is the very first post\n\
+ in the forum"
+ author_id: 1
+ parent_id:
+ board_id: 1
+messages_002:
+ created_on: 2007-05-12 17:18:00 +02:00
+ updated_on: 2007-05-12 17:18:00 +02:00
+ subject: First reply
+ id: 2
+ replies_count: 0
+ last_reply_id:
+ content: "Reply to the first post"
+ author_id: 1
+ parent_id: 1
+ board_id: 1
+messages_003:
+ created_on: 2007-05-12 17:18:02 +02:00
+ updated_on: 2007-05-12 17:18:02 +02:00
+ subject: "RE: First post"
+ id: 3
+ replies_count: 0
+ last_reply_id:
+ content: "An other reply"
+ author_id:
+ parent_id: 1
+ board_id: 1
+messages_004:
+ created_on: 2007-08-12 17:15:32 +02:00
+ updated_on: 2007-08-12 17:15:32 +02:00
+ subject: Post 2
+ id: 4
+ replies_count: 1
+ last_reply_id: 5
+ content: "This is an other post"
+ author_id:
+ parent_id:
+ board_id: 1
+messages_005:
+ created_on: 2007-09-12 17:18:00 +02:00
+ updated_on: 2007-09-12 17:18:00 +02:00
+ subject: 'RE: post 2'
+ id: 5
+ replies_count: 0
+ last_reply_id:
+ content: "Reply to the second post"
+ author_id: 1
+ parent_id: 4
+ board_id: 1
diff --git a/rest_sys/test/fixtures/news.yml b/rest_sys/test/fixtures/news.yml
new file mode 100644
index 000000000..2c2e2c134
--- /dev/null
+++ b/rest_sys/test/fixtures/news.yml
@@ -0,0 +1,22 @@
+---
+news_001:
+ created_on: 2006-07-19 22:40:26 +02:00
+ project_id: 1
+ title: eCookbook first release !
+ id: 1
+ description: |-
+ eCookbook 1.0 has been released.
+
+ Visit http://ecookbook.somenet.foo/
+ summary: First version was released...
+ author_id: 2
+ comments_count: 1
+news_002:
+ created_on: 2006-07-19 22:42:58 +02:00
+ project_id: 1
+ title: 100,000 downloads for eCookbook
+ id: 2
+ description: eCookbook 1.0 have downloaded 100,000 times
+ summary: eCookbook 1.0 have downloaded 100,000 times
+ author_id: 2
+ comments_count: 0
diff --git a/rest_sys/test/fixtures/projects.yml b/rest_sys/test/fixtures/projects.yml
new file mode 100644
index 000000000..d3758c9e3
--- /dev/null
+++ b/rest_sys/test/fixtures/projects.yml
@@ -0,0 +1,45 @@
+---
+projects_001:
+ created_on: 2006-07-19 19:13:59 +02:00
+ name: eCookbook
+ updated_on: 2006-07-19 22:53:01 +02:00
+ projects_count: 2
+ id: 1
+ description: Recipes management application
+ homepage: http://ecookbook.somenet.foo/
+ is_public: true
+ identifier: ecookbook
+ parent_id:
+projects_002:
+ created_on: 2006-07-19 19:14:19 +02:00
+ name: OnlineStore
+ updated_on: 2006-07-19 19:14:19 +02:00
+ projects_count: 0
+ id: 2
+ description: E-commerce web site
+ homepage: ""
+ is_public: false
+ identifier: onlinestore
+ parent_id:
+projects_003:
+ created_on: 2006-07-19 19:15:21 +02:00
+ name: eCookbook Subproject 1
+ updated_on: 2006-07-19 19:18:12 +02:00
+ projects_count: 0
+ id: 3
+ description: eCookBook Subproject 1
+ homepage: ""
+ is_public: true
+ identifier: subproject1
+ parent_id: 1
+projects_004:
+ created_on: 2006-07-19 19:15:51 +02:00
+ name: eCookbook Subproject 2
+ updated_on: 2006-07-19 19:17:07 +02:00
+ projects_count: 0
+ id: 4
+ description: eCookbook Subproject 2
+ homepage: ""
+ is_public: true
+ identifier: subproject1
+ parent_id: 1
diff --git a/rest_sys/test/fixtures/projects_trackers.yml b/rest_sys/test/fixtures/projects_trackers.yml
new file mode 100644
index 000000000..cfca5b228
--- /dev/null
+++ b/rest_sys/test/fixtures/projects_trackers.yml
@@ -0,0 +1,46 @@
+---
+projects_trackers_012:
+ project_id: 4
+ tracker_id: 3
+projects_trackers_001:
+ project_id: 1
+ tracker_id: 1
+projects_trackers_013:
+ project_id: 5
+ tracker_id: 1
+projects_trackers_002:
+ project_id: 1
+ tracker_id: 2
+projects_trackers_014:
+ project_id: 5
+ tracker_id: 2
+projects_trackers_003:
+ project_id: 1
+ tracker_id: 3
+projects_trackers_015:
+ project_id: 5
+ tracker_id: 3
+projects_trackers_004:
+ project_id: 2
+ tracker_id: 1
+projects_trackers_005:
+ project_id: 2
+ tracker_id: 2
+projects_trackers_006:
+ project_id: 2
+ tracker_id: 3
+projects_trackers_007:
+ project_id: 3
+ tracker_id: 1
+projects_trackers_008:
+ project_id: 3
+ tracker_id: 2
+projects_trackers_009:
+ project_id: 3
+ tracker_id: 3
+projects_trackers_010:
+ project_id: 4
+ tracker_id: 1
+projects_trackers_011:
+ project_id: 4
+ tracker_id: 2
diff --git a/rest_sys/test/fixtures/queries.yml b/rest_sys/test/fixtures/queries.yml
new file mode 100644
index 000000000..a4c045b15
--- /dev/null
+++ b/rest_sys/test/fixtures/queries.yml
@@ -0,0 +1,22 @@
+---
+queries_001:
+ name: Multiple custom fields query
+ project_id: 1
+ filters: |
+ ---
+ cf_1:
+ :values:
+ - MySQL
+ :operator: "="
+ status_id:
+ :values:
+ - "1"
+ :operator: o
+ cf_2:
+ :values:
+ - "125"
+ :operator: "="
+
+ id: 1
+ is_public: true
+ user_id: 1
diff --git a/rest_sys/test/fixtures/repositories.yml b/rest_sys/test/fixtures/repositories.yml
new file mode 100644
index 000000000..d86e301c9
--- /dev/null
+++ b/rest_sys/test/fixtures/repositories.yml
@@ -0,0 +1,17 @@
+---
+repositories_001:
+ project_id: 1
+ url: file:///<%= RAILS_ROOT.gsub(%r{config\/\.\.}, '') %>/tmp/test/subversion_repository
+ id: 10
+ root_url: file:///<%= RAILS_ROOT.gsub(%r{config\/\.\.}, '') %>/tmp/test/subversion_repository
+ password: ""
+ login: ""
+ type: Subversion
+repositories_002:
+ project_id: 2
+ url: svn://localhost/test
+ id: 11
+ root_url: svn://localhost
+ password: ""
+ login: ""
+ type: Subversion
diff --git a/rest_sys/test/fixtures/repositories/bazaar_repository.tar.gz b/rest_sys/test/fixtures/repositories/bazaar_repository.tar.gz
new file mode 100644
index 000000000..621c2f145
Binary files /dev/null and b/rest_sys/test/fixtures/repositories/bazaar_repository.tar.gz differ
diff --git a/rest_sys/test/fixtures/repositories/cvs_repository.tar.gz b/rest_sys/test/fixtures/repositories/cvs_repository.tar.gz
new file mode 100644
index 000000000..638b166b5
Binary files /dev/null and b/rest_sys/test/fixtures/repositories/cvs_repository.tar.gz differ
diff --git a/rest_sys/test/fixtures/repositories/mercurial_repository.tar.gz b/rest_sys/test/fixtures/repositories/mercurial_repository.tar.gz
new file mode 100644
index 000000000..1d8ad3057
Binary files /dev/null and b/rest_sys/test/fixtures/repositories/mercurial_repository.tar.gz differ
diff --git a/rest_sys/test/fixtures/repositories/subversion_repository.dump.gz b/rest_sys/test/fixtures/repositories/subversion_repository.dump.gz
new file mode 100644
index 000000000..997835048
Binary files /dev/null and b/rest_sys/test/fixtures/repositories/subversion_repository.dump.gz differ
diff --git a/rest_sys/test/fixtures/roles.yml b/rest_sys/test/fixtures/roles.yml
new file mode 100644
index 000000000..a089a98f9
--- /dev/null
+++ b/rest_sys/test/fixtures/roles.yml
@@ -0,0 +1,163 @@
+---
+roles_004:
+ name: Non member
+ id: 4
+ builtin: 1
+ permissions: |
+ ---
+ - :add_issues
+ - :edit_issues
+ - :manage_issue_relations
+ - :add_issue_notes
+ - :change_issue_status
+ - :move_issues
+ - :save_queries
+ - :view_gantt
+ - :view_calendar
+ - :log_time
+ - :view_time_entries
+ - :comment_news
+ - :view_documents
+ - :manage_documents
+ - :view_wiki_pages
+ - :edit_wiki_pages
+ - :add_messages
+ - :view_files
+ - :manage_files
+ - :browse_repository
+ - :view_changesets
+
+ position: 5
+roles_005:
+ name: Anonymous
+ id: 5
+ builtin: 2
+ permissions: |
+ ---
+ - :view_gantt
+ - :view_calendar
+ - :view_time_entries
+ - :view_documents
+ - :view_wiki_pages
+ - :view_files
+ - :browse_repository
+ - :view_changesets
+
+ position: 6
+roles_001:
+ name: Manager
+ id: 1
+ builtin: 0
+ permissions: |
+ ---
+ - :edit_project
+ - :manage_members
+ - :manage_versions
+ - :manage_categories
+ - :add_issues
+ - :edit_issues
+ - :manage_issue_relations
+ - :add_issue_notes
+ - :change_issue_status
+ - :move_issues
+ - :delete_issues
+ - :manage_public_queries
+ - :save_queries
+ - :view_gantt
+ - :view_calendar
+ - :log_time
+ - :view_time_entries
+ - :manage_news
+ - :comment_news
+ - :view_documents
+ - :manage_documents
+ - :view_wiki_pages
+ - :edit_wiki_pages
+ - :delete_wiki_pages
+ - :rename_wiki_pages
+ - :add_messages
+ - :edit_messages
+ - :delete_messages
+ - :manage_boards
+ - :view_files
+ - :manage_files
+ - :browse_repository
+ - :view_changesets
+
+ position: 2
+roles_002:
+ name: Developer
+ id: 2
+ builtin: 0
+ permissions: |
+ ---
+ - :edit_project
+ - :manage_members
+ - :manage_versions
+ - :manage_categories
+ - :add_issues
+ - :edit_issues
+ - :manage_issue_relations
+ - :add_issue_notes
+ - :change_issue_status
+ - :move_issues
+ - :delete_issues
+ - :manage_public_queries
+ - :save_queries
+ - :view_gantt
+ - :view_calendar
+ - :log_time
+ - :view_time_entries
+ - :manage_news
+ - :comment_news
+ - :view_documents
+ - :manage_documents
+ - :view_wiki_pages
+ - :edit_wiki_pages
+ - :delete_wiki_pages
+ - :add_messages
+ - :manage_boards
+ - :view_files
+ - :manage_files
+ - :browse_repository
+ - :view_changesets
+
+ position: 3
+roles_003:
+ name: Reporter
+ id: 3
+ builtin: 0
+ permissions: |
+ ---
+ - :edit_project
+ - :manage_members
+ - :manage_versions
+ - :manage_categories
+ - :add_issues
+ - :edit_issues
+ - :manage_issue_relations
+ - :add_issue_notes
+ - :change_issue_status
+ - :move_issues
+ - :delete_issues
+ - :manage_public_queries
+ - :save_queries
+ - :view_gantt
+ - :view_calendar
+ - :log_time
+ - :view_time_entries
+ - :manage_news
+ - :comment_news
+ - :view_documents
+ - :manage_documents
+ - :view_wiki_pages
+ - :edit_wiki_pages
+ - :delete_wiki_pages
+ - :add_messages
+ - :manage_boards
+ - :view_files
+ - :manage_files
+ - :browse_repository
+ - :view_changesets
+
+ position: 4
diff --git a/rest_sys/test/fixtures/time_entries.yml b/rest_sys/test/fixtures/time_entries.yml
new file mode 100644
index 000000000..4e4ff6896
--- /dev/null
+++ b/rest_sys/test/fixtures/time_entries.yml
@@ -0,0 +1,43 @@
+---
+time_entries_001:
+ created_on: 2007-03-23 12:54:18 +01:00
+ tweek: 12
+ tmonth: 3
+ project_id: 1
+ comments: My hours
+ updated_on: 2007-03-23 12:54:18 +01:00
+ activity_id: 8
+ spent_on: 2007-03-23
+ issue_id: 1
+ id: 1
+ hours: 4.25
+ user_id: 2
+ tyear: 2007
+time_entries_002:
+ created_on: 2007-03-23 14:11:04 +01:00
+ tweek: 12
+ tmonth: 3
+ project_id: 1
+ comments: ""
+ updated_on: 2007-03-23 14:11:04 +01:00
+ activity_id: 8
+ spent_on: 2007-03-23
+ issue_id: 1
+ id: 2
+ hours: 150.0
+ user_id: 1
+ tyear: 2007
+time_entries_003:
+ created_on: 2007-04-21 12:20:48 +02:00
+ tweek: 16
+ tmonth: 4
+ project_id: 1
+ comments: ""
+ updated_on: 2007-04-21 12:20:48 +02:00
+ activity_id: 8
+ spent_on: 2007-04-21
+ issue_id: 2
+ id: 3
+ hours: 1.0
+ user_id: 1
+ tyear: 2007
diff --git a/rest_sys/test/fixtures/tokens.yml b/rest_sys/test/fixtures/tokens.yml
new file mode 100644
index 000000000..e040a39e9
--- /dev/null
+++ b/rest_sys/test/fixtures/tokens.yml
@@ -0,0 +1,13 @@
+---
+tokens_001:
+ created_on: 2007-01-21 00:39:12 +01:00
+ action: register
+ id: 1
+ value: DwMJ2yIxBNeAk26znMYzYmz5dAiIina0GFrPnGTM
+ user_id: 1
+tokens_002:
+ created_on: 2007-01-21 00:39:52 +01:00
+ action: recovery
+ id: 2
+ value: sahYSIaoYrsZUef86sTHrLISdznW6ApF36h5WSnm
+ user_id: 2
diff --git a/rest_sys/test/fixtures/trackers.yml b/rest_sys/test/fixtures/trackers.yml
new file mode 100644
index 000000000..d4ea34ac8
--- /dev/null
+++ b/rest_sys/test/fixtures/trackers.yml
@@ -0,0 +1,13 @@
+---
+trackers_001:
+ name: Bug
+ id: 1
+ is_in_chlog: true
+trackers_002:
+ name: Feature request
+ id: 2
+ is_in_chlog: true
+trackers_003:
+ name: Support request
+ id: 3
+ is_in_chlog: false
diff --git a/rest_sys/test/fixtures/user_preferences.yml b/rest_sys/test/fixtures/user_preferences.yml
new file mode 100644
index 000000000..b9ba37765
--- /dev/null
+++ b/rest_sys/test/fixtures/user_preferences.yml
@@ -0,0 +1,24 @@
+---
+user_preferences_001:
+ others: |
+ ---
+ :my_page_layout:
+ left:
+ - latest_news
+ - documents
+ right:
+ - issues_assigned_to_me
+ - issues_reported_by_me
+ top:
+ - calendar
+
+ id: 1
+ user_id: 1
+ hide_mail: true
+user_preferences_002:
+ others: |+
+ --- {}
+
+ id: 2
+ user_id: 3
+ hide_mail: false
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/users.yml b/rest_sys/test/fixtures/users.yml
new file mode 100644
index 000000000..df7123879
--- /dev/null
+++ b/rest_sys/test/fixtures/users.yml
@@ -0,0 +1,77 @@
+---
+users_004:
+ created_on: 2006-07-19 19:34:07 +02:00
+ status: 1
+ last_login_on:
+ language: en
+ hashed_password: 4e4aeb7baaf0706bd670263fef42dad15763b608
+ updated_on: 2006-07-19 19:34:07 +02:00
+ admin: false
+ mail: rhill@somenet.foo
+ lastname: Hill
+ firstname: Robert
+ id: 4
+ auth_source_id:
+ mail_notification: true
+ login: rhill
+users_001:
+ created_on: 2006-07-19 19:12:21 +02:00
+ status: 1
+ last_login_on: 2006-07-19 22:57:52 +02:00
+ language: en
+ hashed_password: d033e22ae348aeb5660fc2140aec35850c4da997
+ updated_on: 2006-07-19 22:57:52 +02:00
+ admin: true
+ mail: admin@somenet.foo
+ lastname: Admin
+ firstname: redMine
+ id: 1
+ auth_source_id:
+ mail_notification: true
+ login: admin
+users_002:
+ created_on: 2006-07-19 19:32:09 +02:00
+ status: 1
+ last_login_on: 2006-07-19 22:42:15 +02:00
+ language: en
+ hashed_password: a9a653d4151fa2c081ba1ffc2c2726f3b80b7d7d
+ updated_on: 2006-07-19 22:42:15 +02:00
+ admin: false
+ mail: jsmith@somenet.foo
+ lastname: Smith
+ firstname: John
+ id: 2
+ auth_source_id:
+ mail_notification: true
+ login: jsmith
+users_003:
+ created_on: 2006-07-19 19:33:19 +02:00
+ status: 1
+ last_login_on:
+ language: en
+ hashed_password: 7feb7657aa7a7bf5aef3414a5084875f27192415
+ updated_on: 2006-07-19 19:33:19 +02:00
+ admin: false
+ mail: dlopper@somenet.foo
+ lastname: Lopper
+ firstname: Dave
+ id: 3
+ auth_source_id:
+ mail_notification: true
+ login: dlopper
+users_005:
+ id: 5
+ created_on: 2006-07-19 19:33:19 +02:00
+ # Locked
+ status: 3
+ last_login_on:
+ language: en
+ hashed_password: 7feb7657aa7a7bf5aef3414a5084875f27192415
+ updated_on: 2006-07-19 19:33:19 +02:00
+ admin: false
+ mail: dlopper2@somenet.foo
+ lastname: Lopper2
+ firstname: Dave2
+ auth_source_id:
+ mail_notification: true
+ login: dlopper2
diff --git a/rest_sys/test/fixtures/versions.yml b/rest_sys/test/fixtures/versions.yml
new file mode 100644
index 000000000..bf08660d5
--- /dev/null
+++ b/rest_sys/test/fixtures/versions.yml
@@ -0,0 +1,26 @@
+---
+versions_001:
+ created_on: 2006-07-19 21:00:07 +02:00
+ name: "0.1"
+ project_id: 1
+ updated_on: 2006-07-19 21:00:07 +02:00
+ id: 1
+ description: Beta
+ effective_date: 2006-07-01
+versions_002:
+ created_on: 2006-07-19 21:00:33 +02:00
+ name: "1.0"
+ project_id: 1
+ updated_on: 2006-07-19 21:00:33 +02:00
+ id: 2
+ description: Stable release
+ effective_date: 2006-07-19
+versions_003:
+ created_on: 2006-07-19 21:00:33 +02:00
+ name: "2.0"
+ project_id: 1
+ updated_on: 2006-07-19 21:00:33 +02:00
+ id: 3
+ description: Future version
+ effective_date:
+
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/wiki_content_versions.yml b/rest_sys/test/fixtures/wiki_content_versions.yml
new file mode 100644
index 000000000..547030ccf
--- /dev/null
+++ b/rest_sys/test/fixtures/wiki_content_versions.yml
@@ -0,0 +1,52 @@
+---
+wiki_content_versions_001:
+ updated_on: 2007-03-07 00:08:07 +01:00
+ page_id: 1
+ id: 1
+ version: 1
+ author_id: 1
+ comments: Page creation
+ wiki_content_id: 1
+ compression: ""
+ data: |-
+ h1. CookBook documentation
+
+ Some [[documentation]] here...
+wiki_content_versions_002:
+ updated_on: 2007-03-07 00:08:34 +01:00
+ page_id: 1
+ id: 2
+ version: 2
+ author_id: 1
+ comments: Small update
+ wiki_content_id: 1
+ compression: ""
+ data: |-
+ h1. CookBook documentation
+
+ Some updated [[documentation]] here...
+wiki_content_versions_003:
+ updated_on: 2007-03-07 00:10:51 +01:00
+ page_id: 1
+ id: 3
+ version: 3
+ author_id: 1
+ comments: ""
+ wiki_content_id: 1
+ compression: ""
+ data: |-
+ h1. CookBook documentation
+ Some updated [[documentation]] here...
+wiki_content_versions_004:
+ data: |-
+ h1. Another page
+
+ This is a link to a ticket: #2
+ updated_on: 2007-03-08 00:18:07 +01:00
+ page_id: 2
+ wiki_content_id: 2
+ id: 4
+ version: 1
+ author_id: 1
+ comments:
+
diff --git a/rest_sys/test/fixtures/wiki_contents.yml b/rest_sys/test/fixtures/wiki_contents.yml
new file mode 100644
index 000000000..a230b9c08
--- /dev/null
+++ b/rest_sys/test/fixtures/wiki_contents.yml
@@ -0,0 +1,24 @@
+---
+wiki_contents_001:
+ text: |-
+ h1. CookBook documentation
+
+ Some updated [[documentation]] here with gzipped history
+ updated_on: 2007-03-07 00:10:51 +01:00
+ page_id: 1
+ id: 1
+ version: 3
+ author_id: 1
+ comments: Gzip compression activated
+wiki_contents_002:
+ text: |-
+ h1. Another page
+
+ This is a link to a ticket: #2
+ updated_on: 2007-03-08 00:18:07 +01:00
+ page_id: 2
+ id: 2
+ version: 1
+ author_id: 1
+ comments:
+
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/wiki_pages.yml b/rest_sys/test/fixtures/wiki_pages.yml
new file mode 100644
index 000000000..ca9d6f5dc
--- /dev/null
+++ b/rest_sys/test/fixtures/wiki_pages.yml
@@ -0,0 +1,12 @@
+---
+wiki_pages_001:
+ created_on: 2007-03-07 00:08:07 +01:00
+ title: CookBook_documentation
+ id: 1
+ wiki_id: 1
+wiki_pages_002:
+ created_on: 2007-03-08 00:18:07 +01:00
+ title: Another_page
+ id: 2
+ wiki_id: 1
+
\ No newline at end of file
diff --git a/rest_sys/test/fixtures/wikis.yml b/rest_sys/test/fixtures/wikis.yml
new file mode 100644
index 000000000..ff7b4a1ae
--- /dev/null
+++ b/rest_sys/test/fixtures/wikis.yml
@@ -0,0 +1,6 @@
+---
+wikis_001:
+ status: 1
+ start_page: CookBook documentation
+ project_id: 1
+ id: 1
diff --git a/rest_sys/test/fixtures/workflows.yml b/rest_sys/test/fixtures/workflows.yml
new file mode 100644
index 000000000..47e95e6e3
--- /dev/null
+++ b/rest_sys/test/fixtures/workflows.yml
@@ -0,0 +1,1621 @@
+---
+workflows_189:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 2
+ id: 189
+ tracker_id: 3
+workflows_001:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 1
+ id: 1
+ tracker_id: 1
+workflows_002:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 1
+ id: 2
+ tracker_id: 1
+workflows_003:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 1
+ id: 3
+ tracker_id: 1
+workflows_110:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 4
+ id: 110
+ tracker_id: 2
+workflows_004:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 1
+ id: 4
+ tracker_id: 1
+workflows_030:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 6
+ id: 30
+ tracker_id: 1
+workflows_111:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 5
+ id: 111
+ tracker_id: 2
+workflows_005:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 1
+ id: 5
+ tracker_id: 1
+workflows_031:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 1
+ id: 31
+ tracker_id: 1
+workflows_112:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 5
+ id: 112
+ tracker_id: 2
+workflows_006:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 2
+ id: 6
+ tracker_id: 1
+workflows_032:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 1
+ id: 32
+ tracker_id: 1
+workflows_113:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 5
+ id: 113
+ tracker_id: 2
+workflows_220:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 2
+ id: 220
+ tracker_id: 3
+workflows_007:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 2
+ id: 7
+ tracker_id: 1
+workflows_033:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 1
+ id: 33
+ tracker_id: 1
+workflows_060:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 6
+ id: 60
+ tracker_id: 1
+workflows_114:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 5
+ id: 114
+ tracker_id: 2
+workflows_140:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 4
+ id: 140
+ tracker_id: 2
+workflows_221:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 3
+ id: 221
+ tracker_id: 3
+workflows_008:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 2
+ id: 8
+ tracker_id: 1
+workflows_034:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 1
+ id: 34
+ tracker_id: 1
+workflows_115:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 5
+ id: 115
+ tracker_id: 2
+workflows_141:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 5
+ id: 141
+ tracker_id: 2
+workflows_222:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 3
+ id: 222
+ tracker_id: 3
+workflows_223:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 3
+ id: 223
+ tracker_id: 3
+workflows_009:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 2
+ id: 9
+ tracker_id: 1
+workflows_035:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 1
+ id: 35
+ tracker_id: 1
+workflows_061:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 1
+ id: 61
+ tracker_id: 1
+workflows_116:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 6
+ id: 116
+ tracker_id: 2
+workflows_142:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 5
+ id: 142
+ tracker_id: 2
+workflows_250:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 2
+ id: 250
+ tracker_id: 3
+workflows_224:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 3
+ id: 224
+ tracker_id: 3
+workflows_036:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 2
+ id: 36
+ tracker_id: 1
+workflows_062:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 1
+ id: 62
+ tracker_id: 1
+workflows_117:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 6
+ id: 117
+ tracker_id: 2
+workflows_143:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 5
+ id: 143
+ tracker_id: 2
+workflows_170:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 4
+ id: 170
+ tracker_id: 2
+workflows_251:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 3
+ id: 251
+ tracker_id: 3
+workflows_225:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 3
+ id: 225
+ tracker_id: 3
+workflows_037:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 2
+ id: 37
+ tracker_id: 1
+workflows_063:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 1
+ id: 63
+ tracker_id: 1
+workflows_090:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 6
+ id: 90
+ tracker_id: 1
+workflows_118:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 6
+ id: 118
+ tracker_id: 2
+workflows_144:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 5
+ id: 144
+ tracker_id: 2
+workflows_252:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 3
+ id: 252
+ tracker_id: 3
+workflows_226:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 4
+ id: 226
+ tracker_id: 3
+workflows_038:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 2
+ id: 38
+ tracker_id: 1
+workflows_064:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 1
+ id: 64
+ tracker_id: 1
+workflows_091:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 1
+ id: 91
+ tracker_id: 2
+workflows_119:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 6
+ id: 119
+ tracker_id: 2
+workflows_145:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 5
+ id: 145
+ tracker_id: 2
+workflows_171:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 5
+ id: 171
+ tracker_id: 2
+workflows_253:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 3
+ id: 253
+ tracker_id: 3
+workflows_227:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 4
+ id: 227
+ tracker_id: 3
+workflows_039:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 2
+ id: 39
+ tracker_id: 1
+workflows_065:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 1
+ id: 65
+ tracker_id: 1
+workflows_092:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 1
+ id: 92
+ tracker_id: 2
+workflows_146:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 6
+ id: 146
+ tracker_id: 2
+workflows_172:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 5
+ id: 172
+ tracker_id: 2
+workflows_254:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 3
+ id: 254
+ tracker_id: 3
+workflows_228:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 4
+ id: 228
+ tracker_id: 3
+workflows_066:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 2
+ id: 66
+ tracker_id: 1
+workflows_093:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 1
+ id: 93
+ tracker_id: 2
+workflows_147:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 6
+ id: 147
+ tracker_id: 2
+workflows_173:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 5
+ id: 173
+ tracker_id: 2
+workflows_255:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 3
+ id: 255
+ tracker_id: 3
+workflows_229:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 4
+ id: 229
+ tracker_id: 3
+workflows_067:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 2
+ id: 67
+ tracker_id: 1
+workflows_148:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 6
+ id: 148
+ tracker_id: 2
+workflows_174:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 5
+ id: 174
+ tracker_id: 2
+workflows_256:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 4
+ id: 256
+ tracker_id: 3
+workflows_068:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 2
+ id: 68
+ tracker_id: 1
+workflows_094:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 1
+ id: 94
+ tracker_id: 2
+workflows_149:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 6
+ id: 149
+ tracker_id: 2
+workflows_175:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 5
+ id: 175
+ tracker_id: 2
+workflows_257:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 4
+ id: 257
+ tracker_id: 3
+workflows_069:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 2
+ id: 69
+ tracker_id: 1
+workflows_095:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 1
+ id: 95
+ tracker_id: 2
+workflows_176:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 6
+ id: 176
+ tracker_id: 2
+workflows_258:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 4
+ id: 258
+ tracker_id: 3
+workflows_096:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 2
+ id: 96
+ tracker_id: 2
+workflows_177:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 6
+ id: 177
+ tracker_id: 2
+workflows_259:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 4
+ id: 259
+ tracker_id: 3
+workflows_097:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 2
+ id: 97
+ tracker_id: 2
+workflows_178:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 6
+ id: 178
+ tracker_id: 2
+workflows_098:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 2
+ id: 98
+ tracker_id: 2
+workflows_179:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 6
+ id: 179
+ tracker_id: 2
+workflows_099:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 2
+ id: 99
+ tracker_id: 2
+workflows_100:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 2
+ id: 100
+ tracker_id: 2
+workflows_020:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 4
+ id: 20
+ tracker_id: 1
+workflows_101:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 3
+ id: 101
+ tracker_id: 2
+workflows_021:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 5
+ id: 21
+ tracker_id: 1
+workflows_102:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 3
+ id: 102
+ tracker_id: 2
+workflows_210:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 6
+ id: 210
+ tracker_id: 3
+workflows_022:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 5
+ id: 22
+ tracker_id: 1
+workflows_103:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 3
+ id: 103
+ tracker_id: 2
+workflows_023:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 5
+ id: 23
+ tracker_id: 1
+workflows_104:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 3
+ id: 104
+ tracker_id: 2
+workflows_130:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 2
+ id: 130
+ tracker_id: 2
+workflows_211:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 1
+ id: 211
+ tracker_id: 3
+workflows_024:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 5
+ id: 24
+ tracker_id: 1
+workflows_050:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 4
+ id: 50
+ tracker_id: 1
+workflows_105:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 3
+ id: 105
+ tracker_id: 2
+workflows_131:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 3
+ id: 131
+ tracker_id: 2
+workflows_212:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 1
+ id: 212
+ tracker_id: 3
+workflows_025:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 5
+ id: 25
+ tracker_id: 1
+workflows_051:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 5
+ id: 51
+ tracker_id: 1
+workflows_106:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 4
+ id: 106
+ tracker_id: 2
+workflows_132:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 3
+ id: 132
+ tracker_id: 2
+workflows_213:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 1
+ id: 213
+ tracker_id: 3
+workflows_240:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 6
+ id: 240
+ tracker_id: 3
+workflows_026:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 6
+ id: 26
+ tracker_id: 1
+workflows_052:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 5
+ id: 52
+ tracker_id: 1
+workflows_107:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 4
+ id: 107
+ tracker_id: 2
+workflows_133:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 3
+ id: 133
+ tracker_id: 2
+workflows_214:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 1
+ id: 214
+ tracker_id: 3
+workflows_241:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 1
+ id: 241
+ tracker_id: 3
+workflows_027:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 6
+ id: 27
+ tracker_id: 1
+workflows_053:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 5
+ id: 53
+ tracker_id: 1
+workflows_080:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 4
+ id: 80
+ tracker_id: 1
+workflows_108:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 4
+ id: 108
+ tracker_id: 2
+workflows_134:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 3
+ id: 134
+ tracker_id: 2
+workflows_160:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 2
+ id: 160
+ tracker_id: 2
+workflows_215:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 1
+ id: 215
+ tracker_id: 3
+workflows_242:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 1
+ id: 242
+ tracker_id: 3
+workflows_028:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 6
+ id: 28
+ tracker_id: 1
+workflows_054:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 5
+ id: 54
+ tracker_id: 1
+workflows_081:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 5
+ id: 81
+ tracker_id: 1
+workflows_109:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 4
+ id: 109
+ tracker_id: 2
+workflows_135:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 3
+ id: 135
+ tracker_id: 2
+workflows_161:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 3
+ id: 161
+ tracker_id: 2
+workflows_216:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 2
+ id: 216
+ tracker_id: 3
+workflows_243:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 1
+ id: 243
+ tracker_id: 3
+workflows_029:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 6
+ id: 29
+ tracker_id: 1
+workflows_055:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 5
+ id: 55
+ tracker_id: 1
+workflows_082:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 5
+ id: 82
+ tracker_id: 1
+workflows_136:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 4
+ id: 136
+ tracker_id: 2
+workflows_162:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 3
+ id: 162
+ tracker_id: 2
+workflows_217:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 2
+ id: 217
+ tracker_id: 3
+workflows_270:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 6
+ id: 270
+ tracker_id: 3
+workflows_244:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 1
+ id: 244
+ tracker_id: 3
+workflows_056:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 6
+ id: 56
+ tracker_id: 1
+workflows_137:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 4
+ id: 137
+ tracker_id: 2
+workflows_163:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 3
+ id: 163
+ tracker_id: 2
+workflows_190:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 2
+ id: 190
+ tracker_id: 3
+workflows_218:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 2
+ id: 218
+ tracker_id: 3
+workflows_245:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 1
+ id: 245
+ tracker_id: 3
+workflows_057:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 6
+ id: 57
+ tracker_id: 1
+workflows_083:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 5
+ id: 83
+ tracker_id: 1
+workflows_138:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 4
+ id: 138
+ tracker_id: 2
+workflows_164:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 3
+ id: 164
+ tracker_id: 2
+workflows_191:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 3
+ id: 191
+ tracker_id: 3
+workflows_219:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 2
+ id: 219
+ tracker_id: 3
+workflows_246:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 2
+ id: 246
+ tracker_id: 3
+workflows_058:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 6
+ id: 58
+ tracker_id: 1
+workflows_084:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 5
+ id: 84
+ tracker_id: 1
+workflows_139:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 4
+ id: 139
+ tracker_id: 2
+workflows_165:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 3
+ id: 165
+ tracker_id: 2
+workflows_192:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 3
+ id: 192
+ tracker_id: 3
+workflows_247:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 2
+ id: 247
+ tracker_id: 3
+workflows_059:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 6
+ id: 59
+ tracker_id: 1
+workflows_085:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 5
+ id: 85
+ tracker_id: 1
+workflows_166:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 4
+ id: 166
+ tracker_id: 2
+workflows_248:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 2
+ id: 248
+ tracker_id: 3
+workflows_086:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 6
+ id: 86
+ tracker_id: 1
+workflows_167:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 4
+ id: 167
+ tracker_id: 2
+workflows_193:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 3
+ id: 193
+ tracker_id: 3
+workflows_249:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 2
+ id: 249
+ tracker_id: 3
+workflows_087:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 6
+ id: 87
+ tracker_id: 1
+workflows_168:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 4
+ id: 168
+ tracker_id: 2
+workflows_194:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 3
+ id: 194
+ tracker_id: 3
+workflows_088:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 6
+ id: 88
+ tracker_id: 1
+workflows_169:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 4
+ id: 169
+ tracker_id: 2
+workflows_195:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 3
+ id: 195
+ tracker_id: 3
+workflows_089:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 6
+ id: 89
+ tracker_id: 1
+workflows_196:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 4
+ id: 196
+ tracker_id: 3
+workflows_197:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 4
+ id: 197
+ tracker_id: 3
+workflows_198:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 4
+ id: 198
+ tracker_id: 3
+workflows_199:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 4
+ id: 199
+ tracker_id: 3
+workflows_010:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 2
+ id: 10
+ tracker_id: 1
+workflows_011:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 3
+ id: 11
+ tracker_id: 1
+workflows_012:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 3
+ id: 12
+ tracker_id: 1
+workflows_200:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 4
+ id: 200
+ tracker_id: 3
+workflows_013:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 3
+ id: 13
+ tracker_id: 1
+workflows_120:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 6
+ id: 120
+ tracker_id: 2
+workflows_201:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 5
+ id: 201
+ tracker_id: 3
+workflows_040:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 2
+ id: 40
+ tracker_id: 1
+workflows_121:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 1
+ id: 121
+ tracker_id: 2
+workflows_202:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 5
+ id: 202
+ tracker_id: 3
+workflows_014:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 3
+ id: 14
+ tracker_id: 1
+workflows_041:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 3
+ id: 41
+ tracker_id: 1
+workflows_122:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 1
+ id: 122
+ tracker_id: 2
+workflows_203:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 5
+ id: 203
+ tracker_id: 3
+workflows_015:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 3
+ id: 15
+ tracker_id: 1
+workflows_230:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 4
+ id: 230
+ tracker_id: 3
+workflows_123:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 1
+ id: 123
+ tracker_id: 2
+workflows_204:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 5
+ id: 204
+ tracker_id: 3
+workflows_016:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 4
+ id: 16
+ tracker_id: 1
+workflows_042:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 3
+ id: 42
+ tracker_id: 1
+workflows_231:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 5
+ id: 231
+ tracker_id: 3
+workflows_070:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 2
+ id: 70
+ tracker_id: 1
+workflows_124:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 1
+ id: 124
+ tracker_id: 2
+workflows_150:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 6
+ id: 150
+ tracker_id: 2
+workflows_205:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 5
+ id: 205
+ tracker_id: 3
+workflows_017:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 4
+ id: 17
+ tracker_id: 1
+workflows_043:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 3
+ id: 43
+ tracker_id: 1
+workflows_232:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 5
+ id: 232
+ tracker_id: 3
+workflows_125:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 1
+ id: 125
+ tracker_id: 2
+workflows_151:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 1
+ id: 151
+ tracker_id: 2
+workflows_206:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 6
+ id: 206
+ tracker_id: 3
+workflows_018:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 4
+ id: 18
+ tracker_id: 1
+workflows_044:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 3
+ id: 44
+ tracker_id: 1
+workflows_071:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 3
+ id: 71
+ tracker_id: 1
+workflows_233:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 5
+ id: 233
+ tracker_id: 3
+workflows_126:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 2
+ id: 126
+ tracker_id: 2
+workflows_152:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 1
+ id: 152
+ tracker_id: 2
+workflows_207:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 6
+ id: 207
+ tracker_id: 3
+workflows_019:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 4
+ id: 19
+ tracker_id: 1
+workflows_045:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 3
+ id: 45
+ tracker_id: 1
+workflows_260:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 4
+ id: 260
+ tracker_id: 3
+workflows_234:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 5
+ id: 234
+ tracker_id: 3
+workflows_127:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 2
+ id: 127
+ tracker_id: 2
+workflows_153:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 1
+ id: 153
+ tracker_id: 2
+workflows_180:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 6
+ id: 180
+ tracker_id: 2
+workflows_208:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 6
+ id: 208
+ tracker_id: 3
+workflows_046:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 4
+ id: 46
+ tracker_id: 1
+workflows_072:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 3
+ id: 72
+ tracker_id: 1
+workflows_261:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 5
+ id: 261
+ tracker_id: 3
+workflows_235:
+ new_status_id: 6
+ role_id: 2
+ old_status_id: 5
+ id: 235
+ tracker_id: 3
+workflows_154:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 1
+ id: 154
+ tracker_id: 2
+workflows_181:
+ new_status_id: 2
+ role_id: 1
+ old_status_id: 1
+ id: 181
+ tracker_id: 3
+workflows_209:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 6
+ id: 209
+ tracker_id: 3
+workflows_047:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 4
+ id: 47
+ tracker_id: 1
+workflows_073:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 3
+ id: 73
+ tracker_id: 1
+workflows_128:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 2
+ id: 128
+ tracker_id: 2
+workflows_262:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 5
+ id: 262
+ tracker_id: 3
+workflows_236:
+ new_status_id: 1
+ role_id: 2
+ old_status_id: 6
+ id: 236
+ tracker_id: 3
+workflows_155:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 1
+ id: 155
+ tracker_id: 2
+workflows_048:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 4
+ id: 48
+ tracker_id: 1
+workflows_074:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 3
+ id: 74
+ tracker_id: 1
+workflows_129:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 2
+ id: 129
+ tracker_id: 2
+workflows_263:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 5
+ id: 263
+ tracker_id: 3
+workflows_237:
+ new_status_id: 2
+ role_id: 2
+ old_status_id: 6
+ id: 237
+ tracker_id: 3
+workflows_182:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 1
+ id: 182
+ tracker_id: 3
+workflows_049:
+ new_status_id: 5
+ role_id: 2
+ old_status_id: 4
+ id: 49
+ tracker_id: 1
+workflows_075:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 3
+ id: 75
+ tracker_id: 1
+workflows_156:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 2
+ id: 156
+ tracker_id: 2
+workflows_264:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 5
+ id: 264
+ tracker_id: 3
+workflows_238:
+ new_status_id: 3
+ role_id: 2
+ old_status_id: 6
+ id: 238
+ tracker_id: 3
+workflows_183:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 1
+ id: 183
+ tracker_id: 3
+workflows_076:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 4
+ id: 76
+ tracker_id: 1
+workflows_157:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 2
+ id: 157
+ tracker_id: 2
+workflows_265:
+ new_status_id: 6
+ role_id: 3
+ old_status_id: 5
+ id: 265
+ tracker_id: 3
+workflows_239:
+ new_status_id: 4
+ role_id: 2
+ old_status_id: 6
+ id: 239
+ tracker_id: 3
+workflows_077:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 4
+ id: 77
+ tracker_id: 1
+workflows_158:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 2
+ id: 158
+ tracker_id: 2
+workflows_184:
+ new_status_id: 5
+ role_id: 1
+ old_status_id: 1
+ id: 184
+ tracker_id: 3
+workflows_266:
+ new_status_id: 1
+ role_id: 3
+ old_status_id: 6
+ id: 266
+ tracker_id: 3
+workflows_078:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 4
+ id: 78
+ tracker_id: 1
+workflows_159:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 2
+ id: 159
+ tracker_id: 2
+workflows_185:
+ new_status_id: 6
+ role_id: 1
+ old_status_id: 1
+ id: 185
+ tracker_id: 3
+workflows_267:
+ new_status_id: 2
+ role_id: 3
+ old_status_id: 6
+ id: 267
+ tracker_id: 3
+workflows_079:
+ new_status_id: 5
+ role_id: 3
+ old_status_id: 4
+ id: 79
+ tracker_id: 1
+workflows_186:
+ new_status_id: 1
+ role_id: 1
+ old_status_id: 2
+ id: 186
+ tracker_id: 3
+workflows_268:
+ new_status_id: 3
+ role_id: 3
+ old_status_id: 6
+ id: 268
+ tracker_id: 3
+workflows_187:
+ new_status_id: 3
+ role_id: 1
+ old_status_id: 2
+ id: 187
+ tracker_id: 3
+workflows_269:
+ new_status_id: 4
+ role_id: 3
+ old_status_id: 6
+ id: 269
+ tracker_id: 3
+workflows_188:
+ new_status_id: 4
+ role_id: 1
+ old_status_id: 2
+ id: 188
+ tracker_id: 3
diff --git a/rest_sys/test/functional/account_controller_test.rb b/rest_sys/test/functional/account_controller_test.rb
new file mode 100644
index 000000000..a923de3ea
--- /dev/null
+++ b/rest_sys/test/functional/account_controller_test.rb
@@ -0,0 +1,73 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'account_controller'
+
+# Re-raise errors caught by the controller.
+class AccountController; def rescue_action(e) raise e end; end
+
+class AccountControllerTest < Test::Unit::TestCase
+ fixtures :users
+
+ def setup
+ @controller = AccountController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ end
+
+ def test_show
+ get :show, :id => 2
+ assert_response :success
+ assert_template 'show'
+ assert_not_nil assigns(:user)
+ end
+
+ def test_show_inactive
+ get :show, :id => 5
+ assert_response 404
+ assert_nil assigns(:user)
+ end
+
+ def test_login_with_wrong_password
+ post :login, :login => 'admin', :password => 'bad'
+ assert_response :success
+ assert_template 'login'
+ assert_tag 'div',
+ :attributes => { :class => "flash error" },
+ :content => /Invalid user or password/
+ end
+
+ def test_autologin
+ Setting.autologin = "7"
+ Token.delete_all
+ post :login, :login => 'admin', :password => 'admin', :autologin => 1
+ assert_redirected_to 'my/page'
+ token = Token.find :first
+ assert_not_nil token
+ assert_equal User.find_by_login('admin'), token.user
+ assert_equal 'autologin', token.action
+ end
+
+ def test_logout
+ @request.session[:user_id] = 2
+ get :logout
+ assert_redirected_to ''
+ assert_nil @request.session[:user_id]
+ end
+end
diff --git a/rest_sys/test/functional/admin_controller_test.rb b/rest_sys/test/functional/admin_controller_test.rb
new file mode 100644
index 000000000..d49fe2dda
--- /dev/null
+++ b/rest_sys/test/functional/admin_controller_test.rb
@@ -0,0 +1,61 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'admin_controller'
+
+# Re-raise errors caught by the controller.
+class AdminController; def rescue_action(e) raise e end; end
+
+class AdminControllerTest < Test::Unit::TestCase
+ fixtures :projects, :users
+
+ def setup
+ @controller = AdminController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ @request.session[:user_id] = 1 # admin
+ end
+
+ def test_get_mail_options
+ get :mail_options
+ assert_response :success
+ assert_template 'mail_options'
+ end
+
+ def test_post_mail_options
+ post :mail_options, :settings => {'mail_from' => 'functional@test.foo'}
+ assert_redirected_to 'admin/mail_options'
+ assert_equal 'functional@test.foo', Setting.mail_from
+ end
+
+ def test_test_email
+ get :test_email
+ assert_redirected_to 'admin/mail_options'
+ mail = ActionMailer::Base.deliveries.last
+ assert_kind_of TMail::Mail, mail
+ user = User.find(1)
+ assert_equal [user.mail], mail.bcc
+ end
+
+ def test_info
+ get :info
+ assert_response :success
+ assert_template 'info'
+ end
+end
diff --git a/rest_sys/test/functional/application_controller_test.rb b/rest_sys/test/functional/application_controller_test.rb
new file mode 100644
index 000000000..3a40b15a9
--- /dev/null
+++ b/rest_sys/test/functional/application_controller_test.rb
@@ -0,0 +1,39 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'application'
+
+# Re-raise errors caught by the controller.
+class ApplicationController; def rescue_action(e) raise e end; end
+
+class ApplicationControllerTest < Test::Unit::TestCase
+ def setup
+ @controller = ApplicationController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ # check that all language files are valid
+ def test_localization
+ lang_files_count = Dir["#{RAILS_ROOT}/lang/*.yml"].size
+ assert_equal lang_files_count, GLoc.valid_languages.size
+ GLoc.valid_languages.each do |lang|
+ assert set_language_if_valid(lang)
+ end
+ end
+end
diff --git a/rest_sys/test/functional/boards_controller_test.rb b/rest_sys/test/functional/boards_controller_test.rb
new file mode 100644
index 000000000..3ff71bc4e
--- /dev/null
+++ b/rest_sys/test/functional/boards_controller_test.rb
@@ -0,0 +1,50 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'boards_controller'
+
+# Re-raise errors caught by the controller.
+class BoardsController; def rescue_action(e) raise e end; end
+
+class BoardsControllerTest < Test::Unit::TestCase
+ fixtures :projects, :users, :members, :roles, :boards, :messages, :enabled_modules
+
+ def setup
+ @controller = BoardsController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ end
+
+ def test_index
+ get :index, :project_id => 1
+ assert_response :success
+ assert_template 'index'
+ assert_not_nil assigns(:boards)
+ assert_not_nil assigns(:project)
+ end
+
+ def test_show
+ get :show, :project_id => 1, :id => 1
+ assert_response :success
+ assert_template 'show'
+ assert_not_nil assigns(:board)
+ assert_not_nil assigns(:project)
+ assert_not_nil assigns(:topics)
+ end
+end
diff --git a/rest_sys/test/functional/issues_controller_test.rb b/rest_sys/test/functional/issues_controller_test.rb
new file mode 100644
index 000000000..638362dbe
--- /dev/null
+++ b/rest_sys/test/functional/issues_controller_test.rb
@@ -0,0 +1,163 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'issues_controller'
+
+# Re-raise errors caught by the controller.
+class IssuesController; def rescue_action(e) raise e end; end
+
+class IssuesControllerTest < Test::Unit::TestCase
+ fixtures :projects,
+ :users,
+ :roles,
+ :members,
+ :issues,
+ :issue_statuses,
+ :trackers,
+ :issue_categories,
+ :enabled_modules,
+ :enumerations,
+ :attachments
+
+ def setup
+ @controller = IssuesController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ end
+
+ def test_index
+ get :index
+ assert_response :success
+ assert_template 'index.rhtml'
+ assert_not_nil assigns(:issues)
+ assert_nil assigns(:project)
+ end
+
+ def test_index_with_project
+ get :index, :project_id => 1
+ assert_response :success
+ assert_template 'index.rhtml'
+ assert_not_nil assigns(:issues)
+ end
+
+ def test_index_with_project_and_filter
+ get :index, :project_id => 1, :set_filter => 1
+ assert_response :success
+ assert_template 'index.rhtml'
+ assert_not_nil assigns(:issues)
+ end
+
+ def test_index_csv_with_project
+ get :index, :format => 'csv'
+ assert_response :success
+ assert_not_nil assigns(:issues)
+ assert_equal 'text/csv', @response.content_type
+
+ get :index, :project_id => 1, :format => 'csv'
+ assert_response :success
+ assert_not_nil assigns(:issues)
+ assert_equal 'text/csv', @response.content_type
+ end
+
+ def test_index_pdf
+ get :index, :format => 'pdf'
+ assert_response :success
+ assert_not_nil assigns(:issues)
+ assert_equal 'application/pdf', @response.content_type
+
+ get :index, :project_id => 1, :format => 'pdf'
+ assert_response :success
+ assert_not_nil assigns(:issues)
+ assert_equal 'application/pdf', @response.content_type
+ end
+
+ def test_changes
+ get :changes, :project_id => 1
+ assert_response :success
+ assert_not_nil assigns(:changes)
+ assert_equal 'application/atom+xml', @response.content_type
+ end
+
+ def test_show
+ get :show, :id => 1
+ assert_response :success
+ assert_template 'show.rhtml'
+ assert_not_nil assigns(:issue)
+ end
+
+ def test_get_edit
+ @request.session[:user_id] = 2
+ get :edit, :id => 1
+ assert_response :success
+ assert_template 'edit'
+ assert_not_nil assigns(:issue)
+ assert_equal Issue.find(1), assigns(:issue)
+ end
+
+ def test_post_edit
+ @request.session[:user_id] = 2
+ post :edit, :id => 1, :issue => {:subject => 'Modified subject'}
+ assert_redirected_to 'issues/show/1'
+ assert_equal 'Modified subject', Issue.find(1).subject
+ end
+
+ def test_post_change_status
+ issue = Issue.find(1)
+ assert_equal 1, issue.status_id
+ @request.session[:user_id] = 2
+ post :change_status, :id => 1,
+ :new_status_id => 2,
+ :issue => { :assigned_to_id => 3 },
+ :notes => 'Assigned to dlopper',
+ :confirm => 1
+ assert_redirected_to 'issues/show/1'
+ issue.reload
+ assert_equal 2, issue.status_id
+ j = issue.journals.find(:first, :order => 'created_on DESC')
+ assert_equal 'Assigned to dlopper', j.notes
+ assert_equal 2, j.details.size
+ end
+
+ def test_context_menu
+ @request.session[:user_id] = 2
+ get :context_menu, :id => 1
+ assert_response :success
+ assert_template 'context_menu'
+ end
+
+ def test_destroy
+ @request.session[:user_id] = 2
+ post :destroy, :id => 1
+ assert_redirected_to 'projects/1/issues'
+ assert_nil Issue.find_by_id(1)
+ end
+
+ def test_destroy_attachment
+ issue = Issue.find(3)
+ a = issue.attachments.size
+ @request.session[:user_id] = 2
+ post :destroy_attachment, :id => 3, :attachment_id => 1
+ assert_redirected_to 'issues/show/3'
+ assert_nil Attachment.find_by_id(1)
+ issue.reload
+ assert_equal((a-1), issue.attachments.size)
+ j = issue.journals.find(:first, :order => 'created_on DESC')
+ assert_equal 'attachment', j.details.first.property
+ end
+end
diff --git a/rest_sys/test/functional/messages_controller_test.rb b/rest_sys/test/functional/messages_controller_test.rb
new file mode 100644
index 000000000..dcfe0caa7
--- /dev/null
+++ b/rest_sys/test/functional/messages_controller_test.rb
@@ -0,0 +1,99 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'messages_controller'
+
+# Re-raise errors caught by the controller.
+class MessagesController; def rescue_action(e) raise e end; end
+
+class MessagesControllerTest < Test::Unit::TestCase
+ fixtures :projects, :users, :members, :roles, :boards, :messages, :enabled_modules
+
+ def setup
+ @controller = MessagesController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ end
+
+ def test_show
+ get :show, :board_id => 1, :id => 1
+ assert_response :success
+ assert_template 'show'
+ assert_not_nil assigns(:board)
+ assert_not_nil assigns(:project)
+ assert_not_nil assigns(:topic)
+ end
+
+ def test_show_message_not_found
+ get :show, :board_id => 1, :id => 99999
+ assert_response 404
+ end
+
+ def test_get_new
+ @request.session[:user_id] = 2
+ get :new, :board_id => 1
+ assert_response :success
+ assert_template 'new'
+ end
+
+ def test_post_new
+ @request.session[:user_id] = 2
+ post :new, :board_id => 1,
+ :message => { :subject => 'Test created message',
+ :content => 'Message body'}
+ assert_redirected_to 'messages/show'
+ message = Message.find_by_subject('Test created message')
+ assert_not_nil message
+ assert_equal 'Message body', message.content
+ assert_equal 2, message.author_id
+ assert_equal 1, message.board_id
+ end
+
+ def test_get_edit
+ @request.session[:user_id] = 2
+ get :edit, :board_id => 1, :id => 1
+ assert_response :success
+ assert_template 'edit'
+ end
+
+ def test_post_edit
+ @request.session[:user_id] = 2
+ post :edit, :board_id => 1, :id => 1,
+ :message => { :subject => 'New subject',
+ :content => 'New body'}
+ assert_redirected_to 'messages/show'
+ message = Message.find(1)
+ assert_equal 'New subject', message.subject
+ assert_equal 'New body', message.content
+ end
+
+ def test_reply
+ @request.session[:user_id] = 2
+ post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
+ assert_redirected_to 'messages/show'
+ assert Message.find_by_subject('Test reply')
+ end
+
+ def test_destroy_topic
+ @request.session[:user_id] = 2
+ post :destroy, :board_id => 1, :id => 1
+ assert_redirected_to 'boards/show'
+ assert_nil Message.find_by_id(1)
+ end
+end
diff --git a/rest_sys/test/functional/my_controller_test.rb b/rest_sys/test/functional/my_controller_test.rb
new file mode 100644
index 000000000..c1349ace4
--- /dev/null
+++ b/rest_sys/test/functional/my_controller_test.rb
@@ -0,0 +1,91 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'my_controller'
+
+# Re-raise errors caught by the controller.
+class MyController; def rescue_action(e) raise e end; end
+
+class MyControllerTest < Test::Unit::TestCase
+ fixtures :users, :issues, :issue_statuses, :trackers, :enumerations
+
+ def setup
+ @controller = MyController.new
+ @request = ActionController::TestRequest.new
+ @request.session[:user_id] = 2
+ @response = ActionController::TestResponse.new
+ end
+
+ def test_index
+ get :index
+ assert_response :success
+ assert_template 'page'
+ end
+
+ def test_page
+ get :page
+ assert_response :success
+ assert_template 'page'
+ end
+
+ def test_get_account
+ get :account
+ assert_response :success
+ assert_template 'account'
+ assert_equal User.find(2), assigns(:user)
+ end
+
+ def test_update_account
+ post :account, :user => {:firstname => "Joe", :login => "root", :admin => 1}
+ assert_redirected_to 'my/account'
+ user = User.find(2)
+ assert_equal user, assigns(:user)
+ assert_equal "Joe", user.firstname
+ assert_equal "jsmith", user.login
+ assert !user.admin?
+ end
+
+ def test_change_password
+ get :password
+ assert_response :success
+ assert_template 'password'
+
+ # non matching password confirmation
+ post :password, :password => 'jsmith',
+ :new_password => 'hello',
+ :new_password_confirmation => 'hello2'
+ assert_response :success
+ assert_template 'password'
+ assert_tag :tag => "div", :attributes => { :class => "errorExplanation" }
+
+ # wrong password
+ post :password, :password => 'wrongpassword',
+ :new_password => 'hello',
+ :new_password_confirmation => 'hello'
+ assert_response :success
+ assert_template 'password'
+ assert_equal 'Wrong password', flash[:error]
+
+ # good password
+ post :password, :password => 'jsmith',
+ :new_password => 'hello',
+ :new_password_confirmation => 'hello'
+ assert_redirected_to 'my/account'
+ assert User.try_to_login('jsmith', 'hello')
+ end
+end
diff --git a/rest_sys/test/functional/news_controller_test.rb b/rest_sys/test/functional/news_controller_test.rb
new file mode 100644
index 000000000..8a02345fd
--- /dev/null
+++ b/rest_sys/test/functional/news_controller_test.rb
@@ -0,0 +1,48 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'news_controller'
+
+# Re-raise errors caught by the controller.
+class NewsController; def rescue_action(e) raise e end; end
+
+class NewsControllerTest < Test::Unit::TestCase
+ fixtures :projects, :users, :roles, :members, :enabled_modules
+
+ def setup
+ @controller = NewsController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ end
+
+ def test_index
+ get :index
+ assert_response :success
+ assert_template 'index'
+ assert_not_nil assigns(:newss)
+ assert_nil assigns(:project)
+ end
+
+ def test_index_with_project
+ get :index, :project_id => 1
+ assert_response :success
+ assert_template 'index'
+ assert_not_nil assigns(:newss)
+ end
+end
diff --git a/rest_sys/test/functional/projects_controller_test.rb b/rest_sys/test/functional/projects_controller_test.rb
new file mode 100644
index 000000000..b6ac59141
--- /dev/null
+++ b/rest_sys/test/functional/projects_controller_test.rb
@@ -0,0 +1,257 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'projects_controller'
+
+# Re-raise errors caught by the controller.
+class ProjectsController; def rescue_action(e) raise e end; end
+
+class ProjectsControllerTest < Test::Unit::TestCase
+ fixtures :projects, :versions, :users, :roles, :members, :issues, :journals, :journal_details, :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations
+
+ def setup
+ @controller = ProjectsController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ def test_index
+ get :index
+ assert_response :success
+ assert_template 'list'
+ end
+
+ def test_list
+ get :list
+ assert_response :success
+ assert_template 'list'
+ assert_not_nil assigns(:project_tree)
+ # Root project as hash key
+ assert assigns(:project_tree).has_key?(Project.find(1))
+ # Subproject in corresponding value
+ assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
+ end
+
+ def test_show
+ get :show, :id => 1
+ assert_response :success
+ assert_template 'show'
+ assert_not_nil assigns(:project)
+ end
+
+ def test_settings
+ @request.session[:user_id] = 2 # manager
+ get :settings, :id => 1
+ assert_response :success
+ assert_template 'settings'
+ end
+
+ def test_edit
+ @request.session[:user_id] = 2 # manager
+ post :edit, :id => 1, :project => {:name => 'Test changed name'}
+ assert_redirected_to 'projects/settings/1'
+ project = Project.find(1)
+ assert_equal 'Test changed name', project.name
+ end
+
+ def test_get_destroy
+ @request.session[:user_id] = 1 # admin
+ get :destroy, :id => 1
+ assert_response :success
+ assert_template 'destroy'
+ assert_not_nil Project.find_by_id(1)
+ end
+
+ def test_post_destroy
+ @request.session[:user_id] = 1 # admin
+ post :destroy, :id => 1, :confirm => 1
+ assert_redirected_to 'admin/projects'
+ assert_nil Project.find_by_id(1)
+ end
+
+ def test_list_documents
+ get :list_documents, :id => 1
+ assert_response :success
+ assert_template 'list_documents'
+ assert_not_nil assigns(:grouped)
+ end
+
+ def test_bulk_edit_issues
+ @request.session[:user_id] = 2
+ # update issues priority
+ post :bulk_edit_issues, :id => 1, :issue_ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => ''
+ assert_response 302
+ # check that the issues were updated
+ assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id}
+ assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes
+ end
+
+ def test_move_issues_to_another_project
+ @request.session[:user_id] = 1
+ post :move_issues, :id => 1, :issue_ids => [1, 2], :new_project_id => 2
+ assert_redirected_to 'projects/1/issues'
+ assert_equal 2, Issue.find(1).project_id
+ assert_equal 2, Issue.find(2).project_id
+ end
+
+ def test_move_issues_to_another_tracker
+ @request.session[:user_id] = 1
+ post :move_issues, :id => 1, :issue_ids => [1, 2], :new_tracker_id => 3
+ assert_redirected_to 'projects/1/issues'
+ assert_equal 3, Issue.find(1).tracker_id
+ assert_equal 3, Issue.find(2).tracker_id
+ end
+
+ def test_list_files
+ get :list_files, :id => 1
+ assert_response :success
+ assert_template 'list_files'
+ assert_not_nil assigns(:versions)
+ end
+
+ def test_changelog
+ get :changelog, :id => 1
+ assert_response :success
+ assert_template 'changelog'
+ assert_not_nil assigns(:versions)
+ end
+
+ def test_roadmap
+ get :roadmap, :id => 1
+ assert_response :success
+ assert_template 'roadmap'
+ assert_not_nil assigns(:versions)
+ # Version with no date set appears
+ assert assigns(:versions).include?(Version.find(3))
+ # Completed version doesn't appear
+ assert !assigns(:versions).include?(Version.find(1))
+ end
+
+ def test_roadmap_with_completed_versions
+ get :roadmap, :id => 1, :completed => 1
+ assert_response :success
+ assert_template 'roadmap'
+ assert_not_nil assigns(:versions)
+ # Version with no date set appears
+ assert assigns(:versions).include?(Version.find(3))
+ # Completed version appears
+ assert assigns(:versions).include?(Version.find(1))
+ end
+
+ def test_activity
+ get :activity, :id => 1, :year => 2.days.ago.to_date.year, :month => 2.days.ago.to_date.month
+ assert_response :success
+ assert_template 'activity'
+ assert_not_nil assigns(:events_by_day)
+
+ assert_tag :tag => "h3",
+ :content => /#{2.days.ago.to_date.day}/,
+ :sibling => { :tag => "ul",
+ :child => { :tag => "li",
+ :child => { :tag => "p",
+ :content => /(#{IssueStatus.find(2).name})/,
+ }
+ }
+ }
+
+ get :activity, :id => 1, :year => 3.days.ago.to_date.year, :month => 3.days.ago.to_date.month
+ assert_response :success
+ assert_template 'activity'
+ assert_not_nil assigns(:events_by_day)
+
+ assert_tag :tag => "h3",
+ :content => /#{3.day.ago.to_date.day}/,
+ :sibling => { :tag => "ul",
+ :child => { :tag => "li",
+ :child => { :tag => "p",
+ :content => /#{Issue.find(1).subject}/,
+ }
+ }
+ }
+ end
+
+ def test_calendar
+ get :calendar, :id => 1
+ assert_response :success
+ assert_template 'calendar'
+ assert_not_nil assigns(:calendar)
+ end
+
+ def test_calendar_with_subprojects
+ get :calendar, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2]
+ assert_response :success
+ assert_template 'calendar'
+ assert_not_nil assigns(:calendar)
+ end
+
+ def test_gantt
+ get :gantt, :id => 1
+ assert_response :success
+ assert_template 'gantt.rhtml'
+ assert_not_nil assigns(:events)
+ end
+
+ def test_gantt_with_subprojects
+ get :gantt, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2]
+ assert_response :success
+ assert_template 'gantt.rhtml'
+ assert_not_nil assigns(:events)
+ end
+
+ def test_gantt_export_to_pdf
+ get :gantt, :id => 1, :format => 'pdf'
+ assert_response :success
+ assert_template 'gantt.rfpdf'
+ assert_equal 'application/pdf', @response.content_type
+ assert_not_nil assigns(:events)
+ end
+
+ def test_archive
+ @request.session[:user_id] = 1 # admin
+ post :archive, :id => 1
+ assert_redirected_to 'admin/projects'
+ assert !Project.find(1).active?
+ end
+
+ def test_unarchive
+ @request.session[:user_id] = 1 # admin
+ Project.find(1).archive
+ post :unarchive, :id => 1
+ assert_redirected_to 'admin/projects'
+ assert Project.find(1).active?
+ end
+
+ def test_add_issue
+ @request.session[:user_id] = 2
+ get :add_issue, :id => 1, :tracker_id => 1
+ assert_response :success
+ assert_template 'add_issue'
+ post :add_issue, :id => 1, :issue => {:tracker_id => 1, :subject => 'This is the test_add_issue issue', :description => 'This is the description', :priority_id => 5}
+ assert_redirected_to 'projects/1/issues'
+ assert Issue.find_by_subject('This is the test_add_issue issue')
+ end
+
+ def test_copy_issue
+ @request.session[:user_id] = 2
+ get :add_issue, :id => 1, :copy_from => 1
+ assert_template 'add_issue'
+ assert_not_nil assigns(:issue)
+ orig = Issue.find(1)
+ assert_equal orig.subject, assigns(:issue).subject
+ end
+end
diff --git a/rest_sys/test/functional/repositories_controller_test.rb b/rest_sys/test/functional/repositories_controller_test.rb
new file mode 100644
index 000000000..2f0459505
--- /dev/null
+++ b/rest_sys/test/functional/repositories_controller_test.rb
@@ -0,0 +1,64 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'repositories_controller'
+
+# Re-raise errors caught by the controller.
+class RepositoriesController; def rescue_action(e) raise e end; end
+
+class RepositoriesControllerTest < Test::Unit::TestCase
+ fixtures :projects, :users, :roles, :members, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
+
+ def setup
+ @controller = RepositoriesController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ end
+
+ def test_revisions
+ get :revisions, :id => 1
+ assert_response :success
+ assert_template 'revisions'
+ assert_not_nil assigns(:changesets)
+ end
+
+ def test_revision_with_before_nil_and_afer_normal
+ get :revision, {:id => 1, :rev => 1}
+ assert_response :success
+ assert_template 'revision'
+ assert_no_tag :tag => "div", :attributes => { :class => "contextual" },
+ :child => { :tag => "a", :attributes => { :href => '/repositories/revision/1?rev=0'}
+ }
+ assert_tag :tag => "div", :attributes => { :class => "contextual" },
+ :child => { :tag => "a", :attributes => { :href => '/repositories/revision/1?rev=2'}
+ }
+ end
+
+ def test_graph_commits_per_month
+ get :graph, :id => 1, :graph => 'commits_per_month'
+ assert_response :success
+ assert_equal 'image/svg+xml', @response.content_type
+ end
+
+ def test_graph_commits_per_author
+ get :graph, :id => 1, :graph => 'commits_per_author'
+ assert_response :success
+ assert_equal 'image/svg+xml', @response.content_type
+ end
+end
diff --git a/rest_sys/test/functional/repositories_mercurial_controller_test.rb b/rest_sys/test/functional/repositories_mercurial_controller_test.rb
new file mode 100644
index 000000000..db0029017
--- /dev/null
+++ b/rest_sys/test/functional/repositories_mercurial_controller_test.rb
@@ -0,0 +1,117 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'repositories_controller'
+
+# Re-raise errors caught by the controller.
+class RepositoriesController; def rescue_action(e) raise e end; end
+
+class RepositoriesMercurialControllerTest < Test::Unit::TestCase
+ fixtures :projects, :users, :roles, :members, :repositories, :enabled_modules
+
+ # No '..' in the repository path
+ REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
+
+ def setup
+ @controller = RepositoriesController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ Repository::Mercurial.create(:project => Project.find(3), :url => REPOSITORY_PATH)
+ end
+
+ def test_show
+ get :show, :id => 3
+ assert_response :success
+ assert_template 'show'
+ assert_not_nil assigns(:entries)
+ assert_not_nil assigns(:changesets)
+ end
+
+ def test_browse_root
+ get :browse, :id => 3
+ assert_response :success
+ assert_template 'browse'
+ assert_not_nil assigns(:entries)
+ assert_equal 3, assigns(:entries).size
+ assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
+ assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
+ assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
+ end
+
+ def test_browse_directory
+ get :browse, :id => 3, :path => ['images']
+ assert_response :success
+ assert_template 'browse'
+ assert_not_nil assigns(:entries)
+ assert_equal 2, assigns(:entries).size
+ entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
+ assert_not_nil entry
+ assert_equal 'file', entry.kind
+ assert_equal 'images/edit.png', entry.path
+ end
+
+ def test_changes
+ get :changes, :id => 3, :path => ['images', 'edit.png']
+ assert_response :success
+ assert_template 'changes'
+ assert_tag :tag => 'h2', :content => 'edit.png'
+ end
+
+ def test_entry_show
+ get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb']
+ assert_response :success
+ assert_template 'entry'
+ # Line 19
+ assert_tag :tag => 'th',
+ :content => /10/,
+ :attributes => { :class => /line-num/ },
+ :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
+ end
+
+ def test_entry_download
+ get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
+ assert_response :success
+ # File content
+ assert @response.body.include?('WITHOUT ANY WARRANTY')
+ end
+
+ def test_diff
+ # Full diff of changeset 4
+ get :diff, :id => 3, :rev => 4
+ assert_response :success
+ assert_template 'diff'
+ # Line 22 removed
+ assert_tag :tag => 'th',
+ :content => /22/,
+ :sibling => { :tag => 'td',
+ :attributes => { :class => /diff_out/ },
+ :content => /def remove/ }
+ end
+
+ def test_annotate
+ get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
+ assert_response :success
+ assert_template 'annotate'
+ # Line 23, revision 4
+ assert_tag :tag => 'th', :content => /23/,
+ :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /4/ } },
+ :sibling => { :tag => 'td', :content => /jsmith/ },
+ :sibling => { :tag => 'td', :content => /watcher =/ }
+ end
+end
diff --git a/rest_sys/test/functional/repositories_subversion_controller_test.rb b/rest_sys/test/functional/repositories_subversion_controller_test.rb
new file mode 100644
index 000000000..d7ce45640
--- /dev/null
+++ b/rest_sys/test/functional/repositories_subversion_controller_test.rb
@@ -0,0 +1,91 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'repositories_controller'
+
+# Re-raise errors caught by the controller.
+class RepositoriesController; def rescue_action(e) raise e end; end
+
+class RepositoriesSubversionControllerTest < Test::Unit::TestCase
+ fixtures :projects, :users, :roles, :members, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
+
+ # No '..' in the repository path for svn
+ REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository'
+
+ def setup
+ @controller = RepositoriesController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ end
+
+ if File.directory?(REPOSITORY_PATH)
+ def test_show
+ get :show, :id => 1
+ assert_response :success
+ assert_template 'show'
+ assert_not_nil assigns(:entries)
+ assert_not_nil assigns(:changesets)
+ end
+
+ def test_browse_root
+ get :browse, :id => 1
+ assert_response :success
+ assert_template 'browse'
+ assert_not_nil assigns(:entries)
+ entry = assigns(:entries).detect {|e| e.name == 'subversion_test'}
+ assert_equal 'dir', entry.kind
+ end
+
+ def test_browse_directory
+ get :browse, :id => 1, :path => ['subversion_test']
+ assert_response :success
+ assert_template 'browse'
+ assert_not_nil assigns(:entries)
+ entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
+ assert_equal 'file', entry.kind
+ assert_equal 'subversion_test/helloworld.c', entry.path
+ end
+
+ def test_entry
+ get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c']
+ assert_response :success
+ assert_template 'entry'
+ end
+
+ def test_entry_download
+ get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'], :format => 'raw'
+ assert_response :success
+ end
+
+ def test_diff
+ get :diff, :id => 1, :rev => 3
+ assert_response :success
+ assert_template 'diff'
+ end
+
+ def test_annotate
+ get :annotate, :id => 1, :path => ['subversion_test', 'helloworld.c']
+ assert_response :success
+ assert_template 'annotate'
+ end
+ else
+ puts "Subversion test repository NOT FOUND. Skipping functional tests !!!"
+ def test_fake; assert true end
+ end
+end
diff --git a/rest_sys/test/functional/search_controller_test.rb b/rest_sys/test/functional/search_controller_test.rb
new file mode 100644
index 000000000..330cd0de0
--- /dev/null
+++ b/rest_sys/test/functional/search_controller_test.rb
@@ -0,0 +1,65 @@
+require File.dirname(__FILE__) + '/../test_helper'
+require 'search_controller'
+
+# Re-raise errors caught by the controller.
+class SearchController; def rescue_action(e) raise e end; end
+
+class SearchControllerTest < Test::Unit::TestCase
+ fixtures :projects, :issues, :custom_fields, :custom_values
+
+ def setup
+ @controller = SearchController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ end
+
+ def test_search_for_projects
+ get :index
+ assert_response :success
+ assert_template 'index'
+
+ get :index, :q => "cook"
+ assert_response :success
+ assert_template 'index'
+ assert assigns(:results).include?(Project.find(1))
+ end
+
+ def test_search_without_searchable_custom_fields
+ CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}"
+
+ get :index, :id => 1
+ assert_response :success
+ assert_template 'index'
+ assert_not_nil assigns(:project)
+
+ get :index, :id => 1, :q => "can"
+ assert_response :success
+ assert_template 'index'
+ end
+
+ def test_search_with_searchable_custom_fields
+ get :index, :id => 1, :q => "stringforcustomfield"
+ assert_response :success
+ results = assigns(:results)
+ assert_not_nil results
+ assert_equal 1, results.size
+ assert results.include?(Issue.find(3))
+ end
+
+ def test_quick_jump_to_issue
+ # issue of a public project
+ get :index, :q => "3"
+ assert_redirected_to 'issues/show/3'
+
+ # issue of a private project
+ get :index, :q => "4"
+ assert_response :success
+ assert_template 'index'
+ end
+
+ def test_tokens_with_quotes
+ get :index, :id => 1, :q => '"good bye" hello "bye bye"'
+ assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens)
+ end
+end
diff --git a/rest_sys/test/functional/sys_api_test.rb b/rest_sys/test/functional/sys_api_test.rb
new file mode 100644
index 000000000..ec8d0964e
--- /dev/null
+++ b/rest_sys/test/functional/sys_api_test.rb
@@ -0,0 +1,31 @@
+require File.dirname(__FILE__) + '/../test_helper'
+require 'sys_controller'
+
+# Re-raise errors caught by the controller.
+class SysController; def rescue_action(e) raise e end; end
+
+class SysControllerTest < Test::Unit::TestCase
+ fixtures :projects, :repositories
+
+ def setup
+ @controller = SysController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ # Enable WS
+ Setting.sys_api_enabled = 1
+ end
+
+ def test_projects
+ result = invoke :projects
+ assert_equal Project.count, result.size
+ assert result.first.is_a?(Project)
+ end
+
+ def test_repository_created
+ project = Project.find(3)
+ assert_nil project.repository
+ assert invoke(:repository_created, project.identifier, 'http://localhost/svn')
+ project.reload
+ assert_not_nil project.repository
+ end
+end
diff --git a/rest_sys/test/functional/timelog_controller_test.rb b/rest_sys/test/functional/timelog_controller_test.rb
new file mode 100644
index 000000000..62f1a2e7f
--- /dev/null
+++ b/rest_sys/test/functional/timelog_controller_test.rb
@@ -0,0 +1,52 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'timelog_controller'
+
+# Re-raise errors caught by the controller.
+class TimelogController; def rescue_action(e) raise e end; end
+
+class TimelogControllerTest < Test::Unit::TestCase
+ fixtures :time_entries, :issues
+
+ def setup
+ @controller = TimelogController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ def test_report_no_criteria
+ get :report, :project_id => 1
+ assert_response :success
+ assert_template 'report'
+ end
+
+ def test_report_one_criteria
+ get :report, :project_id => 1, :period => "month", :date_from => "2007-01-01", :date_to => "2007-12-31", :criterias => ["member"]
+ assert_response :success
+ assert_template 'report'
+ assert_not_nil assigns(:hours)
+ end
+
+ def test_report_two_criterias
+ get :report, :project_id => 1, :period => "week", :date_from => "2007-01-01", :date_to => "2007-12-31", :criterias => ["member", "activity"]
+ assert_response :success
+ assert_template 'report'
+ assert_not_nil assigns(:hours)
+ end
+end
diff --git a/rest_sys/test/functional/users_controller_test.rb b/rest_sys/test/functional/users_controller_test.rb
new file mode 100644
index 000000000..8629a7131
--- /dev/null
+++ b/rest_sys/test/functional/users_controller_test.rb
@@ -0,0 +1,62 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'users_controller'
+
+# Re-raise errors caught by the controller.
+class UsersController; def rescue_action(e) raise e end; end
+
+class UsersControllerTest < Test::Unit::TestCase
+ fixtures :users, :projects, :members
+
+ def setup
+ @controller = UsersController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ @request.session[:user_id] = 1 # admin
+ end
+
+ def test_index
+ get :index
+ assert_response :success
+ assert_template 'list'
+ end
+
+ def test_list
+ get :list
+ assert_response :success
+ assert_template 'list'
+ assert_not_nil assigns(:users)
+ # active users only
+ assert_nil assigns(:users).detect {|u| !u.active?}
+ end
+
+ def test_edit_membership
+ post :edit_membership, :id => 2, :membership_id => 1,
+ :membership => { :role_id => 2}
+ assert_redirected_to 'users/edit/2'
+ assert_equal 2, Member.find(1).role_id
+ end
+
+ def test_destroy_membership
+ post :destroy_membership, :id => 2, :membership_id => 1
+ assert_redirected_to 'users/edit/2'
+ assert_nil Member.find_by_id(1)
+ end
+end
diff --git a/rest_sys/test/functional/versions_controller_test.rb b/rest_sys/test/functional/versions_controller_test.rb
new file mode 100644
index 000000000..17ebd3518
--- /dev/null
+++ b/rest_sys/test/functional/versions_controller_test.rb
@@ -0,0 +1,73 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'versions_controller'
+
+# Re-raise errors caught by the controller.
+class VersionsController; def rescue_action(e) raise e end; end
+
+class VersionsControllerTest < Test::Unit::TestCase
+ fixtures :projects, :versions, :users, :roles, :members, :enabled_modules
+
+ def setup
+ @controller = VersionsController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ end
+
+ def test_show
+ get :show, :id => 2
+ assert_response :success
+ assert_template 'show'
+ assert_not_nil assigns(:version)
+
+ assert_tag :tag => 'h2', :content => /1.0/
+ end
+
+ def test_get_edit
+ @request.session[:user_id] = 2
+ get :edit, :id => 2
+ assert_response :success
+ assert_template 'edit'
+ end
+
+ def test_post_edit
+ @request.session[:user_id] = 2
+ post :edit, :id => 2,
+ :version => { :name => 'New version name',
+ :effective_date => Date.today.strftime("%Y-%m-%d")}
+ assert_redirected_to 'projects/settings/1'
+ version = Version.find(2)
+ assert_equal 'New version name', version.name
+ assert_equal Date.today, version.effective_date
+ end
+
+ def test_destroy
+ @request.session[:user_id] = 2
+ post :destroy, :id => 2
+ assert_redirected_to 'projects/settings/1'
+ assert_nil Version.find_by_id(2)
+ end
+
+ def test_issue_status_by
+ xhr :get, :status_by, :id => 2
+ assert_response :success
+ assert_template '_issue_counts'
+ end
+end
diff --git a/rest_sys/test/functional/welcome_controller_test.rb b/rest_sys/test/functional/welcome_controller_test.rb
new file mode 100644
index 000000000..18146c6aa
--- /dev/null
+++ b/rest_sys/test/functional/welcome_controller_test.rb
@@ -0,0 +1,49 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'welcome_controller'
+
+# Re-raise errors caught by the controller.
+class WelcomeController; def rescue_action(e) raise e end; end
+
+class WelcomeControllerTest < Test::Unit::TestCase
+ fixtures :projects, :news
+
+ def setup
+ @controller = WelcomeController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ end
+
+ def test_index
+ get :index
+ assert_response :success
+ assert_template 'index'
+ assert_not_nil assigns(:news)
+ assert_not_nil assigns(:projects)
+ assert !assigns(:projects).include?(Project.find(:first, :conditions => {:is_public => false}))
+ end
+
+ def test_browser_language
+ Setting.default_language = 'en'
+ @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
+ get :index
+ assert_equal :fr, @controller.current_language
+ end
+end
diff --git a/rest_sys/test/functional/wiki_controller_test.rb b/rest_sys/test/functional/wiki_controller_test.rb
new file mode 100644
index 000000000..6ee5ab276
--- /dev/null
+++ b/rest_sys/test/functional/wiki_controller_test.rb
@@ -0,0 +1,145 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'wiki_controller'
+
+# Re-raise errors caught by the controller.
+class WikiController; def rescue_action(e) raise e end; end
+
+class WikiControllerTest < Test::Unit::TestCase
+ fixtures :projects, :users, :roles, :members, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
+
+ def setup
+ @controller = WikiController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ end
+
+ def test_show_start_page
+ get :index, :id => 1
+ assert_response :success
+ assert_template 'show'
+ assert_tag :tag => 'h1', :content => /CookBook documentation/
+ end
+
+ def test_show_page_with_name
+ get :index, :id => 1, :page => 'Another_page'
+ assert_response :success
+ assert_template 'show'
+ assert_tag :tag => 'h1', :content => /Another page/
+ end
+
+ def test_show_unexistent_page_without_edit_right
+ get :index, :id => 1, :page => 'Unexistent page'
+ assert_response 404
+ end
+
+ def test_show_unexistent_page_with_edit_right
+ @request.session[:user_id] = 2
+ get :index, :id => 1, :page => 'Unexistent page'
+ assert_response :success
+ assert_template 'edit'
+ end
+
+ def test_create_page
+ @request.session[:user_id] = 2
+ post :edit, :id => 1,
+ :page => 'New page',
+ :content => {:comments => 'Created the page',
+ :text => "h1. New page\n\nThis is a new page",
+ :version => 0}
+ assert_redirected_to 'wiki/1/New_page'
+ page = Project.find(1).wiki.find_page('New page')
+ assert !page.new_record?
+ assert_not_nil page.content
+ assert_equal 'Created the page', page.content.comments
+ end
+
+ def test_preview
+ @request.session[:user_id] = 2
+ xhr :post, :preview, :id => 1, :page => 'CookBook_documentation',
+ :content => { :comments => '',
+ :text => 'this is a *previewed text*',
+ :version => 3 }
+ assert_response :success
+ assert_template 'common/_preview'
+ assert_tag :tag => 'strong', :content => /previewed text/
+ end
+
+ def test_history
+ get :history, :id => 1, :page => 'CookBook_documentation'
+ assert_response :success
+ assert_template 'history'
+ assert_not_nil assigns(:versions)
+ assert_equal 3, assigns(:versions).size
+ end
+
+ def test_diff
+ get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1
+ assert_response :success
+ assert_template 'diff'
+ assert_tag :tag => 'span', :attributes => { :class => 'diff_in'},
+ :content => /updated/
+ end
+
+ def test_rename_with_redirect
+ @request.session[:user_id] = 2
+ post :rename, :id => 1, :page => 'Another_page',
+ :wiki_page => { :title => 'Another renamed page',
+ :redirect_existing_links => 1 }
+ assert_redirected_to 'wiki/1/Another_renamed_page'
+ wiki = Project.find(1).wiki
+ # Check redirects
+ assert_not_nil wiki.find_page('Another page')
+ assert_nil wiki.find_page('Another page', :with_redirect => false)
+ end
+
+ def test_rename_without_redirect
+ @request.session[:user_id] = 2
+ post :rename, :id => 1, :page => 'Another_page',
+ :wiki_page => { :title => 'Another renamed page',
+ :redirect_existing_links => "0" }
+ assert_redirected_to 'wiki/1/Another_renamed_page'
+ wiki = Project.find(1).wiki
+ # Check that there's no redirects
+ assert_nil wiki.find_page('Another page')
+ end
+
+ def test_destroy
+ @request.session[:user_id] = 2
+ post :destroy, :id => 1, :page => 'CookBook_documentation'
+ assert_redirected_to 'wiki/1/Page_index/special'
+ end
+
+ def test_page_index
+ get :special, :id => 1, :page => 'Page_index'
+ assert_response :success
+ assert_template 'special_page_index'
+ pages = assigns(:pages)
+ assert_not_nil pages
+ assert_equal 2, pages.size
+ assert_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation' },
+ :content => /CookBook documentation/
+ end
+
+ def test_not_found
+ get :index, :id => 999
+ assert_response 404
+ end
+end
diff --git a/rest_sys/test/functional/wikis_controller_test.rb b/rest_sys/test/functional/wikis_controller_test.rb
new file mode 100644
index 000000000..93ad7e32d
--- /dev/null
+++ b/rest_sys/test/functional/wikis_controller_test.rb
@@ -0,0 +1,56 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'wikis_controller'
+
+# Re-raise errors caught by the controller.
+class WikisController; def rescue_action(e) raise e end; end
+
+class WikisControllerTest < Test::Unit::TestCase
+ fixtures :projects, :users, :roles, :members, :enabled_modules, :wikis
+
+ def setup
+ @controller = WikisController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ User.current = nil
+ end
+
+ def test_create
+ @request.session[:user_id] = 1
+ assert_nil Project.find(3).wiki
+ post :edit, :id => 3, :wiki => { :start_page => 'Start page' }
+ assert_response :success
+ wiki = Project.find(3).wiki
+ assert_not_nil wiki
+ assert_equal 'Start page', wiki.start_page
+ end
+
+ def test_destroy
+ @request.session[:user_id] = 1
+ post :destroy, :id => 1, :confirm => 1
+ assert_redirected_to 'projects/settings/1'
+ assert_nil Project.find(1).wiki
+ end
+
+ def test_not_found
+ @request.session[:user_id] = 1
+ post :destroy, :id => 999, :confirm => 1
+ assert_response 404
+ end
+end
diff --git a/rest_sys/test/helper_testcase.rb b/rest_sys/test/helper_testcase.rb
new file mode 100644
index 000000000..aba6784a0
--- /dev/null
+++ b/rest_sys/test/helper_testcase.rb
@@ -0,0 +1,35 @@
+# Re-raise errors caught by the controller.
+class StubController < ApplicationController
+ def rescue_action(e) raise e end;
+ attr_accessor :request, :url
+end
+
+class HelperTestCase < Test::Unit::TestCase
+
+ # Add other helpers here if you need them
+ include ActionView::Helpers::ActiveRecordHelper
+ include ActionView::Helpers::TagHelper
+ include ActionView::Helpers::FormTagHelper
+ include ActionView::Helpers::FormOptionsHelper
+ include ActionView::Helpers::FormHelper
+ include ActionView::Helpers::UrlHelper
+ include ActionView::Helpers::AssetTagHelper
+ include ActionView::Helpers::PrototypeHelper
+
+ def setup
+ super
+
+ @request = ActionController::TestRequest.new
+ @controller = StubController.new
+ @controller.request = @request
+
+ # Fake url rewriter so we can test url_for
+ @controller.url = ActionController::UrlRewriter.new @request, {}
+
+ ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
+ end
+
+ def test_dummy
+ # do nothing - required by test/unit
+ end
+end
diff --git a/rest_sys/test/integration/account_test.rb b/rest_sys/test/integration/account_test.rb
new file mode 100644
index 000000000..e9d665d19
--- /dev/null
+++ b/rest_sys/test/integration/account_test.rb
@@ -0,0 +1,101 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require "#{File.dirname(__FILE__)}/../test_helper"
+
+class AccountTest < ActionController::IntegrationTest
+ fixtures :users
+
+ # Replace this with your real tests.
+ def test_login
+ get "my/page"
+ assert_redirected_to "account/login"
+ log_user('jsmith', 'jsmith')
+
+ get "my/account"
+ assert_response :success
+ assert_template "my/account"
+ end
+
+ def test_lost_password
+ Token.delete_all
+
+ get "account/lost_password"
+ assert_response :success
+ assert_template "account/lost_password"
+
+ post "account/lost_password", :mail => 'jsmith@somenet.foo'
+ assert_redirected_to "account/login"
+
+ token = Token.find(:first)
+ assert_equal 'recovery', token.action
+ assert_equal 'jsmith@somenet.foo', token.user.mail
+ assert !token.expired?
+
+ get "account/lost_password", :token => token.value
+ assert_response :success
+ assert_template "account/password_recovery"
+
+ post "account/lost_password", :token => token.value, :new_password => 'newpass', :new_password_confirmation => 'newpass'
+ assert_redirected_to "account/login"
+ assert_equal 'Password was successfully updated.', flash[:notice]
+
+ log_user('jsmith', 'newpass')
+ assert_equal 0, Token.count
+ end
+
+ def test_register_with_automatic_activation
+ Setting.self_registration = '3'
+
+ get 'account/register'
+ assert_response :success
+ assert_template 'account/register'
+
+ post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar"},
+ :password => "newpass", :password_confirmation => "newpass"
+ assert_redirected_to 'account/login'
+ log_user('newuser', 'newpass')
+ end
+
+ def test_register_with_manual_activation
+ Setting.self_registration = '2'
+
+ post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar"},
+ :password => "newpass", :password_confirmation => "newpass"
+ assert_redirected_to 'account/login'
+ assert !User.find_by_login('newuser').active?
+ end
+
+ def test_register_with_email_activation
+ Setting.self_registration = '1'
+ Token.delete_all
+
+ post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar"},
+ :password => "newpass", :password_confirmation => "newpass"
+ assert_redirected_to 'account/login'
+ assert !User.find_by_login('newuser').active?
+
+ token = Token.find(:first)
+ assert_equal 'register', token.action
+ assert_equal 'newuser@foo.bar', token.user.mail
+ assert !token.expired?
+
+ get 'account/activate', :token => token.value
+ assert_redirected_to 'account/login'
+ log_user('newuser', 'newpass')
+ end
+end
diff --git a/rest_sys/test/integration/admin_test.rb b/rest_sys/test/integration/admin_test.rb
new file mode 100644
index 000000000..a424247cc
--- /dev/null
+++ b/rest_sys/test/integration/admin_test.rb
@@ -0,0 +1,65 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require "#{File.dirname(__FILE__)}/../test_helper"
+
+class AdminTest < ActionController::IntegrationTest
+ fixtures :users
+
+ def test_add_user
+ log_user("admin", "admin")
+ get "/users/add"
+ assert_response :success
+ assert_template "users/add"
+ post "/users/add", :user => { :login => "psmith", :firstname => "Paul", :lastname => "Smith", :mail => "psmith@somenet.foo", :language => "en" }, :password => "psmith09", :password_confirmation => "psmith09"
+ assert_redirected_to "users/list"
+
+ user = User.find_by_login("psmith")
+ assert_kind_of User, user
+ logged_user = User.try_to_login("psmith", "psmith09")
+ assert_kind_of User, logged_user
+ assert_equal "Paul", logged_user.firstname
+
+ post "users/edit", :id => user.id, :user => { :status => User::STATUS_LOCKED }
+ assert_redirected_to "users/list"
+ locked_user = User.try_to_login("psmith", "psmith09")
+ assert_equal nil, locked_user
+ end
+
+ def test_add_project
+ log_user("admin", "admin")
+ get "projects/add"
+ assert_response :success
+ assert_template "projects/add"
+ post "projects/add", :project => { :name => "blog",
+ :description => "weblog",
+ :identifier => "blog",
+ :is_public => 1 },
+ 'custom_fields[3]' => 'Beta'
+ assert_redirected_to "admin/projects"
+ assert_equal 'Successful creation.', flash[:notice]
+
+ project = Project.find_by_name("blog")
+ assert_kind_of Project, project
+ assert_equal "weblog", project.description
+ assert_equal true, project.is_public?
+
+ get "admin/projects"
+ assert_response :success
+ assert_template "admin/projects"
+ end
+end
diff --git a/rest_sys/test/integration/issues_test.rb b/rest_sys/test/integration/issues_test.rb
new file mode 100644
index 000000000..eac407b1b
--- /dev/null
+++ b/rest_sys/test/integration/issues_test.rb
@@ -0,0 +1,58 @@
+require "#{File.dirname(__FILE__)}/../test_helper"
+
+class IssuesTest < ActionController::IntegrationTest
+ fixtures :projects, :users, :trackers, :issue_statuses, :issues, :enumerations
+
+ # create an issue
+ def test_add_issue
+ log_user('jsmith', 'jsmith')
+ get "projects/add_issue/1", :tracker_id => "1"
+ assert_response :success
+ assert_template "projects/add_issue"
+
+ post "projects/add_issue/1", :tracker_id => "1",
+ :issue => { :start_date => "2006-12-26",
+ :priority_id => "3",
+ :subject => "new test issue",
+ :category_id => "",
+ :description => "new issue",
+ :done_ratio => "0",
+ :due_date => "",
+ :assigned_to_id => "" }
+ # find created issue
+ issue = Issue.find_by_subject("new test issue")
+ assert_kind_of Issue, issue
+
+ # check redirection
+ assert_redirected_to "projects/1/issues"
+ follow_redirect!
+ assert assigns(:issues).include?(issue)
+
+ # check issue attributes
+ assert_equal 'jsmith', issue.author.login
+ assert_equal 1, issue.project.id
+ assert_equal 1, issue.status.id
+ end
+
+ # add then remove 2 attachments to an issue
+ def test_issue_attachements
+ log_user('jsmith', 'jsmith')
+
+ post "issues/add_note/1", { :notes => 'Some notes', 'attachments[]' => ActionController::TestUploadedFile.new(Test::Unit::TestCase.fixture_path + '/files/testfile.txt', 'text/plain') }
+ assert_redirected_to "issues/show/1"
+
+ # make sure attachment was saved
+ attachment = Issue.find(1).attachments.find_by_filename("testfile.txt")
+ assert_kind_of Attachment, attachment
+ assert_equal Issue.find(1), attachment.container
+ # verify the size of the attachment stored in db
+ #assert_equal file_data_1.length, attachment.filesize
+ # verify that the attachment was written to disk
+ assert File.exist?(attachment.diskfile)
+
+ # remove the attachments
+ Issue.find(1).attachments.each(&:destroy)
+ assert_equal 0, Issue.find(1).attachments.length
+ end
+
+end
diff --git a/rest_sys/test/integration/projects_test.rb b/rest_sys/test/integration/projects_test.rb
new file mode 100644
index 000000000..e56bee484
--- /dev/null
+++ b/rest_sys/test/integration/projects_test.rb
@@ -0,0 +1,44 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require "#{File.dirname(__FILE__)}/../test_helper"
+
+class ProjectsTest < ActionController::IntegrationTest
+ fixtures :projects, :users, :members
+
+ def test_archive_project
+ subproject = Project.find(1).children.first
+ log_user("admin", "admin")
+ get "admin/projects"
+ assert_response :success
+ assert_template "admin/projects"
+ post "projects/archive", :id => 1
+ assert_redirected_to "admin/projects"
+ assert !Project.find(1).active?
+
+ get "projects/show", :id => 1
+ assert_response 403
+ get "projects/show", :id => subproject.id
+ assert_response 403
+
+ post "projects/unarchive", :id => 1
+ assert_redirected_to "admin/projects"
+ assert Project.find(1).active?
+ get "projects/show", :id => 1
+ assert_response :success
+ end
+end
diff --git a/rest_sys/test/test_helper.rb b/rest_sys/test/test_helper.rb
new file mode 100644
index 000000000..542d4ce72
--- /dev/null
+++ b/rest_sys/test/test_helper.rb
@@ -0,0 +1,73 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ENV["RAILS_ENV"] ||= "test"
+require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
+require 'test_help'
+require File.expand_path(File.dirname(__FILE__) + '/helper_testcase')
+
+class Test::Unit::TestCase
+ # Transactional fixtures accelerate your tests by wrapping each test method
+ # in a transaction that's rolled back on completion. This ensures that the
+ # test database remains unchanged so your fixtures don't have to be reloaded
+ # between every test method. Fewer database queries means faster tests.
+ #
+ # Read Mike Clark's excellent walkthrough at
+ # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
+ #
+ # Every Active Record database supports transactions except MyISAM tables
+ # in MySQL. Turn off transactional fixtures in this case; however, if you
+ # don't care one way or the other, switching from MyISAM to InnoDB tables
+ # is recommended.
+ self.use_transactional_fixtures = true
+
+ # Instantiated fixtures are slow, but give you @david where otherwise you
+ # would need people(:david). If you don't want to migrate your existing
+ # test cases which use the @david style and don't mind the speed hit (each
+ # instantiated fixtures translates to a database query per test method),
+ # then set this back to true.
+ self.use_instantiated_fixtures = false
+
+ # Add more helper methods to be used by all tests here...
+
+ def log_user(login, password)
+ get "/account/login"
+ assert_equal nil, session[:user_id]
+ assert_response :success
+ assert_template "account/login"
+ post "/account/login", :login => login, :password => password
+ assert_redirected_to "my/page"
+ assert_equal login, User.find(session[:user_id]).login
+ end
+end
+
+
+# ActionController::TestUploadedFile bug
+# see http://dev.rubyonrails.org/ticket/4635
+class String
+ def original_filename
+ "testfile.txt"
+ end
+
+ def content_type
+ "text/plain"
+ end
+
+ def read
+ self.to_s
+ end
+end
\ No newline at end of file
diff --git a/rest_sys/test/unit/board_test.rb b/rest_sys/test/unit/board_test.rb
new file mode 100644
index 000000000..3ba4b2d97
--- /dev/null
+++ b/rest_sys/test/unit/board_test.rb
@@ -0,0 +1,30 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class BoardTest < Test::Unit::TestCase
+ fixtures :projects, :boards, :messages
+
+ def setup
+ @project = Project.find(1)
+ end
+
+ def test_create
+ board = Board.new(:project => @project, :name => 'Test board', :description => 'Test board description')
+ assert board.save
+ board.reload
+ assert_equal 'Test board', board.name
+ assert_equal 'Test board description', board.description
+ assert_equal @project, board.project
+ assert_equal 0, board.topics_count
+ assert_equal 0, board.messages_count
+ assert_nil board.last_message
+ # last position
+ assert_equal @project.boards.size, board.position
+ end
+
+ def test_destroy
+ board = Board.find(1)
+ assert board.destroy
+ # make sure that the associated messages are removed
+ assert_equal 0, Message.count(:conditions => {:board_id => 1})
+ end
+end
diff --git a/rest_sys/test/unit/calendar_test.rb b/rest_sys/test/unit/calendar_test.rb
new file mode 100644
index 000000000..98d856921
--- /dev/null
+++ b/rest_sys/test/unit/calendar_test.rb
@@ -0,0 +1,43 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class CalendarTest < Test::Unit::TestCase
+
+ def test_monthly
+ c = Redmine::Helpers::Calendar.new(Date.today, :fr, :month)
+ assert_equal [1, 7], [c.startdt.cwday, c.enddt.cwday]
+
+ c = Redmine::Helpers::Calendar.new('2007-07-14'.to_date, :fr, :month)
+ assert_equal ['2007-06-25'.to_date, '2007-08-05'.to_date], [c.startdt, c.enddt]
+
+ c = Redmine::Helpers::Calendar.new(Date.today, :en, :month)
+ assert_equal [7, 6], [c.startdt.cwday, c.enddt.cwday]
+ end
+
+ def test_weekly
+ c = Redmine::Helpers::Calendar.new(Date.today, :fr, :week)
+ assert_equal [1, 7], [c.startdt.cwday, c.enddt.cwday]
+
+ c = Redmine::Helpers::Calendar.new('2007-07-14'.to_date, :fr, :week)
+ assert_equal ['2007-07-09'.to_date, '2007-07-15'.to_date], [c.startdt, c.enddt]
+
+ c = Redmine::Helpers::Calendar.new(Date.today, :en, :week)
+ assert_equal [7, 6], [c.startdt.cwday, c.enddt.cwday]
+ end
+end
diff --git a/rest_sys/test/unit/changeset_test.rb b/rest_sys/test/unit/changeset_test.rb
new file mode 100644
index 000000000..2442a8b8c
--- /dev/null
+++ b/rest_sys/test/unit/changeset_test.rb
@@ -0,0 +1,62 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class ChangesetTest < Test::Unit::TestCase
+ fixtures :projects, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :users, :members, :trackers
+
+ def setup
+ end
+
+ def test_ref_keywords_any
+ Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id
+ Setting.commit_fix_done_ratio = '90'
+ Setting.commit_ref_keywords = '*'
+ Setting.commit_fix_keywords = 'fixes , closes'
+
+ c = Changeset.new(:repository => Project.find(1).repository,
+ :committed_on => Time.now,
+ :comments => 'New commit (#2). Fixes #1')
+ c.scan_comment_for_issue_ids
+
+ assert_equal [1, 2], c.issue_ids.sort
+ fixed = Issue.find(1)
+ assert fixed.closed?
+ assert_equal 90, fixed.done_ratio
+ end
+
+ def test_previous
+ changeset = Changeset.find_by_revision(3)
+ assert_equal Changeset.find_by_revision(2), changeset.previous
+ end
+
+ def test_previous_nil
+ changeset = Changeset.find_by_revision(1)
+ assert_nil changeset.previous
+ end
+
+ def test_next
+ changeset = Changeset.find_by_revision(2)
+ assert_equal Changeset.find_by_revision(3), changeset.next
+ end
+
+ def test_next_nil
+ changeset = Changeset.find_by_revision(4)
+ assert_nil changeset.next
+ end
+end
diff --git a/rest_sys/test/unit/comment_test.rb b/rest_sys/test/unit/comment_test.rb
new file mode 100644
index 000000000..c07ee8273
--- /dev/null
+++ b/rest_sys/test/unit/comment_test.rb
@@ -0,0 +1,47 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class CommentTest < Test::Unit::TestCase
+ fixtures :users, :news, :comments
+
+ def setup
+ @jsmith = User.find(2)
+ @news = News.find(1)
+ end
+
+ def test_create
+ comment = Comment.new(:commented => @news, :author => @jsmith, :comments => "my comment")
+ assert comment.save
+ @news.reload
+ assert_equal 2, @news.comments_count
+ end
+
+ def test_validate
+ comment = Comment.new(:commented => @news)
+ assert !comment.save
+ assert_equal 2, comment.errors.length
+ end
+
+ def test_destroy
+ comment = Comment.find(1)
+ assert comment.destroy
+ @news.reload
+ assert_equal 0, @news.comments_count
+ end
+end
diff --git a/rest_sys/test/unit/custom_field_test.rb b/rest_sys/test/unit/custom_field_test.rb
new file mode 100644
index 000000000..1b9c9aea9
--- /dev/null
+++ b/rest_sys/test/unit/custom_field_test.rb
@@ -0,0 +1,32 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class CustomFieldTest < Test::Unit::TestCase
+ fixtures :custom_fields
+
+ def test_create
+ field = UserCustomField.new(:name => 'Money money money', :field_format => 'float')
+ assert field.save
+ end
+
+ def test_destroy
+ field = CustomField.find(1)
+ assert field.destroy
+ end
+end
diff --git a/rest_sys/test/unit/custom_value_test.rb b/rest_sys/test/unit/custom_value_test.rb
new file mode 100644
index 000000000..24d09fe49
--- /dev/null
+++ b/rest_sys/test/unit/custom_value_test.rb
@@ -0,0 +1,34 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class CustomValueTest < Test::Unit::TestCase
+ fixtures :custom_fields
+
+ def test_float_field
+ v = CustomValue.new(:customized => User.find(:first), :custom_field => UserCustomField.find_by_name('Money'))
+ v.value = '11.2'
+ assert v.save
+ v.value = ''
+ assert v.save
+ v.value = '-6.250'
+ assert v.save
+ v.value = '6a'
+ assert !v.save
+ end
+end
diff --git a/rest_sys/test/unit/helpers/application_helper_test.rb b/rest_sys/test/unit/helpers/application_helper_test.rb
new file mode 100644
index 000000000..06446d15e
--- /dev/null
+++ b/rest_sys/test/unit/helpers/application_helper_test.rb
@@ -0,0 +1,106 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../../test_helper'
+
+class ApplicationHelperTest < HelperTestCase
+ include ApplicationHelper
+ include ActionView::Helpers::TextHelper
+ fixtures :projects, :repositories, :changesets, :trackers, :issue_statuses, :issues
+
+ def setup
+ super
+ end
+
+ def test_auto_links
+ to_test = {
+ 'http://foo.bar' => 'http://foo.bar ',
+ 'http://foo.bar/~user' => 'http://foo.bar/~user ',
+ 'http://foo.bar.' => 'http://foo.bar .',
+ 'http://foo.bar/foo.bar#foo.bar.' => 'http://foo.bar/foo.bar#foo.bar .',
+ 'www.foo.bar' => 'www.foo.bar ',
+ 'http://foo.bar/page?p=1&t=z&s=' => 'http://foo.bar/page?p=1&t=z&s= ',
+ 'http://foo.bar/page#125' => 'http://foo.bar/page#125 '
+ }
+ to_test.each { |text, result| assert_equal "#{result}
", textilizable(text) }
+ end
+
+ def test_auto_mailto
+ assert_equal 'test@foo.bar
',
+ textilizable('test@foo.bar')
+ end
+
+ def test_textile_tags
+ to_test = {
+ # inline images
+ '!http://foo.bar/image.jpg!' => ' ',
+ 'floating !>http://foo.bar/image.jpg!' => 'floating ',
+ # textile links
+ 'This is a "link":http://foo.bar' => 'This is a link ',
+ 'This is an intern "link":/foo/bar' => 'This is an intern link ',
+ '"link (Link title)":http://foo.bar' => 'link '
+ }
+ to_test.each { |text, result| assert_equal "#{result}
", textilizable(text) }
+ end
+
+ def test_redmine_links
+ issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3},
+ :class => 'issue', :title => 'Error 281 when updating a recipe (New)')
+ changeset_link = link_to('r1', {:controller => 'repositories', :action => 'revision', :id => 1, :rev => 1},
+ :class => 'changeset', :title => 'My very first commit')
+
+ to_test = {
+ '#3, #3 and #3.' => "#{issue_link}, #{issue_link} and #{issue_link}.",
+ 'r1' => changeset_link
+ }
+ @project = Project.find(1)
+ to_test.each { |text, result| assert_equal "#{result}
", textilizable(text) }
+ end
+
+ def test_macro_hello_world
+ text = "{{hello_world}}"
+ assert textilizable(text).match(/Hello world!/)
+ end
+
+ def test_date_format_default
+ today = Date.today
+ Setting.date_format = ''
+ assert_equal l_date(today), format_date(today)
+ end
+
+ def test_date_format
+ today = Date.today
+ Setting.date_format = '%d %m %Y'
+ assert_equal today.strftime('%d %m %Y'), format_date(today)
+ end
+
+ def test_time_format_default
+ now = Time.now
+ Setting.date_format = ''
+ Setting.time_format = ''
+ assert_equal l_datetime(now), format_time(now)
+ assert_equal l_time(now), format_time(now, false)
+ end
+
+ def test_time_format
+ now = Time.now
+ Setting.date_format = '%d %m %Y'
+ Setting.time_format = '%H %M'
+ assert_equal now.strftime('%d %m %Y %H %M'), format_time(now)
+ assert_equal now.strftime('%H %M'), format_time(now, false)
+ end
+end
diff --git a/rest_sys/test/unit/helpers/projects_helper_test.rb b/rest_sys/test/unit/helpers/projects_helper_test.rb
new file mode 100644
index 000000000..d76d92bc9
--- /dev/null
+++ b/rest_sys/test/unit/helpers/projects_helper_test.rb
@@ -0,0 +1,41 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../../test_helper'
+
+class ProjectsHelperTest < HelperTestCase
+ include ProjectsHelper
+ include ActionView::Helpers::TextHelper
+ fixtures :projects, :trackers, :issue_statuses, :issues, :enumerations, :users, :issue_categories
+
+ def setup
+ super
+ end
+
+ if Object.const_defined?(:Magick)
+ def test_gantt_image
+ assert gantt_image(Issue.find(:all, :conditions => "start_date IS NOT NULL AND due_date IS NOT NULL"), Date.today, 6, 2)
+ end
+
+ def test_gantt_image_with_days
+ assert gantt_image(Issue.find(:all, :conditions => "start_date IS NOT NULL AND due_date IS NOT NULL"), Date.today, 3, 4)
+ end
+ else
+ puts "RMagick not installed. Skipping tests !!!"
+ def test_fake; assert true end
+ end
+end
diff --git a/rest_sys/test/unit/issue_category_test.rb b/rest_sys/test/unit/issue_category_test.rb
new file mode 100644
index 000000000..a6edb3c7b
--- /dev/null
+++ b/rest_sys/test/unit/issue_category_test.rb
@@ -0,0 +1,41 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class IssueCategoryTest < Test::Unit::TestCase
+ fixtures :issue_categories, :issues
+
+ def setup
+ @category = IssueCategory.find(1)
+ end
+
+ def test_destroy
+ issue = @category.issues.first
+ @category.destroy
+ # Make sure the category was nullified on the issue
+ assert_nil issue.reload.category
+ end
+
+ def test_destroy_with_reassign
+ issue = @category.issues.first
+ reassign_to = IssueCategory.find(2)
+ @category.destroy(reassign_to)
+ # Make sure the issue was reassigned
+ assert_equal reassign_to, issue.reload.category
+ end
+end
diff --git a/rest_sys/test/unit/issue_status_test.rb b/rest_sys/test/unit/issue_status_test.rb
new file mode 100644
index 000000000..404bc36ba
--- /dev/null
+++ b/rest_sys/test/unit/issue_status_test.rb
@@ -0,0 +1,49 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class IssueStatusTest < Test::Unit::TestCase
+ fixtures :issue_statuses
+
+ def test_create
+ status = IssueStatus.new :name => "Assigned"
+ assert !status.save
+ # status name uniqueness
+ assert_equal 1, status.errors.count
+
+ status.name = "Test Status"
+ assert status.save
+ assert !status.is_default
+ end
+
+ def test_default
+ status = IssueStatus.default
+ assert_kind_of IssueStatus, status
+ end
+
+ def test_change_default
+ status = IssueStatus.find(2)
+ assert !status.is_default
+ status.is_default = true
+ assert status.save
+ status.reload
+
+ assert_equal status, IssueStatus.default
+ assert !IssueStatus.find(1).is_default
+ end
+end
diff --git a/rest_sys/test/unit/issue_test.rb b/rest_sys/test/unit/issue_test.rb
new file mode 100644
index 000000000..da91dd02c
--- /dev/null
+++ b/rest_sys/test/unit/issue_test.rb
@@ -0,0 +1,73 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class IssueTest < Test::Unit::TestCase
+ fixtures :projects, :users, :members, :trackers, :projects_trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :time_entries
+
+ def test_category_based_assignment
+ issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.get_values('IPRI').first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1)
+ assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
+ end
+
+ def test_copy
+ issue = Issue.new.copy_from(1)
+ assert issue.save
+ issue.reload
+ orig = Issue.find(1)
+ assert_equal orig.subject, issue.subject
+ assert_equal orig.tracker, issue.tracker
+ assert_equal orig.custom_values.first.value, issue.custom_values.first.value
+ end
+
+ def test_close_duplicates
+ # Create 3 issues
+ issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => Enumeration.get_values('IPRI').first, :subject => 'Duplicates test', :description => 'Duplicates test')
+ assert issue1.save
+ issue2 = issue1.clone
+ assert issue2.save
+ issue3 = issue1.clone
+ assert issue3.save
+
+ # 2 is a dupe of 1
+ IssueRelation.create(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_DUPLICATES)
+ # And 3 is a dupe of 2
+ IssueRelation.create(:issue_from => issue2, :issue_to => issue3, :relation_type => IssueRelation::TYPE_DUPLICATES)
+
+ assert issue1.reload.duplicates.include?(issue2)
+
+ # Closing issue 1
+ issue1.init_journal(User.find(:first), "Closing issue1")
+ issue1.status = IssueStatus.find :first, :conditions => {:is_closed => true}
+ assert issue1.save
+ # 2 and 3 should be also closed
+ assert issue2.reload.closed?
+ assert issue3.reload.closed?
+ end
+
+ def test_move_to_another_project
+ issue = Issue.find(1)
+ assert issue.move_to(Project.find(2))
+ issue.reload
+ assert_equal 2, issue.project_id
+ # Category removed
+ assert_nil issue.category
+ # Make sure time entries were move to the target project
+ assert_equal 2, issue.time_entries.first.project_id
+ end
+end
diff --git a/rest_sys/test/unit/journal_test.rb b/rest_sys/test/unit/journal_test.rb
new file mode 100644
index 000000000..b177f3198
--- /dev/null
+++ b/rest_sys/test/unit/journal_test.rb
@@ -0,0 +1,39 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class JournalTest < Test::Unit::TestCase
+ fixtures :issues, :issue_statuses, :journals, :journal_details
+
+ def setup
+ @journal = Journal.find 1
+ end
+
+ def test_journalized_is_an_issue
+ issue = @journal.issue
+ assert_kind_of Issue, issue
+ assert_equal 1, issue.id
+ end
+
+ def test_new_status
+ status = @journal.new_status
+ assert_not_nil status
+ assert_kind_of IssueStatus, status
+ assert_equal 2, status.id
+ end
+end
diff --git a/rest_sys/test/unit/mail_handler_test.rb b/rest_sys/test/unit/mail_handler_test.rb
new file mode 100644
index 000000000..d0fc68de8
--- /dev/null
+++ b/rest_sys/test/unit/mail_handler_test.rb
@@ -0,0 +1,57 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class MailHandlerTest < Test::Unit::TestCase
+ fixtures :users, :projects, :enabled_modules, :roles, :members, :issues, :trackers, :enumerations
+
+ FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
+ CHARSET = "utf-8"
+
+ include ActionMailer::Quoting
+
+ def setup
+ ActionMailer::Base.delivery_method = :test
+ ActionMailer::Base.perform_deliveries = true
+ ActionMailer::Base.deliveries = []
+
+ @expected = TMail::Mail.new
+ @expected.set_content_type "text", "plain", { "charset" => CHARSET }
+ @expected.mime_version = '1.0'
+ end
+
+ def test_add_note_to_issue
+ raw = read_fixture("add_note_to_issue.txt").join
+ MailHandler.receive(raw)
+
+ issue = Issue.find(2)
+ journal = issue.journals.find(:first, :order => "created_on DESC")
+ assert journal
+ assert_equal User.find_by_mail("jsmith@somenet.foo"), journal.user
+ assert_equal "Note added by mail", journal.notes
+ end
+
+ private
+ def read_fixture(action)
+ IO.readlines("#{FIXTURES_PATH}/mail_handler/#{action}")
+ end
+
+ def encode(subject)
+ quoted_printable(subject, CHARSET)
+ end
+end
diff --git a/rest_sys/test/unit/mailer_test.rb b/rest_sys/test/unit/mailer_test.rb
new file mode 100644
index 000000000..096551ee5
--- /dev/null
+++ b/rest_sys/test/unit/mailer_test.rb
@@ -0,0 +1,100 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class MailerTest < Test::Unit::TestCase
+ fixtures :projects, :issues, :users, :members, :documents, :attachments, :news, :tokens, :journals, :journal_details, :trackers, :issue_statuses, :enumerations
+
+ # test mailer methods for each language
+ def test_issue_add
+ issue = Issue.find(1)
+ GLoc.valid_languages.each do |lang|
+ Setting.default_language = lang.to_s
+ assert Mailer.deliver_issue_add(issue)
+ end
+ end
+
+ def test_issue_edit
+ journal = Journal.find(1)
+ GLoc.valid_languages.each do |lang|
+ Setting.default_language = lang.to_s
+ assert Mailer.deliver_issue_edit(journal)
+ end
+ end
+
+ def test_document_added
+ document = Document.find(1)
+ GLoc.valid_languages.each do |lang|
+ Setting.default_language = lang.to_s
+ assert Mailer.deliver_document_added(document)
+ end
+ end
+
+ def test_attachments_added
+ attachements = [ Attachment.find_by_container_type('Document') ]
+ GLoc.valid_languages.each do |lang|
+ Setting.default_language = lang.to_s
+ assert Mailer.deliver_attachments_added(attachements)
+ end
+ end
+
+ def test_news_added
+ news = News.find(:first)
+ GLoc.valid_languages.each do |lang|
+ Setting.default_language = lang.to_s
+ assert Mailer.deliver_news_added(news)
+ end
+ end
+
+ def test_message_posted
+ message = Message.find(:first)
+ recipients = ([message.root] + message.root.children).collect {|m| m.author.mail if m.author}
+ recipients = recipients.compact.uniq
+ GLoc.valid_languages.each do |lang|
+ Setting.default_language = lang.to_s
+ assert Mailer.deliver_message_posted(message, recipients)
+ end
+ end
+
+ def test_account_information
+ user = User.find(:first)
+ GLoc.valid_languages.each do |lang|
+ user.update_attribute :language, lang.to_s
+ user.reload
+ assert Mailer.deliver_account_information(user, 'pAsswORd')
+ end
+ end
+
+ def test_lost_password
+ token = Token.find(2)
+ GLoc.valid_languages.each do |lang|
+ token.user.update_attribute :language, lang.to_s
+ token.reload
+ assert Mailer.deliver_lost_password(token)
+ end
+ end
+
+ def test_register
+ token = Token.find(1)
+ GLoc.valid_languages.each do |lang|
+ token.user.update_attribute :language, lang.to_s
+ token.reload
+ assert Mailer.deliver_register(token)
+ end
+ end
+end
diff --git a/rest_sys/test/unit/member_test.rb b/rest_sys/test/unit/member_test.rb
new file mode 100644
index 000000000..079782306
--- /dev/null
+++ b/rest_sys/test/unit/member_test.rb
@@ -0,0 +1,51 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class MemberTest < Test::Unit::TestCase
+ fixtures :users, :projects, :roles, :members
+
+ def setup
+ @jsmith = Member.find(1)
+ end
+
+ def test_create
+ member = Member.new(:project_id => 1, :user_id => 4, :role_id => 1)
+ assert member.save
+ end
+
+ def test_update
+ assert_equal "eCookbook", @jsmith.project.name
+ assert_equal "Manager", @jsmith.role.name
+ assert_equal "jsmith", @jsmith.user.login
+
+ @jsmith.role = Role.find(2)
+ assert @jsmith.save
+ end
+
+ def test_validate
+ member = Member.new(:project_id => 1, :user_id => 2, :role_id =>2)
+ # same use can't have more than one role for a project
+ assert !member.save
+ end
+
+ def test_destroy
+ @jsmith.destroy
+ assert_raise(ActiveRecord::RecordNotFound) { Member.find(@jsmith.id) }
+ end
+end
diff --git a/rest_sys/test/unit/message_test.rb b/rest_sys/test/unit/message_test.rb
new file mode 100644
index 000000000..82ed3fe13
--- /dev/null
+++ b/rest_sys/test/unit/message_test.rb
@@ -0,0 +1,70 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class MessageTest < Test::Unit::TestCase
+ fixtures :projects, :boards, :messages
+
+ def setup
+ @board = Board.find(1)
+ @user = User.find(1)
+ end
+
+ def test_create
+ topics_count = @board.topics_count
+ messages_count = @board.messages_count
+
+ message = Message.new(:board => @board, :subject => 'Test message', :content => 'Test message content', :author => @user)
+ assert message.save
+ @board.reload
+ # topics count incremented
+ assert_equal topics_count+1, @board[:topics_count]
+ # messages count incremented
+ assert_equal messages_count+1, @board[:messages_count]
+ assert_equal message, @board.last_message
+ end
+
+ def test_reply
+ topics_count = @board.topics_count
+ messages_count = @board.messages_count
+ @message = Message.find(1)
+ replies_count = @message.replies_count
+
+ reply = Message.new(:board => @board, :subject => 'Test reply', :content => 'Test reply content', :parent => @message, :author => @user)
+ assert reply.save
+ @board.reload
+ # same topics count
+ assert_equal topics_count, @board[:topics_count]
+ # messages count incremented
+ assert_equal messages_count+1, @board[:messages_count]
+ assert_equal reply, @board.last_message
+ @message.reload
+ # replies count incremented
+ assert_equal replies_count+1, @message[:replies_count]
+ assert_equal reply, @message.last_reply
+ end
+
+ def test_destroy_topic
+ message = Message.find(1)
+ board = message.board
+ topics_count, messages_count = board.topics_count, board.messages_count
+ assert message.destroy
+ board.reload
+
+ # Replies deleted
+ assert Message.find_all_by_parent_id(1).empty?
+ # Checks counters
+ assert_equal topics_count - 1, board.topics_count
+ assert_equal messages_count - 3, board.messages_count
+ end
+
+ def test_destroy_reply
+ message = Message.find(5)
+ board = message.board
+ topics_count, messages_count = board.topics_count, board.messages_count
+ assert message.destroy
+ board.reload
+
+ # Checks counters
+ assert_equal topics_count, board.topics_count
+ assert_equal messages_count - 1, board.messages_count
+ end
+end
diff --git a/rest_sys/test/unit/project_test.rb b/rest_sys/test/unit/project_test.rb
new file mode 100644
index 000000000..62ba2b02d
--- /dev/null
+++ b/rest_sys/test/unit/project_test.rb
@@ -0,0 +1,124 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class ProjectTest < Test::Unit::TestCase
+ fixtures :projects, :issues, :issue_statuses, :journals, :journal_details, :users, :members, :roles
+
+ def setup
+ @ecookbook = Project.find(1)
+ @ecookbook_sub1 = Project.find(3)
+ end
+
+ def test_truth
+ assert_kind_of Project, @ecookbook
+ assert_equal "eCookbook", @ecookbook.name
+ end
+
+ def test_update
+ assert_equal "eCookbook", @ecookbook.name
+ @ecookbook.name = "eCook"
+ assert @ecookbook.save, @ecookbook.errors.full_messages.join("; ")
+ @ecookbook.reload
+ assert_equal "eCook", @ecookbook.name
+ end
+
+ def test_validate
+ @ecookbook.name = ""
+ assert !@ecookbook.save
+ assert_equal 1, @ecookbook.errors.count
+ assert_equal "activerecord_error_blank", @ecookbook.errors.on(:name)
+ end
+
+ def test_public_projects
+ public_projects = Project.find(:all, :conditions => ["is_public=?", true])
+ assert_equal 3, public_projects.length
+ assert_equal true, public_projects[0].is_public?
+ end
+
+ def test_archive
+ user = @ecookbook.members.first.user
+ @ecookbook.archive
+ @ecookbook.reload
+
+ assert !@ecookbook.active?
+ assert !user.projects.include?(@ecookbook)
+ # Subproject are also archived
+ assert !@ecookbook.children.empty?
+ assert @ecookbook.active_children.empty?
+ end
+
+ def test_unarchive
+ user = @ecookbook.members.first.user
+ @ecookbook.archive
+ # A subproject of an archived project can not be unarchived
+ assert !@ecookbook_sub1.unarchive
+
+ # Unarchive project
+ assert @ecookbook.unarchive
+ @ecookbook.reload
+ assert @ecookbook.active?
+ assert user.projects.include?(@ecookbook)
+ # Subproject can now be unarchived
+ @ecookbook_sub1.reload
+ assert @ecookbook_sub1.unarchive
+ end
+
+ def test_destroy
+ # 2 active members
+ assert_equal 2, @ecookbook.members.size
+ # and 1 is locked
+ assert_equal 3, Member.find(:all, :conditions => ['project_id = ?', @ecookbook.id]).size
+
+ @ecookbook.destroy
+ # make sure that the project non longer exists
+ assert_raise(ActiveRecord::RecordNotFound) { Project.find(@ecookbook.id) }
+ # make sure all members have been removed
+ assert_equal 0, Member.find(:all, :conditions => ['project_id = ?', @ecookbook.id]).size
+ end
+
+ def test_subproject_ok
+ sub = Project.find(2)
+ sub.parent = @ecookbook
+ assert sub.save
+ assert_equal @ecookbook.id, sub.parent.id
+ @ecookbook.reload
+ assert_equal 3, @ecookbook.children.size
+ end
+
+ def test_subproject_invalid
+ sub = Project.find(2)
+ sub.parent = @ecookbook_sub1
+ assert !sub.save
+ end
+
+ def test_subproject_invalid_2
+ sub = @ecookbook
+ sub.parent = Project.find(2)
+ assert !sub.save
+ end
+
+ def test_issues_status_changes
+ journals = @ecookbook.issues_status_changes 3.days.ago.to_date, Date.today
+ assert_equal 1, journals.size
+ assert_kind_of Journal, journals.first
+
+ journals = @ecookbook.issues_status_changes 30.days.ago.to_date, 10.days.ago.to_date
+ assert_equal 0, journals.size
+ end
+end
diff --git a/rest_sys/test/unit/query_test.rb b/rest_sys/test/unit/query_test.rb
new file mode 100644
index 000000000..c00f47e5d
--- /dev/null
+++ b/rest_sys/test/unit/query_test.rb
@@ -0,0 +1,44 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class QueryTest < Test::Unit::TestCase
+ fixtures :projects, :users, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :queries
+
+ def test_query_with_multiple_custom_fields
+ query = Query.find(1)
+ assert query.valid?
+ assert query.statement.include?("custom_values.value IN ('MySQL')")
+ issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
+ assert_equal 1, issues.length
+ assert_equal Issue.find(3), issues.first
+ end
+
+ def test_default_columns
+ q = Query.new
+ assert !q.columns.empty?
+ end
+
+ def test_set_column_names
+ q = Query.new
+ q.column_names = ['tracker', :subject, '', 'unknonw_column']
+ assert_equal [:tracker, :subject], q.columns.collect {|c| c.name}
+ c = q.columns.first
+ assert q.has_column?(c)
+ end
+end
diff --git a/rest_sys/test/unit/repository_bazaar_test.rb b/rest_sys/test/unit/repository_bazaar_test.rb
new file mode 100644
index 000000000..15fcc8672
--- /dev/null
+++ b/rest_sys/test/unit/repository_bazaar_test.rb
@@ -0,0 +1,88 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class RepositoryBazaarTest < Test::Unit::TestCase
+ fixtures :projects
+
+ # No '..' in the repository path
+ REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/bazaar_repository'
+ REPOSITORY_PATH.gsub!(/\/+/, '/')
+
+ def setup
+ @project = Project.find(1)
+ assert @repository = Repository::Bazaar.create(:project => @project, :url => "file:///#{REPOSITORY_PATH}")
+ end
+
+ if File.directory?(REPOSITORY_PATH)
+ def test_fetch_changesets_from_scratch
+ @repository.fetch_changesets
+ @repository.reload
+
+ assert_equal 4, @repository.changesets.count
+ assert_equal 9, @repository.changes.count
+ assert_equal 'Initial import', @repository.changesets.find_by_revision(1).comments
+ end
+
+ def test_fetch_changesets_incremental
+ @repository.fetch_changesets
+ # Remove changesets with revision > 5
+ @repository.changesets.find(:all, :conditions => 'revision > 2').each(&:destroy)
+ @repository.reload
+ assert_equal 2, @repository.changesets.count
+
+ @repository.fetch_changesets
+ assert_equal 4, @repository.changesets.count
+ end
+
+ def test_entries
+ entries = @repository.entries
+ assert_equal 2, entries.size
+
+ assert_equal 'dir', entries[0].kind
+ assert_equal 'directory', entries[0].name
+
+ assert_equal 'file', entries[1].kind
+ assert_equal 'doc-mkdir.txt', entries[1].name
+ end
+
+ def test_entries_in_subdirectory
+ entries = @repository.entries('directory')
+ assert_equal 3, entries.size
+
+ assert_equal 'file', entries.last.kind
+ assert_equal 'edit.png', entries.last.name
+ end
+
+ def test_cat
+ cat = @repository.scm.cat('directory/document.txt')
+ assert cat =~ /Write the contents of a file as of a given revision to standard output/
+ end
+
+ def test_annotate
+ annotate = @repository.scm.annotate('doc-mkdir.txt')
+ assert_equal 17, annotate.lines.size
+ assert_equal 1, annotate.revisions[0].identifier
+ assert_equal 'jsmith@', annotate.revisions[0].author
+ assert_equal 'mkdir', annotate.lines[0]
+ end
+ else
+ puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!"
+ def test_fake; assert true end
+ end
+end
diff --git a/rest_sys/test/unit/repository_cvs_test.rb b/rest_sys/test/unit/repository_cvs_test.rb
new file mode 100644
index 000000000..3f6db06eb
--- /dev/null
+++ b/rest_sys/test/unit/repository_cvs_test.rb
@@ -0,0 +1,60 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'pp'
+class RepositoryCvsTest < Test::Unit::TestCase
+ fixtures :projects
+
+ # No '..' in the repository path
+ REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
+ REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
+ # CVS module
+ MODULE_NAME = 'test'
+
+ def setup
+ @project = Project.find(1)
+ assert @repository = Repository::Cvs.create(:project => @project,
+ :root_url => REPOSITORY_PATH,
+ :url => MODULE_NAME)
+ end
+
+ if File.directory?(REPOSITORY_PATH)
+ def test_fetch_changesets_from_scratch
+ @repository.fetch_changesets
+ @repository.reload
+
+ assert_equal 5, @repository.changesets.count
+ assert_equal 14, @repository.changes.count
+ assert_equal 'Two files changed', @repository.changesets.find_by_revision(3).comments
+ end
+
+ def test_fetch_changesets_incremental
+ @repository.fetch_changesets
+ # Remove changesets with revision > 2
+ @repository.changesets.find(:all, :conditions => 'revision > 2').each(&:destroy)
+ @repository.reload
+ assert_equal 2, @repository.changesets.count
+
+ @repository.fetch_changesets
+ assert_equal 5, @repository.changesets.count
+ end
+ else
+ puts "CVS test repository NOT FOUND. Skipping unit tests !!!"
+ def test_fake; assert true end
+ end
+end
diff --git a/rest_sys/test/unit/repository_mercurial_test.rb b/rest_sys/test/unit/repository_mercurial_test.rb
new file mode 100644
index 000000000..e6cfdf9b2
--- /dev/null
+++ b/rest_sys/test/unit/repository_mercurial_test.rb
@@ -0,0 +1,55 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class RepositoryMercurialTest < Test::Unit::TestCase
+ fixtures :projects
+
+ # No '..' in the repository path
+ REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
+
+ def setup
+ @project = Project.find(1)
+ assert @repository = Repository::Mercurial.create(:project => @project, :url => REPOSITORY_PATH)
+ end
+
+ if File.directory?(REPOSITORY_PATH)
+ def test_fetch_changesets_from_scratch
+ @repository.fetch_changesets
+ @repository.reload
+
+ assert_equal 6, @repository.changesets.count
+ assert_equal 11, @repository.changes.count
+ assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find_by_revision(0).comments
+ end
+
+ def test_fetch_changesets_incremental
+ @repository.fetch_changesets
+ # Remove changesets with revision > 2
+ @repository.changesets.find(:all, :conditions => 'revision > 2').each(&:destroy)
+ @repository.reload
+ assert_equal 3, @repository.changesets.count
+
+ @repository.fetch_changesets
+ assert_equal 6, @repository.changesets.count
+ end
+ else
+ puts "Mercurial test repository NOT FOUND. Skipping unit tests !!!"
+ def test_fake; assert true end
+ end
+end
diff --git a/rest_sys/test/unit/repository_subversion_test.rb b/rest_sys/test/unit/repository_subversion_test.rb
new file mode 100644
index 000000000..879feece8
--- /dev/null
+++ b/rest_sys/test/unit/repository_subversion_test.rb
@@ -0,0 +1,55 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class RepositorySubversionTest < Test::Unit::TestCase
+ fixtures :projects
+
+ # No '..' in the repository path for svn
+ REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository'
+
+ def setup
+ @project = Project.find(1)
+ assert @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{REPOSITORY_PATH}")
+ end
+
+ if File.directory?(REPOSITORY_PATH)
+ def test_fetch_changesets_from_scratch
+ @repository.fetch_changesets
+ @repository.reload
+
+ assert_equal 8, @repository.changesets.count
+ assert_equal 16, @repository.changes.count
+ assert_equal 'Initial import.', @repository.changesets.find_by_revision(1).comments
+ end
+
+ def test_fetch_changesets_incremental
+ @repository.fetch_changesets
+ # Remove changesets with revision > 5
+ @repository.changesets.find(:all, :conditions => 'revision > 5').each(&:destroy)
+ @repository.reload
+ assert_equal 5, @repository.changesets.count
+
+ @repository.fetch_changesets
+ assert_equal 8, @repository.changesets.count
+ end
+ else
+ puts "Subversion test repository NOT FOUND. Skipping unit tests !!!"
+ def test_fake; assert true end
+ end
+end
diff --git a/rest_sys/test/unit/repository_test.rb b/rest_sys/test/unit/repository_test.rb
new file mode 100644
index 000000000..5e0432c60
--- /dev/null
+++ b/rest_sys/test/unit/repository_test.rb
@@ -0,0 +1,76 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class RepositoryTest < Test::Unit::TestCase
+ fixtures :projects, :repositories, :issues, :issue_statuses, :changesets, :changes
+
+ def setup
+ @repository = Project.find(1).repository
+ end
+
+ def test_create
+ repository = Repository::Subversion.new(:project => Project.find(3))
+ assert !repository.save
+
+ repository.url = "svn://localhost"
+ assert repository.save
+ repository.reload
+
+ project = Project.find(3)
+ assert_equal repository, project.repository
+ end
+
+ def test_scan_changesets_for_issue_ids
+ # choosing a status to apply to fix issues
+ Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id
+ Setting.commit_fix_done_ratio = "90"
+ Setting.commit_ref_keywords = 'refs , references, IssueID'
+ Setting.commit_fix_keywords = 'fixes , closes'
+
+ # make sure issue 1 is not already closed
+ assert !Issue.find(1).status.is_closed?
+
+ Repository.scan_changesets_for_issue_ids
+ assert_equal [101, 102], Issue.find(3).changeset_ids
+
+ # fixed issues
+ fixed_issue = Issue.find(1)
+ assert fixed_issue.status.is_closed?
+ assert_equal 90, fixed_issue.done_ratio
+ assert_equal [101], fixed_issue.changeset_ids
+
+ # ignoring commits referencing an issue of another project
+ assert_equal [], Issue.find(4).changesets
+ end
+
+ def test_for_changeset_comments_strip
+ repository = Repository::Mercurial.create( :project => Project.find( 4 ), :url => '/foo/bar/baz' )
+ comment = <<-COMMENT
+ This is a loooooooooooooooooooooooooooong comment
+
+
+ COMMENT
+ changeset = Changeset.new(
+ :comments => comment, :commit_date => Time.now, :revision => 0, :scmid => 'f39b7922fb3c',
+ :committer => 'foo ', :committed_on => Time.now, :repository => repository )
+ assert( changeset.save )
+ assert_not_equal( comment, changeset.comments )
+ assert_equal( 'This is a loooooooooooooooooooooooooooong comment', changeset.comments )
+ end
+end
diff --git a/rest_sys/test/unit/setting_test.rb b/rest_sys/test/unit/setting_test.rb
new file mode 100644
index 000000000..34d07c193
--- /dev/null
+++ b/rest_sys/test/unit/setting_test.rb
@@ -0,0 +1,45 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class SettingTest < Test::Unit::TestCase
+
+ def test_read_default
+ assert_equal "Redmine", Setting.app_title
+ assert Setting.self_registration?
+ assert !Setting.login_required?
+ end
+
+ def test_update
+ Setting.app_title = "My title"
+ assert_equal "My title", Setting.app_title
+ # make sure db has been updated (INSERT)
+ assert_equal "My title", Setting.find_by_name('app_title').value
+
+ Setting.app_title = "My other title"
+ assert_equal "My other title", Setting.app_title
+ # make sure db has been updated (UPDATE)
+ assert_equal "My other title", Setting.find_by_name('app_title').value
+ end
+
+ def test_serialized_setting
+ Setting.notified_events = ['issue_added', 'issue_updated', 'news_added']
+ assert_equal ['issue_added', 'issue_updated', 'news_added'], Setting.notified_events
+ assert_equal ['issue_added', 'issue_updated', 'news_added'], Setting.find_by_name('notified_events').value
+ end
+end
diff --git a/rest_sys/test/unit/token_test.rb b/rest_sys/test/unit/token_test.rb
new file mode 100644
index 000000000..5a34e0ad3
--- /dev/null
+++ b/rest_sys/test/unit/token_test.rb
@@ -0,0 +1,29 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class TokenTest < Test::Unit::TestCase
+ fixtures :tokens
+
+ def test_create
+ token = Token.new
+ token.save
+ assert_equal 40, token.value.length
+ assert !token.expired?
+ end
+end
diff --git a/rest_sys/test/unit/user_preference_test.rb b/rest_sys/test/unit/user_preference_test.rb
new file mode 100644
index 000000000..cf6787b17
--- /dev/null
+++ b/rest_sys/test/unit/user_preference_test.rb
@@ -0,0 +1,43 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class UserPreferenceTest < Test::Unit::TestCase
+ fixtures :users, :user_preferences
+
+ def test_create
+ user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
+ user.login = "newuser"
+ user.password, user.password_confirmation = "password", "password"
+ assert user.save
+
+ assert_kind_of UserPreference, user.pref
+ assert_kind_of Hash, user.pref.others
+ assert user.pref.save
+ end
+
+ def test_update
+ user = User.find(1)
+ assert_equal true, user.pref.hide_mail
+ user.pref['preftest'] = 'value'
+ assert user.pref.save
+
+ user.reload
+ assert_equal 'value', user.pref['preftest']
+ end
+end
diff --git a/rest_sys/test/unit/user_test.rb b/rest_sys/test/unit/user_test.rb
new file mode 100644
index 000000000..9f58d278f
--- /dev/null
+++ b/rest_sys/test/unit/user_test.rb
@@ -0,0 +1,139 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class UserTest < Test::Unit::TestCase
+ fixtures :users, :members, :projects
+
+ def setup
+ @admin = User.find(1)
+ @jsmith = User.find(2)
+ @dlopper = User.find(3)
+ end
+
+ def test_truth
+ assert_kind_of User, @jsmith
+ end
+
+ def test_create
+ user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
+
+ user.login = "jsmith"
+ user.password, user.password_confirmation = "password", "password"
+ # login uniqueness
+ assert !user.save
+ assert_equal 1, user.errors.count
+
+ user.login = "newuser"
+ user.password, user.password_confirmation = "passwd", "password"
+ # password confirmation
+ assert !user.save
+ assert_equal 1, user.errors.count
+
+ user.password, user.password_confirmation = "password", "password"
+ assert user.save
+ end
+
+ def test_update
+ assert_equal "admin", @admin.login
+ @admin.login = "john"
+ assert @admin.save, @admin.errors.full_messages.join("; ")
+ @admin.reload
+ assert_equal "john", @admin.login
+ end
+
+ def test_validate
+ @admin.login = ""
+ assert !@admin.save
+ assert_equal 1, @admin.errors.count
+ end
+
+ def test_password
+ user = User.try_to_login("admin", "admin")
+ assert_kind_of User, user
+ assert_equal "admin", user.login
+ user.password = "hello"
+ assert user.save
+
+ user = User.try_to_login("admin", "hello")
+ assert_kind_of User, user
+ assert_equal "admin", user.login
+ assert_equal User.hash_password("hello"), user.hashed_password
+ end
+
+ def test_lock
+ user = User.try_to_login("jsmith", "jsmith")
+ assert_equal @jsmith, user
+
+ @jsmith.status = User::STATUS_LOCKED
+ assert @jsmith.save
+
+ user = User.try_to_login("jsmith", "jsmith")
+ assert_equal nil, user
+ end
+
+ def test_create_anonymous
+ AnonymousUser.delete_all
+ anon = User.anonymous
+ assert !anon.new_record?
+ assert_kind_of AnonymousUser, anon
+ end
+
+ def test_rss_key
+ assert_nil @jsmith.rss_token
+ key = @jsmith.rss_key
+ assert_equal 40, key.length
+
+ @jsmith.reload
+ assert_equal key, @jsmith.rss_key
+ end
+
+ def test_role_for_project
+ # user with a role
+ role = @jsmith.role_for_project(Project.find(1))
+ assert_kind_of Role, role
+ assert_equal "Manager", role.name
+
+ # user with no role
+ assert !@dlopper.role_for_project(Project.find(2)).member?
+ end
+
+ def test_mail_notification_all
+ @jsmith.mail_notification = true
+ @jsmith.notified_project_ids = []
+ @jsmith.save
+ @jsmith.reload
+ assert @jsmith.projects.first.recipients.include?(@jsmith.mail)
+ end
+
+ def test_mail_notification_selected
+ @jsmith.mail_notification = false
+ @jsmith.notified_project_ids = [1]
+ @jsmith.save
+ @jsmith.reload
+ assert Project.find(1).recipients.include?(@jsmith.mail)
+ end
+
+ def test_mail_notification_none
+ @jsmith.mail_notification = false
+ @jsmith.notified_project_ids = []
+ @jsmith.save
+ @jsmith.reload
+ assert !@jsmith.projects.first.recipients.include?(@jsmith.mail)
+ end
+end
diff --git a/rest_sys/test/unit/watcher_test.rb b/rest_sys/test/unit/watcher_test.rb
new file mode 100644
index 000000000..9566e6a7c
--- /dev/null
+++ b/rest_sys/test/unit/watcher_test.rb
@@ -0,0 +1,69 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class WatcherTest < Test::Unit::TestCase
+ fixtures :issues, :users
+
+ def setup
+ @user = User.find(1)
+ @issue = Issue.find(1)
+ end
+
+ def test_watch
+ assert @issue.add_watcher(@user)
+ @issue.reload
+ assert @issue.watchers.detect { |w| w.user == @user }
+ end
+
+ def test_cant_watch_twice
+ assert @issue.add_watcher(@user)
+ assert !@issue.add_watcher(@user)
+ end
+
+ def test_watched_by
+ assert @issue.add_watcher(@user)
+ @issue.reload
+ assert @issue.watched_by?(@user)
+ assert Issue.watched_by(@user).include?(@issue)
+ end
+
+ def test_recipients
+ @issue.watchers.delete_all
+ @issue.reload
+
+ assert @issue.watcher_recipients.empty?
+ assert @issue.add_watcher(@user)
+
+ @user.mail_notification = true
+ @user.save
+ @issue.reload
+ assert @issue.watcher_recipients.include?(@user.mail)
+
+ @user.mail_notification = false
+ @user.save
+ @issue.reload
+ assert @issue.watcher_recipients.include?(@user.mail)
+ end
+
+ def test_unwatch
+ assert @issue.add_watcher(@user)
+ @issue.reload
+ assert_equal 1, @issue.remove_watcher(@user)
+ end
+end
diff --git a/rest_sys/test/unit/wiki_content_test.rb b/rest_sys/test/unit/wiki_content_test.rb
new file mode 100644
index 000000000..a8c28ae21
--- /dev/null
+++ b/rest_sys/test/unit/wiki_content_test.rb
@@ -0,0 +1,60 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class WikiContentTest < Test::Unit::TestCase
+ fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :users
+
+ def setup
+ @wiki = Wiki.find(1)
+ @page = @wiki.pages.first
+ end
+
+ def test_create
+ page = WikiPage.new(:wiki => @wiki, :title => "Page")
+ page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment")
+ assert page.save
+ page.reload
+
+ content = page.content
+ assert_kind_of WikiContent, content
+ assert_equal 1, content.version
+ assert_equal 1, content.versions.length
+ assert_equal "Content text", content.text
+ assert_equal "My comment", content.comments
+ assert_equal User.find(1), content.author
+ assert_equal content.text, content.versions.last.text
+ end
+
+ def test_update
+ content = @page.content
+ version_count = content.version
+ content.text = "My new content"
+ assert content.save
+ content.reload
+ assert_equal version_count+1, content.version
+ assert_equal version_count+1, content.versions.length
+ end
+
+ def test_fetch_history
+ assert !@page.content.versions.empty?
+ @page.content.versions.each do |version|
+ assert_kind_of String, version.text
+ end
+ end
+end
diff --git a/rest_sys/test/unit/wiki_page_test.rb b/rest_sys/test/unit/wiki_page_test.rb
new file mode 100644
index 000000000..bb8111176
--- /dev/null
+++ b/rest_sys/test/unit/wiki_page_test.rb
@@ -0,0 +1,59 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class WikiPageTest < Test::Unit::TestCase
+ fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
+
+ def setup
+ @wiki = Wiki.find(1)
+ @page = @wiki.pages.first
+ end
+
+ def test_create
+ page = WikiPage.new(:wiki => @wiki)
+ assert !page.save
+ assert_equal 1, page.errors.count
+
+ page.title = "Page"
+ assert page.save
+ page.reload
+
+ @wiki.reload
+ assert @wiki.pages.include?(page)
+ end
+
+ def test_find_or_new_page
+ page = @wiki.find_or_new_page("CookBook documentation")
+ assert_kind_of WikiPage, page
+ assert !page.new_record?
+
+ page = @wiki.find_or_new_page("Non existing page")
+ assert_kind_of WikiPage, page
+ assert page.new_record?
+ end
+
+ def test_destroy
+ page = WikiPage.find(1)
+ page.destroy
+ assert_nil WikiPage.find_by_id(1)
+ # make sure that page content and its history are deleted
+ assert WikiContent.find_all_by_page_id(1).empty?
+ assert WikiContent.versioned_class.find_all_by_page_id(1).empty?
+ end
+end
diff --git a/rest_sys/test/unit/wiki_redirect_test.rb b/rest_sys/test/unit/wiki_redirect_test.rb
new file mode 100644
index 000000000..12f6b7d89
--- /dev/null
+++ b/rest_sys/test/unit/wiki_redirect_test.rb
@@ -0,0 +1,73 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class WikiRedirectTest < Test::Unit::TestCase
+ fixtures :projects, :wikis
+
+ def setup
+ @wiki = Wiki.find(1)
+ @original = WikiPage.create(:wiki => @wiki, :title => 'Original title')
+ end
+
+ def test_create_redirect
+ @original.title = 'New title'
+ assert @original.save
+ @original.reload
+
+ assert_equal 'New_title', @original.title
+ assert @wiki.redirects.find_by_title('Original_title')
+ assert @wiki.find_page('Original title')
+ end
+
+ def test_update_redirect
+ # create a redirect that point to this page
+ assert WikiRedirect.create(:wiki => @wiki, :title => 'An_old_page', :redirects_to => 'Original_title')
+
+ @original.title = 'New title'
+ @original.save
+ # make sure the old page now points to the new page
+ assert_equal 'New_title', @wiki.find_page('An old page').title
+ end
+
+ def test_reverse_rename
+ # create a redirect that point to this page
+ assert WikiRedirect.create(:wiki => @wiki, :title => 'An_old_page', :redirects_to => 'Original_title')
+
+ @original.title = 'An old page'
+ @original.save
+ assert !@wiki.redirects.find_by_title_and_redirects_to('An_old_page', 'An_old_page')
+ assert @wiki.redirects.find_by_title_and_redirects_to('Original_title', 'An_old_page')
+ end
+
+ def test_rename_to_already_redirected
+ assert WikiRedirect.create(:wiki => @wiki, :title => 'An_old_page', :redirects_to => 'Other_page')
+
+ @original.title = 'An old page'
+ @original.save
+ # this redirect have to be removed since 'An old page' page now exists
+ assert !@wiki.redirects.find_by_title_and_redirects_to('An_old_page', 'Other_page')
+ end
+
+ def test_redirects_removed_when_deleting_page
+ assert WikiRedirect.create(:wiki => @wiki, :title => 'An_old_page', :redirects_to => 'Original_title')
+
+ @original.destroy
+ assert !@wiki.redirects.find(:first)
+ end
+end
diff --git a/rest_sys/test/unit/wiki_test.rb b/rest_sys/test/unit/wiki_test.rb
new file mode 100644
index 000000000..23d4f442c
--- /dev/null
+++ b/rest_sys/test/unit/wiki_test.rb
@@ -0,0 +1,44 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class WikiTest < Test::Unit::TestCase
+ fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
+
+ def test_create
+ wiki = Wiki.new(:project => Project.find(2))
+ assert !wiki.save
+ assert_equal 1, wiki.errors.count
+
+ wiki.start_page = "Start page"
+ assert wiki.save
+ end
+
+ def test_update
+ @wiki = Wiki.find(1)
+ @wiki.start_page = "Another start page"
+ assert @wiki.save
+ @wiki.reload
+ assert_equal "Another start page", @wiki.start_page
+ end
+
+ def test_titleize
+ assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES')
+ assert_equal 'テスト', Wiki.titleize('テスト')
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/CHANGELOG b/rest_sys/vendor/plugins/actionwebservice/CHANGELOG
new file mode 100644
index 000000000..bb5280356
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/CHANGELOG
@@ -0,0 +1,265 @@
+*SVN*
+
+* Documentation for ActionWebService::API::Base. Closes #7275. [zackchandler]
+
+* Allow action_web_service to handle various HTTP methods including GET. Closes #7011. [zackchandler]
+
+* Ensure that DispatcherError is being thrown when a malformed request is received. [Kent Sibilev]
+
+* Added support for decimal types. Closes #6676. [Kent Sibilev]
+
+* Removed deprecated end_form_tag helper. [Kent Sibilev]
+
+* Removed deprecated @request and @response usages. [Kent Sibilev]
+
+* Removed invocation of deprecated before_action and around_action filter methods. Corresponding before_invocation and after_invocation methods should be used instead. #6275 [Kent Sibilev]
+
+* Provide access to the underlying SOAP driver. #6212 [bmilekic, Kent Sibilev]
+
+* Deprecation: update docs. #5998 [jakob@mentalized.net, Kevin Clark]
+
+* ActionWebService WSDL generation ignores HTTP_X_FORWARDED_HOST [Paul Butcher ]
+
+* Tighten rescue clauses. #5985 [james@grayproductions.net]
+
+* Fixed XMLRPC multicall when one of the called methods returns a struct object. [Kent Sibilev]
+
+* Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar]
+
+* Fix invoke_layered since api_method didn't declare :expects. Closes #4720. [Kevin Ballard , Kent Sibilev]
+
+* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
+
+* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.]
+
+* Fix test database name typo. [Marcel Molina Jr.]
+
+*1.1.2* (April 9th, 2006)
+
+* Rely on Active Record 1.14.2
+
+
+*1.1.1* (April 6th, 2006)
+
+* Do not convert driver options to strings (#4499)
+
+
+*1.1.0* (March 27th, 2006)
+
+* Make ActiveWebService::Struct type reloadable
+
+* Fix scaffolding action when one of the members of a structural type has date or time type
+
+* Remove extra index hash when generating scaffold html for parameters of structural type #4374 [joe@mjg2.com]
+
+* Fix Scaffold Fails with Struct as a Parameter #4363 [joe@mjg2.com]
+
+* Fix soap type registration of multidimensional arrays (#4232)
+
+* Fix that marshaler couldn't handle ActiveRecord models defined in a different namespace (#2392).
+
+* Fix that marshaler couldn't handle structs with members of ActiveRecord type (#1889).
+
+* Fix that marshaler couldn't handle nil values for inner structs (#3576).
+
+* Fix that changes to ActiveWebService::API::Base required restarting of the server (#2390).
+
+* Fix scaffolding for signatures with :date, :time and :base64 types (#3321, #2769, #2078).
+
+* Fix for incorrect casting of TrueClass/FalseClass instances (#2633, #3421).
+
+* Fix for incompatibility problems with SOAP4R 1.5.5 (#2553) [Kent Sibilev]
+
+
+*1.0.0* (December 13th, 2005)
+
+* Become part of Rails 1.0
+
+*0.9.4* (December 7th, 2005)
+
+* Update from LGPL to MIT license as per Minero Aoki's permission. [Marcel Molina Jr.]
+
+* Rename Version constant to VERSION. #2802 [Marcel Molina Jr.]
+
+* Fix that XML-RPC date/time values did not have well-defined behaviour (#2516, #2534). This fix has one caveat, in that we can't support pre-1970 dates from XML-RPC clients.
+
+*0.9.3* (November 7th, 2005)
+
+* Upgraded to Action Pack 1.11.0 and Active Record 1.13.0
+
+
+*0.9.2* (October 26th, 2005)
+
+* Upgraded to Action Pack 1.10.2 and Active Record 1.12.2
+
+
+*0.9.1* (October 19th, 2005)
+
+* Upgraded to Action Pack 1.10.1 and Active Record 1.12.1
+
+
+*0.9.0* (October 16th, 2005)
+
+* Fix invalid XML request generation bug in test_invoke [Ken Barker]
+
+* Add XML-RPC 'system.multicall' support #1941 [jbonnar]
+
+* Fix duplicate XSD entries for custom types shared across delegated/layered services #1729 [Tyler Kovacs]
+
+* Allow multiple invocations in the same test method #1720 [dkhawk]
+
+* Added ActionWebService::API::Base.soap_client and ActionWebService::API::Base.xmlrpc_client helper methods to create the internal clients for an API, useful for testing from ./script/console
+
+* ActionWebService now always returns UTF-8 responses.
+
+
+*0.8.1* (11 July, 2005)
+
+* Fix scaffolding for Action Pack controller changes
+
+
+*0.8.0* (6 July, 2005)
+
+* Fix WSDL generation by aliasing #inherited instead of trying to overwrite it, or the WSDL action may end up not being defined in the controller
+
+* Add ActionController::Base.wsdl_namespace option, to allow overriding of the namespace used in generated WSDL and SOAP messages. This is equivalent to the [WebService(Namespace = "Value")] attribute in .NET.
+
+* Add workaround for Ruby 1.8.3's SOAP4R changing the return value of SOAP::Mapping::Registry#find_mapped_soap_class #1414 [Shugo Maeda]
+
+* Fix moduled controller URLs in WSDL, and add unit test to verify the generated URL #1428
+
+* Fix scaffolding template paths, it was broken on Win32
+
+* Fix that functional testing of :layered controllers failed when using the SOAP protocol
+
+* Allow invocation filters in :direct controllers as well, as they have access to more information regarding the web service request than ActionPack filters
+
+* Add support for a :base64 signature type #1272 [Shugo Maeda]
+
+* Fix that boolean fields were not rendered correctly in scaffolding
+
+* Fix that scaffolding was not working for :delegated dispatching
+
+* Add support for structured types as input parameters to scaffolding, this should let one test the blogging APIs using scaffolding as well
+
+* Fix that generated WSDL was not using relative_url_root for base URI #1210 [Shugo Maeda]
+
+* Use UTF-8 encoding by default for SOAP responses, but if an encoding is supplied by caller, use that for the response #1211 [Shugo Maeda, NAKAMURA Hiroshi]
+
+* If the WSDL was retrieved over HTTPS, use HTTPS URLs in the WSDL too
+
+* Fix that casting change in 0.7.0 would convert nil values to the default value for the type instead of leaving it as nil
+
+
+*0.7.1* (20th April, 2005)
+
+* Depend on Active Record 1.10.1 and Action Pack 1.8.1
+
+
+*0.7.0* (19th April, 2005)
+
+* When casting structured types, don't try to send obj.name= unless obj responds to it, causes casting to be less likely to fail for XML-RPC
+
+* Add scaffolding via ActionController::Base.web_service_scaffold for quick testing using a web browser
+
+* ActionWebService::API::Base#api_methods now returns a hash containing ActionWebService::API::Method objects instead of hashes. However, ActionWebService::API::Method defines a #[]() backwards compatibility method so any existing code utilizing this will still work.
+
+* The :layered dispatching mode can now be used with SOAP as well, allowing you to support SOAP and XML-RPC clients for APIs like the metaWeblog API
+
+* Remove ActiveRecordSoapMarshallable workaround, see #912 for details
+
+* Generalize casting code to be used by both SOAP and XML-RPC (previously, it was only XML-RPC)
+
+* Ensure return value is properly cast as well, fixes XML-RPC interoperability with Ecto and possibly other clients
+
+* Include backtraces in 500 error responses for failed request parsing, and remove "rescue nil" statements obscuring real errors for XML-RPC
+
+* Perform casting of struct members even if the structure is already of the correct type, so that the type we specify for the struct member is always the type of the value seen by the API implementation
+
+
+*0.6.2* (27th March, 2005)
+
+* Allow method declarations for direct dispatching to declare parameters as well. We treat an arity of < 0 or > 0 as an indication that we should send through parameters. Closes #939.
+
+
+*0.6.1* (22th March, 2005)
+
+* Fix that method response QNames mismatched with that declared in the WSDL, makes SOAP::WSDLDriverFactory work against AWS again
+
+* Fix that @request.env was being modified, instead, dup the value gotten from env
+
+* Fix XML-RPC example to use :layered mode, so it works again
+
+* Support casting '0' or 0 into false, and '1' or 1 into true, when expecting a boolean value
+
+* Fix that SOAP fault response fault code values were not QName's #804
+
+
+*0.6.0* (7th March, 2005)
+
+* Add action_controller/test_invoke, used for integrating AWS with the Rails testing infrastructure
+
+* Allow passing through options to the SOAP RPC driver for the SOAP client
+
+* Make the SOAP WS marshaler use #columns to decide which fields to marshal as well, avoids providing attributes brought in by associations
+
+* Add ActionWebService::API::Base.allow_active_record_expects option, with a default of false. Setting this to true will allow specifying ActiveRecord::Base model classes in :expects . API writers should take care to validate the received ActiveRecord model objects when turning it on, and/or have an authentication mechanism in place to reduce the security risk.
+
+* Improve error message reporting. Bugs in either AWS or the web service itself will send back a protocol-specific error report message if possible, otherwise, provide as much detail as possible.
+
+* Removed type checking of received parameters, and perform casting for XML-RPC if possible, but fallback to the received parameters if casting fails, closes #677
+
+* Refactored SOAP and XML-RPC marshaling and encoding into a small library devoted exclusively to protocol specifics, also cleaned up the SOAP marshaling approach, so that array and custom type marshaling should be a bit faster.
+
+* Add namespaced XML-RPC method name support, closes #678
+
+* Replace '::' with '..' in fully qualified type names for marshaling and WSDL. This improves interoperability with .NET, and closes #676.
+
+
+*0.5.0* (24th February, 2005)
+
+ * lib/action_service/dispatcher*: replace "router" fragments with
+ one file for Action Controllers, moves dispatching work out of
+ the container
+ * lib/*,test/*,examples/*: rename project to
+ ActionWebService. prefix all generic "service" type names with web_.
+ update all using code as well as the RDoc.
+ * lib/action_service/router/wsdl.rb: ensure that #wsdl is
+ defined in the final container class, or the new ActionPack
+ filtering will exclude it
+ * lib/action_service/struct.rb,test/struct_test.rb: create a
+ default #initialize on inherit that accepts a Hash containing
+ the default member values
+ * lib/action_service/api/action_controller.rb: add support and
+ tests for #client_api in controller
+ * test/router_wsdl_test.rb: add tests to ensure declared
+ service names don't contain ':', as ':' causes interoperability
+ issues
+ * lib/*, test/*: rename "interface" concept to "api", and change all
+ related uses to reflect this change. update all uses of Inflector
+ to call the method on String instead.
+ * test/api_test.rb: add test to ensure API definition not
+ instantiatable
+ * lib/action_service/invocation.rb: change @invocation_params to
+ @method_params
+ * lib/*: update RDoc
+ * lib/action_service/struct.rb: update to support base types
+ * lib/action_service/support/signature.rb: support the notion of
+ "base types" in signatures, with well-known unambiguous names such as :int,
+ :bool, etc, which map to the correct Ruby class. accept the same names
+ used by ActiveRecord as well as longer versions of each, as aliases.
+ * examples/*: update for seperate API definition updates
+ * lib/action_service/*, test/*: extensive refactoring: define API methods in
+ a seperate class, and specify it wherever used with 'service_api'.
+ this makes writing a client API for accessing defined API methods
+ with ActionWebService really easy.
+ * lib/action_service/container.rb: fix a bug in default call
+ handling for direct dispatching, and add ActionController filter
+ support for direct dispatching.
+ * test/router_action_controller_test.rb: add tests to ensure
+ ActionController filters are actually called.
+ * test/protocol_soap_test.rb: add more tests for direct dispatching.
+
+0.3.0
+
+ * First public release
diff --git a/rest_sys/vendor/plugins/actionwebservice/MIT-LICENSE b/rest_sys/vendor/plugins/actionwebservice/MIT-LICENSE
new file mode 100644
index 000000000..528941e84
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/MIT-LICENSE
@@ -0,0 +1,21 @@
+Copyright (C) 2005 Leon Breedt
+
+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/rest_sys/vendor/plugins/actionwebservice/README b/rest_sys/vendor/plugins/actionwebservice/README
new file mode 100644
index 000000000..78b91f081
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/README
@@ -0,0 +1,364 @@
+= Action Web Service -- Serving APIs on rails
+
+Action Web Service provides a way to publish interoperable web service APIs with
+Rails without spending a lot of time delving into protocol details.
+
+
+== Features
+
+* SOAP RPC protocol support
+* Dynamic WSDL generation for APIs
+* XML-RPC protocol support
+* Clients that use the same API definitions as the server for
+ easy interoperability with other Action Web Service based applications
+* Type signature hints to improve interoperability with static languages
+* Active Record model class support in signatures
+
+
+== Defining your APIs
+
+You specify the methods you want to make available as API methods in an
+ActionWebService::API::Base derivative, and then specify this API
+definition class wherever you want to use that API.
+
+The implementation of the methods is done separately from the API
+specification.
+
+
+==== Method name inflection
+
+Action Web Service will camelcase the method names according to Rails Inflector
+rules for the API visible to public callers. What this means, for example,
+is that the method names in generated WSDL will be camelcased, and callers will
+have to supply the camelcased name in their requests for the request to
+succeed.
+
+If you do not desire this behaviour, you can turn it off with the
+ActionWebService::API::Base +inflect_names+ option.
+
+
+==== Inflection examples
+
+ :add => Add
+ :find_all => FindAll
+
+
+==== Disabling inflection
+
+ class PersonAPI < ActionWebService::API::Base
+ inflect_names false
+ end
+
+
+==== API definition example
+
+ class PersonAPI < ActionWebService::API::Base
+ api_method :add, :expects => [:string, :string, :bool], :returns => [:int]
+ api_method :remove, :expects => [:int], :returns => [:bool]
+ end
+
+==== API usage example
+
+ class PersonController < ActionController::Base
+ web_service_api PersonAPI
+
+ def add
+ end
+
+ def remove
+ end
+ end
+
+
+== Publishing your APIs
+
+Action Web Service uses Action Pack to process protocol requests. There are two
+modes of dispatching protocol requests, _Direct_, and _Delegated_.
+
+
+=== Direct dispatching
+
+This is the default mode. In this mode, public controller instance methods
+implement the API methods, and parameters are passed through to the methods in
+accordance with the API specification.
+
+The return value of the method is sent back as the return value to the
+caller.
+
+In this mode, a special api action is generated in the target
+controller to unwrap the protocol request, forward it on to the relevant method
+and send back the wrapped return value. This action must not be
+overridden.
+
+==== Direct dispatching example
+
+ class PersonController < ApplicationController
+ web_service_api PersonAPI
+
+ def add
+ end
+
+ def remove
+ end
+ end
+
+ class PersonAPI < ActionWebService::API::Base
+ ...
+ end
+
+
+For this example, protocol requests for +Add+ and +Remove+ methods sent to
+/person/api will be routed to the controller methods +add+ and +remove+.
+
+
+=== Delegated dispatching
+
+This mode can be turned on by setting the +web_service_dispatching_mode+ option
+in a controller to :delegated .
+
+In this mode, the controller contains one or more web service objects (objects
+that implement an ActionWebService::API::Base definition). These web service
+objects are each mapped onto one controller action only.
+
+==== Delegated dispatching example
+
+ class ApiController < ApplicationController
+ web_service_dispatching_mode :delegated
+
+ web_service :person, PersonService.new
+ end
+
+ class PersonService < ActionWebService::Base
+ web_service_api PersonAPI
+
+ def add
+ end
+
+ def remove
+ end
+ end
+
+ class PersonAPI < ActionWebService::API::Base
+ ...
+ end
+
+
+For this example, all protocol requests for +PersonService+ are
+sent to the /api/person action.
+
+The /api/person action is generated when the +web_service+
+method is called. This action must not be overridden.
+
+Other controller actions (actions that aren't the target of a +web_service+ call)
+are ignored for ActionWebService purposes, and can do normal action tasks.
+
+
+=== Layered dispatching
+
+This mode can be turned on by setting the +web_service_dispatching_mode+ option
+in a controller to :layered .
+
+This mode is similar to _delegated_ mode, in that multiple web service objects
+can be attached to one controller, however, all protocol requests are sent to a
+single endpoint.
+
+Use this mode when you want to share code between XML-RPC and SOAP clients,
+for APIs where the XML-RPC method names have prefixes. An example of such
+a method name would be blogger.newPost .
+
+
+==== Layered dispatching example
+
+
+ class ApiController < ApplicationController
+ web_service_dispatching_mode :layered
+
+ web_service :mt, MovableTypeService.new
+ web_service :blogger, BloggerService.new
+ web_service :metaWeblog, MetaWeblogService.new
+ end
+
+ class MovableTypeService < ActionWebService::Base
+ ...
+ end
+
+ class BloggerService < ActionWebService::Base
+ ...
+ end
+
+ class MetaWeblogService < ActionWebService::API::Base
+ ...
+ end
+
+
+For this example, an XML-RPC call for a method with a name like
+mt.getCategories will be sent to the getCategories
+method on the :mt service.
+
+
+== Customizing WSDL generation
+
+You can customize the names used for the SOAP bindings in the generated
+WSDL by using the wsdl_service_name option in a controller:
+
+ class WsController < ApplicationController
+ wsdl_service_name 'MyApp'
+ end
+
+You can also customize the namespace used in the generated WSDL for
+custom types and message definition types:
+
+ class WsController < ApplicationController
+ wsdl_namespace 'http://my.company.com/app/wsapi'
+ end
+
+The default namespace used is 'urn:ActionWebService', if you don't supply
+one.
+
+
+== ActionWebService and UTF-8
+
+If you're going to be sending back strings containing non-ASCII UTF-8
+characters using the :string data type, you need to make sure that
+Ruby is using UTF-8 as the default encoding for its strings.
+
+The default in Ruby is to use US-ASCII encoding for strings, which causes a string
+validation check in the Ruby SOAP library to fail and your string to be sent
+back as a Base-64 value, which may confuse clients that expected strings
+because of the WSDL.
+
+Two ways of setting the default string encoding are:
+
+* Start Ruby using the -Ku command-line option to the Ruby executable
+* Set the $KCODE flag in config/environment.rb to the
+ string 'UTF8'
+
+
+== Testing your APIs
+
+
+=== Functional testing
+
+You can perform testing of your APIs by creating a functional test for the
+controller dispatching the API, and calling #invoke in the test case to
+perform the invocation.
+
+Example:
+
+ class PersonApiControllerTest < Test::Unit::TestCase
+ def setup
+ @controller = PersonController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ def test_add
+ result = invoke :remove, 1
+ assert_equal true, result
+ end
+ end
+
+This example invokes the API method test , defined on
+the PersonController, and returns the result.
+
+
+=== Scaffolding
+
+You can also test your APIs with a web browser by attaching scaffolding
+to the controller.
+
+Example:
+
+ class PersonController
+ web_service_scaffold :invocation
+ end
+
+This creates an action named invocation on the PersonController.
+
+Navigating to this action lets you select the method to invoke, supply the parameters,
+and view the result of the invocation.
+
+
+== Using the client support
+
+Action Web Service includes client classes that can use the same API
+definition as the server. The advantage of this approach is that your client
+will have the same support for Active Record and structured types as the
+server, and can just use them directly, and rely on the marshaling to Do The
+Right Thing.
+
+*Note*: The client support is intended for communication between Ruby on Rails
+applications that both use Action Web Service. It may work with other servers, but
+that is not its intended use, and interoperability can't be guaranteed, especially
+not for .NET web services.
+
+Web services protocol specifications are complex, and Action Web Service client
+support can only be guaranteed to work with a subset.
+
+
+==== Factory created client example
+
+ class BlogManagerController < ApplicationController
+ web_client_api :blogger, :xmlrpc, 'http://url/to/blog/api/RPC2', :handler_name => 'blogger'
+ end
+
+ class SearchingController < ApplicationController
+ web_client_api :google, :soap, 'http://url/to/blog/api/beta', :service_name => 'GoogleSearch'
+ end
+
+See ActionWebService::API::ActionController::ClassMethods for more details.
+
+==== Manually created client example
+
+ class PersonAPI < ActionWebService::API::Base
+ api_method :find_all, :returns => [[Person]]
+ end
+
+ soap_client = ActionWebService::Client::Soap.new(PersonAPI, "http://...")
+ persons = soap_client.find_all
+
+ class BloggerAPI < ActionWebService::API::Base
+ inflect_names false
+ api_method :getRecentPosts, :returns => [[Blog::Post]]
+ end
+
+ blog = ActionWebService::Client::XmlRpc.new(BloggerAPI, "http://.../xmlrpc", :handler_name => "blogger")
+ posts = blog.getRecentPosts
+
+
+See ActionWebService::Client::Soap and ActionWebService::Client::XmlRpc for more details.
+
+== Dependencies
+
+Action Web Service requires that the Action Pack and Active Record are either
+available to be required immediately or are accessible as GEMs.
+
+It also requires a version of Ruby that includes SOAP support in the standard
+library. At least version 1.8.2 final (2004-12-25) of Ruby is recommended; this
+is the version tested against.
+
+
+== Download
+
+The latest Action Web Service version can be downloaded from
+http://rubyforge.org/projects/actionservice
+
+
+== Installation
+
+You can install Action Web Service with the following command.
+
+ % [sudo] ruby setup.rb
+
+
+== License
+
+Action Web Service is released under the MIT license.
+
+
+== Support
+
+The Ruby on Rails mailing list
+
+Or, to contact the author, send mail to bitserf@gmail.com
+
diff --git a/rest_sys/vendor/plugins/actionwebservice/Rakefile b/rest_sys/vendor/plugins/actionwebservice/Rakefile
new file mode 100644
index 000000000..ad2ad223e
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/Rakefile
@@ -0,0 +1,172 @@
+require 'rubygems'
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+require 'rake/packagetask'
+require 'rake/gempackagetask'
+require 'rake/contrib/rubyforgepublisher'
+require 'fileutils'
+require File.join(File.dirname(__FILE__), 'lib', 'action_web_service', 'version')
+
+PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
+PKG_NAME = 'actionwebservice'
+PKG_VERSION = ActionWebService::VERSION::STRING + PKG_BUILD
+PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
+PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
+
+RELEASE_NAME = "REL #{PKG_VERSION}"
+
+RUBY_FORGE_PROJECT = "aws"
+RUBY_FORGE_USER = "webster132"
+
+desc "Default Task"
+task :default => [ :test ]
+
+
+# Run the unit tests
+Rake::TestTask.new { |t|
+ t.libs << "test"
+ t.test_files = Dir['test/*_test.rb']
+ t.verbose = true
+}
+
+SCHEMA_PATH = File.join(File.dirname(__FILE__), *%w(test fixtures db_definitions))
+
+desc 'Build the MySQL test database'
+task :build_database do
+ %x( mysqladmin create actionwebservice_unittest )
+ %x( mysql actionwebservice_unittest < #{File.join(SCHEMA_PATH, 'mysql.sql')} )
+end
+
+
+# Generate the RDoc documentation
+Rake::RDocTask.new { |rdoc|
+ rdoc.rdoc_dir = 'doc'
+ rdoc.title = "Action Web Service -- Web services for Action Pack"
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.options << '--charset' << 'utf-8'
+ rdoc.template = "#{ENV['template']}.rb" if ENV['template']
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('CHANGELOG')
+ rdoc.rdoc_files.include('lib/action_web_service.rb')
+ rdoc.rdoc_files.include('lib/action_web_service/*.rb')
+ rdoc.rdoc_files.include('lib/action_web_service/api/*.rb')
+ rdoc.rdoc_files.include('lib/action_web_service/client/*.rb')
+ rdoc.rdoc_files.include('lib/action_web_service/container/*.rb')
+ rdoc.rdoc_files.include('lib/action_web_service/dispatcher/*.rb')
+ rdoc.rdoc_files.include('lib/action_web_service/protocol/*.rb')
+ rdoc.rdoc_files.include('lib/action_web_service/support/*.rb')
+}
+
+
+# Create compressed packages
+spec = Gem::Specification.new do |s|
+ s.platform = Gem::Platform::RUBY
+ s.name = PKG_NAME
+ s.summary = "Web service support for Action Pack."
+ s.description = %q{Adds WSDL/SOAP and XML-RPC web service support to Action Pack}
+ s.version = PKG_VERSION
+
+ s.author = "Leon Breedt"
+ s.email = "bitserf@gmail.com"
+ s.rubyforge_project = "aws"
+ s.homepage = "http://www.rubyonrails.org"
+
+ s.add_dependency('actionpack', '= 1.13.5' + PKG_BUILD)
+ s.add_dependency('activerecord', '= 1.15.5' + PKG_BUILD)
+
+ s.has_rdoc = true
+ s.requirements << 'none'
+ s.require_path = 'lib'
+ s.autorequire = 'action_web_service'
+
+ s.files = [ "Rakefile", "setup.rb", "README", "TODO", "CHANGELOG", "MIT-LICENSE" ]
+ s.files = s.files + Dir.glob( "examples/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
+ s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
+ s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
+end
+Rake::GemPackageTask.new(spec) do |p|
+ p.gem_spec = spec
+ p.need_tar = true
+ p.need_zip = true
+end
+
+
+# Publish beta gem
+desc "Publish the API documentation"
+task :pgem => [:package] do
+ Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
+ `ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'`
+end
+
+# Publish documentation
+desc "Publish the API documentation"
+task :pdoc => [:rdoc] do
+ Rake::SshDirPublisher.new("davidhh@wrath.rubyonrails.org", "public_html/aws", "doc").upload
+end
+
+
+def each_source_file(*args)
+ prefix, includes, excludes, open_file = args
+ prefix ||= File.dirname(__FILE__)
+ open_file = true if open_file.nil?
+ includes ||= %w[lib\/action_web_service\.rb$ lib\/action_web_service\/.*\.rb$]
+ excludes ||= %w[lib\/action_web_service\/vendor]
+ Find.find(prefix) do |file_name|
+ next if file_name =~ /\.svn/
+ file_name.gsub!(/^\.\//, '')
+ continue = false
+ includes.each do |inc|
+ if file_name.match(/#{inc}/)
+ continue = true
+ break
+ end
+ end
+ next unless continue
+ excludes.each do |exc|
+ if file_name.match(/#{exc}/)
+ continue = false
+ break
+ end
+ end
+ next unless continue
+ if open_file
+ File.open(file_name) do |f|
+ yield file_name, f
+ end
+ else
+ yield file_name
+ end
+ end
+end
+
+desc "Count lines of the AWS source code"
+task :lines do
+ total_lines = total_loc = 0
+ puts "Per File:"
+ each_source_file do |file_name, f|
+ file_lines = file_loc = 0
+ while line = f.gets
+ file_lines += 1
+ next if line =~ /^\s*$/
+ next if line =~ /^\s*#/
+ file_loc += 1
+ end
+ puts " #{file_name}: Lines #{file_lines}, LOC #{file_loc}"
+ total_lines += file_lines
+ total_loc += file_loc
+ end
+ puts "Total:"
+ puts " Lines #{total_lines}, LOC #{total_loc}"
+end
+
+desc "Publish the release files to RubyForge."
+task :release => [ :package ] do
+ require 'rubyforge'
+
+ packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
+
+ rubyforge = RubyForge.new
+ rubyforge.login
+ rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/TODO b/rest_sys/vendor/plugins/actionwebservice/TODO
new file mode 100644
index 000000000..7c022c14c
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/TODO
@@ -0,0 +1,32 @@
+= Post-1.0
+ - Document/Literal SOAP support
+ - URL-based dispatching, URL identifies method
+
+ - Add :rest dispatching mode, a.l.a. Backpack API. Clean up dispatching
+ in general. Support vanilla XML-format as a "Rails" protocol?
+ XML::Simple deserialization into params?
+
+ web_service_dispatching_mode :rest
+
+ def method1(params)
+ end
+
+ def method2(params)
+ end
+
+
+ /ws/method1
+
+ /ws/method2
+
+
+ - Allow locking down a controller to only accept messages for a particular
+ protocol. This will allow us to generate fully conformant error messages
+ in cases where we currently fudge it if we don't know the protocol.
+
+ - Allow AWS user to participate in typecasting, so they can centralize
+ workarounds for buggy input in one place
+
+= Refactoring
+ - Don't have clean way to go from SOAP Class object to the xsd:NAME type
+ string -- NaHi possibly looking at remedying this situation
diff --git a/rest_sys/vendor/plugins/actionwebservice/init.rb b/rest_sys/vendor/plugins/actionwebservice/init.rb
new file mode 100644
index 000000000..582f73717
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/init.rb
@@ -0,0 +1,7 @@
+require 'action_web_service'
+
+# These need to be in the load path for action_web_service to work
+Dependencies.load_paths += ["#{RAILS_ROOT}/app/apis"]
+
+# AWS Test helpers
+require 'action_web_service/test_invoke' if ENV['RAILS_ENV'] == 'test'
diff --git a/rest_sys/vendor/plugins/actionwebservice/install.rb b/rest_sys/vendor/plugins/actionwebservice/install.rb
new file mode 100644
index 000000000..da08bf5f9
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/install.rb
@@ -0,0 +1,30 @@
+require 'rbconfig'
+require 'find'
+require 'ftools'
+
+include Config
+
+# this was adapted from rdoc's install.rb by way of Log4r
+
+$sitedir = CONFIG["sitelibdir"]
+unless $sitedir
+ version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
+ $libdir = File.join(CONFIG["libdir"], "ruby", version)
+ $sitedir = $:.find {|x| x =~ /site_ruby/ }
+ if !$sitedir
+ $sitedir = File.join($libdir, "site_ruby")
+ elsif $sitedir !~ Regexp.quote(version)
+ $sitedir = File.join($sitedir, version)
+ end
+end
+
+# the actual gruntwork
+Dir.chdir("lib")
+
+Find.find("action_web_service", "action_web_service.rb") { |f|
+ if f[-3..-1] == ".rb"
+ File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true)
+ else
+ File::makedirs(File.join($sitedir, *f.split(/\//)))
+ end
+}
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service.rb
new file mode 100644
index 000000000..0632dd1ec
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service.rb
@@ -0,0 +1,66 @@
+#--
+# Copyright (C) 2005 Leon Breedt
+#
+# 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.
+#++
+
+begin
+ require 'active_support'
+ require 'action_controller'
+ require 'active_record'
+rescue LoadError
+ require 'rubygems'
+ gem 'activesupport', '>= 1.0.2'
+ gem 'actionpack', '>= 1.6.0'
+ gem 'activerecord', '>= 1.9.0'
+end
+
+$:.unshift(File.dirname(__FILE__) + "/action_web_service/vendor/")
+
+require 'action_web_service/support/class_inheritable_options'
+require 'action_web_service/support/signature_types'
+require 'action_web_service/base'
+require 'action_web_service/client'
+require 'action_web_service/invocation'
+require 'action_web_service/api'
+require 'action_web_service/casting'
+require 'action_web_service/struct'
+require 'action_web_service/container'
+require 'action_web_service/protocol'
+require 'action_web_service/dispatcher'
+require 'action_web_service/scaffolding'
+
+ActionWebService::Base.class_eval do
+ include ActionWebService::Container::Direct
+ include ActionWebService::Invocation
+end
+
+ActionController::Base.class_eval do
+ include ActionWebService::Protocol::Discovery
+ include ActionWebService::Protocol::Soap
+ include ActionWebService::Protocol::XmlRpc
+ include ActionWebService::Container::Direct
+ include ActionWebService::Container::Delegated
+ include ActionWebService::Container::ActionController
+ include ActionWebService::Invocation
+ include ActionWebService::Dispatcher
+ include ActionWebService::Dispatcher::ActionController
+ include ActionWebService::Scaffolding
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/api.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/api.rb
new file mode 100644
index 000000000..d16dc420d
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/api.rb
@@ -0,0 +1,297 @@
+module ActionWebService # :nodoc:
+ module API # :nodoc:
+ # A web service API class specifies the methods that will be available for
+ # invocation for an API. It also contains metadata such as the method type
+ # signature hints.
+ #
+ # It is not intended to be instantiated.
+ #
+ # It is attached to web service implementation classes like
+ # ActionWebService::Base and ActionController::Base derivatives by using
+ # container.web_service_api , where container is an
+ # ActionController::Base or a ActionWebService::Base.
+ #
+ # See ActionWebService::Container::Direct::ClassMethods for an example
+ # of use.
+ class Base
+ # Whether to transform the public API method names into camel-cased names
+ class_inheritable_option :inflect_names, true
+
+ # By default only HTTP POST requests are processed
+ class_inheritable_option :allowed_http_methods, [ :post ]
+
+ # Whether to allow ActiveRecord::Base models in :expects .
+ # The default is +false+; you should be aware of the security implications
+ # of allowing this, and ensure that you don't allow remote callers to
+ # easily overwrite data they should not have access to.
+ class_inheritable_option :allow_active_record_expects, false
+
+ # If present, the name of a method to call when the remote caller
+ # tried to call a nonexistent method. Semantically equivalent to
+ # +method_missing+.
+ class_inheritable_option :default_api_method
+
+ # Disallow instantiation
+ private_class_method :new, :allocate
+
+ class << self
+ include ActionWebService::SignatureTypes
+
+ # API methods have a +name+, which must be the Ruby method name to use when
+ # performing the invocation on the web service object.
+ #
+ # The signatures for the method input parameters and return value can
+ # by specified in +options+.
+ #
+ # A signature is an array of one or more parameter specifiers.
+ # A parameter specifier can be one of the following:
+ #
+ # * A symbol or string representing one of the Action Web Service base types.
+ # See ActionWebService::SignatureTypes for a canonical list of the base types.
+ # * The Class object of the parameter type
+ # * A single-element Array containing one of the two preceding items. This
+ # will cause Action Web Service to treat the parameter at that position
+ # as an array containing only values of the given type.
+ # * A Hash containing as key the name of the parameter, and as value
+ # one of the three preceding items
+ #
+ # If no method input parameter or method return value signatures are given,
+ # the method is assumed to take no parameters and/or return no values of
+ # interest, and any values that are received by the server will be
+ # discarded and ignored.
+ #
+ # Valid options:
+ # [:expects ] Signature for the method input parameters
+ # [:returns ] Signature for the method return value
+ # [:expects_and_returns ] Signature for both input parameters and return value
+ def api_method(name, options={})
+ unless options.is_a?(Hash)
+ raise(ActionWebServiceError, "Expected a Hash for options")
+ end
+ validate_options([:expects, :returns, :expects_and_returns], options.keys)
+ if options[:expects_and_returns]
+ expects = options[:expects_and_returns]
+ returns = options[:expects_and_returns]
+ else
+ expects = options[:expects]
+ returns = options[:returns]
+ end
+ expects = canonical_signature(expects)
+ returns = canonical_signature(returns)
+ if expects
+ expects.each do |type|
+ type = type.element_type if type.is_a?(ArrayType)
+ if type.type_class.ancestors.include?(ActiveRecord::Base) && !allow_active_record_expects
+ raise(ActionWebServiceError, "ActiveRecord model classes not allowed in :expects")
+ end
+ end
+ end
+ name = name.to_sym
+ public_name = public_api_method_name(name)
+ method = Method.new(name, public_name, expects, returns)
+ write_inheritable_hash("api_methods", name => method)
+ write_inheritable_hash("api_public_method_names", public_name => name)
+ end
+
+ # Whether the given method name is a service method on this API
+ #
+ # class ProjectsApi < ActionWebService::API::Base
+ # api_method :getCount, :returns => [:int]
+ # end
+ #
+ # ProjectsApi.has_api_method?('GetCount') #=> false
+ # ProjectsApi.has_api_method?(:getCount) #=> true
+ def has_api_method?(name)
+ api_methods.has_key?(name)
+ end
+
+ # Whether the given public method name has a corresponding service method
+ # on this API
+ #
+ # class ProjectsApi < ActionWebService::API::Base
+ # api_method :getCount, :returns => [:int]
+ # end
+ #
+ # ProjectsApi.has_api_method?(:getCount) #=> false
+ # ProjectsApi.has_api_method?('GetCount') #=> true
+ def has_public_api_method?(public_name)
+ api_public_method_names.has_key?(public_name)
+ end
+
+ # The corresponding public method name for the given service method name
+ #
+ # ProjectsApi.public_api_method_name('GetCount') #=> "GetCount"
+ # ProjectsApi.public_api_method_name(:getCount) #=> "GetCount"
+ def public_api_method_name(name)
+ if inflect_names
+ name.to_s.camelize
+ else
+ name.to_s
+ end
+ end
+
+ # The corresponding service method name for the given public method name
+ #
+ # class ProjectsApi < ActionWebService::API::Base
+ # api_method :getCount, :returns => [:int]
+ # end
+ #
+ # ProjectsApi.api_method_name('GetCount') #=> :getCount
+ def api_method_name(public_name)
+ api_public_method_names[public_name]
+ end
+
+ # A Hash containing all service methods on this API, and their
+ # associated metadata.
+ #
+ # class ProjectsApi < ActionWebService::API::Base
+ # api_method :getCount, :returns => [:int]
+ # api_method :getCompletedCount, :returns => [:int]
+ # end
+ #
+ # ProjectsApi.api_methods #=>
+ # {:getCount=>#,
+ # :getCompletedCount=>#}
+ # ProjectsApi.api_methods[:getCount].public_name #=> "GetCount"
+ def api_methods
+ read_inheritable_attribute("api_methods") || {}
+ end
+
+ # The Method instance for the given public API method name, if any
+ #
+ # class ProjectsApi < ActionWebService::API::Base
+ # api_method :getCount, :returns => [:int]
+ # api_method :getCompletedCount, :returns => [:int]
+ # end
+ #
+ # ProjectsApi.public_api_method_instance('GetCount') #=> <#
+ # ProjectsApi.public_api_method_instance(:getCount) #=> nil
+ def public_api_method_instance(public_method_name)
+ api_method_instance(api_method_name(public_method_name))
+ end
+
+ # The Method instance for the given API method name, if any
+ #
+ # class ProjectsApi < ActionWebService::API::Base
+ # api_method :getCount, :returns => [:int]
+ # api_method :getCompletedCount, :returns => [:int]
+ # end
+ #
+ # ProjectsApi.api_method_instance(:getCount) #=>
+ # ProjectsApi.api_method_instance('GetCount') #=>
+ def api_method_instance(method_name)
+ api_methods[method_name]
+ end
+
+ # The Method instance for the default API method, if any
+ def default_api_method_instance
+ return nil unless name = default_api_method
+ instance = read_inheritable_attribute("default_api_method_instance")
+ if instance && instance.name == name
+ return instance
+ end
+ instance = Method.new(name, public_api_method_name(name), nil, nil)
+ write_inheritable_attribute("default_api_method_instance", instance)
+ instance
+ end
+
+ private
+ def api_public_method_names
+ read_inheritable_attribute("api_public_method_names") || {}
+ end
+
+ def validate_options(valid_option_keys, supplied_option_keys)
+ unknown_option_keys = supplied_option_keys - valid_option_keys
+ unless unknown_option_keys.empty?
+ raise(ActionWebServiceError, "Unknown options: #{unknown_option_keys}")
+ end
+ end
+ end
+ end
+
+ # Represents an API method and its associated metadata, and provides functionality
+ # to assist in commonly performed API method tasks.
+ class Method
+ attr :name
+ attr :public_name
+ attr :expects
+ attr :returns
+
+ def initialize(name, public_name, expects, returns)
+ @name = name
+ @public_name = public_name
+ @expects = expects
+ @returns = returns
+ @caster = ActionWebService::Casting::BaseCaster.new(self)
+ end
+
+ # The list of parameter names for this method
+ def param_names
+ return [] unless @expects
+ @expects.map{ |type| type.name }
+ end
+
+ # Casts a set of Ruby values into the expected Ruby values
+ def cast_expects(params)
+ @caster.cast_expects(params)
+ end
+
+ # Cast a Ruby return value into the expected Ruby value
+ def cast_returns(return_value)
+ @caster.cast_returns(return_value)
+ end
+
+ # Returns the index of the first expected parameter
+ # with the given name
+ def expects_index_of(param_name)
+ return -1 if @expects.nil?
+ (0..(@expects.length-1)).each do |i|
+ return i if @expects[i].name.to_s == param_name.to_s
+ end
+ -1
+ end
+
+ # Returns a hash keyed by parameter name for the given
+ # parameter list
+ def expects_to_hash(params)
+ return {} if @expects.nil?
+ h = {}
+ @expects.zip(params){ |type, param| h[type.name] = param }
+ h
+ end
+
+ # Backwards compatibility with previous API
+ def [](sig_type)
+ case sig_type
+ when :expects
+ @expects.map{|x| compat_signature_entry(x)}
+ when :returns
+ @returns.map{|x| compat_signature_entry(x)}
+ end
+ end
+
+ # String representation of this method
+ def to_s
+ fqn = ""
+ fqn << (@returns ? (@returns[0].human_name(false) + " ") : "void ")
+ fqn << "#{@public_name}("
+ fqn << @expects.map{ |p| p.human_name }.join(", ") if @expects
+ fqn << ")"
+ fqn
+ end
+
+ private
+ def compat_signature_entry(entry)
+ if entry.array?
+ [compat_signature_entry(entry.element_type)]
+ else
+ if entry.spec.is_a?(Hash)
+ {entry.spec.keys.first => entry.type_class}
+ else
+ entry.type_class
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/base.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/base.rb
new file mode 100644
index 000000000..6282061d8
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/base.rb
@@ -0,0 +1,38 @@
+module ActionWebService # :nodoc:
+ class ActionWebServiceError < StandardError # :nodoc:
+ end
+
+ # An Action Web Service object implements a specified API.
+ #
+ # Used by controllers operating in _Delegated_ dispatching mode.
+ #
+ # ==== Example
+ #
+ # class PersonService < ActionWebService::Base
+ # web_service_api PersonAPI
+ #
+ # def find_person(criteria)
+ # Person.find(:all) [...]
+ # end
+ #
+ # def delete_person(id)
+ # Person.find_by_id(id).destroy
+ # end
+ # end
+ #
+ # class PersonAPI < ActionWebService::API::Base
+ # api_method :find_person, :expects => [SearchCriteria], :returns => [[Person]]
+ # api_method :delete_person, :expects => [:int]
+ # end
+ #
+ # class SearchCriteria < ActionWebService::Struct
+ # member :firstname, :string
+ # member :lastname, :string
+ # member :email, :string
+ # end
+ class Base
+ # Whether to report exceptions back to the caller in the protocol's exception
+ # format
+ class_inheritable_option :web_service_exception_reporting, true
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/casting.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/casting.rb
new file mode 100644
index 000000000..71f422eae
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/casting.rb
@@ -0,0 +1,138 @@
+require 'time'
+require 'date'
+require 'xmlrpc/datetime'
+
+module ActionWebService # :nodoc:
+ module Casting # :nodoc:
+ class CastingError < ActionWebServiceError # :nodoc:
+ end
+
+ # Performs casting of arbitrary values into the correct types for the signature
+ class BaseCaster # :nodoc:
+ def initialize(api_method)
+ @api_method = api_method
+ end
+
+ # Coerces the parameters in +params+ (an Enumerable) into the types
+ # this method expects
+ def cast_expects(params)
+ self.class.cast_expects(@api_method, params)
+ end
+
+ # Coerces the given +return_value+ into the type returned by this
+ # method
+ def cast_returns(return_value)
+ self.class.cast_returns(@api_method, return_value)
+ end
+
+ class << self
+ include ActionWebService::SignatureTypes
+
+ def cast_expects(api_method, params) # :nodoc:
+ return [] if api_method.expects.nil?
+ api_method.expects.zip(params).map{ |type, param| cast(param, type) }
+ end
+
+ def cast_returns(api_method, return_value) # :nodoc:
+ return nil if api_method.returns.nil?
+ cast(return_value, api_method.returns[0])
+ end
+
+ def cast(value, signature_type) # :nodoc:
+ return value if signature_type.nil? # signature.length != params.length
+ return nil if value.nil?
+ # XMLRPC protocol doesn't support nil values. It uses false instead.
+ # It should never happen for SOAP.
+ if signature_type.structured? && value.equal?(false)
+ return nil
+ end
+ unless signature_type.array? || signature_type.structured?
+ return value if canonical_type(value.class) == signature_type.type
+ end
+ if signature_type.array?
+ unless value.respond_to?(:entries) && !value.is_a?(String)
+ raise CastingError, "Don't know how to cast #{value.class} into #{signature_type.type.inspect}"
+ end
+ value.entries.map do |entry|
+ cast(entry, signature_type.element_type)
+ end
+ elsif signature_type.structured?
+ cast_to_structured_type(value, signature_type)
+ elsif !signature_type.custom?
+ cast_base_type(value, signature_type)
+ end
+ end
+
+ def cast_base_type(value, signature_type) # :nodoc:
+ # This is a work-around for the fact that XML-RPC special-cases DateTime values into its own DateTime type
+ # in order to support iso8601 dates. This doesn't work too well for us, so we'll convert it into a Time,
+ # with the caveat that we won't be able to handle pre-1970 dates that are sent to us.
+ #
+ # See http://dev.rubyonrails.com/ticket/2516
+ value = value.to_time if value.is_a?(XMLRPC::DateTime)
+
+ case signature_type.type
+ when :int
+ Integer(value)
+ when :string
+ value.to_s
+ when :base64
+ if value.is_a?(ActionWebService::Base64)
+ value
+ else
+ ActionWebService::Base64.new(value.to_s)
+ end
+ when :bool
+ return false if value.nil?
+ return value if value == true || value == false
+ case value.to_s.downcase
+ when '1', 'true', 'y', 'yes'
+ true
+ when '0', 'false', 'n', 'no'
+ false
+ else
+ raise CastingError, "Don't know how to cast #{value.class} into Boolean"
+ end
+ when :float
+ Float(value)
+ when :decimal
+ BigDecimal(value.to_s)
+ when :time
+ value = "%s/%s/%s %s:%s:%s" % value.values_at(*%w[2 3 1 4 5 6]) if value.kind_of?(Hash)
+ value.kind_of?(Time) ? value : Time.parse(value.to_s)
+ when :date
+ value = "%s/%s/%s" % value.values_at(*%w[2 3 1]) if value.kind_of?(Hash)
+ value.kind_of?(Date) ? value : Date.parse(value.to_s)
+ when :datetime
+ value = "%s/%s/%s %s:%s:%s" % value.values_at(*%w[2 3 1 4 5 6]) if value.kind_of?(Hash)
+ value.kind_of?(DateTime) ? value : DateTime.parse(value.to_s)
+ end
+ end
+
+ def cast_to_structured_type(value, signature_type) # :nodoc:
+ obj = nil
+ obj = value if canonical_type(value.class) == canonical_type(signature_type.type)
+ obj ||= signature_type.type_class.new
+ if value.respond_to?(:each_pair)
+ klass = signature_type.type_class
+ value.each_pair do |name, val|
+ type = klass.respond_to?(:member_type) ? klass.member_type(name) : nil
+ val = cast(val, type) if type
+ # See http://dev.rubyonrails.com/ticket/3567
+ val = val.to_time if val.is_a?(XMLRPC::DateTime)
+ obj.__send__("#{name}=", val) if obj.respond_to?(name)
+ end
+ elsif value.respond_to?(:attributes)
+ signature_type.each_member do |name, type|
+ val = value.__send__(name)
+ obj.__send__("#{name}=", cast(val, type)) if obj.respond_to?(name)
+ end
+ else
+ raise CastingError, "Don't know how to cast #{value.class} to #{signature_type.type_class}"
+ end
+ obj
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/client.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/client.rb
new file mode 100644
index 000000000..2a1e33054
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/client.rb
@@ -0,0 +1,3 @@
+require 'action_web_service/client/base'
+require 'action_web_service/client/soap_client'
+require 'action_web_service/client/xmlrpc_client'
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/client/base.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/client/base.rb
new file mode 100644
index 000000000..9dada7bf9
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/client/base.rb
@@ -0,0 +1,28 @@
+module ActionWebService # :nodoc:
+ module Client # :nodoc:
+ class ClientError < StandardError # :nodoc:
+ end
+
+ class Base # :nodoc:
+ def initialize(api, endpoint_uri)
+ @api = api
+ @endpoint_uri = endpoint_uri
+ end
+
+ def method_missing(name, *args) # :nodoc:
+ call_name = method_name(name)
+ return super(name, *args) if call_name.nil?
+ self.perform_invocation(call_name, args)
+ end
+
+ private
+ def method_name(name)
+ if @api.has_api_method?(name.to_sym)
+ name.to_s
+ elsif @api.has_public_api_method?(name.to_s)
+ @api.api_method_name(name.to_s).to_s
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/client/soap_client.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/client/soap_client.rb
new file mode 100644
index 000000000..ebabd8ea8
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/client/soap_client.rb
@@ -0,0 +1,113 @@
+require 'soap/rpc/driver'
+require 'uri'
+
+module ActionWebService # :nodoc:
+ module Client # :nodoc:
+
+ # Implements SOAP client support (using RPC encoding for the messages).
+ #
+ # ==== Example Usage
+ #
+ # class PersonAPI < ActionWebService::API::Base
+ # api_method :find_all, :returns => [[Person]]
+ # end
+ #
+ # soap_client = ActionWebService::Client::Soap.new(PersonAPI, "http://...")
+ # persons = soap_client.find_all
+ #
+ class Soap < Base
+ # provides access to the underlying soap driver
+ attr_reader :driver
+
+ # Creates a new web service client using the SOAP RPC protocol.
+ #
+ # +api+ must be an ActionWebService::API::Base derivative, and
+ # +endpoint_uri+ must point at the relevant URL to which protocol requests
+ # will be sent with HTTP POST.
+ #
+ # Valid options:
+ # [:namespace ] If the remote server has used a custom namespace to
+ # declare its custom types, you can specify it here. This would
+ # be the namespace declared with a [WebService(Namespace = "http://namespace")] attribute
+ # in .NET, for example.
+ # [:driver_options ] If you want to supply any custom SOAP RPC driver
+ # options, you can provide them as a Hash here
+ #
+ # The :driver_options option can be used to configure the backend SOAP
+ # RPC driver. An example of configuring the SOAP backend to do
+ # client-certificate authenticated SSL connections to the server:
+ #
+ # opts = {}
+ # opts['protocol.http.ssl_config.verify_mode'] = 'OpenSSL::SSL::VERIFY_PEER'
+ # opts['protocol.http.ssl_config.client_cert'] = client_cert_file_path
+ # opts['protocol.http.ssl_config.client_key'] = client_key_file_path
+ # opts['protocol.http.ssl_config.ca_file'] = ca_cert_file_path
+ # client = ActionWebService::Client::Soap.new(api, 'https://some/service', :driver_options => opts)
+ def initialize(api, endpoint_uri, options={})
+ super(api, endpoint_uri)
+ @namespace = options[:namespace] || 'urn:ActionWebService'
+ @driver_options = options[:driver_options] || {}
+ @protocol = ActionWebService::Protocol::Soap::SoapProtocol.new @namespace
+ @soap_action_base = options[:soap_action_base]
+ @soap_action_base ||= URI.parse(endpoint_uri).path
+ @driver = create_soap_rpc_driver(api, endpoint_uri)
+ @driver_options.each do |name, value|
+ @driver.options[name.to_s] = value
+ end
+ end
+
+ protected
+ def perform_invocation(method_name, args)
+ method = @api.api_methods[method_name.to_sym]
+ args = method.cast_expects(args.dup) rescue args
+ return_value = @driver.send(method_name, *args)
+ method.cast_returns(return_value.dup) rescue return_value
+ end
+
+ def soap_action(method_name)
+ "#{@soap_action_base}/#{method_name}"
+ end
+
+ private
+ def create_soap_rpc_driver(api, endpoint_uri)
+ @protocol.register_api(api)
+ driver = SoapDriver.new(endpoint_uri, nil)
+ driver.mapping_registry = @protocol.marshaler.registry
+ api.api_methods.each do |name, method|
+ qname = XSD::QName.new(@namespace, method.public_name)
+ action = soap_action(method.public_name)
+ expects = method.expects
+ returns = method.returns
+ param_def = []
+ if expects
+ expects.each do |type|
+ type_binding = @protocol.marshaler.lookup_type(type)
+ if SOAP::Version >= "1.5.5"
+ param_def << ['in', type.name.to_s, [type_binding.type.type_class.to_s]]
+ else
+ param_def << ['in', type.name, type_binding.mapping]
+ end
+ end
+ end
+ if returns
+ type_binding = @protocol.marshaler.lookup_type(returns[0])
+ if SOAP::Version >= "1.5.5"
+ param_def << ['retval', 'return', [type_binding.type.type_class.to_s]]
+ else
+ param_def << ['retval', 'return', type_binding.mapping]
+ end
+ end
+ driver.add_method(qname, action, method.name.to_s, param_def)
+ end
+ driver
+ end
+
+ class SoapDriver < SOAP::RPC::Driver # :nodoc:
+ def add_method(qname, soapaction, name, param_def)
+ @proxy.add_rpc_method(qname, soapaction, name, param_def)
+ add_rpc_method_interface(name, param_def)
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/client/xmlrpc_client.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/client/xmlrpc_client.rb
new file mode 100644
index 000000000..42b5c5d4f
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/client/xmlrpc_client.rb
@@ -0,0 +1,58 @@
+require 'uri'
+require 'xmlrpc/client'
+
+module ActionWebService # :nodoc:
+ module Client # :nodoc:
+
+ # Implements XML-RPC client support
+ #
+ # ==== Example Usage
+ #
+ # class BloggerAPI < ActionWebService::API::Base
+ # inflect_names false
+ # api_method :getRecentPosts, :returns => [[Blog::Post]]
+ # end
+ #
+ # blog = ActionWebService::Client::XmlRpc.new(BloggerAPI, "http://.../RPC", :handler_name => "blogger")
+ # posts = blog.getRecentPosts
+ class XmlRpc < Base
+
+ # Creates a new web service client using the XML-RPC protocol.
+ #
+ # +api+ must be an ActionWebService::API::Base derivative, and
+ # +endpoint_uri+ must point at the relevant URL to which protocol requests
+ # will be sent with HTTP POST.
+ #
+ # Valid options:
+ # [:handler_name ] If the remote server defines its services inside special
+ # handler (the Blogger API uses a "blogger" handler name for example),
+ # provide it here, or your method calls will fail
+ def initialize(api, endpoint_uri, options={})
+ @api = api
+ @handler_name = options[:handler_name]
+ @protocol = ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.new
+ @client = XMLRPC::Client.new2(endpoint_uri, options[:proxy], options[:timeout])
+ end
+
+ protected
+ def perform_invocation(method_name, args)
+ method = @api.api_methods[method_name.to_sym]
+ if method.expects && method.expects.length != args.length
+ raise(ArgumentError, "#{method.public_name}: wrong number of arguments (#{args.length} for #{method.expects.length})")
+ end
+ args = method.cast_expects(args.dup) rescue args
+ if method.expects
+ method.expects.each_with_index{ |type, i| args[i] = @protocol.value_to_xmlrpc_wire_format(args[i], type) }
+ end
+ ok, return_value = @client.call2(public_name(method_name), *args)
+ return (method.cast_returns(return_value.dup) rescue return_value) if ok
+ raise(ClientError, "#{return_value.faultCode}: #{return_value.faultString}")
+ end
+
+ def public_name(method_name)
+ public_name = @api.public_api_method_name(method_name)
+ @handler_name ? "#{@handler_name}.#{public_name}" : public_name
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/container.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/container.rb
new file mode 100644
index 000000000..13d9d8ab5
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/container.rb
@@ -0,0 +1,3 @@
+require 'action_web_service/container/direct_container'
+require 'action_web_service/container/delegated_container'
+require 'action_web_service/container/action_controller_container'
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/container/action_controller_container.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/container/action_controller_container.rb
new file mode 100644
index 000000000..bbc28083c
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/container/action_controller_container.rb
@@ -0,0 +1,93 @@
+module ActionWebService # :nodoc:
+ module Container # :nodoc:
+ module ActionController # :nodoc:
+ def self.included(base) # :nodoc:
+ class << base
+ include ClassMethods
+ alias_method_chain :inherited, :api
+ alias_method_chain :web_service_api, :require
+ end
+ end
+
+ module ClassMethods
+ # Creates a client for accessing remote web services, using the
+ # given +protocol+ to communicate with the +endpoint_uri+.
+ #
+ # ==== Example
+ #
+ # class MyController < ActionController::Base
+ # web_client_api :blogger, :xmlrpc, "http://blogger.com/myblog/api/RPC2", :handler_name => 'blogger'
+ # end
+ #
+ # In this example, a protected method named blogger will
+ # now exist on the controller, and calling it will return the
+ # XML-RPC client object for working with that remote service.
+ #
+ # +options+ is the set of protocol client specific options (see
+ # a protocol client class for details).
+ #
+ # If your API definition does not exist on the load path with the
+ # correct rules for it to be found using +name+, you can pass in
+ # the API definition class via +options+, using a key of :api
+ def web_client_api(name, protocol, endpoint_uri, options={})
+ unless method_defined?(name)
+ api_klass = options.delete(:api) || require_web_service_api(name)
+ class_eval do
+ define_method(name) do
+ create_web_service_client(api_klass, protocol, endpoint_uri, options)
+ end
+ protected name
+ end
+ end
+ end
+
+ def web_service_api_with_require(definition=nil) # :nodoc:
+ return web_service_api_without_require if definition.nil?
+ case definition
+ when String, Symbol
+ klass = require_web_service_api(definition)
+ else
+ klass = definition
+ end
+ web_service_api_without_require(klass)
+ end
+
+ def require_web_service_api(name) # :nodoc:
+ case name
+ when String, Symbol
+ file_name = name.to_s.underscore + "_api"
+ class_name = file_name.camelize
+ class_names = [class_name, class_name.sub(/Api$/, 'API')]
+ begin
+ require_dependency(file_name)
+ rescue LoadError => load_error
+ requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1]
+ msg = requiree == file_name ? "Missing API definition file in apis/#{file_name}.rb" : "Can't load file: #{requiree}"
+ raise LoadError.new(msg).copy_blame!(load_error)
+ end
+ klass = nil
+ class_names.each do |name|
+ klass = name.constantize rescue nil
+ break unless klass.nil?
+ end
+ unless klass
+ raise(NameError, "neither #{class_names[0]} or #{class_names[1]} found")
+ end
+ klass
+ else
+ raise(ArgumentError, "expected String or Symbol argument")
+ end
+ end
+
+ private
+ def inherited_with_api(child)
+ inherited_without_api(child)
+ begin child.web_service_api(child.controller_path)
+ rescue MissingSourceFile => e
+ raise unless e.is_missing?("apis/#{child.controller_path}_api")
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/container/delegated_container.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/container/delegated_container.rb
new file mode 100644
index 000000000..5477f8d10
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/container/delegated_container.rb
@@ -0,0 +1,86 @@
+module ActionWebService # :nodoc:
+ module Container # :nodoc:
+ module Delegated # :nodoc:
+ class ContainerError < ActionWebServiceError # :nodoc:
+ end
+
+ def self.included(base) # :nodoc:
+ base.extend(ClassMethods)
+ base.send(:include, ActionWebService::Container::Delegated::InstanceMethods)
+ end
+
+ module ClassMethods
+ # Declares a web service that will provide access to the API of the given
+ # +object+. +object+ must be an ActionWebService::Base derivative.
+ #
+ # Web service object creation can either be _immediate_, where the object
+ # instance is given at class definition time, or _deferred_, where
+ # object instantiation is delayed until request time.
+ #
+ # ==== Immediate web service object example
+ #
+ # class ApiController < ApplicationController
+ # web_service_dispatching_mode :delegated
+ #
+ # web_service :person, PersonService.new
+ # end
+ #
+ # For deferred instantiation, a block should be given instead of an
+ # object instance. This block will be executed in controller instance
+ # context, so it can rely on controller instance variables being present.
+ #
+ # ==== Deferred web service object example
+ #
+ # class ApiController < ApplicationController
+ # web_service_dispatching_mode :delegated
+ #
+ # web_service(:person) { PersonService.new(request.env) }
+ # end
+ def web_service(name, object=nil, &block)
+ if (object && block_given?) || (object.nil? && block.nil?)
+ raise(ContainerError, "either service, or a block must be given")
+ end
+ name = name.to_sym
+ if block_given?
+ info = { name => { :block => block } }
+ else
+ info = { name => { :object => object } }
+ end
+ write_inheritable_hash("web_services", info)
+ call_web_service_definition_callbacks(self, name, info)
+ end
+
+ # Whether this service contains a service with the given +name+
+ def has_web_service?(name)
+ web_services.has_key?(name.to_sym)
+ end
+
+ def web_services # :nodoc:
+ read_inheritable_attribute("web_services") || {}
+ end
+
+ def add_web_service_definition_callback(&block) # :nodoc:
+ write_inheritable_array("web_service_definition_callbacks", [block])
+ end
+
+ private
+ def call_web_service_definition_callbacks(container_class, web_service_name, service_info)
+ (read_inheritable_attribute("web_service_definition_callbacks") || []).each do |block|
+ block.call(container_class, web_service_name, service_info)
+ end
+ end
+ end
+
+ module InstanceMethods # :nodoc:
+ def web_service_object(web_service_name)
+ info = self.class.web_services[web_service_name.to_sym]
+ unless info
+ raise(ContainerError, "no such web service '#{web_service_name}'")
+ end
+ service = info[:block]
+ service ? self.instance_eval(&service) : info[:object]
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/container/direct_container.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/container/direct_container.rb
new file mode 100644
index 000000000..8818d8f45
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/container/direct_container.rb
@@ -0,0 +1,69 @@
+module ActionWebService # :nodoc:
+ module Container # :nodoc:
+ module Direct # :nodoc:
+ class ContainerError < ActionWebServiceError # :nodoc:
+ end
+
+ def self.included(base) # :nodoc:
+ base.extend(ClassMethods)
+ end
+
+ module ClassMethods
+ # Attaches ActionWebService API +definition+ to the calling class.
+ #
+ # Action Controllers can have a default associated API, removing the need
+ # to call this method if you follow the Action Web Service naming conventions.
+ #
+ # A controller with a class name of GoogleSearchController will
+ # implicitly load app/apis/google_search_api.rb , and expect the
+ # API definition class to be named GoogleSearchAPI or
+ # GoogleSearchApi .
+ #
+ # ==== Service class example
+ #
+ # class MyService < ActionWebService::Base
+ # web_service_api MyAPI
+ # end
+ #
+ # class MyAPI < ActionWebService::API::Base
+ # ...
+ # end
+ #
+ # ==== Controller class example
+ #
+ # class MyController < ActionController::Base
+ # web_service_api MyAPI
+ # end
+ #
+ # class MyAPI < ActionWebService::API::Base
+ # ...
+ # end
+ def web_service_api(definition=nil)
+ if definition.nil?
+ read_inheritable_attribute("web_service_api")
+ else
+ if definition.is_a?(Symbol)
+ raise(ContainerError, "symbols can only be used for #web_service_api inside of a controller")
+ end
+ unless definition.respond_to?(:ancestors) && definition.ancestors.include?(ActionWebService::API::Base)
+ raise(ContainerError, "#{definition.to_s} is not a valid API definition")
+ end
+ write_inheritable_attribute("web_service_api", definition)
+ call_web_service_api_callbacks(self, definition)
+ end
+ end
+
+ def add_web_service_api_callback(&block) # :nodoc:
+ write_inheritable_array("web_service_api_callbacks", [block])
+ end
+
+ private
+ def call_web_service_api_callbacks(container_class, definition)
+ (read_inheritable_attribute("web_service_api_callbacks") || []).each do |block|
+ block.call(container_class, definition)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/dispatcher.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/dispatcher.rb
new file mode 100644
index 000000000..601d83137
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/dispatcher.rb
@@ -0,0 +1,2 @@
+require 'action_web_service/dispatcher/abstract'
+require 'action_web_service/dispatcher/action_controller_dispatcher'
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/dispatcher/abstract.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/dispatcher/abstract.rb
new file mode 100644
index 000000000..cb94d649e
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/dispatcher/abstract.rb
@@ -0,0 +1,207 @@
+require 'benchmark'
+
+module ActionWebService # :nodoc:
+ module Dispatcher # :nodoc:
+ class DispatcherError < ActionWebService::ActionWebServiceError # :nodoc:
+ def initialize(*args)
+ super
+ set_backtrace(caller)
+ end
+ end
+
+ def self.included(base) # :nodoc:
+ base.class_inheritable_option(:web_service_dispatching_mode, :direct)
+ base.class_inheritable_option(:web_service_exception_reporting, true)
+ base.send(:include, ActionWebService::Dispatcher::InstanceMethods)
+ end
+
+ module InstanceMethods # :nodoc:
+ private
+ def invoke_web_service_request(protocol_request)
+ invocation = web_service_invocation(protocol_request)
+ if invocation.is_a?(Array) && protocol_request.protocol.is_a?(Protocol::XmlRpc::XmlRpcProtocol)
+ xmlrpc_multicall_invoke(invocation)
+ else
+ web_service_invoke(invocation)
+ end
+ end
+
+ def web_service_direct_invoke(invocation)
+ @method_params = invocation.method_ordered_params
+ arity = method(invocation.api_method.name).arity rescue 0
+ if arity < 0 || arity > 0
+ params = @method_params
+ else
+ params = []
+ end
+ web_service_filtered_invoke(invocation, params)
+ end
+
+ def web_service_delegated_invoke(invocation)
+ web_service_filtered_invoke(invocation, invocation.method_ordered_params)
+ end
+
+ def web_service_filtered_invoke(invocation, params)
+ cancellation_reason = nil
+ return_value = invocation.service.perform_invocation(invocation.api_method.name, params) do |x|
+ cancellation_reason = x
+ end
+ if cancellation_reason
+ raise(DispatcherError, "request canceled: #{cancellation_reason}")
+ end
+ return_value
+ end
+
+ def web_service_invoke(invocation)
+ case web_service_dispatching_mode
+ when :direct
+ return_value = web_service_direct_invoke(invocation)
+ when :delegated, :layered
+ return_value = web_service_delegated_invoke(invocation)
+ end
+ web_service_create_response(invocation.protocol, invocation.protocol_options, invocation.api, invocation.api_method, return_value)
+ end
+
+ def xmlrpc_multicall_invoke(invocations)
+ responses = []
+ invocations.each do |invocation|
+ if invocation.is_a?(Hash)
+ responses << [invocation, nil]
+ next
+ end
+ begin
+ case web_service_dispatching_mode
+ when :direct
+ return_value = web_service_direct_invoke(invocation)
+ when :delegated, :layered
+ return_value = web_service_delegated_invoke(invocation)
+ end
+ api_method = invocation.api_method
+ if invocation.api.has_api_method?(api_method.name)
+ response_type = (api_method.returns ? api_method.returns[0] : nil)
+ return_value = api_method.cast_returns(return_value)
+ else
+ response_type = ActionWebService::SignatureTypes.canonical_signature_entry(return_value.class, 0)
+ end
+ responses << [return_value, response_type]
+ rescue Exception => e
+ responses << [{ 'faultCode' => 3, 'faultString' => e.message }, nil]
+ end
+ end
+ invocation = invocations[0]
+ invocation.protocol.encode_multicall_response(responses, invocation.protocol_options)
+ end
+
+ def web_service_invocation(request, level = 0)
+ public_method_name = request.method_name
+ invocation = Invocation.new
+ invocation.protocol = request.protocol
+ invocation.protocol_options = request.protocol_options
+ invocation.service_name = request.service_name
+ if web_service_dispatching_mode == :layered
+ case invocation.protocol
+ when Protocol::Soap::SoapProtocol
+ soap_action = request.protocol_options[:soap_action]
+ if soap_action && soap_action =~ /^\/\w+\/(\w+)\//
+ invocation.service_name = $1
+ end
+ when Protocol::XmlRpc::XmlRpcProtocol
+ if request.method_name =~ /^([^\.]+)\.(.*)$/
+ public_method_name = $2
+ invocation.service_name = $1
+ end
+ end
+ end
+ if invocation.protocol.is_a? Protocol::XmlRpc::XmlRpcProtocol
+ if public_method_name == 'multicall' && invocation.service_name == 'system'
+ if level > 0
+ raise(DispatcherError, "Recursive system.multicall invocations not allowed")
+ end
+ multicall = request.method_params.dup
+ unless multicall.is_a?(Array) && multicall[0].is_a?(Array)
+ raise(DispatcherError, "Malformed multicall (expected array of Hash elements)")
+ end
+ multicall = multicall[0]
+ return multicall.map do |item|
+ raise(DispatcherError, "Multicall elements must be Hash") unless item.is_a?(Hash)
+ raise(DispatcherError, "Multicall elements must contain a 'methodName' key") unless item.has_key?('methodName')
+ method_name = item['methodName']
+ params = item.has_key?('params') ? item['params'] : []
+ multicall_request = request.dup
+ multicall_request.method_name = method_name
+ multicall_request.method_params = params
+ begin
+ web_service_invocation(multicall_request, level + 1)
+ rescue Exception => e
+ {'faultCode' => 4, 'faultMessage' => e.message}
+ end
+ end
+ end
+ end
+ case web_service_dispatching_mode
+ when :direct
+ invocation.api = self.class.web_service_api
+ invocation.service = self
+ when :delegated, :layered
+ invocation.service = web_service_object(invocation.service_name)
+ invocation.api = invocation.service.class.web_service_api
+ end
+ if invocation.api.nil?
+ raise(DispatcherError, "no API attached to #{invocation.service.class}")
+ end
+ invocation.protocol.register_api(invocation.api)
+ request.api = invocation.api
+ if invocation.api.has_public_api_method?(public_method_name)
+ invocation.api_method = invocation.api.public_api_method_instance(public_method_name)
+ else
+ if invocation.api.default_api_method.nil?
+ raise(DispatcherError, "no such method '#{public_method_name}' on API #{invocation.api}")
+ else
+ invocation.api_method = invocation.api.default_api_method_instance
+ end
+ end
+ if invocation.service.nil?
+ raise(DispatcherError, "no service available for service name #{invocation.service_name}")
+ end
+ unless invocation.service.respond_to?(invocation.api_method.name)
+ raise(DispatcherError, "no such method '#{public_method_name}' on API #{invocation.api} (#{invocation.api_method.name})")
+ end
+ request.api_method = invocation.api_method
+ begin
+ invocation.method_ordered_params = invocation.api_method.cast_expects(request.method_params.dup)
+ rescue
+ logger.warn "Casting of method parameters failed" unless logger.nil?
+ invocation.method_ordered_params = request.method_params
+ end
+ request.method_params = invocation.method_ordered_params
+ invocation.method_named_params = {}
+ invocation.api_method.param_names.inject(0) do |m, n|
+ invocation.method_named_params[n] = invocation.method_ordered_params[m]
+ m + 1
+ end
+ invocation
+ end
+
+ def web_service_create_response(protocol, protocol_options, api, api_method, return_value)
+ if api.has_api_method?(api_method.name)
+ return_type = api_method.returns ? api_method.returns[0] : nil
+ return_value = api_method.cast_returns(return_value)
+ else
+ return_type = ActionWebService::SignatureTypes.canonical_signature_entry(return_value.class, 0)
+ end
+ protocol.encode_response(api_method.public_name + 'Response', return_value, return_type, protocol_options)
+ end
+
+ class Invocation # :nodoc:
+ attr_accessor :protocol
+ attr_accessor :protocol_options
+ attr_accessor :service_name
+ attr_accessor :api
+ attr_accessor :api_method
+ attr_accessor :method_ordered_params
+ attr_accessor :method_named_params
+ attr_accessor :service
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb
new file mode 100644
index 000000000..f9995197a
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb
@@ -0,0 +1,379 @@
+require 'benchmark'
+require 'builder/xmlmarkup'
+
+module ActionWebService # :nodoc:
+ module Dispatcher # :nodoc:
+ module ActionController # :nodoc:
+ def self.included(base) # :nodoc:
+ class << base
+ include ClassMethods
+ alias_method_chain :inherited, :action_controller
+ end
+ base.class_eval do
+ alias_method :web_service_direct_invoke_without_controller, :web_service_direct_invoke
+ end
+ base.add_web_service_api_callback do |klass, api|
+ if klass.web_service_dispatching_mode == :direct
+ klass.class_eval 'def api; dispatch_web_service_request; end'
+ end
+ end
+ base.add_web_service_definition_callback do |klass, name, info|
+ if klass.web_service_dispatching_mode == :delegated
+ klass.class_eval "def #{name}; dispatch_web_service_request; end"
+ elsif klass.web_service_dispatching_mode == :layered
+ klass.class_eval 'def api; dispatch_web_service_request; end'
+ end
+ end
+ base.send(:include, ActionWebService::Dispatcher::ActionController::InstanceMethods)
+ end
+
+ module ClassMethods # :nodoc:
+ def inherited_with_action_controller(child)
+ inherited_without_action_controller(child)
+ child.send(:include, ActionWebService::Dispatcher::ActionController::WsdlAction)
+ end
+ end
+
+ module InstanceMethods # :nodoc:
+ private
+ def dispatch_web_service_request
+ method = request.method.to_s.upcase
+ allowed_methods = self.class.web_service_api ? (self.class.web_service_api.allowed_http_methods || []) : [ :post ]
+ allowed_methods = allowed_methods.map{|m| m.to_s.upcase }
+ if !allowed_methods.include?(method)
+ render :text => "#{method} not supported", :status=>500
+ return
+ end
+ exception = nil
+ begin
+ ws_request = discover_web_service_request(request)
+ rescue Exception => e
+ exception = e
+ end
+ if ws_request
+ ws_response = nil
+ exception = nil
+ bm = Benchmark.measure do
+ begin
+ ws_response = invoke_web_service_request(ws_request)
+ rescue Exception => e
+ exception = e
+ end
+ end
+ log_request(ws_request, request.raw_post)
+ if exception
+ log_error(exception) unless logger.nil?
+ send_web_service_error_response(ws_request, exception)
+ else
+ send_web_service_response(ws_response, bm.real)
+ end
+ else
+ exception ||= DispatcherError.new("Malformed SOAP or XML-RPC protocol message")
+ log_error(exception) unless logger.nil?
+ send_web_service_error_response(ws_request, exception)
+ end
+ rescue Exception => e
+ log_error(e) unless logger.nil?
+ send_web_service_error_response(ws_request, e)
+ end
+
+ def send_web_service_response(ws_response, elapsed=nil)
+ log_response(ws_response, elapsed)
+ options = { :type => ws_response.content_type, :disposition => 'inline' }
+ send_data(ws_response.body, options)
+ end
+
+ def send_web_service_error_response(ws_request, exception)
+ if ws_request
+ unless self.class.web_service_exception_reporting
+ exception = DispatcherError.new("Internal server error (exception raised)")
+ end
+ api_method = ws_request.api_method
+ public_method_name = api_method ? api_method.public_name : ws_request.method_name
+ return_type = ActionWebService::SignatureTypes.canonical_signature_entry(Exception, 0)
+ ws_response = ws_request.protocol.encode_response(public_method_name + 'Response', exception, return_type, ws_request.protocol_options)
+ send_web_service_response(ws_response)
+ else
+ if self.class.web_service_exception_reporting
+ message = exception.message
+ backtrace = "\nBacktrace:\n#{exception.backtrace.join("\n")}"
+ else
+ message = "Exception raised"
+ backtrace = ""
+ end
+ render :text => "Internal protocol error: #{message}#{backtrace}", :status => 500
+ end
+ end
+
+ def web_service_direct_invoke(invocation)
+ invocation.method_named_params.each do |name, value|
+ params[name] = value
+ end
+ web_service_direct_invoke_without_controller(invocation)
+ end
+
+ def log_request(ws_request, body)
+ unless logger.nil?
+ name = ws_request.method_name
+ api_method = ws_request.api_method
+ params = ws_request.method_params
+ if api_method && api_method.expects
+ params = api_method.expects.zip(params).map{ |type, param| "#{type.name}=>#{param.inspect}" }
+ else
+ params = params.map{ |param| param.inspect }
+ end
+ service = ws_request.service_name
+ logger.debug("\nWeb Service Request: #{name}(#{params.join(", ")}) Entrypoint: #{service}")
+ logger.debug(indent(body))
+ end
+ end
+
+ def log_response(ws_response, elapsed=nil)
+ unless logger.nil?
+ elapsed = (elapsed ? " (%f):" % elapsed : ":")
+ logger.debug("\nWeb Service Response" + elapsed + " => #{ws_response.return_value.inspect}")
+ logger.debug(indent(ws_response.body))
+ end
+ end
+
+ def indent(body)
+ body.split(/\n/).map{|x| " #{x}"}.join("\n")
+ end
+ end
+
+ module WsdlAction # :nodoc:
+ XsdNs = 'http://www.w3.org/2001/XMLSchema'
+ WsdlNs = 'http://schemas.xmlsoap.org/wsdl/'
+ SoapNs = 'http://schemas.xmlsoap.org/wsdl/soap/'
+ SoapEncodingNs = 'http://schemas.xmlsoap.org/soap/encoding/'
+ SoapHttpTransport = 'http://schemas.xmlsoap.org/soap/http'
+
+ def wsdl
+ case request.method
+ when :get
+ begin
+ options = { :type => 'text/xml', :disposition => 'inline' }
+ send_data(to_wsdl, options)
+ rescue Exception => e
+ log_error(e) unless logger.nil?
+ end
+ when :post
+ render :text => 'POST not supported', :status => 500
+ end
+ end
+
+ private
+ def base_uri
+ host = request.host_with_port
+ relative_url_root = request.relative_url_root
+ scheme = request.ssl? ? 'https' : 'http'
+ '%s://%s%s/%s/' % [scheme, host, relative_url_root, self.class.controller_path]
+ end
+
+ def to_wsdl
+ xml = ''
+ dispatching_mode = web_service_dispatching_mode
+ global_service_name = wsdl_service_name
+ namespace = wsdl_namespace || 'urn:ActionWebService'
+ soap_action_base = "/#{controller_name}"
+
+ marshaler = ActionWebService::Protocol::Soap::SoapMarshaler.new(namespace)
+ apis = {}
+ case dispatching_mode
+ when :direct
+ api = self.class.web_service_api
+ web_service_name = controller_class_name.sub(/Controller$/, '').underscore
+ apis[web_service_name] = [api, register_api(api, marshaler)]
+ when :delegated, :layered
+ self.class.web_services.each do |web_service_name, info|
+ service = web_service_object(web_service_name)
+ api = service.class.web_service_api
+ apis[web_service_name] = [api, register_api(api, marshaler)]
+ end
+ end
+ custom_types = []
+ apis.values.each do |api, bindings|
+ bindings.each do |b|
+ custom_types << b unless custom_types.include?(b)
+ end
+ end
+
+ xm = Builder::XmlMarkup.new(:target => xml, :indent => 2)
+ xm.instruct!
+ xm.definitions('name' => wsdl_service_name,
+ 'targetNamespace' => namespace,
+ 'xmlns:typens' => namespace,
+ 'xmlns:xsd' => XsdNs,
+ 'xmlns:soap' => SoapNs,
+ 'xmlns:soapenc' => SoapEncodingNs,
+ 'xmlns:wsdl' => WsdlNs,
+ 'xmlns' => WsdlNs) do
+ # Generate XSD
+ if custom_types.size > 0
+ xm.types do
+ xm.xsd(:schema, 'xmlns' => XsdNs, 'targetNamespace' => namespace) do
+ custom_types.each do |binding|
+ case
+ when binding.type.array?
+ xm.xsd(:complexType, 'name' => binding.type_name) do
+ xm.xsd(:complexContent) do
+ xm.xsd(:restriction, 'base' => 'soapenc:Array') do
+ xm.xsd(:attribute, 'ref' => 'soapenc:arrayType',
+ 'wsdl:arrayType' => binding.element_binding.qualified_type_name('typens') + '[]')
+ end
+ end
+ end
+ when binding.type.structured?
+ xm.xsd(:complexType, 'name' => binding.type_name) do
+ xm.xsd(:all) do
+ binding.type.each_member do |name, type|
+ b = marshaler.register_type(type)
+ xm.xsd(:element, 'name' => name, 'type' => b.qualified_type_name('typens'))
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+
+ # APIs
+ apis.each do |api_name, values|
+ api = values[0]
+ api.api_methods.each do |name, method|
+ gen = lambda do |msg_name, direction|
+ xm.message('name' => message_name_for(api_name, msg_name)) do
+ sym = nil
+ if direction == :out
+ returns = method.returns
+ if returns
+ binding = marshaler.register_type(returns[0])
+ xm.part('name' => 'return', 'type' => binding.qualified_type_name('typens'))
+ end
+ else
+ expects = method.expects
+ expects.each do |type|
+ binding = marshaler.register_type(type)
+ xm.part('name' => type.name, 'type' => binding.qualified_type_name('typens'))
+ end if expects
+ end
+ end
+ end
+ public_name = method.public_name
+ gen.call(public_name, :in)
+ gen.call("#{public_name}Response", :out)
+ end
+
+ # Port
+ port_name = port_name_for(global_service_name, api_name)
+ xm.portType('name' => port_name) do
+ api.api_methods.each do |name, method|
+ xm.operation('name' => method.public_name) do
+ xm.input('message' => "typens:" + message_name_for(api_name, method.public_name))
+ xm.output('message' => "typens:" + message_name_for(api_name, "#{method.public_name}Response"))
+ end
+ end
+ end
+
+ # Bind it
+ binding_name = binding_name_for(global_service_name, api_name)
+ xm.binding('name' => binding_name, 'type' => "typens:#{port_name}") do
+ xm.soap(:binding, 'style' => 'rpc', 'transport' => SoapHttpTransport)
+ api.api_methods.each do |name, method|
+ xm.operation('name' => method.public_name) do
+ case web_service_dispatching_mode
+ when :direct
+ soap_action = soap_action_base + "/api/" + method.public_name
+ when :delegated, :layered
+ soap_action = soap_action_base \
+ + "/" + api_name.to_s \
+ + "/" + method.public_name
+ end
+ xm.soap(:operation, 'soapAction' => soap_action)
+ xm.input do
+ xm.soap(:body,
+ 'use' => 'encoded',
+ 'namespace' => namespace,
+ 'encodingStyle' => SoapEncodingNs)
+ end
+ xm.output do
+ xm.soap(:body,
+ 'use' => 'encoded',
+ 'namespace' => namespace,
+ 'encodingStyle' => SoapEncodingNs)
+ end
+ end
+ end
+ end
+ end
+
+ # Define it
+ xm.service('name' => "#{global_service_name}Service") do
+ apis.each do |api_name, values|
+ port_name = port_name_for(global_service_name, api_name)
+ binding_name = binding_name_for(global_service_name, api_name)
+ case web_service_dispatching_mode
+ when :direct, :layered
+ binding_target = 'api'
+ when :delegated
+ binding_target = api_name.to_s
+ end
+ xm.port('name' => port_name, 'binding' => "typens:#{binding_name}") do
+ xm.soap(:address, 'location' => "#{base_uri}#{binding_target}")
+ end
+ end
+ end
+ end
+ end
+
+ def port_name_for(global_service, service)
+ "#{global_service}#{service.to_s.camelize}Port"
+ end
+
+ def binding_name_for(global_service, service)
+ "#{global_service}#{service.to_s.camelize}Binding"
+ end
+
+ def message_name_for(api_name, message_name)
+ mode = web_service_dispatching_mode
+ if mode == :layered || mode == :delegated
+ api_name.to_s + '-' + message_name
+ else
+ message_name
+ end
+ end
+
+ def register_api(api, marshaler)
+ bindings = {}
+ traverse_custom_types(api, marshaler, bindings) do |binding|
+ bindings[binding] = nil unless bindings.has_key?(binding)
+ element_binding = binding.element_binding
+ bindings[element_binding] = nil if element_binding && !bindings.has_key?(element_binding)
+ end
+ bindings.keys
+ end
+
+ def traverse_custom_types(api, marshaler, bindings, &block)
+ api.api_methods.each do |name, method|
+ expects, returns = method.expects, method.returns
+ expects.each{ |type| traverse_type(marshaler, type, bindings, &block) if type.custom? } if expects
+ returns.each{ |type| traverse_type(marshaler, type, bindings, &block) if type.custom? } if returns
+ end
+ end
+
+ def traverse_type(marshaler, type, bindings, &block)
+ binding = marshaler.register_type(type)
+ return if bindings.has_key?(binding)
+ bindings[binding] = nil
+ yield binding
+ if type.array?
+ yield marshaler.register_type(type.element_type)
+ type = type.element_type
+ end
+ type.each_member{ |name, type| traverse_type(marshaler, type, bindings, &block) } if type.structured?
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/invocation.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/invocation.rb
new file mode 100644
index 000000000..2a9121ee2
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/invocation.rb
@@ -0,0 +1,202 @@
+module ActionWebService # :nodoc:
+ module Invocation # :nodoc:
+ class InvocationError < ActionWebService::ActionWebServiceError # :nodoc:
+ end
+
+ def self.included(base) # :nodoc:
+ base.extend(ClassMethods)
+ base.send(:include, ActionWebService::Invocation::InstanceMethods)
+ end
+
+ # Invocation interceptors provide a means to execute custom code before
+ # and after method invocations on ActionWebService::Base objects.
+ #
+ # When running in _Direct_ dispatching mode, ActionController filters
+ # should be used for this functionality instead.
+ #
+ # The semantics of invocation interceptors are the same as ActionController
+ # filters, and accept the same parameters and options.
+ #
+ # A _before_ interceptor can also cancel execution by returning +false+,
+ # or returning a [false, "cancel reason"] array if it wishes to supply
+ # a reason for canceling the request.
+ #
+ # === Example
+ #
+ # class CustomService < ActionWebService::Base
+ # before_invocation :intercept_add, :only => [:add]
+ #
+ # def add(a, b)
+ # a + b
+ # end
+ #
+ # private
+ # def intercept_add
+ # return [false, "permission denied"] # cancel it
+ # end
+ # end
+ #
+ # Options:
+ # [:except ] A list of methods for which the interceptor will NOT be called
+ # [:only ] A list of methods for which the interceptor WILL be called
+ module ClassMethods
+ # Appends the given +interceptors+ to be called
+ # _before_ method invocation.
+ def append_before_invocation(*interceptors, &block)
+ conditions = extract_conditions!(interceptors)
+ interceptors << block if block_given?
+ add_interception_conditions(interceptors, conditions)
+ append_interceptors_to_chain("before", interceptors)
+ end
+
+ # Prepends the given +interceptors+ to be called
+ # _before_ method invocation.
+ def prepend_before_invocation(*interceptors, &block)
+ conditions = extract_conditions!(interceptors)
+ interceptors << block if block_given?
+ add_interception_conditions(interceptors, conditions)
+ prepend_interceptors_to_chain("before", interceptors)
+ end
+
+ alias :before_invocation :append_before_invocation
+
+ # Appends the given +interceptors+ to be called
+ # _after_ method invocation.
+ def append_after_invocation(*interceptors, &block)
+ conditions = extract_conditions!(interceptors)
+ interceptors << block if block_given?
+ add_interception_conditions(interceptors, conditions)
+ append_interceptors_to_chain("after", interceptors)
+ end
+
+ # Prepends the given +interceptors+ to be called
+ # _after_ method invocation.
+ def prepend_after_invocation(*interceptors, &block)
+ conditions = extract_conditions!(interceptors)
+ interceptors << block if block_given?
+ add_interception_conditions(interceptors, conditions)
+ prepend_interceptors_to_chain("after", interceptors)
+ end
+
+ alias :after_invocation :append_after_invocation
+
+ def before_invocation_interceptors # :nodoc:
+ read_inheritable_attribute("before_invocation_interceptors")
+ end
+
+ def after_invocation_interceptors # :nodoc:
+ read_inheritable_attribute("after_invocation_interceptors")
+ end
+
+ def included_intercepted_methods # :nodoc:
+ read_inheritable_attribute("included_intercepted_methods") || {}
+ end
+
+ def excluded_intercepted_methods # :nodoc:
+ read_inheritable_attribute("excluded_intercepted_methods") || {}
+ end
+
+ private
+ def append_interceptors_to_chain(condition, interceptors)
+ write_inheritable_array("#{condition}_invocation_interceptors", interceptors)
+ end
+
+ def prepend_interceptors_to_chain(condition, interceptors)
+ interceptors = interceptors + read_inheritable_attribute("#{condition}_invocation_interceptors")
+ write_inheritable_attribute("#{condition}_invocation_interceptors", interceptors)
+ end
+
+ def extract_conditions!(interceptors)
+ return nil unless interceptors.last.is_a? Hash
+ interceptors.pop
+ end
+
+ def add_interception_conditions(interceptors, conditions)
+ return unless conditions
+ included, excluded = conditions[:only], conditions[:except]
+ write_inheritable_hash("included_intercepted_methods", condition_hash(interceptors, included)) && return if included
+ write_inheritable_hash("excluded_intercepted_methods", condition_hash(interceptors, excluded)) if excluded
+ end
+
+ def condition_hash(interceptors, *methods)
+ interceptors.inject({}) {|hash, interceptor| hash.merge(interceptor => methods.flatten.map {|method| method.to_s})}
+ end
+ end
+
+ module InstanceMethods # :nodoc:
+ def self.included(base)
+ base.class_eval do
+ alias_method_chain :perform_invocation, :interception
+ end
+ end
+
+ def perform_invocation_with_interception(method_name, params, &block)
+ return if before_invocation(method_name, params, &block) == false
+ return_value = perform_invocation_without_interception(method_name, params)
+ after_invocation(method_name, params, return_value)
+ return_value
+ end
+
+ def perform_invocation(method_name, params)
+ send(method_name, *params)
+ end
+
+ def before_invocation(name, args, &block)
+ call_interceptors(self.class.before_invocation_interceptors, [name, args], &block)
+ end
+
+ def after_invocation(name, args, result)
+ call_interceptors(self.class.after_invocation_interceptors, [name, args, result])
+ end
+
+ private
+
+ def call_interceptors(interceptors, interceptor_args, &block)
+ if interceptors and not interceptors.empty?
+ interceptors.each do |interceptor|
+ next if method_exempted?(interceptor, interceptor_args[0].to_s)
+ result = case
+ when interceptor.is_a?(Symbol)
+ self.send(interceptor, *interceptor_args)
+ when interceptor_block?(interceptor)
+ interceptor.call(self, *interceptor_args)
+ when interceptor_class?(interceptor)
+ interceptor.intercept(self, *interceptor_args)
+ else
+ raise(
+ InvocationError,
+ "Interceptors need to be either a symbol, proc/method, or a class implementing a static intercept method"
+ )
+ end
+ reason = nil
+ if result.is_a?(Array)
+ reason = result[1] if result[1]
+ result = result[0]
+ end
+ if result == false
+ block.call(reason) if block && reason
+ return false
+ end
+ end
+ end
+ end
+
+ def interceptor_block?(interceptor)
+ interceptor.respond_to?("call") && (interceptor.arity == 3 || interceptor.arity == -1)
+ end
+
+ def interceptor_class?(interceptor)
+ interceptor.respond_to?("intercept")
+ end
+
+ def method_exempted?(interceptor, method_name)
+ case
+ when self.class.included_intercepted_methods[interceptor]
+ !self.class.included_intercepted_methods[interceptor].include?(method_name)
+ when self.class.excluded_intercepted_methods[interceptor]
+ self.class.excluded_intercepted_methods[interceptor].include?(method_name)
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol.rb
new file mode 100644
index 000000000..053e9cb4b
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol.rb
@@ -0,0 +1,4 @@
+require 'action_web_service/protocol/abstract'
+require 'action_web_service/protocol/discovery'
+require 'action_web_service/protocol/soap_protocol'
+require 'action_web_service/protocol/xmlrpc_protocol'
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/abstract.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/abstract.rb
new file mode 100644
index 000000000..fff5f622c
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/abstract.rb
@@ -0,0 +1,112 @@
+module ActionWebService # :nodoc:
+ module Protocol # :nodoc:
+ class ProtocolError < ActionWebServiceError # :nodoc:
+ end
+
+ class AbstractProtocol # :nodoc:
+ def setup(controller)
+ end
+
+ def decode_action_pack_request(action_pack_request)
+ end
+
+ def encode_action_pack_request(service_name, public_method_name, raw_body, options={})
+ klass = options[:request_class] || SimpleActionPackRequest
+ request = klass.new
+ request.request_parameters['action'] = service_name.to_s
+ request.env['RAW_POST_DATA'] = raw_body
+ request.env['REQUEST_METHOD'] = 'POST'
+ request.env['HTTP_CONTENT_TYPE'] = 'text/xml'
+ request
+ end
+
+ def decode_request(raw_request, service_name, protocol_options={})
+ end
+
+ def encode_request(method_name, params, param_types)
+ end
+
+ def decode_response(raw_response)
+ end
+
+ def encode_response(method_name, return_value, return_type, protocol_options={})
+ end
+
+ def protocol_client(api, protocol_name, endpoint_uri, options)
+ end
+
+ def register_api(api)
+ end
+ end
+
+ class Request # :nodoc:
+ attr :protocol
+ attr_accessor :method_name
+ attr_accessor :method_params
+ attr :service_name
+ attr_accessor :api
+ attr_accessor :api_method
+ attr :protocol_options
+
+ def initialize(protocol, method_name, method_params, service_name, api=nil, api_method=nil, protocol_options=nil)
+ @protocol = protocol
+ @method_name = method_name
+ @method_params = method_params
+ @service_name = service_name
+ @api = api
+ @api_method = api_method
+ @protocol_options = protocol_options || {}
+ end
+ end
+
+ class Response # :nodoc:
+ attr :body
+ attr :content_type
+ attr :return_value
+
+ def initialize(body, content_type, return_value)
+ @body = body
+ @content_type = content_type
+ @return_value = return_value
+ end
+ end
+
+ class SimpleActionPackRequest < ActionController::AbstractRequest # :nodoc:
+ def initialize
+ @env = {}
+ @qparams = {}
+ @rparams = {}
+ @cookies = {}
+ reset_session
+ end
+
+ def query_parameters
+ @qparams
+ end
+
+ def request_parameters
+ @rparams
+ end
+
+ def env
+ @env
+ end
+
+ def host
+ ''
+ end
+
+ def cookies
+ @cookies
+ end
+
+ def session
+ @session
+ end
+
+ def reset_session
+ @session = {}
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/discovery.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/discovery.rb
new file mode 100644
index 000000000..3d4e0818d
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/discovery.rb
@@ -0,0 +1,37 @@
+module ActionWebService # :nodoc:
+ module Protocol # :nodoc:
+ module Discovery # :nodoc:
+ def self.included(base)
+ base.extend(ClassMethods)
+ base.send(:include, ActionWebService::Protocol::Discovery::InstanceMethods)
+ end
+
+ module ClassMethods # :nodoc:
+ def register_protocol(klass)
+ write_inheritable_array("web_service_protocols", [klass])
+ end
+ end
+
+ module InstanceMethods # :nodoc:
+ private
+ def discover_web_service_request(action_pack_request)
+ (self.class.read_inheritable_attribute("web_service_protocols") || []).each do |protocol|
+ protocol = protocol.create(self)
+ request = protocol.decode_action_pack_request(action_pack_request)
+ return request unless request.nil?
+ end
+ nil
+ end
+
+ def create_web_service_client(api, protocol_name, endpoint_uri, options)
+ (self.class.read_inheritable_attribute("web_service_protocols") || []).each do |protocol|
+ protocol = protocol.create(self)
+ client = protocol.protocol_client(api, protocol_name, endpoint_uri, options)
+ return client unless client.nil?
+ end
+ nil
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb
new file mode 100644
index 000000000..1bce496a7
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb
@@ -0,0 +1,176 @@
+require 'action_web_service/protocol/soap_protocol/marshaler'
+require 'soap/streamHandler'
+require 'action_web_service/client/soap_client'
+
+module ActionWebService # :nodoc:
+ module API # :nodoc:
+ class Base # :nodoc:
+ def self.soap_client(endpoint_uri, options={})
+ ActionWebService::Client::Soap.new self, endpoint_uri, options
+ end
+ end
+ end
+
+ module Protocol # :nodoc:
+ module Soap # :nodoc:
+ def self.included(base)
+ base.register_protocol(SoapProtocol)
+ base.class_inheritable_option(:wsdl_service_name)
+ base.class_inheritable_option(:wsdl_namespace)
+ end
+
+ class SoapProtocol < AbstractProtocol # :nodoc:
+ AWSEncoding = 'UTF-8'
+ XSDEncoding = 'UTF8'
+
+ attr :marshaler
+
+ def initialize(namespace=nil)
+ namespace ||= 'urn:ActionWebService'
+ @marshaler = SoapMarshaler.new namespace
+ end
+
+ def self.create(controller)
+ SoapProtocol.new(controller.wsdl_namespace)
+ end
+
+ def decode_action_pack_request(action_pack_request)
+ return nil unless soap_action = has_valid_soap_action?(action_pack_request)
+ service_name = action_pack_request.parameters['action']
+ input_encoding = parse_charset(action_pack_request.env['HTTP_CONTENT_TYPE'])
+ protocol_options = {
+ :soap_action => soap_action,
+ :charset => input_encoding
+ }
+ decode_request(action_pack_request.raw_post, service_name, protocol_options)
+ end
+
+ def encode_action_pack_request(service_name, public_method_name, raw_body, options={})
+ request = super
+ request.env['HTTP_SOAPACTION'] = '/soap/%s/%s' % [service_name, public_method_name]
+ request
+ end
+
+ def decode_request(raw_request, service_name, protocol_options={})
+ envelope = SOAP::Processor.unmarshal(raw_request, :charset => protocol_options[:charset])
+ unless envelope
+ raise ProtocolError, "Failed to parse SOAP request message"
+ end
+ request = envelope.body.request
+ method_name = request.elename.name
+ params = request.collect{ |k, v| marshaler.soap_to_ruby(request[k]) }
+ Request.new(self, method_name, params, service_name, nil, nil, protocol_options)
+ end
+
+ def encode_request(method_name, params, param_types)
+ param_types.each{ |type| marshaler.register_type(type) } if param_types
+ qname = XSD::QName.new(marshaler.namespace, method_name)
+ param_def = []
+ if param_types
+ params = param_types.zip(params).map do |type, param|
+ param_def << ['in', type.name, marshaler.lookup_type(type).mapping]
+ [type.name, marshaler.ruby_to_soap(param)]
+ end
+ else
+ params = []
+ end
+ request = SOAP::RPC::SOAPMethodRequest.new(qname, param_def)
+ request.set_param(params)
+ envelope = create_soap_envelope(request)
+ SOAP::Processor.marshal(envelope)
+ end
+
+ def decode_response(raw_response)
+ envelope = SOAP::Processor.unmarshal(raw_response)
+ unless envelope
+ raise ProtocolError, "Failed to parse SOAP request message"
+ end
+ method_name = envelope.body.request.elename.name
+ return_value = envelope.body.response
+ return_value = marshaler.soap_to_ruby(return_value) unless return_value.nil?
+ [method_name, return_value]
+ end
+
+ def encode_response(method_name, return_value, return_type, protocol_options={})
+ if return_type
+ return_binding = marshaler.register_type(return_type)
+ marshaler.annotate_arrays(return_binding, return_value)
+ end
+ qname = XSD::QName.new(marshaler.namespace, method_name)
+ if return_value.nil?
+ response = SOAP::RPC::SOAPMethodResponse.new(qname, nil)
+ else
+ if return_value.is_a?(Exception)
+ detail = SOAP::Mapping::SOAPException.new(return_value)
+ response = SOAP::SOAPFault.new(
+ SOAP::SOAPQName.new('%s:%s' % [SOAP::SOAPNamespaceTag, 'Server']),
+ SOAP::SOAPString.new(return_value.to_s),
+ SOAP::SOAPString.new(self.class.name),
+ marshaler.ruby_to_soap(detail))
+ else
+ if return_type
+ param_def = [['retval', 'return', marshaler.lookup_type(return_type).mapping]]
+ response = SOAP::RPC::SOAPMethodResponse.new(qname, param_def)
+ response.retval = marshaler.ruby_to_soap(return_value)
+ else
+ response = SOAP::RPC::SOAPMethodResponse.new(qname, nil)
+ end
+ end
+ end
+ envelope = create_soap_envelope(response)
+
+ # FIXME: This is not thread-safe, but StringFactory_ in SOAP4R only
+ # reads target encoding from the XSD::Charset.encoding variable.
+ # This is required to ensure $KCODE strings are converted
+ # correctly to UTF-8 for any values of $KCODE.
+ previous_encoding = XSD::Charset.encoding
+ XSD::Charset.encoding = XSDEncoding
+ response_body = SOAP::Processor.marshal(envelope, :charset => AWSEncoding)
+ XSD::Charset.encoding = previous_encoding
+
+ Response.new(response_body, "text/xml; charset=#{AWSEncoding}", return_value)
+ end
+
+ def protocol_client(api, protocol_name, endpoint_uri, options={})
+ return nil unless protocol_name == :soap
+ ActionWebService::Client::Soap.new(api, endpoint_uri, options)
+ end
+
+ def register_api(api)
+ api.api_methods.each do |name, method|
+ method.expects.each{ |type| marshaler.register_type(type) } if method.expects
+ method.returns.each{ |type| marshaler.register_type(type) } if method.returns
+ end
+ end
+
+ private
+ def has_valid_soap_action?(request)
+ return nil unless request.method == :post
+ soap_action = request.env['HTTP_SOAPACTION']
+ return nil unless soap_action
+ soap_action = soap_action.dup
+ soap_action.gsub!(/^"/, '')
+ soap_action.gsub!(/"$/, '')
+ soap_action.strip!
+ return nil if soap_action.empty?
+ soap_action
+ end
+
+ def create_soap_envelope(body)
+ header = SOAP::SOAPHeader.new
+ body = SOAP::SOAPBody.new(body)
+ SOAP::SOAPEnvelope.new(header, body)
+ end
+
+ def parse_charset(content_type)
+ return AWSEncoding if content_type.nil?
+ if /^text\/xml(?:\s*;\s*charset=([^"]+|"[^"]+"))$/i =~ content_type
+ $1
+ else
+ AWSEncoding
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb
new file mode 100644
index 000000000..187339627
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb
@@ -0,0 +1,235 @@
+require 'soap/mapping'
+
+module ActionWebService
+ module Protocol
+ module Soap
+ # Workaround for SOAP4R return values changing
+ class Registry < SOAP::Mapping::Registry
+ if SOAP::Version >= "1.5.4"
+ def find_mapped_soap_class(obj_class)
+ return @map.instance_eval { @obj2soap[obj_class][0] }
+ end
+
+ def find_mapped_obj_class(soap_class)
+ return @map.instance_eval { @soap2obj[soap_class][0] }
+ end
+ end
+ end
+
+ class SoapMarshaler
+ attr :namespace
+ attr :registry
+
+ def initialize(namespace=nil)
+ @namespace = namespace || 'urn:ActionWebService'
+ @registry = Registry.new
+ @type2binding = {}
+ register_static_factories
+ end
+
+ def soap_to_ruby(obj)
+ SOAP::Mapping.soap2obj(obj, @registry)
+ end
+
+ def ruby_to_soap(obj)
+ soap = SOAP::Mapping.obj2soap(obj, @registry)
+ soap.elename = XSD::QName.new if SOAP::Version >= "1.5.5" && soap.elename == XSD::QName::EMPTY
+ soap
+ end
+
+ def register_type(type)
+ return @type2binding[type] if @type2binding.has_key?(type)
+
+ if type.array?
+ array_mapping = @registry.find_mapped_soap_class(Array)
+ qname = XSD::QName.new(@namespace, soap_type_name(type.element_type.type_class.name) + 'Array')
+ element_type_binding = register_type(type.element_type)
+ @type2binding[type] = SoapBinding.new(self, qname, type, array_mapping, element_type_binding)
+ elsif (mapping = @registry.find_mapped_soap_class(type.type_class) rescue nil)
+ qname = mapping[2] ? mapping[2][:type] : nil
+ qname ||= soap_base_type_name(mapping[0])
+ @type2binding[type] = SoapBinding.new(self, qname, type, mapping)
+ else
+ qname = XSD::QName.new(@namespace, soap_type_name(type.type_class.name))
+ @registry.add(type.type_class,
+ SOAP::SOAPStruct,
+ typed_struct_factory(type.type_class),
+ { :type => qname })
+ mapping = @registry.find_mapped_soap_class(type.type_class)
+ @type2binding[type] = SoapBinding.new(self, qname, type, mapping)
+ end
+
+ if type.structured?
+ type.each_member do |m_name, m_type|
+ register_type(m_type)
+ end
+ end
+
+ @type2binding[type]
+ end
+ alias :lookup_type :register_type
+
+ def annotate_arrays(binding, value)
+ if value.nil?
+ return
+ elsif binding.type.array?
+ mark_typed_array(value, binding.element_binding.qname)
+ if binding.element_binding.type.custom?
+ value.each do |element|
+ annotate_arrays(binding.element_binding, element)
+ end
+ end
+ elsif binding.type.structured?
+ binding.type.each_member do |name, type|
+ member_binding = register_type(type)
+ member_value = value.respond_to?('[]') ? value[name] : value.send(name)
+ annotate_arrays(member_binding, member_value) if type.custom?
+ end
+ end
+ end
+
+ private
+ def typed_struct_factory(type_class)
+ if Object.const_defined?('ActiveRecord')
+ if type_class.ancestors.include?(ActiveRecord::Base)
+ qname = XSD::QName.new(@namespace, soap_type_name(type_class.name))
+ type_class.instance_variable_set('@qname', qname)
+ return SoapActiveRecordStructFactory.new
+ end
+ end
+ SOAP::Mapping::Registry::TypedStructFactory
+ end
+
+ def mark_typed_array(array, qname)
+ (class << array; self; end).class_eval do
+ define_method(:arytype) do
+ qname
+ end
+ end
+ end
+
+ def soap_base_type_name(type)
+ xsd_type = type.ancestors.find{ |c| c.const_defined? 'Type' }
+ xsd_type ? xsd_type.const_get('Type') : XSD::XSDAnySimpleType::Type
+ end
+
+ def soap_type_name(type_name)
+ type_name.gsub(/::/, '..')
+ end
+
+ def register_static_factories
+ @registry.add(ActionWebService::Base64, SOAP::SOAPBase64, SoapBase64Factory.new, nil)
+ mapping = @registry.find_mapped_soap_class(ActionWebService::Base64)
+ @type2binding[ActionWebService::Base64] =
+ SoapBinding.new(self, SOAP::SOAPBase64::Type, ActionWebService::Base64, mapping)
+ @registry.add(Array, SOAP::SOAPArray, SoapTypedArrayFactory.new, nil)
+ @registry.add(::BigDecimal, SOAP::SOAPDouble, SOAP::Mapping::Registry::BasetypeFactory, {:derived_class => true})
+ end
+ end
+
+ class SoapBinding
+ attr :qname
+ attr :type
+ attr :mapping
+ attr :element_binding
+
+ def initialize(marshaler, qname, type, mapping, element_binding=nil)
+ @marshaler = marshaler
+ @qname = qname
+ @type = type
+ @mapping = mapping
+ @element_binding = element_binding
+ end
+
+ def type_name
+ @type.custom? ? @qname.name : nil
+ end
+
+ def qualified_type_name(ns=nil)
+ if @type.custom?
+ "#{ns ? ns : @qname.namespace}:#{@qname.name}"
+ else
+ ns = XSD::NS.new
+ ns.assign(XSD::Namespace, SOAP::XSDNamespaceTag)
+ ns.assign(SOAP::EncodingNamespace, "soapenc")
+ xsd_klass = mapping[0].ancestors.find{|c| c.const_defined?('Type')}
+ return ns.name(XSD::AnyTypeName) unless xsd_klass
+ ns.name(xsd_klass.const_get('Type'))
+ end
+ end
+
+ def eql?(other)
+ @qname == other.qname
+ end
+ alias :== :eql?
+
+ def hash
+ @qname.hash
+ end
+ end
+
+ class SoapActiveRecordStructFactory < SOAP::Mapping::Factory
+ def obj2soap(soap_class, obj, info, map)
+ unless obj.is_a?(ActiveRecord::Base)
+ return nil
+ end
+ soap_obj = soap_class.new(obj.class.instance_variable_get('@qname'))
+ obj.class.columns.each do |column|
+ key = column.name.to_s
+ value = obj.send(key)
+ soap_obj[key] = SOAP::Mapping._obj2soap(value, map)
+ end
+ soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ unless node.type == obj_class.instance_variable_get('@qname')
+ return false
+ end
+ obj = obj_class.new
+ node.each do |key, value|
+ obj[key] = value.data
+ end
+ obj.instance_variable_set('@new_record', false)
+ return true, obj
+ end
+ end
+
+ class SoapTypedArrayFactory < SOAP::Mapping::Factory
+ def obj2soap(soap_class, obj, info, map)
+ unless obj.respond_to?(:arytype)
+ return nil
+ end
+ soap_obj = soap_class.new(SOAP::ValueArrayName, 1, obj.arytype)
+ mark_marshalled_obj(obj, soap_obj)
+ obj.each do |item|
+ child = SOAP::Mapping._obj2soap(item, map)
+ soap_obj.add(child)
+ end
+ soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ return false
+ end
+ end
+
+ class SoapBase64Factory < SOAP::Mapping::Factory
+ def obj2soap(soap_class, obj, info, map)
+ unless obj.is_a?(ActionWebService::Base64)
+ return nil
+ end
+ return soap_class.new(obj)
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ unless node.type == SOAP::SOAPBase64::Type
+ return false
+ end
+ return true, obj_class.new(node.string)
+ end
+ end
+
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb
new file mode 100644
index 000000000..dfa4afc67
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb
@@ -0,0 +1,122 @@
+require 'xmlrpc/marshal'
+require 'action_web_service/client/xmlrpc_client'
+
+module XMLRPC # :nodoc:
+ class FaultException # :nodoc:
+ alias :message :faultString
+ end
+
+ class Create
+ def wrong_type(value)
+ if BigDecimal === value
+ [true, value.to_f]
+ else
+ false
+ end
+ end
+ end
+end
+
+module ActionWebService # :nodoc:
+ module API # :nodoc:
+ class Base # :nodoc:
+ def self.xmlrpc_client(endpoint_uri, options={})
+ ActionWebService::Client::XmlRpc.new self, endpoint_uri, options
+ end
+ end
+ end
+
+ module Protocol # :nodoc:
+ module XmlRpc # :nodoc:
+ def self.included(base)
+ base.register_protocol(XmlRpcProtocol)
+ end
+
+ class XmlRpcProtocol < AbstractProtocol # :nodoc:
+ def self.create(controller)
+ XmlRpcProtocol.new
+ end
+
+ def decode_action_pack_request(action_pack_request)
+ service_name = action_pack_request.parameters['action']
+ decode_request(action_pack_request.raw_post, service_name)
+ end
+
+ def decode_request(raw_request, service_name)
+ method_name, params = XMLRPC::Marshal.load_call(raw_request)
+ Request.new(self, method_name, params, service_name)
+ rescue
+ return nil
+ end
+
+ def encode_request(method_name, params, param_types)
+ if param_types
+ params = params.dup
+ param_types.each_with_index{ |type, i| params[i] = value_to_xmlrpc_wire_format(params[i], type) }
+ end
+ XMLRPC::Marshal.dump_call(method_name, *params)
+ end
+
+ def decode_response(raw_response)
+ [nil, XMLRPC::Marshal.load_response(raw_response)]
+ end
+
+ def encode_response(method_name, return_value, return_type, protocol_options={})
+ if return_value && return_type
+ return_value = value_to_xmlrpc_wire_format(return_value, return_type)
+ end
+ return_value = false if return_value.nil?
+ raw_response = XMLRPC::Marshal.dump_response(return_value)
+ Response.new(raw_response, 'text/xml', return_value)
+ end
+
+ def encode_multicall_response(responses, protocol_options={})
+ result = responses.map do |return_value, return_type|
+ if return_value && return_type
+ return_value = value_to_xmlrpc_wire_format(return_value, return_type)
+ return_value = [return_value] unless return_value.nil?
+ end
+ return_value = false if return_value.nil?
+ return_value
+ end
+ raw_response = XMLRPC::Marshal.dump_response(result)
+ Response.new(raw_response, 'text/xml', result)
+ end
+
+ def protocol_client(api, protocol_name, endpoint_uri, options={})
+ return nil unless protocol_name == :xmlrpc
+ ActionWebService::Client::XmlRpc.new(api, endpoint_uri, options)
+ end
+
+ def value_to_xmlrpc_wire_format(value, value_type)
+ if value_type.array?
+ value.map{ |val| value_to_xmlrpc_wire_format(val, value_type.element_type) }
+ else
+ if value.is_a?(ActionWebService::Struct)
+ struct = {}
+ value.class.members.each do |name, type|
+ member_value = value[name]
+ next if member_value.nil?
+ struct[name.to_s] = value_to_xmlrpc_wire_format(member_value, type)
+ end
+ struct
+ elsif value.is_a?(ActiveRecord::Base)
+ struct = {}
+ value.attributes.each do |key, member_value|
+ next if member_value.nil?
+ struct[key.to_s] = member_value
+ end
+ struct
+ elsif value.is_a?(ActionWebService::Base64)
+ XMLRPC::Base64.new(value)
+ elsif value.is_a?(Exception) && !value.is_a?(XMLRPC::FaultException)
+ XMLRPC::FaultException.new(2, value.message)
+ else
+ value
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/scaffolding.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/scaffolding.rb
new file mode 100644
index 000000000..f94a7ee91
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/scaffolding.rb
@@ -0,0 +1,283 @@
+require 'benchmark'
+require 'pathname'
+
+module ActionWebService
+ module Scaffolding # :nodoc:
+ class ScaffoldingError < ActionWebServiceError # :nodoc:
+ end
+
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ # Web service invocation scaffolding provides a way to quickly invoke web service methods in a controller. The
+ # generated scaffold actions have default views to let you enter the method parameters and view the
+ # results.
+ #
+ # Example:
+ #
+ # class ApiController < ActionController
+ # web_service_scaffold :invoke
+ # end
+ #
+ # This example generates an +invoke+ action in the +ApiController+ that you can navigate to from
+ # your browser, select the API method, enter its parameters, and perform the invocation.
+ #
+ # If you want to customize the default views, create the following views in "app/views":
+ #
+ # * action_name/methods.erb
+ # * action_name/parameters.erb
+ # * action_name/result.erb
+ # * action_name/layout.erb
+ #
+ # Where action_name is the name of the action you gave to ClassMethods#web_service_scaffold.
+ #
+ # You can use the default views in RAILS_DIR/lib/action_web_service/templates/scaffolds as
+ # a guide.
+ module ClassMethods
+ # Generates web service invocation scaffolding for the current controller. The given action name
+ # can then be used as the entry point for invoking API methods from a web browser.
+ def web_service_scaffold(action_name)
+ add_template_helper(Helpers)
+ module_eval <<-"end_eval", __FILE__, __LINE__ + 1
+ def #{action_name}
+ if request.method == :get
+ setup_invocation_assigns
+ render_invocation_scaffold 'methods'
+ end
+ end
+
+ def #{action_name}_method_params
+ if request.method == :get
+ setup_invocation_assigns
+ render_invocation_scaffold 'parameters'
+ end
+ end
+
+ def #{action_name}_submit
+ if request.method == :post
+ setup_invocation_assigns
+ protocol_name = params['protocol'] ? params['protocol'].to_sym : :soap
+ case protocol_name
+ when :soap
+ @protocol = Protocol::Soap::SoapProtocol.create(self)
+ when :xmlrpc
+ @protocol = Protocol::XmlRpc::XmlRpcProtocol.create(self)
+ end
+ bm = Benchmark.measure do
+ @protocol.register_api(@scaffold_service.api)
+ post_params = params['method_params'] ? params['method_params'].dup : nil
+ params = []
+ @scaffold_method.expects.each_with_index do |spec, i|
+ params << post_params[i.to_s]
+ end if @scaffold_method.expects
+ params = @scaffold_method.cast_expects(params)
+ method_name = public_method_name(@scaffold_service.name, @scaffold_method.public_name)
+ @method_request_xml = @protocol.encode_request(method_name, params, @scaffold_method.expects)
+ new_request = @protocol.encode_action_pack_request(@scaffold_service.name, @scaffold_method.public_name, @method_request_xml)
+ prepare_request(new_request, @scaffold_service.name, @scaffold_method.public_name)
+ self.request = new_request
+ if @scaffold_container.dispatching_mode != :direct
+ request.parameters['action'] = @scaffold_service.name
+ end
+ dispatch_web_service_request
+ @method_response_xml = response.body
+ method_name, obj = @protocol.decode_response(@method_response_xml)
+ return if handle_invocation_exception(obj)
+ @method_return_value = @scaffold_method.cast_returns(obj)
+ end
+ @method_elapsed = bm.real
+ add_instance_variables_to_assigns
+ reset_invocation_response
+ render_invocation_scaffold 'result'
+ end
+ end
+
+ private
+ def setup_invocation_assigns
+ @scaffold_class = self.class
+ @scaffold_action_name = "#{action_name}"
+ @scaffold_container = WebServiceModel::Container.new(self)
+ if params['service'] && params['method']
+ @scaffold_service = @scaffold_container.services.find{ |x| x.name == params['service'] }
+ @scaffold_method = @scaffold_service.api_methods[params['method']]
+ end
+ add_instance_variables_to_assigns
+ end
+
+ def render_invocation_scaffold(action)
+ customized_template = "\#{self.class.controller_path}/#{action_name}/\#{action}"
+ default_template = scaffold_path(action)
+ if template_exists?(customized_template)
+ content = @template.render :file => customized_template
+ else
+ content = @template.render :file => default_template
+ end
+ @template.instance_variable_set("@content_for_layout", content)
+ if self.active_layout.nil?
+ render :file => scaffold_path("layout")
+ else
+ render :file => self.active_layout
+ end
+ end
+
+ def scaffold_path(template_name)
+ File.dirname(__FILE__) + "/templates/scaffolds/" + template_name + ".erb"
+ end
+
+ def reset_invocation_response
+ erase_render_results
+ response.headers = ::ActionController::AbstractResponse::DEFAULT_HEADERS.merge("cookie" => [])
+ end
+
+ def public_method_name(service_name, method_name)
+ if web_service_dispatching_mode == :layered && @protocol.is_a?(ActionWebService::Protocol::XmlRpc::XmlRpcProtocol)
+ service_name + '.' + method_name
+ else
+ method_name
+ end
+ end
+
+ def prepare_request(new_request, service_name, method_name)
+ new_request.parameters.update(request.parameters)
+ request.env.each{ |k, v| new_request.env[k] = v unless new_request.env.has_key?(k) }
+ if web_service_dispatching_mode == :layered && @protocol.is_a?(ActionWebService::Protocol::Soap::SoapProtocol)
+ new_request.env['HTTP_SOAPACTION'] = "/\#{controller_name()}/\#{service_name}/\#{method_name}"
+ end
+ end
+
+ def handle_invocation_exception(obj)
+ exception = nil
+ if obj.respond_to?(:detail) && obj.detail.respond_to?(:cause) && obj.detail.cause.is_a?(Exception)
+ exception = obj.detail.cause
+ elsif obj.is_a?(XMLRPC::FaultException)
+ exception = obj
+ end
+ return unless exception
+ reset_invocation_response
+ rescue_action(exception)
+ true
+ end
+ end_eval
+ end
+ end
+
+ module Helpers # :nodoc:
+ def method_parameter_input_fields(method, type, field_name_base, idx, was_structured=false)
+ if type.array?
+ return content_tag('em', "Typed array input fields not supported yet (#{type.name})")
+ end
+ if type.structured?
+ return content_tag('em', "Nested structural types not supported yet (#{type.name})") if was_structured
+ parameters = ""
+ type.each_member do |member_name, member_type|
+ label = method_parameter_label(member_name, member_type)
+ nested_content = method_parameter_input_fields(
+ method,
+ member_type,
+ "#{field_name_base}[#{idx}][#{member_name}]",
+ idx,
+ true)
+ if member_type.custom?
+ parameters << content_tag('li', label)
+ parameters << content_tag('ul', nested_content)
+ else
+ parameters << content_tag('li', label + ' ' + nested_content)
+ end
+ end
+ content_tag('ul', parameters)
+ else
+ # If the data source was structured previously we already have the index set
+ field_name_base = "#{field_name_base}[#{idx}]" unless was_structured
+
+ case type.type
+ when :int
+ text_field_tag "#{field_name_base}"
+ when :string
+ text_field_tag "#{field_name_base}"
+ when :base64
+ text_area_tag "#{field_name_base}", nil, :size => "40x5"
+ when :bool
+ radio_button_tag("#{field_name_base}", "true") + " True" +
+ radio_button_tag("#{field_name_base}", "false") + "False"
+ when :float
+ text_field_tag "#{field_name_base}"
+ when :time, :datetime
+ time = Time.now
+ i = 0
+ %w|year month day hour minute second|.map do |name|
+ i += 1
+ send("select_#{name}", time, :prefix => "#{field_name_base}[#{i}]", :discard_type => true)
+ end.join
+ when :date
+ date = Date.today
+ i = 0
+ %w|year month day|.map do |name|
+ i += 1
+ send("select_#{name}", date, :prefix => "#{field_name_base}[#{i}]", :discard_type => true)
+ end.join
+ end
+ end
+ end
+
+ def method_parameter_label(name, type)
+ name.to_s.capitalize + ' (' + type.human_name(false) + ')'
+ end
+
+ def service_method_list(service)
+ action = @scaffold_action_name + '_method_params'
+ methods = service.api_methods_full.map do |desc, name|
+ content_tag("li", link_to(desc, :action => action, :service => service.name, :method => name))
+ end
+ content_tag("ul", methods.join("\n"))
+ end
+ end
+
+ module WebServiceModel # :nodoc:
+ class Container # :nodoc:
+ attr :services
+ attr :dispatching_mode
+
+ def initialize(real_container)
+ @real_container = real_container
+ @dispatching_mode = @real_container.class.web_service_dispatching_mode
+ @services = []
+ if @dispatching_mode == :direct
+ @services << Service.new(@real_container.controller_name, @real_container)
+ else
+ @real_container.class.web_services.each do |name, obj|
+ @services << Service.new(name, @real_container.instance_eval{ web_service_object(name) })
+ end
+ end
+ end
+ end
+
+ class Service # :nodoc:
+ attr :name
+ attr :object
+ attr :api
+ attr :api_methods
+ attr :api_methods_full
+
+ def initialize(name, real_service)
+ @name = name.to_s
+ @object = real_service
+ @api = @object.class.web_service_api
+ if @api.nil?
+ raise ScaffoldingError, "No web service API attached to #{object.class}"
+ end
+ @api_methods = {}
+ @api_methods_full = []
+ @api.api_methods.each do |name, method|
+ @api_methods[method.public_name.to_s] = method
+ @api_methods_full << [method.to_s, method.public_name.to_s]
+ end
+ end
+
+ def to_s
+ self.name.camelize
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/struct.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/struct.rb
new file mode 100644
index 000000000..00eafc169
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/struct.rb
@@ -0,0 +1,64 @@
+module ActionWebService
+ # To send structured types across the wire, derive from ActionWebService::Struct,
+ # and use +member+ to declare structure members.
+ #
+ # ActionWebService::Struct should be used in method signatures when you want to accept or return
+ # structured types that have no Active Record model class representations, or you don't
+ # want to expose your entire Active Record model to remote callers.
+ #
+ # === Example
+ #
+ # class Person < ActionWebService::Struct
+ # member :id, :int
+ # member :firstnames, [:string]
+ # member :lastname, :string
+ # member :email, :string
+ # end
+ # person = Person.new(:id => 5, :firstname => 'john', :lastname => 'doe')
+ #
+ # Active Record model classes are already implicitly supported in method
+ # signatures.
+ class Struct
+ # If a Hash is given as argument to an ActionWebService::Struct constructor,
+ # it can contain initial values for the structure member.
+ def initialize(values={})
+ if values.is_a?(Hash)
+ values.map{|k,v| __send__('%s=' % k.to_s, v)}
+ end
+ end
+
+ # The member with the given name
+ def [](name)
+ send(name.to_s)
+ end
+
+ # Iterates through each member
+ def each_pair(&block)
+ self.class.members.each do |name, type|
+ yield name, self.__send__(name)
+ end
+ end
+
+ class << self
+ # Creates a structure member with the specified +name+ and +type+. Generates
+ # accessor methods for reading and writing the member value.
+ def member(name, type)
+ name = name.to_sym
+ type = ActionWebService::SignatureTypes.canonical_signature_entry({ name => type }, 0)
+ write_inheritable_hash("struct_members", name => type)
+ class_eval <<-END
+ def #{name}; @#{name}; end
+ def #{name}=(value); @#{name} = value; end
+ END
+ end
+
+ def members # :nodoc:
+ read_inheritable_attribute("struct_members") || {}
+ end
+
+ def member_type(name) # :nodoc:
+ members[name.to_sym]
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/support/class_inheritable_options.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/support/class_inheritable_options.rb
new file mode 100644
index 000000000..4d1c2ed47
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/support/class_inheritable_options.rb
@@ -0,0 +1,26 @@
+class Class # :nodoc:
+ def class_inheritable_option(sym, default_value=nil)
+ write_inheritable_attribute sym, default_value
+ class_eval <<-EOS
+ def self.#{sym}(value=nil)
+ if !value.nil?
+ write_inheritable_attribute(:#{sym}, value)
+ else
+ read_inheritable_attribute(:#{sym})
+ end
+ end
+
+ def self.#{sym}=(value)
+ write_inheritable_attribute(:#{sym}, value)
+ end
+
+ def #{sym}
+ self.class.#{sym}
+ end
+
+ def #{sym}=(value)
+ self.class.#{sym} = value
+ end
+ EOS
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/support/signature_types.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/support/signature_types.rb
new file mode 100644
index 000000000..66c86bf6d
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/support/signature_types.rb
@@ -0,0 +1,226 @@
+module ActionWebService # :nodoc:
+ # Action Web Service supports the following base types in a signature:
+ #
+ # [:int ] Represents an integer value, will be cast to an integer using Integer(value)
+ # [:string ] Represents a string value, will be cast to an string using the to_s method on an object
+ # [:base64 ] Represents a Base 64 value, will contain the binary bytes of a Base 64 value sent by the caller
+ # [:bool ] Represents a boolean value, whatever is passed will be cast to boolean (true , '1', 'true', 'y', 'yes' are taken to represent true; false , '0', 'false', 'n', 'no' and nil represent false)
+ # [:float ] Represents a floating point value, will be cast to a float using Float(value)
+ # [:time ] Represents a timestamp, will be cast to a Time object
+ # [:datetime ] Represents a timestamp, will be cast to a DateTime object
+ # [:date ] Represents a date, will be cast to a Date object
+ #
+ # For structured types, you'll need to pass in the Class objects of
+ # ActionWebService::Struct and ActiveRecord::Base derivatives.
+ module SignatureTypes
+ def canonical_signature(signature) # :nodoc:
+ return nil if signature.nil?
+ unless signature.is_a?(Array)
+ raise(ActionWebServiceError, "Expected signature to be an Array")
+ end
+ i = -1
+ signature.map{ |spec| canonical_signature_entry(spec, i += 1) }
+ end
+
+ def canonical_signature_entry(spec, i) # :nodoc:
+ orig_spec = spec
+ name = "param#{i}"
+ if spec.is_a?(Hash)
+ name, spec = spec.keys.first, spec.values.first
+ end
+ type = spec
+ if spec.is_a?(Array)
+ ArrayType.new(orig_spec, canonical_signature_entry(spec[0], 0), name)
+ else
+ type = canonical_type(type)
+ if type.is_a?(Symbol)
+ BaseType.new(orig_spec, type, name)
+ else
+ StructuredType.new(orig_spec, type, name)
+ end
+ end
+ end
+
+ def canonical_type(type) # :nodoc:
+ type_name = symbol_name(type) || class_to_type_name(type)
+ type = type_name || type
+ return canonical_type_name(type) if type.is_a?(Symbol)
+ type
+ end
+
+ def canonical_type_name(name) # :nodoc:
+ name = name.to_sym
+ case name
+ when :int, :integer, :fixnum, :bignum
+ :int
+ when :string, :text
+ :string
+ when :base64, :binary
+ :base64
+ when :bool, :boolean
+ :bool
+ when :float, :double
+ :float
+ when :decimal
+ :decimal
+ when :time, :timestamp
+ :time
+ when :datetime
+ :datetime
+ when :date
+ :date
+ else
+ raise(TypeError, "#{name} is not a valid base type")
+ end
+ end
+
+ def canonical_type_class(type) # :nodoc:
+ type = canonical_type(type)
+ type.is_a?(Symbol) ? type_name_to_class(type) : type
+ end
+
+ def symbol_name(name) # :nodoc:
+ return name.to_sym if name.is_a?(Symbol) || name.is_a?(String)
+ nil
+ end
+
+ def class_to_type_name(klass) # :nodoc:
+ klass = klass.class unless klass.is_a?(Class)
+ if derived_from?(Integer, klass) || derived_from?(Fixnum, klass) || derived_from?(Bignum, klass)
+ :int
+ elsif klass == String
+ :string
+ elsif klass == Base64
+ :base64
+ elsif klass == TrueClass || klass == FalseClass
+ :bool
+ elsif derived_from?(Float, klass) || derived_from?(Precision, klass) || derived_from?(Numeric, klass)
+ :float
+ elsif klass == Time
+ :time
+ elsif klass == DateTime
+ :datetime
+ elsif klass == Date
+ :date
+ else
+ nil
+ end
+ end
+
+ def type_name_to_class(name) # :nodoc:
+ case canonical_type_name(name)
+ when :int
+ Integer
+ when :string
+ String
+ when :base64
+ Base64
+ when :bool
+ TrueClass
+ when :float
+ Float
+ when :decimal
+ BigDecimal
+ when :time
+ Time
+ when :date
+ Date
+ when :datetime
+ DateTime
+ else
+ nil
+ end
+ end
+
+ def derived_from?(ancestor, child) # :nodoc:
+ child.ancestors.include?(ancestor)
+ end
+
+ module_function :type_name_to_class
+ module_function :class_to_type_name
+ module_function :symbol_name
+ module_function :canonical_type_class
+ module_function :canonical_type_name
+ module_function :canonical_type
+ module_function :canonical_signature_entry
+ module_function :canonical_signature
+ module_function :derived_from?
+ end
+
+ class BaseType # :nodoc:
+ include SignatureTypes
+
+ attr :spec
+ attr :type
+ attr :type_class
+ attr :name
+
+ def initialize(spec, type, name)
+ @spec = spec
+ @type = canonical_type(type)
+ @type_class = canonical_type_class(@type)
+ @name = name
+ end
+
+ def custom?
+ false
+ end
+
+ def array?
+ false
+ end
+
+ def structured?
+ false
+ end
+
+ def human_name(show_name=true)
+ type_type = array? ? element_type.type.to_s : self.type.to_s
+ str = array? ? (type_type + '[]') : type_type
+ show_name ? (str + " " + name.to_s) : str
+ end
+ end
+
+ class ArrayType < BaseType # :nodoc:
+ attr :element_type
+
+ def initialize(spec, element_type, name)
+ super(spec, Array, name)
+ @element_type = element_type
+ end
+
+ def custom?
+ true
+ end
+
+ def array?
+ true
+ end
+ end
+
+ class StructuredType < BaseType # :nodoc:
+ def each_member
+ if @type_class.respond_to?(:members)
+ @type_class.members.each do |name, type|
+ yield name, type
+ end
+ elsif @type_class.respond_to?(:columns)
+ i = -1
+ @type_class.columns.each do |column|
+ yield column.name, canonical_signature_entry(column.type, i += 1)
+ end
+ end
+ end
+
+ def custom?
+ true
+ end
+
+ def structured?
+ true
+ end
+ end
+
+ class Base64 < String # :nodoc:
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/layout.erb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/layout.erb
new file mode 100644
index 000000000..167613f68
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/layout.erb
@@ -0,0 +1,65 @@
+
+
+ <%= @scaffold_class.wsdl_service_name %> Web Service
+
+
+
+
+<%= @content_for_layout %>
+
+
+
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/layout.rhtml b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/layout.rhtml
new file mode 100644
index 000000000..e69de29bb
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/methods.erb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/methods.erb
new file mode 100644
index 000000000..60dfe23f0
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/methods.erb
@@ -0,0 +1,6 @@
+<% @scaffold_container.services.each do |service| %>
+
+ API Methods for <%= service %>
+ <%= service_method_list(service) %>
+
+<% end %>
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/methods.rhtml b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/methods.rhtml
new file mode 100644
index 000000000..e69de29bb
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.erb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.erb
new file mode 100644
index 000000000..767284e0d
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.erb
@@ -0,0 +1,29 @@
+Method Invocation Details for <%= @scaffold_service %>#<%= @scaffold_method.public_name %>
+
+<% form_tag(:action => @scaffold_action_name + '_submit') do -%>
+<%= hidden_field_tag "service", @scaffold_service.name %>
+<%= hidden_field_tag "method", @scaffold_method.public_name %>
+
+
+Protocol:
+<%= select_tag 'protocol', options_for_select([['SOAP', 'soap'], ['XML-RPC', 'xmlrpc']], params['protocol']) %>
+
+
+<% if @scaffold_method.expects %>
+
+Method Parameters:
+<% @scaffold_method.expects.each_with_index do |type, i| %>
+
+ <%= method_parameter_label(type.name, type) %>
+ <%= method_parameter_input_fields(@scaffold_method, type, "method_params", i) %>
+
+<% end %>
+
+<% end %>
+
+<%= submit_tag "Invoke" %>
+<% end -%>
+
+
+<%= link_to "Back", :action => @scaffold_action_name %>
+
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.rhtml b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.rhtml
new file mode 100644
index 000000000..e69de29bb
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/result.erb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/result.erb
new file mode 100644
index 000000000..5317688fc
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/result.erb
@@ -0,0 +1,30 @@
+Method Invocation Result for <%= @scaffold_service %>#<%= @scaffold_method.public_name %>
+
+
+Invocation took <%= '%f' % @method_elapsed %> seconds
+
+
+
+Return Value:
+
+<%= h @method_return_value.inspect %>
+
+
+
+
+Request XML:
+
+<%= h @method_request_xml %>
+
+
+
+
+Response XML:
+
+<%= h @method_response_xml %>
+
+
+
+
+<%= link_to "Back", :action => @scaffold_action_name + '_method_params', :method => @scaffold_method.public_name, :service => @scaffold_service.name %>
+
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/result.rhtml b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/templates/scaffolds/result.rhtml
new file mode 100644
index 000000000..e69de29bb
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/test_invoke.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/test_invoke.rb
new file mode 100644
index 000000000..7e714c941
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/test_invoke.rb
@@ -0,0 +1,110 @@
+require 'test/unit'
+
+module Test # :nodoc:
+ module Unit # :nodoc:
+ class TestCase # :nodoc:
+ private
+ # invoke the specified API method
+ def invoke_direct(method_name, *args)
+ prepare_request('api', 'api', method_name, *args)
+ @controller.process(@request, @response)
+ decode_rpc_response
+ end
+ alias_method :invoke, :invoke_direct
+
+ # invoke the specified API method on the specified service
+ def invoke_delegated(service_name, method_name, *args)
+ prepare_request(service_name.to_s, service_name, method_name, *args)
+ @controller.process(@request, @response)
+ decode_rpc_response
+ end
+
+ # invoke the specified layered API method on the correct service
+ def invoke_layered(service_name, method_name, *args)
+ prepare_request('api', service_name, method_name, *args)
+ @controller.process(@request, @response)
+ decode_rpc_response
+ end
+
+ # ---------------------- internal ---------------------------
+
+ def prepare_request(action, service_name, api_method_name, *args)
+ @request.recycle!
+ @request.request_parameters['action'] = action
+ @request.env['REQUEST_METHOD'] = 'POST'
+ @request.env['HTTP_CONTENT_TYPE'] = 'text/xml'
+ @request.env['RAW_POST_DATA'] = encode_rpc_call(service_name, api_method_name, *args)
+ case protocol
+ when ActionWebService::Protocol::Soap::SoapProtocol
+ soap_action = "/#{@controller.controller_name}/#{service_name}/#{public_method_name(service_name, api_method_name)}"
+ @request.env['HTTP_SOAPACTION'] = soap_action
+ when ActionWebService::Protocol::XmlRpc::XmlRpcProtocol
+ @request.env.delete('HTTP_SOAPACTION')
+ end
+ end
+
+ def encode_rpc_call(service_name, api_method_name, *args)
+ case @controller.web_service_dispatching_mode
+ when :direct
+ api = @controller.class.web_service_api
+ when :delegated, :layered
+ api = @controller.web_service_object(service_name.to_sym).class.web_service_api
+ end
+ protocol.register_api(api)
+ method = api.api_methods[api_method_name.to_sym]
+ raise ArgumentError, "wrong number of arguments for rpc call (#{args.length} for #{method.expects.length})" if method && method.expects && args.length != method.expects.length
+ protocol.encode_request(public_method_name(service_name, api_method_name), args.dup, method.expects)
+ end
+
+ def decode_rpc_response
+ public_method_name, return_value = protocol.decode_response(@response.body)
+ exception = is_exception?(return_value)
+ raise exception if exception
+ return_value
+ end
+
+ def public_method_name(service_name, api_method_name)
+ public_name = service_api(service_name).public_api_method_name(api_method_name)
+ if @controller.web_service_dispatching_mode == :layered && protocol.is_a?(ActionWebService::Protocol::XmlRpc::XmlRpcProtocol)
+ '%s.%s' % [service_name.to_s, public_name]
+ else
+ public_name
+ end
+ end
+
+ def service_api(service_name)
+ case @controller.web_service_dispatching_mode
+ when :direct
+ @controller.class.web_service_api
+ when :delegated, :layered
+ @controller.web_service_object(service_name.to_sym).class.web_service_api
+ end
+ end
+
+ def protocol
+ if @protocol.nil?
+ @protocol ||= ActionWebService::Protocol::Soap::SoapProtocol.create(@controller)
+ else
+ case @protocol
+ when :xmlrpc
+ @protocol = ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.create(@controller)
+ when :soap
+ @protocol = ActionWebService::Protocol::Soap::SoapProtocol.create(@controller)
+ else
+ @protocol
+ end
+ end
+ end
+
+ def is_exception?(obj)
+ case protocol
+ when :soap, ActionWebService::Protocol::Soap::SoapProtocol
+ (obj.respond_to?(:detail) && obj.detail.respond_to?(:cause) && \
+ obj.detail.cause.is_a?(Exception)) ? obj.detail.cause : nil
+ when :xmlrpc, ActionWebService::Protocol::XmlRpc::XmlRpcProtocol
+ obj.is_a?(XMLRPC::FaultException) ? obj : nil
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/version.rb b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/version.rb
new file mode 100644
index 000000000..a1b3d5929
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/action_web_service/version.rb
@@ -0,0 +1,9 @@
+module ActionWebService
+ module VERSION #:nodoc:
+ MAJOR = 1
+ MINOR = 2
+ TINY = 5
+
+ STRING = [MAJOR, MINOR, TINY].join('.')
+ end
+end
diff --git a/rest_sys/vendor/plugins/actionwebservice/lib/actionwebservice.rb b/rest_sys/vendor/plugins/actionwebservice/lib/actionwebservice.rb
new file mode 100644
index 000000000..25e3aa8e8
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/lib/actionwebservice.rb
@@ -0,0 +1 @@
+require 'action_web_service'
diff --git a/rest_sys/vendor/plugins/actionwebservice/setup.rb b/rest_sys/vendor/plugins/actionwebservice/setup.rb
new file mode 100644
index 000000000..aeef0d106
--- /dev/null
+++ b/rest_sys/vendor/plugins/actionwebservice/setup.rb
@@ -0,0 +1,1379 @@
+#
+# setup.rb
+#
+# Copyright (c) 2000-2004 Minero Aoki
+#
+# 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.
+#
+# Note: Originally licensed under LGPL v2+. Using MIT license for Rails
+# with permission of Minero Aoki.
+
+#
+
+unless Enumerable.method_defined?(:map) # Ruby 1.4.6
+ module Enumerable
+ alias map collect
+ end
+end
+
+unless File.respond_to?(:read) # Ruby 1.6
+ def File.read(fname)
+ open(fname) {|f|
+ return f.read
+ }
+ end
+end
+
+def File.binread(fname)
+ open(fname, 'rb') {|f|
+ return f.read
+ }
+end
+
+# for corrupted windows stat(2)
+def File.dir?(path)
+ File.directory?((path[-1,1] == '/') ? path : path + '/')
+end
+
+
+class SetupError < StandardError; end
+
+def setup_rb_error(msg)
+ raise SetupError, msg
+end
+
+#
+# Config
+#
+
+if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg }
+ ARGV.delete(arg)
+ require arg.split(/=/, 2)[1]
+ $".push 'rbconfig.rb'
+else
+ require 'rbconfig'
+end
+
+def multipackage_install?
+ FileTest.directory?(File.dirname($0) + '/packages')
+end
+
+
+class ConfigItem
+ def initialize(name, template, default, desc)
+ @name = name.freeze
+ @template = template
+ @value = default
+ @default = default.dup.freeze
+ @description = desc
+ end
+
+ attr_reader :name
+ attr_reader :description
+
+ attr_accessor :default
+ alias help_default default
+
+ def help_opt
+ "--#{@name}=#{@template}"
+ end
+
+ def value
+ @value
+ end
+
+ def eval(table)
+ @value.gsub(%r<\$([^/]+)>) { table[$1] }
+ end
+
+ def set(val)
+ @value = check(val)
+ end
+
+ private
+
+ def check(val)
+ setup_rb_error "config: --#{name} requires argument" unless val
+ val
+ end
+end
+
+class BoolItem < ConfigItem
+ def config_type
+ 'bool'
+ end
+
+ def help_opt
+ "--#{@name}"
+ end
+
+ private
+
+ def check(val)
+ return 'yes' unless val
+ unless /\A(y(es)?|n(o)?|t(rue)?|f(alse))\z/i =~ val
+ setup_rb_error "config: --#{@name} accepts only yes/no for argument"
+ end
+ (/\Ay(es)?|\At(rue)/i =~ value) ? 'yes' : 'no'
+ end
+end
+
+class PathItem < ConfigItem
+ def config_type
+ 'path'
+ end
+
+ private
+
+ def check(path)
+ setup_rb_error "config: --#{@name} requires argument" unless path
+ path[0,1] == '$' ? path : File.expand_path(path)
+ end
+end
+
+class ProgramItem < ConfigItem
+ def config_type
+ 'program'
+ end
+end
+
+class SelectItem < ConfigItem
+ def initialize(name, template, default, desc)
+ super
+ @ok = template.split('/')
+ end
+
+ def config_type
+ 'select'
+ end
+
+ private
+
+ def check(val)
+ unless @ok.include?(val.strip)
+ setup_rb_error "config: use --#{@name}=#{@template} (#{val})"
+ end
+ val.strip
+ end
+end
+
+class PackageSelectionItem < ConfigItem
+ def initialize(name, template, default, help_default, desc)
+ super name, template, default, desc
+ @help_default = help_default
+ end
+
+ attr_reader :help_default
+
+ def config_type
+ 'package'
+ end
+
+ private
+
+ def check(val)
+ unless File.dir?("packages/#{val}")
+ setup_rb_error "config: no such package: #{val}"
+ end
+ val
+ end
+end
+
+class ConfigTable_class
+
+ def initialize(items)
+ @items = items
+ @table = {}
+ items.each do |i|
+ @table[i.name] = i
+ end
+ ALIASES.each do |ali, name|
+ @table[ali] = @table[name]
+ end
+ end
+
+ include Enumerable
+
+ def each(&block)
+ @items.each(&block)
+ end
+
+ def key?(name)
+ @table.key?(name)
+ end
+
+ def lookup(name)
+ @table[name] or raise ArgumentError, "no such config item: #{name}"
+ end
+
+ def add(item)
+ @items.push item
+ @table[item.name] = item
+ end
+
+ def remove(name)
+ item = lookup(name)
+ @items.delete_if {|i| i.name == name }
+ @table.delete_if {|name, i| i.name == name }
+ item
+ end
+
+ def new
+ dup()
+ end
+
+ def savefile
+ '.config'
+ end
+
+ def load
+ begin
+ t = dup()
+ File.foreach(savefile()) do |line|
+ k, v = *line.split(/=/, 2)
+ t[k] = v.strip
+ end
+ t
+ rescue Errno::ENOENT
+ setup_rb_error $!.message + "#{File.basename($0)} config first"
+ end
+ end
+
+ def save
+ @items.each {|i| i.value }
+ File.open(savefile(), 'w') {|f|
+ @items.each do |i|
+ f.printf "%s=%s\n", i.name, i.value if i.value
+ end
+ }
+ end
+
+ def [](key)
+ lookup(key).eval(self)
+ end
+
+ def []=(key, val)
+ lookup(key).set val
+ end
+
+end
+
+c = ::Config::CONFIG
+
+rubypath = c['bindir'] + '/' + c['ruby_install_name']
+
+major = c['MAJOR'].to_i
+minor = c['MINOR'].to_i
+teeny = c['TEENY'].to_i
+version = "#{major}.#{minor}"
+
+# ruby ver. >= 1.4.4?
+newpath_p = ((major >= 2) or
+ ((major == 1) and
+ ((minor >= 5) or
+ ((minor == 4) and (teeny >= 4)))))
+
+if c['rubylibdir']
+ # V < 1.6.3
+ _stdruby = c['rubylibdir']
+ _siteruby = c['sitedir']
+ _siterubyver = c['sitelibdir']
+ _siterubyverarch = c['sitearchdir']
+elsif newpath_p
+ # 1.4.4 <= V <= 1.6.3
+ _stdruby = "$prefix/lib/ruby/#{version}"
+ _siteruby = c['sitedir']
+ _siterubyver = "$siteruby/#{version}"
+ _siterubyverarch = "$siterubyver/#{c['arch']}"
+else
+ # V < 1.4.4
+ _stdruby = "$prefix/lib/ruby/#{version}"
+ _siteruby = "$prefix/lib/ruby/#{version}/site_ruby"
+ _siterubyver = _siteruby
+ _siterubyverarch = "$siterubyver/#{c['arch']}"
+end
+libdir = '-* dummy libdir *-'
+stdruby = '-* dummy rubylibdir *-'
+siteruby = '-* dummy site_ruby *-'
+siterubyver = '-* dummy site_ruby version *-'
+parameterize = lambda {|path|
+ path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix')\
+ .sub(/\A#{Regexp.quote(libdir)}/, '$libdir')\
+ .sub(/\A#{Regexp.quote(stdruby)}/, '$stdruby')\
+ .sub(/\A#{Regexp.quote(siteruby)}/, '$siteruby')\
+ .sub(/\A#{Regexp.quote(siterubyver)}/, '$siterubyver')
+}
+libdir = parameterize.call(c['libdir'])
+stdruby = parameterize.call(_stdruby)
+siteruby = parameterize.call(_siteruby)
+siterubyver = parameterize.call(_siterubyver)
+siterubyverarch = parameterize.call(_siterubyverarch)
+
+if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg }
+ makeprog = arg.sub(/'/, '').split(/=/, 2)[1]
+else
+ makeprog = 'make'
+end
+
+common_conf = [
+ PathItem.new('prefix', 'path', c['prefix'],
+ 'path prefix of target environment'),
+ PathItem.new('bindir', 'path', parameterize.call(c['bindir']),
+ 'the directory for commands'),
+ PathItem.new('libdir', 'path', libdir,
+ 'the directory for libraries'),
+ PathItem.new('datadir', 'path', parameterize.call(c['datadir']),
+ 'the directory for shared data'),
+ PathItem.new('mandir', 'path', parameterize.call(c['mandir']),
+ 'the directory for man pages'),
+ PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']),
+ 'the directory for man pages'),
+ PathItem.new('stdruby', 'path', stdruby,
+ 'the directory for standard ruby libraries'),
+ PathItem.new('siteruby', 'path', siteruby,
+ 'the directory for version-independent aux ruby libraries'),
+ PathItem.new('siterubyver', 'path', siterubyver,
+ 'the directory for aux ruby libraries'),
+ PathItem.new('siterubyverarch', 'path', siterubyverarch,
+ 'the directory for aux ruby binaries'),
+ PathItem.new('rbdir', 'path', '$siterubyver',
+ 'the directory for ruby scripts'),
+ PathItem.new('sodir', 'path', '$siterubyverarch',
+ 'the directory for ruby extentions'),
+ PathItem.new('rubypath', 'path', rubypath,
+ 'the path to set to #! line'),
+ ProgramItem.new('rubyprog', 'name', rubypath,
+ 'the ruby program using for installation'),
+ ProgramItem.new('makeprog', 'name', makeprog,
+ 'the make program to compile ruby extentions'),
+ SelectItem.new('shebang', 'all/ruby/never', 'ruby',
+ 'shebang line (#!) editing mode'),
+ BoolItem.new('without-ext', 'yes/no', 'no',
+ 'does not compile/install ruby extentions')
+]
+class ConfigTable_class # open again
+ ALIASES = {
+ 'std-ruby' => 'stdruby',
+ 'site-ruby-common' => 'siteruby', # For backward compatibility
+ 'site-ruby' => 'siterubyver', # For backward compatibility
+ 'bin-dir' => 'bindir',
+ 'bin-dir' => 'bindir',
+ 'rb-dir' => 'rbdir',
+ 'so-dir' => 'sodir',
+ 'data-dir' => 'datadir',
+ 'ruby-path' => 'rubypath',
+ 'ruby-prog' => 'rubyprog',
+ 'ruby' => 'rubyprog',
+ 'make-prog' => 'makeprog',
+ 'make' => 'makeprog'
+ }
+end
+multipackage_conf = [
+ PackageSelectionItem.new('with', 'name,name...', '', 'ALL',
+ 'package names that you want to install'),
+ PackageSelectionItem.new('without', 'name,name...', '', 'NONE',
+ 'package names that you do not want to install')
+]
+if multipackage_install?
+ ConfigTable = ConfigTable_class.new(common_conf + multipackage_conf)
+else
+ ConfigTable = ConfigTable_class.new(common_conf)
+end
+
+
+module MetaConfigAPI
+
+ def eval_file_ifexist(fname)
+ instance_eval File.read(fname), fname, 1 if File.file?(fname)
+ end
+
+ def config_names
+ ConfigTable.map {|i| i.name }
+ end
+
+ def config?(name)
+ ConfigTable.key?(name)
+ end
+
+ def bool_config?(name)
+ ConfigTable.lookup(name).config_type == 'bool'
+ end
+
+ def path_config?(name)
+ ConfigTable.lookup(name).config_type == 'path'
+ end
+
+ def value_config?(name)
+ case ConfigTable.lookup(name).config_type
+ when 'bool', 'path'
+ true
+ else
+ false
+ end
+ end
+
+ def add_config(item)
+ ConfigTable.add item
+ end
+
+ def add_bool_config(name, default, desc)
+ ConfigTable.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc)
+ end
+
+ def add_path_config(name, default, desc)
+ ConfigTable.add PathItem.new(name, 'path', default, desc)
+ end
+
+ def set_config_default(name, default)
+ ConfigTable.lookup(name).default = default
+ end
+
+ def remove_config(name)
+ ConfigTable.remove(name)
+ end
+
+end
+
+
+#
+# File Operations
+#
+
+module FileOperations
+
+ def mkdir_p(dirname, prefix = nil)
+ dirname = prefix + File.expand_path(dirname) if prefix
+ $stderr.puts "mkdir -p #{dirname}" if verbose?
+ return if no_harm?
+
+ # does not check '/'... it's too abnormal case
+ dirs = File.expand_path(dirname).split(%r<(?=/)>)
+ if /\A[a-z]:\z/i =~ dirs[0]
+ disk = dirs.shift
+ dirs[0] = disk + dirs[0]
+ end
+ dirs.each_index do |idx|
+ path = dirs[0..idx].join('')
+ Dir.mkdir path unless File.dir?(path)
+ end
+ end
+
+ def rm_f(fname)
+ $stderr.puts "rm -f #{fname}" if verbose?
+ return if no_harm?
+
+ if File.exist?(fname) or File.symlink?(fname)
+ File.chmod 0777, fname
+ File.unlink fname
+ end
+ end
+
+ def rm_rf(dn)
+ $stderr.puts "rm -rf #{dn}" if verbose?
+ return if no_harm?
+
+ Dir.chdir dn
+ Dir.foreach('.') do |fn|
+ next if fn == '.'
+ next if fn == '..'
+ if File.dir?(fn)
+ verbose_off {
+ rm_rf fn
+ }
+ else
+ verbose_off {
+ rm_f fn
+ }
+ end
+ end
+ Dir.chdir '..'
+ Dir.rmdir dn
+ end
+
+ def move_file(src, dest)
+ File.unlink dest if File.exist?(dest)
+ begin
+ File.rename src, dest
+ rescue
+ File.open(dest, 'wb') {|f| f.write File.binread(src) }
+ File.chmod File.stat(src).mode, dest
+ File.unlink src
+ end
+ end
+
+ def install(from, dest, mode, prefix = nil)
+ $stderr.puts "install #{from} #{dest}" if verbose?
+ return if no_harm?
+
+ realdest = prefix ? prefix + File.expand_path(dest) : dest
+ realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest)
+ str = File.binread(from)
+ if diff?(str, realdest)
+ verbose_off {
+ rm_f realdest if File.exist?(realdest)
+ }
+ File.open(realdest, 'wb') {|f|
+ f.write str
+ }
+ File.chmod mode, realdest
+
+ File.open("#{objdir_root()}/InstalledFiles", 'a') {|f|
+ if prefix
+ f.puts realdest.sub(prefix, '')
+ else
+ f.puts realdest
+ end
+ }
+ end
+ end
+
+ def diff?(new_content, path)
+ return true unless File.exist?(path)
+ new_content != File.binread(path)
+ end
+
+ def command(str)
+ $stderr.puts str if verbose?
+ system str or raise RuntimeError, "'system #{str}' failed"
+ end
+
+ def ruby(str)
+ command config('rubyprog') + ' ' + str
+ end
+
+ def make(task = '')
+ command config('makeprog') + ' ' + task
+ end
+
+ def extdir?(dir)
+ File.exist?(dir + '/MANIFEST')
+ end
+
+ def all_files_in(dirname)
+ Dir.open(dirname) {|d|
+ return d.select {|ent| File.file?("#{dirname}/#{ent}") }
+ }
+ end
+
+ REJECT_DIRS = %w(
+ CVS SCCS RCS CVS.adm .svn
+ )
+
+ def all_dirs_in(dirname)
+ Dir.open(dirname) {|d|
+ return d.select {|n| File.dir?("#{dirname}/#{n}") } - %w(. ..) - REJECT_DIRS
+ }
+ end
+
+end
+
+
+#
+# Main Installer
+#
+
+module HookUtils
+
+ def run_hook(name)
+ try_run_hook "#{curr_srcdir()}/#{name}" or
+ try_run_hook "#{curr_srcdir()}/#{name}.rb"
+ end
+
+ def try_run_hook(fname)
+ return false unless File.file?(fname)
+ begin
+ instance_eval File.read(fname), fname, 1
+ rescue
+ setup_rb_error "hook #{fname} failed:\n" + $!.message
+ end
+ true
+ end
+
+end
+
+
+module HookScriptAPI
+
+ def get_config(key)
+ @config[key]
+ end
+
+ alias config get_config
+
+ def set_config(key, val)
+ @config[key] = val
+ end
+
+ #
+ # srcdir/objdir (works only in the package directory)
+ #
+
+ #abstract srcdir_root
+ #abstract objdir_root
+ #abstract relpath
+
+ def curr_srcdir
+ "#{srcdir_root()}/#{relpath()}"
+ end
+
+ def curr_objdir
+ "#{objdir_root()}/#{relpath()}"
+ end
+
+ def srcfile(path)
+ "#{curr_srcdir()}/#{path}"
+ end
+
+ def srcexist?(path)
+ File.exist?(srcfile(path))
+ end
+
+ def srcdirectory?(path)
+ File.dir?(srcfile(path))
+ end
+
+ def srcfile?(path)
+ File.file? srcfile(path)
+ end
+
+ def srcentries(path = '.')
+ Dir.open("#{curr_srcdir()}/#{path}") {|d|
+ return d.to_a - %w(. ..)
+ }
+ end
+
+ def srcfiles(path = '.')
+ srcentries(path).select {|fname|
+ File.file?(File.join(curr_srcdir(), path, fname))
+ }
+ end
+
+ def srcdirectories(path = '.')
+ srcentries(path).select {|fname|
+ File.dir?(File.join(curr_srcdir(), path, fname))
+ }
+ end
+
+end
+
+
+class ToplevelInstaller
+
+ Version = '3.3.1'
+ Copyright = 'Copyright (c) 2000-2004 Minero Aoki'
+
+ TASKS = [
+ [ 'all', 'do config, setup, then install' ],
+ [ 'config', 'saves your configurations' ],
+ [ 'show', 'shows current configuration' ],
+ [ 'setup', 'compiles ruby extentions and others' ],
+ [ 'install', 'installs files' ],
+ [ 'clean', "does `make clean' for each extention" ],
+ [ 'distclean',"does `make distclean' for each extention" ]
+ ]
+
+ def ToplevelInstaller.invoke
+ instance().invoke
+ end
+
+ @singleton = nil
+
+ def ToplevelInstaller.instance
+ @singleton ||= new(File.dirname($0))
+ @singleton
+ end
+
+ include MetaConfigAPI
+
+ def initialize(ardir_root)
+ @config = nil
+ @options = { 'verbose' => true }
+ @ardir = File.expand_path(ardir_root)
+ end
+
+ def inspect
+ "#<#{self.class} #{__id__()}>"
+ end
+
+ def invoke
+ run_metaconfigs
+ case task = parsearg_global()
+ when nil, 'all'
+ @config = load_config('config')
+ parsearg_config
+ init_installers
+ exec_config
+ exec_setup
+ exec_install
+ else
+ @config = load_config(task)
+ __send__ "parsearg_#{task}"
+ init_installers
+ __send__ "exec_#{task}"
+ end
+ end
+
+ def run_metaconfigs
+ eval_file_ifexist "#{@ardir}/metaconfig"
+ end
+
+ def load_config(task)
+ case task
+ when 'config'
+ ConfigTable.new
+ when 'clean', 'distclean'
+ if File.exist?(ConfigTable.savefile)
+ then ConfigTable.load
+ else ConfigTable.new
+ end
+ else
+ ConfigTable.load
+ end
+ end
+
+ def init_installers
+ @installer = Installer.new(@config, @options, @ardir, File.expand_path('.'))
+ end
+
+ #
+ # Hook Script API bases
+ #
+
+ def srcdir_root
+ @ardir
+ end
+
+ def objdir_root
+ '.'
+ end
+
+ def relpath
+ '.'
+ end
+
+ #
+ # Option Parsing
+ #
+
+ def parsearg_global
+ valid_task = /\A(?:#{TASKS.map {|task,desc| task }.join '|'})\z/
+
+ while arg = ARGV.shift
+ case arg
+ when /\A\w+\z/
+ setup_rb_error "invalid task: #{arg}" unless valid_task =~ arg
+ return arg
+
+ when '-q', '--quiet'
+ @options['verbose'] = false
+
+ when '--verbose'
+ @options['verbose'] = true
+
+ when '-h', '--help'
+ print_usage $stdout
+ exit 0
+
+ when '-v', '--version'
+ puts "#{File.basename($0)} version #{Version}"
+ exit 0
+
+ when '--copyright'
+ puts Copyright
+ exit 0
+
+ else
+ setup_rb_error "unknown global option '#{arg}'"
+ end
+ end
+
+ nil
+ end
+
+
+ def parsearg_no_options
+ unless ARGV.empty?
+ setup_rb_error "#{task}: unknown options: #{ARGV.join ' '}"
+ end
+ end
+
+ alias parsearg_show parsearg_no_options
+ alias parsearg_setup parsearg_no_options
+ alias parsearg_clean parsearg_no_options
+ alias parsearg_distclean parsearg_no_options
+
+ def parsearg_config
+ re = /\A--(#{ConfigTable.map {|i| i.name }.join('|')})(?:=(.*))?\z/
+ @options['config-opt'] = []
+
+ while i = ARGV.shift
+ if /\A--?\z/ =~ i
+ @options['config-opt'] = ARGV.dup
+ break
+ end
+ m = re.match(i) or setup_rb_error "config: unknown option #{i}"
+ name, value = *m.to_a[1,2]
+ @config[name] = value
+ end
+ end
+
+ def parsearg_install
+ @options['no-harm'] = false
+ @options['install-prefix'] = ''
+ while a = ARGV.shift
+ case a
+ when /\A--no-harm\z/
+ @options['no-harm'] = true
+ when /\A--prefix=(.*)\z/
+ path = $1
+ path = File.expand_path(path) unless path[0,1] == '/'
+ @options['install-prefix'] = path
+ else
+ setup_rb_error "install: unknown option #{a}"
+ end
+ end
+ end
+
+ def print_usage(out)
+ out.puts 'Typical Installation Procedure:'
+ out.puts " $ ruby #{File.basename $0} config"
+ out.puts " $ ruby #{File.basename $0} setup"
+ out.puts " # ruby #{File.basename $0} install (may require root privilege)"
+ out.puts
+ out.puts 'Detailed Usage:'
+ out.puts " ruby #{File.basename $0} "
+ out.puts " ruby #{File.basename $0} [] []"
+
+ fmt = " %-24s %s\n"
+ out.puts
+ out.puts 'Global options:'
+ out.printf fmt, '-q,--quiet', 'suppress message outputs'
+ out.printf fmt, ' --verbose', 'output messages verbosely'
+ out.printf fmt, '-h,--help', 'print this message'
+ out.printf fmt, '-v,--version', 'print version and quit'
+ out.printf fmt, ' --copyright', 'print copyright and quit'
+ out.puts
+ out.puts 'Tasks:'
+ TASKS.each do |name, desc|
+ out.printf fmt, name, desc
+ end
+
+ fmt = " %-24s %s [%s]\n"
+ out.puts
+ out.puts 'Options for CONFIG or ALL:'
+ ConfigTable.each do |item|
+ out.printf fmt, item.help_opt, item.description, item.help_default
+ end
+ out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's"
+ out.puts
+ out.puts 'Options for INSTALL:'
+ out.printf fmt, '--no-harm', 'only display what to do if given', 'off'
+ out.printf fmt, '--prefix=path', 'install path prefix', '$prefix'
+ out.puts
+ end
+
+ #
+ # Task Handlers
+ #
+
+ def exec_config
+ @installer.exec_config
+ @config.save # must be final
+ end
+
+ def exec_setup
+ @installer.exec_setup
+ end
+
+ def exec_install
+ @installer.exec_install
+ end
+
+ def exec_show
+ ConfigTable.each do |i|
+ printf "%-20s %s\n", i.name, i.value
+ end
+ end
+
+ def exec_clean
+ @installer.exec_clean
+ end
+
+ def exec_distclean
+ @installer.exec_distclean
+ end
+
+end
+
+
+class ToplevelInstallerMulti < ToplevelInstaller
+
+ include HookUtils
+ include HookScriptAPI
+ include FileOperations
+
+ def initialize(ardir)
+ super
+ @packages = all_dirs_in("#{@ardir}/packages")
+ raise 'no package exists' if @packages.empty?
+ end
+
+ def run_metaconfigs
+ eval_file_ifexist "#{@ardir}/metaconfig"
+ @packages.each do |name|
+ eval_file_ifexist "#{@ardir}/packages/#{name}/metaconfig"
+ end
+ end
+
+ def init_installers
+ @installers = {}
+ @packages.each do |pack|
+ @installers[pack] = Installer.new(@config, @options,
+ "#{@ardir}/packages/#{pack}",
+ "packages/#{pack}")
+ end
+
+ with = extract_selection(config('with'))
+ without = extract_selection(config('without'))
+ @selected = @installers.keys.select {|name|
+ (with.empty? or with.include?(name)) \
+ and not without.include?(name)
+ }
+ end
+
+ def extract_selection(list)
+ a = list.split(/,/)
+ a.each do |name|
+ setup_rb_error "no such package: #{name}" unless @installers.key?(name)
+ end
+ a
+ end
+
+ def print_usage(f)
+ super
+ f.puts 'Included packages:'
+ f.puts ' ' + @packages.sort.join(' ')
+ f.puts
+ end
+
+ #
+ # multi-package metaconfig API
+ #
+
+ attr_reader :packages
+
+ def declare_packages(list)
+ raise 'package list is empty' if list.empty?
+ list.each do |name|
+ raise "directory packages/#{name} does not exist"\
+ unless File.dir?("#{@ardir}/packages/#{name}")
+ end
+ @packages = list
+ end
+
+ #
+ # Task Handlers
+ #
+
+ def exec_config
+ run_hook 'pre-config'
+ each_selected_installers {|inst| inst.exec_config }
+ run_hook 'post-config'
+ @config.save # must be final
+ end
+
+ def exec_setup
+ run_hook 'pre-setup'
+ each_selected_installers {|inst| inst.exec_setup }
+ run_hook 'post-setup'
+ end
+
+ def exec_install
+ run_hook 'pre-install'
+ each_selected_installers {|inst| inst.exec_install }
+ run_hook 'post-install'
+ end
+
+ def exec_clean
+ rm_f ConfigTable.savefile
+ run_hook 'pre-clean'
+ each_selected_installers {|inst| inst.exec_clean }
+ run_hook 'post-clean'
+ end
+
+ def exec_distclean
+ rm_f ConfigTable.savefile
+ run_hook 'pre-distclean'
+ each_selected_installers {|inst| inst.exec_distclean }
+ run_hook 'post-distclean'
+ end
+
+ #
+ # lib
+ #
+
+ def each_selected_installers
+ Dir.mkdir 'packages' unless File.dir?('packages')
+ @selected.each do |pack|
+ $stderr.puts "Processing the package `#{pack}' ..." if @options['verbose']
+ Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}")
+ Dir.chdir "packages/#{pack}"
+ yield @installers[pack]
+ Dir.chdir '../..'
+ end
+ end
+
+ def verbose?
+ @options['verbose']
+ end
+
+ def no_harm?
+ @options['no-harm']
+ end
+
+end
+
+
+class Installer
+
+ FILETYPES = %w( bin lib ext data )
+
+ include HookScriptAPI
+ include HookUtils
+ include FileOperations
+
+ def initialize(config, opt, srcroot, objroot)
+ @config = config
+ @options = opt
+ @srcdir = File.expand_path(srcroot)
+ @objdir = File.expand_path(objroot)
+ @currdir = '.'
+ end
+
+ def inspect
+ "#<#{self.class} #{File.basename(@srcdir)}>"
+ end
+
+ #
+ # Hook Script API base methods
+ #
+
+ def srcdir_root
+ @srcdir
+ end
+
+ def objdir_root
+ @objdir
+ end
+
+ def relpath
+ @currdir
+ end
+
+ #
+ # configs/options
+ #
+
+ def no_harm?
+ @options['no-harm']
+ end
+
+ def verbose?
+ @options['verbose']
+ end
+
+ def verbose_off
+ begin
+ save, @options['verbose'] = @options['verbose'], false
+ yield
+ ensure
+ @options['verbose'] = save
+ end
+ end
+
+ #
+ # TASK config
+ #
+
+ def exec_config
+ exec_task_traverse 'config'
+ end
+
+ def config_dir_bin(rel)
+ end
+
+ def config_dir_lib(rel)
+ end
+
+ def config_dir_ext(rel)
+ extconf if extdir?(curr_srcdir())
+ end
+
+ def extconf
+ opt = @options['config-opt'].join(' ')
+ command "#{config('rubyprog')} #{curr_srcdir()}/extconf.rb #{opt}"
+ end
+
+ def config_dir_data(rel)
+ end
+
+ #
+ # TASK setup
+ #
+
+ def exec_setup
+ exec_task_traverse 'setup'
+ end
+
+ def setup_dir_bin(rel)
+ all_files_in(curr_srcdir()).each do |fname|
+ adjust_shebang "#{curr_srcdir()}/#{fname}"
+ end
+ end
+
+ def adjust_shebang(path)
+ return if no_harm?
+ tmpfile = File.basename(path) + '.tmp'
+ begin
+ File.open(path, 'rb') {|r|
+ first = r.gets
+ return unless File.basename(config('rubypath')) == 'ruby'
+ return unless File.basename(first.sub(/\A\#!/, '').split[0]) == 'ruby'
+ $stderr.puts "adjusting shebang: #{File.basename(path)}" if verbose?
+ File.open(tmpfile, 'wb') {|w|
+ w.print first.sub(/\A\#!\s*\S+/, '#! ' + config('rubypath'))
+ w.write r.read
+ }
+ move_file tmpfile, File.basename(path)
+ }
+ ensure
+ File.unlink tmpfile if File.exist?(tmpfile)
+ end
+ end
+
+ def setup_dir_lib(rel)
+ end
+
+ def setup_dir_ext(rel)
+ make if extdir?(curr_srcdir())
+ end
+
+ def setup_dir_data(rel)
+ end
+
+ #
+ # TASK install
+ #
+
+ def exec_install
+ rm_f 'InstalledFiles'
+ exec_task_traverse 'install'
+ end
+
+ def install_dir_bin(rel)
+ install_files collect_filenames_auto(), "#{config('bindir')}/#{rel}", 0755
+ end
+
+ def install_dir_lib(rel)
+ install_files ruby_scripts(), "#{config('rbdir')}/#{rel}", 0644
+ end
+
+ def install_dir_ext(rel)
+ return unless extdir?(curr_srcdir())
+ install_files ruby_extentions('.'),
+ "#{config('sodir')}/#{File.dirname(rel)}",
+ 0555
+ end
+
+ def install_dir_data(rel)
+ install_files collect_filenames_auto(), "#{config('datadir')}/#{rel}", 0644
+ end
+
+ def install_files(list, dest, mode)
+ mkdir_p dest, @options['install-prefix']
+ list.each do |fname|
+ install fname, dest, mode, @options['install-prefix']
+ end
+ end
+
+ def ruby_scripts
+ collect_filenames_auto().select {|n| /\.rb\z/ =~ n }
+ end
+
+ # picked up many entries from cvs-1.11.1/src/ignore.c
+ reject_patterns = %w(
+ core RCSLOG tags TAGS .make.state
+ .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb
+ *~ *.old *.bak *.BAK *.orig *.rej _$* *$
+
+ *.org *.in .*
+ )
+ mapping = {
+ '.' => '\.',
+ '$' => '\$',
+ '#' => '\#',
+ '*' => '.*'
+ }
+ REJECT_PATTERNS = Regexp.new('\A(?:' +
+ reject_patterns.map {|pat|
+ pat.gsub(/[\.\$\#\*]/) {|ch| mapping[ch] }
+ }.join('|') +
+ ')\z')
+
+ def collect_filenames_auto
+ mapdir((existfiles() - hookfiles()).reject {|fname|
+ REJECT_PATTERNS =~ fname
+ })
+ end
+
+ def existfiles
+ all_files_in(curr_srcdir()) | all_files_in('.')
+ end
+
+ def hookfiles
+ %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt|
+ %w( config setup install clean ).map {|t| sprintf(fmt, t) }
+ }.flatten
+ end
+
+ def mapdir(filelist)
+ filelist.map {|fname|
+ if File.exist?(fname) # objdir
+ fname
+ else # srcdir
+ File.join(curr_srcdir(), fname)
+ end
+ }
+ end
+
+ def ruby_extentions(dir)
+ Dir.open(dir) {|d|
+ ents = d.select {|fname| /\.#{::Config::CONFIG['DLEXT']}\z/ =~ fname }
+ if ents.empty?
+ setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first"
+ end
+ return ents
+ }
+ end
+
+ #
+ # TASK clean
+ #
+
+ def exec_clean
+ exec_task_traverse 'clean'
+ rm_f ConfigTable.savefile
+ rm_f 'InstalledFiles'
+ end
+
+ def clean_dir_bin(rel)
+ end
+
+ def clean_dir_lib(rel)
+ end
+
+ def clean_dir_ext(rel)
+ return unless extdir?(curr_srcdir())
+ make 'clean' if File.file?('Makefile')
+ end
+
+ def clean_dir_data(rel)
+ end
+
+ #
+ # TASK distclean
+ #
+
+ def exec_distclean
+ exec_task_traverse 'distclean'
+ rm_f ConfigTable.savefile
+ rm_f 'InstalledFiles'
+ end
+
+ def distclean_dir_bin(rel)
+ end
+
+ def distclean_dir_lib(rel)
+ end
+
+ def distclean_dir_ext(rel)
+ return unless extdir?(curr_srcdir())
+ make 'distclean' if File.file?('Makefile')
+ end
+
+ #
+ # lib
+ #
+
+ def exec_task_traverse(task)
+ run_hook "pre-#{task}"
+ FILETYPES.each do |type|
+ if config('without-ext') == 'yes' and type == 'ext'
+ $stderr.puts 'skipping ext/* by user option' if verbose?
+ next
+ end
+ traverse task, type, "#{task}_dir_#{type}"
+ end
+ run_hook "post-#{task}"
+ end
+
+ def traverse(task, rel, mid)
+ dive_into(rel) {
+ run_hook "pre-#{task}"
+ __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '')
+ all_dirs_in(curr_srcdir()).each do |d|
+ traverse task, "#{rel}/#{d}", mid
+ end
+ run_hook "post-#{task}"
+ }
+ end
+
+ def dive_into(rel)
+ return unless File.dir?("#{@srcdir}/#{rel}")
+
+ dir = File.basename(rel)
+ Dir.mkdir dir unless File.dir?(dir)
+ prevdir = Dir.pwd
+ Dir.chdir dir
+ $stderr.puts '---> ' + rel if verbose?
+ @currdir = rel
+ yield
+ Dir.chdir prevdir
+ $stderr.puts '<--- ' + rel if verbose?
+ @currdir = File.dirname(rel)
+ end
+
+end
+
+
+if $0 == __FILE__
+ begin
+ if multipackage_install?
+ ToplevelInstallerMulti.invoke
+ else
+ ToplevelInstaller.invoke
+ end
+ rescue SetupError
+ raise if $DEBUG
+ $stderr.puts $!.message
+ $stderr.puts "Try 'ruby #{$0} --help' for detailed usage."
+ exit 1
+ end
+end
diff --git a/rest_sys/vendor/plugins/acts_as_event/init.rb b/rest_sys/vendor/plugins/acts_as_event/init.rb
new file mode 100644
index 000000000..91051510a
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_event/init.rb
@@ -0,0 +1,2 @@
+require File.dirname(__FILE__) + '/lib/acts_as_event'
+ActiveRecord::Base.send(:include, Redmine::Acts::Event)
diff --git a/rest_sys/vendor/plugins/acts_as_event/lib/acts_as_event.rb b/rest_sys/vendor/plugins/acts_as_event/lib/acts_as_event.rb
new file mode 100644
index 000000000..a0d1822ad
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_event/lib/acts_as_event.rb
@@ -0,0 +1,68 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module Redmine
+ module Acts
+ module Event
+ def self.included(base)
+ base.extend ClassMethods
+ end
+
+ module ClassMethods
+ def acts_as_event(options = {})
+ return if self.included_modules.include?(Redmine::Acts::Event::InstanceMethods)
+ options[:datetime] ||= 'created_on'
+ options[:title] ||= 'title'
+ options[:description] ||= 'description'
+ options[:author] ||= 'author'
+ options[:url] ||= {:controller => 'welcome'}
+ cattr_accessor :event_options
+ self.event_options = options
+ send :include, Redmine::Acts::Event::InstanceMethods
+ end
+ end
+
+ module InstanceMethods
+ def self.included(base)
+ base.extend ClassMethods
+ end
+
+ %w(datetime title description author).each do |attr|
+ src = <<-END_SRC
+ def event_#{attr}
+ option = event_options[:#{attr}]
+ option.is_a?(Proc) ? option.call(self) : send(option)
+ end
+ END_SRC
+ class_eval src, __FILE__, __LINE__
+ end
+
+ def event_date
+ event_datetime.to_date
+ end
+
+ def event_url(options = {})
+ option = event_options[:url]
+ (option.is_a?(Proc) ? option.call(self) : send(option)).merge(options)
+ end
+
+ module ClassMethods
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/acts_as_list/README b/rest_sys/vendor/plugins/acts_as_list/README
new file mode 100644
index 000000000..36ae3188e
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_list/README
@@ -0,0 +1,23 @@
+ActsAsList
+==========
+
+This acts_as extension provides the capabilities for sorting and reordering a number of objects in a list. The class that has this specified needs to have a +position+ column defined as an integer on the mapped database table.
+
+
+Example
+=======
+
+ class TodoList < ActiveRecord::Base
+ has_many :todo_items, :order => "position"
+ end
+
+ class TodoItem < ActiveRecord::Base
+ belongs_to :todo_list
+ acts_as_list :scope => :todo_list
+ end
+
+ todo_list.first.move_to_bottom
+ todo_list.last.move_higher
+
+
+Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_list/init.rb b/rest_sys/vendor/plugins/acts_as_list/init.rb
new file mode 100644
index 000000000..eb87e8790
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_list/init.rb
@@ -0,0 +1,3 @@
+$:.unshift "#{File.dirname(__FILE__)}/lib"
+require 'active_record/acts/list'
+ActiveRecord::Base.class_eval { include ActiveRecord::Acts::List }
diff --git a/rest_sys/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb b/rest_sys/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb
new file mode 100644
index 000000000..00d86928d
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb
@@ -0,0 +1,256 @@
+module ActiveRecord
+ module Acts #:nodoc:
+ module List #:nodoc:
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ # This +acts_as+ extension provides the capabilities for sorting and reordering a number of objects in a list.
+ # The class that has this specified needs to have a +position+ column defined as an integer on
+ # the mapped database table.
+ #
+ # Todo list example:
+ #
+ # class TodoList < ActiveRecord::Base
+ # has_many :todo_items, :order => "position"
+ # end
+ #
+ # class TodoItem < ActiveRecord::Base
+ # belongs_to :todo_list
+ # acts_as_list :scope => :todo_list
+ # end
+ #
+ # todo_list.first.move_to_bottom
+ # todo_list.last.move_higher
+ module ClassMethods
+ # Configuration options are:
+ #
+ # * +column+ - specifies the column name to use for keeping the position integer (default: +position+)
+ # * +scope+ - restricts what is to be considered a list. Given a symbol, it'll attach _id
+ # (if it hasn't already been added) and use that as the foreign key restriction. It's also possible
+ # to give it an entire string that is interpolated if you need a tighter scope than just a foreign key.
+ # Example: acts_as_list :scope => 'todo_list_id = #{todo_list_id} AND completed = 0'
+ def acts_as_list(options = {})
+ configuration = { :column => "position", :scope => "1 = 1" }
+ configuration.update(options) if options.is_a?(Hash)
+
+ configuration[:scope] = "#{configuration[:scope]}_id".intern if configuration[:scope].is_a?(Symbol) && configuration[:scope].to_s !~ /_id$/
+
+ if configuration[:scope].is_a?(Symbol)
+ scope_condition_method = %(
+ def scope_condition
+ if #{configuration[:scope].to_s}.nil?
+ "#{configuration[:scope].to_s} IS NULL"
+ else
+ "#{configuration[:scope].to_s} = \#{#{configuration[:scope].to_s}}"
+ end
+ end
+ )
+ else
+ scope_condition_method = "def scope_condition() \"#{configuration[:scope]}\" end"
+ end
+
+ class_eval <<-EOV
+ include ActiveRecord::Acts::List::InstanceMethods
+
+ def acts_as_list_class
+ ::#{self.name}
+ end
+
+ def position_column
+ '#{configuration[:column]}'
+ end
+
+ #{scope_condition_method}
+
+ before_destroy :remove_from_list
+ before_create :add_to_list_bottom
+ EOV
+ end
+ end
+
+ # All the methods available to a record that has had acts_as_list specified. Each method works
+ # by assuming the object to be the item in the list, so chapter.move_lower would move that chapter
+ # lower in the list of all chapters. Likewise, chapter.first? would return +true+ if that chapter is
+ # the first in the list of all chapters.
+ module InstanceMethods
+ # Insert the item at the given position (defaults to the top position of 1).
+ def insert_at(position = 1)
+ insert_at_position(position)
+ end
+
+ # Swap positions with the next lower item, if one exists.
+ def move_lower
+ return unless lower_item
+
+ acts_as_list_class.transaction do
+ lower_item.decrement_position
+ increment_position
+ end
+ end
+
+ # Swap positions with the next higher item, if one exists.
+ def move_higher
+ return unless higher_item
+
+ acts_as_list_class.transaction do
+ higher_item.increment_position
+ decrement_position
+ end
+ end
+
+ # Move to the bottom of the list. If the item is already in the list, the items below it have their
+ # position adjusted accordingly.
+ def move_to_bottom
+ return unless in_list?
+ acts_as_list_class.transaction do
+ decrement_positions_on_lower_items
+ assume_bottom_position
+ end
+ end
+
+ # Move to the top of the list. If the item is already in the list, the items above it have their
+ # position adjusted accordingly.
+ def move_to_top
+ return unless in_list?
+ acts_as_list_class.transaction do
+ increment_positions_on_higher_items
+ assume_top_position
+ end
+ end
+
+ # Removes the item from the list.
+ def remove_from_list
+ if in_list?
+ decrement_positions_on_lower_items
+ update_attribute position_column, nil
+ end
+ end
+
+ # Increase the position of this item without adjusting the rest of the list.
+ def increment_position
+ return unless in_list?
+ update_attribute position_column, self.send(position_column).to_i + 1
+ end
+
+ # Decrease the position of this item without adjusting the rest of the list.
+ def decrement_position
+ return unless in_list?
+ update_attribute position_column, self.send(position_column).to_i - 1
+ end
+
+ # Return +true+ if this object is the first in the list.
+ def first?
+ return false unless in_list?
+ self.send(position_column) == 1
+ end
+
+ # Return +true+ if this object is the last in the list.
+ def last?
+ return false unless in_list?
+ self.send(position_column) == bottom_position_in_list
+ end
+
+ # Return the next higher item in the list.
+ def higher_item
+ return nil unless in_list?
+ acts_as_list_class.find(:first, :conditions =>
+ "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i - 1).to_s}"
+ )
+ end
+
+ # Return the next lower item in the list.
+ def lower_item
+ return nil unless in_list?
+ acts_as_list_class.find(:first, :conditions =>
+ "#{scope_condition} AND #{position_column} = #{(send(position_column).to_i + 1).to_s}"
+ )
+ end
+
+ # Test if this record is in a list
+ def in_list?
+ !send(position_column).nil?
+ end
+
+ private
+ def add_to_list_top
+ increment_positions_on_all_items
+ end
+
+ def add_to_list_bottom
+ self[position_column] = bottom_position_in_list.to_i + 1
+ end
+
+ # Overwrite this method to define the scope of the list changes
+ def scope_condition() "1" end
+
+ # Returns the bottom position number in the list.
+ # bottom_position_in_list # => 2
+ def bottom_position_in_list(except = nil)
+ item = bottom_item(except)
+ item ? item.send(position_column) : 0
+ end
+
+ # Returns the bottom item
+ def bottom_item(except = nil)
+ conditions = scope_condition
+ conditions = "#{conditions} AND #{self.class.primary_key} != #{except.id}" if except
+ acts_as_list_class.find(:first, :conditions => conditions, :order => "#{position_column} DESC")
+ end
+
+ # Forces item to assume the bottom position in the list.
+ def assume_bottom_position
+ update_attribute(position_column, bottom_position_in_list(self).to_i + 1)
+ end
+
+ # Forces item to assume the top position in the list.
+ def assume_top_position
+ update_attribute(position_column, 1)
+ end
+
+ # This has the effect of moving all the higher items up one.
+ def decrement_positions_on_higher_items(position)
+ acts_as_list_class.update_all(
+ "#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} <= #{position}"
+ )
+ end
+
+ # This has the effect of moving all the lower items up one.
+ def decrement_positions_on_lower_items
+ return unless in_list?
+ acts_as_list_class.update_all(
+ "#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} > #{send(position_column).to_i}"
+ )
+ end
+
+ # This has the effect of moving all the higher items down one.
+ def increment_positions_on_higher_items
+ return unless in_list?
+ acts_as_list_class.update_all(
+ "#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} < #{send(position_column).to_i}"
+ )
+ end
+
+ # This has the effect of moving all the lower items down one.
+ def increment_positions_on_lower_items(position)
+ acts_as_list_class.update_all(
+ "#{position_column} = (#{position_column} + 1)", "#{scope_condition} AND #{position_column} >= #{position}"
+ )
+ end
+
+ # Increments position (position_column ) of all items in the list.
+ def increment_positions_on_all_items
+ acts_as_list_class.update_all(
+ "#{position_column} = (#{position_column} + 1)", "#{scope_condition}"
+ )
+ end
+
+ def insert_at_position(position)
+ remove_from_list
+ increment_positions_on_lower_items(position)
+ self.update_attribute(position_column, position)
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/acts_as_list/test/list_test.rb b/rest_sys/vendor/plugins/acts_as_list/test/list_test.rb
new file mode 100644
index 000000000..e89cb8e12
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_list/test/list_test.rb
@@ -0,0 +1,332 @@
+require 'test/unit'
+
+require 'rubygems'
+gem 'activerecord', '>= 1.15.4.7794'
+require 'active_record'
+
+require "#{File.dirname(__FILE__)}/../init"
+
+ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
+
+def setup_db
+ ActiveRecord::Schema.define(:version => 1) do
+ create_table :mixins do |t|
+ t.column :pos, :integer
+ t.column :parent_id, :integer
+ t.column :created_at, :datetime
+ t.column :updated_at, :datetime
+ end
+ end
+end
+
+def teardown_db
+ ActiveRecord::Base.connection.tables.each do |table|
+ ActiveRecord::Base.connection.drop_table(table)
+ end
+end
+
+class Mixin < ActiveRecord::Base
+end
+
+class ListMixin < Mixin
+ acts_as_list :column => "pos", :scope => :parent
+
+ def self.table_name() "mixins" end
+end
+
+class ListMixinSub1 < ListMixin
+end
+
+class ListMixinSub2 < ListMixin
+end
+
+class ListWithStringScopeMixin < ActiveRecord::Base
+ acts_as_list :column => "pos", :scope => 'parent_id = #{parent_id}'
+
+ def self.table_name() "mixins" end
+end
+
+
+class ListTest < Test::Unit::TestCase
+
+ def setup
+ setup_db
+ (1..4).each { |counter| ListMixin.create! :pos => counter, :parent_id => 5 }
+ end
+
+ def teardown
+ teardown_db
+ end
+
+ def test_reordering
+ assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+
+ ListMixin.find(2).move_lower
+ assert_equal [1, 3, 2, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+
+ ListMixin.find(2).move_higher
+ assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+
+ ListMixin.find(1).move_to_bottom
+ assert_equal [2, 3, 4, 1], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+
+ ListMixin.find(1).move_to_top
+ assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+
+ ListMixin.find(2).move_to_bottom
+ assert_equal [1, 3, 4, 2], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+
+ ListMixin.find(4).move_to_top
+ assert_equal [4, 1, 3, 2], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+ end
+
+ def test_move_to_bottom_with_next_to_last_item
+ assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+ ListMixin.find(3).move_to_bottom
+ assert_equal [1, 2, 4, 3], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+ end
+
+ def test_next_prev
+ assert_equal ListMixin.find(2), ListMixin.find(1).lower_item
+ assert_nil ListMixin.find(1).higher_item
+ assert_equal ListMixin.find(3), ListMixin.find(4).higher_item
+ assert_nil ListMixin.find(4).lower_item
+ end
+
+ def test_injection
+ item = ListMixin.new(:parent_id => 1)
+ assert_equal "parent_id = 1", item.scope_condition
+ assert_equal "pos", item.position_column
+ end
+
+ def test_insert
+ new = ListMixin.create(:parent_id => 20)
+ assert_equal 1, new.pos
+ assert new.first?
+ assert new.last?
+
+ new = ListMixin.create(:parent_id => 20)
+ assert_equal 2, new.pos
+ assert !new.first?
+ assert new.last?
+
+ new = ListMixin.create(:parent_id => 20)
+ assert_equal 3, new.pos
+ assert !new.first?
+ assert new.last?
+
+ new = ListMixin.create(:parent_id => 0)
+ assert_equal 1, new.pos
+ assert new.first?
+ assert new.last?
+ end
+
+ def test_insert_at
+ new = ListMixin.create(:parent_id => 20)
+ assert_equal 1, new.pos
+
+ new = ListMixin.create(:parent_id => 20)
+ assert_equal 2, new.pos
+
+ new = ListMixin.create(:parent_id => 20)
+ assert_equal 3, new.pos
+
+ new4 = ListMixin.create(:parent_id => 20)
+ assert_equal 4, new4.pos
+
+ new4.insert_at(3)
+ assert_equal 3, new4.pos
+
+ new.reload
+ assert_equal 4, new.pos
+
+ new.insert_at(2)
+ assert_equal 2, new.pos
+
+ new4.reload
+ assert_equal 4, new4.pos
+
+ new5 = ListMixin.create(:parent_id => 20)
+ assert_equal 5, new5.pos
+
+ new5.insert_at(1)
+ assert_equal 1, new5.pos
+
+ new4.reload
+ assert_equal 5, new4.pos
+ end
+
+ def test_delete_middle
+ assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+
+ ListMixin.find(2).destroy
+
+ assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+
+ assert_equal 1, ListMixin.find(1).pos
+ assert_equal 2, ListMixin.find(3).pos
+ assert_equal 3, ListMixin.find(4).pos
+
+ ListMixin.find(1).destroy
+
+ assert_equal [3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+
+ assert_equal 1, ListMixin.find(3).pos
+ assert_equal 2, ListMixin.find(4).pos
+ end
+
+ def test_with_string_based_scope
+ new = ListWithStringScopeMixin.create(:parent_id => 500)
+ assert_equal 1, new.pos
+ assert new.first?
+ assert new.last?
+ end
+
+ def test_nil_scope
+ new1, new2, new3 = ListMixin.create, ListMixin.create, ListMixin.create
+ new2.move_higher
+ assert_equal [new2, new1, new3], ListMixin.find(:all, :conditions => 'parent_id IS NULL', :order => 'pos')
+ end
+
+
+ def test_remove_from_list_should_then_fail_in_list?
+ assert_equal true, ListMixin.find(1).in_list?
+ ListMixin.find(1).remove_from_list
+ assert_equal false, ListMixin.find(1).in_list?
+ end
+
+ def test_remove_from_list_should_set_position_to_nil
+ assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+
+ ListMixin.find(2).remove_from_list
+
+ assert_equal [2, 1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+
+ assert_equal 1, ListMixin.find(1).pos
+ assert_equal nil, ListMixin.find(2).pos
+ assert_equal 2, ListMixin.find(3).pos
+ assert_equal 3, ListMixin.find(4).pos
+ end
+
+ def test_remove_before_destroy_does_not_shift_lower_items_twice
+ assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+
+ ListMixin.find(2).remove_from_list
+ ListMixin.find(2).destroy
+
+ assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
+
+ assert_equal 1, ListMixin.find(1).pos
+ assert_equal 2, ListMixin.find(3).pos
+ assert_equal 3, ListMixin.find(4).pos
+ end
+
+end
+
+class ListSubTest < Test::Unit::TestCase
+
+ def setup
+ setup_db
+ (1..4).each { |i| ((i % 2 == 1) ? ListMixinSub1 : ListMixinSub2).create! :pos => i, :parent_id => 5000 }
+ end
+
+ def teardown
+ teardown_db
+ end
+
+ def test_reordering
+ assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
+
+ ListMixin.find(2).move_lower
+ assert_equal [1, 3, 2, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
+
+ ListMixin.find(2).move_higher
+ assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
+
+ ListMixin.find(1).move_to_bottom
+ assert_equal [2, 3, 4, 1], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
+
+ ListMixin.find(1).move_to_top
+ assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
+
+ ListMixin.find(2).move_to_bottom
+ assert_equal [1, 3, 4, 2], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
+
+ ListMixin.find(4).move_to_top
+ assert_equal [4, 1, 3, 2], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
+ end
+
+ def test_move_to_bottom_with_next_to_last_item
+ assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
+ ListMixin.find(3).move_to_bottom
+ assert_equal [1, 2, 4, 3], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
+ end
+
+ def test_next_prev
+ assert_equal ListMixin.find(2), ListMixin.find(1).lower_item
+ assert_nil ListMixin.find(1).higher_item
+ assert_equal ListMixin.find(3), ListMixin.find(4).higher_item
+ assert_nil ListMixin.find(4).lower_item
+ end
+
+ def test_injection
+ item = ListMixin.new("parent_id"=>1)
+ assert_equal "parent_id = 1", item.scope_condition
+ assert_equal "pos", item.position_column
+ end
+
+ def test_insert_at
+ new = ListMixin.create("parent_id" => 20)
+ assert_equal 1, new.pos
+
+ new = ListMixinSub1.create("parent_id" => 20)
+ assert_equal 2, new.pos
+
+ new = ListMixinSub2.create("parent_id" => 20)
+ assert_equal 3, new.pos
+
+ new4 = ListMixin.create("parent_id" => 20)
+ assert_equal 4, new4.pos
+
+ new4.insert_at(3)
+ assert_equal 3, new4.pos
+
+ new.reload
+ assert_equal 4, new.pos
+
+ new.insert_at(2)
+ assert_equal 2, new.pos
+
+ new4.reload
+ assert_equal 4, new4.pos
+
+ new5 = ListMixinSub1.create("parent_id" => 20)
+ assert_equal 5, new5.pos
+
+ new5.insert_at(1)
+ assert_equal 1, new5.pos
+
+ new4.reload
+ assert_equal 5, new4.pos
+ end
+
+ def test_delete_middle
+ assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
+
+ ListMixin.find(2).destroy
+
+ assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
+
+ assert_equal 1, ListMixin.find(1).pos
+ assert_equal 2, ListMixin.find(3).pos
+ assert_equal 3, ListMixin.find(4).pos
+
+ ListMixin.find(1).destroy
+
+ assert_equal [3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id)
+
+ assert_equal 1, ListMixin.find(3).pos
+ assert_equal 2, ListMixin.find(4).pos
+ end
+
+end
diff --git a/rest_sys/vendor/plugins/acts_as_searchable/init.rb b/rest_sys/vendor/plugins/acts_as_searchable/init.rb
new file mode 100644
index 000000000..063721756
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_searchable/init.rb
@@ -0,0 +1,2 @@
+require File.dirname(__FILE__) + '/lib/acts_as_searchable'
+ActiveRecord::Base.send(:include, Redmine::Acts::Searchable)
diff --git a/rest_sys/vendor/plugins/acts_as_searchable/lib/acts_as_searchable.rb b/rest_sys/vendor/plugins/acts_as_searchable/lib/acts_as_searchable.rb
new file mode 100644
index 000000000..1dd88978c
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_searchable/lib/acts_as_searchable.rb
@@ -0,0 +1,110 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module Redmine
+ module Acts
+ module Searchable
+ def self.included(base)
+ base.extend ClassMethods
+ end
+
+ module ClassMethods
+ def acts_as_searchable(options = {})
+ return if self.included_modules.include?(Redmine::Acts::Searchable::InstanceMethods)
+
+ cattr_accessor :searchable_options
+ self.searchable_options = options
+
+ if searchable_options[:columns].nil?
+ raise 'No searchable column defined.'
+ elsif !searchable_options[:columns].is_a?(Array)
+ searchable_options[:columns] = [] << searchable_options[:columns]
+ end
+
+ if searchable_options[:project_key]
+ elsif column_names.include?('project_id')
+ searchable_options[:project_key] = "#{table_name}.project_id"
+ else
+ raise 'No project key defined.'
+ end
+
+ if searchable_options[:date_column]
+ elsif column_names.include?('created_on')
+ searchable_options[:date_column] = "#{table_name}.created_on"
+ else
+ raise 'No date column defined defined.'
+ end
+
+ # Should we search custom fields on this model ?
+ searchable_options[:search_custom_fields] = !reflect_on_association(:custom_values).nil?
+
+ send :include, Redmine::Acts::Searchable::InstanceMethods
+ end
+ end
+
+ module InstanceMethods
+ def self.included(base)
+ base.extend ClassMethods
+ end
+
+ module ClassMethods
+ def search(tokens, project, options={})
+ tokens = [] << tokens unless tokens.is_a?(Array)
+ find_options = {:include => searchable_options[:include]}
+ find_options[:limit] = options[:limit] if options[:limit]
+ find_options[:order] = "#{searchable_options[:date_column]} " + (options[:before] ? 'DESC' : 'ASC')
+ columns = searchable_options[:columns]
+ columns.slice!(1..-1) if options[:titles_only]
+
+ token_clauses = columns.collect {|column| "(LOWER(#{column}) LIKE ?)"}
+
+ if !options[:titles_only] && searchable_options[:search_custom_fields]
+ searchable_custom_field_ids = CustomField.find(:all,
+ :select => 'id',
+ :conditions => { :type => "#{self.name}CustomField",
+ :searchable => true }).collect(&:id)
+ if searchable_custom_field_ids.any?
+ custom_field_sql = "#{table_name}.id IN (SELECT customized_id FROM #{CustomValue.table_name}" +
+ " WHERE customized_type='#{self.name}' AND customized_id=#{table_name}.id AND LOWER(value) LIKE ?" +
+ " AND #{CustomValue.table_name}.custom_field_id IN (#{searchable_custom_field_ids.join(',')}))"
+ token_clauses << custom_field_sql
+ end
+ end
+
+ sql = ([token_clauses.join(' OR ')] * tokens.size).join(options[:all_words] ? ' AND ' : ' OR ')
+
+ if options[:offset]
+ sql = "(#{sql}) AND (#{searchable_options[:date_column]} " + (options[:before] ? '<' : '>') + "'#{connection.quoted_date(options[:offset])}')"
+ end
+ find_options[:conditions] = [sql, * (tokens * token_clauses.size).sort]
+
+ results = with_scope(:find => {:conditions => ["#{searchable_options[:project_key]} = ?", project.id]}) do
+ find(:all, find_options)
+ end
+ if searchable_options[:with] && !options[:titles_only]
+ searchable_options[:with].each do |model, assoc|
+ results += model.to_s.camelcase.constantize.search(tokens, project, options).collect {|r| r.send assoc}
+ end
+ results.uniq!
+ end
+ results
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/acts_as_tree/README b/rest_sys/vendor/plugins/acts_as_tree/README
new file mode 100644
index 000000000..a6cc6a904
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_tree/README
@@ -0,0 +1,26 @@
+acts_as_tree
+============
+
+Specify this +acts_as+ extension if you want to model a tree structure by providing a parent association and a children
+association. This requires that you have a foreign key column, which by default is called +parent_id+.
+
+ class Category < ActiveRecord::Base
+ acts_as_tree :order => "name"
+ end
+
+ Example:
+ root
+ \_ child1
+ \_ subchild1
+ \_ subchild2
+
+ root = Category.create("name" => "root")
+ child1 = root.children.create("name" => "child1")
+ subchild1 = child1.children.create("name" => "subchild1")
+
+ root.parent # => nil
+ child1.parent # => root
+ root.children # => [child1]
+ root.children.first.children.first # => subchild1
+
+Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_tree/Rakefile b/rest_sys/vendor/plugins/acts_as_tree/Rakefile
new file mode 100644
index 000000000..da091d9dd
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_tree/Rakefile
@@ -0,0 +1,22 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test acts_as_tree plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for acts_as_tree plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'acts_as_tree'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
diff --git a/rest_sys/vendor/plugins/acts_as_tree/init.rb b/rest_sys/vendor/plugins/acts_as_tree/init.rb
new file mode 100644
index 000000000..0901ddb4a
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_tree/init.rb
@@ -0,0 +1 @@
+ActiveRecord::Base.send :include, ActiveRecord::Acts::Tree
diff --git a/rest_sys/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb b/rest_sys/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb
new file mode 100644
index 000000000..1f00e90a9
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb
@@ -0,0 +1,96 @@
+module ActiveRecord
+ module Acts
+ module Tree
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ # Specify this +acts_as+ extension if you want to model a tree structure by providing a parent association and a children
+ # association. This requires that you have a foreign key column, which by default is called +parent_id+.
+ #
+ # class Category < ActiveRecord::Base
+ # acts_as_tree :order => "name"
+ # end
+ #
+ # Example:
+ # root
+ # \_ child1
+ # \_ subchild1
+ # \_ subchild2
+ #
+ # root = Category.create("name" => "root")
+ # child1 = root.children.create("name" => "child1")
+ # subchild1 = child1.children.create("name" => "subchild1")
+ #
+ # root.parent # => nil
+ # child1.parent # => root
+ # root.children # => [child1]
+ # root.children.first.children.first # => subchild1
+ #
+ # In addition to the parent and children associations, the following instance methods are added to the class
+ # after calling acts_as_tree :
+ # * siblings - Returns all the children of the parent, excluding the current node ([subchild2] when called on subchild1 )
+ # * self_and_siblings - Returns all the children of the parent, including the current node ([subchild1, subchild2] when called on subchild1 )
+ # * ancestors - Returns all the ancestors of the current node ([child1, root] when called on subchild2 )
+ # * root - Returns the root of the current node (root when called on subchild2 )
+ module ClassMethods
+ # Configuration options are:
+ #
+ # * foreign_key - specifies the column name to use for tracking of the tree (default: +parent_id+)
+ # * order - makes it possible to sort the children according to this SQL snippet.
+ # * counter_cache - keeps a count in a +children_count+ column if set to +true+ (default: +false+).
+ def acts_as_tree(options = {})
+ configuration = { :foreign_key => "parent_id", :order => nil, :counter_cache => nil }
+ configuration.update(options) if options.is_a?(Hash)
+
+ belongs_to :parent, :class_name => name, :foreign_key => configuration[:foreign_key], :counter_cache => configuration[:counter_cache]
+ has_many :children, :class_name => name, :foreign_key => configuration[:foreign_key], :order => configuration[:order], :dependent => :destroy
+
+ class_eval <<-EOV
+ include ActiveRecord::Acts::Tree::InstanceMethods
+
+ def self.roots
+ find(:all, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}})
+ end
+
+ def self.root
+ find(:first, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}})
+ end
+ EOV
+ end
+ end
+
+ module InstanceMethods
+ # Returns list of ancestors, starting from parent until root.
+ #
+ # subchild1.ancestors # => [child1, root]
+ def ancestors
+ node, nodes = self, []
+ nodes << node = node.parent while node.parent
+ nodes
+ end
+
+ # Returns the root node of the tree.
+ def root
+ node = self
+ node = node.parent while node.parent
+ node
+ end
+
+ # Returns all siblings of the current node.
+ #
+ # subchild1.siblings # => [subchild2]
+ def siblings
+ self_and_siblings - [self]
+ end
+
+ # Returns all siblings and a reference to the current node.
+ #
+ # subchild1.self_and_siblings # => [subchild1, subchild2]
+ def self_and_siblings
+ parent ? parent.children : self.class.roots
+ end
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/acts_as_tree/test/abstract_unit.rb b/rest_sys/vendor/plugins/acts_as_tree/test/abstract_unit.rb
new file mode 100644
index 000000000..e69de29bb
diff --git a/rest_sys/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb b/rest_sys/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb
new file mode 100644
index 000000000..018c58e1f
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb
@@ -0,0 +1,219 @@
+require 'test/unit'
+
+require 'rubygems'
+require 'active_record'
+
+$:.unshift File.dirname(__FILE__) + '/../lib'
+require File.dirname(__FILE__) + '/../init'
+
+class Test::Unit::TestCase
+ def assert_queries(num = 1)
+ $query_count = 0
+ yield
+ ensure
+ assert_equal num, $query_count, "#{$query_count} instead of #{num} queries were executed."
+ end
+
+ def assert_no_queries(&block)
+ assert_queries(0, &block)
+ end
+end
+
+ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
+
+# AR keeps printing annoying schema statements
+$stdout = StringIO.new
+
+def setup_db
+ ActiveRecord::Base.logger
+ ActiveRecord::Schema.define(:version => 1) do
+ create_table :mixins do |t|
+ t.column :type, :string
+ t.column :parent_id, :integer
+ end
+ end
+end
+
+def teardown_db
+ ActiveRecord::Base.connection.tables.each do |table|
+ ActiveRecord::Base.connection.drop_table(table)
+ end
+end
+
+class Mixin < ActiveRecord::Base
+end
+
+class TreeMixin < Mixin
+ acts_as_tree :foreign_key => "parent_id", :order => "id"
+end
+
+class TreeMixinWithoutOrder < Mixin
+ acts_as_tree :foreign_key => "parent_id"
+end
+
+class RecursivelyCascadedTreeMixin < Mixin
+ acts_as_tree :foreign_key => "parent_id"
+ has_one :first_child, :class_name => 'RecursivelyCascadedTreeMixin', :foreign_key => :parent_id
+end
+
+class TreeTest < Test::Unit::TestCase
+
+ def setup
+ setup_db
+ @root1 = TreeMixin.create!
+ @root_child1 = TreeMixin.create! :parent_id => @root1.id
+ @child1_child = TreeMixin.create! :parent_id => @root_child1.id
+ @root_child2 = TreeMixin.create! :parent_id => @root1.id
+ @root2 = TreeMixin.create!
+ @root3 = TreeMixin.create!
+ end
+
+ def teardown
+ teardown_db
+ end
+
+ def test_children
+ assert_equal @root1.children, [@root_child1, @root_child2]
+ assert_equal @root_child1.children, [@child1_child]
+ assert_equal @child1_child.children, []
+ assert_equal @root_child2.children, []
+ end
+
+ def test_parent
+ assert_equal @root_child1.parent, @root1
+ assert_equal @root_child1.parent, @root_child2.parent
+ assert_nil @root1.parent
+ end
+
+ def test_delete
+ assert_equal 6, TreeMixin.count
+ @root1.destroy
+ assert_equal 2, TreeMixin.count
+ @root2.destroy
+ @root3.destroy
+ assert_equal 0, TreeMixin.count
+ end
+
+ def test_insert
+ @extra = @root1.children.create
+
+ assert @extra
+
+ assert_equal @extra.parent, @root1
+
+ assert_equal 3, @root1.children.size
+ assert @root1.children.include?(@extra)
+ assert @root1.children.include?(@root_child1)
+ assert @root1.children.include?(@root_child2)
+ end
+
+ def test_ancestors
+ assert_equal [], @root1.ancestors
+ assert_equal [@root1], @root_child1.ancestors
+ assert_equal [@root_child1, @root1], @child1_child.ancestors
+ assert_equal [@root1], @root_child2.ancestors
+ assert_equal [], @root2.ancestors
+ assert_equal [], @root3.ancestors
+ end
+
+ def test_root
+ assert_equal @root1, TreeMixin.root
+ assert_equal @root1, @root1.root
+ assert_equal @root1, @root_child1.root
+ assert_equal @root1, @child1_child.root
+ assert_equal @root1, @root_child2.root
+ assert_equal @root2, @root2.root
+ assert_equal @root3, @root3.root
+ end
+
+ def test_roots
+ assert_equal [@root1, @root2, @root3], TreeMixin.roots
+ end
+
+ def test_siblings
+ assert_equal [@root2, @root3], @root1.siblings
+ assert_equal [@root_child2], @root_child1.siblings
+ assert_equal [], @child1_child.siblings
+ assert_equal [@root_child1], @root_child2.siblings
+ assert_equal [@root1, @root3], @root2.siblings
+ assert_equal [@root1, @root2], @root3.siblings
+ end
+
+ def test_self_and_siblings
+ assert_equal [@root1, @root2, @root3], @root1.self_and_siblings
+ assert_equal [@root_child1, @root_child2], @root_child1.self_and_siblings
+ assert_equal [@child1_child], @child1_child.self_and_siblings
+ assert_equal [@root_child1, @root_child2], @root_child2.self_and_siblings
+ assert_equal [@root1, @root2, @root3], @root2.self_and_siblings
+ assert_equal [@root1, @root2, @root3], @root3.self_and_siblings
+ end
+end
+
+class TreeTestWithEagerLoading < Test::Unit::TestCase
+
+ def setup
+ teardown_db
+ setup_db
+ @root1 = TreeMixin.create!
+ @root_child1 = TreeMixin.create! :parent_id => @root1.id
+ @child1_child = TreeMixin.create! :parent_id => @root_child1.id
+ @root_child2 = TreeMixin.create! :parent_id => @root1.id
+ @root2 = TreeMixin.create!
+ @root3 = TreeMixin.create!
+
+ @rc1 = RecursivelyCascadedTreeMixin.create!
+ @rc2 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc1.id
+ @rc3 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc2.id
+ @rc4 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc3.id
+ end
+
+ def teardown
+ teardown_db
+ end
+
+ def test_eager_association_loading
+ roots = TreeMixin.find(:all, :include => :children, :conditions => "mixins.parent_id IS NULL", :order => "mixins.id")
+ assert_equal [@root1, @root2, @root3], roots
+ assert_no_queries do
+ assert_equal 2, roots[0].children.size
+ assert_equal 0, roots[1].children.size
+ assert_equal 0, roots[2].children.size
+ end
+ end
+
+ def test_eager_association_loading_with_recursive_cascading_three_levels_has_many
+ root_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :children => { :children => :children } }, :order => 'mixins.id')
+ assert_equal @rc4, assert_no_queries { root_node.children.first.children.first.children.first }
+ end
+
+ def test_eager_association_loading_with_recursive_cascading_three_levels_has_one
+ root_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :first_child => { :first_child => :first_child } }, :order => 'mixins.id')
+ assert_equal @rc4, assert_no_queries { root_node.first_child.first_child.first_child }
+ end
+
+ def test_eager_association_loading_with_recursive_cascading_three_levels_belongs_to
+ leaf_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :parent => { :parent => :parent } }, :order => 'mixins.id DESC')
+ assert_equal @rc1, assert_no_queries { leaf_node.parent.parent.parent }
+ end
+end
+
+class TreeTestWithoutOrder < Test::Unit::TestCase
+
+ def setup
+ setup_db
+ @root1 = TreeMixinWithoutOrder.create!
+ @root2 = TreeMixinWithoutOrder.create!
+ end
+
+ def teardown
+ teardown_db
+ end
+
+ def test_root
+ assert [@root1, @root2].include?(TreeMixinWithoutOrder.root)
+ end
+
+ def test_roots
+ assert_equal [], [@root1, @root2] - TreeMixinWithoutOrder.roots
+ end
+end
diff --git a/rest_sys/vendor/plugins/acts_as_tree/test/database.yml b/rest_sys/vendor/plugins/acts_as_tree/test/database.yml
new file mode 100644
index 000000000..e69de29bb
diff --git a/rest_sys/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb b/rest_sys/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb
new file mode 100644
index 000000000..e69de29bb
diff --git a/rest_sys/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml b/rest_sys/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml
new file mode 100644
index 000000000..e69de29bb
diff --git a/rest_sys/vendor/plugins/acts_as_tree/test/schema.rb b/rest_sys/vendor/plugins/acts_as_tree/test/schema.rb
new file mode 100644
index 000000000..e69de29bb
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/CHANGELOG b/rest_sys/vendor/plugins/acts_as_versioned/CHANGELOG
new file mode 100644
index 000000000..a5d339cc7
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/CHANGELOG
@@ -0,0 +1,74 @@
+*SVN* (version numbers are overrated)
+
+* (5 Oct 2006) Allow customization of #versions association options [Dan Peterson]
+
+*0.5.1*
+
+* (8 Aug 2006) Versioned models now belong to the unversioned model. @article_version.article.class => Article [Aslak Hellesoy]
+
+*0.5* # do versions even matter for plugins?
+
+* (21 Apr 2006) Added without_locking and without_revision methods.
+
+ Foo.without_revision do
+ @foo.update_attributes ...
+ end
+
+*0.4*
+
+* (28 March 2006) Rename non_versioned_fields to non_versioned_columns (old one is kept for compatibility).
+* (28 March 2006) Made explicit documentation note that string column names are required for non_versioned_columns.
+
+*0.3.1*
+
+* (7 Jan 2006) explicitly set :foreign_key option for the versioned model's belongs_to assocation for STI [Caged]
+* (7 Jan 2006) added tests to prove has_many :through joins work
+
+*0.3*
+
+* (2 Jan 2006) added ability to share a mixin with versioned class
+* (2 Jan 2006) changed the dynamic version model to MyModel::Version
+
+*0.2.4*
+
+* (27 Nov 2005) added note about possible destructive behavior of if_changed? [Michael Schuerig]
+
+*0.2.3*
+
+* (12 Nov 2005) fixed bug with old behavior of #blank? [Michael Schuerig]
+* (12 Nov 2005) updated tests to use ActiveRecord Schema
+
+*0.2.2*
+
+* (3 Nov 2005) added documentation note to #acts_as_versioned [Martin Jul]
+
+*0.2.1*
+
+* (6 Oct 2005) renamed dirty? to changed? to keep it uniform. it was aliased to keep it backwards compatible.
+
+*0.2*
+
+* (6 Oct 2005) added find_versions and find_version class methods.
+
+* (6 Oct 2005) removed transaction from create_versioned_table().
+ this way you can specify your own transaction around a group of operations.
+
+* (30 Sep 2005) fixed bug where find_versions() would order by 'version' twice. (found by Joe Clark)
+
+* (26 Sep 2005) added :sequence_name option to acts_as_versioned to set the sequence name on the versioned model
+
+*0.1.3* (18 Sep 2005)
+
+* First RubyForge release
+
+*0.1.2*
+
+* check if module is already included when acts_as_versioned is called
+
+*0.1.1*
+
+* Adding tests and rdocs
+
+*0.1*
+
+* Initial transfer from Rails ticket: http://dev.rubyonrails.com/ticket/1974
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/MIT-LICENSE b/rest_sys/vendor/plugins/acts_as_versioned/MIT-LICENSE
new file mode 100644
index 000000000..5851fdae1
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2005 Rick Olson
+
+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.
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/README b/rest_sys/vendor/plugins/acts_as_versioned/README
new file mode 100644
index 000000000..8961f0522
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/README
@@ -0,0 +1,28 @@
+= acts_as_versioned
+
+This library adds simple versioning to an ActiveRecord module. ActiveRecord is required.
+
+== Resources
+
+Install
+
+* gem install acts_as_versioned
+
+Rubyforge project
+
+* http://rubyforge.org/projects/ar-versioned
+
+RDocs
+
+* http://ar-versioned.rubyforge.org
+
+Subversion
+
+* http://techno-weenie.net/svn/projects/acts_as_versioned
+
+Collaboa
+
+* http://collaboa.techno-weenie.net/repository/browse/acts_as_versioned
+
+Special thanks to Dreamer on ##rubyonrails for help in early testing. His ServerSideWiki (http://serversidewiki.com)
+was the first project to use acts_as_versioned in the wild .
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/RUNNING_UNIT_TESTS b/rest_sys/vendor/plugins/acts_as_versioned/RUNNING_UNIT_TESTS
new file mode 100644
index 000000000..a6e55b841
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/RUNNING_UNIT_TESTS
@@ -0,0 +1,41 @@
+== Creating the test database
+
+The default name for the test databases is "activerecord_versioned". If you
+want to use another database name then be sure to update the connection
+adapter setups you want to test with in test/connections//connection.rb.
+When you have the database online, you can import the fixture tables with
+the test/fixtures/db_definitions/*.sql files.
+
+Make sure that you create database objects with the same user that you specified in i
+connection.rb otherwise (on Postgres, at least) tests for default values will fail.
+
+== Running with Rake
+
+The easiest way to run the unit tests is through Rake. The default task runs
+the entire test suite for all the adapters. You can also run the suite on just
+one adapter by using the tasks test_mysql_ruby, test_ruby_mysql, test_sqlite,
+or test_postresql. For more information, checkout the full array of rake tasks with "rake -T"
+
+Rake can be found at http://rake.rubyforge.org
+
+== Running by hand
+
+Unit tests are located in test directory. If you only want to run a single test suite,
+or don't want to bother with Rake, you can do so with something like:
+
+ cd test; ruby -I "connections/native_mysql" base_test.rb
+
+That'll run the base suite using the MySQL-Ruby adapter. Change the adapter
+and test suite name as needed.
+
+== Faster tests
+
+If you are using a database that supports transactions, you can set the
+"AR_TX_FIXTURES" environment variable to "yes" to use transactional fixtures.
+This gives a very large speed boost. With rake:
+
+ rake AR_TX_FIXTURES=yes
+
+Or, by hand:
+
+ AR_TX_FIXTURES=yes ruby -I connections/native_sqlite3 base_test.rb
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/Rakefile b/rest_sys/vendor/plugins/acts_as_versioned/Rakefile
new file mode 100644
index 000000000..3ae69e961
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/Rakefile
@@ -0,0 +1,182 @@
+require 'rubygems'
+
+Gem::manage_gems
+
+require 'rake/rdoctask'
+require 'rake/packagetask'
+require 'rake/gempackagetask'
+require 'rake/testtask'
+require 'rake/contrib/rubyforgepublisher'
+
+PKG_NAME = 'acts_as_versioned'
+PKG_VERSION = '0.3.1'
+PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
+PROD_HOST = "technoweenie@bidwell.textdrive.com"
+RUBY_FORGE_PROJECT = 'ar-versioned'
+RUBY_FORGE_USER = 'technoweenie'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the calculations plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the calculations plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "#{PKG_NAME} -- Simple versioning with active record models"
+ rdoc.options << '--line-numbers --inline-source'
+ rdoc.rdoc_files.include('README', 'CHANGELOG', 'RUNNING_UNIT_TESTS')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+spec = Gem::Specification.new do |s|
+ s.name = PKG_NAME
+ s.version = PKG_VERSION
+ s.platform = Gem::Platform::RUBY
+ s.summary = "Simple versioning with active record models"
+ s.files = FileList["{lib,test}/**/*"].to_a + %w(README MIT-LICENSE CHANGELOG RUNNING_UNIT_TESTS)
+ s.files.delete "acts_as_versioned_plugin.sqlite.db"
+ s.files.delete "acts_as_versioned_plugin.sqlite3.db"
+ s.files.delete "test/debug.log"
+ s.require_path = 'lib'
+ s.autorequire = 'acts_as_versioned'
+ s.has_rdoc = true
+ s.test_files = Dir['test/**/*_test.rb']
+ s.add_dependency 'activerecord', '>= 1.10.1'
+ s.add_dependency 'activesupport', '>= 1.1.1'
+ s.author = "Rick Olson"
+ s.email = "technoweenie@gmail.com"
+ s.homepage = "http://techno-weenie.net"
+end
+
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.need_tar = true
+end
+
+desc "Publish the API documentation"
+task :pdoc => [:rdoc] do
+ Rake::RubyForgePublisher.new(RUBY_FORGE_PROJECT, RUBY_FORGE_USER).upload
+end
+
+desc 'Publish the gem and API docs'
+task :publish => [:pdoc, :rubyforge_upload]
+
+desc "Publish the release files to RubyForge."
+task :rubyforge_upload => :package do
+ files = %w(gem tgz).map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
+
+ if RUBY_FORGE_PROJECT then
+ require 'net/http'
+ require 'open-uri'
+
+ project_uri = "http://rubyforge.org/projects/#{RUBY_FORGE_PROJECT}/"
+ project_data = open(project_uri) { |data| data.read }
+ group_id = project_data[/[?&]group_id=(\d+)/, 1]
+ raise "Couldn't get group id" unless group_id
+
+ # This echos password to shell which is a bit sucky
+ if ENV["RUBY_FORGE_PASSWORD"]
+ password = ENV["RUBY_FORGE_PASSWORD"]
+ else
+ print "#{RUBY_FORGE_USER}@rubyforge.org's password: "
+ password = STDIN.gets.chomp
+ end
+
+ login_response = Net::HTTP.start("rubyforge.org", 80) do |http|
+ data = [
+ "login=1",
+ "form_loginname=#{RUBY_FORGE_USER}",
+ "form_pw=#{password}"
+ ].join("&")
+ http.post("/account/login.php", data)
+ end
+
+ cookie = login_response["set-cookie"]
+ raise "Login failed" unless cookie
+ headers = { "Cookie" => cookie }
+
+ release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
+ release_data = open(release_uri, headers) { |data| data.read }
+ package_id = release_data[/[?&]package_id=(\d+)/, 1]
+ raise "Couldn't get package id" unless package_id
+
+ first_file = true
+ release_id = ""
+
+ files.each do |filename|
+ basename = File.basename(filename)
+ file_ext = File.extname(filename)
+ file_data = File.open(filename, "rb") { |file| file.read }
+
+ puts "Releasing #{basename}..."
+
+ release_response = Net::HTTP.start("rubyforge.org", 80) do |http|
+ release_date = Time.now.strftime("%Y-%m-%d %H:%M")
+ type_map = {
+ ".zip" => "3000",
+ ".tgz" => "3110",
+ ".gz" => "3110",
+ ".gem" => "1400"
+ }; type_map.default = "9999"
+ type = type_map[file_ext]
+ boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
+
+ query_hash = if first_file then
+ {
+ "group_id" => group_id,
+ "package_id" => package_id,
+ "release_name" => PKG_FILE_NAME,
+ "release_date" => release_date,
+ "type_id" => type,
+ "processor_id" => "8000", # Any
+ "release_notes" => "",
+ "release_changes" => "",
+ "preformatted" => "1",
+ "submit" => "1"
+ }
+ else
+ {
+ "group_id" => group_id,
+ "release_id" => release_id,
+ "package_id" => package_id,
+ "step2" => "1",
+ "type_id" => type,
+ "processor_id" => "8000", # Any
+ "submit" => "Add This File"
+ }
+ end
+
+ query = "?" + query_hash.map do |(name, value)|
+ [name, URI.encode(value)].join("=")
+ end.join("&")
+
+ data = [
+ "--" + boundary,
+ "Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
+ "Content-Type: application/octet-stream",
+ "Content-Transfer-Encoding: binary",
+ "", file_data, ""
+ ].join("\x0D\x0A")
+
+ release_headers = headers.merge(
+ "Content-Type" => "multipart/form-data; boundary=#{boundary}"
+ )
+
+ target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
+ http.post(target + query, data, release_headers)
+ end
+
+ if first_file then
+ release_id = release_response.body[/release_id=(\d+)/, 1]
+ raise("Couldn't get release id") unless release_id
+ end
+
+ first_file = false
+ end
+ end
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/init.rb b/rest_sys/vendor/plugins/acts_as_versioned/init.rb
new file mode 100644
index 000000000..5937bbc7c
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/init.rb
@@ -0,0 +1 @@
+require 'acts_as_versioned'
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb b/rest_sys/vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb
new file mode 100644
index 000000000..5e6f6e636
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/lib/acts_as_versioned.rb
@@ -0,0 +1,511 @@
+# Copyright (c) 2005 Rick Olson
+#
+# 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.
+
+module ActiveRecord #:nodoc:
+ module Acts #:nodoc:
+ # Specify this act if you want to save a copy of the row in a versioned table. This assumes there is a
+ # versioned table ready and that your model has a version field. This works with optimisic locking if the lock_version
+ # column is present as well.
+ #
+ # The class for the versioned model is derived the first time it is seen. Therefore, if you change your database schema you have to restart
+ # your container for the changes to be reflected. In development mode this usually means restarting WEBrick.
+ #
+ # class Page < ActiveRecord::Base
+ # # assumes pages_versions table
+ # acts_as_versioned
+ # end
+ #
+ # Example:
+ #
+ # page = Page.create(:title => 'hello world!')
+ # page.version # => 1
+ #
+ # page.title = 'hello world'
+ # page.save
+ # page.version # => 2
+ # page.versions.size # => 2
+ #
+ # page.revert_to(1) # using version number
+ # page.title # => 'hello world!'
+ #
+ # page.revert_to(page.versions.last) # using versioned instance
+ # page.title # => 'hello world'
+ #
+ # See ActiveRecord::Acts::Versioned::ClassMethods#acts_as_versioned for configuration options
+ module Versioned
+ CALLBACKS = [:set_new_version, :save_version_on_create, :save_version?, :clear_changed_attributes]
+ def self.included(base) # :nodoc:
+ base.extend ClassMethods
+ end
+
+ module ClassMethods
+ # == Configuration options
+ #
+ # * class_name - versioned model class name (default: PageVersion in the above example)
+ # * table_name - versioned model table name (default: page_versions in the above example)
+ # * foreign_key - foreign key used to relate the versioned model to the original model (default: page_id in the above example)
+ # * inheritance_column - name of the column to save the model's inheritance_column value for STI. (default: versioned_type)
+ # * version_column - name of the column in the model that keeps the version number (default: version)
+ # * sequence_name - name of the custom sequence to be used by the versioned model.
+ # * limit - number of revisions to keep, defaults to unlimited
+ # * if - symbol of method to check before saving a new version. If this method returns false, a new version is not saved.
+ # For finer control, pass either a Proc or modify Model#version_condition_met?
+ #
+ # acts_as_versioned :if => Proc.new { |auction| !auction.expired? }
+ #
+ # or...
+ #
+ # class Auction
+ # def version_condition_met? # totally bypasses the :if option
+ # !expired?
+ # end
+ # end
+ #
+ # * if_changed - Simple way of specifying attributes that are required to be changed before saving a model. This takes
+ # either a symbol or array of symbols. WARNING - This will attempt to overwrite any attribute setters you may have.
+ # Use this instead if you want to write your own attribute setters (and ignore if_changed):
+ #
+ # def name=(new_name)
+ # write_changed_attribute :name, new_name
+ # end
+ #
+ # * extend - Lets you specify a module to be mixed in both the original and versioned models. You can also just pass a block
+ # to create an anonymous mixin:
+ #
+ # class Auction
+ # acts_as_versioned do
+ # def started?
+ # !started_at.nil?
+ # end
+ # end
+ # end
+ #
+ # or...
+ #
+ # module AuctionExtension
+ # def started?
+ # !started_at.nil?
+ # end
+ # end
+ # class Auction
+ # acts_as_versioned :extend => AuctionExtension
+ # end
+ #
+ # Example code:
+ #
+ # @auction = Auction.find(1)
+ # @auction.started?
+ # @auction.versions.first.started?
+ #
+ # == Database Schema
+ #
+ # The model that you're versioning needs to have a 'version' attribute. The model is versioned
+ # into a table called #{model}_versions where the model name is singlular. The _versions table should
+ # contain all the fields you want versioned, the same version column, and a #{model}_id foreign key field.
+ #
+ # A lock_version field is also accepted if your model uses Optimistic Locking. If your table uses Single Table inheritance,
+ # then that field is reflected in the versioned model as 'versioned_type' by default.
+ #
+ # Acts_as_versioned comes prepared with the ActiveRecord::Acts::Versioned::ActMethods::ClassMethods#create_versioned_table
+ # method, perfect for a migration. It will also create the version column if the main model does not already have it.
+ #
+ # class AddVersions < ActiveRecord::Migration
+ # def self.up
+ # # create_versioned_table takes the same options hash
+ # # that create_table does
+ # Post.create_versioned_table
+ # end
+ #
+ # def self.down
+ # Post.drop_versioned_table
+ # end
+ # end
+ #
+ # == Changing What Fields Are Versioned
+ #
+ # By default, acts_as_versioned will version all but these fields:
+ #
+ # [self.primary_key, inheritance_column, 'version', 'lock_version', versioned_inheritance_column]
+ #
+ # You can add or change those by modifying #non_versioned_columns. Note that this takes strings and not symbols.
+ #
+ # class Post < ActiveRecord::Base
+ # acts_as_versioned
+ # self.non_versioned_columns << 'comments_count'
+ # end
+ #
+ def acts_as_versioned(options = {}, &extension)
+ # don't allow multiple calls
+ return if self.included_modules.include?(ActiveRecord::Acts::Versioned::ActMethods)
+
+ send :include, ActiveRecord::Acts::Versioned::ActMethods
+
+ cattr_accessor :versioned_class_name, :versioned_foreign_key, :versioned_table_name, :versioned_inheritance_column,
+ :version_column, :max_version_limit, :track_changed_attributes, :version_condition, :version_sequence_name, :non_versioned_columns,
+ :version_association_options
+
+ # legacy
+ alias_method :non_versioned_fields, :non_versioned_columns
+ alias_method :non_versioned_fields=, :non_versioned_columns=
+
+ class << self
+ alias_method :non_versioned_fields, :non_versioned_columns
+ alias_method :non_versioned_fields=, :non_versioned_columns=
+ end
+
+ send :attr_accessor, :changed_attributes
+
+ self.versioned_class_name = options[:class_name] || "Version"
+ self.versioned_foreign_key = options[:foreign_key] || self.to_s.foreign_key
+ self.versioned_table_name = options[:table_name] || "#{table_name_prefix}#{base_class.name.demodulize.underscore}_versions#{table_name_suffix}"
+ self.versioned_inheritance_column = options[:inheritance_column] || "versioned_#{inheritance_column}"
+ self.version_column = options[:version_column] || 'version'
+ self.version_sequence_name = options[:sequence_name]
+ self.max_version_limit = options[:limit].to_i
+ self.version_condition = options[:if] || true
+ self.non_versioned_columns = [self.primary_key, inheritance_column, 'version', 'lock_version', versioned_inheritance_column]
+ self.version_association_options = {
+ :class_name => "#{self.to_s}::#{versioned_class_name}",
+ :foreign_key => "#{versioned_foreign_key}",
+ :order => 'version',
+ :dependent => :delete_all
+ }.merge(options[:association_options] || {})
+
+ if block_given?
+ extension_module_name = "#{versioned_class_name}Extension"
+ silence_warnings do
+ self.const_set(extension_module_name, Module.new(&extension))
+ end
+
+ options[:extend] = self.const_get(extension_module_name)
+ end
+
+ class_eval do
+ has_many :versions, version_association_options
+ before_save :set_new_version
+ after_create :save_version_on_create
+ after_update :save_version
+ after_save :clear_old_versions
+ after_save :clear_changed_attributes
+
+ unless options[:if_changed].nil?
+ self.track_changed_attributes = true
+ options[:if_changed] = [options[:if_changed]] unless options[:if_changed].is_a?(Array)
+ options[:if_changed].each do |attr_name|
+ define_method("#{attr_name}=") do |value|
+ write_changed_attribute attr_name, value
+ end
+ end
+ end
+
+ include options[:extend] if options[:extend].is_a?(Module)
+ end
+
+ # create the dynamic versioned model
+ const_set(versioned_class_name, Class.new(ActiveRecord::Base)).class_eval do
+ def self.reloadable? ; false ; end
+ end
+
+ versioned_class.set_table_name versioned_table_name
+ versioned_class.belongs_to self.to_s.demodulize.underscore.to_sym,
+ :class_name => "::#{self.to_s}",
+ :foreign_key => versioned_foreign_key
+ versioned_class.send :include, options[:extend] if options[:extend].is_a?(Module)
+ versioned_class.set_sequence_name version_sequence_name if version_sequence_name
+ end
+ end
+
+ module ActMethods
+ def self.included(base) # :nodoc:
+ base.extend ClassMethods
+ end
+
+ # Saves a version of the model if applicable
+ def save_version
+ save_version_on_create if save_version?
+ end
+
+ # Saves a version of the model in the versioned table. This is called in the after_save callback by default
+ def save_version_on_create
+ rev = self.class.versioned_class.new
+ self.clone_versioned_model(self, rev)
+ rev.version = send(self.class.version_column)
+ rev.send("#{self.class.versioned_foreign_key}=", self.id)
+ rev.save
+ end
+
+ # Clears old revisions if a limit is set with the :limit option in acts_as_versioned .
+ # Override this method to set your own criteria for clearing old versions.
+ def clear_old_versions
+ return if self.class.max_version_limit == 0
+ excess_baggage = send(self.class.version_column).to_i - self.class.max_version_limit
+ if excess_baggage > 0
+ sql = "DELETE FROM #{self.class.versioned_table_name} WHERE version <= #{excess_baggage} AND #{self.class.versioned_foreign_key} = #{self.id}"
+ self.class.versioned_class.connection.execute sql
+ end
+ end
+
+ # Finds a specific version of this model.
+ def find_version(version)
+ return version if version.is_a?(self.class.versioned_class)
+ return nil if version.is_a?(ActiveRecord::Base)
+ find_versions(:conditions => ['version = ?', version], :limit => 1).first
+ end
+
+ # Finds versions of this model. Takes an options hash like find
+ def find_versions(options = {})
+ versions.find(:all, options)
+ end
+
+ # Reverts a model to a given version. Takes either a version number or an instance of the versioned model
+ def revert_to(version)
+ if version.is_a?(self.class.versioned_class)
+ return false unless version.send(self.class.versioned_foreign_key) == self.id and !version.new_record?
+ else
+ return false unless version = find_version(version)
+ end
+ self.clone_versioned_model(version, self)
+ self.send("#{self.class.version_column}=", version.version)
+ true
+ end
+
+ # Reverts a model to a given version and saves the model.
+ # Takes either a version number or an instance of the versioned model
+ def revert_to!(version)
+ revert_to(version) ? save_without_revision : false
+ end
+
+ # Temporarily turns off Optimistic Locking while saving. Used when reverting so that a new version is not created.
+ def save_without_revision
+ save_without_revision!
+ true
+ rescue
+ false
+ end
+
+ def save_without_revision!
+ without_locking do
+ without_revision do
+ save!
+ end
+ end
+ end
+
+ # Returns an array of attribute keys that are versioned. See non_versioned_columns
+ def versioned_attributes
+ self.attributes.keys.select { |k| !self.class.non_versioned_columns.include?(k) }
+ end
+
+ # If called with no parameters, gets whether the current model has changed and needs to be versioned.
+ # If called with a single parameter, gets whether the parameter has changed.
+ def changed?(attr_name = nil)
+ attr_name.nil? ?
+ (!self.class.track_changed_attributes || (changed_attributes && changed_attributes.length > 0)) :
+ (changed_attributes && changed_attributes.include?(attr_name.to_s))
+ end
+
+ # keep old dirty? method
+ alias_method :dirty?, :changed?
+
+ # Clones a model. Used when saving a new version or reverting a model's version.
+ def clone_versioned_model(orig_model, new_model)
+ self.versioned_attributes.each do |key|
+ new_model.send("#{key}=", orig_model.attributes[key]) if orig_model.has_attribute?(key)
+ end
+
+ if orig_model.is_a?(self.class.versioned_class)
+ new_model[new_model.class.inheritance_column] = orig_model[self.class.versioned_inheritance_column]
+ elsif new_model.is_a?(self.class.versioned_class)
+ new_model[self.class.versioned_inheritance_column] = orig_model[orig_model.class.inheritance_column]
+ end
+ end
+
+ # Checks whether a new version shall be saved or not. Calls version_condition_met? and changed? .
+ def save_version?
+ version_condition_met? && changed?
+ end
+
+ # Checks condition set in the :if option to check whether a revision should be created or not. Override this for
+ # custom version condition checking.
+ def version_condition_met?
+ case
+ when version_condition.is_a?(Symbol)
+ send(version_condition)
+ when version_condition.respond_to?(:call) && (version_condition.arity == 1 || version_condition.arity == -1)
+ version_condition.call(self)
+ else
+ version_condition
+ end
+ end
+
+ # Executes the block with the versioning callbacks disabled.
+ #
+ # @foo.without_revision do
+ # @foo.save
+ # end
+ #
+ def without_revision(&block)
+ self.class.without_revision(&block)
+ end
+
+ # Turns off optimistic locking for the duration of the block
+ #
+ # @foo.without_locking do
+ # @foo.save
+ # end
+ #
+ def without_locking(&block)
+ self.class.without_locking(&block)
+ end
+
+ def empty_callback() end #:nodoc:
+
+ protected
+ # sets the new version before saving, unless you're using optimistic locking. In that case, let it take care of the version.
+ def set_new_version
+ self.send("#{self.class.version_column}=", self.next_version) if new_record? || (!locking_enabled? && save_version?)
+ end
+
+ # Gets the next available version for the current record, or 1 for a new record
+ def next_version
+ return 1 if new_record?
+ (versions.calculate(:max, :version) || 0) + 1
+ end
+
+ # clears current changed attributes. Called after save.
+ def clear_changed_attributes
+ self.changed_attributes = []
+ end
+
+ def write_changed_attribute(attr_name, attr_value)
+ # Convert to db type for comparison. Avoids failing Float<=>String comparisons.
+ attr_value_for_db = self.class.columns_hash[attr_name.to_s].type_cast(attr_value)
+ (self.changed_attributes ||= []) << attr_name.to_s unless self.changed?(attr_name) || self.send(attr_name) == attr_value_for_db
+ write_attribute(attr_name, attr_value_for_db)
+ end
+
+ private
+ CALLBACKS.each do |attr_name|
+ alias_method "orig_#{attr_name}".to_sym, attr_name
+ end
+
+ module ClassMethods
+ # Finds a specific version of a specific row of this model
+ def find_version(id, version)
+ find_versions(id,
+ :conditions => ["#{versioned_foreign_key} = ? AND version = ?", id, version],
+ :limit => 1).first
+ end
+
+ # Finds versions of a specific model. Takes an options hash like find
+ def find_versions(id, options = {})
+ versioned_class.find :all, {
+ :conditions => ["#{versioned_foreign_key} = ?", id],
+ :order => 'version' }.merge(options)
+ end
+
+ # Returns an array of columns that are versioned. See non_versioned_columns
+ def versioned_columns
+ self.columns.select { |c| !non_versioned_columns.include?(c.name) }
+ end
+
+ # Returns an instance of the dynamic versioned model
+ def versioned_class
+ const_get versioned_class_name
+ end
+
+ # Rake migration task to create the versioned table using options passed to acts_as_versioned
+ def create_versioned_table(create_table_options = {})
+ # create version column in main table if it does not exist
+ if !self.content_columns.find { |c| %w(version lock_version).include? c.name }
+ self.connection.add_column table_name, :version, :integer
+ end
+
+ self.connection.create_table(versioned_table_name, create_table_options) do |t|
+ t.column versioned_foreign_key, :integer
+ t.column :version, :integer
+ end
+
+ updated_col = nil
+ self.versioned_columns.each do |col|
+ updated_col = col if !updated_col && %(updated_at updated_on).include?(col.name)
+ self.connection.add_column versioned_table_name, col.name, col.type,
+ :limit => col.limit,
+ :default => col.default
+ end
+
+ if type_col = self.columns_hash[inheritance_column]
+ self.connection.add_column versioned_table_name, versioned_inheritance_column, type_col.type,
+ :limit => type_col.limit,
+ :default => type_col.default
+ end
+
+ if updated_col.nil?
+ self.connection.add_column versioned_table_name, :updated_at, :timestamp
+ end
+ end
+
+ # Rake migration task to drop the versioned table
+ def drop_versioned_table
+ self.connection.drop_table versioned_table_name
+ end
+
+ # Executes the block with the versioning callbacks disabled.
+ #
+ # Foo.without_revision do
+ # @foo.save
+ # end
+ #
+ def without_revision(&block)
+ class_eval do
+ CALLBACKS.each do |attr_name|
+ alias_method attr_name, :empty_callback
+ end
+ end
+ result = block.call
+ class_eval do
+ CALLBACKS.each do |attr_name|
+ alias_method attr_name, "orig_#{attr_name}".to_sym
+ end
+ end
+ result
+ end
+
+ # Turns off optimistic locking for the duration of the block
+ #
+ # Foo.without_locking do
+ # @foo.save
+ # end
+ #
+ def without_locking(&block)
+ current = ActiveRecord::Base.lock_optimistically
+ ActiveRecord::Base.lock_optimistically = false if current
+ result = block.call
+ ActiveRecord::Base.lock_optimistically = true if current
+ result
+ end
+ end
+ end
+ end
+ end
+end
+
+ActiveRecord::Base.send :include, ActiveRecord::Acts::Versioned
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/abstract_unit.rb b/rest_sys/vendor/plugins/acts_as_versioned/test/abstract_unit.rb
new file mode 100644
index 000000000..1740db8dc
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/abstract_unit.rb
@@ -0,0 +1,40 @@
+$:.unshift(File.dirname(__FILE__) + '/../lib')
+
+require 'test/unit'
+require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
+require 'active_record/fixtures'
+
+config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
+ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
+ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite'])
+
+load(File.dirname(__FILE__) + "/schema.rb")
+
+# set up custom sequence on widget_versions for DBs that support sequences
+if ENV['DB'] == 'postgresql'
+ ActiveRecord::Base.connection.execute "DROP SEQUENCE widgets_seq;" rescue nil
+ ActiveRecord::Base.connection.remove_column :widget_versions, :id
+ ActiveRecord::Base.connection.execute "CREATE SEQUENCE widgets_seq START 101;"
+ ActiveRecord::Base.connection.execute "ALTER TABLE widget_versions ADD COLUMN id INTEGER PRIMARY KEY DEFAULT nextval('widgets_seq');"
+end
+
+Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
+$LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
+
+class Test::Unit::TestCase #:nodoc:
+ def create_fixtures(*table_names)
+ if block_given?
+ Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
+ else
+ Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
+ end
+ end
+
+ # Turn off transactional fixtures if you're working with MyISAM tables in MySQL
+ self.use_transactional_fixtures = true
+
+ # Instantiated fixtures are slow, but give you @david where you otherwise would need people(:david)
+ self.use_instantiated_fixtures = false
+
+ # Add more helper methods to be used by all tests here...
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/database.yml b/rest_sys/vendor/plugins/acts_as_versioned/test/database.yml
new file mode 100644
index 000000000..506e6bd37
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/database.yml
@@ -0,0 +1,18 @@
+sqlite:
+ :adapter: sqlite
+ :dbfile: acts_as_versioned_plugin.sqlite.db
+sqlite3:
+ :adapter: sqlite3
+ :dbfile: acts_as_versioned_plugin.sqlite3.db
+postgresql:
+ :adapter: postgresql
+ :username: postgres
+ :password: postgres
+ :database: acts_as_versioned_plugin_test
+ :min_messages: ERROR
+mysql:
+ :adapter: mysql
+ :host: localhost
+ :username: rails
+ :password:
+ :database: acts_as_versioned_plugin_test
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/authors.yml b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/authors.yml
new file mode 100644
index 000000000..bd7a5aed6
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/authors.yml
@@ -0,0 +1,6 @@
+caged:
+ id: 1
+ name: caged
+mly:
+ id: 2
+ name: mly
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/landmark.rb b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/landmark.rb
new file mode 100644
index 000000000..cb9b93057
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/landmark.rb
@@ -0,0 +1,3 @@
+class Landmark < ActiveRecord::Base
+ acts_as_versioned :if_changed => [ :name, :longitude, :latitude ]
+end
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/landmark_versions.yml b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/landmark_versions.yml
new file mode 100644
index 000000000..2dbd54ed2
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/landmark_versions.yml
@@ -0,0 +1,7 @@
+washington:
+ id: 1
+ landmark_id: 1
+ version: 1
+ name: Washington, D.C.
+ latitude: 38.895
+ longitude: -77.036667
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/landmarks.yml b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/landmarks.yml
new file mode 100644
index 000000000..46d96176a
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/landmarks.yml
@@ -0,0 +1,6 @@
+washington:
+ id: 1
+ name: Washington, D.C.
+ latitude: 38.895
+ longitude: -77.036667
+ version: 1
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/locked_pages.yml b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/locked_pages.yml
new file mode 100644
index 000000000..318e776cb
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/locked_pages.yml
@@ -0,0 +1,10 @@
+welcome:
+ id: 1
+ title: Welcome to the weblog
+ lock_version: 24
+ type: LockedPage
+thinking:
+ id: 2
+ title: So I was thinking
+ lock_version: 24
+ type: SpecialLockedPage
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/locked_pages_revisions.yml b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/locked_pages_revisions.yml
new file mode 100644
index 000000000..5c978e629
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/locked_pages_revisions.yml
@@ -0,0 +1,27 @@
+welcome_1:
+ id: 1
+ page_id: 1
+ title: Welcome to the weblg
+ version: 23
+ version_type: LockedPage
+
+welcome_2:
+ id: 2
+ page_id: 1
+ title: Welcome to the weblog
+ version: 24
+ version_type: LockedPage
+
+thinking_1:
+ id: 3
+ page_id: 2
+ title: So I was thinking!!!
+ version: 23
+ version_type: SpecialLockedPage
+
+thinking_2:
+ id: 4
+ page_id: 2
+ title: So I was thinking
+ version: 24
+ version_type: SpecialLockedPage
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/migrations/1_add_versioned_tables.rb b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/migrations/1_add_versioned_tables.rb
new file mode 100644
index 000000000..9512b5e82
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/migrations/1_add_versioned_tables.rb
@@ -0,0 +1,13 @@
+class AddVersionedTables < ActiveRecord::Migration
+ def self.up
+ create_table("things") do |t|
+ t.column :title, :text
+ end
+ Thing.create_versioned_table
+ end
+
+ def self.down
+ Thing.drop_versioned_table
+ drop_table "things" rescue nil
+ end
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/page.rb b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/page.rb
new file mode 100644
index 000000000..f133e351a
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/page.rb
@@ -0,0 +1,43 @@
+class Page < ActiveRecord::Base
+ belongs_to :author
+ has_many :authors, :through => :versions, :order => 'name'
+ belongs_to :revisor, :class_name => 'Author'
+ has_many :revisors, :class_name => 'Author', :through => :versions, :order => 'name'
+ acts_as_versioned :if => :feeling_good? do
+ def self.included(base)
+ base.cattr_accessor :feeling_good
+ base.feeling_good = true
+ base.belongs_to :author
+ base.belongs_to :revisor, :class_name => 'Author'
+ end
+
+ def feeling_good?
+ @@feeling_good == true
+ end
+ end
+end
+
+module LockedPageExtension
+ def hello_world
+ 'hello_world'
+ end
+end
+
+class LockedPage < ActiveRecord::Base
+ acts_as_versioned \
+ :inheritance_column => :version_type,
+ :foreign_key => :page_id,
+ :table_name => :locked_pages_revisions,
+ :class_name => 'LockedPageRevision',
+ :version_column => :lock_version,
+ :limit => 2,
+ :if_changed => :title,
+ :extend => LockedPageExtension
+end
+
+class SpecialLockedPage < LockedPage
+end
+
+class Author < ActiveRecord::Base
+ has_many :pages
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/page_versions.yml b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/page_versions.yml
new file mode 100644
index 000000000..ef565fa4f
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/page_versions.yml
@@ -0,0 +1,16 @@
+welcome_2:
+ id: 1
+ page_id: 1
+ title: Welcome to the weblog
+ body: Such a lovely day
+ version: 24
+ author_id: 1
+ revisor_id: 1
+welcome_1:
+ id: 2
+ page_id: 1
+ title: Welcome to the weblg
+ body: Such a lovely day
+ version: 23
+ author_id: 2
+ revisor_id: 2
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/pages.yml b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/pages.yml
new file mode 100644
index 000000000..07ac51f97
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/pages.yml
@@ -0,0 +1,7 @@
+welcome:
+ id: 1
+ title: Welcome to the weblog
+ body: Such a lovely day
+ version: 24
+ author_id: 1
+ revisor_id: 1
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/widget.rb b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/widget.rb
new file mode 100644
index 000000000..3c38f2fcf
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/fixtures/widget.rb
@@ -0,0 +1,6 @@
+class Widget < ActiveRecord::Base
+ acts_as_versioned :sequence_name => 'widgets_seq', :association_options => {
+ :dependent => nil, :order => 'version desc'
+ }
+ non_versioned_columns << 'foo'
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/migration_test.rb b/rest_sys/vendor/plugins/acts_as_versioned/test/migration_test.rb
new file mode 100644
index 000000000..d85e95883
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/migration_test.rb
@@ -0,0 +1,32 @@
+require File.join(File.dirname(__FILE__), 'abstract_unit')
+
+if ActiveRecord::Base.connection.supports_migrations?
+ class Thing < ActiveRecord::Base
+ attr_accessor :version
+ acts_as_versioned
+ end
+
+ class MigrationTest < Test::Unit::TestCase
+ self.use_transactional_fixtures = false
+ def teardown
+ ActiveRecord::Base.connection.initialize_schema_information
+ ActiveRecord::Base.connection.update "UPDATE schema_info SET version = 0"
+
+ Thing.connection.drop_table "things" rescue nil
+ Thing.connection.drop_table "thing_versions" rescue nil
+ Thing.reset_column_information
+ end
+
+ def test_versioned_migration
+ assert_raises(ActiveRecord::StatementInvalid) { Thing.create :title => 'blah blah' }
+ # take 'er up
+ ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/')
+ t = Thing.create :title => 'blah blah'
+ assert_equal 1, t.versions.size
+
+ # now lets take 'er back down
+ ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/fixtures/migrations/')
+ assert_raises(ActiveRecord::StatementInvalid) { Thing.create :title => 'blah blah' }
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/schema.rb b/rest_sys/vendor/plugins/acts_as_versioned/test/schema.rb
new file mode 100644
index 000000000..7d5153d07
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/schema.rb
@@ -0,0 +1,68 @@
+ActiveRecord::Schema.define(:version => 0) do
+ create_table :pages, :force => true do |t|
+ t.column :version, :integer
+ t.column :title, :string, :limit => 255
+ t.column :body, :text
+ t.column :updated_on, :datetime
+ t.column :author_id, :integer
+ t.column :revisor_id, :integer
+ end
+
+ create_table :page_versions, :force => true do |t|
+ t.column :page_id, :integer
+ t.column :version, :integer
+ t.column :title, :string, :limit => 255
+ t.column :body, :text
+ t.column :updated_on, :datetime
+ t.column :author_id, :integer
+ t.column :revisor_id, :integer
+ end
+
+ create_table :authors, :force => true do |t|
+ t.column :page_id, :integer
+ t.column :name, :string
+ end
+
+ create_table :locked_pages, :force => true do |t|
+ t.column :lock_version, :integer
+ t.column :title, :string, :limit => 255
+ t.column :type, :string, :limit => 255
+ end
+
+ create_table :locked_pages_revisions, :force => true do |t|
+ t.column :page_id, :integer
+ t.column :version, :integer
+ t.column :title, :string, :limit => 255
+ t.column :version_type, :string, :limit => 255
+ t.column :updated_at, :datetime
+ end
+
+ create_table :widgets, :force => true do |t|
+ t.column :name, :string, :limit => 50
+ t.column :foo, :string
+ t.column :version, :integer
+ t.column :updated_at, :datetime
+ end
+
+ create_table :widget_versions, :force => true do |t|
+ t.column :widget_id, :integer
+ t.column :name, :string, :limit => 50
+ t.column :version, :integer
+ t.column :updated_at, :datetime
+ end
+
+ create_table :landmarks, :force => true do |t|
+ t.column :name, :string
+ t.column :latitude, :float
+ t.column :longitude, :float
+ t.column :version, :integer
+ end
+
+ create_table :landmark_versions, :force => true do |t|
+ t.column :landmark_id, :integer
+ t.column :name, :string
+ t.column :latitude, :float
+ t.column :longitude, :float
+ t.column :version, :integer
+ end
+end
diff --git a/rest_sys/vendor/plugins/acts_as_versioned/test/versioned_test.rb b/rest_sys/vendor/plugins/acts_as_versioned/test/versioned_test.rb
new file mode 100644
index 000000000..c1e1a4b98
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_versioned/test/versioned_test.rb
@@ -0,0 +1,313 @@
+require File.join(File.dirname(__FILE__), 'abstract_unit')
+require File.join(File.dirname(__FILE__), 'fixtures/page')
+require File.join(File.dirname(__FILE__), 'fixtures/widget')
+
+class VersionedTest < Test::Unit::TestCase
+ fixtures :pages, :page_versions, :locked_pages, :locked_pages_revisions, :authors, :landmarks, :landmark_versions
+
+ def test_saves_versioned_copy
+ p = Page.create :title => 'first title', :body => 'first body'
+ assert !p.new_record?
+ assert_equal 1, p.versions.size
+ assert_equal 1, p.version
+ assert_instance_of Page.versioned_class, p.versions.first
+ end
+
+ def test_saves_without_revision
+ p = pages(:welcome)
+ old_versions = p.versions.count
+
+ p.save_without_revision
+
+ p.without_revision do
+ p.update_attributes :title => 'changed'
+ end
+
+ assert_equal old_versions, p.versions.count
+ end
+
+ def test_rollback_with_version_number
+ p = pages(:welcome)
+ assert_equal 24, p.version
+ assert_equal 'Welcome to the weblog', p.title
+
+ assert p.revert_to!(p.versions.first.version), "Couldn't revert to 23"
+ assert_equal 23, p.version
+ assert_equal 'Welcome to the weblg', p.title
+ end
+
+ def test_versioned_class_name
+ assert_equal 'Version', Page.versioned_class_name
+ assert_equal 'LockedPageRevision', LockedPage.versioned_class_name
+ end
+
+ def test_versioned_class
+ assert_equal Page::Version, Page.versioned_class
+ assert_equal LockedPage::LockedPageRevision, LockedPage.versioned_class
+ end
+
+ def test_special_methods
+ assert_nothing_raised { pages(:welcome).feeling_good? }
+ assert_nothing_raised { pages(:welcome).versions.first.feeling_good? }
+ assert_nothing_raised { locked_pages(:welcome).hello_world }
+ assert_nothing_raised { locked_pages(:welcome).versions.first.hello_world }
+ end
+
+ def test_rollback_with_version_class
+ p = pages(:welcome)
+ assert_equal 24, p.version
+ assert_equal 'Welcome to the weblog', p.title
+
+ assert p.revert_to!(p.versions.first), "Couldn't revert to 23"
+ assert_equal 23, p.version
+ assert_equal 'Welcome to the weblg', p.title
+ end
+
+ def test_rollback_fails_with_invalid_revision
+ p = locked_pages(:welcome)
+ assert !p.revert_to!(locked_pages(:thinking))
+ end
+
+ def test_saves_versioned_copy_with_options
+ p = LockedPage.create :title => 'first title'
+ assert !p.new_record?
+ assert_equal 1, p.versions.size
+ assert_instance_of LockedPage.versioned_class, p.versions.first
+ end
+
+ def test_rollback_with_version_number_with_options
+ p = locked_pages(:welcome)
+ assert_equal 'Welcome to the weblog', p.title
+ assert_equal 'LockedPage', p.versions.first.version_type
+
+ assert p.revert_to!(p.versions.first.version), "Couldn't revert to 23"
+ assert_equal 'Welcome to the weblg', p.title
+ assert_equal 'LockedPage', p.versions.first.version_type
+ end
+
+ def test_rollback_with_version_class_with_options
+ p = locked_pages(:welcome)
+ assert_equal 'Welcome to the weblog', p.title
+ assert_equal 'LockedPage', p.versions.first.version_type
+
+ assert p.revert_to!(p.versions.first), "Couldn't revert to 1"
+ assert_equal 'Welcome to the weblg', p.title
+ assert_equal 'LockedPage', p.versions.first.version_type
+ end
+
+ def test_saves_versioned_copy_with_sti
+ p = SpecialLockedPage.create :title => 'first title'
+ assert !p.new_record?
+ assert_equal 1, p.versions.size
+ assert_instance_of LockedPage.versioned_class, p.versions.first
+ assert_equal 'SpecialLockedPage', p.versions.first.version_type
+ end
+
+ def test_rollback_with_version_number_with_sti
+ p = locked_pages(:thinking)
+ assert_equal 'So I was thinking', p.title
+
+ assert p.revert_to!(p.versions.first.version), "Couldn't revert to 1"
+ assert_equal 'So I was thinking!!!', p.title
+ assert_equal 'SpecialLockedPage', p.versions.first.version_type
+ end
+
+ def test_lock_version_works_with_versioning
+ p = locked_pages(:thinking)
+ p2 = LockedPage.find(p.id)
+
+ p.title = 'fresh title'
+ p.save
+ assert_equal 2, p.versions.size # limit!
+
+ assert_raises(ActiveRecord::StaleObjectError) do
+ p2.title = 'stale title'
+ p2.save
+ end
+ end
+
+ def test_version_if_condition
+ p = Page.create :title => "title"
+ assert_equal 1, p.version
+
+ Page.feeling_good = false
+ p.save
+ assert_equal 1, p.version
+ Page.feeling_good = true
+ end
+
+ def test_version_if_condition2
+ # set new if condition
+ Page.class_eval do
+ def new_feeling_good() title[0..0] == 'a'; end
+ alias_method :old_feeling_good, :feeling_good?
+ alias_method :feeling_good?, :new_feeling_good
+ end
+
+ p = Page.create :title => "title"
+ assert_equal 1, p.version # version does not increment
+ assert_equal 1, p.versions(true).size
+
+ p.update_attributes(:title => 'new title')
+ assert_equal 1, p.version # version does not increment
+ assert_equal 1, p.versions(true).size
+
+ p.update_attributes(:title => 'a title')
+ assert_equal 2, p.version
+ assert_equal 2, p.versions(true).size
+
+ # reset original if condition
+ Page.class_eval { alias_method :feeling_good?, :old_feeling_good }
+ end
+
+ def test_version_if_condition_with_block
+ # set new if condition
+ old_condition = Page.version_condition
+ Page.version_condition = Proc.new { |page| page.title[0..0] == 'b' }
+
+ p = Page.create :title => "title"
+ assert_equal 1, p.version # version does not increment
+ assert_equal 1, p.versions(true).size
+
+ p.update_attributes(:title => 'a title')
+ assert_equal 1, p.version # version does not increment
+ assert_equal 1, p.versions(true).size
+
+ p.update_attributes(:title => 'b title')
+ assert_equal 2, p.version
+ assert_equal 2, p.versions(true).size
+
+ # reset original if condition
+ Page.version_condition = old_condition
+ end
+
+ def test_version_no_limit
+ p = Page.create :title => "title", :body => 'first body'
+ p.save
+ p.save
+ 5.times do |i|
+ assert_page_title p, i
+ end
+ end
+
+ def test_version_max_limit
+ p = LockedPage.create :title => "title"
+ p.update_attributes(:title => "title1")
+ p.update_attributes(:title => "title2")
+ 5.times do |i|
+ assert_page_title p, i, :lock_version
+ assert p.versions(true).size <= 2, "locked version can only store 2 versions"
+ end
+ end
+
+ def test_track_changed_attributes_default_value
+ assert !Page.track_changed_attributes
+ assert LockedPage.track_changed_attributes
+ assert SpecialLockedPage.track_changed_attributes
+ end
+
+ def test_version_order
+ assert_equal 23, pages(:welcome).versions.first.version
+ assert_equal 24, pages(:welcome).versions.last.version
+ assert_equal 23, pages(:welcome).find_versions.first.version
+ assert_equal 24, pages(:welcome).find_versions.last.version
+ end
+
+ def test_track_changed_attributes
+ p = LockedPage.create :title => "title"
+ assert_equal 1, p.lock_version
+ assert_equal 1, p.versions(true).size
+
+ p.title = 'title'
+ assert !p.save_version?
+ p.save
+ assert_equal 2, p.lock_version # still increments version because of optimistic locking
+ assert_equal 1, p.versions(true).size
+
+ p.title = 'updated title'
+ assert p.save_version?
+ p.save
+ assert_equal 3, p.lock_version
+ assert_equal 1, p.versions(true).size # version 1 deleted
+
+ p.title = 'updated title!'
+ assert p.save_version?
+ p.save
+ assert_equal 4, p.lock_version
+ assert_equal 2, p.versions(true).size # version 1 deleted
+ end
+
+ def assert_page_title(p, i, version_field = :version)
+ p.title = "title#{i}"
+ p.save
+ assert_equal "title#{i}", p.title
+ assert_equal (i+4), p.send(version_field)
+ end
+
+ def test_find_versions
+ assert_equal 2, locked_pages(:welcome).versions.size
+ assert_equal 1, locked_pages(:welcome).find_versions(:conditions => ['title LIKE ?', '%weblog%']).length
+ assert_equal 2, locked_pages(:welcome).find_versions(:conditions => ['title LIKE ?', '%web%']).length
+ assert_equal 0, locked_pages(:thinking).find_versions(:conditions => ['title LIKE ?', '%web%']).length
+ assert_equal 2, locked_pages(:welcome).find_versions.length
+ end
+
+ def test_with_sequence
+ assert_equal 'widgets_seq', Widget.versioned_class.sequence_name
+ Widget.create :name => 'new widget'
+ Widget.create :name => 'new widget'
+ Widget.create :name => 'new widget'
+ assert_equal 3, Widget.count
+ assert_equal 3, Widget.versioned_class.count
+ end
+
+ def test_has_many_through
+ assert_equal [authors(:caged), authors(:mly)], pages(:welcome).authors
+ end
+
+ def test_has_many_through_with_custom_association
+ assert_equal [authors(:caged), authors(:mly)], pages(:welcome).revisors
+ end
+
+ def test_referential_integrity
+ pages(:welcome).destroy
+ assert_equal 0, Page.count
+ assert_equal 0, Page::Version.count
+ end
+
+ def test_association_options
+ association = Page.reflect_on_association(:versions)
+ options = association.options
+ assert_equal :delete_all, options[:dependent]
+ assert_equal 'version', options[:order]
+
+ association = Widget.reflect_on_association(:versions)
+ options = association.options
+ assert_nil options[:dependent]
+ assert_equal 'version desc', options[:order]
+ assert_equal 'widget_id', options[:foreign_key]
+
+ widget = Widget.create :name => 'new widget'
+ assert_equal 1, Widget.count
+ assert_equal 1, Widget.versioned_class.count
+ widget.destroy
+ assert_equal 0, Widget.count
+ assert_equal 1, Widget.versioned_class.count
+ end
+
+ def test_versioned_records_should_belong_to_parent
+ page = pages(:welcome)
+ page_version = page.versions.last
+ assert_equal page, page_version.page
+ end
+
+ def test_unchanged_attributes
+ landmarks(:washington).attributes = landmarks(:washington).attributes
+ assert !landmarks(:washington).changed?
+ end
+
+ def test_unchanged_string_attributes
+ landmarks(:washington).attributes = landmarks(:washington).attributes.inject({}) { |params, (key, value)| params.update key => value.to_s }
+ assert !landmarks(:washington).changed?
+ end
+end
diff --git a/rest_sys/vendor/plugins/acts_as_watchable/init.rb b/rest_sys/vendor/plugins/acts_as_watchable/init.rb
new file mode 100644
index 000000000..f39cc7d18
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_watchable/init.rb
@@ -0,0 +1,3 @@
+# Include hook code here
+require File.dirname(__FILE__) + '/lib/acts_as_watchable'
+ActiveRecord::Base.send(:include, Redmine::Acts::Watchable)
diff --git a/rest_sys/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb b/rest_sys/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb
new file mode 100644
index 000000000..c789017e5
--- /dev/null
+++ b/rest_sys/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb
@@ -0,0 +1,53 @@
+# ActsAsWatchable
+module Redmine
+ module Acts
+ module Watchable
+ def self.included(base)
+ base.extend ClassMethods
+ end
+
+ module ClassMethods
+ def acts_as_watchable(options = {})
+ return if self.included_modules.include?(Redmine::Acts::Watchable::InstanceMethods)
+ send :include, Redmine::Acts::Watchable::InstanceMethods
+
+ class_eval do
+ has_many :watchers, :as => :watchable, :dependent => :delete_all
+ end
+ end
+ end
+
+ module InstanceMethods
+ def self.included(base)
+ base.extend ClassMethods
+ end
+
+ def add_watcher(user)
+ self.watchers << Watcher.new(:user => user)
+ end
+
+ def remove_watcher(user)
+ return nil unless user && user.is_a?(User)
+ Watcher.delete_all "watchable_type = '#{self.class}' AND watchable_id = #{self.id} AND user_id = #{user.id}"
+ end
+
+ def watched_by?(user)
+ !self.watchers.find(:first,
+ :conditions => ["#{Watcher.table_name}.user_id = ?", user.id]).nil?
+ end
+
+ def watcher_recipients
+ self.watchers.collect { |w| w.user.mail }
+ end
+
+ module ClassMethods
+ def watched_by(user)
+ find(:all,
+ :include => :watchers,
+ :conditions => ["#{Watcher.table_name}.user_id = ?", user.id])
+ end
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/classic_pagination/CHANGELOG b/rest_sys/vendor/plugins/classic_pagination/CHANGELOG
new file mode 100644
index 000000000..d7d11f129
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/CHANGELOG
@@ -0,0 +1,152 @@
+* Exported the changelog of Pagination code for historical reference.
+
+* Imported some patches from Rails Trac (others closed as "wontfix"):
+ #8176, #7325, #7028, #4113. Documentation is much cleaner now and there
+ are some new unobtrusive features!
+
+* Extracted Pagination from Rails trunk (r6795)
+
+#
+# ChangeLog for /trunk/actionpack/lib/action_controller/pagination.rb
+#
+# Generated by Trac 0.10.3
+# 05/20/07 23:48:02
+#
+
+09/03/06 23:28:54 david [4953]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Docs and deprecation
+
+08/07/06 12:40:14 bitsweat [4715]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Deprecate direct usage of @params. Update ActionView::Base for
+ instance var deprecation.
+
+06/21/06 02:16:11 rick [4476]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Fix indent in pagination documentation. Closes #4990. [Kevin Clark]
+
+04/25/06 17:42:48 marcel [4268]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Remove all remaining references to @params in the documentation.
+
+03/16/06 06:38:08 rick [3899]
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ trivial documentation patch for #pagination_links [Francois
+ Beausoleil] closes #4258
+
+02/20/06 03:15:22 david [3620]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/actionpack/test/activerecord/pagination_test.rb (modified)
+ * trunk/activerecord/CHANGELOG (modified)
+ * trunk/activerecord/lib/active_record/base.rb (modified)
+ * trunk/activerecord/test/base_test.rb (modified)
+ Added :count option to pagination that'll make it possible for the
+ ActiveRecord::Base.count call to using something else than * for the
+ count. Especially important for count queries using DISTINCT #3839
+ [skaes]. Added :select option to Base.count that'll allow you to
+ select something else than * to be counted on. Especially important
+ for count queries using DISTINCT (closes #3839) [skaes].
+
+02/09/06 09:17:40 nzkoz [3553]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/actionpack/test/active_record_unit.rb (added)
+ * trunk/actionpack/test/activerecord (added)
+ * trunk/actionpack/test/activerecord/active_record_assertions_test.rb (added)
+ * trunk/actionpack/test/activerecord/pagination_test.rb (added)
+ * trunk/actionpack/test/controller/active_record_assertions_test.rb (deleted)
+ * trunk/actionpack/test/fixtures/companies.yml (added)
+ * trunk/actionpack/test/fixtures/company.rb (added)
+ * trunk/actionpack/test/fixtures/db_definitions (added)
+ * trunk/actionpack/test/fixtures/db_definitions/sqlite.sql (added)
+ * trunk/actionpack/test/fixtures/developer.rb (added)
+ * trunk/actionpack/test/fixtures/developers_projects.yml (added)
+ * trunk/actionpack/test/fixtures/developers.yml (added)
+ * trunk/actionpack/test/fixtures/project.rb (added)
+ * trunk/actionpack/test/fixtures/projects.yml (added)
+ * trunk/actionpack/test/fixtures/replies.yml (added)
+ * trunk/actionpack/test/fixtures/reply.rb (added)
+ * trunk/actionpack/test/fixtures/topic.rb (added)
+ * trunk/actionpack/test/fixtures/topics.yml (added)
+ * Fix pagination problems when using include
+ * Introduce Unit Tests for pagination
+ * Allow count to work with :include by using count distinct.
+
+ [Kevin Clark & Jeremy Hopple]
+
+11/05/05 02:10:29 bitsweat [2878]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Update paginator docs. Closes #2744.
+
+10/16/05 15:42:03 minam [2649]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Update/clean up AP documentation (rdoc)
+
+08/31/05 00:13:10 ulysses [2078]
+ * trunk/actionpack/CHANGELOG (modified)
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Add option to specify the singular name used by pagination. Closes
+ #1960
+
+08/23/05 14:24:15 minam [2041]
+ * trunk/actionpack/CHANGELOG (modified)
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ Add support for :include with pagination (subject to existing
+ constraints for :include with :limit and :offset) #1478
+ [michael@schubert.cx]
+
+07/15/05 20:27:38 david [1839]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ More pagination speed #1334 [Stefan Kaes]
+
+07/14/05 08:02:01 david [1832]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ * trunk/actionpack/test/controller/addresses_render_test.rb (modified)
+ Made pagination faster #1334 [Stefan Kaes]
+
+04/13/05 05:40:22 david [1159]
+ * trunk/actionpack/CHANGELOG (modified)
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/activerecord/lib/active_record/base.rb (modified)
+ Fixed pagination to work with joins #1034 [scott@sigkill.org]
+
+04/02/05 09:11:17 david [1067]
+ * trunk/actionpack/CHANGELOG (modified)
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/actionpack/lib/action_controller/scaffolding.rb (modified)
+ * trunk/actionpack/lib/action_controller/templates/scaffolds/list.rhtml (modified)
+ * trunk/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb (modified)
+ * trunk/railties/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml (modified)
+ Added pagination for scaffolding (10 items per page) #964
+ [mortonda@dgrmm.net]
+
+03/31/05 14:46:11 david [1048]
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ Improved the message display on the exception handler pages #963
+ [Johan Sorensen]
+
+03/27/05 00:04:07 david [1017]
+ * trunk/actionpack/CHANGELOG (modified)
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ Fixed that pagination_helper would ignore :params #947 [Sebastian
+ Kanthak]
+
+03/22/05 13:09:44 david [976]
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ Fixed documentation and prepared for 0.11.0 release
+
+03/21/05 14:35:36 david [967]
+ * trunk/actionpack/lib/action_controller/pagination.rb (modified)
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
+ Tweaked the documentation
+
+03/20/05 23:12:05 david [949]
+ * trunk/actionpack/CHANGELOG (modified)
+ * trunk/actionpack/lib/action_controller.rb (modified)
+ * trunk/actionpack/lib/action_controller/pagination.rb (added)
+ * trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (added)
+ * trunk/activesupport/lib/active_support/core_ext/kernel.rb (added)
+ Added pagination support through both a controller and helper add-on
+ #817 [Sam Stephenson]
diff --git a/rest_sys/vendor/plugins/classic_pagination/README b/rest_sys/vendor/plugins/classic_pagination/README
new file mode 100644
index 000000000..e94904974
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/README
@@ -0,0 +1,18 @@
+Pagination
+==========
+
+To install:
+
+ script/plugin install svn://errtheblog.com/svn/plugins/classic_pagination
+
+This code was extracted from Rails trunk after the release 1.2.3.
+WARNING: this code is dead. It is unmaintained, untested and full of cruft.
+
+There is a much better pagination plugin called will_paginate.
+Install it like this and glance through the README:
+
+ script/plugin install svn://errtheblog.com/svn/plugins/will_paginate
+
+It doesn't have the same API, but is in fact much nicer. You can
+have both plugins installed until you change your controller/view code that
+handles pagination. Then, simply uninstall classic_pagination.
diff --git a/rest_sys/vendor/plugins/classic_pagination/Rakefile b/rest_sys/vendor/plugins/classic_pagination/Rakefile
new file mode 100644
index 000000000..c7e374b56
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/Rakefile
@@ -0,0 +1,22 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the classic_pagination plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the classic_pagination plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'Pagination'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
diff --git a/rest_sys/vendor/plugins/classic_pagination/init.rb b/rest_sys/vendor/plugins/classic_pagination/init.rb
new file mode 100644
index 000000000..25e552f2a
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/init.rb
@@ -0,0 +1,33 @@
+#--
+# Copyright (c) 2004-2006 David Heinemeier Hansson
+#
+# 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.
+#++
+
+require 'pagination'
+require 'pagination_helper'
+
+ActionController::Base.class_eval do
+ include ActionController::Pagination
+end
+
+ActionView::Base.class_eval do
+ include ActionView::Helpers::PaginationHelper
+end
diff --git a/rest_sys/vendor/plugins/classic_pagination/install.rb b/rest_sys/vendor/plugins/classic_pagination/install.rb
new file mode 100644
index 000000000..adf746f8b
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/install.rb
@@ -0,0 +1 @@
+puts "\n\n" + File.read(File.dirname(__FILE__) + '/README')
diff --git a/rest_sys/vendor/plugins/classic_pagination/lib/pagination.rb b/rest_sys/vendor/plugins/classic_pagination/lib/pagination.rb
new file mode 100644
index 000000000..b6e9cf4bc
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/lib/pagination.rb
@@ -0,0 +1,405 @@
+module ActionController
+ # === Action Pack pagination for Active Record collections
+ #
+ # The Pagination module aids in the process of paging large collections of
+ # Active Record objects. It offers macro-style automatic fetching of your
+ # model for multiple views, or explicit fetching for single actions. And if
+ # the magic isn't flexible enough for your needs, you can create your own
+ # paginators with a minimal amount of code.
+ #
+ # The Pagination module can handle as much or as little as you wish. In the
+ # controller, have it automatically query your model for pagination; or,
+ # if you prefer, create Paginator objects yourself.
+ #
+ # Pagination is included automatically for all controllers.
+ #
+ # For help rendering pagination links, see
+ # ActionView::Helpers::PaginationHelper.
+ #
+ # ==== Automatic pagination for every action in a controller
+ #
+ # class PersonController < ApplicationController
+ # model :person
+ #
+ # paginate :people, :order => 'last_name, first_name',
+ # :per_page => 20
+ #
+ # # ...
+ # end
+ #
+ # Each action in this controller now has access to a @people
+ # instance variable, which is an ordered collection of model objects for the
+ # current page (at most 20, sorted by last name and first name), and a
+ # @person_pages Paginator instance. The current page is determined
+ # by the params[:page] variable.
+ #
+ # ==== Pagination for a single action
+ #
+ # def list
+ # @person_pages, @people =
+ # paginate :people, :order => 'last_name, first_name'
+ # end
+ #
+ # Like the previous example, but explicitly creates @person_pages
+ # and @people for a single action, and uses the default of 10 items
+ # per page.
+ #
+ # ==== Custom/"classic" pagination
+ #
+ # def list
+ # @person_pages = Paginator.new self, Person.count, 10, params[:page]
+ # @people = Person.find :all, :order => 'last_name, first_name',
+ # :limit => @person_pages.items_per_page,
+ # :offset => @person_pages.current.offset
+ # end
+ #
+ # Explicitly creates the paginator from the previous example and uses
+ # Paginator#to_sql to retrieve @people from the model.
+ #
+ module Pagination
+ unless const_defined?(:OPTIONS)
+ # A hash holding options for controllers using macro-style pagination
+ OPTIONS = Hash.new
+
+ # The default options for pagination
+ DEFAULT_OPTIONS = {
+ :class_name => nil,
+ :singular_name => nil,
+ :per_page => 10,
+ :conditions => nil,
+ :order_by => nil,
+ :order => nil,
+ :join => nil,
+ :joins => nil,
+ :count => nil,
+ :include => nil,
+ :select => nil,
+ :group => nil,
+ :parameter => 'page'
+ }
+ else
+ DEFAULT_OPTIONS[:group] = nil
+ end
+
+ def self.included(base) #:nodoc:
+ super
+ base.extend(ClassMethods)
+ end
+
+ def self.validate_options!(collection_id, options, in_action) #:nodoc:
+ options.merge!(DEFAULT_OPTIONS) {|key, old, new| old}
+
+ valid_options = DEFAULT_OPTIONS.keys
+ valid_options << :actions unless in_action
+
+ unknown_option_keys = options.keys - valid_options
+ raise ActionController::ActionControllerError,
+ "Unknown options: #{unknown_option_keys.join(', ')}" unless
+ unknown_option_keys.empty?
+
+ options[:singular_name] ||= Inflector.singularize(collection_id.to_s)
+ options[:class_name] ||= Inflector.camelize(options[:singular_name])
+ end
+
+ # Returns a paginator and a collection of Active Record model instances
+ # for the paginator's current page. This is designed to be used in a
+ # single action; to automatically paginate multiple actions, consider
+ # ClassMethods#paginate.
+ #
+ # +options+ are:
+ # :singular_name :: the singular name to use, if it can't be inferred by singularizing the collection name
+ # :class_name :: the class name to use, if it can't be inferred by
+ # camelizing the singular name
+ # :per_page :: the maximum number of items to include in a
+ # single page. Defaults to 10
+ # :conditions :: optional conditions passed to Model.find(:all, *params) and
+ # Model.count
+ # :order :: optional order parameter passed to Model.find(:all, *params)
+ # :order_by :: (deprecated, used :order) optional order parameter passed to Model.find(:all, *params)
+ # :joins :: optional joins parameter passed to Model.find(:all, *params)
+ # and Model.count
+ # :join :: (deprecated, used :joins or :include) optional join parameter passed to Model.find(:all, *params)
+ # and Model.count
+ # :include :: optional eager loading parameter passed to Model.find(:all, *params)
+ # and Model.count
+ # :select :: :select parameter passed to Model.find(:all, *params)
+ #
+ # :count :: parameter passed as :select option to Model.count(*params)
+ #
+ # :group :: :group parameter passed to Model.find(:all, *params). It forces the use of DISTINCT instead of plain COUNT to come up with the total number of records
+ #
+ def paginate(collection_id, options={})
+ Pagination.validate_options!(collection_id, options, true)
+ paginator_and_collection_for(collection_id, options)
+ end
+
+ # These methods become class methods on any controller
+ module ClassMethods
+ # Creates a +before_filter+ which automatically paginates an Active
+ # Record model for all actions in a controller (or certain actions if
+ # specified with the :actions option).
+ #
+ # +options+ are the same as PaginationHelper#paginate, with the addition
+ # of:
+ # :actions :: an array of actions for which the pagination is
+ # active. Defaults to +nil+ (i.e., every action)
+ def paginate(collection_id, options={})
+ Pagination.validate_options!(collection_id, options, false)
+ module_eval do
+ before_filter :create_paginators_and_retrieve_collections
+ OPTIONS[self] ||= Hash.new
+ OPTIONS[self][collection_id] = options
+ end
+ end
+ end
+
+ def create_paginators_and_retrieve_collections #:nodoc:
+ Pagination::OPTIONS[self.class].each do |collection_id, options|
+ next unless options[:actions].include? action_name if
+ options[:actions]
+
+ paginator, collection =
+ paginator_and_collection_for(collection_id, options)
+
+ paginator_name = "@#{options[:singular_name]}_pages"
+ self.instance_variable_set(paginator_name, paginator)
+
+ collection_name = "@#{collection_id.to_s}"
+ self.instance_variable_set(collection_name, collection)
+ end
+ end
+
+ # Returns the total number of items in the collection to be paginated for
+ # the +model+ and given +conditions+. Override this method to implement a
+ # custom counter.
+ def count_collection_for_pagination(model, options)
+ model.count(:conditions => options[:conditions],
+ :joins => options[:join] || options[:joins],
+ :include => options[:include],
+ :select => (options[:group] ? "DISTINCT #{options[:group]}" : options[:count]))
+ end
+
+ # Returns a collection of items for the given +model+ and +options[conditions]+,
+ # ordered by +options[order]+, for the current page in the given +paginator+.
+ # Override this method to implement a custom finder.
+ def find_collection_for_pagination(model, options, paginator)
+ model.find(:all, :conditions => options[:conditions],
+ :order => options[:order_by] || options[:order],
+ :joins => options[:join] || options[:joins], :include => options[:include],
+ :select => options[:select], :limit => options[:per_page],
+ :group => options[:group], :offset => paginator.current.offset)
+ end
+
+ protected :create_paginators_and_retrieve_collections,
+ :count_collection_for_pagination,
+ :find_collection_for_pagination
+
+ def paginator_and_collection_for(collection_id, options) #:nodoc:
+ klass = options[:class_name].constantize
+ page = params[options[:parameter]]
+ count = count_collection_for_pagination(klass, options)
+ paginator = Paginator.new(self, count, options[:per_page], page)
+ collection = find_collection_for_pagination(klass, options, paginator)
+
+ return paginator, collection
+ end
+
+ private :paginator_and_collection_for
+
+ # A class representing a paginator for an Active Record collection.
+ class Paginator
+ include Enumerable
+
+ # Creates a new Paginator on the given +controller+ for a set of items
+ # of size +item_count+ and having +items_per_page+ items per page.
+ # Raises ArgumentError if items_per_page is out of bounds (i.e., less
+ # than or equal to zero). The page CGI parameter for links defaults to
+ # "page" and can be overridden with +page_parameter+.
+ def initialize(controller, item_count, items_per_page, current_page=1)
+ raise ArgumentError, 'must have at least one item per page' if
+ items_per_page <= 0
+
+ @controller = controller
+ @item_count = item_count || 0
+ @items_per_page = items_per_page
+ @pages = {}
+
+ self.current_page = current_page
+ end
+ attr_reader :controller, :item_count, :items_per_page
+
+ # Sets the current page number of this paginator. If +page+ is a Page
+ # object, its +number+ attribute is used as the value; if the page does
+ # not belong to this Paginator, an ArgumentError is raised.
+ def current_page=(page)
+ if page.is_a? Page
+ raise ArgumentError, 'Page/Paginator mismatch' unless
+ page.paginator == self
+ end
+ page = page.to_i
+ @current_page_number = has_page_number?(page) ? page : 1
+ end
+
+ # Returns a Page object representing this paginator's current page.
+ def current_page
+ @current_page ||= self[@current_page_number]
+ end
+ alias current :current_page
+
+ # Returns a new Page representing the first page in this paginator.
+ def first_page
+ @first_page ||= self[1]
+ end
+ alias first :first_page
+
+ # Returns a new Page representing the last page in this paginator.
+ def last_page
+ @last_page ||= self[page_count]
+ end
+ alias last :last_page
+
+ # Returns the number of pages in this paginator.
+ def page_count
+ @page_count ||= @item_count.zero? ? 1 :
+ (q,r=@item_count.divmod(@items_per_page); r==0? q : q+1)
+ end
+
+ alias length :page_count
+
+ # Returns true if this paginator contains the page of index +number+.
+ def has_page_number?(number)
+ number >= 1 and number <= page_count
+ end
+
+ # Returns a new Page representing the page with the given index
+ # +number+.
+ def [](number)
+ @pages[number] ||= Page.new(self, number)
+ end
+
+ # Successively yields all the paginator's pages to the given block.
+ def each(&block)
+ page_count.times do |n|
+ yield self[n+1]
+ end
+ end
+
+ # A class representing a single page in a paginator.
+ class Page
+ include Comparable
+
+ # Creates a new Page for the given +paginator+ with the index
+ # +number+. If +number+ is not in the range of valid page numbers or
+ # is not a number at all, it defaults to 1.
+ def initialize(paginator, number)
+ @paginator = paginator
+ @number = number.to_i
+ @number = 1 unless @paginator.has_page_number? @number
+ end
+ attr_reader :paginator, :number
+ alias to_i :number
+
+ # Compares two Page objects and returns true when they represent the
+ # same page (i.e., their paginators are the same and they have the
+ # same page number).
+ def ==(page)
+ return false if page.nil?
+ @paginator == page.paginator and
+ @number == page.number
+ end
+
+ # Compares two Page objects and returns -1 if the left-hand page comes
+ # before the right-hand page, 0 if the pages are equal, and 1 if the
+ # left-hand page comes after the right-hand page. Raises ArgumentError
+ # if the pages do not belong to the same Paginator object.
+ def <=>(page)
+ raise ArgumentError unless @paginator == page.paginator
+ @number <=> page.number
+ end
+
+ # Returns the item offset for the first item in this page.
+ def offset
+ @paginator.items_per_page * (@number - 1)
+ end
+
+ # Returns the number of the first item displayed.
+ def first_item
+ offset + 1
+ end
+
+ # Returns the number of the last item displayed.
+ def last_item
+ [@paginator.items_per_page * @number, @paginator.item_count].min
+ end
+
+ # Returns true if this page is the first page in the paginator.
+ def first?
+ self == @paginator.first
+ end
+
+ # Returns true if this page is the last page in the paginator.
+ def last?
+ self == @paginator.last
+ end
+
+ # Returns a new Page object representing the page just before this
+ # page, or nil if this is the first page.
+ def previous
+ if first? then nil else @paginator[@number - 1] end
+ end
+
+ # Returns a new Page object representing the page just after this
+ # page, or nil if this is the last page.
+ def next
+ if last? then nil else @paginator[@number + 1] end
+ end
+
+ # Returns a new Window object for this page with the specified
+ # +padding+.
+ def window(padding=2)
+ Window.new(self, padding)
+ end
+
+ # Returns the limit/offset array for this page.
+ def to_sql
+ [@paginator.items_per_page, offset]
+ end
+
+ def to_param #:nodoc:
+ @number.to_s
+ end
+ end
+
+ # A class for representing ranges around a given page.
+ class Window
+ # Creates a new Window object for the given +page+ with the specified
+ # +padding+.
+ def initialize(page, padding=2)
+ @paginator = page.paginator
+ @page = page
+ self.padding = padding
+ end
+ attr_reader :paginator, :page
+
+ # Sets the window's padding (the number of pages on either side of the
+ # window page).
+ def padding=(padding)
+ @padding = padding < 0 ? 0 : padding
+ # Find the beginning and end pages of the window
+ @first = @paginator.has_page_number?(@page.number - @padding) ?
+ @paginator[@page.number - @padding] : @paginator.first
+ @last = @paginator.has_page_number?(@page.number + @padding) ?
+ @paginator[@page.number + @padding] : @paginator.last
+ end
+ attr_reader :padding, :first, :last
+
+ # Returns an array of Page objects in the current window.
+ def pages
+ (@first.number..@last.number).to_a.collect! {|n| @paginator[n]}
+ end
+ alias to_a :pages
+ end
+ end
+
+ end
+end
diff --git a/rest_sys/vendor/plugins/classic_pagination/lib/pagination_helper.rb b/rest_sys/vendor/plugins/classic_pagination/lib/pagination_helper.rb
new file mode 100644
index 000000000..069d77566
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/lib/pagination_helper.rb
@@ -0,0 +1,135 @@
+module ActionView
+ module Helpers
+ # Provides methods for linking to ActionController::Pagination objects using a simple generator API. You can optionally
+ # also build your links manually using ActionView::Helpers::AssetHelper#link_to like so:
+ #
+ # <%= link_to "Previous page", { :page => paginator.current.previous } if paginator.current.previous %>
+ # <%= link_to "Next page", { :page => paginator.current.next } if paginator.current.next %>
+ module PaginationHelper
+ unless const_defined?(:DEFAULT_OPTIONS)
+ DEFAULT_OPTIONS = {
+ :name => :page,
+ :window_size => 2,
+ :always_show_anchors => true,
+ :link_to_current_page => false,
+ :params => {}
+ }
+ end
+
+ # Creates a basic HTML link bar for the given +paginator+. Links will be created
+ # for the next and/or previous page and for a number of other pages around the current
+ # pages position. The +html_options+ hash is passed to +link_to+ when the links are created.
+ #
+ # ==== Options
+ # :name :: the routing name for this paginator
+ # (defaults to +page+)
+ # :prefix :: prefix for pagination links
+ # (i.e. Older Pages: 1 2 3 4)
+ # :suffix :: suffix for pagination links
+ # (i.e. 1 2 3 4 <- Older Pages)
+ # :window_size :: the number of pages to show around
+ # the current page (defaults to 2 )
+ # :always_show_anchors :: whether or not the first and last
+ # pages should always be shown
+ # (defaults to +true+)
+ # :link_to_current_page :: whether or not the current page
+ # should be linked to (defaults to
+ # +false+)
+ # :params :: any additional routing parameters
+ # for page URLs
+ #
+ # ==== Examples
+ # # We'll assume we have a paginator setup in @person_pages...
+ #
+ # pagination_links(@person_pages)
+ # # => 1 2 3 ... 10
+ #
+ # pagination_links(@person_pages, :link_to_current_page => true)
+ # # => 1 2 3 ... 10
+ #
+ # pagination_links(@person_pages, :always_show_anchors => false)
+ # # => 1 2 3
+ #
+ # pagination_links(@person_pages, :window_size => 1)
+ # # => 1 2 ... 10
+ #
+ # pagination_links(@person_pages, :params => { :viewer => "flash" })
+ # # => 1 2 3 ...
+ # # 10
+ def pagination_links(paginator, options={}, html_options={})
+ name = options[:name] || DEFAULT_OPTIONS[:name]
+ params = (options[:params] || DEFAULT_OPTIONS[:params]).clone
+
+ prefix = options[:prefix] || ''
+ suffix = options[:suffix] || ''
+
+ pagination_links_each(paginator, options, prefix, suffix) do |n|
+ params[name] = n
+ link_to(n.to_s, params, html_options)
+ end
+ end
+
+ # Iterate through the pages of a given +paginator+, invoking a
+ # block for each page number that needs to be rendered as a link.
+ #
+ # ==== Options
+ # :window_size :: the number of pages to show around
+ # the current page (defaults to +2+)
+ # :always_show_anchors :: whether or not the first and last
+ # pages should always be shown
+ # (defaults to +true+)
+ # :link_to_current_page :: whether or not the current page
+ # should be linked to (defaults to
+ # +false+)
+ #
+ # ==== Example
+ # # Turn paginated links into an Ajax call
+ # pagination_links_each(paginator, page_options) do |link|
+ # options = { :url => {:action => 'list'}, :update => 'results' }
+ # html_options = { :href => url_for(:action => 'list') }
+ #
+ # link_to_remote(link.to_s, options, html_options)
+ # end
+ def pagination_links_each(paginator, options, prefix = nil, suffix = nil)
+ options = DEFAULT_OPTIONS.merge(options)
+ link_to_current_page = options[:link_to_current_page]
+ always_show_anchors = options[:always_show_anchors]
+
+ current_page = paginator.current_page
+ window_pages = current_page.window(options[:window_size]).pages
+ return if window_pages.length <= 1 unless link_to_current_page
+
+ first, last = paginator.first, paginator.last
+
+ html = ''
+
+ html << prefix if prefix
+
+ if always_show_anchors and not (wp_first = window_pages[0]).first?
+ html << yield(first.number)
+ html << ' ... ' if wp_first.number - first.number > 1
+ html << ' '
+ end
+
+ window_pages.each do |page|
+ if current_page == page && !link_to_current_page
+ html << page.number.to_s
+ else
+ html << yield(page.number)
+ end
+ html << ' '
+ end
+
+ if always_show_anchors and not (wp_last = window_pages[-1]).last?
+ html << ' ... ' if last.number - wp_last.number > 1
+ html << yield(last.number)
+ end
+
+ html << suffix if suffix
+
+ html
+ end
+
+ end # PaginationHelper
+ end # Helpers
+end # ActionView
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/fixtures/companies.yml b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/companies.yml
new file mode 100644
index 000000000..707f72abc
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/companies.yml
@@ -0,0 +1,24 @@
+thirty_seven_signals:
+ id: 1
+ name: 37Signals
+ rating: 4
+
+TextDrive:
+ id: 2
+ name: TextDrive
+ rating: 4
+
+PlanetArgon:
+ id: 3
+ name: Planet Argon
+ rating: 4
+
+Google:
+ id: 4
+ name: Google
+ rating: 4
+
+Ionist:
+ id: 5
+ name: Ioni.st
+ rating: 4
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/fixtures/company.rb b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/company.rb
new file mode 100644
index 000000000..0d1c29b90
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/company.rb
@@ -0,0 +1,9 @@
+class Company < ActiveRecord::Base
+ attr_protected :rating
+ set_sequence_name :companies_nonstd_seq
+
+ validates_presence_of :name
+ def validate
+ errors.add('rating', 'rating should not be 2') if rating == 2
+ end
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/fixtures/developer.rb b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/developer.rb
new file mode 100644
index 000000000..f5e5b901f
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/developer.rb
@@ -0,0 +1,7 @@
+class Developer < ActiveRecord::Base
+ has_and_belongs_to_many :projects
+end
+
+class DeVeLoPeR < ActiveRecord::Base
+ set_table_name "developers"
+end
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/fixtures/developers.yml b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/developers.yml
new file mode 100644
index 000000000..308bf75de
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/developers.yml
@@ -0,0 +1,21 @@
+david:
+ id: 1
+ name: David
+ salary: 80000
+
+jamis:
+ id: 2
+ name: Jamis
+ salary: 150000
+
+<% for digit in 3..10 %>
+dev_<%= digit %>:
+ id: <%= digit %>
+ name: fixture_<%= digit %>
+ salary: 100000
+<% end %>
+
+poor_jamis:
+ id: 11
+ name: Jamis
+ salary: 9000
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/fixtures/developers_projects.yml b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/developers_projects.yml
new file mode 100644
index 000000000..cee359c7c
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/developers_projects.yml
@@ -0,0 +1,13 @@
+david_action_controller:
+ developer_id: 1
+ project_id: 2
+ joined_on: 2004-10-10
+
+david_active_record:
+ developer_id: 1
+ project_id: 1
+ joined_on: 2004-10-10
+
+jamis_active_record:
+ developer_id: 2
+ project_id: 1
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/fixtures/project.rb b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/project.rb
new file mode 100644
index 000000000..2b53d39ed
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/project.rb
@@ -0,0 +1,3 @@
+class Project < ActiveRecord::Base
+ has_and_belongs_to_many :developers, :uniq => true
+end
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/fixtures/projects.yml b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/projects.yml
new file mode 100644
index 000000000..02800c782
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/projects.yml
@@ -0,0 +1,7 @@
+action_controller:
+ id: 2
+ name: Active Controller
+
+active_record:
+ id: 1
+ name: Active Record
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/fixtures/replies.yml b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/replies.yml
new file mode 100644
index 000000000..284c9c079
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/replies.yml
@@ -0,0 +1,13 @@
+witty_retort:
+ id: 1
+ topic_id: 1
+ content: Birdman is better!
+ created_at: <%= 6.hours.ago.to_s(:db) %>
+ updated_at: nil
+
+another:
+ id: 2
+ topic_id: 2
+ content: Nuh uh!
+ created_at: <%= 1.hour.ago.to_s(:db) %>
+ updated_at: nil
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/fixtures/reply.rb b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/reply.rb
new file mode 100644
index 000000000..ea84042b9
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/reply.rb
@@ -0,0 +1,5 @@
+class Reply < ActiveRecord::Base
+ belongs_to :topic, :include => [:replies]
+
+ validates_presence_of :content
+end
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/fixtures/schema.sql b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/schema.sql
new file mode 100644
index 000000000..b4e7539d1
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/schema.sql
@@ -0,0 +1,42 @@
+CREATE TABLE 'companies' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'name' TEXT DEFAULT NULL,
+ 'rating' INTEGER DEFAULT 1
+);
+
+CREATE TABLE 'replies' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'content' text,
+ 'created_at' datetime,
+ 'updated_at' datetime,
+ 'topic_id' integer
+);
+
+CREATE TABLE 'topics' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'title' varchar(255),
+ 'subtitle' varchar(255),
+ 'content' text,
+ 'created_at' datetime,
+ 'updated_at' datetime
+);
+
+CREATE TABLE 'developers' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'name' TEXT DEFAULT NULL,
+ 'salary' INTEGER DEFAULT 70000,
+ 'created_at' DATETIME DEFAULT NULL,
+ 'updated_at' DATETIME DEFAULT NULL
+);
+
+CREATE TABLE 'projects' (
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'name' TEXT DEFAULT NULL
+);
+
+CREATE TABLE 'developers_projects' (
+ 'developer_id' INTEGER NOT NULL,
+ 'project_id' INTEGER NOT NULL,
+ 'joined_on' DATE DEFAULT NULL,
+ 'access_level' INTEGER DEFAULT 1
+);
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/fixtures/topic.rb b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/topic.rb
new file mode 100644
index 000000000..0beeecf28
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/topic.rb
@@ -0,0 +1,3 @@
+class Topic < ActiveRecord::Base
+ has_many :replies, :include => [:user], :dependent => :destroy
+end
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/fixtures/topics.yml b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/topics.yml
new file mode 100644
index 000000000..61ea02d76
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/fixtures/topics.yml
@@ -0,0 +1,22 @@
+futurama:
+ id: 1
+ title: Isnt futurama awesome?
+ subtitle: It really is, isnt it.
+ content: I like futurama
+ created_at: <%= 1.day.ago.to_s(:db) %>
+ updated_at:
+
+harvey_birdman:
+ id: 2
+ title: Harvey Birdman is the king of all men
+ subtitle: yup
+ content: It really is
+ created_at: <%= 2.hours.ago.to_s(:db) %>
+ updated_at:
+
+rails:
+ id: 3
+ title: Rails is nice
+ subtitle: It makes me happy
+ content: except when I have to hack internals to fix pagination. even then really.
+ created_at: <%= 20.minutes.ago.to_s(:db) %>
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/helper.rb b/rest_sys/vendor/plugins/classic_pagination/test/helper.rb
new file mode 100644
index 000000000..3f76d5a76
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/helper.rb
@@ -0,0 +1,117 @@
+require 'test/unit'
+
+unless defined?(ActiveRecord)
+ plugin_root = File.join(File.dirname(__FILE__), '..')
+
+ # first look for a symlink to a copy of the framework
+ if framework_root = ["#{plugin_root}/rails", "#{plugin_root}/../../rails"].find { |p| File.directory? p }
+ puts "found framework root: #{framework_root}"
+ # this allows for a plugin to be tested outside an app
+ $:.unshift "#{framework_root}/activesupport/lib", "#{framework_root}/activerecord/lib", "#{framework_root}/actionpack/lib"
+ else
+ # is the plugin installed in an application?
+ app_root = plugin_root + '/../../..'
+
+ if File.directory? app_root + '/config'
+ puts 'using config/boot.rb'
+ ENV['RAILS_ENV'] = 'test'
+ require File.expand_path(app_root + '/config/boot')
+ else
+ # simply use installed gems if available
+ puts 'using rubygems'
+ require 'rubygems'
+ gem 'actionpack'; gem 'activerecord'
+ end
+ end
+
+ %w(action_pack active_record action_controller active_record/fixtures action_controller/test_process).each {|f| require f}
+
+ Dependencies.load_paths.unshift "#{plugin_root}/lib"
+end
+
+# Define the connector
+class ActiveRecordTestConnector
+ cattr_accessor :able_to_connect
+ cattr_accessor :connected
+
+ # Set our defaults
+ self.connected = false
+ self.able_to_connect = true
+
+ class << self
+ def setup
+ unless self.connected || !self.able_to_connect
+ setup_connection
+ load_schema
+ require_fixture_models
+ self.connected = true
+ end
+ rescue Exception => e # errors from ActiveRecord setup
+ $stderr.puts "\nSkipping ActiveRecord assertion tests: #{e}"
+ #$stderr.puts " #{e.backtrace.join("\n ")}\n"
+ self.able_to_connect = false
+ end
+
+ private
+
+ def setup_connection
+ if Object.const_defined?(:ActiveRecord)
+ defaults = { :database => ':memory:' }
+ begin
+ options = defaults.merge :adapter => 'sqlite3', :timeout => 500
+ ActiveRecord::Base.establish_connection(options)
+ ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' => options }
+ ActiveRecord::Base.connection
+ rescue Exception # errors from establishing a connection
+ $stderr.puts 'SQLite 3 unavailable; trying SQLite 2.'
+ options = defaults.merge :adapter => 'sqlite'
+ ActiveRecord::Base.establish_connection(options)
+ ActiveRecord::Base.configurations = { 'sqlite2_ar_integration' => options }
+ ActiveRecord::Base.connection
+ end
+
+ Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')) unless Object.const_defined?(:QUOTED_TYPE)
+ else
+ raise "Can't setup connection since ActiveRecord isn't loaded."
+ end
+ end
+
+ # Load actionpack sqlite tables
+ def load_schema
+ File.read(File.dirname(__FILE__) + "/fixtures/schema.sql").split(';').each do |sql|
+ ActiveRecord::Base.connection.execute(sql) unless sql.blank?
+ end
+ end
+
+ def require_fixture_models
+ Dir.glob(File.dirname(__FILE__) + "/fixtures/*.rb").each {|f| require f}
+ end
+ end
+end
+
+# Test case for inheritance
+class ActiveRecordTestCase < Test::Unit::TestCase
+ # Set our fixture path
+ if ActiveRecordTestConnector.able_to_connect
+ self.fixture_path = "#{File.dirname(__FILE__)}/fixtures/"
+ self.use_transactional_fixtures = false
+ end
+
+ def self.fixtures(*args)
+ super if ActiveRecordTestConnector.connected
+ end
+
+ def run(*args)
+ super if ActiveRecordTestConnector.connected
+ end
+
+ # Default so Test::Unit::TestCase doesn't complain
+ def test_truth
+ end
+end
+
+ActiveRecordTestConnector.setup
+ActionController::Routing::Routes.reload rescue nil
+ActionController::Routing::Routes.draw do |map|
+ map.connect ':controller/:action/:id'
+end
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/pagination_helper_test.rb b/rest_sys/vendor/plugins/classic_pagination/test/pagination_helper_test.rb
new file mode 100644
index 000000000..d8394a793
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/pagination_helper_test.rb
@@ -0,0 +1,38 @@
+require File.dirname(__FILE__) + '/helper'
+require File.dirname(__FILE__) + '/../init'
+
+class PaginationHelperTest < Test::Unit::TestCase
+ include ActionController::Pagination
+ include ActionView::Helpers::PaginationHelper
+ include ActionView::Helpers::UrlHelper
+ include ActionView::Helpers::TagHelper
+
+ def setup
+ @controller = Class.new do
+ attr_accessor :url, :request
+ def url_for(options, *parameters_for_method_reference)
+ url
+ end
+ end
+ @controller = @controller.new
+ @controller.url = "http://www.example.com"
+ end
+
+ def test_pagination_links
+ total, per_page, page = 30, 10, 1
+ output = pagination_links Paginator.new(@controller, total, per_page, page)
+ assert_equal "1 2 3 ", output
+ end
+
+ def test_pagination_links_with_prefix
+ total, per_page, page = 30, 10, 1
+ output = pagination_links Paginator.new(@controller, total, per_page, page), :prefix => 'Newer '
+ assert_equal "Newer 1 2 3 ", output
+ end
+
+ def test_pagination_links_with_suffix
+ total, per_page, page = 30, 10, 1
+ output = pagination_links Paginator.new(@controller, total, per_page, page), :suffix => 'Older'
+ assert_equal "1 2 3 Older", output
+ end
+end
diff --git a/rest_sys/vendor/plugins/classic_pagination/test/pagination_test.rb b/rest_sys/vendor/plugins/classic_pagination/test/pagination_test.rb
new file mode 100644
index 000000000..16a6f1d84
--- /dev/null
+++ b/rest_sys/vendor/plugins/classic_pagination/test/pagination_test.rb
@@ -0,0 +1,177 @@
+require File.dirname(__FILE__) + '/helper'
+require File.dirname(__FILE__) + '/../init'
+
+class PaginationTest < ActiveRecordTestCase
+ fixtures :topics, :replies, :developers, :projects, :developers_projects
+
+ class PaginationController < ActionController::Base
+ if respond_to? :view_paths=
+ self.view_paths = [ "#{File.dirname(__FILE__)}/../fixtures/" ]
+ else
+ self.template_root = [ "#{File.dirname(__FILE__)}/../fixtures/" ]
+ end
+
+ def simple_paginate
+ @topic_pages, @topics = paginate(:topics)
+ render :nothing => true
+ end
+
+ def paginate_with_per_page
+ @topic_pages, @topics = paginate(:topics, :per_page => 1)
+ render :nothing => true
+ end
+
+ def paginate_with_order
+ @topic_pages, @topics = paginate(:topics, :order => 'created_at asc')
+ render :nothing => true
+ end
+
+ def paginate_with_order_by
+ @topic_pages, @topics = paginate(:topics, :order_by => 'created_at asc')
+ render :nothing => true
+ end
+
+ def paginate_with_include_and_order
+ @topic_pages, @topics = paginate(:topics, :include => :replies, :order => 'replies.created_at asc, topics.created_at asc')
+ render :nothing => true
+ end
+
+ def paginate_with_conditions
+ @topic_pages, @topics = paginate(:topics, :conditions => ["created_at > ?", 30.minutes.ago])
+ render :nothing => true
+ end
+
+ def paginate_with_class_name
+ @developer_pages, @developers = paginate(:developers, :class_name => "DeVeLoPeR")
+ render :nothing => true
+ end
+
+ def paginate_with_singular_name
+ @developer_pages, @developers = paginate()
+ render :nothing => true
+ end
+
+ def paginate_with_joins
+ @developer_pages, @developers = paginate(:developers,
+ :joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id',
+ :conditions => 'project_id=1')
+ render :nothing => true
+ end
+
+ def paginate_with_join
+ @developer_pages, @developers = paginate(:developers,
+ :join => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id',
+ :conditions => 'project_id=1')
+ render :nothing => true
+ end
+
+ def paginate_with_join_and_count
+ @developer_pages, @developers = paginate(:developers,
+ :join => 'd LEFT JOIN developers_projects ON d.id = developers_projects.developer_id',
+ :conditions => 'project_id=1',
+ :count => "d.id")
+ render :nothing => true
+ end
+
+ def paginate_with_join_and_group
+ @developer_pages, @developers = paginate(:developers,
+ :join => 'INNER JOIN developers_projects ON developers.id = developers_projects.developer_id',
+ :group => 'developers.id')
+ render :nothing => true
+ end
+
+ def rescue_errors(e) raise e end
+
+ def rescue_action(e) raise end
+
+ end
+
+ def setup
+ @controller = PaginationController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ super
+ end
+
+ # Single Action Pagination Tests
+
+ def test_simple_paginate
+ get :simple_paginate
+ assert_equal 1, assigns(:topic_pages).page_count
+ assert_equal 3, assigns(:topics).size
+ end
+
+ def test_paginate_with_per_page
+ get :paginate_with_per_page
+ assert_equal 1, assigns(:topics).size
+ assert_equal 3, assigns(:topic_pages).page_count
+ end
+
+ def test_paginate_with_order
+ get :paginate_with_order
+ expected = [topics(:futurama),
+ topics(:harvey_birdman),
+ topics(:rails)]
+ assert_equal expected, assigns(:topics)
+ assert_equal 1, assigns(:topic_pages).page_count
+ end
+
+ def test_paginate_with_order_by
+ get :paginate_with_order
+ expected = assigns(:topics)
+ get :paginate_with_order_by
+ assert_equal expected, assigns(:topics)
+ assert_equal 1, assigns(:topic_pages).page_count
+ end
+
+ def test_paginate_with_conditions
+ get :paginate_with_conditions
+ expected = [topics(:rails)]
+ assert_equal expected, assigns(:topics)
+ assert_equal 1, assigns(:topic_pages).page_count
+ end
+
+ def test_paginate_with_class_name
+ get :paginate_with_class_name
+
+ assert assigns(:developers).size > 0
+ assert_equal DeVeLoPeR, assigns(:developers).first.class
+ end
+
+ def test_paginate_with_joins
+ get :paginate_with_joins
+ assert_equal 2, assigns(:developers).size
+ developer_names = assigns(:developers).map { |d| d.name }
+ assert developer_names.include?('David')
+ assert developer_names.include?('Jamis')
+ end
+
+ def test_paginate_with_join_and_conditions
+ get :paginate_with_joins
+ expected = assigns(:developers)
+ get :paginate_with_join
+ assert_equal expected, assigns(:developers)
+ end
+
+ def test_paginate_with_join_and_count
+ get :paginate_with_joins
+ expected = assigns(:developers)
+ get :paginate_with_join_and_count
+ assert_equal expected, assigns(:developers)
+ end
+
+ def test_paginate_with_include_and_order
+ get :paginate_with_include_and_order
+ expected = Topic.find(:all, :include => 'replies', :order => 'replies.created_at asc, topics.created_at asc', :limit => 10)
+ assert_equal expected, assigns(:topics)
+ end
+
+ def test_paginate_with_join_and_group
+ get :paginate_with_join_and_group
+ assert_equal 2, assigns(:developers).size
+ assert_equal 2, assigns(:developer_pages).item_count
+ developer_names = assigns(:developers).map { |d| d.name }
+ assert developer_names.include?('David')
+ assert developer_names.include?('Jamis')
+ end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/FOLDERS b/rest_sys/vendor/plugins/coderay-0.7.6.227/FOLDERS
new file mode 100644
index 000000000..e393ed7f9
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/FOLDERS
@@ -0,0 +1,53 @@
+= CodeRay - Trunk folder structure
+
+== bench - Benchmarking system
+
+All benchmarking stuff goes here.
+
+Test inputs are stored in files named example..
+Test outputs go to bench/test..
+
+Run bench/bench.rb to get a usage description.
+
+Run rake bench to perform an example benchmark.
+
+
+== bin - Scripts
+
+Executional files for CodeRay.
+
+
+== demo - Demos and functional tests
+
+Demonstrational scripts to show of CodeRay's features.
+
+Run them as functional tests with rake test:demos.
+
+
+== etc - Lots of stuff
+
+Some addidtional files for CodeRay, mainly graphics and Vim scripts.
+
+
+== gem_server - Gem output folder
+
+For rake gem.
+
+
+== lib - CodeRay library code
+
+This is the base directory for the CodeRay library.
+
+
+== rake_helpers - Rake helper libraries
+
+Some files to enhance Rake, including the Autumnal Rdoc template and some scripts.
+
+
+== test - Tests
+
+Tests for the scanners.
+
+Each language has its own subfolder and sub-suite.
+
+Run with rake test.
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/LICENSE b/rest_sys/vendor/plugins/coderay-0.7.6.227/LICENSE
new file mode 100644
index 000000000..c00103def
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/LICENSE
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ , 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/README b/rest_sys/vendor/plugins/coderay-0.7.6.227/README
new file mode 100644
index 000000000..ef8275529
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/README
@@ -0,0 +1,128 @@
+= CodeRay
+
+[- Tired of blue'n'gray? Try the original version of this documentation on
+http://rd.cYcnus.de/coderay/doc (use Ctrl+Click to open it in its own frame.) -]
+
+== About
+CodeRay is a Ruby library for syntax highlighting.
+
+Syntax highlighting means: You put your code in, and you get it back colored;
+Keywords, strings, floats, comments - all in different colors.
+And with line numbers.
+
+*Syntax* *Highlighting*...
+* makes code easier to read and maintain
+* lets you detect syntax errors faster
+* helps you to understand the syntax of a language
+* looks nice
+* is what everybody should have on their website
+* solves all your problems and makes the girls run after you
+
+Version: 0.7.4 (2006.october.20)
+Author:: murphy (Kornelius Kalnbach)
+Contact:: murphy rubychan de
+Website:: coderay.rubychan.de[http://coderay.rubychan.de]
+License:: GNU LGPL; see LICENSE file in the main directory.
+Subversion:: $Id: README 219 2006-10-20 15:52:25Z murphy $
+
+-----
+
+== Installation
+
+You need RubyGems[http://rubyforge.org/frs/?group_id=126].
+
+ % gem install coderay
+
+Since CodeRay is still in beta stage, nightly buildy may be useful:
+
+ % gem install coderay -rs rd.cYcnus.de/coderay
+
+
+=== Dependencies
+
+CodeRay needs Ruby 1.8 and the
+strscan[http://www.ruby-doc.org/stdlib/libdoc/strscan/rdoc/index.htm]
+library (part of the standard library.) It should also run with Ruby 1.9 and
+yarv.
+
+
+== Example Usage
+(Forgive me, but this is not highlighted.)
+
+ require 'coderay'
+
+ tokens = CodeRay.scan "puts 'Hello, world!'", :ruby
+ page = tokens.html :line_numbers => :inline, :wrap => :page
+ puts page
+
+
+== Documentation
+
+See CodeRay.
+
+Please report errors in this documentation to .
+
+
+-----
+
+== Credits
+
+=== Special Thanks to
+
+* licenser (Heinz N. Gies) for ending my QBasic career, inventing the Coder
+ project and the input/output plugin system.
+ CodeRay would not exist without him.
+
+=== Thanks to
+
+* Caleb Clausen for writing RubyLexer (see
+ http://rubyforge.org/projects/rubylexer) and lots of very interesting mail
+ traffic
+* birkenfeld (Georg Brandl) and mitsuhiku (Arnim Ronacher) for PyKleur. You
+ guys rock!
+* Jamis Buck for writing Syntax (see http://rubyforge.org/projects/syntax)
+ I got some useful ideas from it.
+* Doug Kearns and everyone else who worked on ruby.vim - it not only helped me
+ coding CodeRay, but also gave me a wonderful target to reach for the Ruby
+ scanner.
+* everyone who used CodeBB on http://www.rubyforen.de and
+ http://www.infhu.de/mx
+* iGEL, magichisoka, manveru, WoNáDo and everyone I forgot from rubyforen.de
+* Daniel and Dethix from ruby-mine.de
+* Dookie (who is no longer with us...) and Leonidas from
+ http://www.python-forum.de
+* Andreas Schwarz for finding out that CaseIgnoringWordList was not case
+ ignoring! Such things really make you write tests.
+* matz and all Ruby gods and gurus
+* The inventors of: the computer, the internet, the true color display, HTML &
+ CSS, VIM, RUBY, pizza, microwaves, guitars, scouting, programming, anime,
+ manga, coke and green ice tea.
+
+Where would we be without all those people?
+
+=== Created using
+
+* Ruby[http://ruby-lang.org/]
+* Chihiro (my Sony VAIO laptop), Henrietta (my new MacBook) and
+ Seras (my Athlon 2200+ tower)
+* VIM[http://vim.org] and TextMate[http://macromates.com]
+* RDE[http://homepage2.nifty.com/sakazuki/rde_e.html]
+* Microsoft Windows (yes, I confess!) and MacOS X
+* Firefox[http://www.mozilla.org/products/firefox/] and
+ Thunderbird[http://www.mozilla.org/products/thunderbird/]
+* Rake[http://rake.rubyforge.org/]
+* RubyGems[http://docs.rubygems.org/]
+* {Subversion/TortoiseSVN}[http://tortoisesvn.tigris.org/] using Apache via
+ XAMPP[http://www.apachefriends.org/en/xampp.html]
+* RDoc (though I'm quite unsatisfied with it)
+* GNUWin32, MinGW and some other tools to make the shell under windows a bit
+ more useful
+* Term::ANSIColor[http://term-ansicolor.rubyforge.org/]
+
+---
+
+* As you can see, CodeRay was created under heavy use of *free* software.
+* So CodeRay is also *free*.
+* If you use CodeRay to create software, think about making this software
+ *free*, too.
+* Thanks :)
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/bin/coderay b/rest_sys/vendor/plugins/coderay-0.7.6.227/bin/coderay
new file mode 100644
index 000000000..52477613c
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/bin/coderay
@@ -0,0 +1,82 @@
+#!/usr/bin/env ruby
+# CodeRay Executable
+#
+# Version: 0.1
+# Author: murphy
+
+def err msg
+ $stderr.puts msg
+end
+
+begin
+ require 'coderay'
+
+ if ARGV.empty?
+ puts <<-USAGE
+CodeRay #{CodeRay::VERSION} (http://rd.cYcnus.de/coderay)
+Usage:
+ coderay - [-] < file > output
+ coderay file [-]
+Example:
+ coderay -ruby -statistic < foo.rb
+ coderay codegen.c # generates codegen.c.html
+ USAGE
+ end
+
+ first, second = ARGV
+
+ if first
+ if first[/-(\w+)/] == first
+ lang = $1.to_sym
+ input = $stdin.read
+ tokens = :scan
+ elsif first == '-'
+ lang = $1.to_sym
+ input = $stdin.read
+ tokens = :scan
+ else
+ file = first
+ tokens = CodeRay.scan_file file
+ output_filename, output_ext = file, /#{Regexp.escape(File.extname(file))}$/
+ end
+ else
+ puts 'No lang/file given.'
+ exit 1
+ end
+
+ if second
+ if second[/-(\w+)/] == second
+ format = $1.to_sym
+ else
+ raise 'Invalid format (must be -xxx).'
+ end
+ else
+ $stderr.puts 'No format given; setting to default (HTML Page)'
+ format = :page
+ end
+
+ # TODO: allow streaming
+ if tokens == :scan
+ output = CodeRay::Duo[lang => format].highlight input #, :stream => true
+ else
+ output = tokens.encode format
+ end
+ out = $stdout
+ if output_filename
+ output_filename += '.' + CodeRay::Encoders[format]::FILE_EXTENSION
+ if File.exist? output_filename
+ err 'File %s already exists.' % output_filename
+ exit
+ else
+ out = File.open output_filename, 'w'
+ end
+ end
+ out.print output
+
+rescue => boom
+ err "Error: #{boom.message}\n"
+ err boom.backtrace
+ err '-' * 50
+ err ARGV
+ exit 1
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/bin/coderay_stylesheet b/rest_sys/vendor/plugins/coderay-0.7.6.227/bin/coderay_stylesheet
new file mode 100644
index 000000000..baa7c260e
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/bin/coderay_stylesheet
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+require 'coderay'
+
+puts CodeRay::Encoders[:html]::CSS.new.stylesheet
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay.rb
new file mode 100644
index 000000000..fb6a29e1f
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay.rb
@@ -0,0 +1,320 @@
+# = CodeRay Library
+#
+# $Id: coderay.rb 227 2007-04-24 12:26:18Z murphy $
+#
+# CodeRay is a Ruby library for syntax highlighting.
+#
+# I try to make CodeRay easy to use and intuitive, but at the same time fully featured, complete,
+# fast and efficient.
+#
+# See README.
+#
+# It consists mainly of
+# * the main engine: CodeRay (Scanners::Scanner, Tokens/TokenStream, Encoders::Encoder), PluginHost
+# * the scanners in CodeRay::Scanners
+# * the encoders in CodeRay::Encoders
+#
+# Here's a fancy graphic to light up this gray docu:
+#
+# http://rd.cYcnus.de/coderay/scheme.png
+#
+# == Documentation
+#
+# See CodeRay, Encoders, Scanners, Tokens.
+#
+# == Usage
+#
+# Remember you need RubyGems to use CodeRay, unless you have it in your load path. Run Ruby with
+# -rubygems option if required.
+#
+# === Highlight Ruby code in a string as html
+#
+# require 'coderay'
+# print CodeRay.scan('puts "Hello, world!"', :ruby).html
+#
+# # prints something like this:
+# puts "Hello, world!"
+#
+#
+# === Highlight C code from a file in a html div
+#
+# require 'coderay'
+# print CodeRay.scan(File.read('ruby.h'), :c).div
+# print CodeRay.scan_file('ruby.h').html.div
+#
+# You can include this div in your page. The used CSS styles can be printed with
+#
+# % coderay_stylesheet
+#
+# === Highlight without typing too much
+#
+# If you are one of the hasty (or lazy, or extremely curious) people, just run this file:
+#
+# % ruby -rubygems /path/to/coderay/coderay.rb > example.html
+#
+# and look at the file it created in your browser.
+#
+# = CodeRay Module
+#
+# The CodeRay module provides convenience methods for the engine.
+#
+# * The +lang+ and +format+ arguments select Scanner and Encoder to use. These are
+# simply lower-case symbols, like :python or :html .
+# * All methods take an optional hash as last parameter, +options+, that is send to
+# the Encoder / Scanner.
+# * Input and language are always sorted in this order: +code+, +lang+.
+# (This is in alphabetical order, if you need a mnemonic ;)
+#
+# You should be able to highlight everything you want just using these methods;
+# so there is no need to dive into CodeRay's deep class hierarchy.
+#
+# The examples in the demo directory demonstrate common cases using this interface.
+#
+# = Basic Access Ways
+#
+# Read this to get a general view what CodeRay provides.
+#
+# == Scanning
+#
+# Scanning means analysing an input string, splitting it up into Tokens.
+# Each Token knows about what type it is: string, comment, class name, etc.
+#
+# Each +lang+ (language) has its own Scanner; for example, :ruby code is
+# handled by CodeRay::Scanners::Ruby.
+#
+# CodeRay.scan:: Scan a string in a given language into Tokens.
+# This is the most common method to use.
+# CodeRay.scan_file:: Scan a file and guess the language using FileType.
+#
+# The Tokens object you get from these methods can encode itself; see Tokens.
+#
+# == Encoding
+#
+# Encoding means compiling Tokens into an output. This can be colored HTML or
+# LaTeX, a textual statistic or just the number of non-whitespace tokens.
+#
+# Each Encoder provides output in a specific +format+, so you select Encoders via
+# formats like :html or :statistic .
+#
+# CodeRay.encode:: Scan and encode a string in a given language.
+# CodeRay.encode_tokens:: Encode the given tokens.
+# CodeRay.encode_file:: Scan a file, guess the language using FileType and encode it.
+#
+# == Streaming
+#
+# Streaming saves RAM by running Scanner and Encoder in some sort of
+# pipe mode; see TokenStream.
+#
+# CodeRay.scan_stream:: Scan in stream mode.
+#
+# == All-in-One Encoding
+#
+# CodeRay.encode:: Highlight a string with a given input and output format.
+#
+# == Instanciating
+#
+# You can use an Encoder instance to highlight multiple inputs. This way, the setup
+# for this Encoder must only be done once.
+#
+# CodeRay.encoder:: Create an Encoder instance with format and options.
+# CodeRay.scanner:: Create an Scanner instance for lang, with '' as default code.
+#
+# To make use of CodeRay.scanner, use CodeRay::Scanner::code=.
+#
+# The scanning methods provide more flexibility; we recommend to use these.
+#
+# == Reusing Scanners and Encoders
+#
+# If you want to re-use scanners and encoders (because that is faster), see
+# CodeRay::Duo for the most convenient (and recommended) interface.
+module CodeRay
+
+ # Version: Major.Minor.Teeny[.Revision]
+ # Major: 0 for pre-release
+ # Minor: odd for beta, even for stable
+ # Teeny: development state
+ # Revision: Subversion Revision number (generated on rake)
+ VERSION = '0.7.6'
+
+ require 'coderay/tokens'
+ require 'coderay/scanner'
+ require 'coderay/encoder'
+ require 'coderay/duo'
+ require 'coderay/style'
+
+
+ class << self
+
+ # Scans the given +code+ (a String) with the Scanner for +lang+.
+ #
+ # This is a simple way to use CodeRay. Example:
+ # require 'coderay'
+ # page = CodeRay.scan("puts 'Hello, world!'", :ruby).html
+ #
+ # See also demo/demo_simple.
+ def scan code, lang, options = {}, &block
+ scanner = Scanners[lang].new code, options, &block
+ scanner.tokenize
+ end
+
+ # Scans +filename+ (a path to a code file) with the Scanner for +lang+.
+ #
+ # If +lang+ is :auto or omitted, the CodeRay::FileType module is used to
+ # determine it. If it cannot find out what type it is, it uses
+ # CodeRay::Scanners::Plaintext.
+ #
+ # Calls CodeRay.scan.
+ #
+ # Example:
+ # require 'coderay'
+ # page = CodeRay.scan_file('some_c_code.c').html
+ def scan_file filename, lang = :auto, options = {}, &block
+ file = IO.read filename
+ if lang == :auto
+ require 'coderay/helpers/file_type'
+ lang = FileType.fetch filename, :plaintext, true
+ end
+ scan file, lang, options = {}, &block
+ end
+
+ # Scan the +code+ (a string) with the scanner for +lang+.
+ #
+ # Calls scan.
+ #
+ # See CodeRay.scan.
+ def scan_stream code, lang, options = {}, &block
+ options[:stream] = true
+ scan code, lang, options, &block
+ end
+
+ # Encode a string in Streaming mode.
+ #
+ # This starts scanning +code+ with the the Scanner for +lang+
+ # while encodes the output with the Encoder for +format+.
+ # +options+ will be passed to the Encoder.
+ #
+ # See CodeRay::Encoder.encode_stream
+ def encode_stream code, lang, format, options = {}
+ encoder(format, options).encode_stream code, lang, options
+ end
+
+ # Encode a string.
+ #
+ # This scans +code+ with the the Scanner for +lang+ and then
+ # encodes it with the Encoder for +format+.
+ # +options+ will be passed to the Encoder.
+ #
+ # See CodeRay::Encoder.encode
+ def encode code, lang, format, options = {}
+ encoder(format, options).encode code, lang, options
+ end
+
+ # Highlight a string into a HTML .
+ #
+ # CSS styles use classes, so you have to include a stylesheet
+ # in your output.
+ #
+ # See encode.
+ def highlight code, lang, options = { :css => :class }, format = :div
+ encode code, lang, format, options
+ end
+
+ # Encode pre-scanned Tokens.
+ # Use this together with CodeRay.scan:
+ #
+ # require 'coderay'
+ #
+ # # Highlight a short Ruby code example in a HTML span
+ # tokens = CodeRay.scan '1 + 2', :ruby
+ # puts CodeRay.encode_tokens(tokens, :span)
+ #
+ def encode_tokens tokens, format, options = {}
+ encoder(format, options).encode_tokens tokens, options
+ end
+
+ # Encodes +filename+ (a path to a code file) with the Scanner for +lang+.
+ #
+ # See CodeRay.scan_file.
+ # Notice that the second argument is the output +format+, not the input language.
+ #
+ # Example:
+ # require 'coderay'
+ # page = CodeRay.encode_file 'some_c_code.c', :html
+ def encode_file filename, format, options = {}
+ tokens = scan_file filename, :auto, get_scanner_options(options)
+ encode_tokens tokens, format, options
+ end
+
+ # Highlight a file into a HTML
.
+ #
+ # CSS styles use classes, so you have to include a stylesheet
+ # in your output.
+ #
+ # See encode.
+ def highlight_file filename, options = { :css => :class }, format = :div
+ encode_file filename, format, options
+ end
+
+ # Finds the Encoder class for +format+ and creates an instance, passing
+ # +options+ to it.
+ #
+ # Example:
+ # require 'coderay'
+ #
+ # stats = CodeRay.encoder(:statistic)
+ # stats.encode("puts 17 + 4\n", :ruby)
+ #
+ # puts '%d out of %d tokens have the kind :integer.' % [
+ # stats.type_stats[:integer].count,
+ # stats.real_token_count
+ # ]
+ # #-> 2 out of 4 tokens have the kind :integer.
+ def encoder format, options = {}
+ Encoders[format].new options
+ end
+
+ # Finds the Scanner class for +lang+ and creates an instance, passing
+ # +options+ to it.
+ #
+ # See Scanner.new.
+ def scanner lang, options = {}
+ Scanners[lang].new '', options
+ end
+
+ # Extract the options for the scanner from the +options+ hash.
+ #
+ # Returns an empty Hash if
:scanner_options is not set.
+ #
+ # This is used if a method like CodeRay.encode has to provide options
+ # for Encoder _and_ scanner.
+ def get_scanner_options options
+ options.fetch :scanner_options, {}
+ end
+
+ end
+
+ # This Exception is raised when you try to stream with something that is not
+ # capable of streaming.
+ class NotStreamableError < Exception
+ def initialize obj
+ @obj = obj
+ end
+
+ def to_s
+ '%s is not Streamable!' % @obj.class
+ end
+ end
+
+ # A dummy module that is included by subclasses of CodeRay::Scanner an CodeRay::Encoder
+ # to show that they are able to handle streams.
+ module Streamable
+ end
+
+end
+
+# Run a test script.
+if $0 == __FILE__
+ $stderr.print 'Press key to print demo.'; gets
+ code = File.read(__FILE__)[/module CodeRay.*/m]
+ print CodeRay.scan(code, :ruby).html
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/duo.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/duo.rb
new file mode 100644
index 000000000..9d11c0e37
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/duo.rb
@@ -0,0 +1,87 @@
+module CodeRay
+
+ # = Duo
+ #
+ # $Id: scanner.rb 123 2006-03-21 14:46:34Z murphy $
+ #
+ # A Duo is a convenient way to use CodeRay. You just create a Duo,
+ # giving it a lang (language of the input code) and a format (desired
+ # output format), and call Duo#highlight with the code.
+ #
+ # Duo makes it easy to re-use both scanner and encoder for a repetitive
+ # task. It also provides a very easy interface syntax:
+ #
+ # require 'coderay'
+ # CodeRay::Duo[:python, :div].highlight 'import this'
+ #
+ # Until you want to do uncommon things with CodeRay, I recommend to use
+ # this method, since it takes care of everything.
+ class Duo
+
+ attr_accessor :lang, :format, :options
+
+ # Create a new Duo, holding a lang and a format to highlight code.
+ #
+ # simple:
+ # CodeRay::Duo[:ruby, :page].highlight 'bla 42'
+ #
+ # streaming:
+ # CodeRay::Duo[:ruby, :page].highlight 'bar 23', :stream => true
+ #
+ # with options:
+ # CodeRay::Duo[:ruby, :html, :hint => :debug].highlight '????::??'
+ #
+ # alternative syntax without options:
+ # CodeRay::Duo[:ruby => :statistic].encode 'class << self; end'
+ #
+ # alternative syntax with options:
+ # CodeRay::Duo[{ :ruby => :statistic }, :do => :something].encode 'abc'
+ #
+ # The options are forwarded to scanner and encoder
+ # (see CodeRay.get_scanner_options).
+ def initialize lang = nil, format = nil, options = {}
+ if format == nil and lang.is_a? Hash and lang.size == 1
+ @lang = lang.keys.first
+ @format = lang[@lang]
+ else
+ @lang = lang
+ @format = format
+ end
+ @options = options
+ end
+
+ class << self
+ # To allow calls like Duo[:ruby, :html].highlight.
+ alias [] new
+ end
+
+ # The scanner of the duo. Only created once.
+ def scanner
+ @scanner ||= CodeRay.scanner @lang, CodeRay.get_scanner_options(@options)
+ end
+
+ # The encoder of the duo. Only created once.
+ def encoder
+ @encoder ||= CodeRay.encoder @format, @options
+ end
+
+ # Tokenize and highlight the code using +scanner+ and +encoder+.
+ #
+ # If the :stream option is set, the Duo will go into streaming mode,
+ # saving memory for the cost of time.
+ def encode code, options = { :stream => false }
+ stream = options.delete :stream
+ options = @options.merge options
+ if stream
+ encoder.encode_stream(code, @lang, options)
+ else
+ scanner.code = code
+ encoder.encode_tokens(scanner.tokenize, options)
+ end
+ end
+ alias highlight encode
+
+ end
+
+end
+
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoder.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoder.rb
new file mode 100644
index 000000000..8e67172ca
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoder.rb
@@ -0,0 +1,177 @@
+require "stringio"
+
+module CodeRay
+
+ # This module holds the Encoder class and its subclasses.
+ # For example, the HTML encoder is named CodeRay::Encoders::HTML
+ # can be found in coderay/encoders/html.
+ #
+ # Encoders also provides methods and constants for the register
+ # mechanism and the [] method that returns the Encoder class
+ # belonging to the given format.
+ module Encoders
+ extend PluginHost
+ plugin_path File.dirname(__FILE__), 'encoders'
+
+ # = Encoder
+ #
+ # The Encoder base class. Together with Scanner and
+ # Tokens, it forms the highlighting triad.
+ #
+ # Encoder instances take a Tokens object and do something with it.
+ #
+ # The most common Encoder is surely the HTML encoder
+ # (CodeRay::Encoders::HTML). It highlights the code in a colorful
+ # html page.
+ # If you want the highlighted code in a div or a span instead,
+ # use its subclasses Div and Span.
+ class Encoder
+ extend Plugin
+ plugin_host Encoders
+
+ attr_reader :token_stream
+
+ class << self
+
+ # Returns if the Encoder can be used in streaming mode.
+ def streamable?
+ is_a? Streamable
+ end
+
+ # If FILE_EXTENSION isn't defined, this method returns the
+ # downcase class name instead.
+ def const_missing sym
+ if sym == :FILE_EXTENSION
+ plugin_id
+ else
+ super
+ end
+ end
+
+ end
+
+ # Subclasses are to store their default options in this constant.
+ DEFAULT_OPTIONS = { :stream => false }
+
+ # The options you gave the Encoder at creating.
+ attr_accessor :options
+
+ # Creates a new Encoder.
+ # +options+ is saved and used for all encode operations, as long
+ # as you don't overwrite it there by passing additional options.
+ #
+ # Encoder objects provide three encode methods:
+ # - encode simply takes a +code+ string and a +lang+
+ # - encode_tokens expects a +tokens+ object instead
+ # - encode_stream is like encode, but uses streaming mode.
+ #
+ # Each method has an optional +options+ parameter. These are
+ # added to the options you passed at creation.
+ def initialize options = {}
+ @options = self.class::DEFAULT_OPTIONS.merge options
+ raise "I am only the basic Encoder class. I can't encode "\
+ "anything. :( Use my subclasses." if self.class == Encoder
+ end
+
+ # Encode a Tokens object.
+ def encode_tokens tokens, options = {}
+ options = @options.merge options
+ setup options
+ compile tokens, options
+ finish options
+ end
+
+ # Encode the given +code+ after tokenizing it using the Scanner
+ # for +lang+.
+ def encode code, lang, options = {}
+ options = @options.merge options
+ scanner_options = CodeRay.get_scanner_options(options)
+ tokens = CodeRay.scan code, lang, scanner_options
+ encode_tokens tokens, options
+ end
+
+ # You can use highlight instead of encode, if that seems
+ # more clear to you.
+ alias highlight encode
+
+ # Encode the given +code+ using the Scanner for +lang+ in
+ # streaming mode.
+ def encode_stream code, lang, options = {}
+ raise NotStreamableError, self unless kind_of? Streamable
+ options = @options.merge options
+ setup options
+ scanner_options = CodeRay.get_scanner_options options
+ @token_stream =
+ CodeRay.scan_stream code, lang, scanner_options, &self
+ finish options
+ end
+
+ # Behave like a proc. The token method is converted to a proc.
+ def to_proc
+ method(:token).to_proc
+ end
+
+ # Return the default file extension for outputs of this encoder.
+ def file_extension
+ self.class::FILE_EXTENSION
+ end
+
+ protected
+
+ # Called with merged options before encoding starts.
+ # Sets @out to an empty string.
+ #
+ # See the HTML Encoder for an example of option caching.
+ def setup options
+ @out = ''
+ end
+
+ # Called with +text+ and +kind+ of the currently scanned token.
+ # For simple scanners, it's enougth to implement this method.
+ #
+ # By default, it calls text_token or block_token, depending on
+ # whether +text+ is a String.
+ def token text, kind
+ out =
+ if text.is_a? ::String # Ruby 1.9: :open.is_a? String
+ text_token text, kind
+ elsif text.is_a? ::Symbol
+ block_token text, kind
+ else
+ raise 'Unknown token text type: %p' % text
+ end
+ @out << out if @out
+ end
+
+ def text_token text, kind
+ end
+
+ def block_token action, kind
+ case action
+ when :open
+ open_token kind
+ when :close
+ close_token kind
+ else
+ raise 'unknown block action: %p' % action
+ end
+ end
+
+ # Called with merged options after encoding starts.
+ # The return value is the result of encoding, typically @out.
+ def finish options
+ @out
+ end
+
+ # Do the encoding.
+ #
+ # The already created +tokens+ object must be used; it can be a
+ # TokenStream or a Tokens object.
+ def compile tokens, options
+ tokens.each(&self)
+ end
+
+ end
+
+ end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/_map.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/_map.rb
new file mode 100644
index 000000000..8e9732b05
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/_map.rb
@@ -0,0 +1,9 @@
+module CodeRay
+module Encoders
+
+ map :stats => :statistic,
+ :plain => :text,
+ :tex => :latex
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/count.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/count.rb
new file mode 100644
index 000000000..c9a6dfdea
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/count.rb
@@ -0,0 +1,21 @@
+module CodeRay
+module Encoders
+
+ class Count < Encoder
+
+ include Streamable
+ register_for :count
+
+ protected
+
+ def setup options
+ @out = 0
+ end
+
+ def token text, kind
+ @out += 1
+ end
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/debug.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/debug.rb
new file mode 100644
index 000000000..8e1c0f01a
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/debug.rb
@@ -0,0 +1,41 @@
+module CodeRay
+module Encoders
+
+ # = Debug Encoder
+ #
+ # Fast encoder producing simple debug output.
+ #
+ # It is readable and diff-able and is used for testing.
+ #
+ # You cannot fully restore the tokens information from the
+ # output, because consecutive :space tokens are merged.
+ # Use Tokens#dump for caching purposes.
+ class Debug < Encoder
+
+ include Streamable
+ register_for :debug
+
+ FILE_EXTENSION = 'raydebug'
+
+ protected
+ def text_token text, kind
+ if kind == :space
+ text
+ else
+ text = text.gsub(/[)\\]/, '\\\\\0') # escape ) and \
+ "#{kind}(#{text})"
+ end
+ end
+
+ def open_token kind
+ "#{kind}<"
+ end
+
+ def close_token kind
+ ">"
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/div.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/div.rb
new file mode 100644
index 000000000..3d55415f7
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/div.rb
@@ -0,0 +1,20 @@
+module CodeRay
+module Encoders
+
+ load :html
+
+ class Div < HTML
+
+ FILE_EXTENSION = 'div.html'
+
+ register_for :div
+
+ DEFAULT_OPTIONS = HTML::DEFAULT_OPTIONS.merge({
+ :css => :style,
+ :wrap => :div,
+ })
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html.rb
new file mode 100644
index 000000000..f0a123ed8
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html.rb
@@ -0,0 +1,268 @@
+require "set"
+
+module CodeRay
+module Encoders
+
+ # = HTML Encoder
+ #
+ # This is CodeRay's most important highlighter:
+ # It provides save, fast XHTML generation and CSS support.
+ #
+ # == Usage
+ #
+ # require 'coderay'
+ # puts CodeRay.scan('Some /code/', :ruby).html #-> a HTML page
+ # puts CodeRay.scan('Some /code/', :ruby).html(:wrap => :span)
+ # #->
Some /code/
+ # puts CodeRay.scan('Some /code/', :ruby).span #-> the same
+ #
+ # puts CodeRay.scan('Some code', :ruby).html(
+ # :wrap => nil,
+ # :line_numbers => :inline,
+ # :css => :style
+ # )
+ # #->
1 Some code
+ #
+ # == Options
+ #
+ # === :escape
+ # Escape html entities
+ # Default: true
+ #
+ # === :tab_width
+ # Convert \t characters to +n+ spaces (a number.)
+ # Default: 8
+ #
+ # === :css
+ # How to include the styles; can be :class or :style.
+ #
+ # Default: :class
+ #
+ # === :wrap
+ # Wrap in :page, :div, :span or nil.
+ #
+ # You can also use Encoders::Div and Encoders::Span.
+ #
+ # Default: nil
+ #
+ # === :line_numbers
+ # Include line numbers in :table, :inline, :list or nil (no line numbers)
+ #
+ # Default: nil
+ #
+ # === :line_number_start
+ # Where to start with line number counting.
+ #
+ # Default: 1
+ #
+ # === :bold_every
+ # Make every +n+-th number appear bold.
+ #
+ # Default: 10
+ #
+ # === :hint
+ # Include some information into the output using the title attribute.
+ # Can be :info (show token type on mouse-over), :info_long (with full path)
+ # or :debug (via inspect).
+ #
+ # Default: false
+ class HTML < Encoder
+
+ include Streamable
+ register_for :html
+
+ FILE_EXTENSION = 'html'
+
+ DEFAULT_OPTIONS = {
+ :escape => true,
+ :tab_width => 8,
+
+ :level => :xhtml,
+ :css => :class,
+
+ :style => :cycnus,
+
+ :wrap => nil,
+
+ :line_numbers => nil,
+ :line_number_start => 1,
+ :bold_every => 10,
+
+ :hint => false,
+ }
+
+ helper :output, :css
+
+ attr_reader :css
+
+ protected
+
+ HTML_ESCAPE = { #:nodoc:
+ '&' => '&',
+ '"' => '"',
+ '>' => '>',
+ '<' => '<',
+ }
+
+ # This was to prevent illegal HTML.
+ # Strange chars should still be avoided in codes.
+ evil_chars = Array(0x00...0x20) - [?\n, ?\t, ?\s]
+ evil_chars.each { |i| HTML_ESCAPE[i.chr] = ' ' }
+ #ansi_chars = Array(0x7f..0xff)
+ #ansi_chars.each { |i| HTML_ESCAPE[i.chr] = '%d;' % i }
+ # \x9 (\t) and \xA (\n) not included
+ #HTML_ESCAPE_PATTERN = /[\t&"><\0-\x8\xB-\x1f\x7f-\xff]/
+ HTML_ESCAPE_PATTERN = /[\t"&><\0-\x8\xB-\x1f]/
+
+ TOKEN_KIND_TO_INFO = Hash.new { |h, kind|
+ h[kind] =
+ case kind
+ when :pre_constant
+ 'Predefined constant'
+ else
+ kind.to_s.gsub(/_/, ' ').gsub(/\b\w/) { $&.capitalize }
+ end
+ }
+
+ TRANSPARENT_TOKEN_KINDS = [
+ :delimiter, :modifier, :content, :escape, :inline_delimiter,
+ ].to_set
+
+ # Generate a hint about the given +classes+ in a +hint+ style.
+ #
+ # +hint+ may be :info, :info_long or :debug.
+ def self.token_path_to_hint hint, classes
+ title =
+ case hint
+ when :info
+ TOKEN_KIND_TO_INFO[classes.first]
+ when :info_long
+ classes.reverse.map { |kind| TOKEN_KIND_TO_INFO[kind] }.join('/')
+ when :debug
+ classes.inspect
+ end
+ " title=\"#{title}\""
+ end
+
+ def setup options
+ super
+
+ @HTML_ESCAPE = HTML_ESCAPE.dup
+ @HTML_ESCAPE["\t"] = ' ' * options[:tab_width]
+
+ @escape = options[:escape]
+ @opened = [nil]
+ @css = CSS.new options[:style]
+
+ hint = options[:hint]
+ if hint and not [:debug, :info, :info_long].include? hint
+ raise ArgumentError, "Unknown value %p for :hint; \
+ expected :info, :debug, false, or nil." % hint
+ end
+
+ case options[:css]
+
+ when :class
+ @css_style = Hash.new do |h, k|
+ c = Tokens::ClassOfKind[k.first]
+ if c == :NO_HIGHLIGHT and not hint
+ h[k.dup] = false
+ else
+ title = if hint
+ HTML.token_path_to_hint(hint, k[1..-1] << k.first)
+ else
+ ''
+ end
+ if c == :NO_HIGHLIGHT
+ h[k.dup] = '
' % [title]
+ else
+ h[k.dup] = '' % [title, c]
+ end
+ end
+ end
+
+ when :style
+ @css_style = Hash.new do |h, k|
+ if k.is_a? ::Array
+ styles = k.dup
+ else
+ styles = [k]
+ end
+ type = styles.first
+ classes = styles.map { |c| Tokens::ClassOfKind[c] }
+ if classes.first == :NO_HIGHLIGHT and not hint
+ h[k] = false
+ else
+ styles.shift if TRANSPARENT_TOKEN_KINDS.include? styles.first
+ title = HTML.token_path_to_hint hint, styles
+ style = @css[*classes]
+ h[k] =
+ if style
+ '' % [title, style]
+ else
+ false
+ end
+ end
+ end
+
+ else
+ raise ArgumentError, "Unknown value %p for :css." % options[:css]
+
+ end
+ end
+
+ def finish options
+ not_needed = @opened.shift
+ @out << ' ' * @opened.size
+ unless @opened.empty?
+ warn '%d tokens still open: %p' % [@opened.size, @opened]
+ end
+
+ @out.extend Output
+ @out.css = @css
+ @out.numerize! options[:line_numbers], options
+ @out.wrap! options[:wrap]
+
+ super
+ end
+
+ def token text, type
+ if text.is_a? ::String
+ if @escape && (text =~ /#{HTML_ESCAPE_PATTERN}/o)
+ text = text.gsub(/#{HTML_ESCAPE_PATTERN}/o) { |m| @HTML_ESCAPE[m] }
+ end
+ @opened[0] = type
+ if style = @css_style[@opened]
+ @out << style << text << ' '
+ else
+ @out << text
+ end
+ else
+ case text
+ when :open
+ @opened[0] = type
+ @out << (@css_style[@opened] || '')
+ @opened << type
+ when :close
+ if @opened.empty?
+ # nothing to close
+ else
+ if $DEBUG and (@opened.size == 1 or @opened.last != type)
+ raise 'Malformed token stream: Trying to close a token (%p) \
+ that is not open. Open are: %p.' % [type, @opened[1..-1]]
+ end
+ @out << ' '
+ @opened.pop
+ end
+ when nil
+ raise 'Token with nil as text was given: %p' % [[text, type]]
+ else
+ raise 'unknown token kind: %p' % text
+ end
+ end
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html/css.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html/css.rb
new file mode 100644
index 000000000..d5776027f
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html/css.rb
@@ -0,0 +1,65 @@
+module CodeRay
+module Encoders
+
+ class HTML
+ class CSS
+
+ attr :stylesheet
+
+ def CSS.load_stylesheet style = nil
+ CodeRay::Styles[style]
+ end
+
+ def initialize style = :default
+ @classes = Hash.new
+ style = CSS.load_stylesheet style
+ @stylesheet = [
+ style::CSS_MAIN_STYLES,
+ style::TOKEN_COLORS.gsub(/^(?!$)/, '.CodeRay ')
+ ].join("\n")
+ parse style::TOKEN_COLORS
+ end
+
+ def [] *styles
+ cl = @classes[styles.first]
+ return '' unless cl
+ style = ''
+ 1.upto(styles.size) do |offset|
+ break if style = cl[styles[offset .. -1]]
+ end
+ raise 'Style not found: %p' % [styles] if $DEBUG and style.empty?
+ return style
+ end
+
+ private
+
+ CSS_CLASS_PATTERN = /
+ ( (?: # $1 = classes
+ \s* \. [-\w]+
+ )+ )
+ \s* \{ \s*
+ ( [^\}]+ )? # $2 = style
+ \s* \} \s*
+ |
+ ( . ) # $3 = error
+ /mx
+ def parse stylesheet
+ stylesheet.scan CSS_CLASS_PATTERN do |classes, style, error|
+ raise "CSS parse error: '#{error.inspect}' not recognized" if error
+ styles = classes.scan(/[-\w]+/)
+ cl = styles.pop
+ @classes[cl] ||= Hash.new
+ @classes[cl][styles] = style.to_s.strip
+ end
+ end
+
+ end
+ end
+
+end
+end
+
+if $0 == __FILE__
+ require 'pp'
+ pp CodeRay::Encoders::HTML::CSS.new
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html/numerization.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html/numerization.rb
new file mode 100644
index 000000000..1e4a4ed53
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html/numerization.rb
@@ -0,0 +1,122 @@
+module CodeRay
+module Encoders
+
+ class HTML
+
+ module Output
+
+ def numerize *args
+ clone.numerize!(*args)
+ end
+
+=begin NUMERIZABLE_WRAPPINGS = {
+ :table => [:div, :page, nil],
+ :inline => :all,
+ :list => [:div, :page, nil]
+ }
+ NUMERIZABLE_WRAPPINGS.default = :all
+=end
+ def numerize! mode = :table, options = {}
+ return self unless mode
+
+ options = DEFAULT_OPTIONS.merge options
+
+ start = options[:line_number_start]
+ unless start.is_a? Integer
+ raise ArgumentError, "Invalid value %p for :line_number_start; Integer expected." % start
+ end
+
+ #allowed_wrappings = NUMERIZABLE_WRAPPINGS[mode]
+ #unless allowed_wrappings == :all or allowed_wrappings.include? options[:wrap]
+ # raise ArgumentError, "Can't numerize, :wrap must be in %p, but is %p" % [NUMERIZABLE_WRAPPINGS, options[:wrap]]
+ #end
+
+ bold_every = options[:bold_every]
+ bolding =
+ if bold_every == false
+ proc { |line| line.to_s }
+ elsif bold_every.is_a? Integer
+ raise ArgumentError, ":bolding can't be 0." if bold_every == 0
+ proc do |line|
+ if line % bold_every == 0
+ "#{line} " # every bold_every-th number in bold
+ else
+ line.to_s
+ end
+ end
+ else
+ raise ArgumentError, 'Invalid value %p for :bolding; false or Integer expected.' % bold_every
+ end
+
+ case mode
+ when :inline
+ max_width = (start + line_count).to_s.size
+ line = start
+ gsub!(/^/) do
+ line_number = bolding.call line
+ indent = ' ' * (max_width - line.to_s.size)
+ res = "#{indent}#{line_number} "
+ line += 1
+ res
+ end
+
+ when :table
+ # This is really ugly.
+ # Because even monospace fonts seem to have different heights when bold,
+ # I make the newline bold, both in the code and the line numbers.
+ # FIXME Still not working perfect for Mr. Internet Exploder
+ # FIXME Firefox struggles with very long codes (> 200 lines)
+ line_numbers = (start ... start + line_count).to_a.map(&bolding).join("\n")
+ line_numbers << "\n" # also for Mr. MS Internet Exploder :-/
+ line_numbers.gsub!(/\n/) { "\n " }
+
+ line_numbers_table_tpl = TABLE.apply('LINE_NUMBERS', line_numbers)
+ gsub!(/\n/) { "\n " }
+ wrap_in! line_numbers_table_tpl
+ @wrapped_in = :div
+
+ when :list
+ opened_tags = []
+ gsub!(/^.*$\n?/) do |line|
+ line.chomp!
+
+ open = opened_tags.join
+ line.scan(%r!<(/)?span[^>]*>?!) do |close,|
+ if close
+ opened_tags.pop
+ else
+ opened_tags << $&
+ end
+ end
+ close = ' ' * opened_tags.size
+
+ "
#{open}#{line}#{close} "
+ end
+ wrap_in! LIST
+ @wrapped_in = :div
+
+ else
+ raise ArgumentError, 'Unknown value %p for mode: expected one of %p' %
+ [mode, [:table, :list, :inline]]
+ end
+
+ self
+ end
+
+ def line_count
+ line_count = count("\n")
+ position_of_last_newline = rindex(?\n)
+ if position_of_last_newline
+ after_last_newline = self[position_of_last_newline + 1 .. -1]
+ ends_with_newline = after_last_newline[/\A(?:<\/span>)*\z/]
+ line_count += 1 if not ends_with_newline
+ end
+ line_count
+ end
+
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html/output.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html/output.rb
new file mode 100644
index 000000000..e74e55e6e
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/html/output.rb
@@ -0,0 +1,195 @@
+module CodeRay
+module Encoders
+
+ class HTML
+
+ # This module is included in the output String from thew HTML Encoder.
+ #
+ # It provides methods like wrap, div, page etc.
+ #
+ # Remember to use #clone instead of #dup to keep the modules the object was
+ # extended with.
+ #
+ # TODO: more doc.
+ module Output
+
+ require 'coderay/encoders/html/numerization.rb'
+
+ attr_accessor :css
+
+ class << self
+
+ # This makes Output look like a class.
+ #
+ # Example:
+ #
+ # a = Output.new '
Code '
+ # a.wrap! :page
+ def new string, css = CSS.new, element = nil
+ output = string.clone.extend self
+ output.wrapped_in = element
+ output.css = css
+ output
+ end
+
+ # Raises an exception if an object that doesn't respond to to_str is extended by Output,
+ # to prevent users from misuse. Use Module#remove_method to disable.
+ def extended o
+ warn "The Output module is intended to extend instances of String, not #{o.class}." unless o.respond_to? :to_str
+ end
+
+ def make_stylesheet css, in_tag = false
+ sheet = css.stylesheet
+ sheet = <<-CSS if in_tag
+
+ CSS
+ sheet
+ end
+
+ def page_template_for_css css
+ sheet = make_stylesheet css
+ PAGE.apply 'CSS', sheet
+ end
+
+ # Define a new wrapper. This is meta programming.
+ def wrapper *wrappers
+ wrappers.each do |wrapper|
+ define_method wrapper do |*args|
+ wrap wrapper, *args
+ end
+ define_method "#{wrapper}!".to_sym do |*args|
+ wrap! wrapper, *args
+ end
+ end
+ end
+
+ end
+
+ wrapper :div, :span, :page
+
+ def wrapped_in? element
+ wrapped_in == element
+ end
+
+ def wrapped_in
+ @wrapped_in ||= nil
+ end
+ attr_writer :wrapped_in
+
+ def wrap_in template
+ clone.wrap_in! template
+ end
+
+ def wrap_in! template
+ Template.wrap! self, template, 'CONTENT'
+ self
+ end
+
+ def wrap! element, *args
+ return self if not element or element == wrapped_in
+ case element
+ when :div
+ raise "Can't wrap %p in %p" % [wrapped_in, element] unless wrapped_in? nil
+ wrap_in! DIV
+ when :span
+ raise "Can't wrap %p in %p" % [wrapped_in, element] unless wrapped_in? nil
+ wrap_in! SPAN
+ when :page
+ wrap! :div if wrapped_in? nil
+ raise "Can't wrap %p in %p" % [wrapped_in, element] unless wrapped_in? :div
+ wrap_in! Output.page_template_for_css(@css)
+ when nil
+ return self
+ else
+ raise "Unknown value %p for :wrap" % element
+ end
+ @wrapped_in = element
+ self
+ end
+
+ def wrap *args
+ clone.wrap!(*args)
+ end
+
+ def stylesheet in_tag = false
+ Output.make_stylesheet @css, in_tag
+ end
+
+ class Template < String
+
+ def self.wrap! str, template, target
+ target = Regexp.new(Regexp.escape("<%#{target}%>"))
+ if template =~ target
+ str[0,0] = $`
+ str << $'
+ else
+ raise "Template target <%%%p%%> not found" % target
+ end
+ end
+
+ def apply target, replacement
+ target = Regexp.new(Regexp.escape("<%#{target}%>"))
+ if self =~ target
+ Template.new($` + replacement + $')
+ else
+ raise "Template target <%%%p%%> not found" % target
+ end
+ end
+
+ module Simple
+ def ` str #` <-- for stupid editors
+ Template.new str
+ end
+ end
+ end
+
+ extend Template::Simple
+
+#-- don't include the templates in docu
+
+ SPAN = `
<%CONTENT%> `
+
+ DIV = <<-`DIV`
+
+ DIV
+
+ TABLE = <<-`TABLE`
+
+ <%LINE_NUMBERS%>
+ <%CONTENT%>
+
+ TABLE
+ # title="double click to expand"
+
+ LIST = <<-`LIST`
+
<%CONTENT%>
+ LIST
+
+ PAGE = <<-`PAGE`
+
+
+
+
+
CodeRay HTML Encoder Example
+
+
+
+
+<%CONTENT%>
+
+
+ PAGE
+
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/null.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/null.rb
new file mode 100644
index 000000000..add3862a3
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/null.rb
@@ -0,0 +1,26 @@
+module CodeRay
+module Encoders
+
+ # = Null Encoder
+ #
+ # Does nothing and returns an empty string.
+ class Null < Encoder
+
+ include Streamable
+ register_for :null
+
+ # Defined for faster processing
+ def to_proc
+ proc {}
+ end
+
+ protected
+
+ def token(*)
+ # do nothing
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/page.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/page.rb
new file mode 100644
index 000000000..c08f09468
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/page.rb
@@ -0,0 +1,21 @@
+module CodeRay
+module Encoders
+
+ load :html
+
+ class Page < HTML
+
+ FILE_EXTENSION = 'html'
+
+ register_for :page
+
+ DEFAULT_OPTIONS = HTML::DEFAULT_OPTIONS.merge({
+ :css => :class,
+ :wrap => :page,
+ :line_numbers => :table
+ })
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/span.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/span.rb
new file mode 100644
index 000000000..988afec17
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/span.rb
@@ -0,0 +1,20 @@
+module CodeRay
+module Encoders
+
+ load :html
+
+ class Span < HTML
+
+ FILE_EXTENSION = 'span.html'
+
+ register_for :span
+
+ DEFAULT_OPTIONS = HTML::DEFAULT_OPTIONS.merge({
+ :css => :style,
+ :wrap => :span,
+ })
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/statistic.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/statistic.rb
new file mode 100644
index 000000000..6d0c64680
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/statistic.rb
@@ -0,0 +1,77 @@
+module CodeRay
+module Encoders
+
+ # Makes a statistic for the given tokens.
+ class Statistic < Encoder
+
+ include Streamable
+ register_for :stats, :statistic
+
+ attr_reader :type_stats, :real_token_count
+
+ protected
+
+ TypeStats = Struct.new :count, :size
+
+ def setup options
+ @type_stats = Hash.new { |h, k| h[k] = TypeStats.new 0, 0 }
+ @real_token_count = 0
+ end
+
+ def generate tokens, options
+ @tokens = tokens
+ super
+ end
+
+ def text_token text, kind
+ @real_token_count += 1 unless kind == :space
+ @type_stats[kind].count += 1
+ @type_stats[kind].size += text.size
+ @type_stats['TOTAL'].size += text.size
+ @type_stats['TOTAL'].count += 1
+ end
+
+ # TODO Hierarchy handling
+ def block_token action, kind
+ @type_stats['TOTAL'].count += 1
+ @type_stats['open/close'].count += 1
+ end
+
+ STATS = <<-STATS
+
+Code Statistics
+
+Tokens %8d
+ Non-Whitespace %8d
+Bytes Total %8d
+
+Token Types (%d):
+ type count ratio size (average)
+-------------------------------------------------------------
+%s
+ STATS
+# space 12007 33.81 % 1.7
+ TOKEN_TYPES_ROW = <<-TKR
+ %-20s %8d %6.2f %% %5.1f
+ TKR
+
+ def finish options
+ all = @type_stats['TOTAL']
+ all_count, all_size = all.count, all.size
+ @type_stats.each do |type, stat|
+ stat.size /= stat.count.to_f
+ end
+ types_stats = @type_stats.sort_by { |k, v| [-v.count, k.to_s] }.map do |k, v|
+ TOKEN_TYPES_ROW % [k, v.count, 100.0 * v.count / all_count, v.size]
+ end.join
+ STATS % [
+ all_count, @real_token_count, all_size,
+ @type_stats.delete_if { |k, v| k.is_a? String }.size,
+ types_stats
+ ]
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/text.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/text.rb
new file mode 100644
index 000000000..14282ac5f
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/text.rb
@@ -0,0 +1,32 @@
+module CodeRay
+module Encoders
+
+ class Text < Encoder
+
+ include Streamable
+ register_for :text
+
+ FILE_EXTENSION = 'txt'
+
+ DEFAULT_OPTIONS = {
+ :separator => ''
+ }
+
+ protected
+ def setup options
+ @out = ''
+ @sep = options[:separator]
+ end
+
+ def token text, kind
+ @out << text + @sep if text.is_a? ::String
+ end
+
+ def finish options
+ @out.chomp @sep
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/tokens.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/tokens.rb
new file mode 100644
index 000000000..27c7f6d5a
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/tokens.rb
@@ -0,0 +1,44 @@
+module CodeRay
+module Encoders
+
+ # The Tokens encoder converts the tokens to a simple
+ # readable format. It doesn't use colors and is mainly
+ # intended for console output.
+ #
+ # The tokens are converted with Tokens.write_token.
+ #
+ # The format is:
+ #
+ #
\t \n
+ #
+ # Example:
+ #
+ # require 'coderay'
+ # puts CodeRay.scan("puts 3 + 4", :ruby).tokens
+ #
+ # prints:
+ #
+ # ident puts
+ # space
+ # integer 3
+ # space
+ # operator +
+ # space
+ # integer 4
+ #
+ class Tokens < Encoder
+
+ include Streamable
+ register_for :tokens
+
+ FILE_EXTENSION = 'tok'
+
+ protected
+ def token text, kind
+ @out << CodeRay::Tokens.write_token(text, kind)
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/xml.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/xml.rb
new file mode 100644
index 000000000..dffa98c36
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/xml.rb
@@ -0,0 +1,70 @@
+module CodeRay
+module Encoders
+
+ # = XML Encoder
+ #
+ # Uses REXML. Very slow.
+ class XML < Encoder
+
+ include Streamable
+ register_for :xml
+
+ FILE_EXTENSION = 'xml'
+
+ require 'rexml/document'
+
+ DEFAULT_OPTIONS = {
+ :tab_width => 8,
+ :pretty => -1,
+ :transitive => false,
+ }
+
+ protected
+
+ def setup options
+ @doc = REXML::Document.new
+ @doc << REXML::XMLDecl.new
+ @tab_width = options[:tab_width]
+ @root = @node = @doc.add_element('coderay-tokens')
+ end
+
+ def finish options
+ @doc.write @out, options[:pretty], options[:transitive], true
+ @out
+ end
+
+ def text_token text, kind
+ if kind == :space
+ token = @node
+ else
+ token = @node.add_element kind.to_s
+ end
+ text.scan(/(\x20+)|(\t+)|(\n)|[^\x20\t\n]+/) do |space, tab, nl|
+ case
+ when space
+ token << REXML::Text.new(space, true)
+ when tab
+ token << REXML::Text.new(tab, true)
+ when nl
+ token << REXML::Text.new(nl, true)
+ else
+ token << REXML::Text.new($&)
+ end
+ end
+ end
+
+ def open_token kind
+ @node = @node.add_element kind.to_s
+ end
+
+ def close_token kind
+ if @node == @root
+ raise 'no token to close!'
+ end
+ @node = @node.parent
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/yaml.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/yaml.rb
new file mode 100644
index 000000000..5564e58a4
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/encoders/yaml.rb
@@ -0,0 +1,22 @@
+module CodeRay
+module Encoders
+
+ # = YAML Encoder
+ #
+ # Slow.
+ class YAML < Encoder
+
+ register_for :yaml
+
+ FILE_EXTENSION = 'yaml'
+
+ protected
+ def compile tokens, options
+ require 'yaml'
+ @out = tokens.to_a.to_yaml
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/file_type.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/file_type.rb
new file mode 100644
index 000000000..41b6c2ef2
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/file_type.rb
@@ -0,0 +1,190 @@
+module CodeRay
+
+# = FileType
+#
+# A simple filetype recognizer.
+#
+# Copyright (c) 2006 by murphy (Kornelius Kalnbach)
+#
+# License:: LGPL / ask the author
+# Version:: 0.1 (2005-09-01)
+#
+# == Documentation
+#
+# # determine the type of the given
+# lang = FileType[ARGV.first]
+#
+# # return :plaintext if the file type is unknown
+# lang = FileType.fetch ARGV.first, :plaintext
+#
+# # try the shebang line, too
+# lang = FileType.fetch ARGV.first, :plaintext, true
+module FileType
+
+ UnknownFileType = Class.new Exception
+
+ class << self
+
+ # Try to determine the file type of the file.
+ #
+ # +filename+ is a relative or absolute path to a file.
+ #
+ # The file itself is only accessed when +read_shebang+ is set to true.
+ # That means you can get filetypes from files that don't exist.
+ def [] filename, read_shebang = false
+ name = File.basename filename
+ ext = File.extname name
+ ext.sub!(/^\./, '') # delete the leading dot
+
+ type =
+ TypeFromExt[ext] ||
+ TypeFromExt[ext.downcase] ||
+ TypeFromName[name] ||
+ TypeFromName[name.downcase]
+ type ||= shebang(filename) if read_shebang
+
+ type
+ end
+
+ def shebang filename
+ begin
+ File.open filename, 'r' do |f|
+ first_line = f.gets
+ first_line[TypeFromShebang]
+ end
+ rescue IOError
+ nil
+ end
+ end
+
+ # This works like Hash#fetch.
+ #
+ # If the filetype cannot be found, the +default+ value
+ # is returned.
+ def fetch filename, default = nil, read_shebang = false
+ if default and block_given?
+ warn 'block supersedes default value argument'
+ end
+
+ unless type = self[filename, read_shebang]
+ return yield if block_given?
+ return default if default
+ raise UnknownFileType, 'Could not determine type of %p.' % filename
+ end
+ type
+ end
+
+ end
+
+ TypeFromExt = {
+ 'rb' => :ruby,
+ 'rbw' => :ruby,
+ 'rake' => :ruby,
+ 'mab' => :ruby,
+ 'cpp' => :c,
+ 'c' => :c,
+ 'h' => :c,
+ 'js' => :javascript,
+ 'xml' => :xml,
+ 'htm' => :html,
+ 'html' => :html,
+ 'xhtml' => :xhtml,
+ 'raydebug' => :debug,
+ 'rhtml' => :rhtml,
+ 'ss' => :scheme,
+ 'sch' => :scheme,
+ 'yaml' => :yaml,
+ 'yml' => :yaml,
+ }
+
+ TypeFromShebang = /\b(?:ruby|perl|python|sh)\b/
+
+ TypeFromName = {
+ 'Rakefile' => :ruby,
+ 'Rantfile' => :ruby,
+ }
+
+end
+
+end
+
+if $0 == __FILE__
+ $VERBOSE = true
+ eval DATA.read, nil, $0, __LINE__+4
+end
+
+__END__
+
+require 'test/unit'
+
+class TC_FileType < Test::Unit::TestCase
+
+ def test_fetch
+ assert_raise FileType::UnknownFileType do
+ FileType.fetch ''
+ end
+
+ assert_throws :not_found do
+ FileType.fetch '.' do
+ throw :not_found
+ end
+ end
+
+ assert_equal :default, FileType.fetch('c', :default)
+
+ stderr, fake_stderr = $stderr, Object.new
+ $err = ''
+ def fake_stderr.write x
+ $err << x
+ end
+ $stderr = fake_stderr
+ FileType.fetch('c', :default) { }
+ assert_equal "block supersedes default value argument\n", $err
+ $stderr = stderr
+ end
+
+ def test_ruby
+ assert_equal :ruby, FileType['test.rb']
+ assert_equal :ruby, FileType['C:\\Program Files\\x\\y\\c\\test.rbw']
+ assert_equal :ruby, FileType['/usr/bin/something/Rakefile']
+ assert_equal :ruby, FileType['~/myapp/gem/Rantfile']
+ assert_equal :ruby, FileType['./lib/tasks\repository.rake']
+ assert_not_equal :ruby, FileType['test_rb']
+ assert_not_equal :ruby, FileType['Makefile']
+ assert_not_equal :ruby, FileType['set.rb/set']
+ assert_not_equal :ruby, FileType['~/projects/blabla/rb']
+ end
+
+ def test_c
+ assert_equal :c, FileType['test.c']
+ assert_equal :c, FileType['C:\\Program Files\\x\\y\\c\\test.h']
+ assert_not_equal :c, FileType['test_c']
+ assert_not_equal :c, FileType['Makefile']
+ assert_not_equal :c, FileType['set.h/set']
+ assert_not_equal :c, FileType['~/projects/blabla/c']
+ end
+
+ def test_html
+ assert_equal :html, FileType['test.htm']
+ assert_equal :xhtml, FileType['test.xhtml']
+ assert_equal :xhtml, FileType['test.html.xhtml']
+ assert_equal :rhtml, FileType['_form.rhtml']
+ end
+
+ def test_yaml
+ assert_equal :yaml, FileType['test.yml']
+ assert_equal :yaml, FileType['test.yaml']
+ assert_equal :yaml, FileType['my.html.yaml']
+ assert_not_equal :yaml, FileType['YAML']
+ end
+
+ def test_shebang
+ dir = './test'
+ if File.directory? dir
+ Dir.chdir dir do
+ assert_equal :c, FileType['test.c']
+ end
+ end
+ end
+
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/gzip_simple.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/gzip_simple.rb
new file mode 100644
index 000000000..76aeb2274
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/gzip_simple.rb
@@ -0,0 +1,123 @@
+# =GZip Simple
+#
+# A simplified interface to the gzip library +zlib+ (from the Ruby Standard Library.)
+#
+# Author: murphy (mail to murphy cYcnus de)
+#
+# Version: 0.2 (2005.may.28)
+#
+# ==Documentation
+#
+# See +GZip+ module and the +String+ extensions.
+#
+module GZip
+
+ require 'zlib'
+
+ # The default zipping level. 7 zips good and fast.
+ DEFAULT_GZIP_LEVEL = 7
+
+ # Unzips the given string +s+.
+ #
+ # Example:
+ # require 'gzip_simple'
+ # print GZip.gunzip(File.read('adresses.gz'))
+ def GZip.gunzip s
+ Zlib::Inflate.inflate s
+ end
+
+ # Zips the given string +s+.
+ #
+ # Example:
+ # require 'gzip_simple'
+ # File.open('adresses.gz', 'w') do |file
+ # file.write GZip.gzip('Mum: 0123 456 789', 9)
+ # end
+ #
+ # If you provide a +level+, you can control how strong
+ # the string is compressed:
+ # - 0: no compression, only convert to gzip format
+ # - 1: compress fast
+ # - 7: compress more, but still fast (default)
+ # - 8: compress more, slower
+ # - 9: compress best, very slow
+ def GZip.gzip s, level = DEFAULT_GZIP_LEVEL
+ Zlib::Deflate.new(level).deflate s, Zlib::FINISH
+ end
+end
+
+
+# String extensions to use the GZip module.
+#
+# The methods gzip and gunzip provide an even more simple
+# interface to the ZLib:
+#
+# # create a big string
+# x = 'a' * 1000
+#
+# # zip it
+# x_gz = x.gzip
+#
+# # test the result
+# puts 'Zipped %d bytes to %d bytes.' % [x.size, x_gz.size]
+# #-> Zipped 1000 bytes to 19 bytes.
+#
+# # unzipping works
+# p x_gz.gunzip == x #-> true
+class String
+ # Returns the string, unzipped.
+ # See GZip.gunzip
+ def gunzip
+ GZip.gunzip self
+ end
+ # Replaces the string with its unzipped value.
+ # See GZip.gunzip
+ def gunzip!
+ replace gunzip
+ end
+
+ # Returns the string, zipped.
+ # +level+ is the gzip compression level, see GZip.gzip.
+ def gzip level = GZip::DEFAULT_GZIP_LEVEL
+ GZip.gzip self, level
+ end
+ # Replaces the string with its zipped value.
+ # See GZip.gzip.
+ def gzip!(*args)
+ replace gzip(*args)
+ end
+end
+
+if $0 == __FILE__
+ eval DATA.read, nil, $0, __LINE__+4
+end
+
+__END__
+#CODE
+
+# Testing / Benchmark
+x = 'a' * 1000
+x_gz = x.gzip
+puts 'Zipped %d bytes to %d bytes.' % [x.size, x_gz.size] #-> Zipped 1000 bytes to 19 bytes.
+p x_gz.gunzip == x #-> true
+
+require 'benchmark'
+
+INFO = 'packed to %0.3f%%' # :nodoc:
+
+x = Array.new(100000) { rand(255).chr + 'aaaaaaaaa' + rand(255).chr }.join
+Benchmark.bm(10) do |bm|
+ for level in 0..9
+ bm.report "zip #{level}" do
+ $x = x.gzip level
+ end
+ puts INFO % [100.0 * $x.size / x.size]
+ end
+ bm.report 'zip' do
+ $x = x.gzip
+ end
+ puts INFO % [100.0 * $x.size / x.size]
+ bm.report 'unzip' do
+ $x.gunzip
+ end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/plugin.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/plugin.rb
new file mode 100644
index 000000000..29b546ae6
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/plugin.rb
@@ -0,0 +1,329 @@
+module CodeRay
+
+# = PluginHost
+#
+# $Id: plugin.rb 220 2007-01-01 02:58:58Z murphy $
+#
+# A simple subclass plugin system.
+#
+# Example:
+# class Generators < PluginHost
+# plugin_path 'app/generators'
+# end
+#
+# class Generator
+# extend Plugin
+# PLUGIN_HOST = Generators
+# end
+#
+# class FancyGenerator < Generator
+# register_for :fancy
+# end
+#
+# Generators[:fancy] #-> FancyGenerator
+# # or
+# require_plugin 'Generators/fancy'
+module PluginHost
+
+ # Raised if Encoders::[] fails because:
+ # * a file could not be found
+ # * the requested Encoder is not registered
+ PluginNotFound = Class.new Exception
+ HostNotFound = Class.new Exception
+
+ PLUGIN_HOSTS = []
+ PLUGIN_HOSTS_BY_ID = {} # dummy hash
+
+ # Loads all plugins using list and load.
+ def load_all
+ for plugin in list
+ load plugin
+ end
+ end
+
+ # Returns the Plugin for +id+.
+ #
+ # Example:
+ # yaml_plugin = MyPluginHost[:yaml]
+ def [] id, *args, &blk
+ plugin = validate_id(id)
+ begin
+ plugin = plugin_hash.[] plugin, *args, &blk
+ end while plugin.is_a? Symbol
+ plugin
+ end
+
+ # Alias for +[]+.
+ alias load []
+
+ def require_helper plugin_id, helper_name
+ path = path_to File.join(plugin_id, helper_name)
+ require path
+ end
+
+ class << self
+
+ # Adds the module/class to the PLUGIN_HOSTS list.
+ def extended mod
+ PLUGIN_HOSTS << mod
+ end
+
+ # Warns you that you should not #include this module.
+ def included mod
+ warn "#{name} should not be included. Use extend."
+ end
+
+ # Find the PluginHost for host_id.
+ def host_by_id host_id
+ unless PLUGIN_HOSTS_BY_ID.default_proc
+ ph = Hash.new do |h, a_host_id|
+ for host in PLUGIN_HOSTS
+ h[host.host_id] = host
+ end
+ h.fetch a_host_id, nil
+ end
+ PLUGIN_HOSTS_BY_ID.replace ph
+ end
+ PLUGIN_HOSTS_BY_ID[host_id]
+ end
+
+ end
+
+ # The path where the plugins can be found.
+ def plugin_path *args
+ unless args.empty?
+ @plugin_path = File.expand_path File.join(*args)
+ load_map
+ end
+ @plugin_path
+ end
+
+ # The host's ID.
+ #
+ # If PLUGIN_HOST_ID is not set, it is simply the class name.
+ def host_id
+ if self.const_defined? :PLUGIN_HOST_ID
+ self::PLUGIN_HOST_ID
+ else
+ name
+ end
+ end
+
+ # Map a plugin_id to another.
+ #
+ # Usage: Put this in a file plugin_path/_map.rb.
+ #
+ # class MyColorHost < PluginHost
+ # map :navy => :dark_blue,
+ # :maroon => :brown,
+ # :luna => :moon
+ # end
+ def map hash
+ for from, to in hash
+ from = validate_id from
+ to = validate_id to
+ plugin_hash[from] = to unless plugin_hash.has_key? from
+ end
+ end
+
+ # Define the default plugin to use when no plugin is found
+ # for a given id.
+ #
+ # See also map.
+ #
+ # class MyColorHost < PluginHost
+ # map :navy => :dark_blue
+ # default :gray
+ # end
+ def default id
+ id = validate_id id
+ plugin_hash[nil] = id
+ end
+
+ # Every plugin must register itself for one or more
+ # +ids+ by calling register_for, which calls this method.
+ #
+ # See Plugin#register_for.
+ def register plugin, *ids
+ for id in ids
+ unless id.is_a? Symbol
+ raise ArgumentError,
+ "id must be a Symbol, but it was a #{id.class}"
+ end
+ plugin_hash[validate_id(id)] = plugin
+ end
+ end
+
+ # A Hash of plugion_id => Plugin pairs.
+ def plugin_hash
+ @plugin_hash ||= create_plugin_hash
+ end
+
+ # Returns an array of all .rb files in the plugin path.
+ #
+ # The extension .rb is not included.
+ def list
+ Dir[path_to('*')].select do |file|
+ File.basename(file)[/^(?!_)\w+\.rb$/]
+ end.map do |file|
+ File.basename file, '.rb'
+ end
+ end
+
+ # Makes a map of all loaded plugins.
+ def inspect
+ map = plugin_hash.dup
+ map.each do |id, plugin|
+ map[id] = plugin.to_s[/(?>[\w_]+)$/]
+ end
+ "#{name}[#{host_id}]#{map.inspect}"
+ end
+
+protected
+ # Created a new plugin list and stores it to @plugin_hash.
+ def create_plugin_hash
+ @plugin_hash =
+ Hash.new do |h, plugin_id|
+ id = validate_id(plugin_id)
+ path = path_to id
+ begin
+ require path
+ rescue LoadError => boom
+ if h.has_key? nil # default plugin
+ h[id] = h[nil]
+ else
+ raise PluginNotFound, 'Could not load plugin %p: %s' % [id, boom]
+ end
+ else
+ # Plugin should have registered by now
+ unless h.has_key? id
+ raise PluginNotFound,
+ "No #{self.name} plugin for #{id.inspect} found in #{path}."
+ end
+ end
+ h[id]
+ end
+ end
+
+ # Loads the map file (see map).
+ #
+ # This is done automatically when plugin_path is called.
+ def load_map
+ mapfile = path_to '_map'
+ if File.exist? mapfile
+ require mapfile
+ elsif $DEBUG
+ warn 'no _map.rb found for %s' % name
+ end
+ end
+
+ # Returns the Plugin for +id+.
+ # Use it like Hash#fetch.
+ #
+ # Example:
+ # yaml_plugin = MyPluginHost[:yaml, :default]
+ def fetch id, *args, &blk
+ plugin_hash.fetch validate_id(id), *args, &blk
+ end
+
+ # Returns the expected path to the plugin file for the given id.
+ def path_to plugin_id
+ File.join plugin_path, "#{plugin_id}.rb"
+ end
+
+ # Converts +id+ to a Symbol if it is a String,
+ # or returns +id+ if it already is a Symbol.
+ #
+ # Raises +ArgumentError+ for all other objects, or if the
+ # given String includes non-alphanumeric characters (\W).
+ def validate_id id
+ if id.is_a? Symbol or id.nil?
+ id
+ elsif id.is_a? String
+ if id[/\w+/] == id
+ id.to_sym
+ else
+ raise ArgumentError, "Invalid id: '#{id}' given."
+ end
+ else
+ raise ArgumentError,
+ "String or Symbol expected, but #{id.class} given."
+ end
+ end
+
+end
+
+
+# = Plugin
+#
+# Plugins have to include this module.
+#
+# IMPORTANT: use extend for this module.
+#
+# Example: see PluginHost.
+module Plugin
+
+ def included mod
+ warn "#{name} should not be included. Use extend."
+ end
+
+ # Register this class for the given langs.
+ # Example:
+ # class MyPlugin < PluginHost::BaseClass
+ # register_for :my_id
+ # ...
+ # end
+ #
+ # See PluginHost.register.
+ def register_for *ids
+ plugin_host.register self, *ids
+ end
+
+ # The host for this Plugin class.
+ def plugin_host host = nil
+ if host and not host.is_a? PluginHost
+ raise ArgumentError,
+ "PluginHost expected, but #{host.class} given."
+ end
+ self.const_set :PLUGIN_HOST, host if host
+ self::PLUGIN_HOST
+ end
+
+ # Require some helper files.
+ #
+ # Example:
+ #
+ # class MyPlugin < PluginHost::BaseClass
+ # register_for :my_id
+ # helper :my_helper
+ #
+ # The above example loads the file myplugin/my_helper.rb relative to the
+ # file in which MyPlugin was defined.
+ def helper *helpers
+ for helper in helpers
+ self::PLUGIN_HOST.require_helper plugin_id, helper.to_s
+ end
+ end
+
+ # Returns the pulgin id used by the engine.
+ def plugin_id
+ name[/[\w_]+$/].downcase
+ end
+
+end
+
+# Convenience method for plugin loading.
+# The syntax used is:
+#
+# CodeRay.require_plugin '/'
+#
+# Returns the loaded plugin.
+def require_plugin path
+ host_id, plugin_id = path.split '/', 2
+ host = PluginHost.host_by_id(host_id)
+ raise PluginHost::HostNotFound,
+ "No host for #{host_id.inspect} found." unless host
+ host.load plugin_id
+end
+
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/word_list.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/word_list.rb
new file mode 100644
index 000000000..5196a5d68
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/word_list.rb
@@ -0,0 +1,123 @@
+module CodeRay
+
+# = WordList
+#
+# A Hash subclass designed for mapping word lists to token types.
+#
+# Copyright (c) 2006 by murphy (Kornelius Kalnbach)
+#
+# License:: LGPL / ask the author
+# Version:: 1.1 (2006-Oct-19)
+#
+# A WordList is a Hash with some additional features.
+# It is intended to be used for keyword recognition.
+#
+# WordList is highly optimized to be used in Scanners,
+# typically to decide whether a given ident is a special token.
+#
+# For case insensitive words use CaseIgnoringWordList.
+#
+# Example:
+#
+# # define word arrays
+# RESERVED_WORDS = %w[
+# asm break case continue default do else
+# ...
+# ]
+#
+# PREDEFINED_TYPES = %w[
+# int long short char void
+# ...
+# ]
+#
+# PREDEFINED_CONSTANTS = %w[
+# EOF NULL ...
+# ]
+#
+# # make a WordList
+# IDENT_KIND = WordList.new(:ident).
+# add(RESERVED_WORDS, :reserved).
+# add(PREDEFINED_TYPES, :pre_type).
+# add(PREDEFINED_CONSTANTS, :pre_constant)
+#
+# ...
+#
+# def scan_tokens tokens, options
+# ...
+#
+# elsif scan(/[A-Za-z_][A-Za-z_0-9]*/)
+# # use it
+# kind = IDENT_KIND[match]
+# ...
+class WordList < Hash
+
+ # Creates a new WordList with +default+ as default value.
+ #
+ # You can activate +caching+ to store the results for every [] request.
+ #
+ # With caching, methods like +include?+ or +delete+ may no longer behave
+ # as you expect. Therefore, it is recommended to use the [] method only.
+ def initialize default = false, caching = false, &block
+ if block
+ raise ArgumentError, 'Can\'t combine block with caching.' if caching
+ super(&block)
+ else
+ if caching
+ super() do |h, k|
+ h[k] = h.fetch k, default
+ end
+ else
+ super default
+ end
+ end
+ end
+
+ # Add words to the list and associate them with +kind+.
+ #
+ # Returns +self+, so you can concat add calls.
+ def add words, kind = true
+ words.each do |word|
+ self[word] = kind
+ end
+ self
+ end
+
+end
+
+
+# A CaseIgnoringWordList is like a WordList, only that
+# keys are compared case-insensitively.
+#
+# Ignoring the text case is realized by sending the +downcase+ message to
+# all keys.
+#
+# Caching usually makes a CaseIgnoringWordList faster, but it has to be
+# activated explicitely.
+class CaseIgnoringWordList < WordList
+
+ # Creates a new case-insensitive WordList with +default+ as default value.
+ #
+ # You can activate caching to store the results for every [] request.
+ def initialize default = false, caching = false
+ if caching
+ super(default, false) do |h, k|
+ h[k] = h.fetch k.downcase, default
+ end
+ else
+ def self.[] key # :nodoc:
+ super(key.downcase)
+ end
+ end
+ end
+
+ # Add +words+ to the list and associate them with +kind+.
+ def add words, kind = true
+ words.each do |word|
+ self[word.downcase] = kind
+ end
+ self
+ end
+
+end
+
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanner.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanner.rb
new file mode 100644
index 000000000..c956bad98
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanner.rb
@@ -0,0 +1,253 @@
+module CodeRay
+
+ require 'coderay/helpers/plugin'
+
+ # = Scanners
+ #
+ # $Id: scanner.rb 222 2007-01-01 16:26:17Z murphy $
+ #
+ # This module holds the Scanner class and its subclasses.
+ # For example, the Ruby scanner is named CodeRay::Scanners::Ruby
+ # can be found in coderay/scanners/ruby.
+ #
+ # Scanner also provides methods and constants for the register
+ # mechanism and the [] method that returns the Scanner class
+ # belonging to the given lang.
+ #
+ # See PluginHost.
+ module Scanners
+ extend PluginHost
+ plugin_path File.dirname(__FILE__), 'scanners'
+
+ require 'strscan'
+
+ # = Scanner
+ #
+ # The base class for all Scanners.
+ #
+ # It is a subclass of Ruby's great +StringScanner+, which
+ # makes it easy to access the scanning methods inside.
+ #
+ # It is also +Enumerable+, so you can use it like an Array of
+ # Tokens:
+ #
+ # require 'coderay'
+ #
+ # c_scanner = CodeRay::Scanners[:c].new "if (*p == '{') nest++;"
+ #
+ # for text, kind in c_scanner
+ # puts text if kind == :operator
+ # end
+ #
+ # # prints: (*==)++;
+ #
+ # OK, this is a very simple example :)
+ # You can also use +map+, +any?+, +find+ and even +sort_by+,
+ # if you want.
+ class Scanner < StringScanner
+ extend Plugin
+ plugin_host Scanners
+
+ # Raised if a Scanner fails while scanning
+ ScanError = Class.new(Exception)
+
+ require 'coderay/helpers/word_list'
+
+ # The default options for all scanner classes.
+ #
+ # Define @default_options for subclasses.
+ DEFAULT_OPTIONS = { :stream => false }
+
+ class << self
+
+ # Returns if the Scanner can be used in streaming mode.
+ def streamable?
+ is_a? Streamable
+ end
+
+ def normify code
+ code = code.to_s.to_unix
+ end
+
+ def file_extension extension = nil
+ if extension
+ @file_extension = extension.to_s
+ else
+ @file_extension ||= plugin_id.to_s
+ end
+ end
+
+ end
+
+=begin
+## Excluded for speed reasons; protected seems to make methods slow.
+
+ # Save the StringScanner methods from being called.
+ # This would not be useful for highlighting.
+ strscan_public_methods =
+ StringScanner.instance_methods -
+ StringScanner.ancestors[1].instance_methods
+ protected(*strscan_public_methods)
+=end
+
+ # Create a new Scanner.
+ #
+ # * +code+ is the input String and is handled by the superclass
+ # StringScanner.
+ # * +options+ is a Hash with Symbols as keys.
+ # It is merged with the default options of the class (you can
+ # overwrite default options here.)
+ # * +block+ is the callback for streamed highlighting.
+ #
+ # If you set :stream to +true+ in the options, the Scanner uses a
+ # TokenStream with the +block+ as callback to handle the tokens.
+ #
+ # Else, a Tokens object is used.
+ def initialize code='', options = {}, &block
+ @options = self.class::DEFAULT_OPTIONS.merge options
+ raise "I am only the basic Scanner class. I can't scan "\
+ "anything. :( Use my subclasses." if self.class == Scanner
+
+ super Scanner.normify(code)
+
+ @tokens = options[:tokens]
+ if @options[:stream]
+ warn "warning in CodeRay::Scanner.new: :stream is set, "\
+ "but no block was given" unless block_given?
+ raise NotStreamableError, self unless kind_of? Streamable
+ @tokens ||= TokenStream.new(&block)
+ else
+ warn "warning in CodeRay::Scanner.new: Block given, "\
+ "but :stream is #{@options[:stream]}" if block_given?
+ @tokens ||= Tokens.new
+ end
+
+ setup
+ end
+
+ def reset
+ super
+ reset_instance
+ end
+
+ def string= code
+ code = Scanner.normify(code)
+ super code
+ reset_instance
+ end
+
+ # More mnemonic accessor name for the input string.
+ alias code string
+ alias code= string=
+
+ # Scans the code and returns all tokens in a Tokens object.
+ def tokenize new_string=nil, options = {}
+ options = @options.merge(options)
+ self.string = new_string if new_string
+ @cached_tokens =
+ if @options[:stream] # :stream must have been set already
+ reset unless new_string
+ scan_tokens @tokens, options
+ @tokens
+ else
+ scan_tokens @tokens, options
+ end
+ end
+
+ def tokens
+ @cached_tokens ||= tokenize
+ end
+
+ # Whether the scanner is in streaming mode.
+ def streaming?
+ !!@options[:stream]
+ end
+
+ # Traverses the tokens.
+ def each &block
+ raise ArgumentError,
+ 'Cannot traverse TokenStream.' if @options[:stream]
+ tokens.each(&block)
+ end
+ include Enumerable
+
+ # The current line position of the scanner.
+ #
+ # Beware, this is implemented inefficiently. It should be used
+ # for debugging only.
+ def line
+ string[0..pos].count("\n") + 1
+ end
+
+ protected
+
+ # Can be implemented by subclasses to do some initialization
+ # that has to be done once per instance.
+ #
+ # Use reset for initialization that has to be done once per
+ # scan.
+ def setup
+ end
+
+ # This is the central method, and commonly the only one a
+ # subclass implements.
+ #
+ # Subclasses must implement this method; it must return +tokens+
+ # and must only use Tokens#<< for storing scanned tokens!
+ def scan_tokens tokens, options
+ raise NotImplementedError,
+ "#{self.class}#scan_tokens not implemented."
+ end
+
+ def reset_instance
+ @tokens.clear unless @options[:keep_tokens]
+ @cached_tokens = nil
+ end
+
+ # Scanner error with additional status information
+ def raise_inspect msg, tokens, state = 'No state given!', ambit = 30
+ raise ScanError, <<-EOE % [
+
+
+***ERROR in %s: %s (after %d tokens)
+
+tokens:
+%s
+
+current line: %d pos = %d
+matched: %p state: %p
+bol? = %p, eos? = %p
+
+surrounding code:
+%p ~~ %p
+
+
+***ERROR***
+
+ EOE
+ File.basename(caller[0]),
+ msg,
+ tokens.size,
+ tokens.last(10).map { |t| t.inspect }.join("\n"),
+ line, pos,
+ matched, state, bol?, eos?,
+ string[pos-ambit,ambit],
+ string[pos,ambit],
+ ]
+ end
+
+ end
+
+ end
+end
+
+class String
+ # I love this hack. It seems to silence all dos/unix/mac newline problems.
+ def to_unix
+ if index ?\r
+ gsub(/\r\n?/, "\n")
+ else
+ self
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/_map.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/_map.rb
new file mode 100644
index 000000000..1c5fc8922
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/_map.rb
@@ -0,0 +1,15 @@
+module CodeRay
+module Scanners
+
+ map :cpp => :c,
+ :plain => :plaintext,
+ :pascal => :delphi,
+ :irb => :ruby,
+ :xml => :html,
+ :xhtml => :nitro_xhtml,
+ :nitro => :nitro_xhtml
+
+ default :plain
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/c.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/c.rb
new file mode 100644
index 000000000..f6d71ade2
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/c.rb
@@ -0,0 +1,165 @@
+module CodeRay
+module Scanners
+
+ class C < Scanner
+
+ register_for :c
+
+ include Streamable
+
+ RESERVED_WORDS = [
+ 'asm', 'break', 'case', 'continue', 'default', 'do', 'else',
+ 'for', 'goto', 'if', 'return', 'switch', 'while',
+ 'struct', 'union', 'enum', 'typedef',
+ 'static', 'register', 'auto', 'extern',
+ 'sizeof',
+ 'volatile', 'const', # C89
+ 'inline', 'restrict', # C99
+ ]
+
+ PREDEFINED_TYPES = [
+ 'int', 'long', 'short', 'char', 'void',
+ 'signed', 'unsigned', 'float', 'double',
+ 'bool', 'complex', # C99
+ ]
+
+ PREDEFINED_CONSTANTS = [
+ 'EOF', 'NULL',
+ 'true', 'false', # C99
+ ]
+
+ IDENT_KIND = WordList.new(:ident).
+ add(RESERVED_WORDS, :reserved).
+ add(PREDEFINED_TYPES, :pre_type).
+ add(PREDEFINED_CONSTANTS, :pre_constant)
+
+ ESCAPE = / [rbfnrtv\n\\'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x
+ UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x
+
+ def scan_tokens tokens, options
+
+ state = :initial
+
+ until eos?
+
+ kind = nil
+ match = nil
+
+ case state
+
+ when :initial
+
+ if scan(/ \s+ | \\\n /x)
+ kind = :space
+
+ elsif scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx)
+ kind = :comment
+
+ elsif match = scan(/ \# \s* if \s* 0 /x)
+ match << scan_until(/ ^\# (?:elif|else|endif) .*? $ | \z /xm) unless eos?
+ kind = :comment
+
+ elsif scan(/ [-+*\/=<>?:;,!&^|()\[\]{}~%]+ | \.(?!\d) /x)
+ kind = :operator
+
+ elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
+ kind = IDENT_KIND[match]
+ if kind == :ident and check(/:(?!:)/)
+ match << scan(/:/)
+ kind = :label
+ end
+
+ elsif match = scan(/L?"/)
+ tokens << [:open, :string]
+ if match[0] == ?L
+ tokens << ['L', :modifier]
+ match = '"'
+ end
+ state = :string
+ kind = :delimiter
+
+ elsif scan(/#\s*(\w*)/)
+ kind = :preprocessor # FIXME multiline preprocs
+ state = :include_expected if self[1] == 'include'
+
+ elsif scan(/ L?' (?: [^\'\n\\] | \\ #{ESCAPE} )? '? /ox)
+ kind = :char
+
+ elsif scan(/0[xX][0-9A-Fa-f]+/)
+ kind = :hex
+
+ elsif scan(/(?:0[0-7]+)(?![89.eEfF])/)
+ kind = :oct
+
+ elsif scan(/(?:\d+)(?![.eEfF])/)
+ kind = :integer
+
+ elsif scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
+ kind = :float
+
+ else
+ getch
+ kind = :error
+
+ end
+
+ when :string
+ if scan(/[^\\\n"]+/)
+ kind = :content
+ elsif scan(/"/)
+ tokens << ['"', :delimiter]
+ tokens << [:close, :string]
+ state = :initial
+ next
+ elsif scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)
+ kind = :char
+ elsif scan(/ \\ | $ /x)
+ tokens << [:close, :string]
+ kind = :error
+ state = :initial
+ else
+ raise_inspect "else case \" reached; %p not handled." % peek(1), tokens
+ end
+
+ when :include_expected
+ if scan(/<[^>\n]+>?|"[^"\n\\]*(?:\\.[^"\n\\]*)*"?/)
+ kind = :include
+ state = :initial
+
+ elsif match = scan(/\s+/)
+ kind = :space
+ state = :initial if match.index ?\n
+
+ else
+ getch
+ kind = :error
+
+ end
+
+ else
+ raise_inspect 'Unknown state', tokens
+
+ end
+
+ match ||= matched
+ if $DEBUG and not kind
+ raise_inspect 'Error token %p in line %d' %
+ [[match, kind], line], tokens
+ end
+ raise_inspect 'Empty token', tokens unless match
+
+ tokens << [match, kind]
+
+ end
+
+ if state == :string
+ tokens << [:close, :string]
+ end
+
+ tokens
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/debug.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/debug.rb
new file mode 100644
index 000000000..0dee38fa9
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/debug.rb
@@ -0,0 +1,60 @@
+module CodeRay
+module Scanners
+
+ # = Debug Scanner
+ class Debug < Scanner
+
+ include Streamable
+ register_for :debug
+
+ protected
+ def scan_tokens tokens, options
+
+ opened_tokens = []
+
+ until eos?
+
+ kind = nil
+ match = nil
+
+ if scan(/\s+/)
+ tokens << [matched, :space]
+ next
+
+ elsif scan(/ (\w+) \( ( [^\)\\]* ( \\. [^\)\\]* )* ) \) /x)
+ kind = self[1].to_sym
+ match = self[2].gsub(/\\(.)/, '\1')
+
+ elsif scan(/ (\w+) < /x)
+ kind = self[1].to_sym
+ opened_tokens << kind
+ match = :open
+
+ elsif scan(/ > /x)
+ kind = opened_tokens.pop
+ match = :close
+
+ else
+ kind = :error
+ getch
+
+ end
+
+ match ||= matched
+ if $DEBUG and not kind
+ raise_inspect 'Error token %p in line %d' %
+ [[match, kind], line], tokens
+ end
+ raise_inspect 'Empty token', tokens unless match
+
+ tokens << [match, kind]
+
+ end
+
+ tokens
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/delphi.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/delphi.rb
new file mode 100644
index 000000000..5ee07a3ad
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/delphi.rb
@@ -0,0 +1,149 @@
+module CodeRay
+module Scanners
+
+ class Delphi < Scanner
+
+ register_for :delphi
+
+ RESERVED_WORDS = [
+ 'and', 'array', 'as', 'at', 'asm', 'at', 'begin', 'case', 'class',
+ 'const', 'constructor', 'destructor', 'dispinterface', 'div', 'do',
+ 'downto', 'else', 'end', 'except', 'exports', 'file', 'finalization',
+ 'finally', 'for', 'function', 'goto', 'if', 'implementation', 'in',
+ 'inherited', 'initialization', 'inline', 'interface', 'is', 'label',
+ 'library', 'mod', 'nil', 'not', 'object', 'of', 'or', 'out', 'packed',
+ 'procedure', 'program', 'property', 'raise', 'record', 'repeat',
+ 'resourcestring', 'set', 'shl', 'shr', 'string', 'then', 'threadvar',
+ 'to', 'try', 'type', 'unit', 'until', 'uses', 'var', 'while', 'with',
+ 'xor', 'on'
+ ]
+
+ DIRECTIVES = [
+ 'absolute', 'abstract', 'assembler', 'at', 'automated', 'cdecl',
+ 'contains', 'deprecated', 'dispid', 'dynamic', 'export',
+ 'external', 'far', 'forward', 'implements', 'local',
+ 'near', 'nodefault', 'on', 'overload', 'override',
+ 'package', 'pascal', 'platform', 'private', 'protected', 'public',
+ 'published', 'read', 'readonly', 'register', 'reintroduce',
+ 'requires', 'resident', 'safecall', 'stdcall', 'stored', 'varargs',
+ 'virtual', 'write', 'writeonly'
+ ]
+
+ IDENT_KIND = CaseIgnoringWordList.new(:ident, caching=true).
+ add(RESERVED_WORDS, :reserved).
+ add(DIRECTIVES, :directive)
+
+ NAME_FOLLOWS = CaseIgnoringWordList.new(false, caching=true).
+ add(%w(procedure function .))
+
+ private
+ def scan_tokens tokens, options
+
+ state = :initial
+ last_token = ''
+
+ until eos?
+
+ kind = nil
+ match = nil
+
+ if state == :initial
+
+ if scan(/ \s+ /x)
+ tokens << [matched, :space]
+ next
+
+ elsif scan(%r! \{ \$ [^}]* \}? | \(\* \$ (?: .*? \*\) | .* ) !mx)
+ tokens << [matched, :preprocessor]
+ next
+
+ elsif scan(%r! // [^\n]* | \{ [^}]* \}? | \(\* (?: .*? \*\) | .* ) !mx)
+ tokens << [matched, :comment]
+ next
+
+ elsif match = scan(/ <[>=]? | >=? | :=? | [-+=*\/;,@\^|\(\)\[\]] | \.\. /x)
+ kind = :operator
+
+ elsif match = scan(/\./)
+ kind = :operator
+ if last_token == 'end'
+ tokens << [match, kind]
+ next
+ end
+
+ elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
+ kind = NAME_FOLLOWS[last_token] ? :ident : IDENT_KIND[match]
+
+ elsif match = scan(/ ' ( [^\n']|'' ) (?:'|$) /x)
+ tokens << [:open, :char]
+ tokens << ["'", :delimiter]
+ tokens << [self[1], :content]
+ tokens << ["'", :delimiter]
+ tokens << [:close, :char]
+ next
+
+ elsif match = scan(/ ' /x)
+ tokens << [:open, :string]
+ state = :string
+ kind = :delimiter
+
+ elsif scan(/ \# (?: \d+ | \$[0-9A-Fa-f]+ ) /x)
+ kind = :char
+
+ elsif scan(/ \$ [0-9A-Fa-f]+ /x)
+ kind = :hex
+
+ elsif scan(/ (?: \d+ ) (?![eE]|\.[^.]) /x)
+ kind = :integer
+
+ elsif scan(/ \d+ (?: \.\d+ (?: [eE][+-]? \d+ )? | [eE][+-]? \d+ ) /x)
+ kind = :float
+
+ else
+ kind = :error
+ getch
+
+ end
+
+ elsif state == :string
+ if scan(/[^\n']+/)
+ kind = :content
+ elsif scan(/''/)
+ kind = :char
+ elsif scan(/'/)
+ tokens << ["'", :delimiter]
+ tokens << [:close, :string]
+ state = :initial
+ next
+ elsif scan(/\n/)
+ tokens << [:close, :string]
+ kind = :error
+ state = :initial
+ else
+ raise "else case \' reached; %p not handled." % peek(1), tokens
+ end
+
+ else
+ raise 'else-case reached', tokens
+
+ end
+
+ match ||= matched
+ if $DEBUG and not kind
+ raise_inspect 'Error token %p in line %d' %
+ [[match, kind], line], tokens, state
+ end
+ raise_inspect 'Empty token', tokens unless match
+
+ last_token = match
+ tokens << [match, kind]
+
+ end
+
+ tokens
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/html.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/html.rb
new file mode 100644
index 000000000..5f647d3a6
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/html.rb
@@ -0,0 +1,177 @@
+module CodeRay
+module Scanners
+
+ # HTML Scanner
+ #
+ # $Id$
+ class HTML < Scanner
+
+ include Streamable
+ register_for :html
+
+ ATTR_NAME = /[\w.:-]+/
+ ATTR_VALUE_UNQUOTED = ATTR_NAME
+ TAG_END = /\/?>/
+ HEX = /[0-9a-fA-F]/
+ ENTITY = /
+ &
+ (?:
+ \w+
+ |
+ \#
+ (?:
+ \d+
+ |
+ x#{HEX}+
+ )
+ )
+ ;
+ /ox
+
+ PLAIN_STRING_CONTENT = {
+ "'" => /[^&'>\n]+/,
+ '"' => /[^&">\n]+/,
+ }
+
+ def reset
+ super
+ @state = :initial
+ end
+
+ private
+ def setup
+ @state = :initial
+ @plain_string_content = nil
+ end
+
+ def scan_tokens tokens, options
+
+ state = @state
+ plain_string_content = @plain_string_content
+
+ until eos?
+
+ kind = nil
+ match = nil
+
+ if scan(/\s+/m)
+ kind = :space
+
+ else
+
+ case state
+
+ when :initial
+ if scan(//m)
+ kind = :comment
+ elsif scan(//m)
+ kind = :preprocessor
+ elsif scan(/<\?xml.*?\?>/m)
+ kind = :preprocessor
+ elsif scan(/<\?.*?\?>|<%.*?%>/m)
+ kind = :comment
+ elsif scan(/<\/[-\w_.:]*>/m)
+ kind = :tag
+ elsif match = scan(/<[-\w_.:]+>?/m)
+ kind = :tag
+ state = :attribute unless match[-1] == ?>
+ elsif scan(/[^<>&]+/)
+ kind = :plain
+ elsif scan(/#{ENTITY}/ox)
+ kind = :entity
+ elsif scan(/[<>&]/)
+ kind = :error
+ else
+ raise_inspect '[BUG] else-case reached with state %p' % [state], tokens
+ end
+
+ when :attribute
+ if scan(/#{TAG_END}/)
+ kind = :tag
+ state = :initial
+ elsif scan(/#{ATTR_NAME}/o)
+ kind = :attribute_name
+ state = :attribute_equal
+ else
+ kind = :error
+ getch
+ end
+
+ when :attribute_equal
+ if scan(/=/)
+ kind = :operator
+ state = :attribute_value
+ elsif scan(/#{ATTR_NAME}/o)
+ kind = :attribute_name
+ elsif scan(/#{TAG_END}/o)
+ kind = :tag
+ state = :initial
+ elsif scan(/./)
+ kind = :error
+ state = :attribute
+ end
+
+ when :attribute_value
+ if scan(/#{ATTR_VALUE_UNQUOTED}/o)
+ kind = :attribute_value
+ state = :attribute
+ elsif match = scan(/["']/)
+ tokens << [:open, :string]
+ state = :attribute_value_string
+ plain_string_content = PLAIN_STRING_CONTENT[match]
+ kind = :delimiter
+ elsif scan(/#{TAG_END}/o)
+ kind = :tag
+ state = :initial
+ else
+ kind = :error
+ getch
+ end
+
+ when :attribute_value_string
+ if scan(plain_string_content)
+ kind = :content
+ elsif scan(/['"]/)
+ tokens << [matched, :delimiter]
+ tokens << [:close, :string]
+ state = :attribute
+ next
+ elsif scan(/#{ENTITY}/ox)
+ kind = :entity
+ elsif scan(/&/)
+ kind = :content
+ elsif scan(/[\n>]/)
+ tokens << [:close, :string]
+ kind = :error
+ state = :initial
+ end
+
+ else
+ raise_inspect 'Unknown state: %p' % [state], tokens
+
+ end
+
+ end
+
+ match ||= matched
+ if $DEBUG and not kind
+ raise_inspect 'Error token %p in line %d' %
+ [[match, kind], line], tokens, state
+ end
+ raise_inspect 'Empty token', tokens unless match
+
+ tokens << [match, kind]
+ end
+
+ if options[:keep_state]
+ @state = state
+ @plain_string_content = plain_string_content
+ end
+
+ tokens
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/javascript.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/javascript.rb
new file mode 100644
index 000000000..419a5255b
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/javascript.rb
@@ -0,0 +1,176 @@
+# http://pastie.textmate.org/50774/
+module CodeRay module Scanners
+
+ class JavaScript < Scanner
+
+ register_for :javascript
+
+ RESERVED_WORDS = [
+ 'asm', 'break', 'case', 'continue', 'default', 'do', 'else',
+ 'for', 'goto', 'if', 'return', 'switch', 'while',
+# 'struct', 'union', 'enum', 'typedef',
+# 'static', 'register', 'auto', 'extern',
+# 'sizeof',
+ 'typeof',
+# 'volatile', 'const', # C89
+# 'inline', 'restrict', # C99
+ 'var', 'function','try','new','in',
+ 'instanceof','throw','catch'
+ ]
+
+ PREDEFINED_CONSTANTS = [
+ 'void', 'null', 'this',
+ 'true', 'false','undefined',
+ ]
+
+ IDENT_KIND = WordList.new(:ident).
+ add(RESERVED_WORDS, :reserved).
+ add(PREDEFINED_CONSTANTS, :pre_constant)
+
+ ESCAPE = / [rbfnrtv\n\\\/'"] | x[a-fA-F0-9]{1,2} | [0-7]{1,3} /x
+ UNICODE_ESCAPE = / u[a-fA-F0-9]{4} | U[a-fA-F0-9]{8} /x
+
+ def scan_tokens tokens, options
+
+ state = :initial
+ string_type = nil
+ regexp_allowed = true
+
+ until eos?
+
+ kind = :error
+ match = nil
+
+ if state == :initial
+
+ if scan(/ \s+ | \\\n /x)
+ kind = :space
+
+ elsif scan(%r! // [^\n\\]* (?: \\. [^\n\\]* )* | /\* (?: .*? \*/ | .* ) !mx)
+ kind = :comment
+ regexp_allowed = false
+
+ elsif match = scan(/ \# \s* if \s* 0 /x)
+ match << scan_until(/ ^\# (?:elif|else|endif) .*? $ | \z /xm) unless eos?
+ kind = :comment
+ regexp_allowed = false
+
+ elsif regexp_allowed and scan(/\//)
+ tokens << [:open, :regexp]
+ state = :regex
+ kind = :delimiter
+
+ elsif scan(/ [-+*\/=<>?:;,!&^|()\[\]{}~%] | \.(?!\d) /x)
+ kind = :operator
+ regexp_allowed=true
+
+ elsif match = scan(/ [$A-Za-z_][A-Za-z_0-9]* /x)
+ kind = IDENT_KIND[match]
+# if kind == :ident and check(/:(?!:)/)
+# match << scan(/:/)
+# kind = :label
+# end
+ regexp_allowed=false
+
+ elsif match = scan(/["']/)
+ tokens << [:open, :string]
+ string_type = matched
+ state = :string
+ kind = :delimiter
+
+# elsif scan(/#\s*(\w*)/)
+# kind = :preprocessor # FIXME multiline preprocs
+# state = :include_expected if self[1] == 'include'
+#
+# elsif scan(/ L?' (?: [^\'\n\\] | \\ #{ESCAPE} )? '? /ox)
+# kind = :char
+
+ elsif scan(/0[xX][0-9A-Fa-f]+/)
+ kind = :hex
+ regexp_allowed=false
+
+ elsif scan(/(?:0[0-7]+)(?![89.eEfF])/)
+ kind = :oct
+ regexp_allowed=false
+
+ elsif scan(/(?:\d+)(?![.eEfF])/)
+ kind = :integer
+ regexp_allowed=false
+
+ elsif scan(/\d[fF]?|\d*\.\d+(?:[eE][+-]?\d+)?[fF]?|\d+[eE][+-]?\d+[fF]?/)
+ kind = :float
+ regexp_allowed=false
+
+ else
+ getch
+ end
+
+ elsif state == :regex
+ if scan(/[^\\\/]+/)
+ kind = :content
+ elsif scan(/\\\/|\\\\/)
+ kind = :content
+ elsif scan(/\//)
+ tokens << [matched, :delimiter]
+ tokens << [:close, :regexp]
+ state = :initial
+ next
+ else
+ getch
+ kind = :content
+ end
+
+ elsif state == :string
+ if scan(/[^\\"']+/)
+ kind = :content
+ elsif scan(/["']/)
+ if string_type==matched
+ tokens << [matched, :delimiter]
+ tokens << [:close, :string]
+ state = :initial
+ string_type=nil
+ next
+ else
+ kind = :content
+ end
+ elsif scan(/ \\ (?: #{ESCAPE} | #{UNICODE_ESCAPE} ) /mox)
+ kind = :char
+ elsif scan(/ \\ | $ /x)
+ kind = :error
+ state = :initial
+ else
+ raise "else case \" reached; %p not handled." % peek(1), tokens
+ end
+
+# elsif state == :include_expected
+# if scan(/<[^>\n]+>?|"[^"\n\\]*(?:\\.[^"\n\\]*)*"?/)
+# kind = :include
+# state = :initial
+#
+# elsif match = scan(/\s+/)
+# kind = :space
+# state = :initial if match.index ?\n
+#
+# else
+# getch
+#
+# end
+#
+ else
+ raise 'else-case reached', tokens
+
+ end
+
+ match ||= matched
+# raise [match, kind], tokens if kind == :error
+
+ tokens << [match, kind]
+
+ end
+ tokens
+
+ end
+
+ end
+
+end end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/nitro_xhtml.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/nitro_xhtml.rb
new file mode 100644
index 000000000..d7968cc83
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/nitro_xhtml.rb
@@ -0,0 +1,133 @@
+module CodeRay
+module Scanners
+
+ load :html
+ load :ruby
+
+ # Nitro XHTML Scanner
+ #
+ # $Id$
+ class NitroXHTML < Scanner
+
+ include Streamable
+ register_for :nitro_xhtml
+
+ NITRO_RUBY_BLOCK = /
+ <\?r
+ (?>
+ [^\?]*
+ (?> \?(?!>) [^\?]* )*
+ )
+ (?: \?> )?
+ |
+
+ (?>
+ [^<]*
+ (?> <(?!\/ruby>) [^<]* )*
+ )
+ (?: <\/ruby> )?
+ |
+ <%
+ (?>
+ [^%]*
+ (?> %(?!>) [^%]* )*
+ )
+ (?: %> )?
+ /mx
+
+ NITRO_VALUE_BLOCK = /
+ \#
+ (?:
+ \{
+ [^{}]*
+ (?>
+ \{ [^}]* \}
+ (?> [^{}]* )
+ )*
+ \}?
+ | \| [^|]* \|?
+ | \( [^)]* \)?
+ | \[ [^\]]* \]?
+ | \\ [^\\]* \\?
+ )
+ /x
+
+ NITRO_ENTITY = /
+ % (?: \#\d+ | \w+ ) ;
+ /
+
+ START_OF_RUBY = /
+ (?=[<\#%])
+ < (?: \?r | % | ruby> )
+ | \# [{(|]
+ | % (?: \#\d+ | \w+ ) ;
+ /x
+
+ CLOSING_PAREN = Hash.new do |h, p|
+ h[p] = p
+ end.update( {
+ '(' => ')',
+ '[' => ']',
+ '{' => '}',
+ } )
+
+ private
+
+ def setup
+ @ruby_scanner = CodeRay.scanner :ruby, :tokens => @tokens, :keep_tokens => true
+ @html_scanner = CodeRay.scanner :html, :tokens => @tokens, :keep_tokens => true, :keep_state => true
+ end
+
+ def reset_instance
+ super
+ @html_scanner.reset
+ end
+
+ def scan_tokens tokens, options
+
+ until eos?
+
+ if (match = scan_until(/(?=#{START_OF_RUBY})/o) || scan_until(/\z/)) and not match.empty?
+ @html_scanner.tokenize match
+
+ elsif match = scan(/#{NITRO_VALUE_BLOCK}/o)
+ start_tag = match[0,2]
+ delimiter = CLOSING_PAREN[start_tag[1,1]]
+ end_tag = match[-1,1] == delimiter ? delimiter : ''
+ tokens << [:open, :inline]
+ tokens << [start_tag, :inline_delimiter]
+ code = match[start_tag.size .. -1 - end_tag.size]
+ @ruby_scanner.tokenize code
+ tokens << [end_tag, :inline_delimiter] unless end_tag.empty?
+ tokens << [:close, :inline]
+
+ elsif match = scan(/#{NITRO_RUBY_BLOCK}/o)
+ start_tag = '' ? '?>' : ''
+ tokens << [:open, :inline]
+ tokens << [start_tag, :inline_delimiter]
+ code = match[start_tag.size .. -(end_tag.size)-1]
+ @ruby_scanner.tokenize code
+ tokens << [end_tag, :inline_delimiter] unless end_tag.empty?
+ tokens << [:close, :inline]
+
+ elsif entity = scan(/#{NITRO_ENTITY}/o)
+ tokens << [entity, :entity]
+
+ elsif scan(/%/)
+ tokens << [matched, :error]
+
+ else
+ raise_inspect 'else-case reached!', tokens
+ end
+
+ end
+
+ tokens
+
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/plaintext.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/plaintext.rb
new file mode 100644
index 000000000..7a08c3a55
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/plaintext.rb
@@ -0,0 +1,18 @@
+module CodeRay
+module Scanners
+
+ class Plaintext < Scanner
+
+ register_for :plaintext, :plain
+
+ include Streamable
+
+ def scan_tokens tokens, options
+ text = (scan_until(/\z/) || '')
+ tokens << [text, :plain]
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/rhtml.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/rhtml.rb
new file mode 100644
index 000000000..18cc60be6
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/rhtml.rb
@@ -0,0 +1,73 @@
+module CodeRay
+module Scanners
+
+ load :html
+ load :ruby
+
+ # RHTML Scanner
+ #
+ # $Id$
+ class RHTML < Scanner
+
+ include Streamable
+ register_for :rhtml
+
+ ERB_RUBY_BLOCK = /
+ <%(?!%)[=-]?
+ (?>
+ [^\-%]* # normal*
+ (?> # special
+ (?: %(?!>) | -(?!%>) )
+ [^\-%]* # normal*
+ )*
+ )
+ (?: -?%> )?
+ /x
+
+ START_OF_ERB = /
+ <%(?!%)
+ /x
+
+ private
+
+ def setup
+ @ruby_scanner = CodeRay.scanner :ruby, :tokens => @tokens, :keep_tokens => true
+ @html_scanner = CodeRay.scanner :html, :tokens => @tokens, :keep_tokens => true, :keep_state => true
+ end
+
+ def reset_instance
+ super
+ @html_scanner.reset
+ end
+
+ def scan_tokens tokens, options
+
+ until eos?
+
+ if (match = scan_until(/(?=#{START_OF_ERB})/o) || scan_until(/\z/)) and not match.empty?
+ @html_scanner.tokenize match
+
+ elsif match = scan(/#{ERB_RUBY_BLOCK}/o)
+ start_tag = match[/\A<%[-=]?/]
+ end_tag = match[/-?%?>?\z/]
+ tokens << [:open, :inline]
+ tokens << [start_tag, :inline_delimiter]
+ code = match[start_tag.size .. -1 - end_tag.size]
+ @ruby_scanner.tokenize code
+ tokens << [end_tag, :inline_delimiter] unless end_tag.empty?
+ tokens << [:close, :inline]
+
+ else
+ raise_inspect 'else-case reached!', tokens
+ end
+
+ end
+
+ tokens
+
+ end
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/ruby.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/ruby.rb
new file mode 100644
index 000000000..d49773181
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/ruby.rb
@@ -0,0 +1,368 @@
+module CodeRay
+module Scanners
+
+ # This scanner is really complex, since Ruby _is_ a complex language!
+ #
+ # It tries to highlight 100% of all common code,
+ # and 90% of strange codes.
+ #
+ # It is optimized for HTML highlighting, and is not very useful for
+ # parsing or pretty printing.
+ #
+ # For now, I think it's better than the scanners in VIM or Syntax, or
+ # any highlighter I was able to find, except Caleb's RubyLexer.
+ #
+ # I hope it's also better than the rdoc/irb lexer.
+ class Ruby < Scanner
+
+ include Streamable
+
+ register_for :ruby
+ file_extension 'rb'
+
+ helper :patterns
+
+ private
+ def scan_tokens tokens, options
+ last_token_dot = false
+ value_expected = true
+ heredocs = nil
+ last_state = nil
+ state = :initial
+ depth = nil
+ inline_block_stack = []
+
+ patterns = Patterns # avoid constant lookup
+
+ until eos?
+ match = nil
+ kind = nil
+
+ if state.instance_of? patterns::StringState
+# {{{
+ match = scan_until(state.pattern) || scan_until(/\z/)
+ tokens << [match, :content] unless match.empty?
+ break if eos?
+
+ if state.heredoc and self[1] # end of heredoc
+ match = getch.to_s
+ match << scan_until(/$/) unless eos?
+ tokens << [match, :delimiter]
+ tokens << [:close, state.type]
+ state = state.next_state
+ next
+ end
+
+ case match = getch
+
+ when state.delim
+ if state.paren
+ state.paren_depth -= 1
+ if state.paren_depth > 0
+ tokens << [match, :nesting_delimiter]
+ next
+ end
+ end
+ tokens << [match, :delimiter]
+ if state.type == :regexp and not eos?
+ modifiers = scan(/#{patterns::REGEXP_MODIFIERS}/ox)
+ tokens << [modifiers, :modifier] unless modifiers.empty?
+ end
+ tokens << [:close, state.type]
+ value_expected = false
+ state = state.next_state
+
+ when '\\'
+ if state.interpreted
+ if esc = scan(/ #{patterns::ESCAPE} /ox)
+ tokens << [match + esc, :char]
+ else
+ tokens << [match, :error]
+ end
+ else
+ case m = getch
+ when state.delim, '\\'
+ tokens << [match + m, :char]
+ when nil
+ tokens << [match, :error]
+ else
+ tokens << [match + m, :content]
+ end
+ end
+
+ when '#'
+ case peek(1)
+ when '{'
+ inline_block_stack << [state, depth, heredocs]
+ value_expected = true
+ state = :initial
+ depth = 1
+ tokens << [:open, :inline]
+ tokens << [match + getch, :inline_delimiter]
+ when '$', '@'
+ tokens << [match, :escape]
+ last_state = state # scan one token as normal code, then return here
+ state = :initial
+ else
+ raise_inspect 'else-case # reached; #%p not handled' % peek(1), tokens
+ end
+
+ when state.paren
+ state.paren_depth += 1
+ tokens << [match, :nesting_delimiter]
+
+ when /#{patterns::REGEXP_SYMBOLS}/ox
+ tokens << [match, :function]
+
+ else
+ raise_inspect 'else-case " reached; %p not handled, state = %p' % [match, state], tokens
+
+ end
+ next
+# }}}
+ else
+# {{{
+ if match = scan(/[ \t\f]+/)
+ kind = :space
+ match << scan(/\s*/) unless eos? or heredocs
+ tokens << [match, kind]
+ next
+
+ elsif match = scan(/\\?\n/)
+ kind = :space
+ if match == "\n"
+ value_expected = true # FIXME not quite true
+ state = :initial if state == :undef_comma_expected
+ end
+ if heredocs
+ unscan # heredoc scanning needs \n at start
+ state = heredocs.shift
+ tokens << [:open, state.type]
+ heredocs = nil if heredocs.empty?
+ next
+ else
+ match << scan(/\s*/) unless eos?
+ end
+ tokens << [match, kind]
+ next
+
+ elsif match = scan(/\#.*/) or
+ ( bol? and match = scan(/#{patterns::RUBYDOC_OR_DATA}/o) )
+ kind = :comment
+ value_expected = true
+ tokens << [match, kind]
+ next
+
+ elsif state == :initial
+
+ # IDENTS #
+ if match = scan(/#{patterns::METHOD_NAME}/o)
+ if last_token_dot
+ kind = if match[/^[A-Z]/] and not match?(/\(/) then :constant else :ident end
+ else
+ kind = patterns::IDENT_KIND[match]
+ if kind == :ident and match[/^[A-Z]/] and not match[/[!?]$/] and not match?(/\(/)
+ kind = :constant
+ elsif kind == :reserved
+ state = patterns::DEF_NEW_STATE[match]
+ end
+ end
+ ## experimental!
+ value_expected = :set if
+ patterns::REGEXP_ALLOWED[match] or check(/#{patterns::VALUE_FOLLOWS}/o)
+
+ elsif last_token_dot and match = scan(/#{patterns::METHOD_NAME_OPERATOR}/o)
+ kind = :ident
+ value_expected = :set if check(/#{patterns::VALUE_FOLLOWS}/o)
+
+ # OPERATORS #
+ elsif not last_token_dot and match = scan(/ \.\.\.? | (?:\.|::)() | [,\(\)\[\]\{\}] | ==?=? /x)
+ if match !~ / [.\)\]\}] /x or match =~ /\.\.\.?/
+ value_expected = :set
+ end
+ last_token_dot = :set if self[1]
+ kind = :operator
+ unless inline_block_stack.empty?
+ case match
+ when '{'
+ depth += 1
+ when '}'
+ depth -= 1
+ if depth == 0 # closing brace of inline block reached
+ state, depth, heredocs = inline_block_stack.pop
+ tokens << [match, :inline_delimiter]
+ kind = :inline
+ match = :close
+ end
+ end
+ end
+
+ elsif match = scan(/ ['"] /mx)
+ tokens << [:open, :string]
+ kind = :delimiter
+ state = patterns::StringState.new :string, match == '"', match # important for streaming
+
+ elsif match = scan(/#{patterns::INSTANCE_VARIABLE}/o)
+ kind = :instance_variable
+
+ elsif value_expected and match = scan(/\//)
+ tokens << [:open, :regexp]
+ kind = :delimiter
+ interpreted = true
+ state = patterns::StringState.new :regexp, interpreted, match
+
+ elsif match = scan(/#{patterns::NUMERIC}/o)
+ kind = if self[1] then :float else :integer end
+
+ elsif match = scan(/#{patterns::SYMBOL}/o)
+ case delim = match[1]
+ when ?', ?"
+ tokens << [:open, :symbol]
+ tokens << [':', :symbol]
+ match = delim.chr
+ kind = :delimiter
+ state = patterns::StringState.new :symbol, delim == ?", match
+ else
+ kind = :symbol
+ end
+
+ elsif match = scan(/ [-+!~^]=? | [*|&]{1,2}=? | >>? /x)
+ value_expected = :set
+ kind = :operator
+
+ elsif value_expected and match = scan(/#{patterns::HEREDOC_OPEN}/o)
+ indented = self[1] == '-'
+ quote = self[3]
+ delim = self[quote ? 4 : 2]
+ kind = patterns::QUOTE_TO_TYPE[quote]
+ tokens << [:open, kind]
+ tokens << [match, :delimiter]
+ match = :close
+ heredoc = patterns::StringState.new kind, quote != '\'', delim, (indented ? :indented : :linestart )
+ heredocs ||= [] # create heredocs if empty
+ heredocs << heredoc
+
+ elsif value_expected and match = scan(/#{patterns::FANCY_START_CORRECT}/o)
+ kind, interpreted = *patterns::FancyStringType.fetch(self[1]) do
+ raise_inspect 'Unknown fancy string: %%%p' % k, tokens
+ end
+ tokens << [:open, kind]
+ state = patterns::StringState.new kind, interpreted, self[2]
+ kind = :delimiter
+
+ elsif value_expected and match = scan(/#{patterns::CHARACTER}/o)
+ kind = :integer
+
+ elsif match = scan(/ [\/%]=? | <(?:<|=>?)? | [?:;] /x)
+ value_expected = :set
+ kind = :operator
+
+ elsif match = scan(/`/)
+ if last_token_dot
+ kind = :operator
+ else
+ tokens << [:open, :shell]
+ kind = :delimiter
+ state = patterns::StringState.new :shell, true, match
+ end
+
+ elsif match = scan(/#{patterns::GLOBAL_VARIABLE}/o)
+ kind = :global_variable
+
+ elsif match = scan(/#{patterns::CLASS_VARIABLE}/o)
+ kind = :class_variable
+
+ else
+ kind = :error
+ match = getch
+
+ end
+
+ elsif state == :def_expected
+ state = :initial
+ if match = scan(/(?>#{patterns::METHOD_NAME_EX})(?!\.|::)/o)
+ kind = :method
+ else
+ next
+ end
+
+ elsif state == :undef_expected
+ state = :undef_comma_expected
+ if match = scan(/#{patterns::METHOD_NAME_EX}/o)
+ kind = :method
+ elsif match = scan(/#{patterns::SYMBOL}/o)
+ case delim = match[1]
+ when ?', ?"
+ tokens << [:open, :symbol]
+ tokens << [':', :symbol]
+ match = delim.chr
+ kind = :delimiter
+ state = patterns::StringState.new :symbol, delim == ?", match
+ state.next_state = :undef_comma_expected
+ else
+ kind = :symbol
+ end
+ else
+ state = :initial
+ next
+ end
+
+ elsif state == :undef_comma_expected
+ if match = scan(/,/)
+ kind = :operator
+ state = :undef_expected
+ else
+ state = :initial
+ next
+ end
+
+ elsif state == :module_expected
+ if match = scan(/<)
+ kind = :operator
+ else
+ state = :initial
+ if match = scan(/ (?:#{patterns::IDENT}::)* #{patterns::IDENT} /ox)
+ kind = :class
+ else
+ next
+ end
+ end
+
+ end
+# }}}
+
+ value_expected = value_expected == :set
+ last_token_dot = last_token_dot == :set
+
+ if $DEBUG and not kind
+ raise_inspect 'Error token %p in line %d' %
+ [[match, kind], line], tokens, state
+ end
+ raise_inspect 'Empty token', tokens unless match
+
+ tokens << [match, kind]
+
+ if last_state
+ state = last_state
+ last_state = nil
+ end
+ end
+ end
+
+ inline_block_stack << [state] if state.is_a? patterns::StringState
+ until inline_block_stack.empty?
+ this_block = inline_block_stack.pop
+ tokens << [:close, :inline] if this_block.size > 1
+ state = this_block.first
+ tokens << [:close, state.type]
+ end
+
+ tokens
+ end
+
+ end
+
+end
+end
+
+# vim:fdm=marker
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/ruby/patterns.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/ruby/patterns.rb
new file mode 100644
index 000000000..39962ec06
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/ruby/patterns.rb
@@ -0,0 +1,230 @@
+module CodeRay
+module Scanners
+
+ module Ruby::Patterns # :nodoc:
+
+ RESERVED_WORDS = %w[
+ and def end in or unless begin
+ defined? ensure module redo super until
+ BEGIN break do next rescue then
+ when END case else for retry
+ while alias class elsif if not return
+ undef yield
+ ]
+
+ DEF_KEYWORDS = %w[ def ]
+ UNDEF_KEYWORDS = %w[ undef ]
+ MODULE_KEYWORDS = %w[class module]
+ DEF_NEW_STATE = WordList.new(:initial).
+ add(DEF_KEYWORDS, :def_expected).
+ add(UNDEF_KEYWORDS, :undef_expected).
+ add(MODULE_KEYWORDS, :module_expected)
+
+ IDENTS_ALLOWING_REGEXP = %w[
+ and or not while until unless if then elsif when sub sub! gsub gsub!
+ scan slice slice! split
+ ]
+ REGEXP_ALLOWED = WordList.new(false).
+ add(IDENTS_ALLOWING_REGEXP, :set)
+
+ PREDEFINED_CONSTANTS = %w[
+ nil true false self
+ DATA ARGV ARGF __FILE__ __LINE__
+ ]
+
+ IDENT_KIND = WordList.new(:ident).
+ add(RESERVED_WORDS, :reserved).
+ add(PREDEFINED_CONSTANTS, :pre_constant)
+
+ IDENT = /[a-z_][\w_]*/i
+
+ METHOD_NAME = / #{IDENT} [?!]? /ox
+ METHOD_NAME_OPERATOR = /
+ \*\*? # multiplication and power
+ | [-+]@? # plus, minus
+ | [\/%&|^`~] # division, modulo or format strings, &and, |or, ^xor, `system`, tilde
+ | \[\]=? # array getter and setter
+ | << | >> # append or shift left, shift right
+ | <=?>? | >=? # comparison, rocket operator
+ | ===? # simple equality and case equality
+ /ox
+ METHOD_NAME_EX = / #{IDENT} (?:[?!]|=(?!>))? | #{METHOD_NAME_OPERATOR} /ox
+ INSTANCE_VARIABLE = / @ #{IDENT} /ox
+ CLASS_VARIABLE = / @@ #{IDENT} /ox
+ OBJECT_VARIABLE = / @@? #{IDENT} /ox
+ GLOBAL_VARIABLE = / \$ (?: #{IDENT} | [1-9]\d* | 0\w* | [~&+`'=\/,;_.<>!@$?*":\\] | -[a-zA-Z_0-9] ) /ox
+ PREFIX_VARIABLE = / #{GLOBAL_VARIABLE} |#{OBJECT_VARIABLE} /ox
+ VARIABLE = / @?@? #{IDENT} | #{GLOBAL_VARIABLE} /ox
+
+ QUOTE_TO_TYPE = {
+ '`' => :shell,
+ '/'=> :regexp,
+ }
+ QUOTE_TO_TYPE.default = :string
+
+ REGEXP_MODIFIERS = /[mixounse]*/
+ REGEXP_SYMBOLS = /[|?*+?(){}\[\].^$]/
+
+ DECIMAL = /\d+(?:_\d+)*/
+ OCTAL = /0_?[0-7]+(?:_[0-7]+)*/
+ HEXADECIMAL = /0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/
+ BINARY = /0b[01]+(?:_[01]+)*/
+
+ EXPONENT = / [eE] [+-]? #{DECIMAL} /ox
+ FLOAT_SUFFIX = / #{EXPONENT} | \. #{DECIMAL} #{EXPONENT}? /ox
+ FLOAT_OR_INT = / #{DECIMAL} (?: #{FLOAT_SUFFIX} () )? /ox
+ NUMERIC = / [-+]? (?: (?=0) (?: #{OCTAL} | #{HEXADECIMAL} | #{BINARY} ) | #{FLOAT_OR_INT} ) /ox
+
+ SYMBOL = /
+ :
+ (?:
+ #{METHOD_NAME_EX}
+ | #{PREFIX_VARIABLE}
+ | ['"]
+ )
+ /ox
+
+ # TODO investigste \M, \c and \C escape sequences
+ # (?: M-\\C-|C-\\M-|M-\\c|c\\M-|c|C-|M-)? (?: \\ (?: [0-7]{3} | x[0-9A-Fa-f]{2} | . ) )
+ # assert_equal(225, ?\M-a)
+ # assert_equal(129, ?\M-\C-a)
+ ESCAPE = /
+ [abefnrstv]
+ | M-\\C-|C-\\M-|M-\\c|c\\M-|c|C-|M-
+ | [0-7]{1,3}
+ | x[0-9A-Fa-f]{1,2}
+ | .
+ /mx
+
+ CHARACTER = /
+ \?
+ (?:
+ [^\s\\]
+ | \\ #{ESCAPE}
+ )
+ /mx
+
+ # NOTE: This is not completely correct, but
+ # nobody needs heredoc delimiters ending with \n.
+ HEREDOC_OPEN = /
+ << (-)? # $1 = float
+ (?:
+ ( [A-Za-z_0-9]+ ) # $2 = delim
+ |
+ ( ["'`\/] ) # $3 = quote, type
+ ( [^\n]*? ) \3 # $4 = delim
+ )
+ /mx
+
+ RUBYDOC = /
+ =begin (?!\S)
+ .*?
+ (?: \Z | ^=end (?!\S) [^\n]* )
+ /mx
+
+ DATA = /
+ __END__$
+ .*?
+ (?: \Z | (?=^\#CODE) )
+ /mx
+
+ # Checks for a valid value to follow. This enables
+ # fancy_allowed in method calls.
+ VALUE_FOLLOWS = /
+ \s+
+ (?:
+ [%\/][^\s=]
+ |
+ <<-?\S
+ |
+ #{CHARACTER}
+ )
+ /x
+
+ RUBYDOC_OR_DATA = / #{RUBYDOC} | #{DATA} /xo
+
+ RDOC_DATA_START = / ^=begin (?!\S) | ^__END__$ /x
+
+ # FIXME: \s and = are only a workaround, they are still allowed
+ # as delimiters.
+ FANCY_START_SAVE = / % ( [qQwWxsr] | (?![a-zA-Z0-9\s=]) ) ([^a-zA-Z0-9]) /mx
+ FANCY_START_CORRECT = / % ( [qQwWxsr] | (?![a-zA-Z0-9]) ) ([^a-zA-Z0-9]) /mx
+
+ FancyStringType = {
+ 'q' => [:string, false],
+ 'Q' => [:string, true],
+ 'r' => [:regexp, true],
+ 's' => [:symbol, false],
+ 'x' => [:shell, true]
+ }
+ FancyStringType['w'] = FancyStringType['q']
+ FancyStringType['W'] = FancyStringType[''] = FancyStringType['Q']
+
+ class StringState < Struct.new :type, :interpreted, :delim, :heredoc,
+ :paren, :paren_depth, :pattern, :next_state
+
+ CLOSING_PAREN = Hash[ *%w[
+ ( )
+ [ ]
+ < >
+ { }
+ ] ]
+
+ CLOSING_PAREN.values.each { |o| o.freeze } # debug, if I try to change it with <<
+ OPENING_PAREN = CLOSING_PAREN.invert
+
+ STRING_PATTERN = Hash.new { |h, k|
+ delim, interpreted = *k
+ delim_pattern = Regexp.escape(delim.dup)
+ if closing_paren = CLOSING_PAREN[delim]
+ delim_pattern << Regexp.escape(closing_paren)
+ end
+
+
+ special_escapes =
+ case interpreted
+ when :regexp_symbols
+ '| ' + REGEXP_SYMBOLS.source
+ when :words
+ '| \s'
+ end
+
+ h[k] =
+ if interpreted and not delim == '#'
+ / (?= [#{delim_pattern}\\] | \# [{$@] #{special_escapes} ) /mx
+ else
+ / (?= [#{delim_pattern}\\] #{special_escapes} ) /mx
+ end
+ }
+
+ HEREDOC_PATTERN = Hash.new { |h, k|
+ delim, interpreted, indented = *k
+ delim_pattern = Regexp.escape(delim.dup)
+ delim_pattern = / \n #{ '(?>[\ \t]*)' if indented } #{ Regexp.new delim_pattern } $ /x
+ h[k] =
+ if interpreted
+ / (?= #{delim_pattern}() | \\ | \# [{$@] ) /mx # $1 set == end of heredoc
+ else
+ / (?= #{delim_pattern}() | \\ ) /mx
+ end
+ }
+
+ def initialize kind, interpreted, delim, heredoc = false
+ if heredoc
+ pattern = HEREDOC_PATTERN[ [delim, interpreted, heredoc == :indented] ]
+ delim = nil
+ else
+ pattern = STRING_PATTERN[ [delim, interpreted] ]
+ if paren = CLOSING_PAREN[delim]
+ delim, paren = paren, delim
+ paren_depth = 1
+ end
+ end
+ super kind, interpreted, delim, heredoc, paren, paren_depth, pattern, :initial
+ end
+ end unless defined? StringState
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/scheme.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/scheme.rb
new file mode 100644
index 000000000..2aee223a7
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/scheme.rb
@@ -0,0 +1,142 @@
+module CodeRay
+ module Scanners
+
+ # Scheme scanner for CodeRay (by closure).
+ # Thanks to murphy for putting CodeRay into public.
+ class Scheme < Scanner
+
+ register_for :scheme
+ file_extension :scm
+
+ CORE_FORMS = %w[
+ lambda let let* letrec syntax-case define-syntax let-syntax
+ letrec-syntax begin define quote if or and cond case do delay
+ quasiquote set! cons force call-with-current-continuation call/cc
+ ]
+
+ IDENT_KIND = CaseIgnoringWordList.new(:ident).
+ add(CORE_FORMS, :reserved)
+
+ #IDENTIFIER_INITIAL = /[a-z!@\$%&\*\/\:<=>\?~_\^]/i
+ #IDENTIFIER_SUBSEQUENT = /#{IDENTIFIER_INITIAL}|\d|\.|\+|-/
+ #IDENTIFIER = /#{IDENTIFIER_INITIAL}#{IDENTIFIER_SUBSEQUENT}*|\+|-|\.{3}/
+ IDENTIFIER = /[a-zA-Z!@$%&*\/:<=>?~_^][\w!@$%&*\/:<=>?~^.+\-]*|[+-]|\.\.\./
+ DIGIT = /\d/
+ DIGIT10 = DIGIT
+ DIGIT16 = /[0-9a-f]/i
+ DIGIT8 = /[0-7]/
+ DIGIT2 = /[01]/
+ RADIX16 = /\#x/i
+ RADIX8 = /\#o/i
+ RADIX2 = /\#b/i
+ RADIX10 = /\#d/i
+ EXACTNESS = /#i|#e/i
+ SIGN = /[\+-]?/
+ EXP_MARK = /[esfdl]/i
+ EXP = /#{EXP_MARK}#{SIGN}#{DIGIT}+/
+ SUFFIX = /#{EXP}?/
+ PREFIX10 = /#{RADIX10}?#{EXACTNESS}?|#{EXACTNESS}?#{RADIX10}?/
+ PREFIX16 = /#{RADIX16}#{EXACTNESS}?|#{EXACTNESS}?#{RADIX16}/
+ PREFIX8 = /#{RADIX8}#{EXACTNESS}?|#{EXACTNESS}?#{RADIX8}/
+ PREFIX2 = /#{RADIX2}#{EXACTNESS}?|#{EXACTNESS}?#{RADIX2}/
+ UINT10 = /#{DIGIT10}+#*/
+ UINT16 = /#{DIGIT16}+#*/
+ UINT8 = /#{DIGIT8}+#*/
+ UINT2 = /#{DIGIT2}+#*/
+ DECIMAL = /#{DIGIT10}+#+\.#*#{SUFFIX}|#{DIGIT10}+\.#{DIGIT10}*#*#{SUFFIX}|\.#{DIGIT10}+#*#{SUFFIX}|#{UINT10}#{EXP}/
+ UREAL10 = /#{UINT10}\/#{UINT10}|#{DECIMAL}|#{UINT10}/
+ UREAL16 = /#{UINT16}\/#{UINT16}|#{UINT16}/
+ UREAL8 = /#{UINT8}\/#{UINT8}|#{UINT8}/
+ UREAL2 = /#{UINT2}\/#{UINT2}|#{UINT2}/
+ REAL10 = /#{SIGN}#{UREAL10}/
+ REAL16 = /#{SIGN}#{UREAL16}/
+ REAL8 = /#{SIGN}#{UREAL8}/
+ REAL2 = /#{SIGN}#{UREAL2}/
+ IMAG10 = /i|#{UREAL10}i/
+ IMAG16 = /i|#{UREAL16}i/
+ IMAG8 = /i|#{UREAL8}i/
+ IMAG2 = /i|#{UREAL2}i/
+ COMPLEX10 = /#{REAL10}@#{REAL10}|#{REAL10}\+#{IMAG10}|#{REAL10}-#{IMAG10}|\+#{IMAG10}|-#{IMAG10}|#{REAL10}/
+ COMPLEX16 = /#{REAL16}@#{REAL16}|#{REAL16}\+#{IMAG16}|#{REAL16}-#{IMAG16}|\+#{IMAG16}|-#{IMAG16}|#{REAL16}/
+ COMPLEX8 = /#{REAL8}@#{REAL8}|#{REAL8}\+#{IMAG8}|#{REAL8}-#{IMAG8}|\+#{IMAG8}|-#{IMAG8}|#{REAL8}/
+ COMPLEX2 = /#{REAL2}@#{REAL2}|#{REAL2}\+#{IMAG2}|#{REAL2}-#{IMAG2}|\+#{IMAG2}|-#{IMAG2}|#{REAL2}/
+ NUM10 = /#{PREFIX10}?#{COMPLEX10}/
+ NUM16 = /#{PREFIX16}#{COMPLEX16}/
+ NUM8 = /#{PREFIX8}#{COMPLEX8}/
+ NUM2 = /#{PREFIX2}#{COMPLEX2}/
+ NUM = /#{NUM10}|#{NUM16}|#{NUM8}|#{NUM2}/
+
+ private
+ def scan_tokens tokens,options
+
+ state = :initial
+ ident_kind = IDENT_KIND
+
+ until eos?
+ kind = match = nil
+
+ case state
+ when :initial
+ if scan(/ \s+ | \\\n /x)
+ kind = :space
+ elsif scan(/['\(\[\)\]]|#\(/)
+ kind = :operator_fat
+ elsif scan(/;.*/)
+ kind = :comment
+ elsif scan(/#\\(?:newline|space|.?)/)
+ kind = :char
+ elsif scan(/#[ft]/)
+ kind = :pre_constant
+ elsif scan(/#{IDENTIFIER}/o)
+ kind = ident_kind[matched]
+ elsif scan(/\./)
+ kind = :operator
+ elsif scan(/"/)
+ tokens << [:open, :string]
+ state = :string
+ tokens << ['"', :delimiter]
+ next
+ elsif scan(/#{NUM}/o) and not matched.empty?
+ kind = :integer
+ elsif getch
+ kind = :error
+ end
+
+ when :string
+ if scan(/[^"\\]+/) or scan(/\\.?/)
+ kind = :content
+ elsif scan(/"/)
+ tokens << ['"', :delimiter]
+ tokens << [:close, :string]
+ state = :initial
+ next
+ else
+ raise_inspect "else case \" reached; %p not handled." % peek(1),
+ tokens, state
+ end
+
+ else
+ raise "else case reached"
+ end
+
+ match ||= matched
+ if $DEBUG and not kind
+ raise_inspect 'Error token %p in line %d' %
+ [[match, kind], line], tokens
+ end
+ raise_inspect 'Empty token', tokens, state unless match
+
+ tokens << [match, kind]
+
+ end # until eos
+
+ if state == :string
+ tokens << [:close, :string]
+ end
+
+ tokens
+
+ end #scan_tokens
+ end #class
+ end #module scanners
+end #module coderay
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/xml.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/xml.rb
new file mode 100644
index 000000000..ff923fbf5
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/scanners/xml.rb
@@ -0,0 +1,18 @@
+module CodeRay
+module Scanners
+
+ load :html
+
+ # XML Scanner
+ #
+ # $Id$
+ #
+ # Currently this is the same scanner as Scanners::HTML.
+ class XML < HTML
+
+ register_for :xml
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/style.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/style.rb
new file mode 100644
index 000000000..c2977c5f8
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/style.rb
@@ -0,0 +1,20 @@
+module CodeRay
+
+ # This module holds the Style class and its subclasses.
+ #
+ # See Plugin.
+ module Styles
+ extend PluginHost
+ plugin_path File.dirname(__FILE__), 'styles'
+
+ class Style
+ extend Plugin
+ plugin_host Styles
+
+ DEFAULT_OPTIONS = { }
+
+ end
+
+ end
+
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/styles/_map.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/styles/_map.rb
new file mode 100644
index 000000000..52035fea3
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/styles/_map.rb
@@ -0,0 +1,7 @@
+module CodeRay
+module Styles
+
+ default :cycnus
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/styles/cycnus.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/styles/cycnus.rb
new file mode 100644
index 000000000..7747c753f
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/styles/cycnus.rb
@@ -0,0 +1,127 @@
+module CodeRay
+module Styles
+
+ class Cycnus < Style
+
+ register_for :cycnus
+
+ code_background = '#f8f8f8'
+ numbers_background = '#def'
+ border_color = 'silver'
+ normal_color = '#100'
+
+ CSS_MAIN_STYLES = <<-MAIN
+.CodeRay {
+ background-color: #{code_background};
+ border: 1px solid #{border_color};
+ font-family: 'Courier New', 'Terminal', monospace;
+ color: #{normal_color};
+}
+.CodeRay pre { margin: 0px }
+
+div.CodeRay { }
+
+span.CodeRay { white-space: pre; border: 0px; padding: 2px }
+
+table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px }
+table.CodeRay td { padding: 2px 4px; vertical-align: top }
+
+.CodeRay .line_numbers, .CodeRay .no {
+ background-color: #{numbers_background};
+ color: gray;
+ text-align: right;
+}
+.CodeRay .line_numbers tt { font-weight: bold }
+.CodeRay .no { padding: 0px 4px }
+.CodeRay .code { width: 100% }
+
+ol.CodeRay { font-size: 10pt }
+ol.CodeRay li { white-space: pre }
+
+.CodeRay .code pre { overflow: auto }
+ MAIN
+
+ TOKEN_COLORS = <<-'TOKENS'
+.debug { color:white ! important; background:blue ! important; }
+
+.af { color:#00C }
+.an { color:#007 }
+.av { color:#700 }
+.aw { color:#C00 }
+.bi { color:#509; font-weight:bold }
+.c { color:#666; }
+
+.ch { color:#04D }
+.ch .k { color:#04D }
+.ch .dl { color:#039 }
+
+.cl { color:#B06; font-weight:bold }
+.co { color:#036; font-weight:bold }
+.cr { color:#0A0 }
+.cv { color:#369 }
+.df { color:#099; font-weight:bold }
+.di { color:#088; font-weight:bold }
+.dl { color:black }
+.do { color:#970 }
+.ds { color:#D42; font-weight:bold }
+.e { color:#666; font-weight:bold }
+.en { color:#800; font-weight:bold }
+.er { color:#F00; background-color:#FAA }
+.ex { color:#F00; font-weight:bold }
+.fl { color:#60E; font-weight:bold }
+.fu { color:#06B; font-weight:bold }
+.gv { color:#d70; font-weight:bold }
+.hx { color:#058; font-weight:bold }
+.i { color:#00D; font-weight:bold }
+.ic { color:#B44; font-weight:bold }
+
+.il { background: #eee }
+.il .il { background: #ddd }
+.il .il .il { background: #ccc }
+.il .idl { font-weight: bold; color: #888 }
+
+.in { color:#B2B; font-weight:bold }
+.iv { color:#33B }
+.la { color:#970; font-weight:bold }
+.lv { color:#963 }
+.oc { color:#40E; font-weight:bold }
+.of { color:#000; font-weight:bold }
+.op { }
+.pc { color:#038; font-weight:bold }
+.pd { color:#369; font-weight:bold }
+.pp { color:#579 }
+.pt { color:#339; font-weight:bold }
+.r { color:#080; font-weight:bold }
+
+.rx { background-color:#fff0ff }
+.rx .k { color:#808 }
+.rx .dl { color:#404 }
+.rx .mod { color:#C2C }
+.rx .fu { color:#404; font-weight: bold }
+
+.s { background-color:#fff0f0 }
+.s .s { background-color:#ffe0e0 }
+.s .s .s { background-color:#ffd0d0 }
+.s .k { color:#D20 }
+.s .dl { color:#710 }
+
+.sh { background-color:#f0fff0 }
+.sh .k { color:#2B2 }
+.sh .dl { color:#161 }
+
+.sy { color:#A60 }
+.sy .k { color:#A60 }
+.sy .dl { color:#630 }
+
+.ta { color:#070 }
+.tf { color:#070; font-weight:bold }
+.ts { color:#D70; font-weight:bold }
+.ty { color:#339; font-weight:bold }
+.v { color:#036 }
+.xt { color:#444 }
+ TOKENS
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/styles/murphy.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/styles/murphy.rb
new file mode 100644
index 000000000..b42f0e043
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/styles/murphy.rb
@@ -0,0 +1,119 @@
+module CodeRay
+module Styles
+
+ class Murphy < Style
+
+ register_for :murphy
+
+ code_background = '#001129'
+ numbers_background = code_background
+ border_color = 'silver'
+ normal_color = '#C0C0C0'
+
+ CSS_MAIN_STYLES = <<-MAIN
+.CodeRay {
+ background-color: #{code_background};
+ border: 1px solid #{border_color};
+ font-family: 'Courier New', 'Terminal', monospace;
+ color: #{normal_color};
+}
+.CodeRay pre { margin: 0px; }
+
+div.CodeRay { }
+
+span.CodeRay { white-space: pre; border: 0px; padding: 2px; }
+
+table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px; }
+table.CodeRay td { padding: 2px 4px; vertical-align: top; }
+
+.CodeRay .line_numbers, .CodeRay .no {
+ background-color: #{numbers_background};
+ color: gray;
+ text-align: right;
+}
+.CodeRay .line_numbers tt { font-weight: bold; }
+.CodeRay .no { padding: 0px 4px; }
+.CodeRay .code { width: 100%; }
+
+ol.CodeRay { font-size: 10pt; }
+ol.CodeRay li { white-space: pre; }
+
+.CodeRay .code pre { overflow: auto; }
+ MAIN
+
+ TOKEN_COLORS = <<-'TOKENS'
+.af { color:#00C; }
+.an { color:#007; }
+.av { color:#700; }
+.aw { color:#C00; }
+.bi { color:#509; font-weight:bold; }
+.c { color:#555; background-color: black; }
+
+.ch { color:#88F; }
+.ch .k { color:#04D; }
+.ch .dl { color:#039; }
+
+.cl { color:#e9e; font-weight:bold; }
+.co { color:#5ED; font-weight:bold; }
+.cr { color:#0A0; }
+.cv { color:#ccf; }
+.df { color:#099; font-weight:bold; }
+.di { color:#088; font-weight:bold; }
+.dl { color:black; }
+.do { color:#970; }
+.ds { color:#D42; font-weight:bold; }
+.e { color:#666; font-weight:bold; }
+.er { color:#F00; background-color:#FAA; }
+.ex { color:#F00; font-weight:bold; }
+.fl { color:#60E; font-weight:bold; }
+.fu { color:#5ed; font-weight:bold; }
+.gv { color:#f84; }
+.hx { color:#058; font-weight:bold; }
+.i { color:#66f; font-weight:bold; }
+.ic { color:#B44; font-weight:bold; }
+.il { }
+.in { color:#B2B; font-weight:bold; }
+.iv { color:#aaf; }
+.la { color:#970; font-weight:bold; }
+.lv { color:#963; }
+.oc { color:#40E; font-weight:bold; }
+.of { color:#000; font-weight:bold; }
+.op { }
+.pc { color:#08f; font-weight:bold; }
+.pd { color:#369; font-weight:bold; }
+.pp { color:#579; }
+.pt { color:#66f; font-weight:bold; }
+.r { color:#5de; font-weight:bold; }
+
+.rx { background-color:#221133; }
+.rx .k { color:#f8f; }
+.rx .dl { color:#f0f; }
+.rx .mod { color:#f0b; }
+.rx .fu { color:#404; font-weight: bold; }
+
+.s { background-color:#331122; }
+.s .s { background-color:#ffe0e0; }
+.s .s .s { background-color:#ffd0d0; }
+.s .k { color:#F88; }
+.s .dl { color:#f55; }
+
+.sh { background-color:#f0fff0; }
+.sh .k { color:#2B2; }
+.sh .dl { color:#161; }
+
+.sy { color:#Fc8; }
+.sy .k { color:#Fc8; }
+.sy .dl { color:#F84; }
+
+.ta { color:#070; }
+.tf { color:#070; font-weight:bold; }
+.ts { color:#D70; font-weight:bold; }
+.ty { color:#339; font-weight:bold; }
+.v { color:#036; }
+.xt { color:#444; }
+ TOKENS
+
+ end
+
+end
+end
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/token_classes.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/token_classes.rb
new file mode 100644
index 000000000..d0de855a2
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/token_classes.rb
@@ -0,0 +1,71 @@
+module CodeRay
+ class Tokens
+ ClassOfKind = Hash.new do |h, k|
+ h[k] = k.to_s
+ end
+ ClassOfKind.update with = {
+ :attribute_name => 'an',
+ :attribute_name_fat => 'af',
+ :attribute_value => 'av',
+ :attribute_value_fat => 'aw',
+ :bin => 'bi',
+ :char => 'ch',
+ :class => 'cl',
+ :class_variable => 'cv',
+ :color => 'cr',
+ :comment => 'c',
+ :constant => 'co',
+ :content => 'k',
+ :definition => 'df',
+ :delimiter => 'dl',
+ :directive => 'di',
+ :doc => 'do',
+ :doc_string => 'ds',
+ :entity => 'en',
+ :error => 'er',
+ :escape => 'e',
+ :exception => 'ex',
+ :float => 'fl',
+ :function => 'fu',
+ :global_variable => 'gv',
+ :hex => 'hx',
+ :include => 'ic',
+ :inline => 'il',
+ :inline_delimiter => 'idl',
+ :instance_variable => 'iv',
+ :integer => 'i',
+ :interpreted => 'in',
+ :label => 'la',
+ :local_variable => 'lv',
+ :modifier => 'mod',
+ :oct => 'oc',
+ :operator_fat => 'of',
+ :pre_constant => 'pc',
+ :pre_type => 'pt',
+ :predefined => 'pd',
+ :preprocessor => 'pp',
+ :regexp => 'rx',
+ :reserved => 'r',
+ :shell => 'sh',
+ :string => 's',
+ :symbol => 'sy',
+ :tag => 'ta',
+ :tag_fat => 'tf',
+ :tag_special => 'ts',
+ :type => 'ty',
+ :variable => 'v',
+ :xml_text => 'xt',
+
+ :ident => :NO_HIGHLIGHT, # 'id'
+ #:operator => 'op',
+ :operator => :NO_HIGHLIGHT, # 'op'
+ :space => :NO_HIGHLIGHT, # 'sp'
+ :plain => :NO_HIGHLIGHT,
+ }
+ ClassOfKind[:procedure] = ClassOfKind[:method] = ClassOfKind[:function]
+ ClassOfKind[:open] = ClassOfKind[:close] = ClassOfKind[:delimiter]
+ ClassOfKind[:nesting_delimiter] = ClassOfKind[:delimiter]
+ ClassOfKind[:escape] = ClassOfKind[:delimiter]
+ #ClassOfKind.default = ClassOfKind[:error] or raise 'no class found for :error!'
+ end
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/tokens.rb b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/tokens.rb
new file mode 100644
index 000000000..26c923f42
--- /dev/null
+++ b/rest_sys/vendor/plugins/coderay-0.7.6.227/lib/coderay/tokens.rb
@@ -0,0 +1,383 @@
+module CodeRay
+
+ # = Tokens
+ #
+ # The Tokens class represents a list of tokens returnd from
+ # a Scanner.
+ #
+ # A token is not a special object, just a two-element Array
+ # consisting of
+ # * the _token_ _kind_ (a Symbol representing the type of the token)
+ # * the _token_ _text_ (the original source of the token in a String)
+ #
+ # A token looks like this:
+ #
+ # [:comment, '# It looks like this']
+ # [:float, '3.1415926']
+ # [:error, 'äöü']
+ #
+ # Some scanners also yield some kind of sub-tokens, represented by special
+ # token texts, namely :open and :close .
+ #
+ # The Ruby scanner, for example, splits "a string" into:
+ #
+ # [
+ # [:open, :string],
+ # [:delimiter, '"'],
+ # [:content, 'a string'],
+ # [:delimiter, '"'],
+ # [:close, :string]
+ # ]
+ #
+ # Tokens is also the interface between Scanners and Encoders:
+ # The input is split and saved into a Tokens object. The Encoder
+ # then builds the output from this object.
+ #
+ # Thus, the syntax below becomes clear:
+ #
+ # CodeRay.scan('price = 2.59', :ruby).html
+ # # the Tokens object is here -------^
+ #
+ # See how small it is? ;)
+ #
+ # Tokens gives you the power to handle pre-scanned code very easily:
+ # You can convert it to a webpage, a YAML file, or dump it into a gzip'ed string
+ # that you put in your DB.
+ #
+ # Tokens' subclass TokenStream allows streaming to save memory.
+ class Tokens < Array
+
+ class << self
+
+ # Convert the token to a string.
+ #
+ # This format is used by Encoders.Tokens.
+ # It can be reverted using read_token.
+ def write_token text, type
+ if text.is_a? String
+ "#{type}\t#{escape(text)}\n"
+ else
+ ":#{text}\t#{type}\t\n"
+ end
+ end
+
+ # Read a token from the string.
+ #
+ # Inversion of write_token.
+ #
+ # TODO Test this!
+ def read_token token
+ type, text = token.split("\t", 2)
+ if type[0] == ?:
+ [text.to_sym, type[1..-1].to_sym]
+ else
+ [type.to_sym, unescape(text)]
+ end
+ end
+
+ # Escapes a string for use in write_token.
+ def escape text
+ text.gsub(/[\n\\]/, '\\\\\&')
+ end
+
+ # Unescapes a string created by escape.
+ def unescape text
+ text.gsub(/\\[\n\\]/) { |m| m[1,1] }
+ end
+
+ end
+
+ # Whether the object is a TokenStream.
+ #
+ # Returns false.
+ def stream?
+ false
+ end
+
+ # Iterates over all tokens.
+ #
+ # If a filter is given, only tokens of that kind are yielded.
+ def each kind_filter = nil, &block
+ unless kind_filter
+ super(&block)
+ else
+ super() do |text, kind|
+ next unless kind == kind_filter
+ yield text, kind
+ end
+ end
+ end
+
+ # Iterates over all text tokens.
+ # Range tokens like [:open, :string] are left out.
+ #
+ # Example:
+ # tokens.each_text_token { |text, kind| text.replace html_escape(text) }
+ def each_text_token
+ each do |text, kind|
+ next unless text.is_a? ::String
+ yield text, kind
+ end
+ end
+
+ # Encode the tokens using encoder.
+ #
+ # encoder can be
+ # * a symbol like :html oder :statistic
+ # * an Encoder class
+ # * an Encoder object
+ #
+ # options are passed to the encoder.
+ def encode encoder, options = {}
+ unless encoder.is_a? Encoders::Encoder
+ unless encoder.is_a? Class
+ encoder_class = Encoders[encoder]
+ end
+ encoder = encoder_class.new options
+ end
+ encoder.encode_tokens self, options
+ end
+
+
+ # Turn into a string using Encoders::Text.
+ #
+ # +options+ are passed to the encoder if given.
+ def to_s options = {}
+ encode :text, options
+ end
+
+
+ # Redirects unknown methods to encoder calls.
+ #
+ # For example, if you call +tokens.html+, the HTML encoder
+ # is used to highlight the tokens.
+ def method_missing meth, options = {}
+ Encoders[meth].new(options).encode_tokens self
+ end
+
+ # Returns the tokens compressed by joining consecutive
+ # tokens of the same kind.
+ #
+ # This can not be undone, but should yield the same output
+ # in most Encoders. It basically makes the output smaller.
+ #
+ # Combined with dump, it saves space for the cost of time.
+ #
+ # If the scanner is written carefully, this is not required -
+ # for example, consecutive //-comment lines could already be
+ # joined in one comment token by the Scanner.
+ def optimize
+ print ' Tokens#optimize: before: %d - ' % size if $DEBUG
+ last_kind = last_text = nil
+ new = self.class.new
+ for text, kind in self
+ if text.is_a? String
+ if kind == last_kind
+ last_text << text
+ else
+ new << [last_text, last_kind] if last_kind
+ last_text = text
+ last_kind = kind
+ end
+ else
+ new << [last_text, last_kind] if last_kind
+ last_kind = last_text = nil
+ new << [text, kind]
+ end
+ end
+ new << [last_text, last_kind] if last_kind
+ print 'after: %d (%d saved = %2.0f%%)' %
+ [new.size, size - new.size, 1.0 - (new.size.to_f / size)] if $DEBUG
+ new
+ end
+
+ # Compact the object itself; see optimize.
+ def optimize!
+ replace optimize
+ end
+
+ # Ensure that all :open tokens have a correspondent :close one.
+ #
+ # TODO: Test this!
+ def fix
+ # Check token nesting using a stack of kinds.
+ opened = []
+ for token, kind in self
+ if token == :open
+ opened.push kind
+ elsif token == :close
+ expected = opened.pop
+ if kind != expected
+ # Unexpected :close; decide what to do based on the kind:
+ # - token was opened earlier: also close tokens in between
+ # - token was never opened: delete the :close (skip with next)
+ next unless opened.rindex expected
+ tokens << [:close, kind] until (kind = opened.pop) == expected
+ end
+ end
+ tokens << [token, kind]
+ end
+ # Close remaining opened tokens
+ tokens << [:close, kind] while kind = opened.pop
+ tokens
+ end
+
+ def fix!
+ replace fix
+ end
+
+ # Makes sure that:
+ # - newlines are single tokens
+ # (which means all other token are single-line)
+ # - there are no open tokens at the end the line
+ #
+ # This makes it simple for encoders that work line-oriented,
+ # like HTML with list-style numeration.
+ def split_into_lines
+ raise NotImplementedError
+ end
+
+ def split_into_lines!
+ replace split_into_lines
+ end
+
+ # Dumps the object into a String that can be saved
+ # in files or databases.
+ #
+ # The dump is created with Marshal.dump;
+ # In addition, it is gzipped using GZip.gzip.
+ #
+ # The returned String object includes Undumping
+ # so it has an #undump method. See Tokens.load.
+ #
+ # You can configure the level of compression,
+ # but the default value 7 should be what you want
+ # in most cases as it is a good compromise between
+ # speed and compression rate.
+ #
+ # See GZip module.
+ def dump gzip_level = 7
+ require 'coderay/helpers/gzip_simple'
+ dump = Marshal.dump self
+ dump = dump.gzip gzip_level
+ dump.extend Undumping
+ end
+
+ # The total size of the tokens.
+ # Should be equal to the input size before
+ # scanning.
+ def text_size
+ size = 0
+ each_text_token do |t, k|
+ size + t.size
+ end
+ size
+ end
+
+ # The total size of the tokens.
+ # Should be equal to the input size before
+ # scanning.
+ def text
+ map { |t, k| t if t.is_a? ::String }.join
+ end
+
+ # Include this module to give an object an #undump
+ # method.
+ #
+ # The string returned by Tokens.dump includes Undumping.
+ module Undumping
+ # Calls Tokens.load with itself.
+ def undump
+ Tokens.load self
+ end
+ end
+
+ # Undump the object using Marshal.load, then
+ # unzip it using GZip.gunzip.
+ #
+ # The result is commonly a Tokens object, but
+ # this is not guaranteed.
+ def Tokens.load dump
+ require 'coderay/helpers/gzip_simple'
+ dump = dump.gunzip
+ @dump = Marshal.load dump
+ end
+
+ end
+
+
+ # = TokenStream
+ #
+ # The TokenStream class is a fake Array without elements.
+ #
+ # It redirects the method << to a block given at creation.
+ #
+ # This allows scanners and Encoders to use streaming (no
+ # tokens are saved, the input is highlighted the same time it
+ # is scanned) with the same code.
+ #
+ # See CodeRay.encode_stream and CodeRay.scan_stream
+ class TokenStream < Tokens
+
+ # Whether the object is a TokenStream.
+ #
+ # Returns true.
+ def stream?
+ true
+ end
+
+ # The Array is empty, but size counts the tokens given by <<.
+ attr_reader :size
+
+ # Creates a new TokenStream that calls +block+ whenever
+ # its << method is called.
+ #
+ # Example:
+ #
+ # require 'coderay'
+ #
+ # token_stream = CodeRay::TokenStream.new do |kind, text|
+ # puts 'kind: %s, text size: %d.' % [kind, text.size]
+ # end
+ #
+ # token_stream << [:regexp, '/\d+/']
+ # #-> kind: rexpexp, text size: 5.
+ #
+ def initialize &block
+ raise ArgumentError, 'Block expected for streaming.' unless block
+ @callback = block
+ @size = 0
+ end
+
+ # Calls +block+ with +token+ and increments size.
+ #
+ # Returns self.
+ def << token
+ @callback.call token
+ @size += 1
+ self
+ end
+
+ # This method is not implemented due to speed reasons. Use Tokens.
+ def text_size
+ raise NotImplementedError,
+ 'This method is not implemented due to speed reasons.'
+ end
+
+ # A TokenStream cannot be dumped. Use Tokens.
+ def dump
+ raise NotImplementedError, 'A TokenStream cannot be dumped.'
+ end
+
+ # A TokenStream cannot be optimized. Use Tokens.
+ def optimize
+ raise NotImplementedError, 'A TokenStream cannot be optimized.'
+ end
+
+ end
+
+
+ # Token name abbreviations
+ require 'coderay/token_classes'
+
+end
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/CHANGELOG b/rest_sys/vendor/plugins/gloc-1.1.0/CHANGELOG
new file mode 100644
index 000000000..6392d7cbe
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/CHANGELOG
@@ -0,0 +1,19 @@
+== Version 1.1 (28 May 2006)
+
+* The charset for each and/or all languages can now be easily configured.
+* Added a ActionController filter that auto-detects the client language.
+* The rake task "sort" now merges lines that match 100%, and warns if duplicate keys are found.
+* Rule support. Create flexible rules to handle issues such as pluralization.
+* Massive speed and stability improvements to development mode.
+* Added Russian strings. (Thanks to Evgeny Lineytsev)
+* Complete RDoc documentation.
+* Improved helpers.
+* GLoc now configurable via get_config and set_config
+* Added an option to tell GLoc to output various verbose information.
+* More useful functions such as set_language_if_valid, similar_language
+* GLoc's entire internal state can now be backed up and restored.
+
+
+== Version 1.0 (17 April 2006)
+
+* Initial public release.
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/MIT-LICENSE b/rest_sys/vendor/plugins/gloc-1.1.0/MIT-LICENSE
new file mode 100644
index 000000000..081774a65
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/MIT-LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2005-2006 David Barri
+
+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.
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/README b/rest_sys/vendor/plugins/gloc-1.1.0/README
new file mode 100644
index 000000000..66f8e5e9f
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/README
@@ -0,0 +1,208 @@
+= About
+
+=== Preface
+I originally started designing this on weekends and after work in 2005. We started to become very interested in Rails at work and I wanted to get some experience with ruby with before we started using it full-time. I didn't have very many ideas for anything interesting to create so, because we write a lot of multilingual webapps at my company, I decided to write a localization library. That way if my little hobby project developed into something decent, I could at least put it to good use.
+And here we are in 2006, my little hobby project has come a long way and become quite a useful piece of software. Not only do I use it in production sites I write at work, but I also prefer it to other existing alternatives. Therefore I have decided to make it publicly available, and I hope that other developers will find it useful too.
+
+=== About
+GLoc is a localization library. It doesn't aim to do everything l10n-related that you can imagine, but what it does, it does very well. It was originally designed as a Rails plugin, but can also be used for plain ruby projects. Here are a list of its main features:
+* Lightweight and efficient.
+* Uses file-based string bundles. Strings can also be set directly.
+* Intelligent, cascading language configuration.
+* Create flexible rules to handle issues such as pluralization.
+* Includes a ActionController filter that auto-detects the client language.
+* Works perfectly with Rails Engines and allows strings to be overridden just as easily as controllers, models, etc.
+* Automatically localizes Rails functions such as distance_in_minutes, select_month etc
+* Supports different charsets. You can even specify the encoding to use for each language seperately.
+* Special Rails mods/helpers.
+
+=== What does GLoc mean?
+If you're wondering about the name "GLoc", I'm sure you're not alone.
+This project was originally just called "Localization" which was a bit too common, so when I decided to release it I decided to call it "Golly's Localization Library" instead (Golly is my nickname), and that was long and boring so I then abbreviated that to "GLoc". What a fun story!!
+
+=== Localization helpers
+This also includes a few helpers for common situations such as displaying localized date, time, "yes" or "no", etc.
+
+=== Rails Localization
+At the moment, unless you manually remove the require 'gloc-rails-text' line from init.rb, this plugin overrides certain Rails functions to provide multilingual versions. This automatically localizes functions such as select_date(), distance_of_time_in_words() and more...
+The strings can be found in lang/*.yml.
+NOTE: This is not complete. Timezones and countries are not currently localized.
+
+
+
+
+= Usage
+
+=== Quickstart
+
+Windows users will need to first install iconv. http://wiki.rubyonrails.com/rails/pages/iconv
+
+* Create a dir "#{RAILS_ROOT}/lang"
+* Create a file "#{RAILS_ROOT}/lang/en.yml" and write your strings. The format is "key: string". Save it as UTF-8. If you save it in a different encoding, add a key called file_charset (eg. "file_charset: iso-2022-jp")
+* Put the following in config/environment.rb and change the values as you see fit. The following example is for an app that uses English and Japanese, with Japanese being the default.
+ GLoc.set_config :default_language => :ja
+ GLoc.clear_strings_except :en, :ja
+ GLoc.set_kcode
+ GLoc.load_localized_strings
+* Add 'include GLoc' to all classes that will use localization. This is added to most Rails classes automatically.
+* Optionally, you can set the language for models and controllers by simply inserting set_language :en in classes and/or methods.
+* To use localized strings, replace text such as "Welcome" with l(:welcome_string_key) , and "Hello #{name}." with l(:hello_string_key, name) . (Of course the strings will need to exist in your string bundle.)
+
+There is more functionality provided by this plugin, that is not demonstrated above. Please read the API summary for details.
+
+=== API summary
+
+The following methods are added as both class methods and instance methods to modules/classes that include GLoc. They are also available as class methods of GLoc.
+ current_language # Returns the current language
+ l(symbol, *arguments) # Returns a localized string
+ ll(lang, symbol, *arguments) # Returns a localized string in a specific language
+ ltry(possible_key) # Returns a localized string if passed a Symbol, else returns the same argument passed
+ lwr(symbol, *arguments) # Uses the default rule to return a localized string.
+ lwr_(rule, symbol, *arguments) # Uses a specified rule to return a localized string.
+ l_has_string?(symbol) # Checks if a localized string exists
+ set_language(language) # Sets the language for the current class or class instance
+ set_language_if_valid(lang) # Sets the current language if the language passed is a valid language
+
+The GLoc module also defines the following class methods:
+ add_localized_strings(lang, symbol_hash, override=true) # Adds a hash of localized strings
+ backup_state(clear=false) # Creates a backup of GLoc's internal state and optionally clears everything too
+ clear_strings(*languages) # Removes localized strings from memory
+ clear_strings_except(*languages) # Removes localized strings from memory except for those of certain specified languages
+ get_charset(lang) # Returns the charset used to store localized strings in memory
+ get_config(key) # Returns a GLoc configuration value (see below)
+ load_localized_strings(dir=nil, override=true) # Loads localized strings from all YML files in a given directory
+ restore_state(state) # Restores a backup of GLoc's internal state
+ set_charset(new_charset, *langs) # Sets the charset used to internally store localized strings
+ set_config(hash) # Sets GLoc configuration values (see below)
+ set_kcode(charset=nil) # Sets the $KCODE global variable
+ similar_language(language) # Tries to find a valid language that is similar to the argument passed
+ valid_languages # Returns an array of (currently) valid languages (ie. languages for which localized data exists)
+ valid_language?(language) # Checks whether any localized strings are in memory for a given language
+
+GLoc uses the following configuration items. They can be accessed via get_config and set_config .
+ :default_cookie_name
+ :default_language
+ :default_param_name
+ :raise_string_not_found_errors
+ :verbose
+
+The GLoc module is automatically included in the following classes:
+ ActionController::Base
+ ActionMailer::Base
+ ActionView::Base
+ ActionView::Helpers::InstanceTag
+ ActiveRecord::Base
+ ActiveRecord::Errors
+ ApplicationHelper
+ Test::Unit::TestCase
+
+The GLoc module also defines the following controller filters:
+ autodetect_language_filter
+
+GLoc also makes the following change to Rails:
+* Views for ActionMailer are now #{view_name}_#{language}.rb rather than just #{view_name}.rb
+* All ActiveRecord validation class methods now accept a localized string key (symbol) as a :message value.
+* ActiveRecord::Errors.add now accepts symbols as valid message values. At runtime these symbols are converted to localized strings using the current_language of the base record.
+* ActiveRecord::Errors.add now accepts arrays as arguments so that printf-style strings can be generated at runtime. This also applies to the validates_* class methods.
+ Eg. validates_xxxxxx_of :name, :message => ['Your name must be at least %d characters.', MIN_LEN]
+ Eg. validates_xxxxxx_of :name, :message => [:user_error_validation_name_too_short, MIN_LEN]
+* Instances of ActiveView inherit their current_language from the controller (or mailer) creating them.
+
+This plugin also adds the following rake tasks:
+ * gloc:sort - Sorts the keys in the lang ymls (also accepts a DIR argument)
+
+=== Cascading language configuration
+
+The language can be set at three levels:
+ 1. The default # GLoc.get_config :default_language
+ 2. Class level # class A; set_language :de; end
+ 3. Instance level # b= B.new; b.set_language :zh
+
+Instance level has the highest priority and the default has the lowest.
+
+Because GLoc is included at class level too, it becomes easy to associate languages with contexts.
+For example:
+ class Student
+ set_language :en
+ def say_hello
+ puts "We say #{l :hello} but our teachers say #{Teacher.l :hello}"
+ end
+ end
+
+=== Rules
+
+There are often situations when depending on the value of one or more variables, the surrounding text
+changes. The most common case of this is pluralization. Rather than hardcode these rules, they are
+completely definable by the user so that the user can eaasily accomodate for more complicated grammatical
+rules such as those found in Russian and Polish (or so I hear). To define a rule, simply include a string
+in the string bundle whose key begins with "_gloc_rule_" and then write ruby code as the value. The ruby
+code will be converted to a Proc when the string bundle is first read, and should return a prefix that will
+be appended to the string key at runtime to point to a new string. Make sense? Probably not... Please look
+at the following example and I am sure it will all make sense.
+
+Simple example (string bundle / en.yml)
+ _gloc_rule_default: ' |n| n==1 ? "_single" : "_plural" '
+ man_count_plural: There are %d men.
+ man_count_single: There is 1 man.
+
+Simple example (code)
+ lwr(:man_count, 1) # => There is 1 man.
+ lwr(:man_count, 8) # => There are 8 men.
+
+To use rules other than the default simply call lwr_ instead of lwr, and specify the rule.
+
+Example #2 (string bundle / en.yml)
+ _gloc_rule_default: ' |n| n==1 ? "_single" : "_plural" '
+ _gloc_rule_custom: ' |n| return "_none" if n==0; return "_heaps" if n>100; n==1 ? "_single" : "_plural" '
+ man_count_none: There are no men.
+ man_count_heaps: There are heaps of men!!
+ man_count_plural: There are %d men.
+ man_count_single: There is 1 man.
+
+Example #2 (code)
+ lwr_(:custom, :man_count, 0) # => There are no men.
+ lwr_(:custom, :man_count, 1) # => There is 1 man.
+ lwr_(:custom, :man_count, 8) # => There are 8 men.
+ lwr_(:custom, :man_count, 150) # => There are heaps of men!!
+
+
+=== Helpers
+
+GLoc includes the following helpers:
+ l_age(age) # Returns a localized version of an age. eg "3 years old"
+ l_date(date) # Returns a date in a localized format
+ l_datetime(date) # Returns a date+time in a localized format
+ l_datetime_short(date) # Returns a date+time in a localized short format.
+ l_lang_name(l,dl=nil) # Returns the name of a language (you must supply your own strings)
+ l_strftime(date,fmt) # Formats a date/time in a localized format.
+ l_time(date) # Returns a time in a localized format
+ l_YesNo(value) # Returns localized string of "Yes" or "No" depending on the arg
+ l_yesno(value) # Returns localized string of "yes" or "no" depending on the arg
+
+=== Rails localization
+
+Not all of Rails is covered but the following functions are:
+ distance_of_time_in_words
+ select_day
+ select_month
+ select_year
+ add_options
+
+
+
+
+= FAQ
+
+==== How do I use it in engines?
+Simply put this in your init_engine.rb
+ GLoc.load_localized_strings File.join(File.dirname(__FILE__),'lang')
+That way your engines strings will be loaded when the engine is started. Just simply make sure that you load your application strings after you start your engines to safely override any engine strings.
+
+==== Why am I getting an Iconv::IllegalSequence error when calling GLoc.set_charset?
+By default GLoc loads all of its default strings at startup. For example, calling set_charset 'iso-2022-jp' will cause this error because Russian strings are loaded by default, and the Russian strings use characters that cannot be expressed in the ISO-2022-JP charset.
+Before calling set_charset you should call clear_strings_except to remove strings from any languages that you will not be using.
+Alternatively, you can simply specify the language(s) as follows, set_charset 'iso-2022-jp', :ja .
+
+==== How do I make GLoc ignore StringNotFoundErrors?
+Disable it as follows:
+ GLoc.set_config :raise_string_not_found_errors => false
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/Rakefile b/rest_sys/vendor/plugins/gloc-1.1.0/Rakefile
new file mode 100644
index 000000000..a5b8fe762
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/Rakefile
@@ -0,0 +1,15 @@
+Dir.glob("#{File.dirname(__FILE__)}/tasks/*.rake").each {|f| load f}
+
+task :default => 'gloc:sort'
+
+# RDoc task
+require 'rake/rdoctask'
+Rake::RDocTask.new() { |rdoc|
+ rdoc.rdoc_dir = 'doc'
+ rdoc.title = "GLoc Localization Library Documentation"
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README', 'CHANGELOG')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+ rdoc.rdoc_files.exclude('lib/gloc-dev.rb')
+ rdoc.rdoc_files.exclude('lib/gloc-config.rb')
+}
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionController/Filters/ClassMethods.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionController/Filters/ClassMethods.html
new file mode 100644
index 000000000..fba33b5b5
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionController/Filters/ClassMethods.html
@@ -0,0 +1,230 @@
+
+
+
+
+
+ Module: ActionController::Filters::ClassMethods
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Public Instance methods
+
+
+
+
+
+
+
+
+This filter attempts to auto-detect the clients desired language. It first
+checks the params, then a cookie and then the HTTP_ACCEPT_LANGUAGE request
+header. If a language is found to match or be similar to a currently valid
+language, then it sets the current_language of the controller.
+
+
+ class ExampleController < ApplicationController
+ set_language :en
+ autodetect_language_filter :except => 'monkey', :on_no_lang => :lang_not_autodetected_callback
+ autodetect_language_filter :only => 'monkey', :check_cookie => 'monkey_lang', :check_accept_header => false
+ ...
+ def lang_not_autodetected_callback
+ redirect_to somewhere
+ end
+ end
+
+
+The args for this filter are exactly the same the arguments of
+before_filter with the following exceptions:
+
+
+:check_params — If false, then params will not be checked
+for a language. If a String, then this will value will be used as the name
+of the param.
+
+
+:check_cookie — If false, then the cookie will not be
+checked for a language. If a String, then this will value will be used as
+the name of the cookie.
+
+
+:check_accept_header — If false, then HTTP_ACCEPT_LANGUAGE
+will not be checked for a language.
+
+
+:on_set_lang — You can specify the name of a callback
+function to be called when the language is successfully detected and set.
+The param must be a Symbol or a String which is the name of the function.
+The callback function must accept one argument (the language) and must be
+instance level.
+
+
+:on_no_lang — You can specify the name of a callback
+function to be called when the language couldn’t be detected
+automatically. The param must be a Symbol or a String which is the name of
+the function. The callback function must be instance level.
+
+
+
+
+You override the default names of the param or cookie by calling GLoc.set_config :default_param_name
+=> ‘new_param_name‘ and GLoc.set_config :default_cookie_name
+=> ‘new_cookie_name‘ .
+
+
[Source]
+
+
+
+43: def autodetect_language_filter (* args )
+44: options = args .last .is_a? (Hash ) ? args .last : {}
+45: x = 'Proc.new { |c| l= nil;'
+46:
+47: unless (v = options .delete (:check_params )) == false
+48: name = v ? ":#{v}" : 'GLoc.get_config(:default_param_name)'
+49: x << "l ||= GLoc.similar_language(c.params[#{name}]);"
+50: end
+51:
+52: unless (v = options .delete (:check_cookie )) == false
+53: name = v ? ":#{v}" : 'GLoc.get_config(:default_cookie_name)'
+54: x << "l ||= GLoc.similar_language(c.send(:cookies)[#{name}]);"
+55: end
+56:
+57: unless options .delete (:check_accept_header ) == false
+58: x << %<
+59: unless l
+60: a= c.request.env['HTTP_ACCEPT_LANGUAGE'].split(/,|;/) rescue nil
+61: a.each {|x| l ||= GLoc.similar_language(x)} if a
+62: end; >
+63: end
+64:
+65: x << 'ret= true;'
+66: x << 'if l; c.set_language(l); c.headers[\'Content-Language\']= l.to_s; '
+67: if options .has_key? (:on_set_lang )
+68: x << "ret= c.#{options.delete(:on_set_lang)}(l);"
+69: end
+70: if options .has_key? (:on_no_lang )
+71: x << "else; ret= c.#{options.delete(:on_no_lang)};"
+72: end
+73: x << 'end; ret }'
+74:
+75:
+76: block = eval x
+77: before_filter (* args , & block )
+78: end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionMailer/Base.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionMailer/Base.html
new file mode 100644
index 000000000..056b23d85
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionMailer/Base.html
@@ -0,0 +1,140 @@
+
+
+
+
+
+ Class: ActionMailer::Base
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+In addition to including GLoc ,
+render_message is also overridden so that mail templates contain
+the current language at the end of the file. Eg. deliver_hello
+will render hello_en.rhtml .
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
External Aliases
+
+
+
+
+ render_message
+ ->
+ render_message_without_gloc
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionView/Base.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionView/Base.html
new file mode 100644
index 000000000..00767055d
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionView/Base.html
@@ -0,0 +1,174 @@
+
+
+
+
+
+ Class: ActionView::Base
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+initialize is overridden so that new instances of this class
+inherit the current language of the controller.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
External Aliases
+
+
+
+
+ initialize
+ ->
+ initialize_without_gloc
+
+
+
+
+
+
+
+
+
+
+
+
Public Class methods
+
+
+
+
+
+
+
+
[Source]
+
+
+
+109: def initialize (base_path = nil , assigns_for_first_render = {}, controller = nil )
+110: initialize_without_gloc (base_path , assigns_for_first_render , controller )
+111: set_language controller .current_language unless controller .nil?
+112: end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionView/Helpers/DateHelper.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionView/Helpers/DateHelper.html
new file mode 100644
index 000000000..84ca8fae3
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionView/Helpers/DateHelper.html
@@ -0,0 +1,348 @@
+
+
+
+
+
+ Module: ActionView::Helpers::DateHelper
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Constants
+
+
+
+
+ LOCALIZED_HELPERS
+ =
+ true
+
+
+ LOCALIZED_MONTHNAMES
+ =
+ {}
+
+
+ LOCALIZED_ABBR_MONTHNAMES
+ =
+ {}
+
+
+
+
+
+
+
+
+
+
+
+
+
Public Instance methods
+
+
+
+
+
+
+
+
+This method uses current_language to return a localized string.
+
+
[Source]
+
+
+
+16: def distance_of_time_in_words (from_time , to_time = 0 , include_seconds = false )
+17: from_time = from_time .to_time if from_time .respond_to? (:to_time )
+18: to_time = to_time .to_time if to_time .respond_to? (:to_time )
+19: distance_in_minutes = (((to_time - from_time ).abs )/ 60 ).round
+20: distance_in_seconds = ((to_time - from_time ).abs ).round
+21:
+22: case distance_in_minutes
+23: when 0 .. 1
+24: return (distance_in_minutes == 0 ) ? l (:actionview_datehelper_time_in_words_minute_less_than ) : l (:actionview_datehelper_time_in_words_minute_single ) unless include_seconds
+25: case distance_in_seconds
+26: when 0 .. 5 then lwr (:actionview_datehelper_time_in_words_second_less_than , 5 )
+27: when 6 .. 10 then lwr (:actionview_datehelper_time_in_words_second_less_than , 10 )
+28: when 11 .. 20 then lwr (:actionview_datehelper_time_in_words_second_less_than , 20 )
+29: when 21 .. 40 then l (:actionview_datehelper_time_in_words_minute_half )
+30: when 41 .. 59 then l (:actionview_datehelper_time_in_words_minute_less_than )
+31: else l (:actionview_datehelper_time_in_words_minute )
+32: end
+33:
+34: when 2 .. 45 then lwr (:actionview_datehelper_time_in_words_minute , distance_in_minutes )
+35: when 46 .. 90 then l (:actionview_datehelper_time_in_words_hour_about_single )
+36: when 90 .. 1440 then lwr (:actionview_datehelper_time_in_words_hour_about , (distance_in_minutes .to_f / 60.0 ).round )
+37: when 1441 .. 2880 then lwr (:actionview_datehelper_time_in_words_day , 1 )
+38: else lwr (:actionview_datehelper_time_in_words_day , (distance_in_minutes / 1440 ).round )
+39: end
+40: end
+
+
+
+
+
+
+
+
+
+
+
+
+This method has been modified so that a localized string can be appended to
+the day numbers.
+
+
[Source]
+
+
+
+43: def select_day (date , options = {})
+44: day_options = []
+45: prefix = l :actionview_datehelper_select_day_prefix
+46:
+47: 1 .upto (31 ) do | day |
+48: day_options << ((date && (date .kind_of? (Fixnum ) ? date : date .day ) == day ) ?
+49: %(<option value="#{day}" selected="selected">#{day}#{prefix}</option>\n) :
+50: %(<option value="#{day}">#{day}#{prefix}</option>\n)
+51: )
+52: end
+53:
+54: select_html (options [:field_name ] || 'day' , day_options , options [:prefix ], options [:include_blank ], options [:discard_type ], options [:disabled ])
+55: end
+
+
+
+
+
+
+
+
+
+
+
+
+This method has been modified so that
+
+
+the month names are localized.
+
+
+it uses options: :min_date , :max_date ,
+:start_month , :end_month
+
+
+a localized string can be appended to the month numbers when the
+:use_month_numbers option is specified.
+
+
+
+
[Source]
+
+
+
+61: def select_month (date , options = {})
+62: unless LOCALIZED_MONTHNAMES .has_key? (current_language )
+63: LOCALIZED_MONTHNAMES [current_language ] = ['' ] + l (:actionview_datehelper_select_month_names ).split (',' )
+64: LOCALIZED_ABBR_MONTHNAMES [current_language ] = ['' ] + l (:actionview_datehelper_select_month_names_abbr ).split (',' )
+65: end
+66:
+67: month_options = []
+68: month_names = options [:use_short_month ] ? LOCALIZED_ABBR_MONTHNAMES [current_language ] : LOCALIZED_MONTHNAMES [current_language ]
+69:
+70: if options .has_key? (:min_date ) && options .has_key? (:max_date )
+71: if options [:min_date ].year == options [:max_date ].year
+72: start_month , end_month = options [:min_date ].month , options [:max_date ].month
+73: end
+74: end
+75: start_month = (options [:start_month ] || 1 ) unless start_month
+76: end_month = (options [:end_month ] || 12 ) unless end_month
+77: prefix = l :actionview_datehelper_select_month_prefix
+78:
+79: start_month .upto (end_month ) do | month_number |
+80: month_name = if options [:use_month_numbers ]
+81: "#{month_number}#{prefix}"
+82: elsif options [:add_month_numbers ]
+83: month_number .to_s + ' - ' + month_names [month_number ]
+84: else
+85: month_names [month_number ]
+86: end
+87:
+88: month_options << ((date && (date .kind_of? (Fixnum ) ? date : date .month ) == month_number ) ?
+89: %(<option value="#{month_number}" selected="selected">#{month_name}</option>\n) :
+90: %(<option value="#{month_number}">#{month_name}</option>\n)
+91: )
+92: end
+93:
+94: select_html (options [:field_name ] || 'month' , month_options , options [:prefix ], options [:include_blank ], options [:discard_type ], options [:disabled ])
+95: end
+
+
+
+
+
+
+
+
+
+
+
+
+This method has been modified so that
+
+
+it uses options: :min_date , :max_date
+
+
+a localized string can be appended to the years numbers.
+
+
+
+
[Source]
+
+
+
+100: def select_year (date , options = {})
+101: year_options = []
+102: y = date ? (date .kind_of? (Fixnum ) ? (y = (date == 0 ) ? Date .today .year : date ) : date .year ) : Date .today .year
+103:
+104: start_year = options .has_key? (:min_date ) ? options [:min_date ].year : (options [:start_year ] || y - 5 )
+105: end_year = options .has_key? (:max_date ) ? options [:max_date ].year : (options [:end_year ] || y + 5 )
+106: step_val = start_year < end_year ? 1 : -1
+107: prefix = l :actionview_datehelper_select_year_prefix
+108:
+109: start_year .step (end_year , step_val ) do | year |
+110: year_options << ((date && (date .kind_of? (Fixnum ) ? date : date .year ) == year ) ?
+111: %(<option value="#{year}" selected="selected">#{year}#{prefix}</option>\n) :
+112: %(<option value="#{year}">#{year}#{prefix}</option>\n)
+113: )
+114: end
+115:
+116: select_html (options [:field_name ] || 'year' , year_options , options [:prefix ], options [:include_blank ], options [:discard_type ], options [:disabled ])
+117: end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionView/Helpers/InstanceTag.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionView/Helpers/InstanceTag.html
new file mode 100644
index 000000000..a236e0e5d
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActionView/Helpers/InstanceTag.html
@@ -0,0 +1,167 @@
+
+
+
+
+
+ Class: ActionView::Helpers::InstanceTag
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+The private method add_options is overridden so that "Please
+select" is localized.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Public Instance methods
+
+
+
+
+
+
+
+
+Inherits the current language from the template object.
+
+
[Source]
+
+
+
+119: def current_language
+120: @template_object .current_language
+121: end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActiveRecord/Errors.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActiveRecord/Errors.html
new file mode 100644
index 000000000..9a16f608b
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActiveRecord/Errors.html
@@ -0,0 +1,215 @@
+
+
+
+
+
+ Class: ActiveRecord::Errors
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
External Aliases
+
+
+
+
+ add
+ ->
+ add_without_gloc
+
+
+
+
+
+
+
+
+
+
+
+
Public Instance methods
+
+
+
+
+
+
+
+
+The GLoc version of this method provides two
+extra features
+
+
+If msg is a string, it will be considered a GLoc string key.
+
+
+If msg is an array, the first element will be considered the
+string and the remaining elements will be considered arguments for the
+string. Eg. [‘Hi %s.’,’John’]
+
+
+
+
[Source]
+
+
+
+141: def add (attribute , msg = @@default_error_messages [:invalid ])
+142: if msg .is_a? (Array )
+143: args = msg .clone
+144: msg = args .shift
+145: args = nil if args .empty?
+146: end
+147: msg = ltry (msg )
+148: msg = msg % args unless args .nil?
+149: add_without_gloc (attribute , msg )
+150: end
+
+
+
+
+
+
+
+
+
+
+
+
+Inherits the current language from the base record.
+
+
[Source]
+
+
+
+152: def current_language
+153: @base .current_language
+154: end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActiveRecord/Validations/ClassMethods.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActiveRecord/Validations/ClassMethods.html
new file mode 100644
index 000000000..145a74c2b
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/ActiveRecord/Validations/ClassMethods.html
@@ -0,0 +1,217 @@
+
+
+
+
+
+ Module: ActiveRecord::Validations::ClassMethods
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Public Instance methods
+
+
+
+
+
+
+
+
+The default Rails version of this function creates an error message and
+then passes it to ActiveRecord.Errors . The GLoc version of this method, sends an array to
+ActiveRecord.Errors that will be turned into a
+string by ActiveRecord.Errors which in turn
+allows for the message of this validation function to be a GLoc string key.
+
+
[Source]
+
+
+
+164: def validates_length_of (* attrs )
+165:
+166: options = {
+167: :too_long => ActiveRecord :: Errors .default_error_messages [:too_long ],
+168: :too_short => ActiveRecord :: Errors .default_error_messages [:too_short ],
+169: :wrong_length => ActiveRecord :: Errors .default_error_messages [:wrong_length ]
+170: }.merge (DEFAULT_VALIDATION_OPTIONS )
+171: options .update (attrs .pop .symbolize_keys ) if attrs .last .is_a? (Hash )
+172:
+173:
+174: range_options = ALL_RANGE_OPTIONS & options .keys
+175: case range_options .size
+176: when 0
+177: raise ArgumentError , 'Range unspecified. Specify the :within, :maximum, :minimum, or :is option.'
+178: when 1
+179:
+180: else
+181: raise ArgumentError , 'Too many range options specified. Choose only one.'
+182: end
+183:
+184:
+185: option = range_options .first
+186: option_value = options [range_options .first ]
+187:
+188: case option
+189: when :within , :in
+190: raise ArgumentError , ":#{option} must be a Range" unless option_value .is_a? (Range )
+191:
+192: too_short = [options [:too_short ] , option_value .begin ]
+193: too_long = [options [:too_long ] , option_value .end ]
+194:
+195: validates_each (attrs , options ) do | record , attr , value |
+196: if value .nil? or value .split (// ).size < option_value .begin
+197: record .errors .add (attr , too_short )
+198: elsif value .split (// ).size > option_value .end
+199: record .errors .add (attr , too_long )
+200: end
+201: end
+202: when :is , :minimum , :maximum
+203: raise ArgumentError , ":#{option} must be a nonnegative Integer" unless option_value .is_a? (Integer ) and option_value >= 0
+204:
+205:
+206: validity_checks = { :is => "==" , :minimum => ">=" , :maximum => "<=" }
+207: message_options = { :is => :wrong_length , :minimum => :too_short , :maximum => :too_long }
+208:
+209: message = [(options [:message ] || options [message_options [option ]]) , option_value ]
+210:
+211: validates_each (attrs , options ) do | record , attr , value |
+212: if value .kind_of? (String )
+213: record .errors .add (attr , message ) unless ! value .nil? and value .split (// ).size .method (validity_checks [option ])[option_value ]
+214: else
+215: record .errors .add (attr , message ) unless ! value .nil? and value .size .method (validity_checks [option ])[option_value ]
+216: end
+217: end
+218: end
+219: end
+
+
+
+
+
+
+
+
+
+ validates_size_of (*attrs)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/GLoc.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/GLoc.html
new file mode 100644
index 000000000..8a25c7de8
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/GLoc.html
@@ -0,0 +1,774 @@
+
+
+
+
+
+ Module: GLoc
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Copyright © 2005-2006 David Barri
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Constants
+
+
+
+
+ LOCALIZED_STRINGS
+ =
+ {}
+
+
+ RULES
+ =
+ {}
+
+
+ LOWERCASE_LANGUAGES
+ =
+ {}
+
+
+ UTF_8
+ =
+ 'utf-8'
+
+
+ SHIFT_JIS
+ =
+ 'sjis'
+
+
+ EUC_JP
+ =
+ 'euc-jp'
+
+
+
+
+
+
+
External Aliases
+
+
+
+
+ clear_strings
+ ->
+ _clear_strings
+
+
+
+
+
+
+
+
+
+
+
+
Public Class methods
+
+
+
+
+
+
+
+
+Adds a collection of localized strings to the in-memory string store.
+
+
[Source]
+
+
+
+113: def add_localized_strings (lang , symbol_hash , override =true , strings_charset =nil )
+114: _verbose_msg {"Adding #{symbol_hash.size} #{lang} strings." }
+115: _add_localized_strings (lang , symbol_hash , override , strings_charset )
+116: _verbose_msg :stats
+117: end
+
+
+
+
+
+
+
+
+
+
+
+
+Creates a backup of the internal state of GLoc (ie.
+strings, langs, rules, config) and optionally clears everything.
+
+
[Source]
+
+
+
+121: def backup_state (clear =false )
+122: s = _get_internal_state_vars .map {| o | o .clone }
+123: _get_internal_state_vars .each {| o | o .clear } if clear
+124: s
+125: end
+
+
+
+
+
+
+
+
+
+
+
+
+Removes all localized strings from memory, either of a certain language (or
+languages), or entirely.
+
+
[Source]
+
+
+
+129: def clear_strings (* languages )
+130: if languages .empty?
+131: _verbose_msg {"Clearing all strings" }
+132: LOCALIZED_STRINGS .clear
+133: LOWERCASE_LANGUAGES .clear
+134: else
+135: languages .each {| l |
+136: _verbose_msg {"Clearing :#{l} strings" }
+137: l = l .to_sym
+138: LOCALIZED_STRINGS .delete l
+139: LOWERCASE_LANGUAGES .each_pair {| k ,v | LOWERCASE_LANGUAGES .delete k if v == l }
+140: }
+141: end
+142: end
+
+
+
+
+
+
+
+
+
+
+
+
+Removes all localized strings from memory, except for those of certain
+specified languages.
+
+
[Source]
+
+
+
+146: def clear_strings_except (* languages )
+147: clear = (LOCALIZED_STRINGS .keys - languages )
+148: _clear_strings (* clear ) unless clear .empty?
+149: end
+
+
+
+
+
+
+
+
+
+
+
+
+Returns the default language
+
+
[Source]
+
+
+
+108: def current_language
+109: GLoc :: CONFIG [:default_language ]
+110: end
+
+
+
+
+
+
+
+
+
+
+
+
+Returns the charset used to store localized strings in memory.
+
+
[Source]
+
+
+
+152: def get_charset (lang )
+153: CONFIG [:internal_charset_per_lang ][lang ] || CONFIG [:internal_charset ]
+154: end
+
+
+
+
+
+
+
+
+
+
+
+
+Returns a GLoc configuration value.
+
+
[Source]
+
+
+
+157: def get_config (key )
+158: CONFIG [key ]
+159: end
+
+
+
+
+
+
+
+
+
+
+
+
+Loads the localized strings that are included in the GLoc library.
+
+
[Source]
+
+
+
+162: def load_gloc_default_localized_strings (override =false )
+163: GLoc .load_localized_strings "#{File.dirname(__FILE__)}/../lang" , override
+164: end
+
+
+
+
+
+
+
+
+
+
+
+
+Loads localized strings from all yml files in the specifed directory.
+
+
[Source]
+
+
+
+167: def load_localized_strings (dir =nil , override =true )
+168: _charset_required
+169: _get_lang_file_list (dir ).each {| filename |
+170:
+171:
+172: raw_hash = YAML :: load (File .read (filename ))
+173: raw_hash ={} unless raw_hash .kind_of? (Hash )
+174: filename =~ /([^\/\\]+)\.ya?ml$/
+175: lang = $1 .to_sym
+176: file_charset = raw_hash ['file_charset' ] || UTF_8
+177:
+178:
+179: dest_charset = get_charset (lang )
+180: _verbose_msg {"Reading file #{filename} [charset: #{file_charset} --> #{dest_charset}]" }
+181: symbol_hash = {}
+182: Iconv .open (dest_charset , file_charset ) do | i |
+183: raw_hash .each {| key , value |
+184: symbol_hash [key .to_sym ] = i .iconv (value )
+185: }
+186: end
+187:
+188:
+189: _add_localized_strings (lang , symbol_hash , override )
+190: }
+191: _verbose_msg :stats
+192: end
+
+
+
+
+
+
+
+
+
+
+
+
+Restores a backup of GLoc ’s internal state
+that was made with backup_state .
+
+
[Source]
+
+
+
+195: def restore_state (state )
+196: _get_internal_state_vars .each do | o |
+197: o .clear
+198: o .send o .respond_to? (:merge! ) ? :merge! : :concat , state .shift
+199: end
+200: end
+
+
+
+
+
+
+
+
+
+
+
+
+Sets the charset used to internally store localized strings. You can set
+the charset to use for a specific language or languages, or if none are
+specified the charset for ALL localized strings will be set.
+
+
[Source]
+
+
+
+205: def set_charset (new_charset , * langs )
+206: CONFIG [:internal_charset_per_lang ] ||= {}
+207:
+208:
+209: if new_charset .is_a? (Symbol )
+210: new_charset = case new_charset
+211: when :utf8 , :utf_8 then UTF_8
+212: when :sjis , :shift_jis , :shiftjis then SHIFT_JIS
+213: when :eucjp , :euc_jp then EUC_JP
+214: else new_charset .to_s
+215: end
+216: end
+217:
+218:
+219: (langs .empty? ? LOCALIZED_STRINGS .keys : langs ).each do | lang |
+220: cur_charset = get_charset (lang )
+221: if cur_charset && new_charset != cur_charset
+222: _verbose_msg {"Converting :#{lang} strings from #{cur_charset} to #{new_charset}" }
+223: Iconv .open (new_charset , cur_charset ) do | i |
+224: bundle = LOCALIZED_STRINGS [lang ]
+225: bundle .each_pair {| k ,v | bundle [k ]= i .iconv (v )}
+226: end
+227: end
+228: end
+229:
+230:
+231: if langs .empty?
+232: _verbose_msg {"Setting GLoc charset for all languages to #{new_charset}" }
+233: CONFIG [:internal_charset ]= new_charset
+234: CONFIG [:internal_charset_per_lang ].clear
+235: else
+236: langs .each do | lang |
+237: _verbose_msg {"Setting GLoc charset for :#{lang} strings to #{new_charset}" }
+238: CONFIG [:internal_charset_per_lang ][lang ]= new_charset
+239: end
+240: end
+241: end
+
+
+
+
+
+
+
+
+
+
+
+
+Sets GLoc configuration values.
+
+
[Source]
+
+
+
+244: def set_config (hash )
+245: CONFIG .merge! hash
+246: end
+
+
+
+
+
+
+
+
+
+
+
+
+Sets the $KCODE global variable according to a specified charset, or else
+the current default charset for the default language.
+
+
[Source]
+
+
+
+250: def set_kcode (charset =nil )
+251: _charset_required
+252: charset ||= get_charset (current_language )
+253: $KCODE = case charset
+254: when UTF_8 then 'u'
+255: when SHIFT_JIS then 's'
+256: when EUC_JP then 'e'
+257: else 'n'
+258: end
+259: _verbose_msg {"$KCODE set to #{$KCODE}" }
+260: end
+
+
+
+
+
+
+
+
+
+
+
+
+Tries to find a valid language that is similar to the argument passed. Eg.
+:en, :en_au, :EN_US are all similar languages. Returns nil if no
+similar languages are found.
+
+
[Source]
+
+
+
+265: def similar_language (lang )
+266: return nil if lang .nil?
+267: return lang .to_sym if valid_language? (lang )
+268:
+269: lang = lang .to_s .downcase .gsub ('-' ,'_' )
+270: return LOWERCASE_LANGUAGES [lang ] if LOWERCASE_LANGUAGES .has_key? (lang )
+271:
+272: if lang .to_s =~ /^([a-z]+?)[^a-z].*/
+273: lang = $1
+274: return LOWERCASE_LANGUAGES [lang ] if LOWERCASE_LANGUAGES .has_key? (lang )
+275: end
+276:
+277: lang = "#{lang}_"
+278: LOWERCASE_LANGUAGES .keys .each {| k | return LOWERCASE_LANGUAGES [k ] if k .starts_with? (lang )}
+279:
+280: nil
+281: end
+
+
+
+
+
+
+
+
+
+
+
+
+Returns true if there are any localized strings for a specified
+language. Note that although set_langauge nil is perfectly valid,
+nil is not a valid language.
+
+
[Source]
+
+
+
+290: def valid_language? (language )
+291: LOCALIZED_STRINGS .has_key? language .to_sym rescue false
+292: end
+
+
+
+
+
+
+
+
+
+
+
+
+Returns an array of (currently) valid languages (ie. languages for which
+localized data exists).
+
+
[Source]
+
+
+
+284: def valid_languages
+285: LOCALIZED_STRINGS .keys
+286: end
+
+
+
+
+
+
Public Instance methods
+
+
+
+
+
+
+
+
+Returns the instance-level current language, or if not set, returns the
+class-level current language.
+
+
[Source]
+
+
+
+77: def current_language
+78: @gloc_language || self .class .current_language
+79: end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/GLoc/ClassMethods.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/GLoc/ClassMethods.html
new file mode 100644
index 000000000..ba1a28ad0
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/GLoc/ClassMethods.html
@@ -0,0 +1,160 @@
+
+
+
+
+
+ Module: GLoc::ClassMethods
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+All classes/modules that include GLoc will also
+gain these class methods. Notice that the GLoc::InstanceMethods module is also
+included.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Public Instance methods
+
+
+
+
+
+
+
+
+Returns the current language, or if not set, returns the GLoc current language.
+
+
[Source]
+
+
+
+89: def current_language
+90: @gloc_language || GLoc .current_language
+91: end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/GLoc/Helpers.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/GLoc/Helpers.html
new file mode 100644
index 000000000..f3fdf63e1
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/GLoc/Helpers.html
@@ -0,0 +1,323 @@
+
+
+
+
+
+ Module: GLoc::Helpers
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+These helper methods will be included in the InstanceMethods module.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Public Instance methods
+
+
+
+
+
+
+
+
[Source]
+
+
+
+12: def l_YesNo (value ) l (value ? : general_text_Yes : :general_text_No ) end
+
+
+
+
+
+
+
+
+
+
+
+
[Source]
+
+
+
+6: def l_age (age ) lwr : general_fmt_age , age end
+
+
+
+
+
+
+
+
+
+
+
+
[Source]
+
+
+
+7: def l_date (date ) l_strftime date , :general_fmt_date end
+
+
+
+
+
+
+
+
+
+
+
+
[Source]
+
+
+
+8: def l_datetime (date ) l_strftime date , :general_fmt_datetime end
+
+
+
+
+
+
+
+
+
+
+
+
[Source]
+
+
+
+9: def l_datetime_short (date ) l_strftime date , :general_fmt_datetime_short end
+
+
+
+
+
+
+
+
+
+
+
+
[Source]
+
+
+
+15: def l_lang_name (lang , display_lang =nil )
+16: ll display_lang || current_language , "general_lang_#{lang}"
+17: end
+
+
+
+
+
+
+
+
+
+
+
+
[Source]
+
+
+
+10: def l_strftime (date ,fmt ) date .strftime l (fmt ) end
+
+
+
+
+
+
+
+
+
+
+
+
[Source]
+
+
+
+11: def l_time (time ) l_strftime time , :general_fmt_time end
+
+
+
+
+
+
+
+
+
+
+
+
[Source]
+
+
+
+13: def l_yesno (value ) l (value ? : general_text_yes : :general_text_no ) end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/GLoc/InstanceMethods.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/GLoc/InstanceMethods.html
new file mode 100644
index 000000000..4e15c9383
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/classes/GLoc/InstanceMethods.html
@@ -0,0 +1,364 @@
+
+
+
+
+
+ Module: GLoc::InstanceMethods
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+This module will be included in both instances and classes of GLoc includees. It is also included as class
+methods in the GLoc module itself.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Public Instance methods
+
+
+
+
+
+
+
+
+Returns a localized string.
+
+
[Source]
+
+
+
+18: def l (symbol , * arguments )
+19: return GLoc ._l (symbol ,current_language ,* arguments )
+20: end
+
+
+
+
+
+
+
+
+
+
+
+
+Returns true if a localized string with the specified key exists.
+
+
[Source]
+
+
+
+48: def l_has_string? (symbol )
+49: return GLoc ._l_has_string? (symbol ,current_language )
+50: end
+
+
+
+
+
+
+
+
+
+
+
+
+Returns a localized string in a specified language. This does not effect
+current_language .
+
+
[Source]
+
+
+
+24: def ll (lang , symbol , * arguments )
+25: return GLoc ._l (symbol ,lang .to_sym ,* arguments )
+26: end
+
+
+
+
+
+
+
+
+
+
+
+
+Returns a localized string if the argument is a Symbol, else just returns
+the argument.
+
+
[Source]
+
+
+
+29: def ltry (possible_key )
+30: possible_key .is_a? (Symbol ) ? l (possible_key ) : possible_key
+31: end
+
+
+
+
+
+
+
+
+
+
+
+
+Uses the default GLoc rule to return a localized
+string. See lwr_() for more info.
+
+
[Source]
+
+
+
+35: def lwr (symbol , * arguments )
+36: lwr_ (:default , symbol , * arguments )
+37: end
+
+
+
+
+
+
+
+
+
+
+
+
+Uses a rule to return a localized string. A rule is a function
+that uses specified arguments to return a localization key prefix. The
+prefix is appended to the localization key originally specified, to create
+a new key which is then used to lookup a localized string.
+
+
[Source]
+
+
+
+43: def lwr_ (rule , symbol , * arguments )
+44: GLoc ._l ("#{symbol}#{GLoc::_l_rule(rule,current_language).call(*arguments)}" ,current_language ,* arguments )
+45: end
+
+
+
+
+
+
+
+
+
+
+
+
+Sets the current language for this instance/class. Setting the language of
+a class effects all instances unless the instance has its own language
+defined.
+
+
[Source]
+
+
+
+54: def set_language (language )
+55: @gloc_language = language .nil? ? nil : language .to_sym
+56: end
+
+
+
+
+
+
+
+
+
+
+
+
+Sets the current language if the language passed is a valid language. If
+the language was valid, this method returns true else it will
+return false . Note that nil is not a valid language. See
+set_language (language) for more
+info.
+
+
[Source]
+
+
+
+62: def set_language_if_valid (language )
+63: if GLoc .valid_language? (language )
+64: set_language (language )
+65: true
+66: else
+67: false
+68: end
+69: end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/created.rid b/rest_sys/vendor/plugins/gloc-1.1.0/doc/created.rid
new file mode 100644
index 000000000..eba9efa29
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/created.rid
@@ -0,0 +1 @@
+Sun May 28 15:21:13 E. Australia Standard Time 2006
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/CHANGELOG.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/CHANGELOG.html
new file mode 100644
index 000000000..aec36c5bf
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/CHANGELOG.html
@@ -0,0 +1,153 @@
+
+
+
+
+
+ File: CHANGELOG
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Version 1.1 (28 May 2006)
+
+The charset for each and/or all languages can now be easily configured.
+
+
+Added a ActionController filter that auto-detects the client language.
+
+
+The rake task "sort" now merges lines that match 100%, and warns
+if duplicate keys are found.
+
+
+Rule support. Create flexible rules to handle issues such as pluralization.
+
+
+Massive speed and stability improvements to development mode.
+
+
+Added Russian strings. (Thanks to Evgeny Lineytsev)
+
+
+Complete RDoc documentation.
+
+
+Improved helpers.
+
+
+GLoc now configurable via get_config and
+set_config
+
+
+Added an option to tell GLoc to output
+various verbose information.
+
+
+More useful functions such as set_language_if_valid, similar_language
+
+
+GLoc ’s entire internal state can
+now be backed up and restored.
+
+
+
+
Version 1.0 (17 April 2006)
+
+Initial public release.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/README.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/README.html
new file mode 100644
index 000000000..d078659d2
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/README.html
@@ -0,0 +1,480 @@
+
+
+
+
+
+ File: README
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
About
+
Preface
+
+I originally started designing this on weekends and after work in 2005. We
+started to become very interested in Rails at work and I wanted to get some
+experience with ruby with before we started using it full-time. I
+didn’t have very many ideas for anything interesting to create so,
+because we write a lot of multilingual webapps at my company, I decided to
+write a localization library. That way if my little hobby project developed
+into something decent, I could at least put it to good use. And here we are
+in 2006, my little hobby project has come a long way and become quite a
+useful piece of software. Not only do I use it in production sites I write
+at work, but I also prefer it to other existing alternatives. Therefore I
+have decided to make it publicly available, and I hope that other
+developers will find it useful too.
+
+
About
+
+GLoc is a localization library. It
+doesn’t aim to do everything l10n-related that you can imagine, but
+what it does, it does very well. It was originally designed as a Rails
+plugin, but can also be used for plain ruby projects. Here are a list of
+its main features:
+
+
+Lightweight and efficient.
+
+
+Uses file-based string bundles. Strings can also be set directly.
+
+
+Intelligent, cascading language configuration.
+
+
+Create flexible rules to handle issues such as pluralization.
+
+
+Includes a ActionController filter that auto-detects the client language.
+
+
+Works perfectly with Rails Engines and allows strings to be overridden just
+as easily as controllers, models, etc.
+
+
+Automatically localizes Rails functions such as distance_in_minutes,
+select_month etc
+
+
+Supports different charsets. You can even specify the encoding to use for
+each language seperately.
+
+
+Special Rails mods/helpers.
+
+
+
+
What does GLoc mean?
+
+If you’re wondering about the name "GLoc ", I’m sure you’re not
+alone. This project was originally just called "Localization"
+which was a bit too common, so when I decided to release it I decided to
+call it "Golly’s Localization Library" instead (Golly is my
+nickname), and that was long and boring so I then abbreviated that to
+"GLoc ". What a fun story!!
+
+
Localization helpers
+
+This also includes a few helpers for common situations such as displaying
+localized date, time, "yes" or "no", etc.
+
+
Rails Localization
+
+At the moment, unless you manually remove the require
+‘gloc-rails-text’ line from init.rb, this plugin overrides
+certain Rails functions to provide multilingual versions. This
+automatically localizes functions such as select_date(),
+distance_of_time_in_words() and more… The strings can be found in
+lang/*.yml. NOTE: This is not complete. Timezones and countries are not
+currently localized.
+
+
Usage
+
Quickstart
+
+Windows users will need to first install iconv. wiki.rubyonrails.com/rails/pages/iconv
+
+
+
+There is more functionality provided by this plugin, that is not
+demonstrated above. Please read the API summary for details.
+
+
API summary
+
+The following methods are added as both class methods and instance methods
+to modules/classes that include GLoc .
+They are also available as class methods of GLoc .
+
+
+ current_language # Returns the current language
+ l(symbol, *arguments) # Returns a localized string
+ ll(lang, symbol, *arguments) # Returns a localized string in a specific language
+ ltry(possible_key) # Returns a localized string if passed a Symbol, else returns the same argument passed
+ lwr(symbol, *arguments) # Uses the default rule to return a localized string.
+ lwr_(rule, symbol, *arguments) # Uses a specified rule to return a localized string.
+ l_has_string?(symbol) # Checks if a localized string exists
+ set_language(language) # Sets the language for the current class or class instance
+ set_language_if_valid(lang) # Sets the current language if the language passed is a valid language
+
+
+The GLoc module also defines the
+following class methods:
+
+
+ add_localized_strings(lang, symbol_hash, override=true) # Adds a hash of localized strings
+ backup_state(clear=false) # Creates a backup of GLoc's internal state and optionally clears everything too
+ clear_strings(*languages) # Removes localized strings from memory
+ clear_strings_except(*languages) # Removes localized strings from memory except for those of certain specified languages
+ get_charset(lang) # Returns the charset used to store localized strings in memory
+ get_config(key) # Returns a GLoc configuration value (see below)
+ load_localized_strings(dir=nil, override=true) # Loads localized strings from all YML files in a given directory
+ restore_state(state) # Restores a backup of GLoc's internal state
+ set_charset(new_charset, *langs) # Sets the charset used to internally store localized strings
+ set_config(hash) # Sets GLoc configuration values (see below)
+ set_kcode(charset=nil) # Sets the $KCODE global variable
+ similar_language(language) # Tries to find a valid language that is similar to the argument passed
+ valid_languages # Returns an array of (currently) valid languages (ie. languages for which localized data exists)
+ valid_language?(language) # Checks whether any localized strings are in memory for a given language
+
+
+GLoc uses the following configuration
+items. They can be accessed via get_config and
+set_config .
+
+
+ :default_cookie_name
+ :default_language
+ :default_param_name
+ :raise_string_not_found_errors
+ :verbose
+
+
+The GLoc module is automatically
+included in the following classes:
+
+
+ ActionController::Base
+ ActionMailer::Base
+ ActionView::Base
+ ActionView::Helpers::InstanceTag
+ ActiveRecord::Base
+ ActiveRecord::Errors
+ ApplicationHelper
+ Test::Unit::TestCase
+
+
+The GLoc module also defines the
+following controller filters:
+
+
+ autodetect_language_filter
+
+
+GLoc also makes the following change to
+Rails:
+
+
+Views for ActionMailer are now #{view_name}_#{language}.rb rather than just
+#{view_name}.rb
+
+
+All ActiveRecord validation class methods now accept a localized string key
+(symbol) as a :message value.
+
+
+ActiveRecord::Errors.add
+now accepts symbols as valid message values. At runtime these symbols are
+converted to localized strings using the current_language of the base
+record.
+
+
+ActiveRecord::Errors.add
+now accepts arrays as arguments so that printf-style strings can be
+generated at runtime. This also applies to the validates_* class methods.
+
+
+ Eg. validates_xxxxxx_of :name, :message => ['Your name must be at least %d characters.', MIN_LEN]
+ Eg. validates_xxxxxx_of :name, :message => [:user_error_validation_name_too_short, MIN_LEN]
+
+
+Instances of ActiveView inherit their current_language from the controller
+(or mailer) creating them.
+
+
+
+
+This plugin also adds the following rake tasks:
+
+
+ * gloc:sort - Sorts the keys in the lang ymls (also accepts a DIR argument)
+
+
Cascading language configuration
+
+The language can be set at three levels:
+
+
+ 1. The default # GLoc.get_config :default_language
+ 2. Class level # class A; set_language :de; end
+ 3. Instance level # b= B.new; b.set_language :zh
+
+
+Instance level has the highest priority and the default has the lowest.
+
+
+Because GLoc is included at class level
+too, it becomes easy to associate languages with contexts. For example:
+
+
+ class Student
+ set_language :en
+ def say_hello
+ puts "We say #{l :hello} but our teachers say #{Teacher.l :hello}"
+ end
+ end
+
+
Rules
+
+There are often situations when depending on the value of one or more
+variables, the surrounding text changes. The most common case of this is
+pluralization. Rather than hardcode these rules, they are completely
+definable by the user so that the user can eaasily accomodate for more
+complicated grammatical rules such as those found in Russian and Polish (or
+so I hear). To define a rule, simply include a string in the string bundle
+whose key begins with "gloc_rule " and then write ruby
+code as the value. The ruby code will be converted to a Proc when the
+string bundle is first read, and should return a prefix that will be
+appended to the string key at runtime to point to a new string. Make sense?
+Probably not… Please look at the following example and I am sure it
+will all make sense.
+
+
+Simple example (string bundle / en.yml)
+
+
+ _gloc_rule_default: ' |n| n==1 ? "_single" : "_plural" '
+ man_count_plural: There are %d men.
+ man_count_single: There is 1 man.
+
+
+Simple example (code)
+
+
+ lwr(:man_count, 1) # => There is 1 man.
+ lwr(:man_count, 8) # => There are 8 men.
+
+
+To use rules other than the default simply call lwr_ instead of lwr, and
+specify the rule.
+
+
+Example 2 (string bundle / en.yml)
+
+
+ _gloc_rule_default: ' |n| n==1 ? "_single" : "_plural" '
+ _gloc_rule_custom: ' |n| return "_none" if n==0; return "_heaps" if n>100; n==1 ? "_single" : "_plural" '
+ man_count_none: There are no men.
+ man_count_heaps: There are heaps of men!!
+ man_count_plural: There are %d men.
+ man_count_single: There is 1 man.
+
+
+Example 2 (code)
+
+
+ lwr_(:custom, :man_count, 0) # => There are no men.
+ lwr_(:custom, :man_count, 1) # => There is 1 man.
+ lwr_(:custom, :man_count, 8) # => There are 8 men.
+ lwr_(:custom, :man_count, 150) # => There are heaps of men!!
+
+
Helpers
+
+GLoc includes the following helpers:
+
+
+ l_age(age) # Returns a localized version of an age. eg "3 years old"
+ l_date(date) # Returns a date in a localized format
+ l_datetime(date) # Returns a date+time in a localized format
+ l_datetime_short(date) # Returns a date+time in a localized short format.
+ l_lang_name(l,dl=nil) # Returns the name of a language (you must supply your own strings)
+ l_strftime(date,fmt) # Formats a date/time in a localized format.
+ l_time(date) # Returns a time in a localized format
+ l_YesNo(value) # Returns localized string of "Yes" or "No" depending on the arg
+ l_yesno(value) # Returns localized string of "yes" or "no" depending on the arg
+
+
Rails localization
+
+Not all of Rails is covered but the following functions are:
+
+
+ distance_of_time_in_words
+ select_day
+ select_month
+ select_year
+ add_options
+
+
FAQ
+
How do I use it in engines?
+
+Simply put this in your init_engine.rb
+
+
+ GLoc.load_localized_strings File.join(File.dirname(__FILE__),'lang')
+
+
+That way your engines strings will be loaded when the engine is started.
+Just simply make sure that you load your application strings after you
+start your engines to safely override any engine strings.
+
+
Why am I getting an Iconv::IllegalSequence error when calling GLoc.set_charset ?
+
+By default GLoc loads all of its default
+strings at startup. For example, calling set_charset
+‘iso-2022-jp’ will cause this error because Russian
+strings are loaded by default, and the Russian strings use characters that
+cannot be expressed in the ISO-2022-JP charset. Before calling
+set_charset you should call clear_strings_except to
+remove strings from any languages that you will not be using.
+Alternatively, you can simply specify the language(s) as follows,
+set_charset ‘iso-2022-jp’, :ja .
+
+
How do I make GLoc ignore StringNotFoundErrors?
+
+Disable it as follows:
+
+
+ GLoc.set_config :raise_string_not_found_errors => false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-helpers_rb.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-helpers_rb.html
new file mode 100644
index 000000000..394b79d70
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-helpers_rb.html
@@ -0,0 +1,107 @@
+
+
+
+
+
+ File: gloc-helpers.rb
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Copyright © 2005-2006 David Barri
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-internal_rb.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-internal_rb.html
new file mode 100644
index 000000000..6d09fec7b
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-internal_rb.html
@@ -0,0 +1,115 @@
+
+
+
+
+
+ File: gloc-internal.rb
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Copyright © 2005-2006 David Barri
+
+
+
+
+
+
Required files
+
+
+ iconv
+ gloc-version
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-rails-text_rb.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-rails-text_rb.html
new file mode 100644
index 000000000..52a387218
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-rails-text_rb.html
@@ -0,0 +1,114 @@
+
+
+
+
+
+ File: gloc-rails-text.rb
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Copyright © 2005-2006 David Barri
+
+
+
+
+
+
Required files
+
+
+ date
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-rails_rb.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-rails_rb.html
new file mode 100644
index 000000000..3ae73b87b
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-rails_rb.html
@@ -0,0 +1,114 @@
+
+
+
+
+
+ File: gloc-rails.rb
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Copyright © 2005-2006 David Barri
+
+
+
+
+
+
Required files
+
+
+ gloc
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-ruby_rb.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-ruby_rb.html
new file mode 100644
index 000000000..4b29e9d94
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-ruby_rb.html
@@ -0,0 +1,107 @@
+
+
+
+
+
+ File: gloc-ruby.rb
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Copyright © 2005-2006 David Barri
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-version_rb.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-version_rb.html
new file mode 100644
index 000000000..17f93aa43
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc-version_rb.html
@@ -0,0 +1,101 @@
+
+
+
+
+
+ File: gloc-version.rb
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc_rb.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc_rb.html
new file mode 100644
index 000000000..9e68a89cd
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/files/lib/gloc_rb.html
@@ -0,0 +1,116 @@
+
+
+
+
+
+ File: gloc.rb
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Copyright © 2005-2006 David Barri
+
+
+
+
+
+
Required files
+
+
+ yaml
+ gloc-internal
+ gloc-helpers
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/fr_class_index.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/fr_class_index.html
new file mode 100644
index 000000000..08e0418f3
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/fr_class_index.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+ Classes
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/fr_file_index.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/fr_file_index.html
new file mode 100644
index 000000000..839e378d3
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/fr_file_index.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+ Files
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/fr_method_index.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/fr_method_index.html
new file mode 100644
index 000000000..325ed3589
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/fr_method_index.html
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+ Methods
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/index.html b/rest_sys/vendor/plugins/gloc-1.1.0/doc/index.html
new file mode 100644
index 000000000..f29103142
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/index.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+ GLoc Localization Library Documentation
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/doc/rdoc-style.css b/rest_sys/vendor/plugins/gloc-1.1.0/doc/rdoc-style.css
new file mode 100644
index 000000000..fbf7326af
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/doc/rdoc-style.css
@@ -0,0 +1,208 @@
+
+body {
+ font-family: Verdana,Arial,Helvetica,sans-serif;
+ font-size: 90%;
+ margin: 0;
+ margin-left: 40px;
+ padding: 0;
+ background: white;
+}
+
+h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
+h1 { font-size: 150%; }
+h2,h3,h4 { margin-top: 1em; }
+
+a { background: #eef; color: #039; text-decoration: none; }
+a:hover { background: #039; color: #eef; }
+
+/* Override the base stylesheet's Anchor inside a table cell */
+td > a {
+ background: transparent;
+ color: #039;
+ text-decoration: none;
+}
+
+/* and inside a section title */
+.section-title > a {
+ background: transparent;
+ color: #eee;
+ text-decoration: none;
+}
+
+/* === Structural elements =================================== */
+
+div#index {
+ margin: 0;
+ margin-left: -40px;
+ padding: 0;
+ font-size: 90%;
+}
+
+
+div#index a {
+ margin-left: 0.7em;
+}
+
+div#index .section-bar {
+ margin-left: 0px;
+ padding-left: 0.7em;
+ background: #ccc;
+ font-size: small;
+}
+
+
+div#classHeader, div#fileHeader {
+ width: auto;
+ color: white;
+ padding: 0.5em 1.5em 0.5em 1.5em;
+ margin: 0;
+ margin-left: -40px;
+ border-bottom: 3px solid #006;
+}
+
+div#classHeader a, div#fileHeader a {
+ background: inherit;
+ color: white;
+}
+
+div#classHeader td, div#fileHeader td {
+ background: inherit;
+ color: white;
+}
+
+
+div#fileHeader {
+ background: #057;
+}
+
+div#classHeader {
+ background: #048;
+}
+
+
+.class-name-in-header {
+ font-size: 180%;
+ font-weight: bold;
+}
+
+
+div#bodyContent {
+ padding: 0 1.5em 0 1.5em;
+}
+
+div#description {
+ padding: 0.5em 1.5em;
+ background: #efefef;
+ border: 1px dotted #999;
+}
+
+div#description h1,h2,h3,h4,h5,h6 {
+ color: #125;;
+ background: transparent;
+}
+
+div#validator-badges {
+ text-align: center;
+}
+div#validator-badges img { border: 0; }
+
+div#copyright {
+ color: #333;
+ background: #efefef;
+ font: 0.75em sans-serif;
+ margin-top: 5em;
+ margin-bottom: 0;
+ padding: 0.5em 2em;
+}
+
+
+/* === Classes =================================== */
+
+table.header-table {
+ color: white;
+ font-size: small;
+}
+
+.type-note {
+ font-size: small;
+ color: #DEDEDE;
+}
+
+.xxsection-bar {
+ background: #eee;
+ color: #333;
+ padding: 3px;
+}
+
+.section-bar {
+ color: #333;
+ border-bottom: 1px solid #999;
+ margin-left: -20px;
+}
+
+
+.section-title {
+ background: #79a;
+ color: #eee;
+ padding: 3px;
+ margin-top: 2em;
+ margin-left: -30px;
+ border: 1px solid #999;
+}
+
+.top-aligned-row { vertical-align: top }
+.bottom-aligned-row { vertical-align: bottom }
+
+/* --- Context section classes ----------------------- */
+
+.context-row { }
+.context-item-name { font-family: monospace; font-weight: bold; color: black; }
+.context-item-value { font-size: small; color: #448; }
+.context-item-desc { color: #333; padding-left: 2em; }
+
+/* --- Method classes -------------------------- */
+.method-detail {
+ background: #efefef;
+ padding: 0;
+ margin-top: 0.5em;
+ margin-bottom: 1em;
+ border: 1px dotted #ccc;
+}
+.method-heading {
+ color: black;
+ background: #ccc;
+ border-bottom: 1px solid #666;
+ padding: 0.2em 0.5em 0 0.5em;
+}
+.method-signature { color: black; background: inherit; }
+.method-name { font-weight: bold; }
+.method-args { font-style: italic; }
+.method-description { padding: 0 0.5em 0 0.5em; }
+
+/* --- Source code sections -------------------- */
+
+a.source-toggle { font-size: 90%; }
+div.method-source-code {
+ background: #262626;
+ color: #ffdead;
+ margin: 1em;
+ padding: 0.5em;
+ border: 1px dashed #999;
+ overflow: hidden;
+}
+
+div.method-source-code pre { color: #ffdead; overflow: hidden; }
+
+/* --- Ruby keyword styles --------------------- */
+
+.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
+
+.ruby-constant { color: #7fffd4; background: transparent; }
+.ruby-keyword { color: #00ffff; background: transparent; }
+.ruby-ivar { color: #eedd82; background: transparent; }
+.ruby-operator { color: #00ffee; background: transparent; }
+.ruby-identifier { color: #ffdead; background: transparent; }
+.ruby-node { color: #ffa07a; background: transparent; }
+.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
+.ruby-regexp { color: #ffa07a; background: transparent; }
+.ruby-value { color: #7fffd4; background: transparent; }
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/init.rb b/rest_sys/vendor/plugins/gloc-1.1.0/init.rb
new file mode 100644
index 000000000..9d99acd61
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/init.rb
@@ -0,0 +1,11 @@
+# Copyright (c) 2005-2006 David Barri
+
+require 'gloc'
+require 'gloc-ruby'
+require 'gloc-rails'
+require 'gloc-rails-text'
+require 'gloc-config'
+
+require 'gloc-dev' if ENV['RAILS_ENV'] == 'development'
+
+GLoc.load_gloc_default_localized_strings
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-config.rb b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-config.rb
new file mode 100644
index 000000000..e85b041f5
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-config.rb
@@ -0,0 +1,16 @@
+# Copyright (c) 2005-2006 David Barri
+
+module GLoc
+
+ private
+
+ CONFIG= {} unless const_defined?(:CONFIG)
+ unless CONFIG.frozen?
+ CONFIG[:default_language] ||= :en
+ CONFIG[:default_param_name] ||= 'lang'
+ CONFIG[:default_cookie_name] ||= 'lang'
+ CONFIG[:raise_string_not_found_errors]= true unless CONFIG.has_key?(:raise_string_not_found_errors)
+ CONFIG[:verbose] ||= false
+ end
+
+end
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-dev.rb b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-dev.rb
new file mode 100644
index 000000000..cb12b4cb3
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-dev.rb
@@ -0,0 +1,97 @@
+# Copyright (c) 2005-2006 David Barri
+
+puts "GLoc v#{GLoc::VERSION} running in development mode. Strings can be modified at runtime."
+
+module GLoc
+ class << self
+
+ alias :actual_add_localized_strings :add_localized_strings
+ def add_localized_strings(lang, symbol_hash, override=true, strings_charset=nil)
+ _verbose_msg {"dev::add_localized_strings #{lang}, [#{symbol_hash.size}], #{override}, #{strings_charset ? strings_charset : 'nil'}"}
+ STATE.push [:hash, lang, {}.merge(symbol_hash), override, strings_charset]
+ _force_refresh
+ end
+
+ alias :actual_load_localized_strings :load_localized_strings
+ def load_localized_strings(dir=nil, override=true)
+ _verbose_msg {"dev::load_localized_strings #{dir ? dir : 'nil'}, #{override}"}
+ STATE.push [:dir, dir, override]
+ _get_lang_file_list(dir).each {|filename| FILES[filename]= nil}
+ end
+
+ alias :actual_clear_strings :clear_strings
+ def clear_strings(*languages)
+ _verbose_msg {"dev::clear_strings #{languages.map{|l|l.to_s}.join(', ')}"}
+ STATE.push [:clear, languages.clone]
+ _force_refresh
+ end
+
+ alias :actual_clear_strings_except :clear_strings_except
+ def clear_strings_except(*languages)
+ _verbose_msg {"dev::clear_strings_except #{languages.map{|l|l.to_s}.join(', ')}"}
+ STATE.push [:clear_except, languages.clone]
+ _force_refresh
+ end
+
+ # Replace methods
+ [:_l, :_l_rule, :_l_has_string?, :similar_language, :valid_languages, :valid_language?].each do |m|
+ class_eval <<-EOB
+ alias :actual_#{m} :#{m}
+ def #{m}(*args)
+ _assert_gloc_strings_up_to_date
+ actual_#{m}(*args)
+ end
+ EOB
+ end
+
+ #-------------------------------------------------------------------------
+ private
+
+ STATE= []
+ FILES= {}
+
+ def _assert_gloc_strings_up_to_date
+ changed= @@force_refresh
+
+ # Check if any lang files have changed
+ unless changed
+ FILES.each_pair {|f,mtime|
+ changed ||= (File.stat(f).mtime != mtime)
+ }
+ end
+
+ return unless changed
+ puts "GLoc reloading strings..."
+ @@force_refresh= false
+
+ # Update file timestamps
+ FILES.each_key {|f|
+ FILES[f]= File.stat(f).mtime
+ }
+
+ # Reload strings
+ actual_clear_strings
+ STATE.each {|s|
+ case s[0]
+ when :dir then actual_load_localized_strings s[1], s[2]
+ when :hash then actual_add_localized_strings s[1], s[2], s[3], s[4]
+ when :clear then actual_clear_strings(*s[1])
+ when :clear_except then actual_clear_strings_except(*s[1])
+ else raise "Invalid state id: '#{s[0]}'"
+ end
+ }
+ _verbose_msg :stats
+ end
+
+ @@force_refresh= false
+ def _force_refresh
+ @@force_refresh= true
+ end
+
+ alias :super_get_internal_state_vars :_get_internal_state_vars
+ def _get_internal_state_vars
+ super_get_internal_state_vars + [ STATE, FILES ]
+ end
+
+ end
+end
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-helpers.rb b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-helpers.rb
new file mode 100644
index 000000000..f2ceb8e3d
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-helpers.rb
@@ -0,0 +1,20 @@
+# Copyright (c) 2005-2006 David Barri
+
+module GLoc
+ # These helper methods will be included in the InstanceMethods module.
+ module Helpers
+ def l_age(age) lwr :general_fmt_age, age end
+ def l_date(date) l_strftime date, :general_fmt_date end
+ def l_datetime(date) l_strftime date, :general_fmt_datetime end
+ def l_datetime_short(date) l_strftime date, :general_fmt_datetime_short end
+ def l_strftime(date,fmt) date.strftime l(fmt) end
+ def l_time(time) l_strftime time, :general_fmt_time end
+ def l_YesNo(value) l(value ? :general_text_Yes : :general_text_No) end
+ def l_yesno(value) l(value ? :general_text_yes : :general_text_no) end
+
+ def l_lang_name(lang, display_lang=nil)
+ ll display_lang || current_language, "general_lang_#{lang}"
+ end
+
+ end
+end
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-internal.rb b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-internal.rb
new file mode 100644
index 000000000..faed551ca
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-internal.rb
@@ -0,0 +1,134 @@
+# Copyright (c) 2005-2006 David Barri
+
+require 'iconv'
+require 'gloc-version'
+
+module GLoc
+ class GLocError < StandardError #:nodoc:
+ end
+ class InvalidArgumentsError < GLocError #:nodoc:
+ end
+ class InvalidKeyError < GLocError #:nodoc:
+ end
+ class RuleNotFoundError < GLocError #:nodoc:
+ end
+ class StringNotFoundError < GLocError #:nodoc:
+ end
+
+ class << self
+ private
+
+ def _add_localized_data(lang, symbol_hash, override, target) #:nodoc:
+ lang= lang.to_sym
+ if override
+ target[lang] ||= {}
+ target[lang].merge!(symbol_hash)
+ else
+ symbol_hash.merge!(target[lang]) if target[lang]
+ target[lang]= symbol_hash
+ end
+ end
+
+ def _add_localized_strings(lang, symbol_hash, override=true, strings_charset=nil) #:nodoc:
+ _charset_required
+
+ # Convert all incoming strings to the gloc charset
+ if strings_charset
+ Iconv.open(get_charset(lang), strings_charset) do |i|
+ symbol_hash.each_pair {|k,v| symbol_hash[k]= i.iconv(v)}
+ end
+ end
+
+ # Convert rules
+ rules= {}
+ old_kcode= $KCODE
+ begin
+ $KCODE= 'u'
+ Iconv.open(UTF_8, get_charset(lang)) do |i|
+ symbol_hash.each {|k,v|
+ if /^_gloc_rule_(.+)$/ =~ k.to_s
+ v= i.iconv(v) if v
+ v= '""' if v.nil?
+ rules[$1.to_sym]= eval "Proc.new do #{v} end"
+ end
+ }
+ end
+ ensure
+ $KCODE= old_kcode
+ end
+ rules.keys.each {|k| symbol_hash.delete "_gloc_rule_#{k}".to_sym}
+
+ # Add new localized data
+ LOWERCASE_LANGUAGES[lang.to_s.downcase]= lang
+ _add_localized_data(lang, symbol_hash, override, LOCALIZED_STRINGS)
+ _add_localized_data(lang, rules, override, RULES)
+ end
+
+ def _charset_required #:nodoc:
+ set_charset UTF_8 unless CONFIG[:internal_charset]
+ end
+
+ def _get_internal_state_vars
+ [ CONFIG, LOCALIZED_STRINGS, RULES, LOWERCASE_LANGUAGES ]
+ end
+
+ def _get_lang_file_list(dir) #:nodoc:
+ dir= File.join(RAILS_ROOT,'{.,vendor/plugins/*}','lang') if dir.nil?
+ Dir[File.join(dir,'*.{yaml,yml}')]
+ end
+
+ def _l(symbol, language, *arguments) #:nodoc:
+ symbol= symbol.to_sym if symbol.is_a?(String)
+ raise InvalidKeyError.new("Symbol or String expected as key.") unless symbol.kind_of?(Symbol)
+
+ translation= LOCALIZED_STRINGS[language][symbol] rescue nil
+ if translation.nil?
+ raise StringNotFoundError.new("There is no key called '#{symbol}' in the #{language} strings.") if CONFIG[:raise_string_not_found_errors]
+ translation= symbol.to_s
+ end
+
+ begin
+ return translation % arguments
+ rescue => e
+ raise InvalidArgumentsError.new("Translation value #{translation.inspect} with arguments #{arguments.inspect} caused error '#{e.message}'")
+ end
+ end
+
+ def _l_has_string?(symbol,lang) #:nodoc:
+ symbol= symbol.to_sym if symbol.is_a?(String)
+ LOCALIZED_STRINGS[lang].has_key?(symbol.to_sym) rescue false
+ end
+
+ def _l_rule(symbol,lang) #:nodoc:
+ symbol= symbol.to_sym if symbol.is_a?(String)
+ raise InvalidKeyError.new("Symbol or String expected as key.") unless symbol.kind_of?(Symbol)
+
+ r= RULES[lang][symbol] rescue nil
+ raise RuleNotFoundError.new("There is no rule called '#{symbol}' in the #{lang} rules.") if r.nil?
+ r
+ end
+
+ def _verbose_msg(type=nil)
+ return unless CONFIG[:verbose]
+ x= case type
+ when :stats
+ x= valid_languages.map{|l| ":#{l}(#{LOCALIZED_STRINGS[l].size}/#{RULES[l].size})"}.sort.join(', ')
+ "Current stats -- #{x}"
+ else
+ yield
+ end
+ puts "[GLoc] #{x}"
+ end
+
+ public :_l, :_l_has_string?, :_l_rule
+ end
+
+ private
+
+ unless const_defined?(:LOCALIZED_STRINGS)
+ LOCALIZED_STRINGS= {}
+ RULES= {}
+ LOWERCASE_LANGUAGES= {}
+ end
+
+end
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-rails-text.rb b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-rails-text.rb
new file mode 100644
index 000000000..f437410dc
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-rails-text.rb
@@ -0,0 +1,150 @@
+# Copyright (c) 2005-2006 David Barri
+
+require 'date'
+
+module ActionView #:nodoc:
+ module Helpers #:nodoc:
+ module DateHelper
+
+ unless const_defined?(:LOCALIZED_HELPERS)
+ LOCALIZED_HELPERS= true
+ LOCALIZED_MONTHNAMES = {}
+ LOCALIZED_ABBR_MONTHNAMES = {}
+ end
+
+ # This method uses current_language to return a localized string.
+ def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)
+ from_time = from_time.to_time if from_time.respond_to?(:to_time)
+ to_time = to_time.to_time if to_time.respond_to?(:to_time)
+ distance_in_minutes = (((to_time - from_time).abs)/60).round
+ distance_in_seconds = ((to_time - from_time).abs).round
+
+ case distance_in_minutes
+ when 0..1
+ return (distance_in_minutes==0) ? l(:actionview_datehelper_time_in_words_minute_less_than) : l(:actionview_datehelper_time_in_words_minute_single) unless include_seconds
+ case distance_in_seconds
+ when 0..5 then lwr(:actionview_datehelper_time_in_words_second_less_than, 5)
+ when 6..10 then lwr(:actionview_datehelper_time_in_words_second_less_than, 10)
+ when 11..20 then lwr(:actionview_datehelper_time_in_words_second_less_than, 20)
+ when 21..40 then l(:actionview_datehelper_time_in_words_minute_half)
+ when 41..59 then l(:actionview_datehelper_time_in_words_minute_less_than)
+ else l(:actionview_datehelper_time_in_words_minute)
+ end
+
+ when 2..45 then lwr(:actionview_datehelper_time_in_words_minute, distance_in_minutes)
+ when 46..90 then l(:actionview_datehelper_time_in_words_hour_about_single)
+ when 90..1440 then lwr(:actionview_datehelper_time_in_words_hour_about, (distance_in_minutes.to_f / 60.0).round)
+ when 1441..2880 then lwr(:actionview_datehelper_time_in_words_day, 1)
+ else lwr(:actionview_datehelper_time_in_words_day, (distance_in_minutes / 1440).round)
+ end
+ end
+
+ # This method has been modified so that a localized string can be appended to the day numbers.
+ def select_day(date, options = {})
+ day_options = []
+ prefix = l :actionview_datehelper_select_day_prefix
+
+ 1.upto(31) do |day|
+ day_options << ((date && (date.kind_of?(Fixnum) ? date : date.day) == day) ?
+ %(#{day}#{prefix} \n) :
+ %(#{day}#{prefix} \n)
+ )
+ end
+
+ select_html(options[:field_name] || 'day', day_options, options[:prefix], options[:include_blank], options[:discard_type], options[:disabled])
+ end
+
+ # This method has been modified so that
+ # * the month names are localized.
+ # * it uses options: :min_date , :max_date , :start_month , :end_month
+ # * a localized string can be appended to the month numbers when the :use_month_numbers option is specified.
+ def select_month(date, options = {})
+ unless LOCALIZED_MONTHNAMES.has_key?(current_language)
+ LOCALIZED_MONTHNAMES[current_language] = [''] + l(:actionview_datehelper_select_month_names).split(',')
+ LOCALIZED_ABBR_MONTHNAMES[current_language] = [''] + l(:actionview_datehelper_select_month_names_abbr).split(',')
+ end
+
+ month_options = []
+ month_names = options[:use_short_month] ? LOCALIZED_ABBR_MONTHNAMES[current_language] : LOCALIZED_MONTHNAMES[current_language]
+
+ if options.has_key?(:min_date) && options.has_key?(:max_date)
+ if options[:min_date].year == options[:max_date].year
+ start_month, end_month = options[:min_date].month, options[:max_date].month
+ end
+ end
+ start_month = (options[:start_month] || 1) unless start_month
+ end_month = (options[:end_month] || 12) unless end_month
+ prefix = l :actionview_datehelper_select_month_prefix
+
+ start_month.upto(end_month) do |month_number|
+ month_name = if options[:use_month_numbers]
+ "#{month_number}#{prefix}"
+ elsif options[:add_month_numbers]
+ month_number.to_s + ' - ' + month_names[month_number]
+ else
+ month_names[month_number]
+ end
+
+ month_options << ((date && (date.kind_of?(Fixnum) ? date : date.month) == month_number) ?
+ %(#{month_name} \n) :
+ %(#{month_name} \n)
+ )
+ end
+
+ select_html(options[:field_name] || 'month', month_options, options[:prefix], options[:include_blank], options[:discard_type], options[:disabled])
+ end
+
+ # This method has been modified so that
+ # * it uses options: :min_date , :max_date
+ # * a localized string can be appended to the years numbers.
+ def select_year(date, options = {})
+ year_options = []
+ y = date ? (date.kind_of?(Fixnum) ? (y = (date == 0) ? Date.today.year : date) : date.year) : Date.today.year
+
+ start_year = options.has_key?(:min_date) ? options[:min_date].year : (options[:start_year] || y-5)
+ end_year = options.has_key?(:max_date) ? options[:max_date].year : (options[:end_year] || y+5)
+ step_val = start_year < end_year ? 1 : -1
+ prefix = l :actionview_datehelper_select_year_prefix
+
+ start_year.step(end_year, step_val) do |year|
+ year_options << ((date && (date.kind_of?(Fixnum) ? date : date.year) == year) ?
+ %(#{year}#{prefix} \n) :
+ %(#{year}#{prefix} \n)
+ )
+ end
+
+ select_html(options[:field_name] || 'year', year_options, options[:prefix], options[:include_blank], options[:discard_type], options[:disabled])
+ end
+
+ # added by JP Lang
+ # select_html is a rails private method and changed in 1.2
+ # implementation added here for compatibility
+ def select_html(type, options, prefix = nil, include_blank = false, discard_type = false, disabled = false)
+ select_html = %(\n)
+ select_html << %( \n) if include_blank
+ select_html << options.to_s
+ select_html << " \n"
+ end
+ end
+
+ # The private method add_options is overridden so that "Please select" is localized.
+ class InstanceTag
+ private
+
+ def add_options(option_tags, options, value = nil)
+ option_tags = " \n" + option_tags if options[:include_blank]
+
+ if value.blank? && options[:prompt]
+ ("#{options[:prompt].kind_of?(String) ? options[:prompt] : l(:actionview_instancetag_blank_option)} \n") + option_tags
+ else
+ option_tags
+ end
+ end
+
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-rails.rb b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-rails.rb
new file mode 100644
index 000000000..8f201bcb8
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-rails.rb
@@ -0,0 +1,231 @@
+# Copyright (c) 2005-2006 David Barri
+
+require 'gloc'
+
+module ActionController #:nodoc:
+ class Base #:nodoc:
+ include GLoc
+ end
+ module Filters #:nodoc:
+ module ClassMethods
+
+ # This filter attempts to auto-detect the clients desired language.
+ # It first checks the params, then a cookie and then the HTTP_ACCEPT_LANGUAGE
+ # request header. If a language is found to match or be similar to a currently
+ # valid language, then it sets the current_language of the controller.
+ #
+ # class ExampleController < ApplicationController
+ # set_language :en
+ # autodetect_language_filter :except => 'monkey', :on_no_lang => :lang_not_autodetected_callback
+ # autodetect_language_filter :only => 'monkey', :check_cookie => 'monkey_lang', :check_accept_header => false
+ # ...
+ # def lang_not_autodetected_callback
+ # redirect_to somewhere
+ # end
+ # end
+ #
+ # The args for this filter are exactly the same the arguments of
+ # before_filter with the following exceptions:
+ # * :check_params -- If false, then params will not be checked for a language.
+ # If a String, then this will value will be used as the name of the param.
+ # * :check_cookie -- If false, then the cookie will not be checked for a language.
+ # If a String, then this will value will be used as the name of the cookie.
+ # * :check_accept_header -- If false, then HTTP_ACCEPT_LANGUAGE will not be checked for a language.
+ # * :on_set_lang -- You can specify the name of a callback function to be called when the language
+ # is successfully detected and set. The param must be a Symbol or a String which is the name of the function.
+ # The callback function must accept one argument (the language) and must be instance level.
+ # * :on_no_lang -- You can specify the name of a callback function to be called when the language
+ # couldn't be detected automatically. The param must be a Symbol or a String which is the name of the function.
+ # The callback function must be instance level.
+ #
+ # You override the default names of the param or cookie by calling GLoc.set_config :default_param_name => 'new_param_name'
+ # and GLoc.set_config :default_cookie_name => 'new_cookie_name' .
+ def autodetect_language_filter(*args)
+ options= args.last.is_a?(Hash) ? args.last : {}
+ x= 'Proc.new { |c| l= nil;'
+ # :check_params
+ unless (v= options.delete(:check_params)) == false
+ name= v ? ":#{v}" : 'GLoc.get_config(:default_param_name)'
+ x << "l ||= GLoc.similar_language(c.params[#{name}]);"
+ end
+ # :check_cookie
+ unless (v= options.delete(:check_cookie)) == false
+ name= v ? ":#{v}" : 'GLoc.get_config(:default_cookie_name)'
+ x << "l ||= GLoc.similar_language(c.send(:cookies)[#{name}]);"
+ end
+ # :check_accept_header
+ unless options.delete(:check_accept_header) == false
+ x << %<
+ unless l
+ a= c.request.env['HTTP_ACCEPT_LANGUAGE'].split(/,|;/) rescue nil
+ a.each {|x| l ||= GLoc.similar_language(x)} if a
+ end; >
+ end
+ # Set language
+ x << 'ret= true;'
+ x << 'if l; c.set_language(l); c.headers[\'Content-Language\']= l.to_s; '
+ if options.has_key?(:on_set_lang)
+ x << "ret= c.#{options.delete(:on_set_lang)}(l);"
+ end
+ if options.has_key?(:on_no_lang)
+ x << "else; ret= c.#{options.delete(:on_no_lang)};"
+ end
+ x << 'end; ret }'
+
+ # Create filter
+ block= eval x
+ before_filter(*args, &block)
+ end
+
+ end
+ end
+end
+
+# ==============================================================================
+
+module ActionMailer #:nodoc:
+ # In addition to including GLoc, render_message is also overridden so
+ # that mail templates contain the current language at the end of the file.
+ # Eg. deliver_hello will render hello_en.rhtml .
+ class Base
+ include GLoc
+ private
+ alias :render_message_without_gloc :render_message
+ def render_message(method_name, body)
+ template = File.exist?("#{template_path}/#{method_name}_#{current_language}.rhtml") ? "#{method_name}_#{current_language}" : "#{method_name}"
+ render_message_without_gloc(template, body)
+ end
+ end
+end
+
+# ==============================================================================
+
+module ActionView #:nodoc:
+ # initialize is overridden so that new instances of this class inherit
+ # the current language of the controller.
+ class Base
+ include GLoc
+
+ alias :initialize_without_gloc :initialize
+ def initialize(base_path = nil, assigns_for_first_render = {}, controller = nil)
+ initialize_without_gloc(base_path, assigns_for_first_render, controller)
+ set_language controller.current_language unless controller.nil?
+ end
+ end
+
+ module Helpers #:nodoc:
+ class InstanceTag
+ include GLoc
+ # Inherits the current language from the template object.
+ def current_language
+ @template_object.current_language
+ end
+ end
+ end
+end
+
+# ==============================================================================
+
+module ActiveRecord #:nodoc:
+ class Base #:nodoc:
+ include GLoc
+ end
+
+# class Errors
+# include GLoc
+# alias :add_without_gloc :add
+# # The GLoc version of this method provides two extra features
+# # * If msg is a string, it will be considered a GLoc string key.
+# # * If msg is an array, the first element will be considered
+# # the string and the remaining elements will be considered arguments for the
+# # string. Eg. ['Hi %s.','John']
+# def add(attribute, msg= @@default_error_messages[:invalid])
+# if msg.is_a?(Array)
+# args= msg.clone
+# msg= args.shift
+# args= nil if args.empty?
+# end
+# msg= ltry(msg)
+# msg= msg % args unless args.nil?
+# add_without_gloc(attribute, msg)
+# end
+# # Inherits the current language from the base record.
+# def current_language
+# @base.current_language
+# end
+# end
+
+ module Validations #:nodoc:
+ module ClassMethods
+ # The default Rails version of this function creates an error message and then
+ # passes it to ActiveRecord.Errors.
+ # The GLoc version of this method, sends an array to ActiveRecord.Errors that will
+ # be turned into a string by ActiveRecord.Errors which in turn allows for the message
+ # of this validation function to be a GLoc string key.
+ def validates_length_of(*attrs)
+ # Merge given options with defaults.
+ options = {
+ :too_long => ActiveRecord::Errors.default_error_messages[:too_long],
+ :too_short => ActiveRecord::Errors.default_error_messages[:too_short],
+ :wrong_length => ActiveRecord::Errors.default_error_messages[:wrong_length]
+ }.merge(DEFAULT_VALIDATION_OPTIONS)
+ options.update(attrs.pop.symbolize_keys) if attrs.last.is_a?(Hash)
+
+ # Ensure that one and only one range option is specified.
+ range_options = ALL_RANGE_OPTIONS & options.keys
+ case range_options.size
+ when 0
+ raise ArgumentError, 'Range unspecified. Specify the :within, :maximum, :minimum, or :is option.'
+ when 1
+ # Valid number of options; do nothing.
+ else
+ raise ArgumentError, 'Too many range options specified. Choose only one.'
+ end
+
+ # Get range option and value.
+ option = range_options.first
+ option_value = options[range_options.first]
+
+ case option
+ when :within, :in
+ raise ArgumentError, ":#{option} must be a Range" unless option_value.is_a?(Range)
+
+ too_short = [options[:too_short] , option_value.begin]
+ too_long = [options[:too_long] , option_value.end ]
+
+ validates_each(attrs, options) do |record, attr, value|
+ if value.nil? or value.split(//).size < option_value.begin
+ record.errors.add(attr, too_short)
+ elsif value.split(//).size > option_value.end
+ record.errors.add(attr, too_long)
+ end
+ end
+ when :is, :minimum, :maximum
+ raise ArgumentError, ":#{option} must be a nonnegative Integer" unless option_value.is_a?(Integer) and option_value >= 0
+
+ # Declare different validations per option.
+ validity_checks = { :is => "==", :minimum => ">=", :maximum => "<=" }
+ message_options = { :is => :wrong_length, :minimum => :too_short, :maximum => :too_long }
+
+ message = [(options[:message] || options[message_options[option]]) , option_value]
+
+ validates_each(attrs, options) do |record, attr, value|
+ if value.kind_of?(String)
+ record.errors.add(attr, message) unless !value.nil? and value.split(//).size.method(validity_checks[option])[option_value]
+ else
+ record.errors.add(attr, message) unless !value.nil? and value.size.method(validity_checks[option])[option_value]
+ end
+ end
+ end
+ end
+
+ alias_method :validates_size_of, :validates_length_of
+ end
+ end
+end
+
+# ==============================================================================
+
+module ApplicationHelper #:nodoc:
+ include GLoc
+end
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-ruby.rb b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-ruby.rb
new file mode 100644
index 000000000..f96ab6cf9
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-ruby.rb
@@ -0,0 +1,7 @@
+# Copyright (c) 2005-2006 David Barri
+
+module Test # :nodoc:
+ module Unit # :nodoc:
+ class TestCase # :nodoc:
+ include GLoc
+end; end; end
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-version.rb b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-version.rb
new file mode 100644
index 000000000..91afcf482
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc-version.rb
@@ -0,0 +1,12 @@
+module GLoc
+ module VERSION #:nodoc:
+ MAJOR = 1
+ MINOR = 1
+ TINY = nil
+
+ STRING= [MAJOR, MINOR, TINY].delete_if{|x|x.nil?}.join('.')
+ def self.to_s; STRING end
+ end
+end
+
+puts "NOTICE: You are using a dev version of GLoc." if GLoc::VERSION::TINY == 'DEV'
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc.rb b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc.rb
new file mode 100644
index 000000000..bcad0ed9b
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/lib/gloc.rb
@@ -0,0 +1,294 @@
+# Copyright (c) 2005-2006 David Barri
+
+require 'yaml'
+require 'gloc-internal'
+require 'gloc-helpers'
+
+module GLoc
+ UTF_8= 'utf-8'
+ SHIFT_JIS= 'sjis'
+ EUC_JP= 'euc-jp'
+
+ # This module will be included in both instances and classes of GLoc includees.
+ # It is also included as class methods in the GLoc module itself.
+ module InstanceMethods
+ include Helpers
+
+ # Returns a localized string.
+ def l(symbol, *arguments)
+ return GLoc._l(symbol,current_language,*arguments)
+ end
+
+ # Returns a localized string in a specified language.
+ # This does not effect current_language .
+ def ll(lang, symbol, *arguments)
+ return GLoc._l(symbol,lang.to_sym,*arguments)
+ end
+
+ # Returns a localized string if the argument is a Symbol, else just returns the argument.
+ def ltry(possible_key)
+ possible_key.is_a?(Symbol) ? l(possible_key) : possible_key
+ end
+
+ # Uses the default GLoc rule to return a localized string.
+ # See lwr_() for more info.
+ def lwr(symbol, *arguments)
+ lwr_(:default, symbol, *arguments)
+ end
+
+ # Uses a rule to return a localized string.
+ # A rule is a function that uses specified arguments to return a localization key prefix.
+ # The prefix is appended to the localization key originally specified, to create a new key which
+ # is then used to lookup a localized string.
+ def lwr_(rule, symbol, *arguments)
+ GLoc._l("#{symbol}#{GLoc::_l_rule(rule,current_language).call(*arguments)}",current_language,*arguments)
+ end
+
+ # Returns true if a localized string with the specified key exists.
+ def l_has_string?(symbol)
+ return GLoc._l_has_string?(symbol,current_language)
+ end
+
+ # Sets the current language for this instance/class.
+ # Setting the language of a class effects all instances unless the instance has its own language defined.
+ def set_language(language)
+ @gloc_language= language.nil? ? nil : language.to_sym
+ end
+
+ # Sets the current language if the language passed is a valid language.
+ # If the language was valid, this method returns true else it will return false .
+ # Note that nil is not a valid language.
+ # See set_language(language) for more info.
+ def set_language_if_valid(language)
+ if GLoc.valid_language?(language)
+ set_language(language)
+ true
+ else
+ false
+ end
+ end
+ end
+
+ #---------------------------------------------------------------------------
+ # Instance
+
+ include ::GLoc::InstanceMethods
+ # Returns the instance-level current language, or if not set, returns the class-level current language.
+ def current_language
+ @gloc_language || self.class.current_language
+ end
+
+ #---------------------------------------------------------------------------
+ # Class
+
+ # All classes/modules that include GLoc will also gain these class methods.
+ # Notice that the GLoc::InstanceMethods module is also included.
+ module ClassMethods
+ include ::GLoc::InstanceMethods
+ # Returns the current language, or if not set, returns the GLoc current language.
+ def current_language
+ @gloc_language || GLoc.current_language
+ end
+ end
+
+ def self.included(target) #:nodoc:
+ super
+ class << target
+ include ::GLoc::ClassMethods
+ end
+ end
+
+ #---------------------------------------------------------------------------
+ # GLoc module
+
+ class << self
+ include ::GLoc::InstanceMethods
+
+ # Returns the default language
+ def current_language
+ GLoc::CONFIG[:default_language]
+ end
+
+ # Adds a collection of localized strings to the in-memory string store.
+ def add_localized_strings(lang, symbol_hash, override=true, strings_charset=nil)
+ _verbose_msg {"Adding #{symbol_hash.size} #{lang} strings."}
+ _add_localized_strings(lang, symbol_hash, override, strings_charset)
+ _verbose_msg :stats
+ end
+
+ # Creates a backup of the internal state of GLoc (ie. strings, langs, rules, config)
+ # and optionally clears everything.
+ def backup_state(clear=false)
+ s= _get_internal_state_vars.map{|o| o.clone}
+ _get_internal_state_vars.each{|o| o.clear} if clear
+ s
+ end
+
+ # Removes all localized strings from memory, either of a certain language (or languages),
+ # or entirely.
+ def clear_strings(*languages)
+ if languages.empty?
+ _verbose_msg {"Clearing all strings"}
+ LOCALIZED_STRINGS.clear
+ LOWERCASE_LANGUAGES.clear
+ else
+ languages.each {|l|
+ _verbose_msg {"Clearing :#{l} strings"}
+ l= l.to_sym
+ LOCALIZED_STRINGS.delete l
+ LOWERCASE_LANGUAGES.each_pair {|k,v| LOWERCASE_LANGUAGES.delete k if v == l}
+ }
+ end
+ end
+ alias :_clear_strings :clear_strings
+
+ # Removes all localized strings from memory, except for those of certain specified languages.
+ def clear_strings_except(*languages)
+ clear= (LOCALIZED_STRINGS.keys - languages)
+ _clear_strings(*clear) unless clear.empty?
+ end
+
+ # Returns the charset used to store localized strings in memory.
+ def get_charset(lang)
+ CONFIG[:internal_charset_per_lang][lang] || CONFIG[:internal_charset]
+ end
+
+ # Returns a GLoc configuration value.
+ def get_config(key)
+ CONFIG[key]
+ end
+
+ # Loads the localized strings that are included in the GLoc library.
+ def load_gloc_default_localized_strings(override=false)
+ GLoc.load_localized_strings "#{File.dirname(__FILE__)}/../lang", override
+ end
+
+ # Loads localized strings from all yml files in the specifed directory.
+ def load_localized_strings(dir=nil, override=true)
+ _charset_required
+ _get_lang_file_list(dir).each {|filename|
+
+ # Load file
+ raw_hash = YAML::load(File.read(filename))
+ raw_hash={} unless raw_hash.kind_of?(Hash)
+ filename =~ /([^\/\\]+)\.ya?ml$/
+ lang = $1.to_sym
+ file_charset = raw_hash['file_charset'] || UTF_8
+
+ # Convert string keys to symbols
+ dest_charset= get_charset(lang)
+ _verbose_msg {"Reading file #{filename} [charset: #{file_charset} --> #{dest_charset}]"}
+ symbol_hash = {}
+ Iconv.open(dest_charset, file_charset) do |i|
+ raw_hash.each {|key, value|
+ symbol_hash[key.to_sym] = i.iconv(value)
+ }
+ end
+
+ # Add strings to repos
+ _add_localized_strings(lang, symbol_hash, override)
+ }
+ _verbose_msg :stats
+ end
+
+ # Restores a backup of GLoc's internal state that was made with backup_state.
+ def restore_state(state)
+ _get_internal_state_vars.each do |o|
+ o.clear
+ o.send o.respond_to?(:merge!) ? :merge! : :concat, state.shift
+ end
+ end
+
+ # Sets the charset used to internally store localized strings.
+ # You can set the charset to use for a specific language or languages,
+ # or if none are specified the charset for ALL localized strings will be set.
+ def set_charset(new_charset, *langs)
+ CONFIG[:internal_charset_per_lang] ||= {}
+
+ # Convert symbol shortcuts
+ if new_charset.is_a?(Symbol)
+ new_charset= case new_charset
+ when :utf8, :utf_8 then UTF_8
+ when :sjis, :shift_jis, :shiftjis then SHIFT_JIS
+ when :eucjp, :euc_jp then EUC_JP
+ else new_charset.to_s
+ end
+ end
+
+ # Convert existing strings
+ (langs.empty? ? LOCALIZED_STRINGS.keys : langs).each do |lang|
+ cur_charset= get_charset(lang)
+ if cur_charset && new_charset != cur_charset
+ _verbose_msg {"Converting :#{lang} strings from #{cur_charset} to #{new_charset}"}
+ Iconv.open(new_charset, cur_charset) do |i|
+ bundle= LOCALIZED_STRINGS[lang]
+ bundle.each_pair {|k,v| bundle[k]= i.iconv(v)}
+ end
+ end
+ end
+
+ # Set new charset value
+ if langs.empty?
+ _verbose_msg {"Setting GLoc charset for all languages to #{new_charset}"}
+ CONFIG[:internal_charset]= new_charset
+ CONFIG[:internal_charset_per_lang].clear
+ else
+ langs.each do |lang|
+ _verbose_msg {"Setting GLoc charset for :#{lang} strings to #{new_charset}"}
+ CONFIG[:internal_charset_per_lang][lang]= new_charset
+ end
+ end
+ end
+
+ # Sets GLoc configuration values.
+ def set_config(hash)
+ CONFIG.merge! hash
+ end
+
+ # Sets the $KCODE global variable according to a specified charset, or else the
+ # current default charset for the default language.
+ def set_kcode(charset=nil)
+ _charset_required
+ charset ||= get_charset(current_language)
+ $KCODE= case charset
+ when UTF_8 then 'u'
+ when SHIFT_JIS then 's'
+ when EUC_JP then 'e'
+ else 'n'
+ end
+ _verbose_msg {"$KCODE set to #{$KCODE}"}
+ end
+
+ # Tries to find a valid language that is similar to the argument passed.
+ # Eg. :en, :en_au, :EN_US are all similar languages.
+ # Returns nil if no similar languages are found.
+ def similar_language(lang)
+ return nil if lang.nil?
+ return lang.to_sym if valid_language?(lang)
+ # Check lowercase without dashes
+ lang= lang.to_s.downcase.gsub('-','_')
+ return LOWERCASE_LANGUAGES[lang] if LOWERCASE_LANGUAGES.has_key?(lang)
+ # Check without dialect
+ if lang.to_s =~ /^([a-z]+?)[^a-z].*/
+ lang= $1
+ return LOWERCASE_LANGUAGES[lang] if LOWERCASE_LANGUAGES.has_key?(lang)
+ end
+ # Check other dialects
+ lang= "#{lang}_"
+ LOWERCASE_LANGUAGES.keys.each {|k| return LOWERCASE_LANGUAGES[k] if k.starts_with?(lang)}
+ # Nothing found
+ nil
+ end
+
+ # Returns an array of (currently) valid languages (ie. languages for which localized data exists).
+ def valid_languages
+ LOCALIZED_STRINGS.keys
+ end
+
+ # Returns true if there are any localized strings for a specified language.
+ # Note that although set_langauge nil is perfectly valid, nil is not a valid language.
+ def valid_language?(language)
+ LOCALIZED_STRINGS.has_key? language.to_sym rescue false
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/tasks/gloc.rake b/rest_sys/vendor/plugins/gloc-1.1.0/tasks/gloc.rake
new file mode 100644
index 000000000..88f3472ec
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/tasks/gloc.rake
@@ -0,0 +1,53 @@
+namespace :gloc do
+ desc 'Sorts the keys in the lang ymls'
+ task :sort do
+ dir = ENV['DIR'] || '{.,vendor/plugins/*}/lang'
+ puts "Processing directory #{dir}"
+ files = Dir.glob(File.join(dir,'*.{yaml,yml}'))
+ puts 'No files found.' if files.empty?
+ files.each {|file|
+ puts "Sorting file: #{file}"
+ header = []
+ content = IO.readlines(file)
+ content.each {|line| line.gsub!(/[\s\r\n\t]+$/,'')}
+ content.delete_if {|line| line==''}
+ tmp= []
+ content.each {|x| tmp << x unless tmp.include?(x)}
+ content= tmp
+ header << content.shift if !content.empty? && content[0] =~ /^file_charset:/
+ content.sort!
+ filebak = "#{file}.bak"
+ File.rename file, filebak
+ File.open(file, 'w') {|fout| fout << header.join("\n") << content.join("\n") << "\n"}
+ File.delete filebak
+ # Report duplicates
+ count= {}
+ content.map {|x| x.gsub(/:.+$/, '') }.each {|x| count[x] ||= 0; count[x] += 1}
+ count.delete_if {|k,v|v==1}
+ puts count.keys.sort.map{|x|" WARNING: Duplicate key '#{x}' (#{count[x]} occurances)"}.join("\n") unless count.empty?
+ }
+ end
+
+ desc 'Updates language files based on em.yml content'
+ task :update do
+ dir = ENV['DIR'] || './lang'
+
+ en_strings = {}
+ en_file = File.open(File.join(dir,'en.yml'), 'r')
+ en_file.each_line {|line| en_strings[$1] = $2 if line =~ %r{^([\w_]+):\s(.+)$} }
+ en_file.close
+
+ files = Dir.glob(File.join(dir,'*.{yaml,yml}'))
+ files.each do |file|
+ puts "Updating file #{file}"
+ keys = IO.readlines(file).collect {|line| $1 if line =~ %r{^([\w_]+):\s(.+)$} }.compact
+ lang = File.open(file, 'a')
+ en_strings.each do |key, str|
+ next if keys.include?(key)
+ puts "added: #{key}"
+ lang << "#{key}: #{str}\n"
+ end
+ lang.close
+ end
+ end
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/test/gloc_rails_test.rb b/rest_sys/vendor/plugins/gloc-1.1.0/test/gloc_rails_test.rb
new file mode 100644
index 000000000..4cb232904
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/test/gloc_rails_test.rb
@@ -0,0 +1,118 @@
+# Copyright (c) 2005-2006 David Barri
+
+$LOAD_PATH.push File.join(File.dirname(__FILE__),'..','lib')
+require "#{File.dirname(__FILE__)}/../../../../test/test_helper"
+require "#{File.dirname(__FILE__)}/../init"
+
+class GLocRailsTestController < ActionController::Base
+ autodetect_language_filter :only => :auto, :on_set_lang => :called_when_set, :on_no_lang => :called_when_bad
+ autodetect_language_filter :only => :auto2, :check_accept_header => false, :check_params => 'xx'
+ autodetect_language_filter :only => :auto3, :check_cookie => false
+ autodetect_language_filter :only => :auto4, :check_cookie => 'qwe', :check_params => false
+ def rescue_action(e) raise e end
+ def auto; render :text => 'auto'; end
+ def auto2; render :text => 'auto'; end
+ def auto3; render :text => 'auto'; end
+ def auto4; render :text => 'auto'; end
+ attr_accessor :callback_set, :callback_bad
+ def called_when_set(l) @callback_set ||= 0; @callback_set += 1 end
+ def called_when_bad; @callback_bad ||= 0; @callback_bad += 1 end
+end
+
+class GLocRailsTest < Test::Unit::TestCase
+
+ def setup
+ @lstrings = GLoc::LOCALIZED_STRINGS.clone
+ @old_config= GLoc::CONFIG.clone
+ begin_new_request
+ end
+
+ def teardown
+ GLoc.clear_strings
+ GLoc::LOCALIZED_STRINGS.merge! @lstrings
+ GLoc::CONFIG.merge! @old_config
+ end
+
+ def begin_new_request
+ @controller = GLocRailsTestController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ def test_autodetect_language
+ GLoc::CONFIG[:default_language]= :def
+ GLoc::CONFIG[:default_param_name] = 'plang'
+ GLoc::CONFIG[:default_cookie_name] = 'clang'
+ GLoc.clear_strings
+ GLoc.add_localized_strings :en, :a => 'a'
+ GLoc.add_localized_strings :en_au, :a => 'a'
+ GLoc.add_localized_strings :en_US, :a => 'a'
+ GLoc.add_localized_strings :Ja, :a => 'a'
+ GLoc.add_localized_strings :ZH_HK, :a => 'a'
+
+ # default
+ subtest_autodetect_language :def, nil, nil, nil
+ subtest_autodetect_language :def, 'its', 'all', 'bullshit,man;q=zxc'
+ # simple
+ subtest_autodetect_language :en_au, 'en_au', nil, nil
+ subtest_autodetect_language :en_US, nil, 'en_us', nil
+ subtest_autodetect_language :Ja, nil, nil, 'ja'
+ # priority
+ subtest_autodetect_language :Ja, 'ja', 'en_us', 'qwe_ja,zh,monkey_en;q=0.5'
+ subtest_autodetect_language :en_US, 'why', 'en_us', 'qwe_ja,zh,monkey_en;q=0.5'
+ subtest_autodetect_language :Ja, nil, nil, 'qwe_en,JA,zh,monkey_en;q=0.5'
+ # dashes to underscores in accept string
+ subtest_autodetect_language :en_au, 'monkey', nil, 'de,EN-Au'
+ # remove dialect
+ subtest_autodetect_language :en, nil, 'en-bullshit', nil
+ subtest_autodetect_language :en, 'monkey', nil, 'de,EN-NZ,ja'
+ # different dialect
+ subtest_autodetect_language :ZH_HK, 'zh', nil, 'de,EN-NZ,ja'
+ subtest_autodetect_language :ZH_HK, 'monkey', 'zh', 'de,EN-NZ,ja'
+
+ # Check param/cookie names use defaults
+ GLoc::CONFIG[:default_param_name] = 'p_lang'
+ GLoc::CONFIG[:default_cookie_name] = 'c_lang'
+ # :check_params
+ subtest_autodetect_language :def, 'en_au', nil, nil
+ subtest_autodetect_language :en_au, {:p_lang => 'en_au'}, nil, nil
+ # :check_cookie
+ subtest_autodetect_language :def, nil, 'en_us', nil
+ subtest_autodetect_language :en_US, nil, {:c_lang => 'en_us'}, nil
+ GLoc::CONFIG[:default_param_name] = 'plang'
+ GLoc::CONFIG[:default_cookie_name] = 'clang'
+
+ # autodetect_language_filter :only => :auto2, :check_accept_header => false, :check_params => 'xx'
+ subtest_autodetect_language :def, 'ja', nil, 'en_US', :auto2
+ subtest_autodetect_language :Ja, {:xx => 'ja'}, nil, 'en_US', :auto2
+ subtest_autodetect_language :en_au, 'ja', 'en_au', 'en_US', :auto2
+
+ # autodetect_language_filter :only => :auto3, :check_cookie => false
+ subtest_autodetect_language :Ja, 'ja', 'en_us', 'qwe_ja,zh,monkey_en;q=0.5', :auto3
+ subtest_autodetect_language :ZH_HK, 'hehe', 'en_us', 'qwe_ja,zh,monkey_en;q=0.5', :auto3
+
+ # autodetect_language_filter :only => :auto4, :check_cookie => 'qwe', :check_params => false
+ subtest_autodetect_language :def, 'ja', 'en_us', nil, :auto4
+ subtest_autodetect_language :ZH_HK, 'ja', 'en_us', 'qwe_ja,zh,monkey_en;q=0.5', :auto4
+ subtest_autodetect_language :en_US, 'ja', {:qwe => 'en_us'}, 'ja', :auto4
+ end
+
+ def subtest_autodetect_language(expected,params,cookie,accept, action=:auto)
+ begin_new_request
+ params= {'plang' => params} if params.is_a?(String)
+ params ||= {}
+ if cookie
+ cookie={'clang' => cookie} unless cookie.is_a?(Hash)
+ cookie.each_pair {|k,v| @request.cookies[k.to_s]= CGI::Cookie.new(k.to_s,v)}
+ end
+ @request.env['HTTP_ACCEPT_LANGUAGE']= accept
+ get action, params
+ assert_equal expected, @controller.current_language
+ if action == :auto
+ s,b = expected != :def ? [1,nil] : [nil,1]
+ assert_equal s, @controller.callback_set
+ assert_equal b, @controller.callback_bad
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/test/gloc_test.rb b/rest_sys/vendor/plugins/gloc-1.1.0/test/gloc_test.rb
new file mode 100644
index 000000000..a39d5c41c
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/test/gloc_test.rb
@@ -0,0 +1,433 @@
+# Copyright (c) 2005-2006 David Barri
+
+$LOAD_PATH.push File.join(File.dirname(__FILE__),'..','lib')
+require 'gloc'
+require 'gloc-ruby'
+require 'gloc-config'
+require 'gloc-rails-text'
+require File.join(File.dirname(__FILE__),'lib','rails-time_ext') unless 3.respond_to?(:days)
+require File.join(File.dirname(__FILE__),'lib','rails-string_ext') unless ''.respond_to?(:starts_with?)
+#require 'gloc-dev'
+
+class LClass; include GLoc; end
+class LClass2 < LClass; end
+class LClass_en < LClass2; set_language :en; end
+class LClass_ja < LClass2; set_language :ja; end
+# class LClass_forced_au < LClass; set_language :en; force_language :en_AU; set_language :ja; end
+
+class GLocTest < Test::Unit::TestCase
+ include GLoc
+ include ActionView::Helpers::DateHelper
+
+ def setup
+ @l1 = LClass.new
+ @l2 = LClass.new
+ @l3 = LClass.new
+ @l1.set_language :ja
+ @l2.set_language :en
+ @l3.set_language 'en_AU'
+ @gloc_state= GLoc.backup_state true
+ GLoc::CONFIG.merge!({
+ :default_param_name => 'lang',
+ :default_cookie_name => 'lang',
+ :default_language => :ja,
+ :raise_string_not_found_errors => true,
+ :verbose => false,
+ })
+ end
+
+ def teardown
+ GLoc.restore_state @gloc_state
+ end
+
+ #---------------------------------------------------------------------------
+
+ def test_basic
+ assert_localized_value [nil, @l1, @l2, @l3], nil, :in_both_langs
+
+ GLoc.load_localized_strings File.join(File.dirname(__FILE__),'lang')
+
+ assert_localized_value [nil, @l1], 'enã«ã‚‚jaã«ã‚‚ã‚ã‚‹', :in_both_langs
+ assert_localized_value [nil, @l1], '日本語ã®ã¿', :ja_only
+ assert_localized_value [nil, @l1], nil, :en_only
+
+ assert_localized_value @l2, 'This is in en+ja', :in_both_langs
+ assert_localized_value @l2, nil, :ja_only
+ assert_localized_value @l2, 'English only', :en_only
+
+ assert_localized_value @l3, "Thiz in en 'n' ja", :in_both_langs
+ assert_localized_value @l3, nil, :ja_only
+ assert_localized_value @l3, 'Aussie English only bro', :en_only
+
+ @l3.set_language :en
+ assert_localized_value @l3, 'This is in en+ja', :in_both_langs
+ assert_localized_value @l3, nil, :ja_only
+ assert_localized_value @l3, 'English only', :en_only
+
+ assert_localized_value nil, 'enã«ã‚‚jaã«ã‚‚ã‚ã‚‹', :in_both_langs
+ assert_localized_value nil, '日本語ã®ã¿', :ja_only
+ assert_localized_value nil, nil, :en_only
+ end
+
+ def test_load_twice_with_override
+ GLoc.load_localized_strings File.join(File.dirname(__FILE__),'lang')
+ GLoc.load_localized_strings File.join(File.dirname(__FILE__),'lang2')
+
+ assert_localized_value [nil, @l1], 'æ›´æ–°ã•れãŸ', :in_both_langs
+ assert_localized_value [nil, @l1], '日本語ã®ã¿', :ja_only
+ assert_localized_value [nil, @l1], nil, :en_only
+ assert_localized_value [nil, @l1], nil, :new_en
+ assert_localized_value [nil, @l1], 'æ–°ãŸãªæ—¥æœ¬èªžã‚¹ãƒˆãƒªãƒ³ã‚°', :new_ja
+
+ assert_localized_value @l2, 'This is in en+ja', :in_both_langs
+ assert_localized_value @l2, nil, :ja_only
+ assert_localized_value @l2, 'overriden dude', :en_only
+ assert_localized_value @l2, 'This is a new English string', :new_en
+ assert_localized_value @l2, nil, :new_ja
+
+ assert_localized_value @l3, "Thiz in en 'n' ja", :in_both_langs
+ assert_localized_value @l3, nil, :ja_only
+ assert_localized_value @l3, 'Aussie English only bro', :en_only
+ end
+
+ def test_load_twice_without_override
+ GLoc.load_localized_strings File.join(File.dirname(__FILE__),'lang')
+ GLoc.load_localized_strings File.join(File.dirname(__FILE__),'lang2'), false
+
+ assert_localized_value [nil, @l1], 'enã«ã‚‚jaã«ã‚‚ã‚ã‚‹', :in_both_langs
+ assert_localized_value [nil, @l1], '日本語ã®ã¿', :ja_only
+ assert_localized_value [nil, @l1], nil, :en_only
+ assert_localized_value [nil, @l1], nil, :new_en
+ assert_localized_value [nil, @l1], 'æ–°ãŸãªæ—¥æœ¬èªžã‚¹ãƒˆãƒªãƒ³ã‚°', :new_ja
+
+ assert_localized_value @l2, 'This is in en+ja', :in_both_langs
+ assert_localized_value @l2, nil, :ja_only
+ assert_localized_value @l2, 'English only', :en_only
+ assert_localized_value @l2, 'This is a new English string', :new_en
+ assert_localized_value @l2, nil, :new_ja
+
+ assert_localized_value @l3, "Thiz in en 'n' ja", :in_both_langs
+ assert_localized_value @l3, nil, :ja_only
+ assert_localized_value @l3, 'Aussie English only bro', :en_only
+ end
+
+ def test_add_localized_strings
+ assert_localized_value nil, nil, :add
+ assert_localized_value nil, nil, :ja_only
+ GLoc.load_localized_strings File.join(File.dirname(__FILE__),'lang')
+ assert_localized_value nil, nil, :add
+ assert_localized_value nil, '日本語ã®ã¿', :ja_only
+ GLoc.add_localized_strings 'en', {:ja_only => 'bullshit'}, true
+ GLoc.add_localized_strings 'en', {:ja_only => 'bullshit'}, false
+ assert_localized_value nil, nil, :add
+ assert_localized_value nil, '日本語ã®ã¿', :ja_only
+ GLoc.add_localized_strings 'ja', {:ja_only => 'bullshit', :add => '123'}, false
+ assert_localized_value nil, '123', :add
+ assert_localized_value nil, '日本語ã®ã¿', :ja_only
+ GLoc.add_localized_strings 'ja', {:ja_only => 'bullshit', :add => '234'}
+ assert_localized_value nil, '234', :add
+ assert_localized_value nil, 'bullshit', :ja_only
+ end
+
+ def test_class_set_language
+ GLoc.load_localized_strings File.join(File.dirname(__FILE__),'lang')
+
+ @l1 = LClass_ja.new
+ @l2 = LClass_en.new
+ @l3 = LClass_en.new
+
+ assert_localized_value @l1, 'enã«ã‚‚jaã«ã‚‚ã‚ã‚‹', :in_both_langs
+ assert_localized_value @l2, 'This is in en+ja', :in_both_langs
+ assert_localized_value @l3, 'This is in en+ja', :in_both_langs
+
+ @l3.set_language 'en_AU'
+
+ assert_localized_value @l1, 'enã«ã‚‚jaã«ã‚‚ã‚ã‚‹', :in_both_langs
+ assert_localized_value @l2, 'This is in en+ja', :in_both_langs
+ assert_localized_value @l3, "Thiz in en 'n' ja", :in_both_langs
+ end
+
+ def test_ll
+ GLoc.load_localized_strings File.join(File.dirname(__FILE__),'lang')
+
+ assert_equal 'enã«ã‚‚jaã«ã‚‚ã‚ã‚‹', ll('ja',:in_both_langs)
+ assert_equal 'enã«ã‚‚jaã«ã‚‚ã‚ã‚‹', GLoc::ll('ja',:in_both_langs)
+ assert_equal 'enã«ã‚‚jaã«ã‚‚ã‚ã‚‹', LClass_en.ll('ja',:in_both_langs)
+ assert_equal 'enã«ã‚‚jaã«ã‚‚ã‚ã‚‹', LClass_ja.ll('ja',:in_both_langs)
+
+ assert_equal 'This is in en+ja', ll('en',:in_both_langs)
+ assert_equal 'This is in en+ja', GLoc::ll('en',:in_both_langs)
+ assert_equal 'This is in en+ja', LClass_en.ll('en',:in_both_langs)
+ assert_equal 'This is in en+ja', LClass_ja.ll('en',:in_both_langs)
+ end
+
+ def test_lsym
+ GLoc.load_localized_strings File.join(File.dirname(__FILE__),'lang')
+ assert_equal 'enã«ã‚‚jaã«ã‚‚ã‚ã‚‹', LClass_ja.ltry(:in_both_langs)
+ assert_equal 'hello', LClass_ja.ltry('hello')
+ assert_equal nil, LClass_ja.ltry(nil)
+ end
+
+# def test_forced
+# assert_equal :en_AU, LClass_forced_au.current_language
+# a= LClass_forced_au.new
+# a.set_language :ja
+# assert_equal :en_AU, a.current_language
+# a.force_language :ja
+# assert_equal :ja, a.current_language
+# assert_equal :en_AU, LClass_forced_au.current_language
+# end
+
+ def test_pluralization
+ GLoc.add_localized_strings :en, :_gloc_rule_default => %[|n| case n; when 0 then '_none'; when 1 then '_single'; else '_many'; end], :a_single => '%d man', :a_many => '%d men', :a_none => 'No men'
+ GLoc.add_localized_strings :en, :_gloc_rule_asd => %[|n| n<10 ? '_few' : '_heaps'], :a_few => 'a few men (%d)', :a_heaps=> 'soo many men'
+ set_language :en
+
+ assert_equal 'No men', lwr(:a, 0)
+ assert_equal '1 man', lwr(:a, 1)
+ assert_equal '3 men', lwr(:a, 3)
+ assert_equal '20 men', lwr(:a, 20)
+
+ assert_equal 'a few men (0)', lwr_(:asd, :a, 0)
+ assert_equal 'a few men (1)', lwr_(:asd, :a, 1)
+ assert_equal 'a few men (3)', lwr_(:asd, :a, 3)
+ assert_equal 'soo many men', lwr_(:asd, :a, 12)
+ assert_equal 'soo many men', lwr_(:asd, :a, 20)
+
+ end
+
+ def test_distance_in_words
+ load_default_strings
+ [
+ [20.seconds, 'less than a minute', '1分以内', 'меньше минуты'],
+ [80.seconds, '1 minute', '1分', '1 минуту'],
+ [3.seconds, 'less than 5 seconds', '5秒以内', 'менее 5 Ñекунд', true],
+ [9.seconds, 'less than 10 seconds', '10秒以内', 'менее 10 Ñекунд', true],
+ [16.seconds, 'less than 20 seconds', '20秒以内', 'менее 20 Ñекунд', true],
+ [35.seconds, 'half a minute', '約30秒', 'полминуты', true],
+ [50.seconds, 'less than a minute', '1分以内', 'меньше минуты', true],
+ [1.1.minutes, '1 minute', '1分', '1 минуту'],
+ [2.1.minutes, '2 minutes', '2分', '2 минуты'],
+ [4.1.minutes, '4 minutes', '4分', '4 минуты'],
+ [5.1.minutes, '5 minutes', '5分', '5 минут'],
+ [1.1.hours, 'about an hour', 'ç´„1時間', 'около чаÑа'],
+ [3.1.hours, 'about 3 hours', 'ç´„3時間', 'около 3 чаÑов'],
+ [9.1.hours, 'about 9 hours', 'ç´„9時間', 'около 9 чаÑов'],
+ [1.1.days, '1 day', '1日間', '1 день'],
+ [2.1.days, '2 days', '2日間', '2 днÑ'],
+ [4.days, '4 days', '4日間', '4 днÑ'],
+ [6.days, '6 days', '6日間', '6 дней'],
+ [11.days, '11 days', '11日間', '11 дней'],
+ [12.days, '12 days', '12日間', '12 дней'],
+ [15.days, '15 days', '15日間', '15 дней'],
+ [20.days, '20 days', '20日間', '20 дней'],
+ [21.days, '21 days', '21日間', '21 день'],
+ [22.days, '22 days', '22日間', '22 днÑ'],
+ [25.days, '25 days', '25日間', '25 дней'],
+ ].each do |a|
+ t, en, ja, ru = a
+ inc_sec= (a.size == 5) ? a[-1] : false
+ set_language :en
+ assert_equal en, distance_of_time_in_words(t,0,inc_sec)
+ set_language :ja
+ assert_equal ja, distance_of_time_in_words(t,0,inc_sec)
+ set_language :ru
+ assert_equal ru, distance_of_time_in_words(t,0,inc_sec)
+ end
+ end
+
+ def test_age
+ load_default_strings
+ [
+ [1, '1 yr', '1æ³', '1 год'],
+ [22, '22 yrs', '22æ³', '22 года'],
+ [27, '27 yrs', '27æ³', '27 лет'],
+ ].each do |a, en, ja, ru|
+ set_language :en
+ assert_equal en, l_age(a)
+ set_language :ja
+ assert_equal ja, l_age(a)
+ set_language :ru
+ assert_equal ru, l_age(a)
+ end
+ end
+
+ def test_yesno
+ load_default_strings
+ set_language :en
+ assert_equal 'yes', l_yesno(true)
+ assert_equal 'no', l_yesno(false)
+ assert_equal 'Yes', l_YesNo(true)
+ assert_equal 'No', l_YesNo(false)
+ end
+
+ def test_all_languages_have_values_for_helpers
+ load_default_strings
+ t= Time.local(2000, 9, 15, 11, 23, 57)
+ GLoc.valid_languages.each {|l|
+ set_language l
+ 0.upto(120) {|n| l_age(n)}
+ l_date(t)
+ l_datetime(t)
+ l_datetime_short(t)
+ l_time(t)
+ [true,false].each{|v| l_YesNo(v); l_yesno(v) }
+ }
+ end
+
+ def test_similar_languages
+ GLoc.add_localized_strings :en, :a => 'a'
+ GLoc.add_localized_strings :en_AU, :a => 'a'
+ GLoc.add_localized_strings :ja, :a => 'a'
+ GLoc.add_localized_strings :zh_tw, :a => 'a'
+
+ assert_equal :en, GLoc.similar_language(:en)
+ assert_equal :en, GLoc.similar_language('en')
+ assert_equal :ja, GLoc.similar_language(:ja)
+ assert_equal :ja, GLoc.similar_language('ja')
+ # lowercase + dashes to underscores
+ assert_equal :en, GLoc.similar_language('EN')
+ assert_equal :en, GLoc.similar_language(:EN)
+ assert_equal :en_AU, GLoc.similar_language(:EN_Au)
+ assert_equal :en_AU, GLoc.similar_language('eN-Au')
+ # remove dialect
+ assert_equal :ja, GLoc.similar_language(:ja_Au)
+ assert_equal :ja, GLoc.similar_language('JA-ASDF')
+ assert_equal :ja, GLoc.similar_language('jA_ASD_ZXC')
+ # different dialect
+ assert_equal :zh_tw, GLoc.similar_language('ZH')
+ assert_equal :zh_tw, GLoc.similar_language('ZH_HK')
+ assert_equal :zh_tw, GLoc.similar_language('ZH-BUL')
+ # non matching
+ assert_equal nil, GLoc.similar_language('WW')
+ assert_equal nil, GLoc.similar_language('WW_AU')
+ assert_equal nil, GLoc.similar_language('WW-AU')
+ assert_equal nil, GLoc.similar_language('eZ_en')
+ assert_equal nil, GLoc.similar_language('AU-ZH')
+ end
+
+ def test_clear_strings_and_similar_langs
+ GLoc.add_localized_strings :en, :a => 'a'
+ GLoc.add_localized_strings :en_AU, :a => 'a'
+ GLoc.add_localized_strings :ja, :a => 'a'
+ GLoc.add_localized_strings :zh_tw, :a => 'a'
+ GLoc.clear_strings :en, :ja
+ assert_equal nil, GLoc.similar_language('ja')
+ assert_equal :en_AU, GLoc.similar_language('en')
+ assert_equal :zh_tw, GLoc.similar_language('ZH_HK')
+ GLoc.clear_strings
+ assert_equal nil, GLoc.similar_language('ZH_HK')
+ end
+
+ def test_lang_name
+ GLoc.add_localized_strings :en, :general_lang_en => 'English', :general_lang_ja => 'Japanese'
+ GLoc.add_localized_strings :ja, :general_lang_en => '英語', :general_lang_ja => '日本語'
+ set_language :en
+ assert_equal 'Japanese', l_lang_name(:ja)
+ assert_equal 'English', l_lang_name('en')
+ set_language :ja
+ assert_equal '日本語', l_lang_name('ja')
+ assert_equal '英語', l_lang_name(:en)
+ end
+
+ def test_charset_change_all
+ load_default_strings
+ GLoc.add_localized_strings :ja2, :a => 'a'
+ GLoc.valid_languages # Force refresh if in dev mode
+ GLoc.class_eval 'LOCALIZED_STRINGS[:ja2]= LOCALIZED_STRINGS[:ja].clone'
+
+ [:ja, :ja2].each do |l|
+ set_language l
+ assert_equal 'ã¯ã„', l_yesno(true)
+ assert_equal "E381AFE38184", l_yesno(true).unpack('H*')[0].upcase
+ end
+
+ GLoc.set_charset 'sjis'
+ assert_equal 'sjis', GLoc.get_charset(:ja)
+ assert_equal 'sjis', GLoc.get_charset(:ja2)
+
+ [:ja, :ja2].each do |l|
+ set_language l
+ assert_equal "82CD82A2", l_yesno(true).unpack('H*')[0].upcase
+ end
+ end
+
+ def test_charset_change_single
+ load_default_strings
+ GLoc.add_localized_strings :ja2, :a => 'a'
+ GLoc.add_localized_strings :ja3, :a => 'a'
+ GLoc.valid_languages # Force refresh if in dev mode
+ GLoc.class_eval 'LOCALIZED_STRINGS[:ja2]= LOCALIZED_STRINGS[:ja].clone'
+ GLoc.class_eval 'LOCALIZED_STRINGS[:ja3]= LOCALIZED_STRINGS[:ja].clone'
+
+ [:ja, :ja2, :ja3].each do |l|
+ set_language l
+ assert_equal 'ã¯ã„', l_yesno(true)
+ assert_equal "E381AFE38184", l_yesno(true).unpack('H*')[0].upcase
+ end
+
+ GLoc.set_charset 'sjis', :ja
+ assert_equal 'sjis', GLoc.get_charset(:ja)
+ assert_equal 'utf-8', GLoc.get_charset(:ja2)
+ assert_equal 'utf-8', GLoc.get_charset(:ja3)
+
+ set_language :ja
+ assert_equal "82CD82A2", l_yesno(true).unpack('H*')[0].upcase
+ set_language :ja2
+ assert_equal "E381AFE38184", l_yesno(true).unpack('H*')[0].upcase
+ set_language :ja3
+ assert_equal "E381AFE38184", l_yesno(true).unpack('H*')[0].upcase
+
+ GLoc.set_charset 'euc-jp', :ja, :ja3
+ assert_equal 'euc-jp', GLoc.get_charset(:ja)
+ assert_equal 'utf-8', GLoc.get_charset(:ja2)
+ assert_equal 'euc-jp', GLoc.get_charset(:ja3)
+
+ set_language :ja
+ assert_equal "A4CFA4A4", l_yesno(true).unpack('H*')[0].upcase
+ set_language :ja2
+ assert_equal "E381AFE38184", l_yesno(true).unpack('H*')[0].upcase
+ set_language :ja3
+ assert_equal "A4CFA4A4", l_yesno(true).unpack('H*')[0].upcase
+ end
+
+ def test_set_language_if_valid
+ GLoc.add_localized_strings :en, :a => 'a'
+ GLoc.add_localized_strings :zh_tw, :a => 'a'
+
+ assert set_language_if_valid('en')
+ assert_equal :en, current_language
+
+ assert set_language_if_valid('zh_tw')
+ assert_equal :zh_tw, current_language
+
+ assert !set_language_if_valid(nil)
+ assert_equal :zh_tw, current_language
+
+ assert !set_language_if_valid('ja')
+ assert_equal :zh_tw, current_language
+
+ assert set_language_if_valid(:en)
+ assert_equal :en, current_language
+ end
+
+ #===========================================================================
+ protected
+
+ def assert_localized_value(objects,expected,key)
+ objects = [objects] unless objects.kind_of?(Array)
+ objects.each {|object|
+ o = object || GLoc
+ assert_equal !expected.nil?, o.l_has_string?(key)
+ if expected.nil?
+ assert_raise(GLoc::StringNotFoundError) {o.l(key)}
+ else
+ assert_equal expected, o.l(key)
+ end
+ }
+ end
+
+ def load_default_strings
+ GLoc.load_localized_strings File.join(File.dirname(__FILE__),'..','lang')
+ end
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/test/lang/en.yaml b/rest_sys/vendor/plugins/gloc-1.1.0/test/lang/en.yaml
new file mode 100644
index 000000000..325dc599e
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/test/lang/en.yaml
@@ -0,0 +1,2 @@
+in_both_langs: This is in en+ja
+en_only: English only
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/test/lang/en_AU.yaml b/rest_sys/vendor/plugins/gloc-1.1.0/test/lang/en_AU.yaml
new file mode 100644
index 000000000..307cc7859
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/test/lang/en_AU.yaml
@@ -0,0 +1,2 @@
+in_both_langs: Thiz in en 'n' ja
+en_only: Aussie English only bro
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/test/lang/ja.yml b/rest_sys/vendor/plugins/gloc-1.1.0/test/lang/ja.yml
new file mode 100644
index 000000000..64df03376
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/test/lang/ja.yml
@@ -0,0 +1,2 @@
+in_both_langs: enã«ã‚‚jaã«ã‚‚ã‚ã‚‹
+ja_only: 日本語ã®ã¿
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/test/lang2/en.yml b/rest_sys/vendor/plugins/gloc-1.1.0/test/lang2/en.yml
new file mode 100644
index 000000000..e6467e7a0
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/test/lang2/en.yml
@@ -0,0 +1,2 @@
+en_only: overriden dude
+new_en: This is a new English string
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/test/lang2/ja.yaml b/rest_sys/vendor/plugins/gloc-1.1.0/test/lang2/ja.yaml
new file mode 100644
index 000000000..864b287d0
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/test/lang2/ja.yaml
@@ -0,0 +1,2 @@
+in_both_langs: æ›´æ–°ã•れãŸ
+new_ja: æ–°ãŸãªæ—¥æœ¬èªžã‚¹ãƒˆãƒªãƒ³ã‚°
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/test/lib/rails-string_ext.rb b/rest_sys/vendor/plugins/gloc-1.1.0/test/lib/rails-string_ext.rb
new file mode 100644
index 000000000..418d28db2
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/test/lib/rails-string_ext.rb
@@ -0,0 +1,23 @@
+module ActiveSupport #:nodoc:
+ module CoreExtensions #:nodoc:
+ module String #:nodoc:
+ # Additional string tests.
+ module StartsEndsWith
+ # Does the string start with the specified +prefix+?
+ def starts_with?(prefix)
+ prefix = prefix.to_s
+ self[0, prefix.length] == prefix
+ end
+
+ # Does the string end with the specified +suffix+?
+ def ends_with?(suffix)
+ suffix = suffix.to_s
+ self[-suffix.length, suffix.length] == suffix
+ end
+ end
+ end
+ end
+end
+class String
+ include ActiveSupport::CoreExtensions::String::StartsEndsWith
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/gloc-1.1.0/test/lib/rails-time_ext.rb b/rest_sys/vendor/plugins/gloc-1.1.0/test/lib/rails-time_ext.rb
new file mode 100644
index 000000000..d8771e4e6
--- /dev/null
+++ b/rest_sys/vendor/plugins/gloc-1.1.0/test/lib/rails-time_ext.rb
@@ -0,0 +1,76 @@
+module ActiveSupport #:nodoc:
+ module CoreExtensions #:nodoc:
+ module Numeric #:nodoc:
+ # Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.
+ #
+ # If you need precise date calculations that doesn't just treat months as 30 days, then have
+ # a look at Time#advance.
+ #
+ # Some of these methods are approximations, Ruby's core
+ # Date[http://stdlib.rubyonrails.org/libdoc/date/rdoc/index.html] and
+ # Time[http://stdlib.rubyonrails.org/libdoc/time/rdoc/index.html] should be used for precision
+ # date and time arithmetic
+ module Time
+ def seconds
+ self
+ end
+ alias :second :seconds
+
+ def minutes
+ self * 60
+ end
+ alias :minute :minutes
+
+ def hours
+ self * 60.minutes
+ end
+ alias :hour :hours
+
+ def days
+ self * 24.hours
+ end
+ alias :day :days
+
+ def weeks
+ self * 7.days
+ end
+ alias :week :weeks
+
+ def fortnights
+ self * 2.weeks
+ end
+ alias :fortnight :fortnights
+
+ def months
+ self * 30.days
+ end
+ alias :month :months
+
+ def years
+ (self * 365.25.days).to_i
+ end
+ alias :year :years
+
+ # Reads best without arguments: 10.minutes.ago
+ def ago(time = ::Time.now)
+ time - self
+ end
+
+ # Reads best with argument: 10.minutes.until(time)
+ alias :until :ago
+
+ # Reads best with argument: 10.minutes.since(time)
+ def since(time = ::Time.now)
+ time + self
+ end
+
+ # Reads best without arguments: 10.minutes.from_now
+ alias :from_now :since
+ end
+ end
+ end
+end
+
+class Numeric #:nodoc:
+ include ActiveSupport::CoreExtensions::Numeric::Time
+end
diff --git a/rest_sys/vendor/plugins/rfpdf/CHANGELOG b/rest_sys/vendor/plugins/rfpdf/CHANGELOG
new file mode 100644
index 000000000..6822b8364
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/CHANGELOG
@@ -0,0 +1,13 @@
+1.00 Added view template functionality
+1.10 Added Chinese support
+1.11 Added Japanese support
+1.12 Added Korean support
+1.13 Updated to fpdf.rb 1.53d.
+ Added makefont and fpdf_eps.
+ Handle \n at the beginning of a string in MultiCell.
+ Tried to fix clipping issue in MultiCell - still needs some work.
+1.14 2006-09-26
+* Added support for @options_for_rfpdf hash for configuration:
+ * Added :filename option in this hash
+If you're using the same settings for @options_for_rfpdf often, you might want to
+put your assignment in a before_filter (perhaps overriding :filename, etc in your actions).
diff --git a/rest_sys/vendor/plugins/rfpdf/MIT-LICENSE b/rest_sys/vendor/plugins/rfpdf/MIT-LICENSE
new file mode 100644
index 000000000..f39a79dc0
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2006 4ssoM LLC
+
+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 PURPOa AND
+NONINFRINGEMENT. IN NO EVENT SaALL 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.
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/rfpdf/README b/rest_sys/vendor/plugins/rfpdf/README
new file mode 100644
index 000000000..9db19075b
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/README
@@ -0,0 +1,99 @@
+= RFPDF Template Plugin
+
+A template plugin allowing the inclusion of ERB-enabled RFPDF template files.
+
+== Example .rb method Usage
+
+In the controller, something like:
+
+ def mypdf
+ pdf = FPDF.new()
+
+ #
+ # Chinese
+ #
+ pdf.extend(PDF_Chinese)
+ pdf.AddPage
+ pdf.AddBig5Font
+ pdf.SetFont('Big5','',18)
+ pdf.Write(5, '²{®É®ð·Å 18 C Àã«× 83 %')
+ icBig5 = Iconv.new('Big5', 'UTF-8')
+ pdf.Write(15, icBig5.iconv("宋体 should be working"))
+ send_data pdf.Output, :filename => "something.pdf", :type => "application/pdf"
+ end
+
+== Example .rfdf Usage
+
+In the controller, something like:
+
+ def mypdf
+ @options_for_rfpdf ||= {}
+ @options_for_rfpdf[:file_name] = "nice_looking.pdf"
+ end
+
+In the layout (make sure this is the only item in the layout):
+<%= @content_for_layout %>
+
+In the view (mypdf.rfpdf):
+
+<%
+ pdf = FPDF.new()
+ #
+ # Chinese
+ #
+ pdf.extend(PDF_Chinese)
+ pdf.AddPage
+ pdf.AddBig5Font
+ pdf.SetFont('Big5','',18)
+ pdf.Write(5, '²{®É®ð·Å 18 C Àã«× 83 %')
+ icBig5 = Iconv.new('Big5', 'UTF-8')
+ pdf.Write(15, icBig5.iconv("宋体 should be working"))
+
+ #
+ # Japanese
+ #
+ pdf.extend(PDF_Japanese)
+ pdf.AddSJISFont();
+ pdf.AddPage();
+ pdf.SetFont('SJIS','',18);
+ pdf.Write(5,'9ÉñåéÇÃåˆäJÉeÉXÉgÇåoǃPHP 3.0ÇÕ1998îN6åéÇ…åˆéÆÇ…ÉäÉäÅ[ÉXÇ≥ÇÃNjǵÇΩÅB');
+ icSJIS = Iconv.new('SJIS', 'UTF-8')
+ pdf.Write(15, icSJIS.iconv("ã“れã¯ãƒ†ã‚ストã§ã‚ã‚‹ should be working"))
+
+ #
+ # Korean
+ #
+ pdf.extend(PDF_Korean)
+ pdf.AddUHCFont();
+ pdf.AddPage();
+ pdf.SetFont('UHC','',18);
+ pdf.Write(5,'PHP 3.0˼ 1998³â 6¿ù¿¡ °ø½ÄÀûÀ¸·Î ¸±¸®ÃîµÇ¾ú´Ù. °ø°³ÀûÀÎ Å×½ºÆ® ÀÌÈľà 9°³¿ù¸¸À̾ú´Ù.');
+ icUHC = Iconv.new('UHC', 'UTF-8')
+ pdf.Write(15, icUHC.iconv("ì´ê²ƒì€ ì›ë³¸ ì´ë‹¤"))
+
+ #
+ # English
+ #
+ pdf.AddPage();
+ pdf.SetFont('Arial', '', 10)
+ pdf.Write(5, "should be working")
+%>
+<%= pdf.Output() %>
+
+
+== Configuring
+
+You can configure Rfpdf by using an @options_for_rfpdf hash in your controllers.
+
+Here are a few options:
+
+:filename (default: action_name.pdf)
+ Filename of PDF to generate
+
+Note: If you're using the same settings for @options_for_rfpdf often, you might want to
+put your assignment in a before_filter (perhaps overriding :filename, etc in your actions).
+
+== Problems
+
+Layouts and partials are currently not supported; just need
+to wrap the PDF generation differently.
diff --git a/rest_sys/vendor/plugins/rfpdf/init.rb b/rest_sys/vendor/plugins/rfpdf/init.rb
new file mode 100644
index 000000000..7e51d9eba
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/init.rb
@@ -0,0 +1,3 @@
+require 'rfpdf'
+
+ActionView::Base::register_template_handler 'rfpdf', RFPDF::View
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/rfpdf/lib/rfpdf.rb b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf.rb
new file mode 100644
index 000000000..9fc0683ef
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf.rb
@@ -0,0 +1,31 @@
+# Copyright (c) 2006 4ssoM LLC
+#
+# The MIT License
+#
+# 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.
+
+$LOAD_PATH.unshift(File.dirname(__FILE__))
+
+require 'rfpdf/errors'
+require 'rfpdf/view'
+require 'rfpdf/fpdf'
+require 'rfpdf/rfpdf'
+require 'rfpdf/chinese'
+require 'rfpdf/japanese'
+require 'rfpdf/korean'
diff --git a/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/bookmark.rb b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/bookmark.rb
new file mode 100644
index 000000000..a04ccd18d
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/bookmark.rb
@@ -0,0 +1,99 @@
+# Translation of the bookmark class from the PHP FPDF script from Olivier Plathey
+# Translated by Sylvain Lafleur and ?? with the help of Brian Ollenberger
+#
+# First added in 1.53b
+#
+# Usage is as follows:
+#
+# require 'fpdf'
+# require 'bookmark'
+# pdf = FPDF.new
+# pdf.extend(PDF_Bookmark)
+#
+# This allows it to be combined with other extensions, such as the Chinese
+# module.
+
+module PDF_Bookmark
+ def PDF_Bookmark.extend_object(o)
+ o.instance_eval('@outlines,@OutlineRoot=[],0')
+ super(o)
+ end
+
+ def Bookmark(txt,level=0,y=0)
+ y=self.GetY() if y==-1
+ @outlines.push({'t'=>txt,'l'=>level,'y'=>y,'p'=>self.PageNo()})
+ end
+
+ def putbookmarks
+ @nb=@outlines.size
+ return if @nb==0
+ lru=[]
+ level=0
+ @outlines.each_index do |i|
+ o=@outlines[i]
+ if o['l']>0
+ parent=lru[o['l']-1]
+ # Set parent and last pointers
+ @outlines[i]['parent']=parent
+ @outlines[parent]['last']=i
+ if o['l']>level
+ # Level increasing: set first pointer
+ @outlines[parent]['first']=i
+ end
+ else
+ @outlines[i]['parent']=@nb
+ end
+ if o['l']<=level and i>0
+ # Set prev and next pointers
+ prev=lru[o['l']]
+ @outlines[prev]['next']=i
+ @outlines[i]['prev']=prev
+ end
+ lru[o['l']]=i
+ level=o['l']
+ end
+ # Outline items
+ n=@n+1
+ @outlines.each_index do |i|
+ o=@outlines[i]
+ newobj
+ out('<>')
+ out('endobj')
+ end
+ # Outline root
+ newobj
+ @OutlineRoot=@n
+ out('<>')
+ out('endobj')
+ end
+
+ def putresources
+ super
+ putbookmarks
+ end
+
+ def putcatalog
+ super
+ if not @outlines.empty?
+ out('/Outlines '+@OutlineRoot.to_s+' 0 R')
+ out('/PageMode /UseOutlines')
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/chinese.rb b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/chinese.rb
new file mode 100644
index 000000000..6fe3eee8a
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/chinese.rb
@@ -0,0 +1,473 @@
+# Copyright (c) 2006 4ssoM LLC
+# 1.12 contributed by Ed Moss.
+#
+# The MIT License
+#
+# 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.
+#
+# This is direct port of chinese.php
+#
+# Chinese PDF support.
+#
+# Usage is as follows:
+#
+# require 'fpdf'
+# require 'chinese'
+# pdf = FPDF.new
+# pdf.extend(PDF_Chinese)
+#
+# This allows it to be combined with other extensions, such as the bookmark
+# module.
+
+module PDF_Chinese
+
+ Big5_widths={' '=>250,'!'=>250,'"'=>408,'#'=>668,''=>490,'%'=>875,'&'=>698,'\''=>250,
+ '('=>240,')'=>240,'*'=>417,'+'=>667,','=>250,'-'=>313,'.'=>250,'/'=>520,'0'=>500,'1'=>500,
+ '2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>250,''=>250,
+ '<'=>667,'='=>667,'>'=>667,'?'=>396,'@'=>921,'A'=>677,'B'=>615,'C'=>719,'D'=>760,'E'=>625,
+ 'F'=>552,'G'=>771,'H'=>802,'I'=>354,'J'=>354,'K'=>781,'L'=>604,'M'=>927,'N'=>750,'O'=>823,
+ 'P'=>563,'Q'=>823,'R'=>729,'S'=>542,'T'=>698,'U'=>771,'V'=>729,'W'=>948,'X'=>771,'Y'=>677,
+ 'Z'=>635,'['=>344,'\\'=>520,']'=>344,'^'=>469,'_'=>500,'`'=>250,'a'=>469,'b'=>521,'c'=>427,
+ 'd'=>521,'e'=>438,'f'=>271,'g'=>469,'h'=>531,'i'=>250,'j'=>250,'k'=>458,'l'=>240,'m'=>802,
+ 'n'=>531,'o'=>500,'p'=>521,'q'=>521,'r'=>365,'s'=>333,'t'=>292,'u'=>521,'v'=>458,'w'=>677,
+ 'x'=>479,'y'=>458,'z'=>427,'{'=>480,'|'=>496,'end'=>480,'~'=>667}
+
+ GB_widths={' '=>207,'!'=>270,'"'=>342,'#'=>467,''=>462,'%'=>797,'&'=>710,'\''=>239,
+ '('=>374,')'=>374,'*'=>423,'+'=>605,','=>238,'-'=>375,'.'=>238,'/'=>334,'0'=>462,'1'=>462,
+ '2'=>462,'3'=>462,'4'=>462,'5'=>462,'6'=>462,'7'=>462,'8'=>462,'9'=>462,':'=>238,''=>238,
+ '<'=>605,'='=>605,'>'=>605,'?'=>344,'@'=>748,'A'=>684,'B'=>560,'C'=>695,'D'=>739,'E'=>563,
+ 'F'=>511,'G'=>729,'H'=>793,'I'=>318,'J'=>312,'K'=>666,'L'=>526,'M'=>896,'N'=>758,'O'=>772,
+ 'P'=>544,'Q'=>772,'R'=>628,'S'=>465,'T'=>607,'U'=>753,'V'=>711,'W'=>972,'X'=>647,'Y'=>620,
+ 'Z'=>607,'['=>374,'\\'=>333,']'=>374,'^'=>606,'_'=>500,'`'=>239,'a'=>417,'b'=>503,'c'=>427,
+ 'd'=>529,'e'=>415,'f'=>264,'g'=>444,'h'=>518,'i'=>241,'j'=>230,'k'=>495,'l'=>228,'m'=>793,
+ 'n'=>527,'o'=>524,'p'=>524,'q'=>504,'r'=>338,'s'=>336,'t'=>277,'u'=>517,'v'=>450,'w'=>652,
+ 'x'=>466,'y'=>452,'z'=>407,'{'=>370,'|'=>258,'end'=>370,'~'=>605}
+
+ def AddCIDFont(family,style,name,cw,cMap,registry)
+#ActionController::Base::logger.debug registry.to_a.join(":").to_s
+ fontkey=family.downcase+style.upcase
+ unless @fonts[fontkey].nil?
+ Error("Font already added: family style")
+ end
+ i=@fonts.length+1
+ name=name.gsub(' ','')
+ @fonts[fontkey]={'i'=>i,'type'=>'Type0','name'=>name,'up'=>-130,'ut'=>40,'cw'=>cw, 'CMap'=>cMap,'registry'=>registry}
+ end
+
+ def AddCIDFonts(family,name,cw,cMap,registry)
+ AddCIDFont(family,'',name,cw,cMap,registry)
+ AddCIDFont(family,'B',name+',Bold',cw,cMap,registry)
+ AddCIDFont(family,'I',name+',Italic',cw,cMap,registry)
+ AddCIDFont(family,'BI',name+',BoldItalic',cw,cMap,registry)
+ end
+
+ def AddBig5Font(family='Big5',name='MSungStd-Light-Acro')
+ #Add Big5 font with proportional Latin
+ cw=Big5_widths
+ cMap='ETenms-B5-H'
+ registry={'ordering'=>'CNS1','supplement'=>0}
+#ActionController::Base::logger.debug registry.to_a.join(":").to_s
+ AddCIDFonts(family,name,cw,cMap,registry)
+ end
+
+ def AddBig5hwFont(family='Big5-hw',name='MSungStd-Light-Acro')
+ #Add Big5 font with half-witdh Latin
+ cw = {}
+ 32.upto(126) do |i|
+ cw[i.chr]=500
+ end
+ cMap='ETen-B5-H'
+ registry={'ordering'=>'CNS1','supplement'=>0}
+ AddCIDFonts(family,name,cw,cMap,registry)
+ end
+
+ def AddGBFont(family='GB',name='STSongStd-Light-Acro')
+ #Add GB font with proportional Latin
+ cw=GB_widths
+ cMap='GBKp-EUC-H'
+ registry={'ordering'=>'GB1','supplement'=>2}
+ AddCIDFonts(family,name,cw,cMap,registry)
+ end
+
+ def AddGBhwFont(family='GB-hw',name='STSongStd-Light-Acro')
+ #Add GB font with half-width Latin
+ 32.upto(126) do |i|
+ cw[i.chr]=500
+ end
+ cMap='GBK-EUC-H'
+ registry={'ordering'=>'GB1','supplement'=>2}
+ AddCIDFonts(family,name,cw,cMap,registry)
+ end
+
+ def GetStringWidth(s)
+ if(@CurrentFont['type']=='Type0')
+ return GetMBStringWidth(s)
+ else
+ return super(s)
+ end
+ end
+
+ def GetMBStringWidth(s)
+ #Multi-byte version of GetStringWidth()
+ l=0
+ cw=@CurrentFont['cw']
+ nb=s.length
+ i=0
+ while(i0 and s[nb-1]=="\n")
+ nb-=1
+ end
+ b=0
+ if(border)
+ if(border==1)
+ border='LTRB'
+ b='LRT'
+ b2='LR'
+ else
+ b2=''
+ if(border.to_s.index('L'))
+ b2+='L'
+ end
+ if(border.to_s.index('R'))
+ b2+='R'
+ end
+ b=border.to_s.index('T') ? b2+'T' : b2
+ end
+ end
+ sep=-1
+ i=0
+ j=0
+ l=0
+ nl=1
+ while(iwmax)
+ #Automatic line break
+ if(sep==-1 or i==j)
+ if(i==j)
+ i+=ascii ? 1 : 2
+ end
+ Cell(w,h,s[j,i-j],b,2,align,fill)
+ else
+ Cell(w,h,s[j,sep-j],b,2,align,fill)
+ i=(s[sep]==' ') ? sep+1 : sep
+ end
+ sep=-1
+ j=i
+ l=0
+# nl+=1
+ if(border and nl==2)
+ b=b2
+ end
+ else
+ i+=ascii ? 1 : 2
+ end
+ end
+ #Last chunk
+ if(border and not border.to_s.index('B').nil?)
+ b+='B'
+ end
+ Cell(w,h,s[j,i-j],b,2,align,fill)
+ @x=@lMargin
+ end
+
+ def Write(h,txt,link='')
+ if(@CurrentFont['type']=='Type0')
+ MBWrite(h,txt,link)
+ else
+ super(h,txt,link)
+ end
+ end
+
+ def MBWrite(h,txt,link)
+ #Multi-byte version of Write()
+ cw=@CurrentFont['cw']
+ w=@w-@rMargin-@x
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ s=txt.gsub("\r",'')
+ nb=s.length
+ sep=-1
+ i=0
+ j=0
+ l=0
+ nl=1
+ while(iwmax)
+ #Automatic line break
+ if(sep==-1 or i==j)
+ if(@x>@lMargin)
+ #Move to next line
+ @x=@lMargin
+ @y+=h
+ w=@w-@rMargin-@x
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ i+=1
+ nl+=1
+ next
+ end
+ if(i==j)
+ i+=ascii ? 1 : 2
+ end
+ Cell(w,h,s[j,i-j],0,2,'',0,link)
+ else
+ Cell(w,h,s[j,sep-j],0,2,'',0,link)
+ i=(s[sep]==' ') ? sep+1 : sep
+ end
+ sep=-1
+ j=i
+ l=0
+ if(nl==1)
+ @x=@lMargin
+ w=@w-@rMargin-@x
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ end
+ nl+=1
+ else
+ i+=ascii ? 1 : 2
+ end
+ end
+ #Last chunk
+ if(i!=j)
+ Cell(l/1000*@FontSize,h,s[j,i-j],0,0,'',0,link)
+ end
+ end
+
+private
+
+ def putfonts()
+ nf=@n
+ @diffs.each do |diff|
+ #Encodings
+ newobj()
+ out('<>')
+ out('endobj')
+ end
+ # mqr=get_magic_quotes_runtime()
+ # set_magic_quotes_runtime(0)
+ @FontFiles.each_pair do |file, info|
+ #Font file embedding
+ newobj()
+ @FontFiles[file]['n']=@n
+ if(defined('FPDF_FONTPATH'))
+ file=FPDF_FONTPATH+file
+ end
+ size=filesize(file)
+ if(!size)
+ Error('Font file not found')
+ end
+ out('<>')
+ f=fopen(file,'rb')
+ putstream(fread(f,size))
+ fclose(f)
+ out('endobj')
+ end
+#
+ # set_magic_quotes_runtime(mqr)
+#
+ @fonts.each_pair do |k, font|
+ #Font objects
+ newobj()
+ @fonts[k]['n']=@n
+ out('<>')
+ out('endobj')
+ if(font['type']!='core')
+ #Widths
+ newobj()
+ cw=font['cw']
+ s='['
+ 32.upto(255) do |i|
+ s+=cw[i.chr]+' '
+ end
+ out(s+']')
+ out('endobj')
+ #Descriptor
+ newobj()
+ s='<>')
+ out('endobj')
+ end
+ end
+ end
+ end
+
+ def putType0(font)
+ #Type0
+ out('/Subtype /Type0')
+ out('/BaseFont /'+font['name']+'-'+font['CMap'])
+ out('/Encoding /'+font['CMap'])
+ out('/DescendantFonts ['+(@n+1).to_s+' 0 R]')
+ out('>>')
+ out('endobj')
+ #CIDFont
+ newobj()
+ out('<>')
+ out('/FontDescriptor '+(@n+1).to_s+' 0 R')
+ if(font['CMap']=='ETen-B5-H')
+ w='13648 13742 500'
+ elsif(font['CMap']=='GBK-EUC-H')
+ w='814 907 500 7716 [500]'
+ else
+ # ActionController::Base::logger.debug font['cw'].keys.sort.join(' ').to_s
+ # ActionController::Base::logger.debug font['cw'].values.join(' ').to_s
+ w='1 ['
+ font['cw'].keys.sort.each {|key|
+ w+=font['cw'][key].to_s + " "
+# ActionController::Base::logger.debug key.to_s
+# ActionController::Base::logger.debug font['cw'][key].to_s
+ }
+ w +=']'
+ end
+ out('/W ['+w+']>>')
+ out('endobj')
+ #Font descriptor
+ newobj()
+ out('<>')
+ out('endobj')
+ end
+end
diff --git a/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/errors.rb b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/errors.rb
new file mode 100644
index 000000000..2be2dae16
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/errors.rb
@@ -0,0 +1,4 @@
+module RFPDF
+ class GenerationError < StandardError #:nodoc:
+ end
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb
new file mode 100644
index 000000000..ad52e9e62
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/fpdf.rb
@@ -0,0 +1,1550 @@
+# Ruby FPDF 1.53d
+# FPDF 1.53 by Olivier Plathey ported to Ruby by Brian Ollenberger
+# Copyright 2005 Brian Ollenberger
+# Please retain this entire copyright notice. If you distribute any
+# modifications, place an additional comment here that clearly indicates
+# that it was modified. You may (but are not send any useful modifications that you make
+# back to me at http://zeropluszero.com/software/fpdf/
+
+# Bug fixes, examples, external fonts, JPEG support, and upgrade to version
+# 1.53 contributed by Kim Shrier.
+#
+# Bookmark support contributed by Sylvain Lafleur.
+#
+# EPS support contributed by Thiago Jackiw, ported from the PHP version by Valentin Schmidt.
+#
+# Bookmarks contributed by Sylvain Lafleur.
+#
+# 1.53 contributed by Ed Moss
+# Handle '\n' at the beginning of a string
+# Bookmarks contributed by Sylvain Lafleur.
+
+require 'date'
+require 'zlib'
+
+class FPDF
+ FPDF_VERSION = '1.53d'
+
+ Charwidths = {
+ 'courier'=>[600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600],
+
+ 'courierB'=>[600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600],
+
+ 'courierI'=>[600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600],
+
+ 'courierBI'=>[600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600],
+
+ 'helvetica'=>[278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 350, 556, 350, 222, 556, 333, 1000, 556, 556, 333, 1000, 667, 333, 1000, 350, 611, 350, 350, 222, 222, 333, 333, 350, 556, 1000, 333, 1000, 500, 333, 944, 350, 500, 667, 278, 333, 556, 556, 556, 556, 260, 556, 333, 737, 370, 556, 584, 333, 737, 333, 400, 584, 333, 333, 333, 556, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 584, 611, 556, 556, 556, 556, 500, 556, 500],
+
+ 'helveticaB'=>[278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 350, 556, 350, 278, 556, 500, 1000, 556, 556, 333, 1000, 667, 333, 1000, 350, 611, 350, 350, 278, 278, 500, 500, 350, 556, 1000, 333, 1000, 556, 333, 944, 350, 500, 667, 278, 333, 556, 556, 556, 556, 280, 556, 333, 737, 370, 556, 584, 333, 737, 333, 400, 584, 333, 333, 333, 611, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 584, 611, 611, 611, 611, 611, 556, 611, 556],
+
+ 'helveticaI'=>[278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 350, 556, 350, 222, 556, 333, 1000, 556, 556, 333, 1000, 667, 333, 1000, 350, 611, 350, 350, 222, 222, 333, 333, 350, 556, 1000, 333, 1000, 500, 333, 944, 350, 500, 667, 278, 333, 556, 556, 556, 556, 260, 556, 333, 737, 370, 556, 584, 333, 737, 333, 400, 584, 333, 333, 333, 556, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 584, 611, 556, 556, 556, 556, 500, 556, 500],
+
+ 'helveticaBI'=>[278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 350, 556, 350, 278, 556, 500, 1000, 556, 556, 333, 1000, 667, 333, 1000, 350, 611, 350, 350, 278, 278, 500, 500, 350, 556, 1000, 333, 1000, 556, 333, 944, 350, 500, 667, 278, 333, 556, 556, 556, 556, 280, 556, 333, 737, 370, 556, 584, 333, 737, 333, 400, 584, 333, 333, 333, 611, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 584, 611, 611, 611, 611, 611, 556, 611, 556],
+
+ 'times'=>[250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 333, 408, 500, 500, 833, 778, 180, 333, 333, 500, 564, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 278, 278, 564, 564, 564, 444, 921, 722, 667, 667, 722, 611, 556, 722, 722, 333, 389, 722, 611, 889, 722, 722, 556, 722, 667, 556, 611, 722, 722, 944, 722, 722, 611, 333, 278, 333, 469, 500, 333, 444, 500, 444, 500, 444, 333, 500, 500, 278, 278, 500, 278, 778, 500, 500, 500, 500, 333, 389, 278, 500, 500, 722, 500, 500, 444, 480, 200, 480, 541, 350, 500, 350, 333, 500, 444, 1000, 500, 500, 333, 1000, 556, 333, 889, 350, 611, 350, 350, 333, 333, 444, 444, 350, 500, 1000, 333, 980, 389, 333, 722, 350, 444, 722, 250, 333, 500, 500, 500, 500, 200, 500, 333, 760, 276, 500, 564, 333, 760, 333, 400, 564, 300, 300, 333, 500, 453, 250, 333, 300, 310, 500, 750, 750, 750, 444, 722, 722, 722, 722, 722, 722, 889, 667, 611, 611, 611, 611, 333, 333, 333, 333, 722, 722, 722, 722, 722, 722, 722, 564, 722, 722, 722, 722, 722, 722, 556, 500, 444, 444, 444, 444, 444, 444, 667, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 500, 500, 500, 500, 500, 500, 564, 500, 500, 500, 500, 500, 500, 500, 500],
+
+ 'timesB'=>[250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 333, 555, 500, 500, 1000, 833, 278, 333, 333, 500, 570, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 333, 333, 570, 570, 570, 500, 930, 722, 667, 722, 722, 667, 611, 778, 778, 389, 500, 778, 667, 944, 722, 778, 611, 778, 722, 556, 667, 722, 722, 1000, 722, 722, 667, 333, 278, 333, 581, 500, 333, 500, 556, 444, 556, 444, 333, 500, 556, 278, 333, 556, 278, 833, 556, 500, 556, 556, 444, 389, 333, 556, 500, 722, 500, 500, 444, 394, 220, 394, 520, 350, 500, 350, 333, 500, 500, 1000, 500, 500, 333, 1000, 556, 333, 1000, 350, 667, 350, 350, 333, 333, 500, 500, 350, 500, 1000, 333, 1000, 389, 333, 722, 350, 444, 722, 250, 333, 500, 500, 500, 500, 220, 500, 333, 747, 300, 500, 570, 333, 747, 333, 400, 570, 300, 300, 333, 556, 540, 250, 333, 300, 330, 500, 750, 750, 750, 500, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 389, 389, 389, 389, 722, 722, 778, 778, 778, 778, 778, 570, 778, 722, 722, 722, 722, 722, 611, 556, 500, 500, 500, 500, 500, 500, 722, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 556, 500, 500, 500, 500, 500, 570, 500, 556, 556, 556, 556, 500, 556, 500],
+
+ 'timesI'=>[250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 333, 420, 500, 500, 833, 778, 214, 333, 333, 500, 675, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 333, 333, 675, 675, 675, 500, 920, 611, 611, 667, 722, 611, 611, 722, 722, 333, 444, 667, 556, 833, 667, 722, 611, 722, 611, 500, 556, 722, 611, 833, 611, 556, 556, 389, 278, 389, 422, 500, 333, 500, 500, 444, 500, 444, 278, 500, 500, 278, 278, 444, 278, 722, 500, 500, 500, 500, 389, 389, 278, 500, 444, 667, 444, 444, 389, 400, 275, 400, 541, 350, 500, 350, 333, 500, 556, 889, 500, 500, 333, 1000, 500, 333, 944, 350, 556, 350, 350, 333, 333, 556, 556, 350, 500, 889, 333, 980, 389, 333, 667, 350, 389, 556, 250, 389, 500, 500, 500, 500, 275, 500, 333, 760, 276, 500, 675, 333, 760, 333, 400, 675, 300, 300, 333, 500, 523, 250, 333, 300, 310, 500, 750, 750, 750, 500, 611, 611, 611, 611, 611, 611, 889, 667, 611, 611, 611, 611, 333, 333, 333, 333, 722, 667, 722, 722, 722, 722, 722, 675, 722, 722, 722, 722, 722, 556, 611, 500, 500, 500, 500, 500, 500, 500, 667, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 500, 500, 500, 500, 500, 500, 675, 500, 500, 500, 500, 500, 444, 500, 444],
+
+ 'timesBI'=>[250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 389, 555, 500, 500, 833, 778, 278, 333, 333, 500, 570, 250, 333, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 333, 333, 570, 570, 570, 500, 832, 667, 667, 667, 722, 667, 667, 722, 778, 389, 500, 667, 611, 889, 722, 722, 611, 722, 667, 556, 611, 722, 667, 889, 667, 611, 611, 333, 278, 333, 570, 500, 333, 500, 500, 444, 500, 444, 333, 500, 556, 278, 278, 500, 278, 778, 556, 500, 500, 500, 389, 389, 278, 556, 444, 667, 500, 444, 389, 348, 220, 348, 570, 350, 500, 350, 333, 500, 500, 1000, 500, 500, 333, 1000, 556, 333, 944, 350, 611, 350, 350, 333, 333, 500, 500, 350, 500, 1000, 333, 1000, 389, 333, 722, 350, 389, 611, 250, 389, 500, 500, 500, 500, 220, 500, 333, 747, 266, 500, 606, 333, 747, 333, 400, 570, 300, 300, 333, 576, 500, 250, 333, 300, 300, 500, 750, 750, 750, 500, 667, 667, 667, 667, 667, 667, 944, 667, 667, 667, 667, 667, 389, 389, 389, 389, 722, 722, 722, 722, 722, 722, 722, 570, 722, 722, 722, 722, 722, 611, 611, 500, 500, 500, 500, 500, 500, 500, 722, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 556, 500, 500, 500, 500, 500, 570, 500, 556, 556, 556, 556, 444, 500, 444],
+
+ 'symbol'=>[250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 333, 713, 500, 549, 833, 778, 439, 333, 333, 500, 549, 250, 549, 250, 278, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 278, 278, 549, 549, 549, 444, 549, 722, 667, 722, 612, 611, 763, 603, 722, 333, 631, 722, 686, 889, 722, 722, 768, 741, 556, 592, 611, 690, 439, 768, 645, 795, 611, 333, 863, 333, 658, 500, 500, 631, 549, 549, 494, 439, 521, 411, 603, 329, 603, 549, 549, 576, 521, 549, 549, 521, 549, 603, 439, 576, 713, 686, 493, 686, 494, 480, 200, 480, 549, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 750, 620, 247, 549, 167, 713, 500, 753, 753, 753, 753, 1042, 987, 603, 987, 603, 400, 549, 411, 549, 549, 713, 494, 460, 549, 549, 549, 549, 1000, 603, 1000, 658, 823, 686, 795, 987, 768, 768, 823, 768, 768, 713, 713, 713, 713, 713, 713, 713, 768, 713, 790, 790, 890, 823, 549, 250, 713, 603, 603, 1042, 987, 603, 987, 603, 494, 329, 790, 790, 786, 713, 384, 384, 384, 384, 384, 384, 494, 494, 494, 494, 0, 329, 274, 686, 686, 686, 384, 384, 384, 384, 384, 384, 494, 494, 494, 0],
+
+ 'zapfdingbats'=>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 974, 961, 974, 980, 719, 789, 790, 791, 690, 960, 939, 549, 855, 911, 933, 911, 945, 974, 755, 846, 762, 761, 571, 677, 763, 760, 759, 754, 494, 552, 537, 577, 692, 786, 788, 788, 790, 793, 794, 816, 823, 789, 841, 823, 833, 816, 831, 923, 744, 723, 749, 790, 792, 695, 776, 768, 792, 759, 707, 708, 682, 701, 826, 815, 789, 789, 707, 687, 696, 689, 786, 787, 713, 791, 785, 791, 873, 761, 762, 762, 759, 759, 892, 892, 788, 784, 438, 138, 277, 415, 392, 392, 668, 668, 0, 390, 390, 317, 317, 276, 276, 509, 509, 410, 410, 234, 234, 334, 334, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 732, 544, 544, 910, 667, 760, 760, 776, 595, 694, 626, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 894, 838, 1016, 458, 748, 924, 748, 918, 927, 928, 928, 834, 873, 828, 924, 924, 917, 930, 931, 463, 883, 836, 836, 867, 867, 696, 696, 874, 0, 874, 760, 946, 771, 865, 771, 888, 967, 888, 831, 873, 927, 970, 918, 0]
+ }
+
+ def initialize(orientation='P', unit='mm', format='A4')
+ # Initialization of properties
+ @page=0
+ @n=2
+ @buffer=''
+ @pages=[]
+ @OrientationChanges=[]
+ @state=0
+ @fonts={}
+ @FontFiles={}
+ @diffs=[]
+ @images={}
+ @links=[]
+ @PageLinks={}
+ @InFooter=false
+ @FontFamily=''
+ @FontStyle=''
+ @FontSizePt=12
+ @underline= false
+ @DrawColor='0 G'
+ @FillColor='0 g'
+ @TextColor='0 g'
+ @ColorFlag=false
+ @ws=0
+ @offsets=[]
+
+ # Standard fonts
+ @CoreFonts={}
+ @CoreFonts['courier']='Courier'
+ @CoreFonts['courierB']='Courier-Bold'
+ @CoreFonts['courierI']='Courier-Oblique'
+ @CoreFonts['courierBI']='Courier-BoldOblique'
+ @CoreFonts['helvetica']='Helvetica'
+ @CoreFonts['helveticaB']='Helvetica-Bold'
+ @CoreFonts['helveticaI']='Helvetica-Oblique'
+ @CoreFonts['helveticaBI']='Helvetica-BoldOblique'
+ @CoreFonts['times']='Times-Roman'
+ @CoreFonts['timesB']='Times-Bold'
+ @CoreFonts['timesI']='Times-Italic'
+ @CoreFonts['timesBI']='Times-BoldItalic'
+ @CoreFonts['symbol']='Symbol'
+ @CoreFonts['zapfdingbats']='ZapfDingbats'
+
+ # Scale factor
+ if unit=='pt'
+ @k=1
+ elsif unit=='mm'
+ @k=72/25.4
+ elsif unit=='cm'
+ @k=72/2.54;
+ elsif unit=='in'
+ @k=72
+ else
+ raise 'Incorrect unit: '+unit
+ end
+
+ # Page format
+ if format.is_a? String
+ format.downcase!
+ if format=='a3'
+ format=[841.89,1190.55]
+ elsif format=='a4'
+ format=[595.28,841.89]
+ elsif format=='a5'
+ format=[420.94,595.28]
+ elsif format=='letter'
+ format=[612,792]
+ elsif format=='legal'
+ format=[612,1008]
+ else
+ raise 'Unknown page format: '+format
+ end
+ @fwPt,@fhPt=format
+ else
+ @fwPt=format[0]*@k
+ @fhPt=format[1]*@k
+ end
+ @fw=@fwPt/@k;
+ @fh=@fhPt/@k;
+
+ # Page orientation
+ orientation.downcase!
+ if orientation=='p' or orientation=='portrait'
+ @DefOrientation='P'
+ @wPt=@fwPt
+ @hPt=@fhPt
+ elsif orientation=='l' or orientation=='landscape'
+ @DefOrientation='L'
+ @wPt=@fhPt
+ @hPt=@fwPt
+ else
+ raise 'Incorrect orientation: '+orientation
+ end
+ @CurOrientation=@DefOrientation
+ @w=@wPt/@k
+ @h=@hPt/@k
+
+ # Page margins (1 cm)
+ margin=28.35/@k
+ SetMargins(margin,margin)
+ # Interior cell margin (1 mm)
+ @cMargin=margin/10
+ # Line width (0.2 mm)
+ @LineWidth=0.567/@k
+ # Automatic page break
+ SetAutoPageBreak(true,2*margin)
+ # Full width display mode
+ SetDisplayMode('fullwidth')
+ # Enable compression
+ SetCompression(true)
+ # Set default PDF version number
+ @PDFVersion='1.3'
+ end
+
+ def SetMargins(left, top, right=-1)
+ # Set left, top and right margins
+ @lMargin=left
+ @tMargin=top
+ right=left if right==-1
+ @rMargin=right
+ end
+
+ def SetLeftMargin(margin)
+ # Set left margin
+ @lMargin=margin
+ @x=margin if @page>0 and @x0
+ # Page footer
+ @InFooter=true
+ self.Footer
+ @InFooter=false
+ # Close page
+ endpage
+ end
+ # Start new page
+ beginpage(orientation)
+ # Set line cap style to square
+ out('2 J')
+ # Set line width
+ @LineWidth=lw
+ out(sprintf('%.2f w',lw*@k))
+ # Set font
+ SetFont(family,style,size) if family
+ # Set colors
+ @DrawColor=dc
+ out(dc) if dc!='0 G'
+ @FillColor=fc
+ out(fc) if fc!='0 g'
+ @TextColor=tc
+ @ColorFlag=cf
+ # Page header
+ self.Header
+ # Restore line width
+ if @LineWidth!=lw
+ @LineWidth=lw
+ out(sprintf('%.2f w',lw*@k))
+ end
+ # Restore font
+ self.SetFont(family,style,size) if family
+ # Restore colors
+ if @DrawColor!=dc
+ @DrawColor=dc
+ out(dc)
+ end
+ if @FillColor!=fc
+ @FillColor=fc
+ out(fc)
+ end
+ @TextColor=tc
+ @ColorFlag=cf
+ end
+
+ def Header
+ # To be implemented in your inherited class
+ end
+
+ def Footer
+ # To be implemented in your inherited class
+ end
+
+ def PageNo
+ # Get current page number
+ @page
+ end
+
+ def SetDrawColor(r,g=-1,b=-1)
+ # Set color for all stroking operations
+ if (r==0 and g==0 and b==0) or g==-1
+ @DrawColor=sprintf('%.3f G',r/255.0)
+ else
+ @DrawColor=sprintf('%.3f %.3f %.3f RG',r/255.0,g/255.0,b/255.0)
+ end
+ out(@DrawColor) if(@page>0)
+ end
+
+ def SetFillColor(r,g=-1,b=-1)
+ # Set color for all filling operations
+ if (r==0 and g==0 and b==0) or g==-1
+ @FillColor=sprintf('%.3f g',r/255.0)
+ else
+ @FillColor=sprintf('%.3f %.3f %.3f rg',r/255.0,g/255.0,b/255.0)
+ end
+ @ColorFlag=(@FillColor!=@TextColor)
+ out(@FillColor) if(@page>0)
+ end
+
+ def SetTextColor(r,g=-1,b=-1)
+ # Set color for text
+ if (r==0 and g==0 and b==0) or g==-1
+ @TextColor=sprintf('%.3f g',r/255.0)
+ else
+ @TextColor=sprintf('%.3f %.3f %.3f rg',r/255.0,g/255.0,b/255.0)
+ end
+ @ColorFlag=(@FillColor!=@TextColor)
+ end
+
+ def GetStringWidth(s)
+ # Get width of a string in the current font
+ cw=@CurrentFont['cw']
+ w=0
+ s.each_byte do |c|
+ w=w+cw[c]
+ end
+ w*@FontSize/1000.0
+ end
+
+ def SetLineWidth(width)
+ # Set line width
+ @LineWidth=width
+ out(sprintf('%.2f w',width*@k)) if @page>0
+ end
+
+ def Line(x1, y1, x2, y2)
+ # Draw a line
+ out(sprintf('%.2f %.2f m %.2f %.2f l S',
+ x1*@k,(@h-y1)*@k,x2*@k,(@h-y2)*@k))
+ end
+
+ def Rect(x, y, w, h, style='')
+ # Draw a rectangle
+ if style=='F'
+ op='f'
+ elsif style=='FD' or style=='DF'
+ op='B'
+ else
+ op='S'
+ end
+ out(sprintf('%.2f %.2f %.2f %.2f re %s', x*@k,(@h-y)*@k,w*@k,-h*@k,op))
+ end
+
+ def AddFont(family, style='', file='')
+ # Add a TrueType or Type1 font
+ family = family.downcase
+ family = 'helvetica' if family == 'arial'
+
+ style = style.upcase
+ style = 'BI' if style == 'IB'
+
+ fontkey = family + style
+
+ if @fonts.has_key?(fontkey)
+ self.Error("Font already added: #{family} #{style}")
+ end
+
+ file = family.gsub(' ', '') + style.downcase + '.rb' if file == ''
+
+ if self.class.const_defined? 'FPDF_FONTPATH'
+ if FPDF_FONTPATH[-1,1] == '/'
+ file = FPDF_FONTPATH + file
+ else
+ file = FPDF_FONTPATH + '/' + file
+ end
+ end
+
+ # Changed from "require file" to fix bug reported by Hans Allis.
+ load file
+
+ if FontDef.desc.nil?
+ self.Error("Could not include font definition file #{file}")
+ end
+
+ i = @fonts.length + 1
+
+ @fonts[fontkey] = {'i' => i,
+ 'type' => FontDef.type,
+ 'name' => FontDef.name,
+ 'desc' => FontDef.desc,
+ 'up' => FontDef.up,
+ 'ut' => FontDef.ut,
+ 'cw' => FontDef.cw,
+ 'enc' => FontDef.enc,
+ 'file' => FontDef.file
+ }
+
+ if FontDef.diff
+ # Search existing encodings
+ unless @diffs.include?(FontDef.diff)
+ @diffs.push(FontDef.diff)
+ @fonts[fontkey]['diff'] = @diffs.length - 1
+ end
+ end
+
+ if FontDef.file
+ if FontDef.type == 'TrueType'
+ @FontFiles[FontDef.file] = {'length1' => FontDef.originalsize}
+ else
+ @FontFiles[FontDef.file] = {'length1' => FontDef.size1, 'length2' => FontDef.size2}
+ end
+ end
+
+ return self
+ end
+
+ def SetFont(family, style='', size=0)
+ # Select a font; size given in points
+ family.downcase!
+ family=@FontFamily if family==''
+ if family=='arial'
+ family='helvetica'
+ elsif family=='symbol' or family=='zapfdingbats'
+ style=''
+ end
+ style.upcase!
+ unless style.index('U').nil?
+ @underline=true
+ style.gsub!('U','')
+ else
+ @underline=false;
+ end
+ style='BI' if style=='IB'
+ size=@FontSizePt if size==0
+ # Test if font is already selected
+ return if @FontFamily==family and
+ @FontStyle==style and @FontSizePt==size
+ # Test if used for the first time
+ fontkey=family+style
+ unless @fonts.has_key?(fontkey)
+ if @CoreFonts.has_key?(fontkey)
+ unless Charwidths.has_key?(fontkey)
+ raise 'Font unavailable'
+ end
+ @fonts[fontkey]={
+ 'i'=>@fonts.size,
+ 'type'=>'core',
+ 'name'=>@CoreFonts[fontkey],
+ 'up'=>-100,
+ 'ut'=>50,
+ 'cw'=>Charwidths[fontkey]}
+ else
+ raise 'Font unavailable'
+ end
+ end
+
+ #Select it
+ @FontFamily=family
+ @FontStyle=style;
+ @FontSizePt=size
+ @FontSize=size/@k;
+ @CurrentFont=@fonts[fontkey]
+ if @page>0
+ out(sprintf('BT /F%d %.2f Tf ET', @CurrentFont['i'], @FontSizePt))
+ end
+ end
+
+ def SetFontSize(size)
+ # Set font size in points
+ return if @FontSizePt==size
+ @FontSizePt=size
+ @FontSize=size/@k
+ if @page>0
+ out(sprintf('BT /F%d %.2f Tf ET',@CurrentFont['i'],@FontSizePt))
+ end
+ end
+
+ def AddLink
+ # Create a new internal link
+ @links.push([0, 0])
+ @links.size
+ end
+
+ def SetLink(link, y=0, page=-1)
+ # Set destination of internal link
+ y=@y if y==-1
+ page=@page if page==-1
+ @links[link]=[page, y]
+ end
+
+ def Link(x, y, w, h, link)
+ # Put a link on the page
+ @PageLinks[@page]=Array.new unless @PageLinks.has_key?(@Page)
+ @PageLinks[@page].push([x*@k,@hPt-y*@k,w*@k,h*@k,link])
+ end
+
+ def Text(x, y, txt)
+ # Output a string
+ txt.gsub!(')', '\\)')
+ txt.gsub!('(', '\\(')
+ txt.gsub!('\\', '\\\\')
+ s=sprintf('BT %.2f %.2f Td (%s) Tj ET',x*@k,(@h-y)*@k,txt);
+ s=s+' '+dounderline(x,y,txt) if @underline and txt!=''
+ s='q '+@TextColor+' '+s+' Q' if @ColorFlag
+ out(s)
+ end
+
+ def AcceptPageBreak
+ # Accept automatic page break or not
+ @AutoPageBreak
+ end
+
+ def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
+ # Output a cell
+ if @y+h>@PageBreakTrigger and !@InFooter and self.AcceptPageBreak
+ # Automatic page break
+ x=@x
+ ws=@ws
+ if ws>0
+ @ws=0
+ out('0 Tw')
+ end
+ self.AddPage(@CurOrientation)
+ @x=x
+ if ws>0
+ @ws=ws
+ out(sprintf('%.3f Tw',ws*@k))
+ end
+ end
+ w=@w-@rMargin-@x if w==0
+ s=''
+ if fill==1 or border==1
+ if fill==1
+ op=(border==1) ? 'B' : 'f'
+ else
+ op='S'
+ end
+ s=sprintf('%.2f %.2f %.2f %.2f re %s ',@x*@k,(@h-@y)*@k,w*@k,-h*@k,op)
+ end
+ if border.is_a? String
+ x=@x
+ y=@y
+ unless border.index('L').nil?
+ s=s+sprintf('%.2f %.2f m %.2f %.2f l S ',
+ x*@k,(@h-y)*@k,x*@k,(@h-(y+h))*@k)
+ end
+ unless border.index('T').nil?
+ s=s+sprintf('%.2f %.2f m %.2f %.2f l S ',
+ x*@k,(@h-y)*@k,(x+w)*@k,(@h-y)*@k)
+ end
+ unless border.index('R').nil?
+ s=s+sprintf('%.2f %.2f m %.2f %.2f l S ',
+ (x+w)*@k,(@h-y)*@k,(x+w)*@k,(@h-(y+h))*@k)
+ end
+ unless border.index('B').nil?
+ s=s+sprintf('%.2f %.2f m %.2f %.2f l S ',
+ x*@k,(@h-(y+h))*@k,(x+w)*@k,(@h-(y+h))*@k)
+ end
+ end
+ if txt!=''
+ if align=='R'
+ dx=w-@cMargin-self.GetStringWidth(txt)
+ elsif align=='C'
+ dx=(w-self.GetStringWidth(txt))/2
+ else
+ dx=@cMargin
+ end
+ txt = txt.gsub(')', '\\)')
+ txt.gsub!('(', '\\(')
+ txt.gsub!('\\', '\\\\')
+ if @ColorFlag
+ s=s+'q '+@TextColor+' '
+ end
+ s=s+sprintf('BT %.2f %.2f Td (%s) Tj ET',
+ (@x+dx)*@k,(@h-(@y+0.5*h+0.3*@FontSize))*@k,txt)
+ s=s+' '+dounderline(@x+dx,@y+0.5*h+0.3*@FontSize,txt) if @underline
+ s=s+' Q' if @ColorFlag
+ if link and link != ''
+ Link(@x+dx,@y+0.5*h-0.5*@FontSize,GetStringWidth(txt),@FontSize,link)
+ end
+ end
+ out(s) if s
+ @lasth=h
+ if ln>0
+ # Go to next line
+ @y=@y+h
+ @x=@lMargin if ln==1
+ else
+ @x=@x+w
+ end
+ end
+
+ def MultiCell(w,h,txt,border=0,align='J',fill=0)
+ # Output text with automatic or explicit line breaks
+ cw=@CurrentFont['cw']
+ w=@w-@rMargin-@x if w==0
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ s=txt.gsub('\r','')
+ nb=s.length
+ nb=nb-1 if nb>0 and s[nb-1].chr=='\n'
+ b=0
+ if border!=0
+ if border==1
+ border='LTRB'
+ b='LRT'
+ b2='LR'
+ else
+ b2=''
+ b2='L' unless border.index('L').nil?
+ b2=b2+'R' unless border.index('R').nil?
+ b=(not border.index('T').nil?) ? (b2+'T') : b2
+ end
+ end
+ sep=-1
+ i=0
+ j=0
+ l=0
+ ns=0
+ nl=1
+ while i0
+ @ws=0
+ out('0 Tw')
+ end
+#Ed Moss
+# Don't let i go negative
+ end_i = i == 0 ? 0 : i - 1
+ # Changed from s[j..i] to fix bug reported by Hans Allis.
+ self.Cell(w,h,s[j..end_i],b,2,align,fill)
+#
+ i=i+1
+ sep=-1
+ j=i
+ l=0
+ ns=0
+ nl=nl+1
+ b=b2 if border and nl==2
+ else
+ if c==' '
+ sep=i
+ ls=l
+ ns=ns+1
+ end
+ l=l+cw[c[0]]
+ if l>wmax
+ # Automatic line break
+ if sep==-1
+ i=i+1 if i==j
+ if @ws>0
+ @ws=0
+ out('0 Tw')
+ end
+ self.Cell(w,h,s[j..i],b,2,align,fill)
+#Ed Moss
+# Added so that it wouldn't print the last character of the string if it got close
+#FIXME 2006-07-18 Level=0 - but it still puts out an extra new line
+ i += 1
+#
+ else
+ if align=='J'
+ @ws=(ns>1) ? (wmax-ls)/1000.0*@FontSize/(ns-1) : 0
+ out(sprintf('%.3f Tw',@ws*@k))
+ end
+ self.Cell(w,h,s[j..sep],b,2,align,fill)
+ i=sep+1
+ end
+ sep=-1
+ j=i
+ l=0
+ ns=0
+ nl=nl+1
+ b=b2 if border and nl==2
+ else
+ i=i+1
+ end
+ end
+ end
+
+ # Last chunk
+ if @ws>0
+ @ws=0
+ out('0 Tw')
+ end
+ b=b+'B' if border!=0 and not border.index('B').nil?
+ self.Cell(w,h,s[j..i],b,2,align,fill)
+ @x=@lMargin
+ end
+
+ def Write(h,txt,link='')
+ # Output text in flowing mode
+ cw=@CurrentFont['cw']
+ w=@w-@rMargin-@x
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ s=txt.gsub("\r",'')
+ nb=s.length
+ sep=-1
+ i=0
+ j=0
+ l=0
+ nl=1
+ while iwmax
+ # Automatic line break
+ if sep==-1
+ if @x>@lMargin
+ # Move to next line
+ @x=@lMargin
+ @y=@y+h
+ w=@w-@rMargin-@x
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ i=i+1
+ nl=nl+1
+ next
+ end
+ i=i+1 if i==j
+ self.Cell(w,h,s[j,i-j],0,2,'',0,link)
+ else
+ self.Cell(w,h,s[j,sep-j],0,2,'',0,link)
+ i=sep+1
+ end
+ sep=-1
+ j=i
+ l=0
+ if nl==1
+ @x=@lMargin
+ w=@w-@rMargin-@x
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ end
+ nl=nl+1
+ else
+ i=i+1
+ end
+ end
+ # Last chunk
+ self.Cell(l/1000.0*@FontSize,h,s[j,i],0,0,'',0,link) if i!=j
+ end
+
+ def Image(file,x,y,w=0,h=0,type='',link='')
+ # Put an image on the page
+ unless @images.has_key?(file)
+ # First use of image, get info
+ if type==''
+ pos=file.rindex('.')
+ if pos.nil?
+ self.Error('Image file has no extension and no type was '+
+ 'specified: '+file)
+ end
+ type=file[pos+1..-1]
+ end
+ type.downcase!
+ if type=='jpg' or type=='jpeg'
+ info=parsejpg(file)
+ elsif type=='png'
+ info=parsepng(file)
+ else
+ self.Error('Unsupported image file type: '+type)
+ end
+ info['i']=@images.length+1
+ @images[file]=info
+ else
+ info=@images[file]
+ end
+#Ed Moss
+ if(w==0 && h==0)
+ #Put image at 72 dpi
+ w=info['w']/@k;
+ h=info['h']/@k;
+ end
+#
+ # Automatic width or height calculation
+ w=h*info['w']/info['h'] if w==0
+ h=w*info['h']/info['w'] if h==0
+ out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',
+ w*@k,h*@k,x*@k,(@h-(y+h))*@k,info['i']))
+ Link(x,y,w,h,link) if link and link != ''
+ end
+
+ def Ln(h='')
+ # Line feed; default value is last cell height
+ @x=@lMargin
+ if h.kind_of?(String)
+ @y=@y+@lasth
+ else
+ @y=@y+h
+ end
+ end
+
+ def GetX
+ # Get x position
+ @x
+ end
+
+ def SetX(x)
+ # Set x position
+ if x>=0
+ @x=x
+ else
+ @x=@w+x
+ end
+ end
+
+ def GetY
+ # Get y position
+ @y
+ end
+
+ def SetY(y)
+ # Set y position and reset x
+ @x=@lMargin
+ if y>=0
+ @y=y
+ else
+ @y=@h+y
+ end
+ end
+
+ def SetXY(x,y)
+ # Set x and y positions
+ SetY(y)
+ SetX(x)
+ end
+
+ def Output(file=nil)
+ # Output PDF to file or return as a string
+
+ # Finish document if necessary
+ self.Close if(@state<3)
+
+ if file.nil?
+ # Return as a string
+ return @buffer
+ else
+ # Save file locally
+ open(file,'wb') do |f|
+ f.write(@buffer)
+ end
+ end
+ end
+
+ private
+
+ def putpages
+ nb=@page
+ unless @AliasNbPages.nil? or @AliasNbPages==''
+ # Replace number of pages
+ 1.upto(nb) do |n|
+ @pages[n].gsub!(@AliasNbPages,nb.to_s)
+ end
+ end
+ if @DefOrientation=='P'
+ wPt=@fwPt
+ hPt=@fhPt
+ else
+ wPt=@fhPt
+ hPt=@fwPt
+ end
+ filter=(@compress) ? '/Filter /FlateDecode ' : ''
+ 1.upto(nb) do |n|
+ # Page
+ newobj
+ out('<>>>'
+ else
+ l=@links[pl[4]]
+ h=@OrientationChanges[l[0]].nil? ? hPt : wPt
+ annots=annots+sprintf(
+ '/Dest [%d 0 R /XYZ 0 %.2f null]>>',
+ 1+2*l[0],h-l[1]*@k)
+ end
+ end
+ out(annots+']')
+ end
+ out('/Contents '+(@n+1).to_s+' 0 R>>')
+ out('endobj')
+ # Page content
+ p=(@compress) ? Zlib::Deflate.deflate(@pages[n]) : @pages[n]
+ newobj
+ out('<<'+filter+'/Length '+p.length.to_s+'>>')
+ putstream(p)
+ out('endobj')
+ end
+ # Pages root
+ @offsets[1]=@buffer.length
+ out('1 0 obj')
+ out('<>')
+ out('endobj')
+ end
+
+ def putfonts
+ nf=@n
+ @diffs.each do |diff|
+ # Encodings
+ newobj
+ out('<>')
+ out('endobj')
+ end
+
+ @FontFiles.each do |file, info|
+ # Font file embedding
+ newobj
+ @FontFiles[file]['n'] = @n
+
+ if self.class.const_defined? 'FPDF_FONTPATH' then
+ if FPDF_FONTPATH[-1,1] == '/' then
+ file = FPDF_FONTPATH + file
+ else
+ file = FPDF_FONTPATH + '/' + file
+ end
+ end
+
+ size = File.size(file)
+ unless File.exists?(file)
+ Error('Font file not found')
+ end
+
+ out('<>')
+ open(file, 'rb') do |f|
+ putstream(f.read())
+ end
+ out('endobj')
+ end
+
+ file = 0
+ @fonts.each do |k, font|
+ # Font objects
+ @fonts[k]['n']=@n+1
+ type=font['type']
+ name=font['name']
+ if type=='core'
+ # Standard font
+ newobj
+ out('<>')
+ out('endobj')
+ elsif type=='Type1' or type=='TrueType'
+ # Additional Type1 or TrueType font
+ newobj
+ out('<>')
+ out('endobj')
+ # Widths
+ newobj
+ cw=font['cw']
+ s='['
+ 32.upto(255) do |i|
+ s << cw[i].to_s+' '
+ end
+ out(s+']')
+ out('endobj')
+ # Descriptor
+ newobj
+ s='<>')
+ out('endobj')
+ else
+ # Allow for additional types
+ mtd='put'+type.downcase
+ unless self.respond_to?(mtd)
+ self.Error('Unsupported font type: '+type)
+ end
+ self.send(mtd, font)
+ end
+ end
+ end
+
+ def putimages
+ filter=(@compress) ? '/Filter /FlateDecode ' : ''
+ @images.each do |file, info|
+ newobj
+ @images[file]['n']=@n
+ out('<>')
+ putstream(info['data'])
+ @images[file]['data']=nil
+ out('endobj')
+ # Palette
+ if info['cs']=='Indexed'
+ newobj
+ pal=(@compress) ? Zlib::Deflate.deflate(info['pal']) : info['pal']
+ out('<<'+filter+'/Length '+pal.length.to_s+'>>')
+ putstream(pal)
+ out('endobj')
+ end
+ end
+ end
+
+ def putxobjectdict
+ @images.each_value do |image|
+ out('/I'+image['i'].to_s+' '+image['n'].to_s+' 0 R')
+ end
+ end
+
+ def putresourcedict
+ out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]')
+ out('/Font <<')
+ @fonts.each_value do |font|
+ out('/F'+font['i'].to_s+' '+font['n'].to_s+' 0 R')
+ end
+ out('>>')
+ out('/XObject <<')
+ putxobjectdict
+ out('>>')
+ end
+
+ def putresources
+ putfonts
+ putimages
+ # Resource dictionary
+ @offsets[2]=@buffer.length
+ out('2 0 obj')
+ out('<<')
+ putresourcedict
+ out('>>')
+ out('endobj')
+ end
+
+ def putinfo
+ out('/Producer '+textstring('Ruby FPDF '+FPDF_VERSION));
+ unless @title.nil?
+ out('/Title '+textstring(@title))
+ end
+ unless @subject.nil?
+ out('/Subject '+textstring(@subject))
+ end
+ unless @author.nil?
+ out('/Author '+textstring(@author))
+ end
+ unless @keywords.nil?
+ out('/Keywords '+textstring(@keywords))
+ end
+ unless @creator.nil?
+ out('/Creator '+textstring(@creator))
+ end
+ out('/CreationDate '+textstring('D: '+DateTime.now.to_s))
+ end
+
+ def putcatalog
+ out('/Type /Catalog')
+ out('/Pages 1 0 R')
+ if @ZoomMode=='fullpage'
+ out('/OpenAction [3 0 R /Fit]')
+ elsif @ZoomMode=='fullwidth'
+ out('/OpenAction [3 0 R /FitH null]')
+ elsif @ZoomMode=='real'
+ out('/OpenAction [3 0 R /XYZ null null 1]')
+ elsif not @ZoomMode.kind_of?(String)
+ out('/OpenAction [3 0 R /XYZ null null '+(@ZoomMode/100)+']')
+ end
+
+ if @LayoutMode=='single'
+ out('/PageLayout /SinglePage')
+ elsif @LayoutMode=='continuous'
+ out('/PageLayout /OneColumn')
+ elsif @LayoutMode=='two'
+ out('/PageLayout /TwoColumnLeft')
+ end
+ end
+
+ def putheader
+ out('%PDF-'+@PDFVersion)
+ end
+
+ def puttrailer
+ out('/Size '+(@n+1).to_s)
+ out('/Root '+@n.to_s+' 0 R')
+ out('/Info '+(@n-1).to_s+' 0 R')
+ end
+
+ def enddoc
+ putheader
+ putpages
+ putresources
+ # Info
+ newobj
+ out('<<')
+ putinfo
+ out('>>')
+ out('endobj')
+ # Catalog
+ newobj
+ out('<<')
+ putcatalog
+ out('>>')
+ out('endobj')
+ # Cross-ref
+ o=@buffer.length
+ out('xref')
+ out('0 '+(@n+1).to_s)
+ out('0000000000 65535 f ')
+ 1.upto(@n) do |i|
+ out(sprintf('%010d 00000 n ',@offsets[i]))
+ end
+ # Trailer
+ out('trailer')
+ out('<<')
+ puttrailer
+ out('>>')
+ out('startxref')
+ out(o)
+ out('%%EOF')
+ state=3
+ end
+
+ def beginpage(orientation)
+ @page=@page+1
+ @pages[@page]=''
+ @state=2
+ @x=@lMargin
+ @y=@tMargin
+ @lasth=0
+ @FontFamily=''
+ # Page orientation
+ if orientation==''
+ orientation=@DefOrientation
+ else
+ orientation=orientation[0].chr.upcase
+ if orientation!=@DefOrientation
+ @OrientationChanges[@page]=true
+ end
+ end
+ if orientation!=@CurOrientation
+ # Change orientation
+ if orientation=='P'
+ @wPt=@fwPt
+ @hPt=@fhPt
+ @w=@fw
+ @h=@fh
+ else
+ @wPt=@fhPt
+ @hPt=@fwPt
+ @w=@fh
+ @h=@fw
+ end
+ @PageBreakTrigger=@h-@bMargin
+ @CurOrientation=orientation
+ end
+ end
+
+ def endpage
+ # End of page contents
+ @state=1
+ end
+
+ def newobj
+ # Begin a new object
+ @n=@n+1
+ @offsets[@n]=@buffer.length
+ out(@n.to_s+' 0 obj')
+ end
+
+ def dounderline(x,y,txt)
+ # Underline text
+ up=@CurrentFont['up']
+ ut=@CurrentFont['ut']
+ w=GetStringWidth(txt)+@ws*txt.count(' ')
+ sprintf('%.2f %.2f %.2f %.2f re f',
+ x*@k,(@h-(y-up/1000.0*@FontSize))*@k,w*@k,-ut/1000.0*@FontSizePt)
+ end
+
+ def parsejpg(file)
+ # Extract info from a JPEG file
+ a=extractjpginfo(file)
+ raise "Missing or incorrect JPEG file: #{file}" if a.nil?
+
+ if a['channels'].nil? || a['channels']==3 then
+ colspace='DeviceRGB'
+ elsif a['channels']==4 then
+ colspace='DeviceCMYK'
+ else
+ colspace='DeviceGray'
+ end
+ bpc= a['bits'] ? a['bits'].to_i : 8
+
+ # Read whole file
+ data = nil
+ open(file, 'rb') do |f|
+ data = f.read
+ end
+ return {'w'=>a['width'],'h'=>a['height'],'cs'=>colspace,'bpc'=>bpc,'f'=>'DCTDecode','data'=>data}
+ end
+
+ def parsepng(file)
+ # Extract info from a PNG file
+ f=open(file,'rb')
+ # Check signature
+ unless f.read(8)==137.chr+'PNG'+13.chr+10.chr+26.chr+10.chr
+ self.Error('Not a PNG file: '+file)
+ end
+ # Read header chunk
+ f.read(4)
+ if f.read(4)!='IHDR'
+ self.Error('Incorrect PNG file: '+file)
+ end
+ w=freadint(f)
+ h=freadint(f)
+ bpc=f.read(1)[0]
+ if bpc>8
+ self.Error('16-bit depth not supported: '+file)
+ end
+ ct=f.read(1)[0]
+ if ct==0
+ colspace='DeviceGray'
+ elsif ct==2
+ colspace='DeviceRGB'
+ elsif ct==3
+ colspace='Indexed'
+ else
+ self.Error('Alpha channel not supported: '+file)
+ end
+ if f.read(1)[0]!=0
+ self.Error('Unknown compression method: '+file)
+ end
+ if f.read(1)[0]!=0
+ self.Error('Unknown filter method: '+file)
+ end
+ if f.read(1)[0]!=0
+ self.Error('Interlacing not supported: '+file)
+ end
+ f.read(4)
+ parms='/DecodeParms <>'
+ # Scan chunks looking for palette, transparency and image data
+ pal=''
+ trns=''
+ data=''
+ begin
+ n=freadint(f)
+ type=f.read(4)
+ if type=='PLTE'
+ # Read palette
+ pal=f.read(n)
+ f.read(4)
+ elsif type=='tRNS'
+ # Read transparency info
+ t=f.read(n)
+ if ct==0
+ trns=[t[1]]
+ elsif ct==2
+ trns=[t[1],t[3],t[5]]
+ else
+ pos=t.index(0)
+ trns=[pos] unless pos.nil?
+ end
+ f.read(4)
+ elsif type=='IDAT'
+ # Read image data block
+ data << f.read(n)
+ f.read(4)
+ elsif type=='IEND'
+ break
+ else
+ f.read(n+4)
+ end
+ end while n
+ if colspace=='Indexed' and pal==''
+ self.Error('Missing palette in '+file)
+ end
+ f.close
+ {'w'=>w,'h'=>h,'cs'=>colspace,'bpc'=>bpc,'f'=>'FlateDecode',
+ 'parms'=>parms,'pal'=>pal,'trns'=>trns,'data'=>data}
+ end
+
+ def freadint(f)
+ # Read a 4-byte integer from file
+ a = f.read(4).unpack('N')
+ return a[0]
+ end
+
+ def freadshort(f)
+ a = f.read(2).unpack('n')
+ return a[0]
+ end
+
+ def freadbyte(f)
+ a = f.read(1).unpack('C')
+ return a[0]
+ end
+
+ def textstring(s)
+ # Format a text string
+ '('+escape(s)+')'
+ end
+
+ def escape(s)
+ # Add \ before \, ( and )
+ s.gsub('\\','\\\\').gsub('(','\\(').gsub(')','\\)')
+ end
+
+ def putstream(s)
+ out('stream')
+ out(s)
+ out('endstream')
+ end
+
+ def out(s)
+ # Add a line to the document
+ if @state==2
+ @pages[@page]=@pages[@page]+s+"\n"
+ else
+ @buffer=@buffer+s.to_s+"\n"
+ end
+ end
+
+ # jpeg marker codes
+
+ M_SOF0 = 0xc0
+ M_SOF1 = 0xc1
+ M_SOF2 = 0xc2
+ M_SOF3 = 0xc3
+
+ M_SOF5 = 0xc5
+ M_SOF6 = 0xc6
+ M_SOF7 = 0xc7
+
+ M_SOF9 = 0xc9
+ M_SOF10 = 0xca
+ M_SOF11 = 0xcb
+
+ M_SOF13 = 0xcd
+ M_SOF14 = 0xce
+ M_SOF15 = 0xcf
+
+ M_SOI = 0xd8
+ M_EOI = 0xd9
+ M_SOS = 0xda
+
+ def extractjpginfo(file)
+ result = nil
+
+ open(file, "rb") do |f|
+ marker = jpegnextmarker(f)
+
+ if marker != M_SOI
+ return nil
+ end
+
+ while true
+ marker = jpegnextmarker(f)
+
+ case marker
+ when M_SOF0, M_SOF1, M_SOF2, M_SOF3,
+ M_SOF5, M_SOF6, M_SOF7, M_SOF9,
+ M_SOF10, M_SOF11, M_SOF13, M_SOF14,
+ M_SOF15 then
+
+ length = freadshort(f)
+
+ if result.nil?
+ result = {}
+
+ result['bits'] = freadbyte(f)
+ result['height'] = freadshort(f)
+ result['width'] = freadshort(f)
+ result['channels'] = freadbyte(f)
+
+ f.seek(length - 8, IO::SEEK_CUR)
+ else
+ f.seek(length - 2, IO::SEEK_CUR)
+ end
+ when M_SOS, M_EOI then
+ return result
+ else
+ length = freadshort(f)
+ f.seek(length - 2, IO::SEEK_CUR)
+ end
+ end
+ end
+ end
+
+ def jpegnextmarker(f)
+ while true
+ # look for 0xff
+ while (c = freadbyte(f)) != 0xff
+ end
+
+ c = freadbyte(f)
+
+ if c != 0
+ return c
+ end
+ end
+ end
+end
diff --git a/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/fpdf_eps.rb b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/fpdf_eps.rb
new file mode 100644
index 000000000..c6a224310
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/fpdf_eps.rb
@@ -0,0 +1,139 @@
+# Information
+#
+# PDF_EPS class from Valentin Schmidt ported to ruby by Thiago Jackiw (tjackiw@gmail.com)
+# working for Mingle LLC (www.mingle.com)
+# Release Date: July 13th, 2006
+#
+# Description
+#
+# This script allows to embed vector-based Adobe Illustrator (AI) or AI-compatible EPS files.
+# Only vector drawing is supported, not text or bitmap. Although the script was successfully
+# tested with various AI format versions, best results are probably achieved with files that
+# were exported in the AI3 format (tested with Illustrator CS2, Freehand MX and Photoshop CS2).
+#
+# ImageEps(string file, float x, float y [, float w [, float h [, string link [, boolean useBoundingBox]]]])
+#
+# Same parameters as for regular FPDF::Image() method, with an additional one:
+#
+# useBoundingBox: specifies whether to position the bounding box (true) or the complete canvas (false)
+# at location (x,y). Default value is true.
+#
+# First added to the Ruby FPDF distribution in 1.53c
+#
+# Usage is as follows:
+#
+# require 'fpdf'
+# require 'fpdf_eps'
+# pdf = FPDF.new
+# pdf.extend(PDF_EPS)
+# pdf.ImageEps(...)
+#
+# This allows it to be combined with other extensions, such as the bookmark
+# module.
+
+module PDF_EPS
+ def ImageEps(file, x, y, w=0, h=0, link='', use_bounding_box=true)
+ data = nil
+ if File.exists?(file)
+ File.open(file, 'rb') do |f|
+ data = f.read()
+ end
+ else
+ Error('EPS file not found: '+file)
+ end
+
+ # Find BoundingBox param
+ regs = data.scan(/%%BoundingBox: [^\r\n]*/m)
+ regs << regs[0].gsub(/%%BoundingBox: /, '')
+ if regs.size > 1
+ tmp = regs[1].to_s.split(' ')
+ @x1 = tmp[0].to_i
+ @y1 = tmp[1].to_i
+ @x2 = tmp[2].to_i
+ @y2 = tmp[3].to_i
+ else
+ Error('No BoundingBox found in EPS file: '+file)
+ end
+ f_start = data.index('%%EndSetup')
+ f_start = data.index('%%EndProlog') if f_start === false
+ f_start = data.index('%%BoundingBox') if f_start === false
+
+ data = data.slice(f_start, data.length)
+
+ f_end = data.index('%%PageTrailer')
+ f_end = data.index('showpage') if f_end === false
+ data = data.slice(0, f_end) if f_end
+
+ # save the current graphic state
+ out('q')
+
+ k = @k
+
+ # Translate
+ if use_bounding_box
+ dx = x*k-@x1
+ dy = @hPt-@y2-y*k
+ else
+ dx = x*k
+ dy = -y*k
+ end
+ tm = [1,0,0,1,dx,dy]
+ out(sprintf('%.3f %.3f %.3f %.3f %.3f %.3f cm',
+ tm[0], tm[1], tm[2], tm[3], tm[4], tm[5]))
+
+ if w > 0
+ scale_x = w/((@x2-@x1)/k)
+ if h > 0
+ scale_y = h/((@y2-@y1)/k)
+ else
+ scale_y = scale_x
+ h = (@y2-@y1)/k * scale_y
+ end
+ else
+ if h > 0
+ scale_y = $h/((@y2-@y1)/$k)
+ scale_x = scale_y
+ w = (@x2-@x1)/k * scale_x
+ else
+ w = (@x2-@x1)/k
+ h = (@y2-@y1)/k
+ end
+ end
+
+ if !scale_x.nil?
+ # Scale
+ tm = [scale_x,0,0,scale_y,0,@hPt*(1-scale_y)]
+ out(sprintf('%.3f %.3f %.3f %.3f %.3f %.3f cm',
+ tm[0], tm[1], tm[2], tm[3], tm[4], tm[5]))
+ end
+
+ data.split(/\r\n|[\r\n]/).each do |line|
+ next if line == '' || line[0,1] == '%'
+ len = line.length
+ # next if (len > 2 && line[len-2,len] != ' ')
+ cmd = line[len-2,len].strip
+ case cmd
+ when 'm', 'l', 'v', 'y', 'c', 'k', 'K', 'g', 'G', 's', 'S', 'J', 'j', 'w', 'M', 'd':
+ out(line)
+
+ when 'L':
+ line[len-1,len]='l'
+ out(line)
+
+ when 'C':
+ line[len-1,len]='c'
+ out(line)
+
+ when 'f', 'F':
+ out('f*')
+
+ when 'b', 'B':
+ out(cmd + '*')
+ end
+ end
+
+ # restore previous graphic state
+ out('Q')
+ Link(x,y,w,h,link) if link
+ end
+end
diff --git a/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/japanese.rb b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/japanese.rb
new file mode 100644
index 000000000..4e611a6f6
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/japanese.rb
@@ -0,0 +1,468 @@
+# Copyright (c) 2006 4ssoM LLC
+# 1.12 contributed by Ed Moss.
+#
+# The MIT License
+#
+# 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.
+#
+# This is direct port of japanese.php
+#
+# Japanese PDF support.
+#
+# Usage is as follows:
+#
+# require 'fpdf'
+# require 'chinese'
+# pdf = FPDF.new
+# pdf.extend(PDF_Japanese)
+#
+# This allows it to be combined with other extensions, such as the bookmark
+# module.
+
+module PDF_Japanese
+
+ SJIS_widths={' ' => 278, '!' => 299, '"' => 353, '#' => 614, '$' => 614, '%' => 721, '&' => 735, '\'' => 216,
+ '(' => 323, ')' => 323, '*' => 449, '+' => 529, ',' => 219, '-' => 306, '.' => 219, '/' => 453, '0' => 614, '1' => 614,
+ '2' => 614, '3' => 614, '4' => 614, '5' => 614, '6' => 614, '7' => 614, '8' => 614, '9' => 614, ':' => 219, ';' => 219,
+ '<' => 529, '=' => 529, '>' => 529, '?' => 486, '@' => 744, 'A' => 646, 'B' => 604, 'C' => 617, 'D' => 681, 'E' => 567,
+ 'F' => 537, 'G' => 647, 'H' => 738, 'I' => 320, 'J' => 433, 'K' => 637, 'L' => 566, 'M' => 904, 'N' => 710, 'O' => 716,
+ 'P' => 605, 'Q' => 716, 'R' => 623, 'S' => 517, 'T' => 601, 'U' => 690, 'V' => 668, 'W' => 990, 'X' => 681, 'Y' => 634,
+ 'Z' => 578, '[' => 316, '\\' => 614, ']' => 316, '^' => 529, '_' => 500, '`' => 387, 'a' => 509, 'b' => 566, 'c' => 478,
+ 'd' => 565, 'e' => 503, 'f' => 337, 'g' => 549, 'h' => 580, 'i' => 275, 'j' => 266, 'k' => 544, 'l' => 276, 'm' => 854,
+ 'n' => 579, 'o' => 550, 'p' => 578, 'q' => 566, 'r' => 410, 's' => 444, 't' => 340, 'u' => 575, 'v' => 512, 'w' => 760,
+ 'x' => 503, 'y' => 529, 'z' => 453, '{' => 326, '|' => 380, '}' => 326, '~' => 387}
+
+ def AddCIDFont(family,style,name,cw,cMap,registry)
+ fontkey=family.downcase+style.upcase
+ unless @fonts[fontkey].nil?
+ Error("CID font already added: family style")
+ end
+ i=@fonts.length+1
+ @fonts[fontkey]={'i'=>i,'type'=>'Type0','name'=>name,'up'=>-120,'ut'=>40,'cw'=>cw,
+ 'CMap'=>cMap,'registry'=>registry}
+ end
+
+ def AddCIDFonts(family,name,cw,cMap,registry)
+ AddCIDFont(family,'',name,cw,cMap,registry)
+ AddCIDFont(family,'B',name+',Bold',cw,cMap,registry)
+ AddCIDFont(family,'I',name+',Italic',cw,cMap,registry)
+ AddCIDFont(family,'BI',name+',BoldItalic',cw,cMap,registry)
+ end
+
+ def AddSJISFont(family='SJIS')
+ #Add SJIS font with proportional Latin
+ name='KozMinPro-Regular-Acro'
+ cw=SJIS_widths
+ cMap='90msp-RKSJ-H'
+ registry={'ordering'=>'Japan1','supplement'=>2}
+ AddCIDFonts(family,name,cw,cMap,registry)
+ end
+
+ def AddSJIShwFont(family='SJIS-hw')
+ #Add SJIS font with half-width Latin
+ name='KozMinPro-Regular-Acro'
+ 32.upto(126) do |i|
+ cw[i.chr]=500
+ end
+ cMap='90ms-RKSJ-H'
+ registry={'ordering'=>'Japan1','supplement'=>2}
+ AddCIDFonts(family,name,cw,cMap,registry)
+ end
+
+ def GetStringWidth(s)
+ if(@CurrentFont['type']=='Type0')
+ return GetSJISStringWidth(s)
+ else
+ return super(s)
+ end
+ end
+
+ def GetSJISStringWidth(s)
+ #SJIS version of GetStringWidth()
+ l=0
+ cw=@CurrentFont['cw']
+ nb=s.length
+ i=0
+ while(i=161 and o<=223)
+ #Half-width katakana
+ l+=500
+ i+=1
+ else
+ #Full-width character
+ l+=1000
+ i+=2
+ end
+ end
+ return l*@FontSize/1000
+ end
+
+ def MultiCell(w,h,txt,border=0,align='L',fill=0)
+ if(@CurrentFont['type']=='Type0')
+ SJISMultiCell(w,h,txt,border,align,fill)
+ else
+ super(w,h,txt,border,align,fill)
+ end
+ end
+
+ def SJISMultiCell(w,h,txt,border=0,align='L',fill=0)
+ #Output text with automatic or explicit line breaks
+ cw=@CurrentFont['cw']
+ if(w==0)
+ w=@w-@rMargin-@x
+ end
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ s=txt.gsub("\r",'')
+ nb=s.length
+ if(nb>0 and s[nb-1]=="\n")
+ nb-=1
+ end
+ b=0
+ if(border)
+ if(border==1)
+ border='LTRB'
+ b='LRT'
+ b2='LR'
+ else
+ b2=''
+ if(border.to_s.index('L'))
+ b2+='L'
+ end
+ if(border.to_s.index('R'))
+ b2+='R'
+ end
+ b=border.to_s.index('T') ? b2+'T' : b2
+ end
+ end
+ sep=-1
+ i=0
+ j=0
+ l=0
+ nl=1
+ while(i=161 and o<=223)
+ #Half-width katakana
+ l+=500
+ n=1
+ sep=i
+ else
+ #Full-width character
+ l+=1000
+ n=2
+ sep=i
+ end
+ if(l>wmax)
+ #Automatic line break
+ if(sep==-1 or i==j)
+ if(i==j)
+ i+=n
+ end
+ Cell(w,h,s[j,i-j],b,2,align,fill)
+ else
+ Cell(w,h,s[j,sep-j],b,2,align,fill)
+ i=(s[sep]==' ') ? sep+1 : sep
+ end
+ sep=-1
+ j=i
+ l=0
+ nl+=1
+ if(border and nl==2)
+ b=b2
+ end
+ else
+ i+=n
+ if(o>=128)
+ sep=i
+ end
+ end
+ end
+ #Last chunk
+ if(border and not border.to_s.index('B').nil?)
+ b+='B'
+ end
+ Cell(w,h,s[j,i-j],b,2,align,fill)
+ @x=@lMargin
+ end
+
+ def Write(h,txt,link='')
+ if(@CurrentFont['type']=='Type0')
+ SJISWrite(h,txt,link)
+ else
+ super(h,txt,link)
+ end
+ end
+
+ def SJISWrite(h,txt,link)
+ #SJIS version of Write()
+ cw=@CurrentFont['cw']
+ w=@w-@rMargin-@x
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ s=txt.gsub("\r",'')
+ nb=s.length
+ sep=-1
+ i=0
+ j=0
+ l=0
+ nl=1
+ while(i=161 and o<=223)
+ #Half-width katakana
+ l+=500
+ n=1
+ sep=i
+ else
+ #Full-width character
+ l+=1000
+ n=2
+ sep=i
+ end
+ if(l>wmax)
+ #Automatic line break
+ if(sep==-1 or i==j)
+ if(@x>@lMargin)
+ #Move to next line
+ @x=@lMargin
+ @y+=h
+ w=@w-@rMargin-@x
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ i+=n
+ nl+=1
+ next
+ end
+ if(i==j)
+ i+=n
+ end
+ Cell(w,h,s[j,i-j],0,2,'',0,link)
+ else
+ Cell(w,h,s[j,sep-j],0,2,'',0,link)
+ i=(s[sep]==' ') ? sep+1 : sep
+ end
+ sep=-1
+ j=i
+ l=0
+ if(nl==1)
+ @x=@lMargin
+ w=@w-@rMargin-@x
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ end
+ nl+=1
+ else
+ i+=n
+ if(o>=128)
+ sep=i
+ end
+ end
+ end
+ #Last chunk
+ if(i!=j)
+ Cell(l/1000*@FontSize,h,s[j,i-j],0,0,'',0,link)
+ end
+ end
+
+private
+
+ def putfonts()
+ nf=@n
+ @diffs.each do |diff|
+ #Encodings
+ newobj()
+ out('<>')
+ out('endobj')
+ end
+ # mqr=get_magic_quotes_runtime()
+ # set_magic_quotes_runtime(0)
+ @FontFiles.each_pair do |file, info|
+ #Font file embedding
+ newobj()
+ @FontFiles[file]['n']=@n
+ if(defined('FPDF_FONTPATH'))
+ file=FPDF_FONTPATH+file
+ end
+ size=filesize(file)
+ if(!size)
+ Error('Font file not found')
+ end
+ out('<>')
+ f=fopen(file,'rb')
+ putstream(fread(f,size))
+ fclose(f)
+ out('endobj')
+ end
+ # set_magic_quotes_runtime(mqr)
+ @fonts.each_pair do |k, font|
+ #Font objects
+ newobj()
+ @fonts[k]['n']=@n
+ out('<>')
+ out('endobj')
+ if(font['type']!='core')
+ #Widths
+ newobj()
+ cw=font['cw']
+ s='['
+ 32.upto(255) do |i|
+ s+=cw[i.chr]+' '
+ end
+ out(s+']')
+ out('endobj')
+ #Descriptor
+ newobj()
+ s='<>')
+ out('endobj')
+ end
+ end
+ end
+ end
+
+ def putType0(font)
+ #Type0
+ out('/Subtype /Type0')
+ out('/BaseFont /'+font['name']+'-'+font['CMap'])
+ out('/Encoding /'+font['CMap'])
+ out('/DescendantFonts ['+(@n+1).to_s+' 0 R]')
+ out('>>')
+ out('endobj')
+ #CIDFont
+ newobj()
+ out('<>')
+ out('/FontDescriptor '+(@n+1).to_s+' 0 R')
+ w='/W [1 ['
+ font['cw'].keys.sort.each {|key|
+ w+=font['cw'][key].to_s + " "
+# ActionController::Base::logger.debug key.to_s
+# ActionController::Base::logger.debug font['cw'][key].to_s
+ }
+ out(w+'] 231 325 500 631 [500] 326 389 500]')
+ out('>>')
+ out('endobj')
+ #Font descriptor
+ newobj()
+ out('<>')
+ out('endobj')
+ end
+end
diff --git a/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/korean.rb b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/korean.rb
new file mode 100644
index 000000000..64131405e
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/korean.rb
@@ -0,0 +1,436 @@
+# Copyright (c) 2006 4ssoM LLC
+# 1.12 contributed by Ed Moss.
+#
+# The MIT License
+#
+# 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.
+#
+# This is direct port of korean.php
+#
+# Korean PDF support.
+#
+# Usage is as follows:
+#
+# require 'fpdf'
+# require 'chinese'
+# pdf = FPDF.new
+# pdf.extend(PDF_Korean)
+#
+# This allows it to be combined with other extensions, such as the bookmark
+# module.
+
+module PDF_Korean
+
+UHC_widths={' ' => 333, '!' => 416, '"' => 416, '#' => 833, '$' => 625, '%' => 916, '&' => 833, '\'' => 250,
+ '(' => 500, ')' => 500, '*' => 500, '+' => 833, ',' => 291, '-' => 833, '.' => 291, '/' => 375, '0' => 625, '1' => 625,
+ '2' => 625, '3' => 625, '4' => 625, '5' => 625, '6' => 625, '7' => 625, '8' => 625, '9' => 625, ':' => 333, ';' => 333,
+ '<' => 833, '=' => 833, '>' => 916, '?' => 500, '@' => 1000, 'A' => 791, 'B' => 708, 'C' => 708, 'D' => 750, 'E' => 708,
+ 'F' => 666, 'G' => 750, 'H' => 791, 'I' => 375, 'J' => 500, 'K' => 791, 'L' => 666, 'M' => 916, 'N' => 791, 'O' => 750,
+ 'P' => 666, 'Q' => 750, 'R' => 708, 'S' => 666, 'T' => 791, 'U' => 791, 'V' => 750, 'W' => 1000, 'X' => 708, 'Y' => 708,
+ 'Z' => 666, '[' => 500, '\\' => 375, ']' => 500, '^' => 500, '_' => 500, '`' => 333, 'a' => 541, 'b' => 583, 'c' => 541,
+ 'd' => 583, 'e' => 583, 'f' => 375, 'g' => 583, 'h' => 583, 'i' => 291, 'j' => 333, 'k' => 583, 'l' => 291, 'm' => 875,
+ 'n' => 583, 'o' => 583, 'p' => 583, 'q' => 583, 'r' => 458, 's' => 541, 't' => 375, 'u' => 583, 'v' => 583, 'w' => 833,
+ 'x' => 625, 'y' => 625, 'z' => 500, '{' => 583, '|' => 583, '}' => 583, '~' => 750}
+
+ def AddCIDFont(family,style,name,cw,cMap,registry)
+ fontkey=family.downcase+style.upcase
+ unless @fonts[fontkey].nil?
+ Error("Font already added: family style")
+ end
+ i=@fonts.length+1
+ name=name.gsub(' ','')
+ @fonts[fontkey]={'i'=>i,'type'=>'Type0','name'=>name,'up'=>-130,'ut'=>40,'cw'=>cw,
+ 'CMap'=>cMap,'registry'=>registry}
+ end
+
+ def AddCIDFonts(family,name,cw,cMap,registry)
+ AddCIDFont(family,'',name,cw,cMap,registry)
+ AddCIDFont(family,'B',name+',Bold',cw,cMap,registry)
+ AddCIDFont(family,'I',name+',Italic',cw,cMap,registry)
+ AddCIDFont(family,'BI',name+',BoldItalic',cw,cMap,registry)
+ end
+
+ def AddUHCFont(family='UHC',name='HYSMyeongJoStd-Medium-Acro')
+ #Add UHC font with proportional Latin
+ cw=UHC_widths
+ cMap='KSCms-UHC-H'
+ registry={'ordering'=>'Korea1','supplement'=>1}
+ AddCIDFonts(family,name,cw,cMap,registry)
+ end
+
+ def AddUHChwFont(family='UHC-hw',name='HYSMyeongJoStd-Medium-Acro')
+ #Add UHC font with half-witdh Latin
+ 32.upto(126) do |i|
+ cw[i.chr]=500
+ end
+ cMap='KSCms-UHC-HW-H'
+ registry={'ordering'=>'Korea1','supplement'=>1}
+ AddCIDFonts(family,name,cw,cMap,registry)
+ end
+
+ def GetStringWidth(s)
+ if(@CurrentFont['type']=='Type0')
+ return GetMBStringWidth(s)
+ else
+ return super(s)
+ end
+ end
+
+ def GetMBStringWidth(s)
+ #Multi-byte version of GetStringWidth()
+ l=0
+ cw=@CurrentFont['cw']
+ nb=s.length
+ i=0
+ while(i0 and s[nb-1]=="\n")
+ nb-=1
+ end
+ b=0
+ if(border)
+ if(border==1)
+ border='LTRB'
+ b='LRT'
+ b2='LR'
+ else
+ b2=''
+ if(border.index('L').nil?)
+ b2+='L'
+ end
+ if(border.index('R').nil?)
+ b2+='R'
+ end
+ b=border.index('T').nil? ? b2+'T' : b2
+ end
+ end
+ sep=-1
+ i=0
+ j=0
+ l=0
+ nl=1
+ while(iwmax)
+ #Automatic line break
+ if(sep==-1 or i==j)
+ if(i==j)
+ i+=ascii ? 1 : 2
+ end
+ Cell(w,h,s[j,i-j],b,2,align,fill)
+ else
+ Cell(w,h,s[j,sep-j],b,2,align,fill)
+ i=(s[sep]==' ') ? sep+1 : sep
+ end
+ sep=-1
+ j=i
+ l=0
+ nl+=1
+ if(border and nl==2)
+ b=b2
+ end
+ else
+ i+=ascii ? 1 : 2
+ end
+ end
+ #Last chunk
+ if(border and not border.index('B').nil?)
+ b+='B'
+ end
+ Cell(w,h,s[j,i-j],b,2,align,fill)
+ @x=@lMargin
+ end
+
+ def Write(h,txt,link='')
+ if(@CurrentFont['type']=='Type0')
+ MBWrite(h,txt,link)
+ else
+ super(h,txt,link)
+ end
+ end
+
+ def MBWrite(h,txt,link)
+ #Multi-byte version of Write()
+ cw=@CurrentFont['cw']
+ w=@w-@rMargin-@x
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ s=txt.gsub("\r",'')
+ nb=s.length
+ sep=-1
+ i=0
+ j=0
+ l=0
+ nl=1
+ while(iwmax)
+ #Automatic line break
+ if(sep==-1 or i==j)
+ if(@x>@lMargin)
+ #Move to next line
+ @x=@lMargin
+ @y+=h
+ w=@w-@rMargin-@x
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ i+=1
+ nl+=1
+ next
+ end
+ if(i==j)
+ i+=ascii ? 1 : 2
+ end
+ Cell(w,h,s[j,i-j],0,2,'',0,link)
+ else
+ Cell(w,h,s[j,sep-j],0,2,'',0,link)
+ i=(s[sep]==' ') ? sep+1 : sep
+ end
+ sep=-1
+ j=i
+ l=0
+ if(nl==1)
+ @x=@lMargin
+ w=@w-@rMargin-@x
+ wmax=(w-2*@cMargin)*1000/@FontSize
+ end
+ nl+=1
+ else
+ i+=ascii ? 1 : 2
+ end
+ end
+ #Last chunk
+ if(i!=j)
+ Cell(l/1000*@FontSize,h,s[j,i-j],0,0,'',0,link)
+ end
+ end
+
+private
+
+ def putfonts()
+ nf=@n
+ @diffs.each do |diff|
+ #Encodings
+ newobj()
+ out('<>')
+ out('endobj')
+ end
+ # mqr=get_magic_quotes_runtime()
+ # set_magic_quotes_runtime(0)
+ @FontFiles.each_pair do |file, info|
+ #Font file embedding
+ newobj()
+ @FontFiles[file]['n']=@n
+ if(defined('FPDF_FONTPATH'))
+ file=FPDF_FONTPATH+file
+ end
+ size=filesize(file)
+ if(!size)
+ Error('Font file not found')
+ end
+ out('<>')
+ f=fopen(file,'rb')
+ putstream(fread(f,size))
+ fclose(f)
+ out('endobj')
+ end
+ # set_magic_quotes_runtime(mqr)
+ @fonts.each_pair do |k, font|
+ #Font objects
+ newobj()
+ @fonts[k]['n']=@n
+ out('<>')
+ out('endobj')
+ if(font['type']!='core')
+ #Widths
+ newobj()
+ cw=font['cw']
+ s='['
+ 32.upto(255) do |i|
+ s+=cw[i.chr]+' '
+ end
+ out(s+']')
+ out('endobj')
+ #Descriptor
+ newobj()
+ s='<>')
+ out('endobj')
+ end
+ end
+ end
+ end
+
+ def putType0(font)
+ #Type0
+ out('/Subtype /Type0')
+ out('/BaseFont /'+font['name']+'-'+font['CMap'])
+ out('/Encoding /'+font['CMap'])
+ out('/DescendantFonts ['+(@n+1).to_s+' 0 R]')
+ out('>>')
+ out('endobj')
+ #CIDFont
+ newobj()
+ out('<>')
+ out('/FontDescriptor '+(@n+1).to_s+' 0 R')
+ if(font['CMap']=='KSCms-UHC-HW-H')
+ w='8094 8190 500'
+ else
+ w='1 ['
+ font['cw'].keys.sort.each {|key|
+ w+=font['cw'][key].to_s + " "
+ # ActionController::Base::logger.debug key.to_s
+ # ActionController::Base::logger.debug font['cw'][key].to_s
+ }
+ w +=']'
+ end
+ out('/W ['+w+']>>')
+ out('endobj')
+ #Font descriptor
+ newobj()
+ out('<>')
+ out('endobj')
+ end
+end
diff --git a/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/makefont.rb b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/makefont.rb
new file mode 100644
index 000000000..bda7a70ef
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/makefont.rb
@@ -0,0 +1,1787 @@
+#!/usr/bin/env ruby
+#
+# Utility to generate font definition files
+# Version: 1.1
+# Date: 2006-07-19
+#
+# Changelog:
+# Version 1.1 - Brian Ollenberger
+# - Fixed a very small bug in MakeFont for generating FontDef.diff.
+
+Charencodings = {
+# Central Europe
+ 'cp1250' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ 'Euro', '.notdef', 'quotesinglbase', '.notdef',
+ 'quotedblbase', 'ellipsis', 'dagger', 'daggerdbl',
+ '.notdef', 'perthousand', 'Scaron', 'guilsinglleft',
+ 'Sacute', 'Tcaron', 'Zcaron', 'Zacute',
+ '.notdef', 'quoteleft', 'quoteright', 'quotedblleft',
+ 'quotedblright', 'bullet', 'endash', 'emdash',
+ '.notdef', 'trademark', 'scaron', 'guilsinglright',
+ 'sacute', 'tcaron', 'zcaron', 'zacute',
+ 'space', 'caron', 'breve', 'Lslash',
+ 'currency', 'Aogonek', 'brokenbar', 'section',
+ 'dieresis', 'copyright', 'Scedilla', 'guillemotleft',
+ 'logicalnot', 'hyphen', 'registered', 'Zdotaccent',
+ 'degree', 'plusminus', 'ogonek', 'lslash',
+ 'acute', 'mu', 'paragraph', 'periodcentered',
+ 'cedilla', 'aogonek', 'scedilla', 'guillemotright',
+ 'Lcaron', 'hungarumlaut', 'lcaron', 'zdotaccent',
+ 'Racute', 'Aacute', 'Acircumflex', 'Abreve',
+ 'Adieresis', 'Lacute', 'Cacute', 'Ccedilla',
+ 'Ccaron', 'Eacute', 'Eogonek', 'Edieresis',
+ 'Ecaron', 'Iacute', 'Icircumflex', 'Dcaron',
+ 'Dcroat', 'Nacute', 'Ncaron', 'Oacute',
+ 'Ocircumflex', 'Ohungarumlaut', 'Odieresis', 'multiply',
+ 'Rcaron', 'Uring', 'Uacute', 'Uhungarumlaut',
+ 'Udieresis', 'Yacute', 'Tcommaaccent', 'germandbls',
+ 'racute', 'aacute', 'acircumflex', 'abreve',
+ 'adieresis', 'lacute', 'cacute', 'ccedilla',
+ 'ccaron', 'eacute', 'eogonek', 'edieresis',
+ 'ecaron', 'iacute', 'icircumflex', 'dcaron',
+ 'dcroat', 'nacute', 'ncaron', 'oacute',
+ 'ocircumflex', 'ohungarumlaut', 'odieresis', 'divide',
+ 'rcaron', 'uring', 'uacute', 'uhungarumlaut',
+ 'udieresis', 'yacute', 'tcommaaccent', 'dotaccent'
+ ],
+# Cyrillic
+ 'cp1251' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ 'afii10051', 'afii10052', 'quotesinglbase', 'afii10100',
+ 'quotedblbase', 'ellipsis', 'dagger', 'daggerdbl',
+ 'Euro', 'perthousand', 'afii10058', 'guilsinglleft',
+ 'afii10059', 'afii10061', 'afii10060', 'afii10145',
+ 'afii10099', 'quoteleft', 'quoteright', 'quotedblleft',
+ 'quotedblright', 'bullet', 'endash', 'emdash',
+ '.notdef', 'trademark', 'afii10106', 'guilsinglright',
+ 'afii10107', 'afii10109', 'afii10108', 'afii10193',
+ 'space', 'afii10062', 'afii10110', 'afii10057',
+ 'currency', 'afii10050', 'brokenbar', 'section',
+ 'afii10023', 'copyright', 'afii10053', 'guillemotleft',
+ 'logicalnot', 'hyphen', 'registered', 'afii10056',
+ 'degree', 'plusminus', 'afii10055', 'afii10103',
+ 'afii10098', 'mu', 'paragraph', 'periodcentered',
+ 'afii10071', 'afii61352', 'afii10101', 'guillemotright',
+ 'afii10105', 'afii10054', 'afii10102', 'afii10104',
+ 'afii10017', 'afii10018', 'afii10019', 'afii10020',
+ 'afii10021', 'afii10022', 'afii10024', 'afii10025',
+ 'afii10026', 'afii10027', 'afii10028', 'afii10029',
+ 'afii10030', 'afii10031', 'afii10032', 'afii10033',
+ 'afii10034', 'afii10035', 'afii10036', 'afii10037',
+ 'afii10038', 'afii10039', 'afii10040', 'afii10041',
+ 'afii10042', 'afii10043', 'afii10044', 'afii10045',
+ 'afii10046', 'afii10047', 'afii10048', 'afii10049',
+ 'afii10065', 'afii10066', 'afii10067', 'afii10068',
+ 'afii10069', 'afii10070', 'afii10072', 'afii10073',
+ 'afii10074', 'afii10075', 'afii10076', 'afii10077',
+ 'afii10078', 'afii10079', 'afii10080', 'afii10081',
+ 'afii10082', 'afii10083', 'afii10084', 'afii10085',
+ 'afii10086', 'afii10087', 'afii10088', 'afii10089',
+ 'afii10090', 'afii10091', 'afii10092', 'afii10093',
+ 'afii10094', 'afii10095', 'afii10096', 'afii10097'
+ ],
+# Western Europe
+ 'cp1252' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ 'Euro', '.notdef', 'quotesinglbase', 'florin',
+ 'quotedblbase', 'ellipsis', 'dagger', 'daggerdbl',
+ 'circumflex', 'perthousand', 'Scaron', 'guilsinglleft',
+ 'OE', '.notdef', 'Zcaron', '.notdef',
+ '.notdef', 'quoteleft', 'quoteright', 'quotedblleft',
+ 'quotedblright', 'bullet', 'endash', 'emdash',
+ 'tilde', 'trademark', 'scaron', 'guilsinglright',
+ 'oe', '.notdef', 'zcaron', 'Ydieresis',
+ 'space', 'exclamdown', 'cent', 'sterling',
+ 'currency', 'yen', 'brokenbar', 'section',
+ 'dieresis', 'copyright', 'ordfeminine', 'guillemotleft',
+ 'logicalnot', 'hyphen', 'registered', 'macron',
+ 'degree', 'plusminus', 'twosuperior', 'threesuperior',
+ 'acute', 'mu', 'paragraph', 'periodcentered',
+ 'cedilla', 'onesuperior', 'ordmasculine', 'guillemotright',
+ 'onequarter', 'onehalf', 'threequarters', 'questiondown',
+ 'Agrave', 'Aacute', 'Acircumflex', 'Atilde',
+ 'Adieresis', 'Aring', 'AE', 'Ccedilla',
+ 'Egrave', 'Eacute', 'Ecircumflex', 'Edieresis',
+ 'Igrave', 'Iacute', 'Icircumflex', 'Idieresis',
+ 'Eth', 'Ntilde', 'Ograve', 'Oacute',
+ 'Ocircumflex', 'Otilde', 'Odieresis', 'multiply',
+ 'Oslash', 'Ugrave', 'Uacute', 'Ucircumflex',
+ 'Udieresis', 'Yacute', 'Thorn', 'germandbls',
+ 'agrave', 'aacute', 'acircumflex', 'atilde',
+ 'adieresis', 'aring', 'ae', 'ccedilla',
+ 'egrave', 'eacute', 'ecircumflex', 'edieresis',
+ 'igrave', 'iacute', 'icircumflex', 'idieresis',
+ 'eth', 'ntilde', 'ograve', 'oacute',
+ 'ocircumflex', 'otilde', 'odieresis', 'divide',
+ 'oslash', 'ugrave', 'uacute', 'ucircumflex',
+ 'udieresis', 'yacute', 'thorn', 'ydieresis'
+ ],
+# Greek
+ 'cp1253' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ 'Euro', '.notdef', 'quotesinglbase', 'florin',
+ 'quotedblbase', 'ellipsis', 'dagger', 'daggerdbl',
+ '.notdef', 'perthousand', '.notdef', 'guilsinglleft',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', 'quoteleft', 'quoteright', 'quotedblleft',
+ 'quotedblright', 'bullet', 'endash', 'emdash',
+ '.notdef', 'trademark', '.notdef', 'guilsinglright',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'dieresistonos', 'Alphatonos', 'sterling',
+ 'currency', 'yen', 'brokenbar', 'section',
+ 'dieresis', 'copyright', '.notdef', 'guillemotleft',
+ 'logicalnot', 'hyphen', 'registered', 'afii00208',
+ 'degree', 'plusminus', 'twosuperior', 'threesuperior',
+ 'tonos', 'mu', 'paragraph', 'periodcentered',
+ 'Epsilontonos', 'Etatonos', 'Iotatonos', 'guillemotright',
+ 'Omicrontonos', 'onehalf', 'Upsilontonos', 'Omegatonos',
+ 'iotadieresistonos','Alpha', 'Beta', 'Gamma',
+ 'Delta', 'Epsilon', 'Zeta', 'Eta',
+ 'Theta', 'Iota', 'Kappa', 'Lambda',
+ 'Mu', 'Nu', 'Xi', 'Omicron',
+ 'Pi', 'Rho', '.notdef', 'Sigma',
+ 'Tau', 'Upsilon', 'Phi', 'Chi',
+ 'Psi', 'Omega', 'Iotadieresis', 'Upsilondieresis',
+ 'alphatonos', 'epsilontonos', 'etatonos', 'iotatonos',
+ 'upsilondieresistonos','alpha', 'beta', 'gamma',
+ 'delta', 'epsilon', 'zeta', 'eta',
+ 'theta', 'iota', 'kappa', 'lambda',
+ 'mu', 'nu', 'xi', 'omicron',
+ 'pi', 'rho', 'sigma1', 'sigma',
+ 'tau', 'upsilon', 'phi', 'chi',
+ 'psi', 'omega', 'iotadieresis', 'upsilondieresis',
+ 'omicrontonos', 'upsilontonos', 'omegatonos', '.notdef'
+ ],
+# Turkish
+ 'cp1254' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ 'Euro', '.notdef', 'quotesinglbase', 'florin',
+ 'quotedblbase', 'ellipsis', 'dagger', 'daggerdbl',
+ 'circumflex', 'perthousand', 'Scaron', 'guilsinglleft',
+ 'OE', '.notdef', '.notdef', '.notdef',
+ '.notdef', 'quoteleft', 'quoteright', 'quotedblleft',
+ 'quotedblright', 'bullet', 'endash', 'emdash',
+ 'tilde', 'trademark', 'scaron', 'guilsinglright',
+ 'oe', '.notdef', '.notdef', 'Ydieresis',
+ 'space', 'exclamdown', 'cent', 'sterling',
+ 'currency', 'yen', 'brokenbar', 'section',
+ 'dieresis', 'copyright', 'ordfeminine', 'guillemotleft',
+ 'logicalnot', 'hyphen', 'registered', 'macron',
+ 'degree', 'plusminus', 'twosuperior', 'threesuperior',
+ 'acute', 'mu', 'paragraph', 'periodcentered',
+ 'cedilla', 'onesuperior', 'ordmasculine', 'guillemotright',
+ 'onequarter', 'onehalf', 'threequarters', 'questiondown',
+ 'Agrave', 'Aacute', 'Acircumflex', 'Atilde',
+ 'Adieresis', 'Aring', 'AE', 'Ccedilla',
+ 'Egrave', 'Eacute', 'Ecircumflex', 'Edieresis',
+ 'Igrave', 'Iacute', 'Icircumflex', 'Idieresis',
+ 'Gbreve', 'Ntilde', 'Ograve', 'Oacute',
+ 'Ocircumflex', 'Otilde', 'Odieresis', 'multiply',
+ 'Oslash', 'Ugrave', 'Uacute', 'Ucircumflex',
+ 'Udieresis', 'Idotaccent', 'Scedilla', 'germandbls',
+ 'agrave', 'aacute', 'acircumflex', 'atilde',
+ 'adieresis', 'aring', 'ae', 'ccedilla',
+ 'egrave', 'eacute', 'ecircumflex', 'edieresis',
+ 'igrave', 'iacute', 'icircumflex', 'idieresis',
+ 'gbreve', 'ntilde', 'ograve', 'oacute',
+ 'ocircumflex', 'otilde', 'odieresis', 'divide',
+ 'oslash', 'ugrave', 'uacute', 'ucircumflex',
+ 'udieresis', 'dotlessi', 'scedilla', 'ydieresis'
+ ],
+# Hebrew
+ 'cp1255' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ 'Euro', '.notdef', 'quotesinglbase', 'florin',
+ 'quotedblbase', 'ellipsis', 'dagger', 'daggerdbl',
+ 'circumflex', 'perthousand', '.notdef', 'guilsinglleft',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', 'quoteleft', 'quoteright', 'quotedblleft',
+ 'quotedblright', 'bullet', 'endash', 'emdash',
+ 'tilde', 'trademark', '.notdef', 'guilsinglright',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclamdown', 'cent', 'sterling',
+ 'afii57636', 'yen', 'brokenbar', 'section',
+ 'dieresis', 'copyright', 'multiply', 'guillemotleft',
+ 'logicalnot', 'sfthyphen', 'registered', 'macron',
+ 'degree', 'plusminus', 'twosuperior', 'threesuperior',
+ 'acute', 'mu', 'paragraph', 'middot',
+ 'cedilla', 'onesuperior', 'divide', 'guillemotright',
+ 'onequarter', 'onehalf', 'threequarters', 'questiondown',
+ 'afii57799', 'afii57801', 'afii57800', 'afii57802',
+ 'afii57793', 'afii57794', 'afii57795', 'afii57798',
+ 'afii57797', 'afii57806', '.notdef', 'afii57796',
+ 'afii57807', 'afii57839', 'afii57645', 'afii57841',
+ 'afii57842', 'afii57804', 'afii57803', 'afii57658',
+ 'afii57716', 'afii57717', 'afii57718', 'gereshhebrew',
+ 'gershayimhebrew','.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'afii57664', 'afii57665', 'afii57666', 'afii57667',
+ 'afii57668', 'afii57669', 'afii57670', 'afii57671',
+ 'afii57672', 'afii57673', 'afii57674', 'afii57675',
+ 'afii57676', 'afii57677', 'afii57678', 'afii57679',
+ 'afii57680', 'afii57681', 'afii57682', 'afii57683',
+ 'afii57684', 'afii57685', 'afii57686', 'afii57687',
+ 'afii57688', 'afii57689', 'afii57690', '.notdef',
+ '.notdef', 'afii299', 'afii300', '.notdef'
+ ],
+# Baltic
+ 'cp1257' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ 'Euro', '.notdef', 'quotesinglbase', '.notdef',
+ 'quotedblbase', 'ellipsis', 'dagger', 'daggerdbl',
+ '.notdef', 'perthousand', '.notdef', 'guilsinglleft',
+ '.notdef', 'dieresis', 'caron', 'cedilla',
+ '.notdef', 'quoteleft', 'quoteright', 'quotedblleft',
+ 'quotedblright', 'bullet', 'endash', 'emdash',
+ '.notdef', 'trademark', '.notdef', 'guilsinglright',
+ '.notdef', 'macron', 'ogonek', '.notdef',
+ 'space', '.notdef', 'cent', 'sterling',
+ 'currency', '.notdef', 'brokenbar', 'section',
+ 'Oslash', 'copyright', 'Rcommaaccent', 'guillemotleft',
+ 'logicalnot', 'hyphen', 'registered', 'AE',
+ 'degree', 'plusminus', 'twosuperior', 'threesuperior',
+ 'acute', 'mu', 'paragraph', 'periodcentered',
+ 'oslash', 'onesuperior', 'rcommaaccent', 'guillemotright',
+ 'onequarter', 'onehalf', 'threequarters', 'ae',
+ 'Aogonek', 'Iogonek', 'Amacron', 'Cacute',
+ 'Adieresis', 'Aring', 'Eogonek', 'Emacron',
+ 'Ccaron', 'Eacute', 'Zacute', 'Edotaccent',
+ 'Gcommaaccent', 'Kcommaaccent', 'Imacron', 'Lcommaaccent',
+ 'Scaron', 'Nacute', 'Ncommaaccent', 'Oacute',
+ 'Omacron', 'Otilde', 'Odieresis', 'multiply',
+ 'Uogonek', 'Lslash', 'Sacute', 'Umacron',
+ 'Udieresis', 'Zdotaccent', 'Zcaron', 'germandbls',
+ 'aogonek', 'iogonek', 'amacron', 'cacute',
+ 'adieresis', 'aring', 'eogonek', 'emacron',
+ 'ccaron', 'eacute', 'zacute', 'edotaccent',
+ 'gcommaaccent', 'kcommaaccent', 'imacron', 'lcommaaccent',
+ 'scaron', 'nacute', 'ncommaaccent', 'oacute',
+ 'omacron', 'otilde', 'odieresis', 'divide',
+ 'uogonek', 'lslash', 'sacute', 'umacron',
+ 'udieresis', 'zdotaccent', 'zcaron', 'dotaccent'
+ ],
+# Vietnamese
+ 'cp1258' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ 'Euro', '.notdef', 'quotesinglbase', 'florin',
+ 'quotedblbase', 'ellipsis', 'dagger', 'daggerdbl',
+ 'circumflex', 'perthousand', '.notdef', 'guilsinglleft',
+ 'OE', '.notdef', '.notdef', '.notdef',
+ '.notdef', 'quoteleft', 'quoteright', 'quotedblleft',
+ 'quotedblright', 'bullet', 'endash', 'emdash',
+ 'tilde', 'trademark', '.notdef', 'guilsinglright',
+ 'oe', '.notdef', '.notdef', 'Ydieresis',
+ 'space', 'exclamdown', 'cent', 'sterling',
+ 'currency', 'yen', 'brokenbar', 'section',
+ 'dieresis', 'copyright', 'ordfeminine', 'guillemotleft',
+ 'logicalnot', 'hyphen', 'registered', 'macron',
+ 'degree', 'plusminus', 'twosuperior', 'threesuperior',
+ 'acute', 'mu', 'paragraph', 'periodcentered',
+ 'cedilla', 'onesuperior', 'ordmasculine', 'guillemotright',
+ 'onequarter', 'onehalf', 'threequarters', 'questiondown',
+ 'Agrave', 'Aacute', 'Acircumflex', 'Abreve',
+ 'Adieresis', 'Aring', 'AE', 'Ccedilla',
+ 'Egrave', 'Eacute', 'Ecircumflex', 'Edieresis',
+ 'gravecomb', 'Iacute', 'Icircumflex', 'Idieresis',
+ 'Dcroat', 'Ntilde', 'hookabovecomb', 'Oacute',
+ 'Ocircumflex', 'Ohorn', 'Odieresis', 'multiply',
+ 'Oslash', 'Ugrave', 'Uacute', 'Ucircumflex',
+ 'Udieresis', 'Uhorn', 'tildecomb', 'germandbls',
+ 'agrave', 'aacute', 'acircumflex', 'abreve',
+ 'adieresis', 'aring', 'ae', 'ccedilla',
+ 'egrave', 'eacute', 'ecircumflex', 'edieresis',
+ 'acutecomb', 'iacute', 'icircumflex', 'idieresis',
+ 'dcroat', 'ntilde', 'dotbelowcomb', 'oacute',
+ 'ocircumflex', 'ohorn', 'odieresis', 'divide',
+ 'oslash', 'ugrave', 'uacute', 'ucircumflex',
+ 'udieresis', 'uhorn', 'dong', 'ydieresis'
+ ],
+# Thai
+ 'cp874' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ 'Euro', '.notdef', '.notdef', '.notdef',
+ '.notdef', 'ellipsis', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', 'quoteleft', 'quoteright', 'quotedblleft',
+ 'quotedblright', 'bullet', 'endash', 'emdash',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'kokaithai', 'khokhaithai', 'khokhuatthai',
+ 'khokhwaithai', 'khokhonthai', 'khorakhangthai', 'ngonguthai',
+ 'chochanthai', 'chochingthai', 'chochangthai', 'sosothai',
+ 'chochoethai', 'yoyingthai', 'dochadathai', 'topatakthai',
+ 'thothanthai', 'thonangmonthothai', 'thophuthaothai', 'nonenthai',
+ 'dodekthai', 'totaothai', 'thothungthai', 'thothahanthai',
+ 'thothongthai', 'nonuthai', 'bobaimaithai', 'poplathai',
+ 'phophungthai', 'fofathai', 'phophanthai', 'fofanthai',
+ 'phosamphaothai', 'momathai', 'yoyakthai', 'roruathai',
+ 'ruthai', 'lolingthai', 'luthai', 'wowaenthai',
+ 'sosalathai', 'sorusithai', 'sosuathai', 'hohipthai',
+ 'lochulathai', 'oangthai', 'honokhukthai', 'paiyannoithai',
+ 'saraathai', 'maihanakatthai', 'saraaathai', 'saraamthai',
+ 'saraithai', 'saraiithai', 'sarauethai', 'saraueethai',
+ 'sarauthai', 'sarauuthai', 'phinthuthai', '.notdef',
+ '.notdef', '.notdef', '.notdef', 'bahtthai',
+ 'saraethai', 'saraaethai', 'saraothai', 'saraaimaimuanthai',
+ 'saraaimaimalaithai', 'lakkhangyaothai', 'maiyamokthai', 'maitaikhuthai',
+ 'maiekthai', 'maithothai', 'maitrithai', 'maichattawathai',
+ 'thanthakhatthai', 'nikhahitthai', 'yamakkanthai', 'fongmanthai',
+ 'zerothai', 'onethai', 'twothai', 'threethai',
+ 'fourthai', 'fivethai', 'sixthai', 'seventhai',
+ 'eightthai', 'ninethai', 'angkhankhuthai', 'khomutthai',
+ '.notdef', '.notdef', '.notdef', '.notdef'
+ ],
+# Western Europe
+ 'ISO-8859-1' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclamdown', 'cent', 'sterling',
+ 'currency', 'yen', 'brokenbar', 'section',
+ 'dieresis', 'copyright', 'ordfeminine', 'guillemotleft',
+ 'logicalnot', 'hyphen', 'registered', 'macron',
+ 'degree', 'plusminus', 'twosuperior', 'threesuperior',
+ 'acute', 'mu', 'paragraph', 'periodcentered',
+ 'cedilla', 'onesuperior', 'ordmasculine', 'guillemotright',
+ 'onequarter', 'onehalf', 'threequarters', 'questiondown',
+ 'Agrave', 'Aacute', 'Acircumflex', 'Atilde',
+ 'Adieresis', 'Aring', 'AE', 'Ccedilla',
+ 'Egrave', 'Eacute', 'Ecircumflex', 'Edieresis',
+ 'Igrave', 'Iacute', 'Icircumflex', 'Idieresis',
+ 'Eth', 'Ntilde', 'Ograve', 'Oacute',
+ 'Ocircumflex', 'Otilde', 'Odieresis', 'multiply',
+ 'Oslash', 'Ugrave', 'Uacute', 'Ucircumflex',
+ 'Udieresis', 'Yacute', 'Thorn', 'germandbls',
+ 'agrave', 'aacute', 'acircumflex', 'atilde',
+ 'adieresis', 'aring', 'ae', 'ccedilla',
+ 'egrave', 'eacute', 'ecircumflex', 'edieresis',
+ 'igrave', 'iacute', 'icircumflex', 'idieresis',
+ 'eth', 'ntilde', 'ograve', 'oacute',
+ 'ocircumflex', 'otilde', 'odieresis', 'divide',
+ 'oslash', 'ugrave', 'uacute', 'ucircumflex',
+ 'udieresis', 'yacute', 'thorn', 'ydieresis'
+ ],
+# Central Europe
+ 'ISO-8859-2' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'Aogonek', 'breve', 'Lslash',
+ 'currency', 'Lcaron', 'Sacute', 'section',
+ 'dieresis', 'Scaron', 'Scedilla', 'Tcaron',
+ 'Zacute', 'hyphen', 'Zcaron', 'Zdotaccent',
+ 'degree', 'aogonek', 'ogonek', 'lslash',
+ 'acute', 'lcaron', 'sacute', 'caron',
+ 'cedilla', 'scaron', 'scedilla', 'tcaron',
+ 'zacute', 'hungarumlaut', 'zcaron', 'zdotaccent',
+ 'Racute', 'Aacute', 'Acircumflex', 'Abreve',
+ 'Adieresis', 'Lacute', 'Cacute', 'Ccedilla',
+ 'Ccaron', 'Eacute', 'Eogonek', 'Edieresis',
+ 'Ecaron', 'Iacute', 'Icircumflex', 'Dcaron',
+ 'Dcroat', 'Nacute', 'Ncaron', 'Oacute',
+ 'Ocircumflex', 'Ohungarumlaut', 'Odieresis', 'multiply',
+ 'Rcaron', 'Uring', 'Uacute', 'Uhungarumlaut',
+ 'Udieresis', 'Yacute', 'Tcommaaccent', 'germandbls',
+ 'racute', 'aacute', 'acircumflex', 'abreve',
+ 'adieresis', 'lacute', 'cacute', 'ccedilla',
+ 'ccaron', 'eacute', 'eogonek', 'edieresis',
+ 'ecaron', 'iacute', 'icircumflex', 'dcaron',
+ 'dcroat', 'nacute', 'ncaron', 'oacute',
+ 'ocircumflex', 'ohungarumlaut', 'odieresis', 'divide',
+ 'rcaron', 'uring', 'uacute', 'uhungarumlaut',
+ 'udieresis', 'yacute', 'tcommaaccent', 'dotaccent'
+ ],
+# Baltic
+ 'ISO-8859-4' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'Aogonek', 'kgreenlandic', 'Rcommaaccent',
+ 'currency', 'Itilde', 'Lcommaaccent', 'section',
+ 'dieresis', 'Scaron', 'Emacron', 'Gcommaaccent',
+ 'Tbar', 'hyphen', 'Zcaron', 'macron',
+ 'degree', 'aogonek', 'ogonek', 'rcommaaccent',
+ 'acute', 'itilde', 'lcommaaccent', 'caron',
+ 'cedilla', 'scaron', 'emacron', 'gcommaaccent',
+ 'tbar', 'Eng', 'zcaron', 'eng',
+ 'Amacron', 'Aacute', 'Acircumflex', 'Atilde',
+ 'Adieresis', 'Aring', 'AE', 'Iogonek',
+ 'Ccaron', 'Eacute', 'Eogonek', 'Edieresis',
+ 'Edotaccent', 'Iacute', 'Icircumflex', 'Imacron',
+ 'Dcroat', 'Ncommaaccent', 'Omacron', 'Kcommaaccent',
+ 'Ocircumflex', 'Otilde', 'Odieresis', 'multiply',
+ 'Oslash', 'Uogonek', 'Uacute', 'Ucircumflex',
+ 'Udieresis', 'Utilde', 'Umacron', 'germandbls',
+ 'amacron', 'aacute', 'acircumflex', 'atilde',
+ 'adieresis', 'aring', 'ae', 'iogonek',
+ 'ccaron', 'eacute', 'eogonek', 'edieresis',
+ 'edotaccent', 'iacute', 'icircumflex', 'imacron',
+ 'dcroat', 'ncommaaccent', 'omacron', 'kcommaaccent',
+ 'ocircumflex', 'otilde', 'odieresis', 'divide',
+ 'oslash', 'uogonek', 'uacute', 'ucircumflex',
+ 'udieresis', 'utilde', 'umacron', 'dotaccent'
+ ],
+# Cyrillic
+ 'ISO-8859-5' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'afii10023', 'afii10051', 'afii10052',
+ 'afii10053', 'afii10054', 'afii10055', 'afii10056',
+ 'afii10057', 'afii10058', 'afii10059', 'afii10060',
+ 'afii10061', 'hyphen', 'afii10062', 'afii10145',
+ 'afii10017', 'afii10018', 'afii10019', 'afii10020',
+ 'afii10021', 'afii10022', 'afii10024', 'afii10025',
+ 'afii10026', 'afii10027', 'afii10028', 'afii10029',
+ 'afii10030', 'afii10031', 'afii10032', 'afii10033',
+ 'afii10034', 'afii10035', 'afii10036', 'afii10037',
+ 'afii10038', 'afii10039', 'afii10040', 'afii10041',
+ 'afii10042', 'afii10043', 'afii10044', 'afii10045',
+ 'afii10046', 'afii10047', 'afii10048', 'afii10049',
+ 'afii10065', 'afii10066', 'afii10067', 'afii10068',
+ 'afii10069', 'afii10070', 'afii10072', 'afii10073',
+ 'afii10074', 'afii10075', 'afii10076', 'afii10077',
+ 'afii10078', 'afii10079', 'afii10080', 'afii10081',
+ 'afii10082', 'afii10083', 'afii10084', 'afii10085',
+ 'afii10086', 'afii10087', 'afii10088', 'afii10089',
+ 'afii10090', 'afii10091', 'afii10092', 'afii10093',
+ 'afii10094', 'afii10095', 'afii10096', 'afii10097',
+ 'afii61352', 'afii10071', 'afii10099', 'afii10100',
+ 'afii10101', 'afii10102', 'afii10103', 'afii10104',
+ 'afii10105', 'afii10106', 'afii10107', 'afii10108',
+ 'afii10109', 'section', 'afii10110', 'afii10193'
+ ],
+# Greek
+ 'ISO-8859-7' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'quoteleft', 'quoteright', 'sterling',
+ '.notdef', '.notdef', 'brokenbar', 'section',
+ 'dieresis', 'copyright', '.notdef', 'guillemotleft',
+ 'logicalnot', 'hyphen', '.notdef', 'afii00208',
+ 'degree', 'plusminus', 'twosuperior', 'threesuperior',
+ 'tonos', 'dieresistonos', 'Alphatonos', 'periodcentered',
+ 'Epsilontonos', 'Etatonos', 'Iotatonos', 'guillemotright',
+ 'Omicrontonos', 'onehalf', 'Upsilontonos', 'Omegatonos',
+ 'iotadieresistonos','Alpha', 'Beta', 'Gamma',
+ 'Delta', 'Epsilon', 'Zeta', 'Eta',
+ 'Theta', 'Iota', 'Kappa', 'Lambda',
+ 'Mu', 'Nu', 'Xi', 'Omicron',
+ 'Pi', 'Rho', '.notdef', 'Sigma',
+ 'Tau', 'Upsilon', 'Phi', 'Chi',
+ 'Psi', 'Omega', 'Iotadieresis', 'Upsilondieresis',
+ 'alphatonos', 'epsilontonos', 'etatonos', 'iotatonos',
+ 'upsilondieresistonos','alpha', 'beta', 'gamma',
+ 'delta', 'epsilon', 'zeta', 'eta',
+ 'theta', 'iota', 'kappa', 'lambda',
+ 'mu', 'nu', 'xi', 'omicron',
+ 'pi', 'rho', 'sigma1', 'sigma',
+ 'tau', 'upsilon', 'phi', 'chi',
+ 'psi', 'omega', 'iotadieresis', 'upsilondieresis',
+ 'omicrontonos', 'upsilontonos', 'omegatonos', '.notdef'
+ ],
+# Turkish
+ 'ISO-8859-9' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclamdown', 'cent', 'sterling',
+ 'currency', 'yen', 'brokenbar', 'section',
+ 'dieresis', 'copyright', 'ordfeminine', 'guillemotleft',
+ 'logicalnot', 'hyphen', 'registered', 'macron',
+ 'degree', 'plusminus', 'twosuperior', 'threesuperior',
+ 'acute', 'mu', 'paragraph', 'periodcentered',
+ 'cedilla', 'onesuperior', 'ordmasculine', 'guillemotright',
+ 'onequarter', 'onehalf', 'threequarters', 'questiondown',
+ 'Agrave', 'Aacute', 'Acircumflex', 'Atilde',
+ 'Adieresis', 'Aring', 'AE', 'Ccedilla',
+ 'Egrave', 'Eacute', 'Ecircumflex', 'Edieresis',
+ 'Igrave', 'Iacute', 'Icircumflex', 'Idieresis',
+ 'Gbreve', 'Ntilde', 'Ograve', 'Oacute',
+ 'Ocircumflex', 'Otilde', 'Odieresis', 'multiply',
+ 'Oslash', 'Ugrave', 'Uacute', 'Ucircumflex',
+ 'Udieresis', 'Idotaccent', 'Scedilla', 'germandbls',
+ 'agrave', 'aacute', 'acircumflex', 'atilde',
+ 'adieresis', 'aring', 'ae', 'ccedilla',
+ 'egrave', 'eacute', 'ecircumflex', 'edieresis',
+ 'igrave', 'iacute', 'icircumflex', 'idieresis',
+ 'gbreve', 'ntilde', 'ograve', 'oacute',
+ 'ocircumflex', 'otilde', 'odieresis', 'divide',
+ 'oslash', 'ugrave', 'uacute', 'ucircumflex',
+ 'udieresis', 'dotlessi', 'scedilla', 'ydieresis'
+ ],
+# Thai
+ 'ISO-8859-11' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'kokaithai', 'khokhaithai', 'khokhuatthai',
+ 'khokhwaithai', 'khokhonthai', 'khorakhangthai', 'ngonguthai',
+ 'chochanthai', 'chochingthai', 'chochangthai', 'sosothai',
+ 'chochoethai', 'yoyingthai', 'dochadathai', 'topatakthai',
+ 'thothanthai', 'thonangmonthothai','thophuthaothai', 'nonenthai',
+ 'dodekthai', 'totaothai', 'thothungthai', 'thothahanthai',
+ 'thothongthai', 'nonuthai', 'bobaimaithai', 'poplathai',
+ 'phophungthai', 'fofathai', 'phophanthai', 'fofanthai',
+ 'phosamphaothai', 'momathai', 'yoyakthai', 'roruathai',
+ 'ruthai', 'lolingthai', 'luthai', 'wowaenthai',
+ 'sosalathai', 'sorusithai', 'sosuathai', 'hohipthai',
+ 'lochulathai', 'oangthai', 'honokhukthai', 'paiyannoithai',
+ 'saraathai', 'maihanakatthai', 'saraaathai', 'saraamthai',
+ 'saraithai', 'saraiithai', 'sarauethai', 'saraueethai',
+ 'sarauthai', 'sarauuthai', 'phinthuthai', '.notdef',
+ '.notdef', '.notdef', '.notdef', 'bahtthai',
+ 'saraethai', 'saraaethai', 'saraothai', 'saraaimaimuanthai',
+ 'saraaimaimalaithai','lakkhangyaothai','maiyamokthai', 'maitaikhuthai',
+ 'maiekthai', 'maithothai', 'maitrithai', 'maichattawathai',
+ 'thanthakhatthai','nikhahitthai', 'yamakkanthai', 'fongmanthai',
+ 'zerothai', 'onethai', 'twothai', 'threethai',
+ 'fourthai', 'fivethai', 'sixthai', 'seventhai',
+ 'eightthai', 'ninethai', 'angkhankhuthai', 'khomutthai',
+ '.notdef', '.notdef', '.notdef', '.notdef'
+ ],
+# Western Europe
+ 'ISO-8859-15' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclamdown', 'cent', 'sterling',
+ 'Euro', 'yen', 'Scaron', 'section',
+ 'scaron', 'copyright', 'ordfeminine', 'guillemotleft',
+ 'logicalnot', 'hyphen', 'registered', 'macron',
+ 'degree', 'plusminus', 'twosuperior', 'threesuperior',
+ 'Zcaron', 'mu', 'paragraph', 'periodcentered',
+ 'zcaron', 'onesuperior', 'ordmasculine', 'guillemotright',
+ 'OE', 'oe', 'Ydieresis', 'questiondown',
+ 'Agrave', 'Aacute', 'Acircumflex', 'Atilde',
+ 'Adieresis', 'Aring', 'AE', 'Ccedilla',
+ 'Egrave', 'Eacute', 'Ecircumflex', 'Edieresis',
+ 'Igrave', 'Iacute', 'Icircumflex', 'Idieresis',
+ 'Eth', 'Ntilde', 'Ograve', 'Oacute',
+ 'Ocircumflex', 'Otilde', 'Odieresis', 'multiply',
+ 'Oslash', 'Ugrave', 'Uacute', 'Ucircumflex',
+ 'Udieresis', 'Yacute', 'Thorn', 'germandbls',
+ 'agrave', 'aacute', 'acircumflex', 'atilde',
+ 'adieresis', 'aring', 'ae', 'ccedilla',
+ 'egrave', 'eacute', 'ecircumflex', 'edieresis',
+ 'igrave', 'iacute', 'icircumflex', 'idieresis',
+ 'eth', 'ntilde', 'ograve', 'oacute',
+ 'ocircumflex', 'otilde', 'odieresis', 'divide',
+ 'oslash', 'ugrave', 'uacute', 'ucircumflex',
+ 'udieresis', 'yacute', 'thorn', 'ydieresis'
+ ],
+# Central Europe
+ 'ISO-8859-16' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'Aogonek', 'aogonek', 'Lslash',
+ 'Euro', 'quotedblbase', 'Scaron', 'section',
+ 'scaron', 'copyright', 'Scommaaccent', 'guillemotleft',
+ 'Zacute', 'hyphen', 'zacute', 'Zdotaccent',
+ 'degree', 'plusminus', 'Ccaron', 'lslash',
+ 'Zcaron', 'quotedblright', 'paragraph', 'periodcentered',
+ 'zcaron', 'ccaron', 'scommaaccent', 'guillemotright',
+ 'OE', 'oe', 'Ydieresis', 'zdotaccent',
+ 'Agrave', 'Aacute', 'Acircumflex', 'Abreve',
+ 'Adieresis', 'Cacute', 'AE', 'Ccedilla',
+ 'Egrave', 'Eacute', 'Ecircumflex', 'Edieresis',
+ 'Igrave', 'Iacute', 'Icircumflex', 'Idieresis',
+ 'Dcroat', 'Nacute', 'Ograve', 'Oacute',
+ 'Ocircumflex', 'Ohungarumlaut', 'Odieresis', 'Sacute',
+ 'Uhungarumlaut', 'Ugrave', 'Uacute', 'Ucircumflex',
+ 'Udieresis', 'Eogonek', 'Tcommaaccent', 'germandbls',
+ 'agrave', 'aacute', 'acircumflex', 'abreve',
+ 'adieresis', 'cacute', 'ae', 'ccedilla',
+ 'egrave', 'eacute', 'ecircumflex', 'edieresis',
+ 'igrave', 'iacute', 'icircumflex', 'idieresis',
+ 'dcroat', 'nacute', 'ograve', 'oacute',
+ 'ocircumflex', 'ohungarumlaut', 'odieresis', 'sacute',
+ 'uhungarumlaut', 'ugrave', 'uacute', 'ucircumflex',
+ 'udieresis', 'eogonek', 'tcommaaccent', 'ydieresis'
+ ],
+# Russian
+ 'KOI8-R' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ 'SF100000', 'SF110000', 'SF010000', 'SF030000',
+ 'SF020000', 'SF040000', 'SF080000', 'SF090000',
+ 'SF060000', 'SF070000', 'SF050000', 'upblock',
+ 'dnblock', 'block', 'lfblock', 'rtblock',
+ 'ltshade', 'shade', 'dkshade', 'integraltp',
+ 'filledbox', 'periodcentered', 'radical', 'approxequal',
+ 'lessequal', 'greaterequal', 'space', 'integralbt',
+ 'degree', 'twosuperior', 'periodcentered', 'divide',
+ 'SF430000', 'SF240000', 'SF510000', 'afii10071',
+ 'SF520000', 'SF390000', 'SF220000', 'SF210000',
+ 'SF250000', 'SF500000', 'SF490000', 'SF380000',
+ 'SF280000', 'SF270000', 'SF260000', 'SF360000',
+ 'SF370000', 'SF420000', 'SF190000', 'afii10023',
+ 'SF200000', 'SF230000', 'SF470000', 'SF480000',
+ 'SF410000', 'SF450000', 'SF460000', 'SF400000',
+ 'SF540000', 'SF530000', 'SF440000', 'copyright',
+ 'afii10096', 'afii10065', 'afii10066', 'afii10088',
+ 'afii10069', 'afii10070', 'afii10086', 'afii10068',
+ 'afii10087', 'afii10074', 'afii10075', 'afii10076',
+ 'afii10077', 'afii10078', 'afii10079', 'afii10080',
+ 'afii10081', 'afii10097', 'afii10082', 'afii10083',
+ 'afii10084', 'afii10085', 'afii10072', 'afii10067',
+ 'afii10094', 'afii10093', 'afii10073', 'afii10090',
+ 'afii10095', 'afii10091', 'afii10089', 'afii10092',
+ 'afii10048', 'afii10017', 'afii10018', 'afii10040',
+ 'afii10021', 'afii10022', 'afii10038', 'afii10020',
+ 'afii10039', 'afii10026', 'afii10027', 'afii10028',
+ 'afii10029', 'afii10030', 'afii10031', 'afii10032',
+ 'afii10033', 'afii10049', 'afii10034', 'afii10035',
+ 'afii10036', 'afii10037', 'afii10024', 'afii10019',
+ 'afii10046', 'afii10045', 'afii10025', 'afii10042',
+ 'afii10047', 'afii10043', 'afii10041', 'afii10044'
+ ],
+# Ukrainian
+ 'KOI8-U' => [
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ '.notdef', '.notdef', '.notdef', '.notdef',
+ 'space', 'exclam', 'quotedbl', 'numbersign',
+ 'dollar', 'percent', 'ampersand', 'quotesingle',
+ 'parenleft', 'parenright', 'asterisk', 'plus',
+ 'comma', 'hyphen', 'period', 'slash',
+ 'zero', 'one', 'two', 'three',
+ 'four', 'five', 'six', 'seven',
+ 'eight', 'nine', 'colon', 'semicolon',
+ 'less', 'equal', 'greater', 'question',
+ 'at', 'A', 'B', 'C',
+ 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K',
+ 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', 'bracketleft',
+ 'backslash', 'bracketright', 'asciicircum', 'underscore',
+ 'grave', 'a', 'b', 'c',
+ 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k',
+ 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's',
+ 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', 'braceleft',
+ 'bar', 'braceright', 'asciitilde', '.notdef',
+ 'SF100000', 'SF110000', 'SF010000', 'SF030000',
+ 'SF020000', 'SF040000', 'SF080000', 'SF090000',
+ 'SF060000', 'SF070000', 'SF050000', 'upblock',
+ 'dnblock', 'block', 'lfblock', 'rtblock',
+ 'ltshade', 'shade', 'dkshade', 'integraltp',
+ 'filledbox', 'bullet', 'radical', 'approxequal',
+ 'lessequal', 'greaterequal', 'space', 'integralbt',
+ 'degree', 'twosuperior', 'periodcentered', 'divide',
+ 'SF430000', 'SF240000', 'SF510000', 'afii10071',
+ 'afii10101', 'SF390000', 'afii10103', 'afii10104',
+ 'SF250000', 'SF500000', 'SF490000', 'SF380000',
+ 'SF280000', 'afii10098', 'SF260000', 'SF360000',
+ 'SF370000', 'SF420000', 'SF190000', 'afii10023',
+ 'afii10053', 'SF230000', 'afii10055', 'afii10056',
+ 'SF410000', 'SF450000', 'SF460000', 'SF400000',
+ 'SF540000', 'afii10050', 'SF440000', 'copyright',
+ 'afii10096', 'afii10065', 'afii10066', 'afii10088',
+ 'afii10069', 'afii10070', 'afii10086', 'afii10068',
+ 'afii10087', 'afii10074', 'afii10075', 'afii10076',
+ 'afii10077', 'afii10078', 'afii10079', 'afii10080',
+ 'afii10081', 'afii10097', 'afii10082', 'afii10083',
+ 'afii10084', 'afii10085', 'afii10072', 'afii10067',
+ 'afii10094', 'afii10093', 'afii10073', 'afii10090',
+ 'afii10095', 'afii10091', 'afii10089', 'afii10092',
+ 'afii10048', 'afii10017', 'afii10018', 'afii10040',
+ 'afii10021', 'afii10022', 'afii10038', 'afii10020',
+ 'afii10039', 'afii10026', 'afii10027', 'afii10028',
+ 'afii10029', 'afii10030', 'afii10031', 'afii10032',
+ 'afii10033', 'afii10049', 'afii10034', 'afii10035',
+ 'afii10036', 'afii10037', 'afii10024', 'afii10019',
+ 'afii10046', 'afii10045', 'afii10025', 'afii10042',
+ 'afii10047', 'afii10043', 'afii10041', 'afii10044'
+ ]
+}
+
+def ReadAFM(file, map)
+
+ # Read a font metric file
+ a = IO.readlines(file)
+
+ raise "File no found: #{file}" if a.size == 0
+
+ widths = {}
+ fm = {}
+ fix = { 'Edot' => 'Edotaccent', 'edot' => 'edotaccent',
+ 'Idot' => 'Idotaccent',
+ 'Zdot' => 'Zdotaccent', 'zdot' => 'zdotaccent',
+ 'Odblacute' => 'Ohungarumlaut', 'odblacute' => 'ohungarumlaut',
+ 'Udblacute' => 'Uhungarumlaut', 'udblacute' => 'uhungarumlaut',
+ 'Gcedilla' => 'Gcommaaccent', 'gcedilla' => 'gcommaaccent',
+ 'Kcedilla' => 'Kcommaaccent', 'kcedilla' => 'kcommaaccent',
+ 'Lcedilla' => 'Lcommaaccent', 'lcedilla' => 'lcommaaccent',
+ 'Ncedilla' => 'Ncommaaccent', 'ncedilla' => 'ncommaaccent',
+ 'Rcedilla' => 'Rcommaaccent', 'rcedilla' => 'rcommaaccent',
+ 'Scedilla' => 'Scommaaccent',' scedilla' => 'scommaaccent',
+ 'Tcedilla' => 'Tcommaaccent',' tcedilla' => 'tcommaaccent',
+ 'Dslash' => 'Dcroat', 'dslash' => 'dcroat',
+ 'Dmacron' => 'Dcroat', 'dmacron' => 'dcroat',
+ 'combininggraveaccent' => 'gravecomb',
+ 'combininghookabove' => 'hookabovecomb',
+ 'combiningtildeaccent' => 'tildecomb',
+ 'combiningacuteaccent' => 'acutecomb',
+ 'combiningdotbelow' => 'dotbelowcomb',
+ 'dongsign' => 'dong'
+ }
+
+ a.each do |line|
+
+ e = line.rstrip.split(' ')
+ next if e.size < 2
+
+ code = e[0]
+ param = e[1]
+
+ if code == 'C' then
+
+ # Character metrics
+ cc = e[1].to_i
+ w = e[4]
+ gn = e[7]
+
+ gn = 'Euro' if gn[-4, 4] == '20AC'
+
+ if fix[gn] then
+
+ # Fix incorrect glyph name
+ 0.upto(map.size - 1) do |i|
+ if map[i] == fix[gn] then
+ map[i] = gn
+ end
+ end
+ end
+
+ if map.size == 0 then
+ # Symbolic font: use built-in encoding
+ widths[cc] = w
+ else
+ widths[gn] = w
+ fm['CapXHeight'] = e[13].to_i if gn == 'X'
+ end
+
+ fm['MissingWidth'] = w if gn == '.notdef'
+
+ elsif code == 'FontName' then
+ fm['FontName'] = param
+ elsif code == 'Weight' then
+ fm['Weight'] = param
+ elsif code == 'ItalicAngle' then
+ fm['ItalicAngle'] = param.to_f
+ elsif code == 'Ascender' then
+ fm['Ascender'] = param.to_i
+ elsif code == 'Descender' then
+ fm['Descender'] = param.to_i
+ elsif code == 'UnderlineThickness' then
+ fm['UnderlineThickness'] = param.to_i
+ elsif code == 'UnderlinePosition' then
+ fm['UnderlinePosition'] = param.to_i
+ elsif code == 'IsFixedPitch' then
+ fm['IsFixedPitch'] = (param == 'true')
+ elsif code == 'FontBBox' then
+ fm['FontBBox'] = "[#{e[1]},#{e[2]},#{e[3]},#{e[4]}]"
+ elsif code == 'CapHeight' then
+ fm['CapHeight'] = param.to_i
+ elsif code == 'StdVW' then
+ fm['StdVW'] = param.to_i
+ end
+ end
+
+ raise 'FontName not found' unless fm['FontName']
+
+ if map.size > 0 then
+ widths['.notdef'] = 600 unless widths['.notdef']
+
+ if (widths['Delta'] == nil) && widths['increment'] then
+ widths['Delta'] = widths['increment']
+ end
+
+ # Order widths according to map
+ 0.upto(255) do |i|
+ if widths[map[i]] == nil
+ puts "Warning: character #{map[i]} is missing"
+ widths[i] = widths['.notdef']
+ else
+ widths[i] = widths[map[i]]
+ end
+ end
+ end
+
+ fm['Widths'] = widths
+
+ return fm
+end
+
+def MakeFontDescriptor(fm, symbolic)
+
+ # Ascent
+ asc = fm['Ascender'] ? fm['Ascender'] : 1000
+ fd = "{\n 'Ascent' => '#{asc}'"
+
+ # Descent
+ desc = fm['Descender'] ? fm['Descender'] : -200
+ fd += ", 'Descent' => '#{desc}'"
+
+ # CapHeight
+ if fm['CapHeight'] then
+ ch = fm['CapHeight']
+ elsif fm['CapXHeight']
+ ch = fm['CapXHeight']
+ else
+ ch = asc
+ end
+ fd += ", 'CapHeight' => '#{ch}'"
+
+ # Flags
+ flags = 0
+
+ if fm['IsFixedPitch'] then
+ flags += 1 << 0
+ end
+
+ if symbolic then
+ flags += 1 << 2
+ else
+ flags += 1 << 5
+ end
+
+ if fm['ItalicAngle'] && (fm['ItalicAngle'] != 0) then
+ flags += 1 << 6
+ end
+
+ fd += ",\n 'Flags' => '#{flags}'"
+
+ # FontBBox
+ if fm['FontBBox'] then
+ fbb = fm['FontBBox'].gsub(/,/, ' ')
+ else
+ fbb = "[0 #{desc - 100} 1000 #{asc + 100}]"
+ end
+
+ fd += ", 'FontBBox' => '#{fbb}'"
+
+ # ItalicAngle
+ ia = fm['ItalicAngle'] ? fm['ItalicAngle'] : 0
+ fd += ",\n 'ItalicAngle' => '#{ia}'"
+
+ # StemV
+ if fm['StdVW'] then
+ stemv = fm['StdVW']
+ elsif fm['Weight'] && (/bold|black/i =~ fm['Weight'])
+ stemv = 120
+ else
+ stemv = 70
+ end
+
+ fd += ", 'StemV' => '#{stemv}'"
+
+ # MissingWidth
+ if fm['MissingWidth'] then
+ fd += ", 'MissingWidth' => '#{fm['MissingWidth']}'"
+ end
+
+ fd += "\n }"
+ return fd
+end
+
+def MakeWidthArray(fm)
+
+ # Make character width array
+ s = " [\n "
+
+ cw = fm['Widths']
+
+ 0.upto(255) do |i|
+ s += "%5d" % cw[i]
+ s += "," if i != 255
+ s += "\n " if (i % 8) == 7
+ end
+
+ s += ']'
+
+ return s
+end
+
+def MakeFontEncoding(map)
+
+ # Build differences from reference encoding
+ ref = Charencodings['cp1252']
+ s = ''
+ last = 0
+ 32.upto(255) do |i|
+ if map[i] != ref[i] then
+ if i != last + 1 then
+ s += i.to_s + ' '
+ end
+ last = i
+ s += '/' + map[i] + ' '
+ end
+ end
+ return s.rstrip
+end
+
+def ReadShort(f)
+ a = f.read(2).unpack('n')
+ return a[0]
+end
+
+def ReadLong(f)
+ a = f.read(4).unpack('N')
+ return a[0]
+end
+
+def CheckTTF(file)
+
+ rl = false
+ pp = false
+ e = false
+
+ # Check if font license allows embedding
+ File.open(file, 'rb') do |f|
+
+ # Extract number of tables
+ f.seek(4, IO::SEEK_CUR)
+ nb = ReadShort(f)
+ f.seek(6, IO::SEEK_CUR)
+
+ # Seek OS/2 table
+ found = false
+ 0.upto(nb - 1) do |i|
+ if f.read(4) == 'OS/2' then
+ found = true
+ break
+ end
+
+ f.seek(12, IO::SEEK_CUR)
+ end
+
+ if ! found then
+ return
+ end
+
+ f.seek(4, IO::SEEK_CUR)
+ offset = ReadLong(f)
+ f.seek(offset, IO::SEEK_SET)
+
+ # Extract fsType flags
+ f.seek(8, IO::SEEK_CUR)
+ fsType = ReadShort(f)
+
+ rl = (fsType & 0x02) != 0
+ pp = (fsType & 0x04) != 0
+ e = (fsType & 0x08) != 0
+ end
+
+ if rl && ( ! pp) && ( ! e) then
+ puts 'Warning: font license does not allow embedding'
+ end
+end
+
+#
+# fontfile: path to TTF file (or empty string if not to be embedded)
+# afmfile: path to AFM file
+# enc: font encoding (or empty string for symbolic fonts)
+# patch: optional patch for encoding
+# type : font type if $fontfile is empty
+#
+def MakeFont(fontfile, afmfile, enc = 'cp1252', patch = {}, type = 'TrueType')
+ # Generate a font definition file
+ if (enc != nil) && (enc != '') then
+ map = Charencodings[enc]
+ patch.each { |cc, gn| map[cc] = gn }
+ else
+ map = []
+ end
+
+ raise "Error: AFM file not found: #{afmfile}" unless File.exists?(afmfile)
+
+ fm = ReadAFM(afmfile, map)
+
+ if (enc != nil) && (enc != '') then
+ diff = MakeFontEncoding(map)
+ else
+ diff = ''
+ end
+
+ fd = MakeFontDescriptor(fm, (map.size == 0))
+
+ # Find font type
+ if fontfile then
+ ext = File.extname(fontfile).downcase.sub(/^\./, '')
+
+ if ext == 'ttf' then
+ type = 'TrueType'
+ elsif ext == 'pfb'
+ type = 'Type1'
+ else
+ raise "Error: unrecognized font file extension: #{ext}"
+ end
+ else
+ raise "Error: incorrect font type: #{type}" if (type != 'TrueType') && (type != 'Type1')
+ end
+ printf "type = #{type}\n"
+ # Start generation
+ s = "# #{fm['FontName']} font definition\n\n"
+ s += "module FontDef\n"
+ s += " def FontDef.type\n '#{type}'\n end\n"
+ s += " def FontDef.name\n '#{fm['FontName']}'\n end\n"
+ s += " def FontDef.desc\n #{fd}\n end\n"
+
+ if fm['UnderlinePosition'] == nil then
+ fm['UnderlinePosition'] = -100
+ end
+
+ if fm['UnderlineThickness'] == nil then
+ fm['UnderlineThickness'] = 50
+ end
+
+ s += " def FontDef.up\n #{fm['UnderlinePosition']}\n end\n"
+ s += " def FontDef.ut\n #{fm['UnderlineThickness']}\n end\n"
+
+ w = MakeWidthArray(fm)
+ s += " def FontDef.cw\n#{w}\n end\n"
+
+ s += " def FontDef.enc\n '#{enc}'\n end\n"
+ s += " def FontDef.diff\n #{(diff == nil) || (diff == '') ? 'nil' : '\'' + diff + '\''}\n end\n"
+
+ basename = File.basename(afmfile, '.*')
+
+ if fontfile then
+ # Embedded font
+ if ! File.exist?(fontfile) then
+ raise "Error: font file not found: #{fontfile}"
+ end
+
+ if type == 'TrueType' then
+ CheckTTF(fontfile)
+ end
+
+ file = ''
+ File.open(fontfile, 'rb') do |f|
+ file = f.read()
+ end
+
+ if type == 'Type1' then
+ # Find first two sections and discard third one
+ header = file[0] == 128
+ file = file[6, file.length - 6] if header
+
+ pos = file.index('eexec')
+ raise 'Error: font file does not seem to be valid Type1' if pos == nil
+
+ size1 = pos + 6
+
+ file = file[0, size1] + file[size1 + 6, file.length - (size1 + 6)] if header && file[size1] == 128
+
+ pos = file.index('00000000')
+ raise 'Error: font file does not seem to be valid Type1' if pos == nil
+
+ size2 = pos - size1
+ file = file[0, size1 + size2]
+ end
+
+ if require 'zlib' then
+ File.open(basename + '.z', 'wb') { |f| f.write(Zlib::Deflate.deflate(file)) }
+ s += " def FontDef.file\n '#{basename}.z'\n end\n"
+ puts "Font file compressed ('#{basename}.z')"
+ else
+ s += " def FontDef.file\n '#{File.basename(fontfile)}'\n end\n"
+ puts 'Notice: font file could not be compressed (zlib not available)'
+ end
+
+ if type == 'Type1' then
+ s += " def FontDef.size1\n '#{size1}'\n end\n"
+ s += " def FontDef.size2\n '#{size2}'\n end\n"
+ else
+ s += " def FontDef.originalsize\n '#{File.size(fontfile)}'\n end\n"
+ end
+
+ else
+ # Not embedded font
+ s += " def FontDef.file\n ''\n end\n"
+ end
+
+ s += "end\n"
+ File.open(basename + '.rb', 'w') { |file| file.write(s)}
+ puts "Font definition file generated (#{basename}.rb)"
+end
+
+
+if $0 == __FILE__ then
+ if ARGV.length >= 3 then
+ enc = ARGV[2]
+ else
+ enc = 'cp1252'
+ end
+
+ if ARGV.length >= 4 then
+ patch = ARGV[3]
+ else
+ patch = {}
+ end
+
+ if ARGV.length >= 5 then
+ type = ARGV[4]
+ else
+ type = 'TrueType'
+ end
+
+ MakeFont(ARGV[0], ARGV[1], enc, patch, type)
+end
diff --git a/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/rfpdf.rb b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/rfpdf.rb
new file mode 100644
index 000000000..5ad882903
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/rfpdf.rb
@@ -0,0 +1,346 @@
+module RFPDF
+ COLOR_PALETTE = {
+ :black => [0x00, 0x00, 0x00],
+ :white => [0xff, 0xff, 0xff],
+ }.freeze
+
+ # Draw a line from (x1, y1 ) to (x2, y2 ).
+ #
+ # Options are:
+ # * :line_color - Default value is COLOR_PALETTE[:black] .
+ # * :line_width - Default value is 0.5 .
+ #
+ # Example:
+ #
+ # draw_line(x1, y1, x1, y1+h, :line_color => ReportHelper::COLOR_PALETTE[:dark_blue], :line_width => 1)
+ #
+ def draw_line(x1, y1, x2, y2, options = {})
+ options[:line_color] ||= COLOR_PALETTE[:black]
+ options[:line_width] ||= 0.5
+ set_draw_color(options[:line_color])
+ SetLineWidth(options[:line_width])
+ Line(x1, y1, x2, y2)
+ end
+
+ # Draw a string of text at (x, y ).
+ #
+ # Options are:
+ # * :font_color - Default value is COLOR_PALETTE[:black] .
+ # * :font_size - Default value is 10 .
+ # * :font_style - Default value is nothing or '' .
+ #
+ # Example:
+ #
+ # draw_text(x, y, header_left, :font_size => 10)
+ #
+ def draw_text(x, y, text, options = {})
+ options[:font_color] ||= COLOR_PALETTE[:black]
+ options[:font_size] ||= 10
+ options[:font_style] ||= ''
+ set_text_color(options[:font_color])
+ SetFont('Arial', options[:font_style], options[:font_size])
+ SetXY(x, y)
+ Write(options[:font_size] + 4, text)
+ end
+
+ # Draw a block of text at (x, y ) bounded by left_margin and right_margin . Both
+ # margins are measured from their corresponding edge.
+ #
+ # Options are:
+ # * :font_color - Default value is COLOR_PALETTE[:black] .
+ # * :font_size - Default value is 10 .
+ # * :font_style - Default value is nothing or '' .
+ #
+ # Example:
+ #
+ # draw_text_block(left_margin, 85, "question", left_margin, 280,
+ # :font_color => ReportHelper::COLOR_PALETTE[:dark_blue],
+ # :font_size => 12,
+ # :font_style => 'I')
+ #
+ def draw_text_block(x, y, text, left_margin, right_margin, options = {})
+ options[:font_color] ||= COLOR_PALETTE[:black]
+ options[:font_size] ||= 10
+ options[:font_style] ||= ''
+ set_text_color(options[:font_color])
+ SetFont('Arial', options[:font_style], options[:font_size])
+ SetXY(x, y)
+ SetLeftMargin(left_margin)
+ SetRightMargin(right_margin)
+ Write(options[:font_size] + 4, text)
+ SetMargins(0,0,0)
+ end
+
+ # Draw a box at (x, y ), w wide and h high.
+ #
+ # Options are:
+ # * :border - Draw a border, 0 = no, 1 = yes? Default value is 1 .
+ # * :border_color - Default value is COLOR_PALETTE[:black] .
+ # * :border_width - Default value is 0.5 .
+ # * :fill - Fill the box, 0 = no, 1 = yes? Default value is 1 .
+ # * :fill_color - Default value is nothing or COLOR_PALETTE[:white] .
+ #
+ # Example:
+ #
+ # draw_box(x, y - 1, 38, 22)
+ #
+ def draw_box(x, y, w, h, options = {})
+ options[:border] ||= 1
+ options[:border_color] ||= COLOR_PALETTE[:black]
+ options[:border_width] ||= 0.5
+ options[:fill] ||= 1
+ options[:fill_color] ||= COLOR_PALETTE[:white]
+ SetLineWidth(options[:border_width])
+ set_draw_color(options[:border_color])
+ set_fill_color(options[:fill_color])
+ fd = ""
+ fd = "D" if options[:border] == 1
+ fd += "F" if options[:fill] == 1
+ Rect(x, y, w, h, fd)
+ end
+
+ # Draw a string of text at (x, y ) in a box w wide and h high.
+ #
+ # Options are:
+ # * :align - Vertical alignment 'C' = center, 'L' = left, 'R' = right. Default value is 'C' .
+ # * :border - Draw a border, 0 = no, 1 = yes? Default value is 0 .
+ # * :border_color - Default value is COLOR_PALETTE[:black] .
+ # * :border_width - Default value is 0.5 .
+ # * :fill - Fill the box, 0 = no, 1 = yes? Default value is 1 .
+ # * :fill_color - Default value is nothing or COLOR_PALETTE[:white] .
+ # * :font_color - Default value is COLOR_PALETTE[:black] .
+ # * :font_size - Default value is nothing or 8 .
+ # * :font_style - 'B' = bold, 'I' = italic, 'U' = underline. Default value is nothing '' .
+ # * :padding - Default value is nothing or 2 .
+ # * :valign - 'M' = middle, 'T' = top, 'B' = bottom. Default value is nothing or 'M' .
+ #
+ # Example:
+ #
+ # draw_text_box(x, y - 1, 38, 22,
+ # "your_score_title",
+ # :fill => 0,
+ # :font_color => ReportHelper::COLOR_PALETTE[:blue],
+ # :font_line_spacing => 0,
+ # :font_style => "B",
+ # :valign => "M")
+ #
+ def draw_text_box(x, y, w, h, text, options = {})
+ options[:align] ||= 'C'
+ options[:border] ||= 0
+ options[:border_color] ||= COLOR_PALETTE[:black]
+ options[:border_width] ||= 0.5
+ options[:fill] ||= 1
+ options[:fill_color] ||= COLOR_PALETTE[:white]
+ options[:font_color] ||= COLOR_PALETTE[:black]
+ options[:font_size] ||= 8
+ options[:font_line_spacing] ||= options[:font_size] * 0.3
+ options[:font_style] ||= ''
+ options[:padding] ||= 2
+ options[:valign] ||= "M"
+ if options[:fill] == 1 or options[:border] == 1
+ draw_box(x, y, w, h, options)
+ end
+ SetMargins(0,0,0)
+ set_text_color(options[:font_color])
+ font_size = options[:font_size]
+ SetFont('Arial', options[:font_style], font_size)
+ font_size += options[:font_line_spacing]
+ case options[:valign]
+ when "B"
+ y -= options[:padding]
+ text = "\n" + text if text["\n"].nil?
+ when "T"
+ y += options[:padding]
+ end
+ SetXY(x, y)
+ if GetStringWidth(text) > w or not text["\n"].nil? or options[:valign] == "T"
+ font_size += options[:font_size] * 0.1
+ #TODO 2006-07-21 Level=1 - this is assuming a 2 line text
+ SetXY(x, y + ((h - (font_size * 2)) / 2)) if options[:valign] == "M"
+ MultiCell(w, font_size, text, 0, options[:align])
+ else
+ Cell(w, h, text, 0, 0, options[:align])
+ end
+ end
+
+ # Draw a string of text at (x, y ) as a title.
+ #
+ # Options are:
+ # * :font_color - Default value is COLOR_PALETTE[:black] .
+ # * :font_size - Default value is 18 .
+ # * :font_style - Default value is nothing or '' .
+ #
+ # Example:
+ #
+ # draw_title(left_margin, 60,
+ # "title:",
+ # :font_color => ReportHelper::COLOR_PALETTE[:dark_blue])
+ #
+ def draw_title(x, y, title, options = {})
+ options[:font_color] ||= COLOR_PALETTE[:black]
+ options[:font_size] ||= 18
+ options[:font_style] ||= ''
+ set_text_color(options[:font_color])
+ SetFont('Arial', options[:font_style], options[:font_size])
+ SetXY(x, y)
+ Write(options[:font_size] + 2, title)
+ end
+
+ # Set the draw color. Default value is COLOR_PALETTE[:black] .
+ #
+ # Example:
+ #
+ # set_draw_color(ReportHelper::COLOR_PALETTE[:dark_blue])
+ #
+ def set_draw_color(color = COLOR_PALETTE[:black])
+ SetDrawColor(color[0], color[1], color[2])
+ end
+
+ # Set the fill color. Default value is COLOR_PALETTE[:white] .
+ #
+ # Example:
+ #
+ # set_fill_color(ReportHelper::COLOR_PALETTE[:dark_blue])
+ #
+ def set_fill_color(color = COLOR_PALETTE[:white])
+ SetFillColor(color[0], color[1], color[2])
+ end
+
+ # Set the text color. Default value is COLOR_PALETTE[:white] .
+ #
+ # Example:
+ #
+ # set_text_color(ReportHelper::COLOR_PALETTE[:dark_blue])
+ #
+ def set_text_color(color = COLOR_PALETTE[:black])
+ SetTextColor(color[0], color[1], color[2])
+ end
+
+ # Write a string containing html characters. Default value is COLOR_PALETTE[:white] .
+ #
+ # Options are:
+ # * :height - Line height. Default value is 20 .
+ #
+ # Example:
+ #
+ # write_html(html, :height => 12)
+ #
+ def write_html(html, options = {})
+ options[:height] ||= 20
+ #HTML parser
+ @href = nil
+ @style = {}
+ html.gsub!("\n",' ')
+ re = %r{ ( |
+ < (?:
+ [^<>"] +
+ |
+ " (?: \\. | [^\\"]+ ) * "
+ ) *
+ >
+ ) }xm
+
+ html.split(re).each do |value|
+ if "<" == value[0,1]
+ #Tag
+ if (value[1, 1] == '/')
+ close_tag(value[2..-2], options)
+ else
+ tag = value[1..-2]
+ open_tag(tag, options)
+ end
+ else
+ #Text
+ if @href
+ put_link(@href,value)
+ else
+ Write(options[:height], value)
+ end
+ end
+ end
+ end
+
+ def open_tag(tag, options = {}) #:nodoc:
+ #Opening tag
+ tag = tag.to_s.upcase
+ set_style(tag, true) if tag == 'B' or tag == 'I' or tag == 'U'
+ @href = options['HREF'] if tag == 'A'
+ Ln(options[:height]) if tag == 'BR'
+ end
+
+ def close_tag(tag, options = {}) #:nodoc:
+ #Closing tag
+ tag = tag.to_s.upcase
+ set_style(tag, false) if tag == 'B' or tag == 'I' or tag == 'U'
+ @href = '' if $tag == 'A'
+ end
+
+ def set_style(tag, enable = true) #:nodoc:
+ #Modify style and select corresponding font
+ style = ""
+ @style[tag] = enable
+ ['B','I','U'].each do |s|
+ style += s if not @style[s].nil? and @style[s]
+ end
+ SetFont('', style)
+ end
+
+ def put_link(url, txt) #:nodoc:
+ #Put a hyperlink
+ SetTextColor(0,0,255)
+ set_style('U',true)
+ Write(5, txt, url)
+ set_style('U',false)
+ SetTextColor(0)
+ end
+end
+
+# class FPDF
+# alias_method :set_margins , :SetMargins
+# alias_method :set_left_margin , :SetLeftMargin
+# alias_method :set_top_margin , :SetTopMargin
+# alias_method :set_right_margin , :SetRightMargin
+# alias_method :set_auto_pagebreak , :SetAutoPageBreak
+# alias_method :set_display_mode , :SetDisplayMode
+# alias_method :set_compression , :SetCompression
+# alias_method :set_title , :SetTitle
+# alias_method :set_subject , :SetSubject
+# alias_method :set_author , :SetAuthor
+# alias_method :set_keywords , :SetKeywords
+# alias_method :set_creator , :SetCreator
+# alias_method :set_draw_color , :SetDrawColor
+# alias_method :set_fill_color , :SetFillColor
+# alias_method :set_text_color , :SetTextColor
+# alias_method :set_line_width , :SetLineWidth
+# alias_method :set_font , :SetFont
+# alias_method :set_font_size , :SetFontSize
+# alias_method :set_link , :SetLink
+# alias_method :set_y , :SetY
+# alias_method :set_xy , :SetXY
+# alias_method :get_string_width , :GetStringWidth
+# alias_method :get_x , :GetX
+# alias_method :set_x , :SetX
+# alias_method :get_y , :GetY
+# alias_method :accept_pagev_break , :AcceptPageBreak
+# alias_method :add_font , :AddFont
+# alias_method :add_link , :AddLink
+# alias_method :add_page , :AddPage
+# alias_method :alias_nb_pages , :AliasNbPages
+# alias_method :cell , :Cell
+# alias_method :close , :Close
+# alias_method :error , :Error
+# alias_method :footer , :Footer
+# alias_method :header , :Header
+# alias_method :image , :Image
+# alias_method :line , :Line
+# alias_method :link , :Link
+# alias_method :ln , :Ln
+# alias_method :multi_cell , :MultiCell
+# alias_method :open , :Open
+# alias_method :Open , :open
+# alias_method :output , :Output
+# alias_method :page_no , :PageNo
+# alias_method :rect , :Rect
+# alias_method :text , :Text
+# alias_method :write , :Write
+# end
diff --git a/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/view.rb b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/view.rb
new file mode 100644
index 000000000..185811202
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/lib/rfpdf/view.rb
@@ -0,0 +1,75 @@
+# Copyright (c) 2006 4ssoM LLC
+#
+# The MIT License
+#
+# 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.
+#
+# Thanks go out to Bruce Williams of codefluency who created RTex. This
+# template handler is modification of his work.
+#
+# Example Registration
+#
+# ActionView::Base::register_template_handler 'rfpdf', RFpdfView
+
+module RFPDF
+
+ class View
+
+ def initialize(action_view)
+ @action_view = action_view
+ # Override with @options_for_rfpdf Hash in your controller
+ @options = {
+ # Run through latex first? (for table of contents, etc)
+ :pre_process => false,
+ # Debugging mode; raises exception
+ :debug => false,
+ # Filename of pdf to generate
+ :file_name => "#{@action_view.controller.action_name}.pdf",
+ # Temporary Directory
+ :temp_dir => "#{File.expand_path(RAILS_ROOT)}/tmp"
+ }.merge(@action_view.controller.instance_eval{ @options_for_rfpdf } || {}).with_indifferent_access
+ end
+
+ def render(template, local_assigns = {})
+ @pdf_name = "Default.pdf" if @pdf_name.nil?
+ unless @action_view.controller.headers["Content-Type"] == 'application/pdf'
+ @generate = true
+ @action_view.controller.headers["Content-Type"] = 'application/pdf'
+ @action_view.controller.headers["Content-disposition:"] = "inline; filename=\"#{@options[:file_name]}\""
+ end
+ assigns = @action_view.assigns.dup
+
+ if content_for_layout = @action_view.instance_variable_get("@content_for_layout")
+ assigns['content_for_layout'] = content_for_layout
+ end
+
+ result = @action_view.instance_eval do
+ assigns.each do |key,val|
+ instance_variable_set "@#{key}", val
+ end
+ local_assigns.each do |key,val|
+ class << self; self; end.send(:define_method,key){ val }
+ end
+ ERB.new(template).result(binding)
+ end
+ end
+
+ end
+
+end
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/rfpdf/test/test_helper.rb b/rest_sys/vendor/plugins/rfpdf/test/test_helper.rb
new file mode 100644
index 000000000..2e2ea3bc5
--- /dev/null
+++ b/rest_sys/vendor/plugins/rfpdf/test/test_helper.rb
@@ -0,0 +1 @@
+#!/usr/bin/env ruby
\ No newline at end of file
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/COPYING b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/COPYING
new file mode 100644
index 000000000..2ff629a20
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/COPYING
@@ -0,0 +1,272 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street,
+Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and
+distribute verbatim copies of this license document, but changing it is not
+allowed.
+
+ Preamble
+
+The licenses for most software are designed to take away your freedom to
+share and change it. By contrast, the GNU General Public License is
+intended to guarantee your freedom to share and change free software--to
+make sure the software is free for all its users. This General Public
+License applies to most of the Free Software Foundation's software and to
+any other program whose authors commit to using it. (Some other Free
+Software Foundation software is covered by the GNU Lesser General Public
+License instead.) You can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our
+General Public Licenses are designed to make sure that you have the freedom
+to distribute copies of free software (and charge for this service if you
+wish), that you receive source code or can get it if you want it, that you
+can change the software or use pieces of it in new free programs; and that
+you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to
+deny you these rights or to ask you to surrender the rights. These
+restrictions translate to certain responsibilities for you if you distribute
+copies of the software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or
+for a fee, you must give the recipients all the rights that you have. You
+must make sure that they, too, receive or can get the source code. And you
+must show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2)
+offer you this license which gives you legal permission to copy, distribute
+and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that
+everyone understands that there is no warranty for this free software. If
+the software is modified by someone else and passed on, we want its
+recipients to know that what they have is not the original, so that any
+problems introduced by others will not reflect on the original authors'
+reputations.
+
+Finally, any free program is threatened constantly by software patents. We
+wish to avoid the danger that redistributors of a free program will
+individually obtain patent licenses, in effect making the program
+proprietary. To prevent this, we have made it clear that any patent must be
+licensed for everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification
+follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License applies to any program or other work which contains a notice
+ placed by the copyright holder saying it may be distributed under the
+ terms of this General Public License. The "Program", below, refers to
+ any such program or work, and a "work based on the Program" means either
+ the Program or any derivative work under copyright law: that is to say, a
+ work containing the Program or a portion of it, either verbatim or with
+ modifications and/or translated into another language. (Hereinafter,
+ translation is included without limitation in the term "modification".)
+ Each licensee is addressed as "you".
+
+ Activities other than copying, distribution and modification are not
+ covered by this License; they are outside its scope. The act of running
+ the Program is not restricted, and the output from the Program is covered
+ only if its contents constitute a work based on the Program (independent
+ of having been made by running the Program). Whether that is true depends
+ on what the Program does.
+
+1. You may copy and distribute verbatim copies of the Program's source code
+ as you receive it, in any medium, provided that you conspicuously and
+ appropriately publish on each copy an appropriate copyright notice and
+ disclaimer of warranty; keep intact all the notices that refer to this
+ License and to the absence of any warranty; and give any other recipients
+ of the Program a copy of this License along with the Program.
+
+ You may charge a fee for the physical act of transferring a copy, and you
+ may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it,
+ thus forming a work based on the Program, and copy and distribute such
+ modifications or work under the terms of Section 1 above, provided that
+ you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices stating
+ that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in whole
+ or in part contains or is derived from the Program or any part
+ thereof, to be licensed as a whole at no charge to all third parties
+ under the terms of this License.
+
+ c) If the modified program normally reads commands interactively when
+ run, you must cause it, when started running for such interactive use
+ in the most ordinary way, to print or display an announcement
+ including an appropriate copyright notice and a notice that there is
+ no warranty (or else, saying that you provide a warranty) and that
+ users may redistribute the program under these conditions, and telling
+ the user how to view a copy of this License. (Exception: if the
+ Program itself is interactive but does not normally print such an
+ announcement, your work based on the Program is not required to print
+ an announcement.)
+
+ These requirements apply to the modified work as a whole. If
+ identifiable sections of that work are not derived from the Program, and
+ can be reasonably considered independent and separate works in
+ themselves, then this License, and its terms, do not apply to those
+ sections when you distribute them as separate works. But when you
+ distribute the same sections as part of a whole which is a work based on
+ the Program, the distribution of the whole must be on the terms of this
+ License, whose permissions for other licensees extend to the entire
+ whole, and thus to each and every part regardless of who wrote it.
+
+ Thus, it is not the intent of this section to claim rights or contest
+ your rights to work written entirely by you; rather, the intent is to
+ exercise the right to control the distribution of derivative or
+ collective works based on the Program.
+
+ In addition, mere aggregation of another work not based on the Program
+ with the Program (or with a work based on the Program) on a volume of a
+ storage or distribution medium does not bring the other work under the
+ scope of this License.
+
+3. You may copy and distribute the Program (or a work based on it, under
+ Section 2) in object code or executable form under the terms of Sections
+ 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable source
+ code, which must be distributed under the terms of Sections 1 and 2
+ above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three years, to
+ give any third party, for a charge no more than your cost of
+ physically performing source distribution, a complete machine-readable
+ copy of the corresponding source code, to be distributed under the
+ terms of Sections 1 and 2 above on a medium customarily used for
+ software interchange; or,
+
+ c) Accompany it with the information you received as to the offer to
+ distribute corresponding source code. (This alternative is allowed
+ only for noncommercial distribution and only if you received the
+ program in object code or executable form with such an offer, in
+ accord with Subsection b above.)
+
+ The source code for a work means the preferred form of the work for
+ making modifications to it. For an executable work, complete source code
+ means all the source code for all modules it contains, plus any
+ associated interface definition files, plus the scripts used to control
+ compilation and installation of the executable. However, as a special
+ exception, the source code distributed need not include anything that is
+ normally distributed (in either source or binary form) with the major
+ components (compiler, kernel, and so on) of the operating system on which
+ the executable runs, unless that component itself accompanies the
+ executable.
+
+ If distribution of executable or object code is made by offering access
+ to copy from a designated place, then offering equivalent access to copy
+ the source code from the same place counts as distribution of the source
+ code, even though third parties are not compelled to copy the source
+ along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as
+ expressly provided under this License. Any attempt otherwise to copy,
+ modify, sublicense or distribute the Program is void, and will
+ automatically terminate your rights under this License. However, parties
+ who have received copies, or rights, from you under this License will not
+ have their licenses terminated so long as such parties remain in full
+ compliance.
+
+5. You are not required to accept this License, since you have not signed
+ it. However, nothing else grants you permission to modify or distribute
+ the Program or its derivative works. These actions are prohibited by law
+ if you do not accept this License. Therefore, by modifying or
+ distributing the Program (or any work based on the Program), you indicate
+ your acceptance of this License to do so, and all its terms and
+ conditions for copying, distributing or modifying the Program or works
+ based on it.
+
+6. Each time you redistribute the Program (or any work based on the
+ Program), the recipient automatically receives a license from the
+ original licensor to copy, distribute or modify the Program subject to
+ these terms and conditions. You may not impose any further restrictions
+ on the recipients' exercise of the rights granted herein. You are not
+ responsible for enforcing compliance by third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent
+ infringement or for any other reason (not limited to patent issues),
+ conditions are imposed on you (whether by court order, agreement or
+ otherwise) that contradict the conditions of this License, they do not
+ excuse you from the conditions of this License. If you cannot distribute
+ so as to satisfy simultaneously your obligations under this License and
+ any other pertinent obligations, then as a consequence you may not
+ distribute the Program at all. For example, if a patent license would
+ not permit royalty-free redistribution of the Program by all those who
+ receive copies directly or indirectly through you, then the only way you
+ could satisfy both it and this License would be to refrain entirely from
+ distribution of the Program.
+
+ If any portion of this section is held invalid or unenforceable under any
+ particular circumstance, the balance of the section is intended to apply
+ and the section as a whole is intended to apply in other circumstances.
+
+ It is not the purpose of this section to induce you to infringe any
+ patents or other property right claims or to contest validity of any such
+ claims; this section has the sole purpose of protecting the integrity of
+ the free software distribution system, which is implemented by public
+ license practices. Many people have made generous contributions to the
+ wide range of software distributed through that system in reliance on
+ consistent application of that system; it is up to the author/donor to
+ decide if he or she is willing to distribute software through any other
+ system and a licensee cannot impose that choice.
+
+ This section is intended to make thoroughly clear what is believed to be
+ a consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain
+ countries either by patents or by copyrighted interfaces, the original
+ copyright holder who places the Program under this License may add an
+ explicit geographical distribution limitation excluding those countries,
+ so that distribution is permitted only in or among countries not thus
+ excluded. In such case, this License incorporates the limitation as if
+ written in the body of this License.
+
+9. The Free Software Foundation may publish revised and/or new versions of
+ the General Public License from time to time. Such new versions will be
+ similar in spirit to the present version, but may differ in detail to
+ address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the Program
+ specifies a version number of this License which applies to it and "any
+ later version", you have the option of following the terms and conditions
+ either of that version or of any later version published by the Free
+ Software Foundation. If the Program does not specify a version number of
+ this License, you may choose any version ever published by the Free
+ Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs
+ whose distribution conditions are different, write to the author to ask
+ for permission. For software which is copyrighted by the Free Software
+ Foundation, write to the Free Software Foundation; we sometimes make
+ exceptions for this. Our decision will be guided by the two goals of
+ preserving the free status of all derivatives of our free software and
+ of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
+ THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
+ EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
+ ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH
+ YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+ NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
+ DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
+ DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM
+ (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
+ INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
+ THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR
+ OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/ChangeLog b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/ChangeLog
new file mode 100644
index 000000000..bd9b70e7d
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/ChangeLog
@@ -0,0 +1,58 @@
+= Net::LDAP Changelog
+
+== Net::LDAP 0.0.4: August 15, 2006
+* Undeprecated Net::LDAP#modify. Thanks to Justin Forder for
+ providing the rationale for this.
+* Added a much-expanded set of special characters to the parser
+ for RFC-2254 filters. Thanks to Andre Nathan.
+* Changed Net::LDAP#search so you can pass it a filter in string form.
+ The conversion to a Net::LDAP::Filter now happens automatically.
+* Implemented Net::LDAP#bind_as (preliminary and subject to change).
+ Thanks for Simon Claret for valuable suggestions and for helping test.
+* Fixed bug in Net::LDAP#open that was preventing #open from being
+ called more than one on a given Net::LDAP object.
+
+== Net::LDAP 0.0.3: July 26, 2006
+* Added simple TLS encryption.
+ Thanks to Garett Shulman for suggestions and for helping test.
+
+== Net::LDAP 0.0.2: July 12, 2006
+* Fixed malformation in distro tarball and gem.
+* Improved documentation.
+* Supported "paged search control."
+* Added a range of API improvements.
+* Thanks to Andre Nathan, andre@digirati.com.br, for valuable
+ suggestions.
+* Added support for LE and GE search filters.
+* Added support for Search referrals.
+* Fixed a regression with openldap 2.2.x and higher caused
+ by the introduction of RFC-2696 controls. Thanks to Andre
+ Nathan for reporting the problem.
+* Added support for RFC-2254 filter syntax.
+
+== Net::LDAP 0.0.1: May 1, 2006
+* Initial release.
+* Client functionality is near-complete, although the APIs
+ are not guaranteed and may change depending on feedback
+ from the community.
+* We're internally working on a Ruby-based implementation
+ of a full-featured, production-quality LDAP server,
+ which will leverage the underlying LDAP and BER functionality
+ in Net::LDAP.
+* Please tell us if you would be interested in seeing a public
+ release of the LDAP server.
+* Grateful acknowledgement to Austin Ziegler, who reviewed
+ this code and provided the release framework, including
+ minitar.
+
+#--
+# Net::LDAP for Ruby.
+# http://rubyforge.org/projects/net-ldap/
+# Copyright (C) 2006 by Francis Cianfrocca
+#
+# Available under the same terms as Ruby. See LICENCE in the main
+# distribution for full licensing information.
+#
+# $Id: ChangeLog,v 1.17.2.4 2005/09/09 12:36:42 austin Exp $
+#++
+# vim: sts=2 sw=2 ts=4 et ai tw=77
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/LICENCE b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/LICENCE
new file mode 100644
index 000000000..953ea0bb9
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/LICENCE
@@ -0,0 +1,55 @@
+Net::LDAP is copyrighted free software by Francis Cianfrocca
+. You can redistribute it and/or modify it under either
+the terms of the GPL (see the file COPYING), or the conditions below:
+
+1. You may make and give away verbatim copies of the source form of the
+ software without restriction, provided that you duplicate all of the
+ original copyright notices and associated disclaimers.
+
+2. You may modify your copy of the software in any way, provided that you do
+ at least ONE of the following:
+
+ a) place your modifications in the Public Domain or otherwise make them
+ Freely Available, such as by posting said modifications to Usenet or
+ an equivalent medium, or by allowing the author to include your
+ modifications in the software.
+
+ b) use the modified software only within your corporation or
+ organization.
+
+ c) rename any non-standard executables so the names do not conflict with
+ standard executables, which must also be provided.
+
+ d) make other distribution arrangements with the author.
+
+3. You may distribute the software in object code or executable form,
+ provided that you do at least ONE of the following:
+
+ a) distribute the executables and library files of the software, together
+ with instructions (in the manual page or equivalent) on where to get
+ the original distribution.
+
+ b) accompany the distribution with the machine-readable source of the
+ software.
+
+ c) give non-standard executables non-standard names, with instructions on
+ where to get the original software distribution.
+
+ d) make other distribution arrangements with the author.
+
+4. You may modify and include the part of the software into any other
+ software (possibly commercial). But some files in the distribution are
+ not written by the author, so that they are not under this terms.
+
+ They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
+ files under the ./missing directory. See each file for the copying
+ condition.
+
+5. The scripts and library files supplied as input to or produced as output
+ from the software do not automatically fall under the copyright of the
+ software, but belong to whomever generated them, and may be sold
+ commercially, and may be aggregated with this software.
+
+6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/README b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/README
new file mode 100644
index 000000000..f61a7ff15
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/README
@@ -0,0 +1,32 @@
+= Net::LDAP for Ruby
+Net::LDAP is an LDAP support library written in pure Ruby. It supports all
+LDAP client features, and a subset of server features as well.
+
+Homepage:: http://rubyforge.org/projects/net-ldap/
+Copyright:: (C) 2006 by Francis Cianfrocca
+
+Original developer: Francis Cianfrocca
+Contributions by Austin Ziegler gratefully acknowledged.
+
+== LICENCE NOTES
+Please read the file LICENCE for licensing restrictions on this library. In
+the simplest terms, this library is available under the same terms as Ruby
+itself.
+
+== Requirements
+Net::LDAP requires Ruby 1.8.2 or better.
+
+== Documentation
+See Net::LDAP for documentation and usage samples.
+
+#--
+# Net::LDAP for Ruby.
+# http://rubyforge.org/projects/net-ldap/
+# Copyright (C) 2006 by Francis Cianfrocca
+#
+# Available under the same terms as Ruby. See LICENCE in the main
+# distribution for full licensing information.
+#
+# $Id: README 141 2006-07-12 10:37:37Z blackhedd $
+#++
+# vim: sts=2 sw=2 ts=4 et ai tw=77
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ber.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ber.rb
new file mode 100644
index 000000000..e76100656
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ber.rb
@@ -0,0 +1,294 @@
+# $Id: ber.rb 142 2006-07-26 12:20:33Z blackhedd $
+#
+# NET::BER
+# Mixes ASN.1/BER convenience methods into several standard classes.
+# Also provides BER parsing functionality.
+#
+#----------------------------------------------------------------------------
+#
+# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
+#
+# Gmail: garbagecat10
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#---------------------------------------------------------------------------
+#
+#
+
+
+
+
+module Net
+
+ module BER
+
+ class BerError < Exception; end
+
+
+ # This module is for mixing into IO and IO-like objects.
+ module BERParser
+
+ # The order of these follows the class-codes in BER.
+ # Maybe this should have been a hash.
+ TagClasses = [:universal, :application, :context_specific, :private]
+
+ BuiltinSyntax = {
+ :universal => {
+ :primitive => {
+ 1 => :boolean,
+ 2 => :integer,
+ 4 => :string,
+ 10 => :integer,
+ },
+ :constructed => {
+ 16 => :array,
+ 17 => :array
+ }
+ }
+ }
+
+ #
+ # read_ber
+ # TODO: clean this up so it works properly with partial
+ # packets coming from streams that don't block when
+ # we ask for more data (like StringIOs). At it is,
+ # this can throw TypeErrors and other nasties.
+ #
+ def read_ber syntax=nil
+ return nil if eof?
+
+ id = getc # don't trash this value, we'll use it later
+ tag = id & 31
+ tag < 31 or raise BerError.new( "unsupported tag encoding: #{id}" )
+ tagclass = TagClasses[ id >> 6 ]
+ encoding = (id & 0x20 != 0) ? :constructed : :primitive
+
+ n = getc
+ lengthlength,contentlength = if n <= 127
+ [1,n]
+ else
+ j = (0...(n & 127)).inject(0) {|mem,x| mem = (mem << 8) + getc}
+ [1 + (n & 127), j]
+ end
+
+ newobj = read contentlength
+
+ objtype = nil
+ [syntax, BuiltinSyntax].each {|syn|
+ if syn && (ot = syn[tagclass]) && (ot = ot[encoding]) && ot[tag]
+ objtype = ot[tag]
+ break
+ end
+ }
+
+ obj = case objtype
+ when :boolean
+ newobj != "\000"
+ when :string
+ (newobj || "").dup
+ when :integer
+ j = 0
+ newobj.each_byte {|b| j = (j << 8) + b}
+ j
+ when :array
+ seq = []
+ sio = StringIO.new( newobj || "" )
+ # Interpret the subobject, but note how the loop
+ # is built: nil ends the loop, but false (a valid
+ # BER value) does not!
+ while (e = sio.read_ber(syntax)) != nil
+ seq << e
+ end
+ seq
+ else
+ raise BerError.new( "unsupported object type: class=#{tagclass}, encoding=#{encoding}, tag=#{tag}" )
+ end
+
+ # Add the identifier bits into the object if it's a String or an Array.
+ # We can't add extra stuff to Fixnums and booleans, not that it makes much sense anyway.
+ obj and ([String,Array].include? obj.class) and obj.instance_eval "def ber_identifier; #{id}; end"
+ obj
+
+ end
+
+ end # module BERParser
+ end # module BER
+
+end # module Net
+
+
+class IO
+ include Net::BER::BERParser
+end
+
+require "stringio"
+class StringIO
+ include Net::BER::BERParser
+end
+
+begin
+ require 'openssl'
+ class OpenSSL::SSL::SSLSocket
+ include Net::BER::BERParser
+ end
+rescue LoadError
+# Ignore LoadError.
+# DON'T ignore NameError, which means the SSLSocket class
+# is somehow unavailable on this implementation of Ruby's openssl.
+# This may be WRONG, however, because we don't yet know how Ruby's
+# openssl behaves on machines with no OpenSSL library. I suppose
+# it's possible they do not fail to require 'openssl' but do not
+# create the classes. So this code is provisional.
+# Also, you might think that OpenSSL::SSL::SSLSocket inherits from
+# IO so we'd pick it up above. But you'd be wrong.
+end
+
+class String
+ def read_ber syntax=nil
+ StringIO.new(self).read_ber(syntax)
+ end
+end
+
+
+
+#----------------------------------------------
+
+
+class FalseClass
+ #
+ # to_ber
+ #
+ def to_ber
+ "\001\001\000"
+ end
+end
+
+
+class TrueClass
+ #
+ # to_ber
+ #
+ def to_ber
+ "\001\001\001"
+ end
+end
+
+
+
+class Fixnum
+ #
+ # to_ber
+ #
+ def to_ber
+ i = [self].pack('w')
+ [2, i.length].pack("CC") + i
+ end
+
+ #
+ # to_ber_enumerated
+ #
+ def to_ber_enumerated
+ i = [self].pack('w')
+ [10, i.length].pack("CC") + i
+ end
+
+ #
+ # to_ber_length_encoding
+ #
+ def to_ber_length_encoding
+ if self <= 127
+ [self].pack('C')
+ else
+ i = [self].pack('N').sub(/^[\0]+/,"")
+ [0x80 + i.length].pack('C') + i
+ end
+ end
+
+end # class Fixnum
+
+
+class Bignum
+
+ def to_ber
+ i = [self].pack('w')
+ i.length > 126 and raise Net::BER::BerError.new( "range error in bignum" )
+ [2, i.length].pack("CC") + i
+ end
+
+end
+
+
+
+class String
+ #
+ # to_ber
+ # A universal octet-string is tag number 4,
+ # but others are possible depending on the context, so we
+ # let the caller give us one.
+ # The preferred way to do this in user code is via to_ber_application_sring
+ # and to_ber_contextspecific.
+ #
+ def to_ber code = 4
+ [code].pack('C') + length.to_ber_length_encoding + self
+ end
+
+ #
+ # to_ber_application_string
+ #
+ def to_ber_application_string code
+ to_ber( 0x40 + code )
+ end
+
+ #
+ # to_ber_contextspecific
+ #
+ def to_ber_contextspecific code
+ to_ber( 0x80 + code )
+ end
+
+end # class String
+
+
+
+class Array
+ #
+ # to_ber_appsequence
+ # An application-specific sequence usually gets assigned
+ # a tag that is meaningful to the particular protocol being used.
+ # This is different from the universal sequence, which usually
+ # gets a tag value of 16.
+ # Now here's an interesting thing: We're adding the X.690
+ # "application constructed" code at the top of the tag byte (0x60),
+ # but some clients, notably ldapsearch, send "context-specific
+ # constructed" (0xA0). The latter would appear to violate RFC-1777,
+ # but what do I know? We may need to change this.
+ #
+
+ def to_ber id = 0; to_ber_seq_internal( 0x30 + id ); end
+ def to_ber_set id = 0; to_ber_seq_internal( 0x31 + id ); end
+ def to_ber_sequence id = 0; to_ber_seq_internal( 0x30 + id ); end
+ def to_ber_appsequence id = 0; to_ber_seq_internal( 0x60 + id ); end
+ def to_ber_contextspecific id = 0; to_ber_seq_internal( 0xA0 + id ); end
+
+ private
+ def to_ber_seq_internal code
+ s = self.to_s
+ [code].pack('C') + s.length.to_ber_length_encoding + s
+ end
+
+end # class Array
+
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap.rb
new file mode 100644
index 000000000..d741e722b
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap.rb
@@ -0,0 +1,1311 @@
+# $Id: ldap.rb 154 2006-08-15 09:35:43Z blackhedd $
+#
+# Net::LDAP for Ruby
+#
+#
+# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
+#
+# Written and maintained by Francis Cianfrocca, gmail: garbagecat10.
+#
+# This program is free software.
+# You may re-distribute and/or modify this program under the same terms
+# as Ruby itself: Ruby Distribution License or GNU General Public License.
+#
+#
+# See Net::LDAP for documentation and usage samples.
+#
+
+
+require 'socket'
+require 'ostruct'
+
+begin
+ require 'openssl'
+ $net_ldap_openssl_available = true
+rescue LoadError
+end
+
+require 'net/ber'
+require 'net/ldap/pdu'
+require 'net/ldap/filter'
+require 'net/ldap/dataset'
+require 'net/ldap/psw'
+require 'net/ldap/entry'
+
+
+module Net
+
+
+ # == Net::LDAP
+ #
+ # This library provides a pure-Ruby implementation of the
+ # LDAP client protocol, per RFC-2251.
+ # It can be used to access any server which implements the
+ # LDAP protocol.
+ #
+ # Net::LDAP is intended to provide full LDAP functionality
+ # while hiding the more arcane aspects
+ # the LDAP protocol itself, and thus presenting as Ruby-like
+ # a programming interface as possible.
+ #
+ # == Quick-start for the Impatient
+ # === Quick Example of a user-authentication against an LDAP directory:
+ #
+ # require 'rubygems'
+ # require 'net/ldap'
+ #
+ # ldap = Net::LDAP.new
+ # ldap.host = your_server_ip_address
+ # ldap.port = 389
+ # ldap.auth "joe_user", "opensesame"
+ # if ldap.bind
+ # # authentication succeeded
+ # else
+ # # authentication failed
+ # end
+ #
+ #
+ # === Quick Example of a search against an LDAP directory:
+ #
+ # require 'rubygems'
+ # require 'net/ldap'
+ #
+ # ldap = Net::LDAP.new :host => server_ip_address,
+ # :port => 389,
+ # :auth => {
+ # :method => :simple,
+ # :username => "cn=manager,dc=example,dc=com",
+ # :password => "opensesame"
+ # }
+ #
+ # filter = Net::LDAP::Filter.eq( "cn", "George*" )
+ # treebase = "dc=example,dc=com"
+ #
+ # ldap.search( :base => treebase, :filter => filter ) do |entry|
+ # puts "DN: #{entry.dn}"
+ # entry.each do |attribute, values|
+ # puts " #{attribute}:"
+ # values.each do |value|
+ # puts " --->#{value}"
+ # end
+ # end
+ # end
+ #
+ # p ldap.get_operation_result
+ #
+ #
+ # == A Brief Introduction to LDAP
+ #
+ # We're going to provide a quick, informal introduction to LDAP
+ # terminology and
+ # typical operations. If you're comfortable with this material, skip
+ # ahead to "How to use Net::LDAP." If you want a more rigorous treatment
+ # of this material, we recommend you start with the various IETF and ITU
+ # standards that relate to LDAP.
+ #
+ # === Entities
+ # LDAP is an Internet-standard protocol used to access directory servers.
+ # The basic search unit is the entity, which corresponds to
+ # a person or other domain-specific object.
+ # A directory service which supports the LDAP protocol typically
+ # stores information about a number of entities.
+ #
+ # === Principals
+ # LDAP servers are typically used to access information about people,
+ # but also very often about such items as printers, computers, and other
+ # resources. To reflect this, LDAP uses the term entity, or less
+ # commonly, principal, to denote its basic data-storage unit.
+ #
+ #
+ # === Distinguished Names
+ # In LDAP's view of the world,
+ # an entity is uniquely identified by a globally-unique text string
+ # called a Distinguished Name, originally defined in the X.400
+ # standards from which LDAP is ultimately derived.
+ # Much like a DNS hostname, a DN is a "flattened" text representation
+ # of a string of tree nodes. Also like DNS (and unlike Java package
+ # names), a DN expresses a chain of tree-nodes written from left to right
+ # in order from the most-resolved node to the most-general one.
+ #
+ # If you know the DN of a person or other entity, then you can query
+ # an LDAP-enabled directory for information (attributes) about the entity.
+ # Alternatively, you can query the directory for a list of DNs matching
+ # a set of criteria that you supply.
+ #
+ # === Attributes
+ #
+ # In the LDAP view of the world, a DN uniquely identifies an entity.
+ # Information about the entity is stored as a set of Attributes.
+ # An attribute is a text string which is associated with zero or more
+ # values. Most LDAP-enabled directories store a well-standardized
+ # range of attributes, and constrain their values according to standard
+ # rules.
+ #
+ # A good example of an attribute is sn, which stands for "Surname."
+ # This attribute is generally used to store a person's surname, or last name.
+ # Most directories enforce the standard convention that
+ # an entity's sn attribute have exactly one value. In LDAP
+ # jargon, that means that sn must be present and
+ # single-valued.
+ #
+ # Another attribute is mail, which is used to store email addresses.
+ # (No, there is no attribute called "email," perhaps because X.400 terminology
+ # predates the invention of the term email. ) mail differs
+ # from sn in that most directories permit any number of values for the
+ # mail attribute, including zero.
+ #
+ #
+ # === Tree-Base
+ # We said above that X.400 Distinguished Names are globally unique.
+ # In a manner reminiscent of DNS, LDAP supposes that each directory server
+ # contains authoritative attribute data for a set of DNs corresponding
+ # to a specific sub-tree of the (notional) global directory tree.
+ # This subtree is generally configured into a directory server when it is
+ # created. It matters for this discussion because most servers will not
+ # allow you to query them unless you specify a correct tree-base.
+ #
+ # Let's say you work for the engineering department of Big Company, Inc.,
+ # whose internet domain is bigcompany.com. You may find that your departmental
+ # directory is stored in a server with a defined tree-base of
+ # ou=engineering,dc=bigcompany,dc=com
+ # You will need to supply this string as the tree-base when querying this
+ # directory. (Ou is a very old X.400 term meaning "organizational unit."
+ # Dc is a more recent term meaning "domain component.")
+ #
+ # === LDAP Versions
+ # (stub, discuss v2 and v3)
+ #
+ # === LDAP Operations
+ # The essential operations are: #bind, #search, #add, #modify, #delete, and #rename.
+ # ==== Bind
+ # #bind supplies a user's authentication credentials to a server, which in turn verifies
+ # or rejects them. There is a range of possibilities for credentials, but most directories
+ # support a simple username and password authentication.
+ #
+ # Taken by itself, #bind can be used to authenticate a user against information
+ # stored in a directory, for example to permit or deny access to some other resource.
+ # In terms of the other LDAP operations, most directories require a successful #bind to
+ # be performed before the other operations will be permitted. Some servers permit certain
+ # operations to be performed with an "anonymous" binding, meaning that no credentials are
+ # presented by the user. (We're glossing over a lot of platform-specific detail here.)
+ #
+ # ==== Search
+ # Calling #search against the directory involves specifying a treebase, a set of search filters,
+ # and a list of attribute values.
+ # The filters specify ranges of possible values for particular attributes. Multiple
+ # filters can be joined together with AND, OR, and NOT operators.
+ # A server will respond to a #search by returning a list of matching DNs together with a
+ # set of attribute values for each entity, depending on what attributes the search requested.
+ #
+ # ==== Add
+ # #add specifies a new DN and an initial set of attribute values. If the operation
+ # succeeds, a new entity with the corresponding DN and attributes is added to the directory.
+ #
+ # ==== Modify
+ # #modify specifies an entity DN, and a list of attribute operations. #modify is used to change
+ # the attribute values stored in the directory for a particular entity.
+ # #modify may add or delete attributes (which are lists of values) or it change attributes by
+ # adding to or deleting from their values.
+ # Net::LDAP provides three easier methods to modify an entry's attribute values:
+ # #add_attribute, #replace_attribute, and #delete_attribute.
+ #
+ # ==== Delete
+ # #delete specifies an entity DN. If it succeeds, the entity and all its attributes
+ # is removed from the directory.
+ #
+ # ==== Rename (or Modify RDN)
+ # #rename (or #modify_rdn) is an operation added to version 3 of the LDAP protocol. It responds to
+ # the often-arising need to change the DN of an entity without discarding its attribute values.
+ # In earlier LDAP versions, the only way to do this was to delete the whole entity and add it
+ # again with a different DN.
+ #
+ # #rename works by taking an "old" DN (the one to change) and a "new RDN," which is the left-most
+ # part of the DN string. If successful, #rename changes the entity DN so that its left-most
+ # node corresponds to the new RDN given in the request. (RDN, or "relative distinguished name,"
+ # denotes a single tree-node as expressed in a DN, which is a chain of tree nodes.)
+ #
+ # == How to use Net::LDAP
+ #
+ # To access Net::LDAP functionality in your Ruby programs, start by requiring
+ # the library:
+ #
+ # require 'net/ldap'
+ #
+ # If you installed the Gem version of Net::LDAP, and depending on your version of
+ # Ruby and rubygems, you _may_ also need to require rubygems explicitly:
+ #
+ # require 'rubygems'
+ # require 'net/ldap'
+ #
+ # Most operations with Net::LDAP start by instantiating a Net::LDAP object.
+ # The constructor for this object takes arguments specifying the network location
+ # (address and port) of the LDAP server, and also the binding (authentication)
+ # credentials, typically a username and password.
+ # Given an object of class Net:LDAP, you can then perform LDAP operations by calling
+ # instance methods on the object. These are documented with usage examples below.
+ #
+ # The Net::LDAP library is designed to be very disciplined about how it makes network
+ # connections to servers. This is different from many of the standard native-code
+ # libraries that are provided on most platforms, which share bloodlines with the
+ # original Netscape/Michigan LDAP client implementations. These libraries sought to
+ # insulate user code from the workings of the network. This is a good idea of course,
+ # but the practical effect has been confusing and many difficult bugs have been caused
+ # by the opacity of the native libraries, and their variable behavior across platforms.
+ #
+ # In general, Net::LDAP instance methods which invoke server operations make a connection
+ # to the server when the method is called. They execute the operation (typically binding first)
+ # and then disconnect from the server. The exception is Net::LDAP#open, which makes a connection
+ # to the server and then keeps it open while it executes a user-supplied block. Net::LDAP#open
+ # closes the connection on completion of the block.
+ #
+
+ class LDAP
+
+ class LdapError < Exception; end
+
+ VERSION = "0.0.4"
+
+
+ SearchScope_BaseObject = 0
+ SearchScope_SingleLevel = 1
+ SearchScope_WholeSubtree = 2
+ SearchScopes = [SearchScope_BaseObject, SearchScope_SingleLevel, SearchScope_WholeSubtree]
+
+ AsnSyntax = {
+ :application => {
+ :constructed => {
+ 0 => :array, # BindRequest
+ 1 => :array, # BindResponse
+ 2 => :array, # UnbindRequest
+ 3 => :array, # SearchRequest
+ 4 => :array, # SearchData
+ 5 => :array, # SearchResult
+ 6 => :array, # ModifyRequest
+ 7 => :array, # ModifyResponse
+ 8 => :array, # AddRequest
+ 9 => :array, # AddResponse
+ 10 => :array, # DelRequest
+ 11 => :array, # DelResponse
+ 12 => :array, # ModifyRdnRequest
+ 13 => :array, # ModifyRdnResponse
+ 14 => :array, # CompareRequest
+ 15 => :array, # CompareResponse
+ 16 => :array, # AbandonRequest
+ 19 => :array, # SearchResultReferral
+ 24 => :array, # Unsolicited Notification
+ }
+ },
+ :context_specific => {
+ :primitive => {
+ 0 => :string, # password
+ 1 => :string, # Kerberos v4
+ 2 => :string, # Kerberos v5
+ },
+ :constructed => {
+ 0 => :array, # RFC-2251 Control
+ 3 => :array, # Seach referral
+ }
+ }
+ }
+
+ DefaultHost = "127.0.0.1"
+ DefaultPort = 389
+ DefaultAuth = {:method => :anonymous}
+ DefaultTreebase = "dc=com"
+
+
+ ResultStrings = {
+ 0 => "Success",
+ 1 => "Operations Error",
+ 2 => "Protocol Error",
+ 3 => "Time Limit Exceeded",
+ 4 => "Size Limit Exceeded",
+ 12 => "Unavailable crtical extension",
+ 16 => "No Such Attribute",
+ 17 => "Undefined Attribute Type",
+ 20 => "Attribute or Value Exists",
+ 32 => "No Such Object",
+ 34 => "Invalid DN Syntax",
+ 48 => "Invalid DN Syntax",
+ 48 => "Inappropriate Authentication",
+ 49 => "Invalid Credentials",
+ 50 => "Insufficient Access Rights",
+ 51 => "Busy",
+ 52 => "Unavailable",
+ 53 => "Unwilling to perform",
+ 65 => "Object Class Violation",
+ 68 => "Entry Already Exists"
+ }
+
+
+ module LdapControls
+ PagedResults = "1.2.840.113556.1.4.319" # Microsoft evil from RFC 2696
+ end
+
+
+ #
+ # LDAP::result2string
+ #
+ def LDAP::result2string code # :nodoc:
+ ResultStrings[code] || "unknown result (#{code})"
+ end
+
+
+ attr_accessor :host, :port, :base
+
+
+ # Instantiate an object of type Net::LDAP to perform directory operations.
+ # This constructor takes a Hash containing arguments, all of which are either optional or may be specified later with other methods as described below. The following arguments
+ # are supported:
+ # * :host => the LDAP server's IP-address (default 127.0.0.1)
+ # * :port => the LDAP server's TCP port (default 389)
+ # * :auth => a Hash containing authorization parameters. Currently supported values include:
+ # {:method => :anonymous} and
+ # {:method => :simple, :username => your_user_name, :password => your_password }
+ # The password parameter may be a Proc that returns a String.
+ # * :base => a default treebase parameter for searches performed against the LDAP server. If you don't give this value, then each call to #search must specify a treebase parameter. If you do give this value, then it will be used in subsequent calls to #search that do not specify a treebase. If you give a treebase value in any particular call to #search, that value will override any treebase value you give here.
+ # * :encryption => specifies the encryption to be used in communicating with the LDAP server. The value is either a Hash containing additional parameters, or the Symbol :simple_tls, which is equivalent to specifying the Hash {:method => :simple_tls}. There is a fairly large range of potential values that may be given for this parameter. See #encryption for details.
+ #
+ # Instantiating a Net::LDAP object does not result in network traffic to
+ # the LDAP server. It simply stores the connection and binding parameters in the
+ # object.
+ #
+ def initialize args = {}
+ @host = args[:host] || DefaultHost
+ @port = args[:port] || DefaultPort
+ @verbose = false # Make this configurable with a switch on the class.
+ @auth = args[:auth] || DefaultAuth
+ @base = args[:base] || DefaultTreebase
+ encryption args[:encryption] # may be nil
+
+ if pr = @auth[:password] and pr.respond_to?(:call)
+ @auth[:password] = pr.call
+ end
+
+ # This variable is only set when we are created with LDAP::open.
+ # All of our internal methods will connect using it, or else
+ # they will create their own.
+ @open_connection = nil
+ end
+
+ # Convenience method to specify authentication credentials to the LDAP
+ # server. Currently supports simple authentication requiring
+ # a username and password.
+ #
+ # Observe that on most LDAP servers,
+ # the username is a complete DN. However, with A/D, it's often possible
+ # to give only a user-name rather than a complete DN. In the latter
+ # case, beware that many A/D servers are configured to permit anonymous
+ # (uncredentialled) binding, and will silently accept your binding
+ # as anonymous if you give an unrecognized username. This is not usually
+ # what you want. (See #get_operation_result.)
+ #
+ # Important: The password argument may be a Proc that returns a string.
+ # This makes it possible for you to write client programs that solicit
+ # passwords from users or from other data sources without showing them
+ # in your code or on command lines.
+ #
+ # require 'net/ldap'
+ #
+ # ldap = Net::LDAP.new
+ # ldap.host = server_ip_address
+ # ldap.authenticate "cn=Your Username,cn=Users,dc=example,dc=com", "your_psw"
+ #
+ # Alternatively (with a password block):
+ #
+ # require 'net/ldap'
+ #
+ # ldap = Net::LDAP.new
+ # ldap.host = server_ip_address
+ # psw = proc { your_psw_function }
+ # ldap.authenticate "cn=Your Username,cn=Users,dc=example,dc=com", psw
+ #
+ def authenticate username, password
+ password = password.call if password.respond_to?(:call)
+ @auth = {:method => :simple, :username => username, :password => password}
+ end
+
+ alias_method :auth, :authenticate
+
+ # Convenience method to specify encryption characteristics for connections
+ # to LDAP servers. Called implicitly by #new and #open, but may also be called
+ # by user code if desired.
+ # The single argument is generally a Hash (but see below for convenience alternatives).
+ # This implementation is currently a stub, supporting only a few encryption
+ # alternatives. As additional capabilities are added, more configuration values
+ # will be added here.
+ #
+ # Currently, the only supported argument is {:method => :simple_tls}.
+ # (Equivalently, you may pass the symbol :simple_tls all by itself, without
+ # enclosing it in a Hash.)
+ #
+ # The :simple_tls encryption method encrypts all communications with the LDAP
+ # server.
+ # It completely establishes SSL/TLS encryption with the LDAP server
+ # before any LDAP-protocol data is exchanged.
+ # There is no plaintext negotiation and no special encryption-request controls
+ # are sent to the server.
+ # The :simple_tls option is the simplest, easiest way to encrypt communications
+ # between Net::LDAP and LDAP servers.
+ # It's intended for cases where you have an implicit level of trust in the authenticity
+ # of the LDAP server. No validation of the LDAP server's SSL certificate is
+ # performed. This means that :simple_tls will not produce errors if the LDAP
+ # server's encryption certificate is not signed by a well-known Certification
+ # Authority.
+ # If you get communications or protocol errors when using this option, check
+ # with your LDAP server administrator. Pay particular attention to the TCP port
+ # you are connecting to. It's impossible for an LDAP server to support plaintext
+ # LDAP communications and simple TLS connections on the same port.
+ # The standard TCP port for unencrypted LDAP connections is 389, but the standard
+ # port for simple-TLS encrypted connections is 636. Be sure you are using the
+ # correct port.
+ #
+ # [Note: a future version of Net::LDAP will support the STARTTLS LDAP control,
+ # which will enable encrypted communications on the same TCP port used for
+ # unencrypted connections.]
+ #
+ def encryption args
+ if args == :simple_tls
+ args = {:method => :simple_tls}
+ end
+ @encryption = args
+ end
+
+
+ # #open takes the same parameters as #new. #open makes a network connection to the
+ # LDAP server and then passes a newly-created Net::LDAP object to the caller-supplied block.
+ # Within the block, you can call any of the instance methods of Net::LDAP to
+ # perform operations against the LDAP directory. #open will perform all the
+ # operations in the user-supplied block on the same network connection, which
+ # will be closed automatically when the block finishes.
+ #
+ # # (PSEUDOCODE)
+ # auth = {:method => :simple, :username => username, :password => password}
+ # Net::LDAP.open( :host => ipaddress, :port => 389, :auth => auth ) do |ldap|
+ # ldap.search( ... )
+ # ldap.add( ... )
+ # ldap.modify( ... )
+ # end
+ #
+ def LDAP::open args
+ ldap1 = LDAP.new args
+ ldap1.open {|ldap| yield ldap }
+ end
+
+ # Returns a meaningful result any time after
+ # a protocol operation (#bind, #search, #add, #modify, #rename, #delete)
+ # has completed.
+ # It returns an #OpenStruct containing an LDAP result code (0 means success),
+ # and a human-readable string.
+ # unless ldap.bind
+ # puts "Result: #{ldap.get_operation_result.code}"
+ # puts "Message: #{ldap.get_operation_result.message}"
+ # end
+ #
+ def get_operation_result
+ os = OpenStruct.new
+ if @result
+ os.code = @result
+ else
+ os.code = 0
+ end
+ os.message = LDAP.result2string( os.code )
+ os
+ end
+
+
+ # Opens a network connection to the server and then
+ # passes self to the caller-supplied block. The connection is
+ # closed when the block completes. Used for executing multiple
+ # LDAP operations without requiring a separate network connection
+ # (and authentication) for each one.
+ # Note: You do not need to log-in or "bind" to the server. This will
+ # be done for you automatically.
+ # For an even simpler approach, see the class method Net::LDAP#open.
+ #
+ # # (PSEUDOCODE)
+ # auth = {:method => :simple, :username => username, :password => password}
+ # ldap = Net::LDAP.new( :host => ipaddress, :port => 389, :auth => auth )
+ # ldap.open do |ldap|
+ # ldap.search( ... )
+ # ldap.add( ... )
+ # ldap.modify( ... )
+ # end
+ #--
+ # First we make a connection and then a binding, but we don't
+ # do anything with the bind results.
+ # We then pass self to the caller's block, where he will execute
+ # his LDAP operations. Of course they will all generate auth failures
+ # if the bind was unsuccessful.
+ def open
+ raise LdapError.new( "open already in progress" ) if @open_connection
+ @open_connection = Connection.new( :host => @host, :port => @port, :encryption => @encryption )
+ @open_connection.bind @auth
+ yield self
+ @open_connection.close
+ @open_connection = nil
+ end
+
+
+ # Searches the LDAP directory for directory entries.
+ # Takes a hash argument with parameters. Supported parameters include:
+ # * :base (a string specifying the tree-base for the search);
+ # * :filter (an object of type Net::LDAP::Filter, defaults to objectclass=*);
+ # * :attributes (a string or array of strings specifying the LDAP attributes to return from the server);
+ # * :return_result (a boolean specifying whether to return a result set).
+ # * :attributes_only (a boolean flag, defaults false)
+ # * :scope (one of: Net::LDAP::SearchScope_BaseObject, Net::LDAP::SearchScope_SingleLevel, Net::LDAP::SearchScope_WholeSubtree. Default is WholeSubtree.)
+ #
+ # #search queries the LDAP server and passes each entry to the
+ # caller-supplied block, as an object of type Net::LDAP::Entry.
+ # If the search returns 1000 entries, the block will
+ # be called 1000 times. If the search returns no entries, the block will
+ # not be called.
+ #
+ #--
+ # ORIGINAL TEXT, replaced 04May06.
+ # #search returns either a result-set or a boolean, depending on the
+ # value of the :return_result argument. The default behavior is to return
+ # a result set, which is a hash. Each key in the hash is a string specifying
+ # the DN of an entry. The corresponding value for each key is a Net::LDAP::Entry object.
+ # If you request a result set and #search fails with an error, it will return nil.
+ # Call #get_operation_result to get the error information returned by
+ # the LDAP server.
+ #++
+ # #search returns either a result-set or a boolean, depending on the
+ # value of the :return_result argument. The default behavior is to return
+ # a result set, which is an Array of objects of class Net::LDAP::Entry.
+ # If you request a result set and #search fails with an error, it will return nil.
+ # Call #get_operation_result to get the error information returned by
+ # the LDAP server.
+ #
+ # When :return_result => false, #search will
+ # return only a Boolean, to indicate whether the operation succeeded. This can improve performance
+ # with very large result sets, because the library can discard each entry from memory after
+ # your block processes it.
+ #
+ #
+ # treebase = "dc=example,dc=com"
+ # filter = Net::LDAP::Filter.eq( "mail", "a*.com" )
+ # attrs = ["mail", "cn", "sn", "objectclass"]
+ # ldap.search( :base => treebase, :filter => filter, :attributes => attrs, :return_result => false ) do |entry|
+ # puts "DN: #{entry.dn}"
+ # entry.each do |attr, values|
+ # puts ".......#{attr}:"
+ # values.each do |value|
+ # puts " #{value}"
+ # end
+ # end
+ # end
+ #
+ #--
+ # This is a re-implementation of search that replaces the
+ # original one (now renamed searchx and possibly destined to go away).
+ # The difference is that we return a dataset (or nil) from the
+ # call, and pass _each entry_ as it is received from the server
+ # to the caller-supplied block. This will probably make things
+ # far faster as we can do useful work during the network latency
+ # of the search. The downside is that we have no access to the
+ # whole set while processing the blocks, so we can't do stuff
+ # like sort the DNs until after the call completes.
+ # It's also possible that this interacts badly with server timeouts.
+ # We'll have to ensure that something reasonable happens if
+ # the caller has processed half a result set when we throw a timeout
+ # error.
+ # Another important difference is that we return a result set from
+ # this method rather than a T/F indication.
+ # Since this can be very heavy-weight, we define an argument flag
+ # that the caller can set to suppress the return of a result set,
+ # if he's planning to process every entry as it comes from the server.
+ #
+ # REINTERPRETED the result set, 04May06. Originally this was a hash
+ # of entries keyed by DNs. But let's get away from making users
+ # handle DNs. Change it to a plain array. Eventually we may
+ # want to return a Dataset object that delegates to an internal
+ # array, so we can provide sort methods and what-not.
+ #
+ def search args = {}
+ args[:base] ||= @base
+ result_set = (args and args[:return_result] == false) ? nil : []
+
+ if @open_connection
+ @result = @open_connection.search( args ) {|entry|
+ result_set << entry if result_set
+ yield( entry ) if block_given?
+ }
+ else
+ @result = 0
+ conn = Connection.new( :host => @host, :port => @port, :encryption => @encryption )
+ if (@result = conn.bind( args[:auth] || @auth )) == 0
+ @result = conn.search( args ) {|entry|
+ result_set << entry if result_set
+ yield( entry ) if block_given?
+ }
+ end
+ conn.close
+ end
+
+ @result == 0 and result_set
+ end
+
+ # #bind connects to an LDAP server and requests authentication
+ # based on the :auth parameter passed to #open or #new.
+ # It takes no parameters.
+ #
+ # User code does not need to call #bind directly. It will be called
+ # implicitly by the library whenever you invoke an LDAP operation,
+ # such as #search or #add.
+ #
+ # It is useful, however, to call #bind in your own code when the
+ # only operation you intend to perform against the directory is
+ # to validate a login credential. #bind returns true or false
+ # to indicate whether the binding was successful. Reasons for
+ # failure include malformed or unrecognized usernames and
+ # incorrect passwords. Use #get_operation_result to find out
+ # what happened in case of failure.
+ #
+ # Here's a typical example using #bind to authenticate a
+ # credential which was (perhaps) solicited from the user of a
+ # web site:
+ #
+ # require 'net/ldap'
+ # ldap = Net::LDAP.new
+ # ldap.host = your_server_ip_address
+ # ldap.port = 389
+ # ldap.auth your_user_name, your_user_password
+ # if ldap.bind
+ # # authentication succeeded
+ # else
+ # # authentication failed
+ # p ldap.get_operation_result
+ # end
+ #
+ # You don't have to create a new instance of Net::LDAP every time
+ # you perform a binding in this way. If you prefer, you can cache the Net::LDAP object
+ # and re-use it to perform subsequent bindings, provided you call
+ # #auth to specify a new credential before calling #bind. Otherwise, you'll
+ # just re-authenticate the previous user! (You don't need to re-set
+ # the values of #host and #port.) As noted in the documentation for #auth,
+ # the password parameter can be a Ruby Proc instead of a String.
+ #
+ #--
+ # If there is an @open_connection, then perform the bind
+ # on it. Otherwise, connect, bind, and disconnect.
+ # The latter operation is obviously useful only as an auth check.
+ #
+ def bind auth=@auth
+ if @open_connection
+ @result = @open_connection.bind auth
+ else
+ conn = Connection.new( :host => @host, :port => @port , :encryption => @encryption)
+ @result = conn.bind @auth
+ conn.close
+ end
+
+ @result == 0
+ end
+
+ #
+ # #bind_as is for testing authentication credentials.
+ #
+ # As described under #bind, most LDAP servers require that you supply a complete DN
+ # as a binding-credential, along with an authenticator such as a password.
+ # But for many applications (such as authenticating users to a Rails application),
+ # you often don't have a full DN to identify the user. You usually get a simple
+ # identifier like a username or an email address, along with a password.
+ # #bind_as allows you to authenticate these user-identifiers.
+ #
+ # #bind_as is a combination of a search and an LDAP binding. First, it connects and
+ # binds to the directory as normal. Then it searches the directory for an entry
+ # corresponding to the email address, username, or other string that you supply.
+ # If the entry exists, then #bind_as will re-bind as that user with the
+ # password (or other authenticator) that you supply.
+ #
+ # #bind_as takes the same parameters as #search, with the addition of an
+ # authenticator. Currently, this authenticator must be :password .
+ # Its value may be either a String, or a +proc+ that returns a String.
+ # #bind_as returns +false+ on failure. On success, it returns a result set,
+ # just as #search does. This result set is an Array of objects of
+ # type Net::LDAP::Entry. It contains the directory attributes corresponding to
+ # the user. (Just test whether the return value is logically true, if you don't
+ # need this additional information.)
+ #
+ # Here's how you would use #bind_as to authenticate an email address and password:
+ #
+ # require 'net/ldap'
+ #
+ # user,psw = "joe_user@yourcompany.com", "joes_psw"
+ #
+ # ldap = Net::LDAP.new
+ # ldap.host = "192.168.0.100"
+ # ldap.port = 389
+ # ldap.auth "cn=manager,dc=yourcompany,dc=com", "topsecret"
+ #
+ # result = ldap.bind_as(
+ # :base => "dc=yourcompany,dc=com",
+ # :filter => "(mail=#{user})",
+ # :password => psw
+ # )
+ # if result
+ # puts "Authenticated #{result.first.dn}"
+ # else
+ # puts "Authentication FAILED."
+ # end
+ def bind_as args={}
+ result = false
+ open {|me|
+ rs = search args
+ if rs and rs.first and dn = rs.first.dn
+ password = args[:password]
+ password = password.call if password.respond_to?(:call)
+ result = rs if bind :method => :simple, :username => dn, :password => password
+ end
+ }
+ result
+ end
+
+
+ # Adds a new entry to the remote LDAP server.
+ # Supported arguments:
+ # :dn :: Full DN of the new entry
+ # :attributes :: Attributes of the new entry.
+ #
+ # The attributes argument is supplied as a Hash keyed by Strings or Symbols
+ # giving the attribute name, and mapping to Strings or Arrays of Strings
+ # giving the actual attribute values. Observe that most LDAP directories
+ # enforce schema constraints on the attributes contained in entries.
+ # #add will fail with a server-generated error if your attributes violate
+ # the server-specific constraints.
+ # Here's an example:
+ #
+ # dn = "cn=George Smith,ou=people,dc=example,dc=com"
+ # attr = {
+ # :cn => "George Smith",
+ # :objectclass => ["top", "inetorgperson"],
+ # :sn => "Smith",
+ # :mail => "gsmith@example.com"
+ # }
+ # Net::LDAP.open (:host => host) do |ldap|
+ # ldap.add( :dn => dn, :attributes => attr )
+ # end
+ #
+ def add args
+ if @open_connection
+ @result = @open_connection.add( args )
+ else
+ @result = 0
+ conn = Connection.new( :host => @host, :port => @port, :encryption => @encryption)
+ if (@result = conn.bind( args[:auth] || @auth )) == 0
+ @result = conn.add( args )
+ end
+ conn.close
+ end
+ @result == 0
+ end
+
+
+ # Modifies the attribute values of a particular entry on the LDAP directory.
+ # Takes a hash with arguments. Supported arguments are:
+ # :dn :: (the full DN of the entry whose attributes are to be modified)
+ # :operations :: (the modifications to be performed, detailed next)
+ #
+ # This method returns True or False to indicate whether the operation
+ # succeeded or failed, with extended information available by calling
+ # #get_operation_result.
+ #
+ # Also see #add_attribute, #replace_attribute, or #delete_attribute, which
+ # provide simpler interfaces to this functionality.
+ #
+ # The LDAP protocol provides a full and well thought-out set of operations
+ # for changing the values of attributes, but they are necessarily somewhat complex
+ # and not always intuitive. If these instructions are confusing or incomplete,
+ # please send us email or create a bug report on rubyforge.
+ #
+ # The :operations parameter to #modify takes an array of operation-descriptors.
+ # Each individual operation is specified in one element of the array, and
+ # most LDAP servers will attempt to perform the operations in order.
+ #
+ # Each of the operations appearing in the Array must itself be an Array
+ # with exactly three elements:
+ # an operator:: must be :add, :replace, or :delete
+ # an attribute name:: the attribute name (string or symbol) to modify
+ # a value:: either a string or an array of strings.
+ #
+ # The :add operator will, unsurprisingly, add the specified values to
+ # the specified attribute. If the attribute does not already exist,
+ # :add will create it. Most LDAP servers will generate an error if you
+ # try to add a value that already exists.
+ #
+ # :replace will erase the current value(s) for the specified attribute,
+ # if there are any, and replace them with the specified value(s).
+ #
+ # :delete will remove the specified value(s) from the specified attribute.
+ # If you pass nil, an empty string, or an empty array as the value parameter
+ # to a :delete operation, the _entire_ _attribute_ will be deleted, along
+ # with all of its values.
+ #
+ # For example:
+ #
+ # dn = "mail=modifyme@example.com,ou=people,dc=example,dc=com"
+ # ops = [
+ # [:add, :mail, "aliasaddress@example.com"],
+ # [:replace, :mail, ["newaddress@example.com", "newalias@example.com"]],
+ # [:delete, :sn, nil]
+ # ]
+ # ldap.modify :dn => dn, :operations => ops
+ #
+ # (This example is contrived since you probably wouldn't add a mail
+ # value right before replacing the whole attribute, but it shows that order
+ # of execution matters. Also, many LDAP servers won't let you delete SN
+ # because that would be a schema violation.)
+ #
+ # It's essential to keep in mind that if you specify more than one operation in
+ # a call to #modify, most LDAP servers will attempt to perform all of the operations
+ # in the order you gave them.
+ # This matters because you may specify operations on the
+ # same attribute which must be performed in a certain order.
+ #
+ # Most LDAP servers will _stop_ processing your modifications if one of them
+ # causes an error on the server (such as a schema-constraint violation).
+ # If this happens, you will probably get a result code from the server that
+ # reflects only the operation that failed, and you may or may not get extended
+ # information that will tell you which one failed. #modify has no notion
+ # of an atomic transaction. If you specify a chain of modifications in one
+ # call to #modify, and one of them fails, the preceding ones will usually
+ # not be "rolled back," resulting in a partial update. This is a limitation
+ # of the LDAP protocol, not of Net::LDAP.
+ #
+ # The lack of transactional atomicity in LDAP means that you're usually
+ # better off using the convenience methods #add_attribute, #replace_attribute,
+ # and #delete_attribute, which are are wrappers over #modify. However, certain
+ # LDAP servers may provide concurrency semantics, in which the several operations
+ # contained in a single #modify call are not interleaved with other
+ # modification-requests received simultaneously by the server.
+ # It bears repeating that this concurrency does _not_ imply transactional
+ # atomicity, which LDAP does not provide.
+ #
+ def modify args
+ if @open_connection
+ @result = @open_connection.modify( args )
+ else
+ @result = 0
+ conn = Connection.new( :host => @host, :port => @port, :encryption => @encryption )
+ if (@result = conn.bind( args[:auth] || @auth )) == 0
+ @result = conn.modify( args )
+ end
+ conn.close
+ end
+ @result == 0
+ end
+
+
+ # Add a value to an attribute.
+ # Takes the full DN of the entry to modify,
+ # the name (Symbol or String) of the attribute, and the value (String or
+ # Array). If the attribute does not exist (and there are no schema violations),
+ # #add_attribute will create it with the caller-specified values.
+ # If the attribute already exists (and there are no schema violations), the
+ # caller-specified values will be _added_ to the values already present.
+ #
+ # Returns True or False to indicate whether the operation
+ # succeeded or failed, with extended information available by calling
+ # #get_operation_result. See also #replace_attribute and #delete_attribute.
+ #
+ # dn = "cn=modifyme,dc=example,dc=com"
+ # ldap.add_attribute dn, :mail, "newmailaddress@example.com"
+ #
+ def add_attribute dn, attribute, value
+ modify :dn => dn, :operations => [[:add, attribute, value]]
+ end
+
+ # Replace the value of an attribute.
+ # #replace_attribute can be thought of as equivalent to calling #delete_attribute
+ # followed by #add_attribute. It takes the full DN of the entry to modify,
+ # the name (Symbol or String) of the attribute, and the value (String or
+ # Array). If the attribute does not exist, it will be created with the
+ # caller-specified value(s). If the attribute does exist, its values will be
+ # _discarded_ and replaced with the caller-specified values.
+ #
+ # Returns True or False to indicate whether the operation
+ # succeeded or failed, with extended information available by calling
+ # #get_operation_result. See also #add_attribute and #delete_attribute.
+ #
+ # dn = "cn=modifyme,dc=example,dc=com"
+ # ldap.replace_attribute dn, :mail, "newmailaddress@example.com"
+ #
+ def replace_attribute dn, attribute, value
+ modify :dn => dn, :operations => [[:replace, attribute, value]]
+ end
+
+ # Delete an attribute and all its values.
+ # Takes the full DN of the entry to modify, and the
+ # name (Symbol or String) of the attribute to delete.
+ #
+ # Returns True or False to indicate whether the operation
+ # succeeded or failed, with extended information available by calling
+ # #get_operation_result. See also #add_attribute and #replace_attribute.
+ #
+ # dn = "cn=modifyme,dc=example,dc=com"
+ # ldap.delete_attribute dn, :mail
+ #
+ def delete_attribute dn, attribute
+ modify :dn => dn, :operations => [[:delete, attribute, nil]]
+ end
+
+
+ # Rename an entry on the remote DIS by changing the last RDN of its DN.
+ # _Documentation_ _stub_
+ #
+ def rename args
+ if @open_connection
+ @result = @open_connection.rename( args )
+ else
+ @result = 0
+ conn = Connection.new( :host => @host, :port => @port, :encryption => @encryption )
+ if (@result = conn.bind( args[:auth] || @auth )) == 0
+ @result = conn.rename( args )
+ end
+ conn.close
+ end
+ @result == 0
+ end
+
+ # modify_rdn is an alias for #rename.
+ def modify_rdn args
+ rename args
+ end
+
+ # Delete an entry from the LDAP directory.
+ # Takes a hash of arguments.
+ # The only supported argument is :dn, which must
+ # give the complete DN of the entry to be deleted.
+ # Returns True or False to indicate whether the delete
+ # succeeded. Extended status information is available by
+ # calling #get_operation_result.
+ #
+ # dn = "mail=deleteme@example.com,ou=people,dc=example,dc=com"
+ # ldap.delete :dn => dn
+ #
+ def delete args
+ if @open_connection
+ @result = @open_connection.delete( args )
+ else
+ @result = 0
+ conn = Connection.new( :host => @host, :port => @port, :encryption => @encryption )
+ if (@result = conn.bind( args[:auth] || @auth )) == 0
+ @result = conn.delete( args )
+ end
+ conn.close
+ end
+ @result == 0
+ end
+
+ end # class LDAP
+
+
+
+ class LDAP
+ # This is a private class used internally by the library. It should not be called by user code.
+ class Connection # :nodoc:
+
+ LdapVersion = 3
+
+
+ #--
+ # initialize
+ #
+ def initialize server
+ begin
+ @conn = TCPsocket.new( server[:host], server[:port] )
+ rescue
+ raise LdapError.new( "no connection to server" )
+ end
+
+ if server[:encryption]
+ setup_encryption server[:encryption]
+ end
+
+ yield self if block_given?
+ end
+
+
+ #--
+ # Helper method called only from new, and only after we have a successfully-opened
+ # @conn instance variable, which is a TCP connection.
+ # Depending on the received arguments, we establish SSL, potentially replacing
+ # the value of @conn accordingly.
+ # Don't generate any errors here if no encryption is requested.
+ # DO raise LdapError objects if encryption is requested and we have trouble setting
+ # it up. That includes if OpenSSL is not set up on the machine. (Question:
+ # how does the Ruby OpenSSL wrapper react in that case?)
+ # DO NOT filter exceptions raised by the OpenSSL library. Let them pass back
+ # to the user. That should make it easier for us to debug the problem reports.
+ # Presumably (hopefully?) that will also produce recognizable errors if someone
+ # tries to use this on a machine without OpenSSL.
+ #
+ # The simple_tls method is intended as the simplest, stupidest, easiest solution
+ # for people who want nothing more than encrypted comms with the LDAP server.
+ # It doesn't do any server-cert validation and requires nothing in the way
+ # of key files and root-cert files, etc etc.
+ # OBSERVE: WE REPLACE the value of @conn, which is presumed to be a connected
+ # TCPsocket object.
+ #
+ def setup_encryption args
+ case args[:method]
+ when :simple_tls
+ raise LdapError.new("openssl unavailable") unless $net_ldap_openssl_available
+ ctx = OpenSSL::SSL::SSLContext.new
+ @conn = OpenSSL::SSL::SSLSocket.new(@conn, ctx)
+ @conn.connect
+ @conn.sync_close = true
+ # additional branches requiring server validation and peer certs, etc. go here.
+ else
+ raise LdapError.new( "unsupported encryption method #{args[:method]}" )
+ end
+ end
+
+ #--
+ # close
+ # This is provided as a convenience method to make
+ # sure a connection object gets closed without waiting
+ # for a GC to happen. Clients shouldn't have to call it,
+ # but perhaps it will come in handy someday.
+ def close
+ @conn.close
+ @conn = nil
+ end
+
+ #--
+ # next_msgid
+ #
+ def next_msgid
+ @msgid ||= 0
+ @msgid += 1
+ end
+
+
+ #--
+ # bind
+ #
+ def bind auth
+ user,psw = case auth[:method]
+ when :anonymous
+ ["",""]
+ when :simple
+ [auth[:username] || auth[:dn], auth[:password]]
+ end
+ raise LdapError.new( "invalid binding information" ) unless (user && psw)
+
+ msgid = next_msgid.to_ber
+ request = [LdapVersion.to_ber, user.to_ber, psw.to_ber_contextspecific(0)].to_ber_appsequence(0)
+ request_pkt = [msgid, request].to_ber_sequence
+ @conn.write request_pkt
+
+ (be = @conn.read_ber(AsnSyntax) and pdu = Net::LdapPdu.new( be )) or raise LdapError.new( "no bind result" )
+ pdu.result_code
+ end
+
+ #--
+ # search
+ # Alternate implementation, this yields each search entry to the caller
+ # as it are received.
+ # TODO, certain search parameters are hardcoded.
+ # TODO, if we mis-parse the server results or the results are wrong, we can block
+ # forever. That's because we keep reading results until we get a type-5 packet,
+ # which might never come. We need to support the time-limit in the protocol.
+ #--
+ # WARNING: this code substantially recapitulates the searchx method.
+ #
+ # 02May06: Well, I added support for RFC-2696-style paged searches.
+ # This is used on all queries because the extension is marked non-critical.
+ # As far as I know, only A/D uses this, but it's required for A/D. Otherwise
+ # you won't get more than 1000 results back from a query.
+ # This implementation is kindof clunky and should probably be refactored.
+ # Also, is it my imagination, or are A/Ds the slowest directory servers ever???
+ #
+ def search args = {}
+ search_filter = (args && args[:filter]) || Filter.eq( "objectclass", "*" )
+ search_filter = Filter.construct(search_filter) if search_filter.is_a?(String)
+ search_base = (args && args[:base]) || "dc=example,dc=com"
+ search_attributes = ((args && args[:attributes]) || []).map {|attr| attr.to_s.to_ber}
+ return_referrals = args && args[:return_referrals] == true
+
+ attributes_only = (args and args[:attributes_only] == true)
+ scope = args[:scope] || Net::LDAP::SearchScope_WholeSubtree
+ raise LdapError.new( "invalid search scope" ) unless SearchScopes.include?(scope)
+
+ # An interesting value for the size limit would be close to A/D's built-in
+ # page limit of 1000 records, but openLDAP newer than version 2.2.0 chokes
+ # on anything bigger than 126. You get a silent error that is easily visible
+ # by running slapd in debug mode. Go figure.
+ rfc2696_cookie = [126, ""]
+ result_code = 0
+
+ loop {
+ # should collect this into a private helper to clarify the structure
+
+ request = [
+ search_base.to_ber,
+ scope.to_ber_enumerated,
+ 0.to_ber_enumerated,
+ 0.to_ber,
+ 0.to_ber,
+ attributes_only.to_ber,
+ search_filter.to_ber,
+ search_attributes.to_ber_sequence
+ ].to_ber_appsequence(3)
+
+ controls = [
+ [
+ LdapControls::PagedResults.to_ber,
+ false.to_ber, # criticality MUST be false to interoperate with normal LDAPs.
+ rfc2696_cookie.map{|v| v.to_ber}.to_ber_sequence.to_s.to_ber
+ ].to_ber_sequence
+ ].to_ber_contextspecific(0)
+
+ pkt = [next_msgid.to_ber, request, controls].to_ber_sequence
+ @conn.write pkt
+
+ result_code = 0
+ controls = []
+
+ while (be = @conn.read_ber(AsnSyntax)) && (pdu = LdapPdu.new( be ))
+ case pdu.app_tag
+ when 4 # search-data
+ yield( pdu.search_entry ) if block_given?
+ when 19 # search-referral
+ if return_referrals
+ if block_given?
+ se = Net::LDAP::Entry.new
+ se[:search_referrals] = (pdu.search_referrals || [])
+ yield se
+ end
+ end
+ #p pdu.referrals
+ when 5 # search-result
+ result_code = pdu.result_code
+ controls = pdu.result_controls
+ break
+ else
+ raise LdapError.new( "invalid response-type in search: #{pdu.app_tag}" )
+ end
+ end
+
+ # When we get here, we have seen a type-5 response.
+ # If there is no error AND there is an RFC-2696 cookie,
+ # then query again for the next page of results.
+ # If not, we're done.
+ # Don't screw this up or we'll break every search we do.
+ more_pages = false
+ if result_code == 0 and controls
+ controls.each do |c|
+ if c.oid == LdapControls::PagedResults
+ more_pages = false # just in case some bogus server sends us >1 of these.
+ if c.value and c.value.length > 0
+ cookie = c.value.read_ber[1]
+ if cookie and cookie.length > 0
+ rfc2696_cookie[1] = cookie
+ more_pages = true
+ end
+ end
+ end
+ end
+ end
+
+ break unless more_pages
+ } # loop
+
+ result_code
+ end
+
+
+
+
+ #--
+ # modify
+ # TODO, need to support a time limit, in case the server fails to respond.
+ # TODO!!! We're throwing an exception here on empty DN.
+ # Should return a proper error instead, probaby from farther up the chain.
+ # TODO!!! If the user specifies a bogus opcode, we'll throw a
+ # confusing error here ("to_ber_enumerated is not defined on nil").
+ #
+ def modify args
+ modify_dn = args[:dn] or raise "Unable to modify empty DN"
+ modify_ops = []
+ a = args[:operations] and a.each {|op, attr, values|
+ # TODO, fix the following line, which gives a bogus error
+ # if the opcode is invalid.
+ op_1 = {:add => 0, :delete => 1, :replace => 2} [op.to_sym].to_ber_enumerated
+ modify_ops << [op_1, [attr.to_s.to_ber, values.to_a.map {|v| v.to_ber}.to_ber_set].to_ber_sequence].to_ber_sequence
+ }
+
+ request = [modify_dn.to_ber, modify_ops.to_ber_sequence].to_ber_appsequence(6)
+ pkt = [next_msgid.to_ber, request].to_ber_sequence
+ @conn.write pkt
+
+ (be = @conn.read_ber(AsnSyntax)) && (pdu = LdapPdu.new( be )) && (pdu.app_tag == 7) or raise LdapError.new( "response missing or invalid" )
+ pdu.result_code
+ end
+
+
+ #--
+ # add
+ # TODO, need to support a time limit, in case the server fails to respond.
+ #
+ def add args
+ add_dn = args[:dn] or raise LdapError.new("Unable to add empty DN")
+ add_attrs = []
+ a = args[:attributes] and a.each {|k,v|
+ add_attrs << [ k.to_s.to_ber, v.to_a.map {|m| m.to_ber}.to_ber_set ].to_ber_sequence
+ }
+
+ request = [add_dn.to_ber, add_attrs.to_ber_sequence].to_ber_appsequence(8)
+ pkt = [next_msgid.to_ber, request].to_ber_sequence
+ @conn.write pkt
+
+ (be = @conn.read_ber(AsnSyntax)) && (pdu = LdapPdu.new( be )) && (pdu.app_tag == 9) or raise LdapError.new( "response missing or invalid" )
+ pdu.result_code
+ end
+
+
+ #--
+ # rename
+ # TODO, need to support a time limit, in case the server fails to respond.
+ #
+ def rename args
+ old_dn = args[:olddn] or raise "Unable to rename empty DN"
+ new_rdn = args[:newrdn] or raise "Unable to rename to empty RDN"
+ delete_attrs = args[:delete_attributes] ? true : false
+
+ request = [old_dn.to_ber, new_rdn.to_ber, delete_attrs.to_ber].to_ber_appsequence(12)
+ pkt = [next_msgid.to_ber, request].to_ber_sequence
+ @conn.write pkt
+
+ (be = @conn.read_ber(AsnSyntax)) && (pdu = LdapPdu.new( be )) && (pdu.app_tag == 13) or raise LdapError.new( "response missing or invalid" )
+ pdu.result_code
+ end
+
+
+ #--
+ # delete
+ # TODO, need to support a time limit, in case the server fails to respond.
+ #
+ def delete args
+ dn = args[:dn] or raise "Unable to delete empty DN"
+
+ request = dn.to_s.to_ber_application_string(10)
+ pkt = [next_msgid.to_ber, request].to_ber_sequence
+ @conn.write pkt
+
+ (be = @conn.read_ber(AsnSyntax)) && (pdu = LdapPdu.new( be )) && (pdu.app_tag == 11) or raise LdapError.new( "response missing or invalid" )
+ pdu.result_code
+ end
+
+
+ end # class Connection
+ end # class LDAP
+
+
+end # module Net
+
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/dataset.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/dataset.rb
new file mode 100644
index 000000000..1480a8f84
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/dataset.rb
@@ -0,0 +1,108 @@
+# $Id: dataset.rb 78 2006-04-26 02:57:34Z blackhedd $
+#
+#
+#----------------------------------------------------------------------------
+#
+# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
+#
+# Gmail: garbagecat10
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#---------------------------------------------------------------------------
+#
+#
+
+
+
+
+module Net
+class LDAP
+
+class Dataset < Hash
+
+ attr_reader :comments
+
+
+ def Dataset::read_ldif io
+ ds = Dataset.new
+
+ line = io.gets && chomp
+ dn = nil
+
+ while line
+ io.gets and chomp
+ if $_ =~ /^[\s]+/
+ line << " " << $'
+ else
+ nextline = $_
+
+ if line =~ /^\#/
+ ds.comments << line
+ elsif line =~ /^dn:[\s]*/i
+ dn = $'
+ ds[dn] = Hash.new {|k,v| k[v] = []}
+ elsif line.length == 0
+ dn = nil
+ elsif line =~ /^([^:]+):([\:]?)[\s]*/
+ # $1 is the attribute name
+ # $2 is a colon iff the attr-value is base-64 encoded
+ # $' is the attr-value
+ # Avoid the Base64 class because not all Ruby versions have it.
+ attrvalue = ($2 == ":") ? $'.unpack('m').shift : $'
+ ds[dn][$1.downcase.intern] << attrvalue
+ end
+
+ line = nextline
+ end
+ end
+
+ ds
+ end
+
+
+ def initialize
+ @comments = []
+ end
+
+
+ def to_ldif
+ ary = []
+ ary += (@comments || [])
+
+ keys.sort.each {|dn|
+ ary << "dn: #{dn}"
+
+ self[dn].keys.map {|sym| sym.to_s}.sort.each {|attr|
+ self[dn][attr.intern].each {|val|
+ ary << "#{attr}: #{val}"
+ }
+ }
+
+ ary << ""
+ }
+
+ block_given? and ary.each {|line| yield line}
+
+ ary
+ end
+
+
+end # Dataset
+
+end # LDAP
+end # Net
+
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/entry.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/entry.rb
new file mode 100644
index 000000000..8978545ee
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/entry.rb
@@ -0,0 +1,165 @@
+# $Id: entry.rb 123 2006-05-18 03:52:38Z blackhedd $
+#
+# LDAP Entry (search-result) support classes
+#
+#
+#----------------------------------------------------------------------------
+#
+# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
+#
+# Gmail: garbagecat10
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#---------------------------------------------------------------------------
+#
+
+
+
+
+module Net
+class LDAP
+
+
+ # Objects of this class represent individual entries in an LDAP
+ # directory. User code generally does not instantiate this class.
+ # Net::LDAP#search provides objects of this class to user code,
+ # either as block parameters or as return values.
+ #
+ # In LDAP-land, an "entry" is a collection of attributes that are
+ # uniquely and globally identified by a DN ("Distinguished Name").
+ # Attributes are identified by short, descriptive words or phrases.
+ # Although a directory is
+ # free to implement any attribute name, most of them follow rigorous
+ # standards so that the range of commonly-encountered attribute
+ # names is not large.
+ #
+ # An attribute name is case-insensitive. Most directories also
+ # restrict the range of characters allowed in attribute names.
+ # To simplify handling attribute names, Net::LDAP::Entry
+ # internally converts them to a standard format. Therefore, the
+ # methods which take attribute names can take Strings or Symbols,
+ # and work correctly regardless of case or capitalization.
+ #
+ # An attribute consists of zero or more data items called
+ # values. An entry is the combination of a unique DN, a set of attribute
+ # names, and a (possibly-empty) array of values for each attribute.
+ #
+ # Class Net::LDAP::Entry provides convenience methods for dealing
+ # with LDAP entries.
+ # In addition to the methods documented below, you may access individual
+ # attributes of an entry simply by giving the attribute name as
+ # the name of a method call. For example:
+ # ldap.search( ... ) do |entry|
+ # puts "Common name: #{entry.cn}"
+ # puts "Email addresses:"
+ # entry.mail.each {|ma| puts ma}
+ # end
+ # If you use this technique to access an attribute that is not present
+ # in a particular Entry object, a NoMethodError exception will be raised.
+ #
+ #--
+ # Ugly problem to fix someday: We key off the internal hash with
+ # a canonical form of the attribute name: convert to a string,
+ # downcase, then take the symbol. Unfortunately we do this in
+ # at least three places. Should do it in ONE place.
+ class Entry
+
+ # This constructor is not generally called by user code.
+ def initialize dn = nil # :nodoc:
+ @myhash = Hash.new {|k,v| k[v] = [] }
+ @myhash[:dn] = [dn]
+ end
+
+
+ def []= name, value # :nodoc:
+ sym = name.to_s.downcase.intern
+ @myhash[sym] = value
+ end
+
+
+ #--
+ # We have to deal with this one as we do with []=
+ # because this one and not the other one gets called
+ # in formulations like entry["CN"] << cn.
+ #
+ def [] name # :nodoc:
+ name = name.to_s.downcase.intern unless name.is_a?(Symbol)
+ @myhash[name]
+ end
+
+ # Returns the dn of the Entry as a String.
+ def dn
+ self[:dn][0]
+ end
+
+ # Returns an array of the attribute names present in the Entry.
+ def attribute_names
+ @myhash.keys
+ end
+
+ # Accesses each of the attributes present in the Entry.
+ # Calls a user-supplied block with each attribute in turn,
+ # passing two arguments to the block: a Symbol giving
+ # the name of the attribute, and a (possibly empty)
+ # Array of data values.
+ #
+ def each
+ if block_given?
+ attribute_names.each {|a|
+ attr_name,values = a,self[a]
+ yield attr_name, values
+ }
+ end
+ end
+
+ alias_method :each_attribute, :each
+
+
+ #--
+ # Convenience method to convert unknown method names
+ # to attribute references. Of course the method name
+ # comes to us as a symbol, so let's save a little time
+ # and not bother with the to_s.downcase two-step.
+ # Of course that means that a method name like mAIL
+ # won't work, but we shouldn't be encouraging that
+ # kind of bad behavior in the first place.
+ # Maybe we should thow something if the caller sends
+ # arguments or a block...
+ #
+ def method_missing *args, &block # :nodoc:
+ s = args[0].to_s.downcase.intern
+ if attribute_names.include?(s)
+ self[s]
+ elsif s.to_s[-1] == 61 and s.to_s.length > 1
+ value = args[1] or raise RuntimeError.new( "unable to set value" )
+ value = [value] unless value.is_a?(Array)
+ name = s.to_s[0..-2].intern
+ self[name] = value
+ else
+ raise NoMethodError.new( "undefined method '#{s}'" )
+ end
+ end
+
+ def write
+ end
+
+ end # class Entry
+
+
+end # class LDAP
+end # module Net
+
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/filter.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/filter.rb
new file mode 100644
index 000000000..4d06c26f3
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/filter.rb
@@ -0,0 +1,387 @@
+# $Id: filter.rb 151 2006-08-15 08:34:53Z blackhedd $
+#
+#
+#----------------------------------------------------------------------------
+#
+# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
+#
+# Gmail: garbagecat10
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#---------------------------------------------------------------------------
+#
+#
+
+
+module Net
+class LDAP
+
+
+# Class Net::LDAP::Filter is used to constrain
+# LDAP searches. An object of this class is
+# passed to Net::LDAP#search in the parameter :filter.
+#
+# Net::LDAP::Filter supports the complete set of search filters
+# available in LDAP, including conjunction, disjunction and negation
+# (AND, OR, and NOT). This class supplants the (infamous) RFC-2254
+# standard notation for specifying LDAP search filters.
+#
+# Here's how to code the familiar "objectclass is present" filter:
+# f = Net::LDAP::Filter.pres( "objectclass" )
+# The object returned by this code can be passed directly to
+# the :filter parameter of Net::LDAP#search.
+#
+# See the individual class and instance methods below for more examples.
+#
+class Filter
+
+ def initialize op, a, b
+ @op = op
+ @left = a
+ @right = b
+ end
+
+ # #eq creates a filter object indicating that the value of
+ # a paticular attribute must be either present or must
+ # match a particular string.
+ #
+ # To specify that an attribute is "present" means that only
+ # directory entries which contain a value for the particular
+ # attribute will be selected by the filter. This is useful
+ # in case of optional attributes such as mail.
+ # Presence is indicated by giving the value "*" in the second
+ # parameter to #eq. This example selects only entries that have
+ # one or more values for sAMAccountName:
+ # f = Net::LDAP::Filter.eq( "sAMAccountName", "*" )
+ #
+ # To match a particular range of values, pass a string as the
+ # second parameter to #eq. The string may contain one or more
+ # "*" characters as wildcards: these match zero or more occurrences
+ # of any character. Full regular-expressions are not supported
+ # due to limitations in the underlying LDAP protocol.
+ # This example selects any entry with a mail value containing
+ # the substring "anderson":
+ # f = Net::LDAP::Filter.eq( "mail", "*anderson*" )
+ #--
+ # Removed gt and lt. They ain't in the standard!
+ #
+ def Filter::eq attribute, value; Filter.new :eq, attribute, value; end
+ def Filter::ne attribute, value; Filter.new :ne, attribute, value; end
+ #def Filter::gt attribute, value; Filter.new :gt, attribute, value; end
+ #def Filter::lt attribute, value; Filter.new :lt, attribute, value; end
+ def Filter::ge attribute, value; Filter.new :ge, attribute, value; end
+ def Filter::le attribute, value; Filter.new :le, attribute, value; end
+
+ # #pres( attribute ) is a synonym for #eq( attribute, "*" )
+ #
+ def Filter::pres attribute; Filter.eq attribute, "*"; end
+
+ # operator & ("AND") is used to conjoin two or more filters.
+ # This expression will select only entries that have an objectclass
+ # attribute AND have a mail attribute that begins with "George":
+ # f = Net::LDAP::Filter.pres( "objectclass" ) & Net::LDAP::Filter.eq( "mail", "George*" )
+ #
+ def & filter; Filter.new :and, self, filter; end
+
+ # operator | ("OR") is used to disjoin two or more filters.
+ # This expression will select entries that have either an objectclass
+ # attribute OR a mail attribute that begins with "George":
+ # f = Net::LDAP::Filter.pres( "objectclass" ) | Net::LDAP::Filter.eq( "mail", "George*" )
+ #
+ def | filter; Filter.new :or, self, filter; end
+
+
+ #
+ # operator ~ ("NOT") is used to negate a filter.
+ # This expression will select only entries that do not have an objectclass
+ # attribute:
+ # f = ~ Net::LDAP::Filter.pres( "objectclass" )
+ #
+ #--
+ # This operator can't be !, evidently. Try it.
+ # Removed GT and LT. They're not in the RFC.
+ def ~@; Filter.new :not, self, nil; end
+
+
+ def to_s
+ case @op
+ when :ne
+ "(!(#{@left}=#{@right}))"
+ when :eq
+ "(#{@left}=#{@right})"
+ #when :gt
+ # "#{@left}>#{@right}"
+ #when :lt
+ # "#{@left}<#{@right}"
+ when :ge
+ "#{@left}>=#{@right}"
+ when :le
+ "#{@left}<=#{@right}"
+ when :and
+ "(&(#{@left})(#{@right}))"
+ when :or
+ "(|(#{@left})(#{@right}))"
+ when :not
+ "(!(#{@left}))"
+ else
+ raise "invalid or unsupported operator in LDAP Filter"
+ end
+ end
+
+
+ #--
+ # to_ber
+ # Filter ::=
+ # CHOICE {
+ # and [0] SET OF Filter,
+ # or [1] SET OF Filter,
+ # not [2] Filter,
+ # equalityMatch [3] AttributeValueAssertion,
+ # substrings [4] SubstringFilter,
+ # greaterOrEqual [5] AttributeValueAssertion,
+ # lessOrEqual [6] AttributeValueAssertion,
+ # present [7] AttributeType,
+ # approxMatch [8] AttributeValueAssertion
+ # }
+ #
+ # SubstringFilter
+ # SEQUENCE {
+ # type AttributeType,
+ # SEQUENCE OF CHOICE {
+ # initial [0] LDAPString,
+ # any [1] LDAPString,
+ # final [2] LDAPString
+ # }
+ # }
+ #
+ # Parsing substrings is a little tricky.
+ # We use the split method to break a string into substrings
+ # delimited by the * (star) character. But we also need
+ # to know whether there is a star at the head and tail
+ # of the string. A Ruby particularity comes into play here:
+ # if you split on * and the first character of the string is
+ # a star, then split will return an array whose first element
+ # is an _empty_ string. But if the _last_ character of the
+ # string is star, then split will return an array that does
+ # _not_ add an empty string at the end. So we have to deal
+ # with all that specifically.
+ #
+ def to_ber
+ case @op
+ when :eq
+ if @right == "*" # present
+ @left.to_s.to_ber_contextspecific 7
+ elsif @right =~ /[\*]/ #substring
+ ary = @right.split( /[\*]+/ )
+ final_star = @right =~ /[\*]$/
+ initial_star = ary.first == "" and ary.shift
+
+ seq = []
+ unless initial_star
+ seq << ary.shift.to_ber_contextspecific(0)
+ end
+ n_any_strings = ary.length - (final_star ? 0 : 1)
+ #p n_any_strings
+ n_any_strings.times {
+ seq << ary.shift.to_ber_contextspecific(1)
+ }
+ unless final_star
+ seq << ary.shift.to_ber_contextspecific(2)
+ end
+ [@left.to_s.to_ber, seq.to_ber].to_ber_contextspecific 4
+ else #equality
+ [@left.to_s.to_ber, @right.to_ber].to_ber_contextspecific 3
+ end
+ when :ge
+ [@left.to_s.to_ber, @right.to_ber].to_ber_contextspecific 5
+ when :le
+ [@left.to_s.to_ber, @right.to_ber].to_ber_contextspecific 6
+ when :and
+ ary = [@left.coalesce(:and), @right.coalesce(:and)].flatten
+ ary.map {|a| a.to_ber}.to_ber_contextspecific( 0 )
+ when :or
+ ary = [@left.coalesce(:or), @right.coalesce(:or)].flatten
+ ary.map {|a| a.to_ber}.to_ber_contextspecific( 1 )
+ when :not
+ [@left.to_ber].to_ber_contextspecific 2
+ else
+ # ERROR, we'll return objectclass=* to keep things from blowing up,
+ # but that ain't a good answer and we need to kick out an error of some kind.
+ raise "unimplemented search filter"
+ end
+ end
+
+ #--
+ # coalesce
+ # This is a private helper method for dealing with chains of ANDs and ORs
+ # that are longer than two. If BOTH of our branches are of the specified
+ # type of joining operator, then return both of them as an array (calling
+ # coalesce recursively). If they're not, then return an array consisting
+ # only of self.
+ #
+ def coalesce operator
+ if @op == operator
+ [@left.coalesce( operator ), @right.coalesce( operator )]
+ else
+ [self]
+ end
+ end
+
+
+
+ #--
+ # We get a Ruby object which comes from parsing an RFC-1777 "Filter"
+ # object. Convert it to a Net::LDAP::Filter.
+ # TODO, we're hardcoding the RFC-1777 BER-encodings of the various
+ # filter types. Could pull them out into a constant.
+ #
+ def Filter::parse_ldap_filter obj
+ case obj.ber_identifier
+ when 0x87 # present. context-specific primitive 7.
+ Filter.eq( obj.to_s, "*" )
+ when 0xa3 # equalityMatch. context-specific constructed 3.
+ Filter.eq( obj[0], obj[1] )
+ else
+ raise LdapError.new( "unknown ldap search-filter type: #{obj.ber_identifier}" )
+ end
+ end
+
+
+ #--
+ # We got a hash of attribute values.
+ # Do we match the attributes?
+ # Return T/F, and call match recursively as necessary.
+ def match entry
+ case @op
+ when :eq
+ if @right == "*"
+ l = entry[@left] and l.length > 0
+ else
+ l = entry[@left] and l = l.to_a and l.index(@right)
+ end
+ else
+ raise LdapError.new( "unknown filter type in match: #{@op}" )
+ end
+ end
+
+ # Converts an LDAP filter-string (in the prefix syntax specified in RFC-2254)
+ # to a Net::LDAP::Filter.
+ def self.construct ldap_filter_string
+ FilterParser.new(ldap_filter_string).filter
+ end
+
+ # Synonym for #construct.
+ # to a Net::LDAP::Filter.
+ def self.from_rfc2254 ldap_filter_string
+ construct ldap_filter_string
+ end
+
+end # class Net::LDAP::Filter
+
+
+
+class FilterParser #:nodoc:
+
+ attr_reader :filter
+
+ def initialize str
+ require 'strscan'
+ @filter = parse( StringScanner.new( str )) or raise Net::LDAP::LdapError.new( "invalid filter syntax" )
+ end
+
+ def parse scanner
+ parse_filter_branch(scanner) or parse_paren_expression(scanner)
+ end
+
+ def parse_paren_expression scanner
+ if scanner.scan(/\s*\(\s*/)
+ b = if scanner.scan(/\s*\&\s*/)
+ a = nil
+ branches = []
+ while br = parse_paren_expression(scanner)
+ branches << br
+ end
+ if branches.length >= 2
+ a = branches.shift
+ while branches.length > 0
+ a = a & branches.shift
+ end
+ a
+ end
+ elsif scanner.scan(/\s*\|\s*/)
+ # TODO: DRY!
+ a = nil
+ branches = []
+ while br = parse_paren_expression(scanner)
+ branches << br
+ end
+ if branches.length >= 2
+ a = branches.shift
+ while branches.length > 0
+ a = a | branches.shift
+ end
+ a
+ end
+ elsif scanner.scan(/\s*\!\s*/)
+ br = parse_paren_expression(scanner)
+ if br
+ ~ br
+ end
+ else
+ parse_filter_branch( scanner )
+ end
+
+ if b and scanner.scan( /\s*\)\s*/ )
+ b
+ end
+ end
+ end
+
+ # Added a greatly-augmented filter contributed by Andre Nathan
+ # for detecting special characters in values. (15Aug06)
+ def parse_filter_branch scanner
+ scanner.scan(/\s*/)
+ if token = scanner.scan( /[\w\-_]+/ )
+ scanner.scan(/\s*/)
+ if op = scanner.scan( /\=|\<\=|\<|\>\=|\>|\!\=/ )
+ scanner.scan(/\s*/)
+ #if value = scanner.scan( /[\w\*\.]+/ ) (ORG)
+ if value = scanner.scan( /[\w\*\.\+\-@=#\$%&!]+/ )
+ case op
+ when "="
+ Filter.eq( token, value )
+ when "!="
+ Filter.ne( token, value )
+ when "<"
+ Filter.lt( token, value )
+ when "<="
+ Filter.le( token, value )
+ when ">"
+ Filter.gt( token, value )
+ when ">="
+ Filter.ge( token, value )
+ end
+ end
+ end
+ end
+ end
+
+end # class Net::LDAP::FilterParser
+
+end # class Net::LDAP
+end # module Net
+
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/pdu.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/pdu.rb
new file mode 100644
index 000000000..dbc0d6f10
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/pdu.rb
@@ -0,0 +1,205 @@
+# $Id: pdu.rb 126 2006-05-31 15:55:16Z blackhedd $
+#
+# LDAP PDU support classes
+#
+#
+#----------------------------------------------------------------------------
+#
+# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
+#
+# Gmail: garbagecat10
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#---------------------------------------------------------------------------
+#
+
+
+
+module Net
+
+
+class LdapPduError < Exception; end
+
+
+class LdapPdu
+
+ BindResult = 1
+ SearchReturnedData = 4
+ SearchResult = 5
+ ModifyResponse = 7
+ AddResponse = 9
+ DeleteResponse = 11
+ ModifyRDNResponse = 13
+ SearchResultReferral = 19
+
+ attr_reader :msg_id, :app_tag
+ attr_reader :search_dn, :search_attributes, :search_entry
+ attr_reader :search_referrals
+
+ #
+ # initialize
+ # An LDAP PDU always looks like a BerSequence with
+ # at least two elements: an integer (message-id number), and
+ # an application-specific sequence.
+ # Some LDAPv3 packets also include an optional
+ # third element, which is a sequence of "controls"
+ # (See RFC 2251, section 4.1.12).
+ # The application-specific tag in the sequence tells
+ # us what kind of packet it is, and each kind has its
+ # own format, defined in RFC-1777.
+ # Observe that many clients (such as ldapsearch)
+ # do not necessarily enforce the expected application
+ # tags on received protocol packets. This implementation
+ # does interpret the RFC strictly in this regard, and
+ # it remains to be seen whether there are servers out
+ # there that will not work well with our approach.
+ #
+ # Added a controls-processor to SearchResult.
+ # Didn't add it everywhere because it just _feels_
+ # like it will need to be refactored.
+ #
+ def initialize ber_object
+ begin
+ @msg_id = ber_object[0].to_i
+ @app_tag = ber_object[1].ber_identifier - 0x60
+ rescue
+ # any error becomes a data-format error
+ raise LdapPduError.new( "ldap-pdu format error" )
+ end
+
+ case @app_tag
+ when BindResult
+ parse_ldap_result ber_object[1]
+ when SearchReturnedData
+ parse_search_return ber_object[1]
+ when SearchResultReferral
+ parse_search_referral ber_object[1]
+ when SearchResult
+ parse_ldap_result ber_object[1]
+ parse_controls(ber_object[2]) if ber_object[2]
+ when ModifyResponse
+ parse_ldap_result ber_object[1]
+ when AddResponse
+ parse_ldap_result ber_object[1]
+ when DeleteResponse
+ parse_ldap_result ber_object[1]
+ when ModifyRDNResponse
+ parse_ldap_result ber_object[1]
+ else
+ raise LdapPduError.new( "unknown pdu-type: #{@app_tag}" )
+ end
+ end
+
+ #
+ # result_code
+ # This returns an LDAP result code taken from the PDU,
+ # but it will be nil if there wasn't a result code.
+ # That can easily happen depending on the type of packet.
+ #
+ def result_code code = :resultCode
+ @ldap_result and @ldap_result[code]
+ end
+
+ # Return RFC-2251 Controls if any.
+ # Messy. Does this functionality belong somewhere else?
+ def result_controls
+ @ldap_controls || []
+ end
+
+
+ #
+ # parse_ldap_result
+ #
+ def parse_ldap_result sequence
+ sequence.length >= 3 or raise LdapPduError
+ @ldap_result = {:resultCode => sequence[0], :matchedDN => sequence[1], :errorMessage => sequence[2]}
+ end
+ private :parse_ldap_result
+
+ #
+ # parse_search_return
+ # Definition from RFC 1777 (we're handling application-4 here)
+ #
+ # Search Response ::=
+ # CHOICE {
+ # entry [APPLICATION 4] SEQUENCE {
+ # objectName LDAPDN,
+ # attributes SEQUENCE OF SEQUENCE {
+ # AttributeType,
+ # SET OF AttributeValue
+ # }
+ # },
+ # resultCode [APPLICATION 5] LDAPResult
+ # }
+ #
+ # We concoct a search response that is a hash of the returned attribute values.
+ # NOW OBSERVE CAREFULLY: WE ARE DOWNCASING THE RETURNED ATTRIBUTE NAMES.
+ # This is to make them more predictable for user programs, but it
+ # may not be a good idea. Maybe this should be configurable.
+ # ALTERNATE IMPLEMENTATION: In addition to @search_dn and @search_attributes,
+ # we also return @search_entry, which is an LDAP::Entry object.
+ # If that works out well, then we'll remove the first two.
+ #
+ # Provisionally removed obsolete search_attributes and search_dn, 04May06.
+ #
+ def parse_search_return sequence
+ sequence.length >= 2 or raise LdapPduError
+ @search_entry = LDAP::Entry.new( sequence[0] )
+ #@search_dn = sequence[0]
+ #@search_attributes = {}
+ sequence[1].each {|seq|
+ @search_entry[seq[0]] = seq[1]
+ #@search_attributes[seq[0].downcase.intern] = seq[1]
+ }
+ end
+
+ #
+ # A search referral is a sequence of one or more LDAP URIs.
+ # Any number of search-referral replies can be returned by the server, interspersed
+ # with normal replies in any order.
+ # Until I can think of a better way to do this, we'll return the referrals as an array.
+ # It'll be up to higher-level handlers to expose something reasonable to the client.
+ def parse_search_referral uris
+ @search_referrals = uris
+ end
+
+
+ # Per RFC 2251, an LDAP "control" is a sequence of tuples, each consisting
+ # of an OID, a boolean criticality flag defaulting FALSE, and an OPTIONAL
+ # Octet String. If only two fields are given, the second one may be
+ # either criticality or data, since criticality has a default value.
+ # Someday we may want to come back here and add support for some of
+ # more-widely used controls. RFC-2696 is a good example.
+ #
+ def parse_controls sequence
+ @ldap_controls = sequence.map do |control|
+ o = OpenStruct.new
+ o.oid,o.criticality,o.value = control[0],control[1],control[2]
+ if o.criticality and o.criticality.is_a?(String)
+ o.value = o.criticality
+ o.criticality = false
+ end
+ o
+ end
+ end
+ private :parse_controls
+
+
+end
+
+
+end # module Net
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/psw.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/psw.rb
new file mode 100644
index 000000000..89d1ffdf2
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldap/psw.rb
@@ -0,0 +1,64 @@
+# $Id: psw.rb 73 2006-04-24 21:59:35Z blackhedd $
+#
+#
+#----------------------------------------------------------------------------
+#
+# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
+#
+# Gmail: garbagecat10
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#---------------------------------------------------------------------------
+#
+#
+
+
+module Net
+class LDAP
+
+
+class Password
+ class << self
+
+ # Generate a password-hash suitable for inclusion in an LDAP attribute.
+ # Pass a hash type (currently supported: :md5 and :sha) and a plaintext
+ # password. This function will return a hashed representation.
+ # STUB: This is here to fulfill the requirements of an RFC, which one?
+ # TODO, gotta do salted-sha and (maybe) salted-md5.
+ # Should we provide sha1 as a synonym for sha1? I vote no because then
+ # should you also provide ssha1 for symmetry?
+ def generate( type, str )
+ case type
+ when :md5
+ require 'md5'
+ "{MD5}#{ [MD5.new( str.to_s ).digest].pack("m").chomp }"
+ when :sha
+ require 'sha1'
+ "{SHA}#{ [SHA1.new( str.to_s ).digest].pack("m").chomp }"
+ # when ssha
+ else
+ raise Net::LDAP::LdapError.new( "unsupported password-hash type (#{type})" )
+ end
+ end
+
+ end
+end
+
+
+end # class LDAP
+end # module Net
+
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldif.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldif.rb
new file mode 100644
index 000000000..1641bda4b
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/lib/net/ldif.rb
@@ -0,0 +1,39 @@
+# $Id: ldif.rb 78 2006-04-26 02:57:34Z blackhedd $
+#
+# Net::LDIF for Ruby
+#
+#
+#
+# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
+#
+# Gmail: garbagecat10
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+#
+
+# THIS FILE IS A STUB.
+
+module Net
+
+ class LDIF
+
+
+ end # class LDIF
+
+
+end # module Net
+
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testber.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testber.rb
new file mode 100644
index 000000000..4fe2e3071
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testber.rb
@@ -0,0 +1,42 @@
+# $Id: testber.rb 57 2006-04-18 00:18:48Z blackhedd $
+#
+#
+
+
+$:.unshift "lib"
+
+require 'net/ldap'
+require 'stringio'
+
+
+class TestBer < Test::Unit::TestCase
+
+ def setup
+ end
+
+ # TODO: Add some much bigger numbers
+ # 5000000000 is a Bignum, which hits different code.
+ def test_ber_integers
+ assert_equal( "\002\001\005", 5.to_ber )
+ assert_equal( "\002\002\203t", 500.to_ber )
+ assert_equal( "\002\003\203\206P", 50000.to_ber )
+ assert_equal( "\002\005\222\320\227\344\000", 5000000000.to_ber )
+ end
+
+ def test_ber_parsing
+ assert_equal( 6, "\002\001\006".read_ber( Net::LDAP::AsnSyntax ))
+ assert_equal( "testing", "\004\007testing".read_ber( Net::LDAP::AsnSyntax ))
+ end
+
+
+ def test_ber_parser_on_ldap_bind_request
+ s = StringIO.new "0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus"
+ assert_equal( [1, [3, "Administrator", "ad_is_bogus"]], s.read_ber( Net::LDAP::AsnSyntax ))
+ end
+
+
+
+
+end
+
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testdata.ldif b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testdata.ldif
new file mode 100644
index 000000000..eb5610d5f
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testdata.ldif
@@ -0,0 +1,101 @@
+# $Id: testdata.ldif 50 2006-04-17 17:57:33Z blackhedd $
+#
+# This is test-data for an LDAP server in LDIF format.
+#
+dn: dc=bayshorenetworks,dc=com
+objectClass: dcObject
+objectClass: organization
+o: Bayshore Networks LLC
+dc: bayshorenetworks
+
+dn: cn=Manager,dc=bayshorenetworks,dc=com
+objectClass: organizationalrole
+cn: Manager
+
+dn: ou=people,dc=bayshorenetworks,dc=com
+objectClass: organizationalunit
+ou: people
+
+dn: ou=privileges,dc=bayshorenetworks,dc=com
+objectClass: organizationalunit
+ou: privileges
+
+dn: ou=roles,dc=bayshorenetworks,dc=com
+objectClass: organizationalunit
+ou: roles
+
+dn: ou=office,dc=bayshorenetworks,dc=com
+objectClass: organizationalunit
+ou: office
+
+dn: mail=nogoodnik@steamheat.net,ou=people,dc=bayshorenetworks,dc=com
+cn: Bob Fosse
+mail: nogoodnik@steamheat.net
+sn: Fosse
+ou: people
+objectClass: top
+objectClass: inetorgperson
+objectClass: authorizedperson
+hasAccessRole: uniqueIdentifier=engineer,ou=roles
+hasAccessRole: uniqueIdentifier=ldapadmin,ou=roles
+hasAccessRole: uniqueIdentifier=ldapsuperadmin,ou=roles
+hasAccessRole: uniqueIdentifier=ogilvy_elephant_user,ou=roles
+hasAccessRole: uniqueIdentifier=ogilvy_eagle_user,ou=roles
+hasAccessRole: uniqueIdentifier=greenplug_user,ou=roles
+hasAccessRole: uniqueIdentifier=brandplace_logging_user,ou=roles
+hasAccessRole: uniqueIdentifier=brandplace_report_user,ou=roles
+hasAccessRole: uniqueIdentifier=workorder_user,ou=roles
+hasAccessRole: uniqueIdentifier=bayshore_eagle_user,ou=roles
+hasAccessRole: uniqueIdentifier=bayshore_eagle_superuser,ou=roles
+hasAccessRole: uniqueIdentifier=kledaras_user,ou=roles
+
+dn: mail=elephant@steamheat.net,ou=people,dc=bayshorenetworks,dc=com
+cn: Gwen Verdon
+mail: elephant@steamheat.net
+sn: Verdon
+ou: people
+objectClass: top
+objectClass: inetorgperson
+objectClass: authorizedperson
+hasAccessRole: uniqueIdentifier=brandplace_report_user,ou=roles
+hasAccessRole: uniqueIdentifier=engineer,ou=roles
+hasAccessRole: uniqueIdentifier=ogilvy_elephant_user,ou=roles
+hasAccessRole: uniqueIdentifier=ldapsuperadmin,ou=roles
+hasAccessRole: uniqueIdentifier=ldapadmin,ou=roles
+
+dn: uniqueIdentifier=engineering,ou=privileges,dc=bayshorenetworks,dc=com
+uniqueIdentifier: engineering
+ou: privileges
+objectClass: accessPrivilege
+
+dn: uniqueIdentifier=engineer,ou=roles,dc=bayshorenetworks,dc=com
+uniqueIdentifier: engineer
+ou: roles
+objectClass: accessRole
+hasAccessPrivilege: uniqueIdentifier=engineering,ou=privileges
+
+dn: uniqueIdentifier=ldapadmin,ou=roles,dc=bayshorenetworks,dc=com
+uniqueIdentifier: ldapadmin
+ou: roles
+objectClass: accessRole
+
+dn: uniqueIdentifier=ldapsuperadmin,ou=roles,dc=bayshorenetworks,dc=com
+uniqueIdentifier: ldapsuperadmin
+ou: roles
+objectClass: accessRole
+
+dn: mail=catperson@steamheat.net,ou=people,dc=bayshorenetworks,dc=com
+cn: Sid Sorokin
+mail: catperson@steamheat.net
+sn: Sorokin
+ou: people
+objectClass: top
+objectClass: inetorgperson
+objectClass: authorizedperson
+hasAccessRole: uniqueIdentifier=engineer,ou=roles
+hasAccessRole: uniqueIdentifier=ogilvy_elephant_user,ou=roles
+hasAccessRole: uniqueIdentifier=ldapsuperadmin,ou=roles
+hasAccessRole: uniqueIdentifier=ogilvy_eagle_user,ou=roles
+hasAccessRole: uniqueIdentifier=greenplug_user,ou=roles
+hasAccessRole: uniqueIdentifier=workorder_user,ou=roles
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testem.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testem.rb
new file mode 100644
index 000000000..46b4909cb
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testem.rb
@@ -0,0 +1,12 @@
+# $Id: testem.rb 121 2006-05-15 18:36:24Z blackhedd $
+#
+#
+
+require 'test/unit'
+require 'tests/testber'
+require 'tests/testldif'
+require 'tests/testldap'
+require 'tests/testpsw'
+require 'tests/testfilter'
+
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testfilter.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testfilter.rb
new file mode 100644
index 000000000..b8fb40996
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testfilter.rb
@@ -0,0 +1,37 @@
+# $Id: testfilter.rb 122 2006-05-15 20:03:56Z blackhedd $
+#
+#
+
+require 'test/unit'
+
+$:.unshift "lib"
+
+require 'net/ldap'
+
+
+class TestFilter < Test::Unit::TestCase
+
+ def setup
+ end
+
+
+ def teardown
+ end
+
+ def test_rfc_2254
+ p Net::LDAP::Filter.from_rfc2254( " ( uid=george* ) " )
+ p Net::LDAP::Filter.from_rfc2254( "uid!=george*" )
+ p Net::LDAP::Filter.from_rfc2254( "uidgeorge*" )
+ p Net::LDAP::Filter.from_rfc2254( "uid>=george*" )
+ p Net::LDAP::Filter.from_rfc2254( "uid!=george*" )
+
+ p Net::LDAP::Filter.from_rfc2254( "(& (uid!=george* ) (mail=*))" )
+ p Net::LDAP::Filter.from_rfc2254( "(| (uid!=george* ) (mail=*))" )
+ p Net::LDAP::Filter.from_rfc2254( "(! (mail=*))" )
+ end
+
+
+end
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testldap.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testldap.rb
new file mode 100644
index 000000000..bb70a0b20
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testldap.rb
@@ -0,0 +1,190 @@
+# $Id: testldap.rb 65 2006-04-23 01:17:49Z blackhedd $
+#
+#
+
+
+$:.unshift "lib"
+
+require 'test/unit'
+
+require 'net/ldap'
+require 'stringio'
+
+
+class TestLdapClient < Test::Unit::TestCase
+
+ # TODO: these tests crash and burn if the associated
+ # LDAP testserver isn't up and running.
+ # We rely on being able to read a file with test data
+ # in LDIF format.
+ # TODO, WARNING: for the moment, this data is in a file
+ # whose name and location are HARDCODED into the
+ # instance method load_test_data.
+
+ def setup
+ @host = "127.0.0.1"
+ @port = 3890
+ @auth = {
+ :method => :simple,
+ :username => "cn=bigshot,dc=bayshorenetworks,dc=com",
+ :password => "opensesame"
+ }
+
+ @ldif = load_test_data
+ end
+
+
+
+ # Get some test data which will be used to validate
+ # the responses from the test LDAP server we will
+ # connect to.
+ # TODO, Bogus: we are HARDCODING the location of the file for now.
+ #
+ def load_test_data
+ ary = File.readlines( "tests/testdata.ldif" )
+ hash = {}
+ while line = ary.shift and line.chomp!
+ if line =~ /^dn:[\s]*/i
+ dn = $'
+ hash[dn] = {}
+ while attr = ary.shift and attr.chomp! and attr =~ /^([\w]+)[\s]*:[\s]*/
+ hash[dn][$1.downcase.intern] ||= []
+ hash[dn][$1.downcase.intern] << $'
+ end
+ end
+ end
+ hash
+ end
+
+
+
+ # Binding tests.
+ # Need tests for all kinds of network failures and incorrect auth.
+ # TODO: Implement a class-level timeout for operations like bind.
+ # Search has a timeout defined at the protocol level, other ops do not.
+ # TODO, use constants for the LDAP result codes, rather than hardcoding them.
+ def test_bind
+ ldap = Net::LDAP.new :host => @host, :port => @port, :auth => @auth
+ assert_equal( true, ldap.bind )
+ assert_equal( 0, ldap.get_operation_result.code )
+ assert_equal( "Success", ldap.get_operation_result.message )
+
+ bad_username = @auth.merge( {:username => "cn=badguy,dc=imposters,dc=com"} )
+ ldap = Net::LDAP.new :host => @host, :port => @port, :auth => bad_username
+ assert_equal( false, ldap.bind )
+ assert_equal( 48, ldap.get_operation_result.code )
+ assert_equal( "Inappropriate Authentication", ldap.get_operation_result.message )
+
+ bad_password = @auth.merge( {:password => "cornhusk"} )
+ ldap = Net::LDAP.new :host => @host, :port => @port, :auth => bad_password
+ assert_equal( false, ldap.bind )
+ assert_equal( 49, ldap.get_operation_result.code )
+ assert_equal( "Invalid Credentials", ldap.get_operation_result.message )
+ end
+
+
+
+ def test_search
+ ldap = Net::LDAP.new :host => @host, :port => @port, :auth => @auth
+
+ search = {:base => "dc=smalldomain,dc=com"}
+ assert_equal( false, ldap.search( search ))
+ assert_equal( 32, ldap.get_operation_result.code )
+
+ search = {:base => "dc=bayshorenetworks,dc=com"}
+ assert_equal( true, ldap.search( search ))
+ assert_equal( 0, ldap.get_operation_result.code )
+
+ ldap.search( search ) {|res|
+ assert_equal( res, @ldif )
+ }
+ end
+
+
+
+
+ # This is a helper routine for test_search_attributes.
+ def internal_test_search_attributes attrs_to_search
+ ldap = Net::LDAP.new :host => @host, :port => @port, :auth => @auth
+ assert( ldap.bind )
+
+ search = {
+ :base => "dc=bayshorenetworks,dc=com",
+ :attributes => attrs_to_search
+ }
+
+ ldif = @ldif
+ ldif.each {|dn,entry|
+ entry.delete_if {|attr,value|
+ ! attrs_to_search.include?(attr)
+ }
+ }
+
+ assert_equal( true, ldap.search( search ))
+ ldap.search( search ) {|res|
+ res_keys = res.keys.sort
+ ldif_keys = ldif.keys.sort
+ assert( res_keys, ldif_keys )
+ res.keys.each {|rk|
+ assert( res[rk], ldif[rk] )
+ }
+ }
+ end
+
+
+ def test_search_attributes
+ internal_test_search_attributes [:mail]
+ internal_test_search_attributes [:cn]
+ internal_test_search_attributes [:ou]
+ internal_test_search_attributes [:hasaccessprivilege]
+ internal_test_search_attributes ["mail"]
+ internal_test_search_attributes ["cn"]
+ internal_test_search_attributes ["ou"]
+ internal_test_search_attributes ["hasaccessrole"]
+
+ internal_test_search_attributes [:mail, :cn, :ou, :hasaccessrole]
+ internal_test_search_attributes [:mail, "cn", :ou, "hasaccessrole"]
+ end
+
+
+ def test_search_filters
+ ldap = Net::LDAP.new :host => @host, :port => @port, :auth => @auth
+ search = {
+ :base => "dc=bayshorenetworks,dc=com",
+ :filter => Net::LDAP::Filter.eq( "sn", "Fosse" )
+ }
+
+ ldap.search( search ) {|res|
+ p res
+ }
+ end
+
+
+
+ def test_open
+ ldap = Net::LDAP.new :host => @host, :port => @port, :auth => @auth
+ ldap.open {|ldap|
+ 10.times {
+ rc = ldap.search( :base => "dc=bayshorenetworks,dc=com" )
+ assert_equal( true, rc )
+ }
+ }
+ end
+
+
+ def test_ldap_open
+ Net::LDAP.open( :host => @host, :port => @port, :auth => @auth ) {|ldap|
+ 10.times {
+ rc = ldap.search( :base => "dc=bayshorenetworks,dc=com" )
+ assert_equal( true, rc )
+ }
+ }
+ end
+
+
+
+
+
+end
+
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testldif.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testldif.rb
new file mode 100644
index 000000000..73eca746f
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testldif.rb
@@ -0,0 +1,69 @@
+# $Id: testldif.rb 61 2006-04-18 20:55:55Z blackhedd $
+#
+#
+
+
+$:.unshift "lib"
+
+require 'test/unit'
+
+require 'net/ldap'
+require 'net/ldif'
+
+require 'sha1'
+require 'base64'
+
+class TestLdif < Test::Unit::TestCase
+
+ TestLdifFilename = "tests/testdata.ldif"
+
+ def test_empty_ldif
+ ds = Net::LDAP::Dataset::read_ldif( StringIO.new )
+ assert_equal( true, ds.empty? )
+ end
+
+ def test_ldif_with_comments
+ str = ["# Hello from LDIF-land", "# This is an unterminated comment"]
+ io = StringIO.new( str[0] + "\r\n" + str[1] )
+ ds = Net::LDAP::Dataset::read_ldif( io )
+ assert_equal( str, ds.comments )
+ end
+
+ def test_ldif_with_password
+ psw = "goldbricks"
+ hashed_psw = "{SHA}" + Base64::encode64( SHA1.new(psw).digest ).chomp
+
+ ldif_encoded = Base64::encode64( hashed_psw ).chomp
+ ds = Net::LDAP::Dataset::read_ldif( StringIO.new( "dn: Goldbrick\r\nuserPassword:: #{ldif_encoded}\r\n\r\n" ))
+ recovered_psw = ds["Goldbrick"][:userpassword].shift
+ assert_equal( hashed_psw, recovered_psw )
+ end
+
+ def test_ldif_with_continuation_lines
+ ds = Net::LDAP::Dataset::read_ldif( StringIO.new( "dn: abcdefg\r\n hijklmn\r\n\r\n" ))
+ assert_equal( true, ds.has_key?( "abcdefg hijklmn" ))
+ end
+
+ # TODO, INADEQUATE. We need some more tests
+ # to verify the content.
+ def test_ldif
+ File.open( TestLdifFilename, "r" ) {|f|
+ ds = Net::LDAP::Dataset::read_ldif( f )
+ assert_equal( 13, ds.length )
+ }
+ end
+
+ # TODO, need some tests.
+ # Must test folded lines and base64-encoded lines as well as normal ones.
+ def test_to_ldif
+ File.open( TestLdifFilename, "r" ) {|f|
+ ds = Net::LDAP::Dataset::read_ldif( f )
+ ds.to_ldif
+ assert_equal( true, false ) # REMOVE WHEN WE HAVE SOME TESTS HERE.
+ }
+ end
+
+
+end
+
+
diff --git a/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testpsw.rb b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testpsw.rb
new file mode 100644
index 000000000..6b1aa08be
--- /dev/null
+++ b/rest_sys/vendor/plugins/ruby-net-ldap-0.0.4/tests/testpsw.rb
@@ -0,0 +1,28 @@
+# $Id: testpsw.rb 72 2006-04-24 21:58:14Z blackhedd $
+#
+#
+
+
+$:.unshift "lib"
+
+require 'net/ldap'
+require 'stringio'
+
+
+class TestPassword < Test::Unit::TestCase
+
+ def setup
+ end
+
+
+ def test_psw
+ assert_equal( "{MD5}xq8jwrcfibi0sZdZYNkSng==", Net::LDAP::Password.generate( :md5, "cashflow" ))
+ assert_equal( "{SHA}YE4eGkN4BvwNN1f5R7CZz0kFn14=", Net::LDAP::Password.generate( :sha, "cashflow" ))
+ end
+
+
+
+
+end
+
+
<%= l(:label_comment_plural) %>
+<% @news.comments.each do |comment| %> + <% next if comment.new_record? %> +<%= authoring comment.created_on, comment.author %>
+