From e0cdedfa2ee45afe3d3afad57179560a33be0ff8 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Tue, 6 Dec 2011 18:12:12 +0800 Subject: [PATCH 01/20] Remove useless controller and view user_attributes_controller and user_attributes views --- app/assets/javascripts/user_attribute_form.js | 10 ----- .../admin/user_attributes_controller.rb | 43 ------------------- .../admin/user_attributes/_form.html.erb | 32 -------------- app/views/admin/user_attributes/edit.html.erb | 12 ------ .../admin/user_attributes/index.html.erb | 23 ---------- app/views/admin/user_attributes/new.html.erb | 17 -------- 6 files changed, 137 deletions(-) delete mode 100644 app/assets/javascripts/user_attribute_form.js delete mode 100644 app/controllers/admin/user_attributes_controller.rb delete mode 100644 app/views/admin/user_attributes/_form.html.erb delete mode 100644 app/views/admin/user_attributes/edit.html.erb delete mode 100644 app/views/admin/user_attributes/index.html.erb delete mode 100644 app/views/admin/user_attributes/new.html.erb diff --git a/app/assets/javascripts/user_attribute_form.js b/app/assets/javascripts/user_attribute_form.js deleted file mode 100644 index 3af8dc01..00000000 --- a/app/assets/javascripts/user_attribute_form.js +++ /dev/null @@ -1,10 +0,0 @@ -var new_one = $('fieldset #new_one').clone(); -$('fieldset #new_one').remove(); - -$('fieldset a.remove').live( "click", function(){ - $(this).parent().remove(); -}); - -$('fieldset a.add').click(function(){ - new_one.clone().appendTo( $('fieldset') ); -}) \ No newline at end of file diff --git a/app/controllers/admin/user_attributes_controller.rb b/app/controllers/admin/user_attributes_controller.rb deleted file mode 100644 index c7021c74..00000000 --- a/app/controllers/admin/user_attributes_controller.rb +++ /dev/null @@ -1,43 +0,0 @@ -class Admin::UserAttributesController < ApplicationController - - layout "admin" - before_filter :authenticate_user! - - def index - @user_attributes = UserAttribute.all - end - - def show - @user_attribute = UserAttribute.find(params[:id]) - end - - def new - @user_attribute = UserAttribute.new - end - - def edit - @user_attribute = UserAttribute.find(params[:id]) - end - - def create - @user_attribute = UserAttribute.new(params[:user_attribute]) - @user_attribute.save - - redirect_to :action => :index - end - - def update - @user_attribute = UserAttribute.find(params[:id]) - @user_attribute.update_attributes(params[:user_attribute]) - - redirect_to :action => :index - end - - def destroy - @user_attribute = UserAttribute.find(params[:id]) - @user_attribute.destroy - - redirect_to :action => :index - end - -end diff --git a/app/views/admin/user_attributes/_form.html.erb b/app/views/admin/user_attributes/_form.html.erb deleted file mode 100644 index 98953d2c..00000000 --- a/app/views/admin/user_attributes/_form.html.erb +++ /dev/null @@ -1,32 +0,0 @@ -

- <%= f.label :name %> - <%= f.text_field :name %> -

- -
- <% @user_attribute.attrs.each_with_index do |attr, i| %> -

- - <%= hidden_field_tag "user_attribute[attrs][][key]", attr["key"] %> - <%= text_field_tag "user_attribute[attrs][][name]", attr["name"] %> - <%= select_tag "user_attribute[attrs][][type]", options_for_select(["text_field", "select"], attr["type"]) %> - (remove) -

- <% end -%> - -

- - <%= text_field_tag "user_attribute[attrs][][key]", "" %> - - <%= text_field_tag "user_attribute[attrs][][name]", "" %> - <%= select_tag "user_attribute[attrs][][type]", options_for_select(["text_field"], "") %> - (remove) -

- - (add) - -
- -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "user_attribute_form" %> -<% end -%> \ No newline at end of file diff --git a/app/views/admin/user_attributes/edit.html.erb b/app/views/admin/user_attributes/edit.html.erb deleted file mode 100644 index 1bc86bc4..00000000 --- a/app/views/admin/user_attributes/edit.html.erb +++ /dev/null @@ -1,12 +0,0 @@ - -

Editing user attribute: <%= @user_attribute.key %>

- -<% form_for @user_attribute, :url => admin_user_attribute_path(@user_attribute) do |f| %> - - <%= render :partial => "form", :locals => { :f => f } %> - -

- <%= f.submit %> -

- -<% end -%> diff --git a/app/views/admin/user_attributes/index.html.erb b/app/views/admin/user_attributes/index.html.erb deleted file mode 100644 index c9fe93b4..00000000 --- a/app/views/admin/user_attributes/index.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -

Listing user attributes

- - - - - - - - - -<% @user_attributes.each do |user_attribute| %> - - - - - - -<% end %> -
名稱Key
<%= user_attribute.name %><%= user_attribute.key %><%= link_to t(:edit), edit_admin_user_attribute_path(user_attribute) %><%= link_to t(:delete), admin_user_attribute_path(user_attribute), :confirm => 'Are you sure?', :method => :delete %>
- -
- -<%= link_to t(:new_user_attribute, :scope => :admin), new_admin_user_attribute_path, :class => 'button positive' %> \ No newline at end of file diff --git a/app/views/admin/user_attributes/new.html.erb b/app/views/admin/user_attributes/new.html.erb deleted file mode 100644 index c2ada3c1..00000000 --- a/app/views/admin/user_attributes/new.html.erb +++ /dev/null @@ -1,17 +0,0 @@ - -

New user attribute: <%= @user_attribute.key %>

- -<% form_for @user_attribute, :url => admin_user_attributes_path do |f| %> - -

- <%= f.label :key, "Key" %> - <%= f.text_field :key %> -

- - <%= render :partial => "form", :locals => { :f => f } %> - -

- <%= f.submit %> -

- -<% end -%> From b7ac5478b40f32a619a1434b6407cebcb1ef1b45 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Sat, 10 Dec 2011 18:12:39 +0800 Subject: [PATCH 02/20] Change role structure Still needs to: change the views and create sub_roles in the dev.rake --- .rspec | 1 + Gemfile | 1 + Gemfile.lock | 2 + app/controllers/admin/infos_controller.rb | 49 ++++++++ app/controllers/admin/roles_controller.rb | 54 +++++++++ .../admin/user_info_models_controller.rb | 58 ---------- .../admin/user_role_models_controller.rb | 59 ---------- app/controllers/admin/users_controller.rb | 16 +-- app/models/i18n_variable.rb | 2 + app/models/user/attribute.rb | 27 +++++ app/models/user/attribute_field.rb | 37 ++++++ app/models/user/attribute_model.rb | 62 ---------- app/models/user/attribute_value.rb | 3 +- app/models/user/info.rb | 3 + app/models/user/role.rb | 29 +++++ app/models/user/sub_role.rb | 10 ++ app/models/user/user.rb | 41 +------ app/models/user/user_attribute.rb | 21 ---- app/models/user/user_attribute_model.rb | 74 ------------ app/models/user/user_info.rb | 5 - app/models/user/user_info_model.rb | 3 - app/models/user/user_role.rb | 5 - app/models/user/user_role_model.rb | 8 -- .../attributes/_attribute_model.html.erb | 36 ++++++ app/views/admin/attributes/_form.html.erb | 57 +++++++++ app/views/admin/attributes/edit.html.erb | 16 +++ app/views/admin/attributes/index.html.erb | 34 ++++++ app/views/admin/attributes/new.html.erb | 20 ++++ .../admin/attributes/toggle_enable.js.erb | 3 + app/views/admin/infos/edit.html.erb | 16 +++ app/views/admin/users/_side_bar.html.erb | 11 ++ config/routes.rb | 4 +- lib/tasks/dev.rake | 48 ++++---- spec/controllers/design_controller_spec.rb | 47 -------- spec/helpers/design_helper_spec.rb | 15 --- spec/models/design_spec.rb | 5 - spec/models/role_spec.rb | 109 ++++++++++++++++++ spec/spec.opts | 4 - spec/spec_helper.rb | 75 ++++++++---- spec/views/design/create.html.erb_spec.rb | 5 - spec/views/design/destroy.html.erb_spec.rb | 5 - spec/views/design/edit.html.erb_spec.rb | 5 - spec/views/design/index.html.erb_spec.rb | 5 - spec/views/design/new.html.erb_spec.rb | 5 - spec/views/design/update.html.erb_spec.rb | 5 - 45 files changed, 608 insertions(+), 492 deletions(-) create mode 100644 app/controllers/admin/infos_controller.rb create mode 100644 app/controllers/admin/roles_controller.rb delete mode 100644 app/controllers/admin/user_info_models_controller.rb delete mode 100644 app/controllers/admin/user_role_models_controller.rb create mode 100644 app/models/user/attribute.rb create mode 100644 app/models/user/attribute_field.rb delete mode 100644 app/models/user/attribute_model.rb create mode 100644 app/models/user/info.rb create mode 100644 app/models/user/role.rb create mode 100644 app/models/user/sub_role.rb delete mode 100644 app/models/user/user_attribute.rb delete mode 100644 app/models/user/user_attribute_model.rb delete mode 100644 app/models/user/user_info.rb delete mode 100644 app/models/user/user_info_model.rb delete mode 100644 app/models/user/user_role.rb delete mode 100644 app/models/user/user_role_model.rb create mode 100644 app/views/admin/attributes/_attribute_model.html.erb create mode 100644 app/views/admin/attributes/_form.html.erb create mode 100644 app/views/admin/attributes/edit.html.erb create mode 100644 app/views/admin/attributes/index.html.erb create mode 100644 app/views/admin/attributes/new.html.erb create mode 100644 app/views/admin/attributes/toggle_enable.js.erb create mode 100644 app/views/admin/infos/edit.html.erb create mode 100644 app/views/admin/users/_side_bar.html.erb delete mode 100644 spec/controllers/design_controller_spec.rb delete mode 100644 spec/helpers/design_helper_spec.rb delete mode 100644 spec/models/design_spec.rb create mode 100644 spec/models/role_spec.rb delete mode 100644 spec/spec.opts delete mode 100644 spec/views/design/create.html.erb_spec.rb delete mode 100644 spec/views/design/destroy.html.erb_spec.rb delete mode 100644 spec/views/design/edit.html.erb_spec.rb delete mode 100644 spec/views/design/index.html.erb_spec.rb delete mode 100644 spec/views/design/new.html.erb_spec.rb delete mode 100644 spec/views/design/update.html.erb_spec.rb diff --git a/.rspec b/.rspec index 53607ea5..61f260b7 100644 --- a/.rspec +++ b/.rspec @@ -1 +1,2 @@ --colour +--drb diff --git a/Gemfile b/Gemfile index 2732e123..45b8257e 100644 --- a/Gemfile +++ b/Gemfile @@ -40,6 +40,7 @@ group :test, :development do gem "rcov" gem "delorean" gem "watchr" + gem "spork" # gem "capybara" # gem 'yard' # gem "bluecloth" diff --git a/Gemfile.lock b/Gemfile.lock index 6c1a1ae3..86b786e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -154,6 +154,7 @@ GEM rack (~> 1.3, >= 1.3.4) rack-protection (~> 1.1, >= 1.1.2) tilt (~> 1.3, >= 1.3.3) + spork (0.8.5) sprockets (2.0.3) hike (~> 1.2) rack (~> 1.0) @@ -200,6 +201,7 @@ DEPENDENCIES sass-rails shoulda-matchers sinatra + spork sprockets therubyracer uglifier diff --git a/app/controllers/admin/infos_controller.rb b/app/controllers/admin/infos_controller.rb new file mode 100644 index 00000000..a00bd94e --- /dev/null +++ b/app/controllers/admin/infos_controller.rb @@ -0,0 +1,49 @@ +class Admin::InfosController < ApplicationController + + layout "admin" + before_filter :authenticate_user! + before_filter :is_admin? + before_filter :set_attribute, :only => [:index, :show, :new, :edit] + + def index + @attributes = Info.all.entries + render :template => 'admin/attributes/index' + end + + def show + #@attribute = Info.find(params[:id]) + end + + def new + @attribute = Info.new + end + + def edit + @attribute = Info.find(params[:id]) + @i18n_variable = @attribute.i18n_variable + end + + def create + @attribute = Info.new(params[:info]) + @attribute.save + redirect_to :action => :index + end + + def update + @attribute = Info.find(params[:id]) + @attribute.update_attributes(params[:info]) + end + + def destroy + @attribute = Info.find(params[:id]) + @attribute.destroy + redirect_to :action => :index + end + + protected + + def set_attribute + @attribute_type = 'info' + end + +end diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb new file mode 100644 index 00000000..f3a17dd7 --- /dev/null +++ b/app/controllers/admin/roles_controller.rb @@ -0,0 +1,54 @@ +class Admin::RolesController < ApplicationController + + layout "admin" + before_filter :authenticate_user! + before_filter :is_admin? + before_filter :set_attribute, :only => [:index, :show, :new, :edit] + + def index + @attributes = Role.all.entries + render :template => 'admin/attributes/index' + end + + def show + #@attribute = Role.find(params[:id]) + end + + def new + @attribute = Role.new + end + + def edit + @attribute = Role.find(params[:id]) + @i18n_variable = @attribute.i18n_variable + end + + def create + @attribute = Role.new(params[:role]) + @attribute.save + redirect_to :action => :index + end + + def update + @attribute = Role.find(params[:id]) + @attribute.update_attributes(params[:role]) + + respond_to do |format| + format.html { redirect_to :action => :index } + format.js { render 'admin/attributes/toggle_enable' } + end + end + + def destroy + @attribute = Role.find(params[:id]) + @attribute.destroy + redirect_to :action => :index + end + + protected + + def set_attribute + @attribute_type = 'role' + end + +end diff --git a/app/controllers/admin/user_info_models_controller.rb b/app/controllers/admin/user_info_models_controller.rb deleted file mode 100644 index 7660d699..00000000 --- a/app/controllers/admin/user_info_models_controller.rb +++ /dev/null @@ -1,58 +0,0 @@ -class Admin::UserInfoModelsController < ApplicationController - - layout "admin" - before_filter :authenticate_user! - before_filter :is_admin? - before_filter :set_attribute, :only => [:index, :show, :new, :edit] - - def index - @user_attribute_models = UserInfoModel.all.entries - render :template => 'admin/user_attribute_models/index' - end - - def show - #@user_attribute_model = UserInfoModel.find(params[:id]) - end - - def new - @user_attribute_model = UserInfoModel.new - render :template => 'admin/user_attribute_models/new' - end - - def edit - @user_attribute_model = UserInfoModel.find(params[:id]) - @i18n_variable = @user_attribute_model.i18n_variable - render :template => 'admin/user_attribute_models/edit' - end - - def create - @user_attribute_model = UserInfoModel.new(params[:user_info_model]) - @user_attribute_model.save - redirect_to :action => :index - end - - def update - @user_attribute_model = UserInfoModel.find(params[:id]) - @user_attribute_model.update_attributes(params[:user_info_model]) - respond_to do |format| - format.html { redirect_to :action => :index } - format.js { render 'admin/user_attribute_models/toggle_enable' } - end - end - - def destroy - @user_attribute_model = UserInfoModel.find(params[:id]) - @user_attribute_model.destroy - - @user_attribute_model.destroy_i18n_variables - - redirect_to :action => :index - end - - protected - - def set_attribute - @attribute = 'info' - end - -end diff --git a/app/controllers/admin/user_role_models_controller.rb b/app/controllers/admin/user_role_models_controller.rb deleted file mode 100644 index b4145a8f..00000000 --- a/app/controllers/admin/user_role_models_controller.rb +++ /dev/null @@ -1,59 +0,0 @@ -class Admin::UserRoleModelsController < ApplicationController - - layout "admin" - before_filter :authenticate_user! - before_filter :is_admin? - before_filter :set_attribute, :only => [:index, :show, :new, :edit] - - def index - @user_attribute_models = UserRoleModel.all.entries - render :template => 'admin/user_attribute_models/index' - end - - def show - #@user_attribute_model = UserRoleModel.find(params[:id]) - end - - def new - @user_attribute_model = UserRoleModel.new - render :template => 'admin/user_attribute_models/new' - end - - def edit - @user_attribute_model = UserRoleModel.find(params[:id]) - @i18n_variable = @user_attribute_model.i18n_variable - render :template => 'admin/user_attribute_models/edit' - end - - def create - @user_attribute_model = UserRoleModel.new(params[:user_role_model]) - @user_attribute_model.save - redirect_to :action => :index - end - - def update - @user_attribute_model = UserRoleModel.find(params[:id]) - @user_attribute_model.update_attributes(params[:user_role_model]) - - respond_to do |format| - format.html { redirect_to :action => :index } - format.js { render 'admin/user_attribute_models/toggle_enable' } - end - end - - def destroy - @user_attribute_model = UserRoleModel.find(params[:id]) - @user_attribute_model.destroy - - @user_attribute_model.destroy_i18n_variables - - redirect_to :action => :index - end - - protected - - def set_attribute - @attribute = 'role' - end - -end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 79df2f2a..77cada1b 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -20,13 +20,13 @@ class Admin::UsersController < ApplicationController def create @user = User.new(params[:user]) if @user.save - @user.user_infos.each do |user_info| - user_info.save - user_info.attribute_values.each(&:save) + @user.user_infos.each do |info| + info.save + info.attribute_values.each(&:save) end - @user.user_roles.each do |user_role| - user_role.save - user_role.attribute_values.each(&:save) + @user.roles.each do |role| + role.save + role.attribute_values.each(&:save) end flash[:notice] = t('admin.create_success_user') redirect_to :action => :index @@ -77,8 +77,8 @@ class Admin::UsersController < ApplicationController protected def get_info_role_models - @user_info_models = UserInfoModel.excludes('disabled' => true) - @user_role_models = UserRoleModel.excludes('disabled' => true) + @roles = Info.excludes('disabled' => true) + @infos = Role.excludes('disabled' => true) end end diff --git a/app/models/i18n_variable.rb b/app/models/i18n_variable.rb index e6835347..b5983d35 100644 --- a/app/models/i18n_variable.rb +++ b/app/models/i18n_variable.rb @@ -7,6 +7,8 @@ class I18nVariable field :document_class, :type => String field :parent_id, :type => BSON::ObjectId, :index => true + belongs_to :language_value, polymorphic: true + def method_missing(field) self[field] end diff --git a/app/models/user/attribute.rb b/app/models/user/attribute.rb new file mode 100644 index 00000000..aee7c36c --- /dev/null +++ b/app/models/user/attribute.rb @@ -0,0 +1,27 @@ +class Attribute + + include Mongoid::Document + include Mongoid::Timestamps + + field :key + field :built_in, :type => Boolean, :default => false + field :disabled, :type => Boolean, :default => false + + embeds_many :attribute_fields + has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy + accepts_nested_attributes_for :i18n_variable, :allow_destroy => true + accepts_nested_attributes_for :attribute_fields, :allow_destroy => true + + def is_built_in? + self.built_in + end + + def is_disabled? + self.disabled + end + + def get_enabled_attribute_fields + self.attribute_fields.excludes('disabled' => true) + end + +end \ No newline at end of file diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb new file mode 100644 index 00000000..56bb02b7 --- /dev/null +++ b/app/models/user/attribute_field.rb @@ -0,0 +1,37 @@ +class AttributeField + + include Mongoid::Document + include Mongoid::Timestamps + + field :key + field :markup + field :locale, :type => Boolean + field :list_options, :type => Array + field :built_in, :type => Boolean, :default => false + field :disabled, :type => Boolean, :default => false + + embedded_in :attribute + has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy + has_many :attribute_values + validates_uniqueness_of :key + accepts_nested_attributes_for :i18n_variable, :allow_destroy => true + + # Convert the string list_options into an array + def select_list_options=(var) + self.list_options = var.gsub(' ', '').split(',') + end + + # Convert the array list_options into a string + def select_list_options + self.list_options.to_a.join(', ') + end + + def is_built_in? + self.built_in + end + + def is_disabled? + self.disabled + end + +end diff --git a/app/models/user/attribute_model.rb b/app/models/user/attribute_model.rb deleted file mode 100644 index d2cb8a1a..00000000 --- a/app/models/user/attribute_model.rb +++ /dev/null @@ -1,62 +0,0 @@ -class AttributeModel - - include Mongoid::Document - include Mongoid::Timestamps - - field :key - field :i18n_variable_id, :type => BSON::ObjectId, :index => true - field :markup - field :locale, :type => Boolean - field :list_options, :type => Array - field :built_in, :type => Boolean, :default => false - field :disabled, :type => Boolean, :default => false - - embedded_in :user_attribute_model - validates_uniqueness_of :key - - # Destroy the i18n_variable - def destroy_i18n_variable - self.i18n_variable.destroy rescue nil - end - - # Get the i18n_variable - def i18n_variable - @i18n_variable ||= I18nVariable.find(self.i18n_variable_id) rescue nil - end - - # Update or create the i18n_variable record - def i18n_variable=(attr) - if self.i18n_variable_id - self.i18n_variable.update_attributes(attr) - else - # var = I18nVariable.new(attr.merge({:key => self.key, :document_class => self.class, :parent_id => self.user_attribute_model.i18n_variable_id})) - var = I18nVariable.new(attr.merge({:key => self.key, :document_class => self.class})) - var.save - self.i18n_variable_id = var.id - end - end - - # Convert the string list_options into an array - def select_list_options=(var) - self.list_options = var.gsub(' ', '').split(',') - end - - # Convert the array list_options into a string - def select_list_options - self.list_options.to_a.join(', ') - end - - # Check if the attribute is set to be destroyed - def should_destroy? - should_destroy.to_i == 1 rescue nil - end - - def is_built_in? - self.built_in - end - - def is_disabled? - self.disabled - end - -end diff --git a/app/models/user/attribute_value.rb b/app/models/user/attribute_value.rb index 877431f0..8b15bf3d 100644 --- a/app/models/user/attribute_value.rb +++ b/app/models/user/attribute_value.rb @@ -5,6 +5,7 @@ class AttributeValue field :key - belongs_to :user_attribute + belongs_to :attribute_field + belongs_to :user end diff --git a/app/models/user/info.rb b/app/models/user/info.rb new file mode 100644 index 00000000..e55fa6f2 --- /dev/null +++ b/app/models/user/info.rb @@ -0,0 +1,3 @@ +class Info < Attribute + +end diff --git a/app/models/user/role.rb b/app/models/user/role.rb new file mode 100644 index 00000000..90294f58 --- /dev/null +++ b/app/models/user/role.rb @@ -0,0 +1,29 @@ +class Role + + include Mongoid::Document + include Mongoid::Timestamps + + field :key + field :built_in, :type => Boolean, :default => false + field :disabled, :type => Boolean, :default => false + + embeds_many :sub_roles + has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy + has_many :users + accepts_nested_attributes_for :i18n_variable, :allow_destroy => true + accepts_nested_attributes_for :sub_roles, :allow_destroy => true + + def is_built_in? + self.built_in + end + + def is_disabled? + self.disabled + end + + # Get an role from key + def self.get_role_from_key(key) + self.first(:conditions => {:key => key}) + end + +end \ No newline at end of file diff --git a/app/models/user/sub_role.rb b/app/models/user/sub_role.rb new file mode 100644 index 00000000..496055c2 --- /dev/null +++ b/app/models/user/sub_role.rb @@ -0,0 +1,10 @@ +class SubRole < Attribute + + has_many :users + + # Get an sub_role from key + def self.get_sub_role_from_key(key) + self.first(:conditions => {:key => key}) + end + +end \ No newline at end of file diff --git a/app/models/user/user.rb b/app/models/user/user.rb index f582dc04..2eca43dd 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -10,43 +10,10 @@ class User field :admin, :type => Boolean, :default => true field :active_role - has_many :user_attributes - has_many :user_roles - has_many :user_infos - - # Update or create the user_role records - def user_roles=(*attrs) - attrs[0].each do |roles| - if roles[:id].blank? - user_roles.build(roles) - else - user_role = user_roles.detect {|a| a.id.to_s == roles[:id].to_s } - user_role.update_attributes(roles) - end - end - end - - # Update or create the user_info records - def user_infos=(*attrs) - attrs[0].each do |infos| - if infos[:id].blank? - user_infos.build(infos) - else - user_info = user_infos.detect {|a| a.id.to_s == infos[:id].to_s } - user_info.update_attributes(infos) - end - end - end - - # Get an user_info from model key - def get_info_from_model_key(key) - self.user_infos.detect {|a| a.key.to_s == key.to_s } - end - - # Get an user_role from model key - def get_role_from_model_key(key) - self.user_roles.detect {|a| a.key.to_s == key.to_s } - end + has_many :attribute_values, :autosave => true, :dependent => :destroy + belongs_to :role + belongs_to :sub_role + accepts_nested_attributes_for :attribute_values, :allow_destroy => true def name infos = self.user_infos.detect {|info| info.key.to_s.eql?('profile') } diff --git a/app/models/user/user_attribute.rb b/app/models/user/user_attribute.rb deleted file mode 100644 index ddf04cc1..00000000 --- a/app/models/user/user_attribute.rb +++ /dev/null @@ -1,21 +0,0 @@ -class UserAttribute - - include Mongoid::Document - include Mongoid::Timestamps - - field :key - has_many :attribute_values - - # Update or create the attribute_value records - def attribute_values=(*args) - args[0].each do |value| - if value[:id].blank? - attribute_values.build(value) - else - attribute_value = attribute_values.detect {|a| a.id.to_s == value[:id].to_s } - attribute_value.update_attributes(value) - end - end - end - -end diff --git a/app/models/user/user_attribute_model.rb b/app/models/user/user_attribute_model.rb deleted file mode 100644 index c8aea4b2..00000000 --- a/app/models/user/user_attribute_model.rb +++ /dev/null @@ -1,74 +0,0 @@ -class UserAttributeModel - - include Mongoid::Document - include Mongoid::Timestamps - - field :key - field :i18n_variable_id, :type => BSON::ObjectId, :index => true - field :built_in, :type => Boolean, :default => false - field :disabled, :type => Boolean, :default => false - - embeds_many :attribute_models - - after_update :destroy_attrs - - # Update or create the attribute_model records - def attribute_models=(*attrs) - attrs[0].each do |attributes| - if attributes[:id].blank? - attribute_models.build(attributes) - else - attribute_model = attribute_models.detect {|a| a.id.to_s == attributes[:id].to_s } - attribute_model.update_attributes(attributes) - end - end - end - - # Destroy the i18n_variables - def destroy_i18n_variables - self.i18n_variable.destroy rescue nil - self.attribute_models.each do |attr| - attr.destroy_i18n_variable - end - end - - # Update or create the i18n_variable record - def i18n_variable=(attr) - if self.i18n_variable_id - self.i18n_variable.update_attributes(attr) rescue nil - else - var = I18nVariable.new(attr.merge({:key => self.key, :document_class => self.class})) - var.save - self.i18n_variable_id = var.id - end - end - - # Get the i18n_variable - def i18n_variable - @i18n_variable ||= I18nVariable.find(self.i18n_variable_id) rescue nil - end - - def is_built_in? - self.built_in - end - - def is_disabled? - self.disabled.blank? ? false : self.disabled - end - - def get_enabled_attribute_models - self.attribute_models.excludes('disabled' => true) - end - - protected - - # Destroy the i18n_variable for each attribute_models if marked to destroy - def destroy_attrs - attribute_models.each do |a| - if a.should_destroy? - a.destroy_i18n_variable - end - end - end - -end diff --git a/app/models/user/user_info.rb b/app/models/user/user_info.rb deleted file mode 100644 index f216c83a..00000000 --- a/app/models/user/user_info.rb +++ /dev/null @@ -1,5 +0,0 @@ -class UserInfo < UserAttribute - - belongs_to :user - -end diff --git a/app/models/user/user_info_model.rb b/app/models/user/user_info_model.rb deleted file mode 100644 index cacf2a55..00000000 --- a/app/models/user/user_info_model.rb +++ /dev/null @@ -1,3 +0,0 @@ -class UserInfoModel < UserAttributeModel - -end diff --git a/app/models/user/user_role.rb b/app/models/user/user_role.rb deleted file mode 100644 index 1bc23e93..00000000 --- a/app/models/user/user_role.rb +++ /dev/null @@ -1,5 +0,0 @@ -class UserRole < UserAttribute - - belongs_to :user - -end diff --git a/app/models/user/user_role_model.rb b/app/models/user/user_role_model.rb deleted file mode 100644 index d5271edd..00000000 --- a/app/models/user/user_role_model.rb +++ /dev/null @@ -1,8 +0,0 @@ -class UserRoleModel < UserAttributeModel - - # Get an user_role_model from key - def self.get_role_model_from_key(key) - self.first(:conditions => {:key => key}) - end - -end diff --git a/app/views/admin/attributes/_attribute_model.html.erb b/app/views/admin/attributes/_attribute_model.html.erb new file mode 100644 index 00000000..89c1ef89 --- /dev/null +++ b/app/views/admin/attributes/_attribute_model.html.erb @@ -0,0 +1,36 @@ +<%= fields_for "user_#{@attribute_type}_model[attribute_models][]", attribute_model, :index => nil do |f| %> + + <%= attribute_model.new_record? ? (f.text_field :key) : attribute_model.key %> + + <%= check_box_tag "locale[]", value = '', attribute_model.locale.nil? ? true : attribute_model.locale %> + <%= hidden_field_tag "user_#{@attribute_type}_model[attribute_models][][locale]", attribute_model.locale.nil? ? true : attribute_model.locale %> + + <% @site_valid_locales.each do |locale| %> + <%= text_field_tag "user_#{@attribute_type}_model[attribute_models][][i18n_variable][#{locale}]", (attribute_model.i18n_variable[locale] rescue nil), :style => "width:130px" %> + <% end %> + + <%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %> +
> + <%= t('admin.options') %>: + <%= text_field_tag "user_#{@attribute_type}_model[attribute_models][][select_list_options]", attribute_model.select_list_options, :style => "width:130px" %> +
+ + + + <% if attribute_model.new_record? %> + <%= t(:delete) %> + <% else %> + <% if attribute_model.is_built_in? %> + + <%= hidden_field_tag "user_#{@attribute_type}_model[attribute_models][][disabled]", attribute_model.is_disabled? , :class => 'built_in_state' %> + <% else %> + <%= t(:delete) %> + <%= hidden_field_tag "user_#{@attribute_type}_model[attribute_models][][should_destroy]", nil , :class => 'should_destroy' %> + <% end %> + <%= f.hidden_field :id %> + <%= f.hidden_field :key %> + <% end %> + + + +<% end %> \ No newline at end of file diff --git a/app/views/admin/attributes/_form.html.erb b/app/views/admin/attributes/_form.html.erb new file mode 100644 index 00000000..5d66152c --- /dev/null +++ b/app/views/admin/attributes/_form.html.erb @@ -0,0 +1,57 @@ +
+

<%= t("admin.user_#{@attribute_type}") %>

+
+ + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + +
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %> + <%= text_field_tag "user_#{@attribute_type}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> +
+
+
+ + +
+

Attributes

+
+ + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + + + + + + <%= render :partial => 'admin/attributes/attribute_model', :collection => @attribute.attribute_models %> + +
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
<%= t(:add) %>
+
+
+ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "attribute_form" %> +<% end -%> diff --git a/app/views/admin/attributes/edit.html.erb b/app/views/admin/attributes/edit.html.erb new file mode 100644 index 00000000..e0f75789 --- /dev/null +++ b/app/views/admin/attributes/edit.html.erb @@ -0,0 +1,16 @@ +<% content_for :secondary do %> + <%= render 'admin/users/side_bar' %> +<% end %> + +
+ <%= form_for @attribute, :url => eval("admin_user_#{@attribute_type}_model_path(@user_role_model)") do |f| %> + <%= f.error_messages %> + <%= render :partial => "admin/attributes/form", :locals => { :f => f, :is_new => false } %> +
+ <%= link_to t('update'), "#", :onclick=>"$('#edit_user_role_model_#{@attribute.id}').submit()" %> +
+
+ <%= link_back %> +
+ <% end -%> +
\ No newline at end of file diff --git a/app/views/admin/attributes/index.html.erb b/app/views/admin/attributes/index.html.erb new file mode 100644 index 00000000..efd8c775 --- /dev/null +++ b/app/views/admin/attributes/index.html.erb @@ -0,0 +1,34 @@ +<% content_for :secondary do %> + <%= render 'admin/users/side_bar' %> +<% end %> + +
+
+ <%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path") %> +
+
    +
  • + <%= t("admin.#{@attribute_type}") %> + <%= t('admin.action') %> +
  • + <% @attributes.each do |attribute| %> +
  • clear"> + <%= attribute.i18n_variable[I18n.locale] %> + + + <%= link_to t(:edit), eval("edit_admin_#{@attribute_type}_path(attribute)"), :class => 'edit' %> + <% if attribute.is_built_in? %> + <%= link_to t(:enable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' %> + <%= link_to t(:disable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' %> + <% else %> + <%= link_to t(:delete), eval("admin_#{@attribute_type}_path(attribute)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %> + <% end %> + + +
  • + <% end %> +
+
+ <%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path") %> +
+
diff --git a/app/views/admin/attributes/new.html.erb b/app/views/admin/attributes/new.html.erb new file mode 100644 index 00000000..431814d1 --- /dev/null +++ b/app/views/admin/attributes/new.html.erb @@ -0,0 +1,20 @@ +<% content_for :secondary do %> + <%= render 'admin/users/side_bar' %> +<% end %> + +
+ <%= form_for @attribute, :url => eval("admin_infos_path") do |f| %> + <%= f.error_messages %> + <%= render :partial => "admin/infos/form", :locals => { :f => f, :is_new => true } %> +
+ <%= link_to t('create'), "#", :onclick=>"$('#new_attribute').submit()" %> +
+
+ <%= link_back %> +
+ <% end -%> +
+ + + + diff --git a/app/views/admin/attributes/toggle_enable.js.erb b/app/views/admin/attributes/toggle_enable.js.erb new file mode 100644 index 00000000..c42c4744 --- /dev/null +++ b/app/views/admin/attributes/toggle_enable.js.erb @@ -0,0 +1,3 @@ +$("#enable_<%= @attribute.id %>").toggle(); +$("#disable_<%= @attribute.id %>").toggle(); +$("#attribute_<%= @attribute.id %>").toggleClass('disable'); \ No newline at end of file diff --git a/app/views/admin/infos/edit.html.erb b/app/views/admin/infos/edit.html.erb new file mode 100644 index 00000000..e0f75789 --- /dev/null +++ b/app/views/admin/infos/edit.html.erb @@ -0,0 +1,16 @@ +<% content_for :secondary do %> + <%= render 'admin/users/side_bar' %> +<% end %> + +
+ <%= form_for @attribute, :url => eval("admin_user_#{@attribute_type}_model_path(@user_role_model)") do |f| %> + <%= f.error_messages %> + <%= render :partial => "admin/attributes/form", :locals => { :f => f, :is_new => false } %> +
+ <%= link_to t('update'), "#", :onclick=>"$('#edit_user_role_model_#{@attribute.id}').submit()" %> +
+
+ <%= link_back %> +
+ <% end -%> +
\ No newline at end of file diff --git a/app/views/admin/users/_side_bar.html.erb b/app/views/admin/users/_side_bar.html.erb new file mode 100644 index 00000000..8b8393db --- /dev/null +++ b/app/views/admin/users/_side_bar.html.erb @@ -0,0 +1,11 @@ + +
+

<%= t('admin.setup_member') %>

+
    +
  • <%= link_to content_tag(:span, t('admin.list_users')), admin_users_path %>
  • +
  • <%= link_to content_tag(:span, t('admin.list_roles')), admin_roles_path %>
  • +
  • <%= link_to content_tag(:span, t('admin.list_infos')), admin_infos_path %>
  • +
+
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index fba21f02..69a554d1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,6 +22,7 @@ PrototypeR4::Application.routes.draw do post 'edit_file' => 'designs#edit_file' end end + resources :infos resources :items resources :links do member do @@ -43,12 +44,11 @@ PrototypeR4::Application.routes.draw do get 'download' end end + resources :roles resources :sites resources :snippets resources :translations resources :users - resources :user_info_models - resources :user_role_models end # end admin diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 2ab64d6d..60dcdbe0 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -15,13 +15,13 @@ namespace :dev do I18nVariable.create!( :document_class => 'language', :key => 'en', :en => 'English', :zh_tw => '英文' ) I18nVariable.create!( :document_class => 'language', :key => 'zh_tw', :en => 'Chinese', :zh_tw => '中文' ) - var_1 = I18nVariable.create!( :document_class => 'UserRoleModel', :key => 'teacher', :en => 'Teacher', :zh_tw => '老師' ) + var_1 = I18nVariable.create!( :document_class => 'Role', :key => 'teacher', :en => 'Teacher', :zh_tw => '老師' ) var_2 = I18nVariable.create!( :document_class => 'AttributeModel', :key => 'discipline', :en => 'Discipline', :zh_tw => '學科', :parent_id => var_1.id ) var_3 = I18nVariable.create!( :document_class => 'AttributeModel', :key => 'department', :en => 'Department', :zh_tw => '學系', :parent_id => var_1.id ) - var_4 = I18nVariable.create!( :document_class => 'UserRoleModel', :key => 'student', :en => 'Student', :zh_tw => '學生' ) + var_4 = I18nVariable.create!( :document_class => 'Role', :key => 'student', :en => 'Student', :zh_tw => '學生' ) var_5 = I18nVariable.create!( :document_class => 'AttributeModel', :key => 'department', :en => 'Department', :zh_tw => '學系', :parent_id => var_4.id ) var_6 = I18nVariable.create!( :document_class => 'AttributeModel', :key => 'major', :en => 'Major', :zh_tw => '主修', :parent_id => var_4.id ) - var_7 = I18nVariable.create!( :document_class => 'UserInfoModel', :key => 'profile', :en => 'Profile', :zh_tw => '個人檔案' ) + var_7 = I18nVariable.create!( :document_class => 'Info', :key => 'profile', :en => 'Profile', :zh_tw => '個人檔案' ) var_8 = I18nVariable.create!( :document_class => 'AttributeModel', :key => 'last_name', :en => 'Last name', :zh_tw => '姓氏', :parent_id => var_7.id ) var_9 = I18nVariable.create!( :document_class => 'AttributeModel', :key => 'first_name', :en => 'First name', :zh_tw => '名字', :parent_id => var_7.id ) var_10 = I18nVariable.create!( :document_class => 'Home', :key => 'home', :en => 'Homepage', :zh_tw => '首頁') @@ -32,17 +32,17 @@ namespace :dev do # TODO: modify for the new model - urm_1 = UserRoleModel.new( :key => 'teacher', :i18n_variable_id => var_1.id, :built_in => true ) - urm_1.attribute_models.build( :key => 'discipline', :locale => true, :i18n_variable_id => var_2.id, :markup => 'text_field', :list_options => [], :built_in => true ) - urm_1.attribute_models.build( :key => 'department', :locale => true, :i18n_variable_id => var_3.id, :markup => 'text_field', :list_options => [], :built_in => true ) + urm_1 = Role.new( :key => 'teacher', :i18n_variable_id => var_1.id, :built_in => true ) + urm_1.attributes.build( :key => 'discipline', :locale => true, :i18n_variable_id => var_2.id, :markup => 'text_field', :list_options => [], :built_in => true ) + urm_1.attributes.build( :key => 'department', :locale => true, :i18n_variable_id => var_3.id, :markup => 'text_field', :list_options => [], :built_in => true ) urm_1.save! - urm_2 = UserRoleModel.new( :key => 'student', :i18n_variable_id => var_4.id ) - urm_2.attribute_models.build( :key => 'department', :locale => true, :i18n_variable_id => var_5.id, :markup => 'text_field', :list_options => [] ) - urm_2.attribute_models.build( :key => 'major', :locale => true, :i18n_variable_id => var_6.id, :markup => 'text_field', :list_options => [] ) + urm_2 = Role.new( :key => 'student', :i18n_variable_id => var_4.id ) + urm_2.attributes.build( :key => 'department', :locale => true, :i18n_variable_id => var_5.id, :markup => 'text_field', :list_options => [] ) + urm_2.attributes.build( :key => 'major', :locale => true, :i18n_variable_id => var_6.id, :markup => 'text_field', :list_options => [] ) urm_2.save! - uim_1 = UserInfoModel.new( :key => 'profile', :i18n_variable_id => var_7.id, :built_in => true ) - uim_1.attribute_models.build( :key => 'last_name', :locale => true, :i18n_variable_id => var_8.id, :markup => 'text_field', :list_options => [], :built_in => true ) - uim_1.attribute_models.build( :key => 'first_name', :locale => true, :i18n_variable_id => var_9.id, :markup => 'text_field', :list_options => [], :built_in => true ) + uim_1 = Info.new( :key => 'profile', :i18n_variable_id => var_7.id, :built_in => true ) + uim_1.attributes.build( :key => 'last_name', :locale => true, :i18n_variable_id => var_8.id, :markup => 'text_field', :list_options => [], :built_in => true ) + uim_1.attributes.build( :key => 'first_name', :locale => true, :i18n_variable_id => var_9.id, :markup => 'text_field', :list_options => [], :built_in => true ) uim_1.save! @@ -118,22 +118,18 @@ namespace :dev do - user = User.create( :email => 'chris@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :active_role => 'teacher' ) - user_info = UserInfo.create( :user_id => user.id, :key => 'profile' ) - user_role = UserRole.create( :user_id => user.id, :key => 'teacher' ) - AttributeValue.create( :user_attribute_id => user_info.id, :key => 'first_name', :en => 'Christophe', :zh_tw => '順發' ) - AttributeValue.create( :user_attribute_id => user_info.id, :key => 'last_name', :en => 'Vilayphiou', :zh_tw => '林' ) - AttributeValue.create( :user_attribute_id => user_role.id, :key => 'discipline', :en => 'Computer Architecture', :zh_tw => '計算機系統結構' ) - AttributeValue.create( :user_attribute_id => user_role.id, :key => 'department', :en => 'Computer Science', :zh_tw => '計算機科學' ) + user = User.create( :email => 'chris@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :role_id => urm_1.id ) + AttributeValue.create( :user_id => user.id, :key => 'first_name', :en => 'Christophe', :zh_tw => '順發' ) + AttributeValue.create( :user_id => user.id, :key => 'last_name', :en => 'Vilayphiou', :zh_tw => '林' ) + AttributeValue.create( :user_id => user.id, :key => 'discipline', :en => 'Computer Architecture', :zh_tw => '計算機系統結構' ) + AttributeValue.create( :user_id => user.id, :key => 'department', :en => 'Computer Science', :zh_tw => '計算機科學' ) - user = User.create( :email => 'matt@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :active_role => 'student' ) - user_info = UserInfo.create( :user_id => user.id, :key => 'profile' ) - user_role = UserRole.create( :user_id => user.id, :key => 'student' ) - AttributeValue.create( :user_attribute_id => user_info.id, :key => 'first_name', :en => 'Matt', :zh_tw => '儒淵' ) - AttributeValue.create( :user_attribute_id => user_info.id, :key => 'last_name', :en => 'Fu', :zh_tw => '傅' ) - AttributeValue.create( :user_attribute_id => user_role.id, :key => 'major', :en => 'Information management', :zh_tw => '信息化管理' ) - AttributeValue.create( :user_attribute_id => user_role.id, :key => 'department', :en => 'Computer Science', :zh_tw => '計算機科學' ) + user = User.create( :email => 'matt@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :role_id => urm_2.id ) + AttributeValue.create( :user_id => user.id, :key => 'first_name', :en => 'Matt', :zh_tw => '儒淵' ) + AttributeValue.create( :user_id => user.id, :key => 'last_name', :en => 'Fu', :zh_tw => '傅' ) + AttributeValue.create( :user_id => user.id, :key => 'major', :en => 'Information management', :zh_tw => '信息化管理' ) + AttributeValue.create( :user_id => user.id, :key => 'department', :en => 'Computer Science', :zh_tw => '計算機科學' ) diff --git a/spec/controllers/design_controller_spec.rb b/spec/controllers/design_controller_spec.rb deleted file mode 100644 index dd02b1cd..00000000 --- a/spec/controllers/design_controller_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'spec_helper' - -describe DesignController do - - describe "GET 'index'" do - it "should be successful" do - get 'index' - response.should be_success - end - end - - describe "GET 'new'" do - it "should be successful" do - get 'new' - response.should be_success - end - end - - describe "GET 'update'" do - it "should be successful" do - get 'update' - response.should be_success - end - end - - describe "GET 'edit'" do - it "should be successful" do - get 'edit' - response.should be_success - end - end - - describe "GET 'destroy'" do - it "should be successful" do - get 'destroy' - response.should be_success - end - end - - describe "GET 'create'" do - it "should be successful" do - get 'create' - response.should be_success - end - end - -end diff --git a/spec/helpers/design_helper_spec.rb b/spec/helpers/design_helper_spec.rb deleted file mode 100644 index dcebcb47..00000000 --- a/spec/helpers/design_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the DesignHelper. For example: -# -# describe DesignHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe DesignHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/design_spec.rb b/spec/models/design_spec.rb deleted file mode 100644 index 704b1d25..00000000 --- a/spec/models/design_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe Design do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb new file mode 100644 index 00000000..d7587792 --- /dev/null +++ b/spec/models/role_spec.rb @@ -0,0 +1,109 @@ +require 'spec_helper' + +describe Role do + before do + @role = Role.create(:key => 'teacher', + :i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'}, + :sub_roles => [{:key => 'undergrad', + :attribute_fields => [{:key => 'department'}, + {:key => 'room'}]}, + {:key => 'master', + :attribute_fields => [{:key => 'department'}]}]) + end + describe 'New role' do + describe '#Role' do + it 'should have :built_in false' do + @role.built_in.should be false + end + it 'should have :disabled false' do + @role.disabled.should be false + end + it 'should have a i18n_variable' do + @role.i18n_variable.should be_an_instance_of I18nVariable + end + it 'should create sub_roles' do + @role.should have(2).sub_roles + end + it 'should create attribute_fields' do + @role.sub_roles[1].should have(1).attribute_fields + end + end + describe '#SubRole' do + it 'should have :built_in false' do + @role.sub_roles[0].built_in.should be false + end + it 'should have :disabled false' do + @role.sub_roles[0].disabled.should be false + end + end + describe '#AttributeField' do + it 'should have :built_in false' do + @role.sub_roles[0].attribute_fields[0].built_in.should be false + end + it 'should have :disabled false' do + @role.sub_roles[0].attribute_fields[0].disabled.should be false + end + end + end + describe 'Edit role' do + describe '#Role' do + before do + @role.update_attributes({:key => 'student', :i18n_variable => {:en => 'Student'}, + :sub_roles => [{:key => 'new', + :attribute_fields => [{:key => 'bob'}, + {:key => 'great'}]}, + {:id => @role.sub_roles[0].id}, + {:id => @role.sub_roles[1].id}]}) + end + it 'should not be the old :key' do + @role.key.should_not == 'teacher' + end + it 'should be the new :key' do + @role.key.should == 'student' + end + it 'should not be the old :i18n_variable[:en]' do + @role.i18n_variable[:en].should_not == 'Teacher' + end + it 'should be the new :i18n_variable[:en]' do + @role.i18n_variable[:en].should == 'Student' + end + it 'should have one more SubRole' do + @role.should have(3).sub_roles + end + end + end + describe 'Destroy' do + describe '#AttributeField' do + before do + @role.update_attributes(:key => 'teacher', + :i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'}, + :sub_roles_attributes => {'0' => {:id => @role.sub_roles[0].id, + :key => 'undergrad', + :attribute_fields_attributes => {'0' => {:id => @role.sub_roles[0].attribute_fields[0].id, + :key => 'department'}, + '1' => {:id => @role.sub_roles[0].attribute_fields[1].id, + :key => 'room', :_destroy => true}}}}) + end + it 'should have only one AttributeField for the first SubRole' do + @role.sub_roles[0].should have(1).attribute_fields + end + end + describe '#I18nVariable' do + before do + @role.update_attributes(:key => 'teacher', + :i18n_variable_attributes => {:id => @role.i18n_variable.id, :key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role', :_destroy => true}) + end + it 'should not have a I18nVariable' do + @role.i18n_variable.should_not be_an_instance_of I18nVariable + end + end + describe '#Role' do + it 'should destroy the I18nVariable' do + id = @role.i18n_variable.id + @role.destroy + lambda {I18nVariable.find(id)}.should raise_error + end + end + end + +end \ No newline at end of file diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 index 391705bf..00000000 --- a/spec/spec.opts +++ /dev/null @@ -1,4 +0,0 @@ ---colour ---format progress ---loadby mtime ---reverse diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9b8b02c8..a4b16f6c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,27 +1,58 @@ -# This file is copied to spec/ when you run 'rails generate rspec:install' -ENV["RAILS_ENV"] ||= 'test' -require File.expand_path("../../config/environment", __FILE__) -require 'rspec/rails' +require 'rubygems' +require 'spork' -# Requires supporting ruby files with custom matchers and macros, etc, -# in spec/support/ and its subdirectories. -Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} +Spork.prefork do + # Loading more in this block will cause your tests to run faster. However, + # if you change any configuration or code from libraries loaded here, you'll + # need to restart spork for it take effect. + # This file is copied to spec/ when you run 'rails generate rspec:install' + ENV["RAILS_ENV"] ||= 'test' + require File.expand_path("../../config/environment", __FILE__) + require 'rspec/rails' + require 'rspec/autorun' -RSpec.configure do |config| - # == Mock Framework - # - # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: - # - # config.mock_with :mocha - # config.mock_with :flexmock - # config.mock_with :rr - config.mock_with :rspec + # Requires supporting ruby files with custom matchers and macros, etc, + # in spec/support/ and its subdirectories. + Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} - # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + RSpec.configure do |config| + # == Mock Framework + # + # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: + # + # config.mock_with :mocha + # config.mock_with :flexmock + # config.mock_with :rr + config.mock_with :rspec - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, remove the following line or assign false - # instead of true. - config.use_transactional_fixtures = true + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + # config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + # config.use_transactional_fixtures = true + + # If true, the base class of anonymous controllers will be inferred + # automatically. This will be the default behavior in future versions of + # rspec-rails. + config.infer_base_class_for_anonymous_controllers = false + end end + +Spork.each_run do + # This code will be run each time you run your specs. + load "#{Rails.root}/config/routes.rb" + Dir["#{Rails.root}/app/**/*.rb"].each { |f| load f } +end + +# --- Instructions --- +# - Sort through your spec_helper file. Place as much environment loading +# code that you don't normally modify during development in the +# Spork.prefork block. +# - Place the rest under Spork.each_run block +# - Any code that is left outside of the blocks will be ran during preforking +# and during each_run! +# - These instructions should self-destruct in 10 seconds. If they don't, +# feel free to delete them. +# \ No newline at end of file diff --git a/spec/views/design/create.html.erb_spec.rb b/spec/views/design/create.html.erb_spec.rb deleted file mode 100644 index aa2aa68b..00000000 --- a/spec/views/design/create.html.erb_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe "design/create.html.erb" do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/views/design/destroy.html.erb_spec.rb b/spec/views/design/destroy.html.erb_spec.rb deleted file mode 100644 index 4944b52a..00000000 --- a/spec/views/design/destroy.html.erb_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe "design/destroy.html.erb" do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/views/design/edit.html.erb_spec.rb b/spec/views/design/edit.html.erb_spec.rb deleted file mode 100644 index beb152f7..00000000 --- a/spec/views/design/edit.html.erb_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe "design/edit.html.erb" do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/views/design/index.html.erb_spec.rb b/spec/views/design/index.html.erb_spec.rb deleted file mode 100644 index 6ef1761e..00000000 --- a/spec/views/design/index.html.erb_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe "design/index.html.erb" do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/views/design/new.html.erb_spec.rb b/spec/views/design/new.html.erb_spec.rb deleted file mode 100644 index 3af6c888..00000000 --- a/spec/views/design/new.html.erb_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe "design/new.html.erb" do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/views/design/update.html.erb_spec.rb b/spec/views/design/update.html.erb_spec.rb deleted file mode 100644 index bf433577..00000000 --- a/spec/views/design/update.html.erb_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe "design/update.html.erb" do - pending "add some examples to (or delete) #{__FILE__}" -end From d23cf152da67349339f64c3dab3192b5dbaae7d3 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Sat, 10 Dec 2011 18:21:59 +0800 Subject: [PATCH 03/20] Merge 'standardization' and 'role structure modification' --- admin_back_end.css.erb | 278 ++++++ .../javascripts/user_attribute_model_form.js | 2 +- app/assets/stylesheets/_form.html.erb | 57 ++ app/assets/stylesheets/admin.css.erb | 15 +- app/assets/stylesheets/admin_back_end.css.erb | 842 ++++++++++-------- app/assets/stylesheets/reset.css | 44 + app/assets/stylesheets/reset.css.erb | 44 + .../admin/user_info_models_controller.rb | 59 ++ .../admin/user_role_models_controller.rb | 60 ++ app/controllers/admin/users_controller.rb | 173 ++-- .../user_attribute_models/_form.html.erb | 114 +-- .../user_attribute_models/admin.html.erb | 31 + .../admin/user_attribute_models/edit.html.erb | 24 +- .../user_attribute_models/index.html.erb | 71 +- .../admin/user_attribute_models/new.html.erb | 34 +- .../admin/user_attributes/index.html.erb | 34 + app/views/admin/user_attributes/new.html.erb | 16 + app/views/admin/users/_form.html.erb | 87 +- .../admin/users/_show_user_attribute.html.erb | 52 +- app/views/admin/users/_side_bar.html.erb | 14 +- .../admin/users/_user_attribute.html.erb | 88 +- app/views/admin/users/edit.html.erb | 24 +- app/views/admin/users/index.html.erb | 75 +- app/views/admin/users/new.html.erb | 36 +- app/views/admin/users/show.html.erb | 62 +- app/views/layouts/admin.html.erb | 67 +- app/views/layouts/admin.html.erb.back20111207 | 36 + edit.html.erb | 14 + index.html.erb | 34 + 29 files changed, 1687 insertions(+), 800 deletions(-) create mode 100644 admin_back_end.css.erb create mode 100644 app/assets/stylesheets/_form.html.erb create mode 100644 app/assets/stylesheets/reset.css create mode 100644 app/assets/stylesheets/reset.css.erb create mode 100644 app/controllers/admin/user_info_models_controller.rb create mode 100644 app/controllers/admin/user_role_models_controller.rb create mode 100644 app/views/admin/user_attribute_models/admin.html.erb create mode 100644 app/views/admin/user_attributes/index.html.erb create mode 100644 app/views/admin/user_attributes/new.html.erb create mode 100644 app/views/layouts/admin.html.erb.back20111207 create mode 100644 edit.html.erb create mode 100644 index.html.erb diff --git a/admin_back_end.css.erb b/admin_back_end.css.erb new file mode 100644 index 00000000..a0eff84e --- /dev/null +++ b/admin_back_end.css.erb @@ -0,0 +1,278 @@ +html, body{ + height: 100%; + margin: 0; + padding: 0; +} +html{ + background: url(<%= asset_path "body.jpg" %>) no-repeat scroll 0 0 transparent; + background-size: cover; +} + +body{ + color: #000000; + font-family: Helvetica, '微軟正黑體'; +} + +#panel_banner_link{ + background: url(<%= asset_path "orbitbar1.png" %>) repeat-x scroll 0 0; + height: 50px; + left: 0; + position: fixed; + top: 0; + width: 100%; + z-index: 5; +} +.hmenu{ + height: 40px; + position: absolute; + right: 0; + top: 1px; + width: 250px; +} +#orbit{ + background: url(<%= asset_path "bar_orbit.png" %>) no-repeat scroll 0 0 transparent; + cursor:pointer; + height: 43px; + left: 10px; + position: relative; + width: 41px; +} +#orbit:hover{ + background-position:0 -43px; + box-shadow: 0 3px 3px #000000; +} +#orbit:hover #orblist{ + display:block; +} +#orblist{ + background: none repeat scroll 0 0 #FFFFFF; + border-radius: 0 3px 3px 3px; + box-shadow: 0 3px 3px #000000; + display: none; + margin: 0; + padding: 10px; + position: absolute; + top: 43px; + width: 130px; +} +#orblist li{ + border-bottom:1px solid #aaa; + list-style:none; +} +.orblink{ + color: #333333; + display: block; + font: 12px/100% arial,sans-serif; + padding: 5px; + text-decoration: none; +} +.orblink:hover{ + background:#eee; + color:#333; +} + +#log_out a{ + background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right 0 transparent; + border: medium none !important; + display: block !important; + height: 40px !important; + line-height: normal !important; + padding: 0 !important; + position: absolute; + right: 0px; + text-indent: -10000px; + top: 0px; + width: 43px !important; +} +#log_out a:hover{ + background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right bottom transparent !important; +} +.lang{ + color: #FFFFFF; + font-size: 15px; + line-height: 40px; + position: absolute; + right: 55px; + top: 0; +} + +.lang a{ + color:#fff; + text-decoration:none; +} + +.lang a:hover{ + text-decoration:underline; +} + +#content{ + height: 100%; +} +#sidebar { + background: url(<%= asset_path "75.png" %>) repeat scroll left top transparent; + box-shadow: 3px 0 4px #472A12; + border-right: 1px solid #121212; + height: 100%; + left: 0; + position: fixed; + top: 0; + width: 220px; +} +#search { + background: url(<%= asset_path "search_block_bg.jpg" %>) repeat-x scroll left top transparent; + height: 20px; + margin-top: 43px; + padding: 15px 12px; +} +#search input { + background: url(<%= asset_path "search_bg.png" %>) no-repeat scroll left top transparent; + border: medium none; + font-family: Helvetica; + height: 20px; + padding: 0 20px; + width: 154px; +} +h1 { + background: url(<%= asset_path "h1_bg.png" %>) repeat-x scroll left top transparent; + border-bottom: 1px solid #1B1B1B; + border-top: 1px solid #424344; + color: #FFFFFF; + font-size: 12px; + font-weight: normal; + height: 21px; + line-height: 21px; + margin: 0; + padding-left: 10px; + text-shadow: 0 -1px 0 #000000; +} +.member_setup .list { + color:#fff; + font-size:12px; + background:url(<%= asset_path "line.png" %>) repeat-x left bottom; +} +.member_setup .list li { + background:url(<%= asset_path "sidebar_li.jpg" %>) repeat-x left top; + border-top:1px solid #424344; + border-bottom:1px solid #000000; +} +.member_setup .list li:hover { + background-position:left bottom; + border-top:1px solid #406cc3; + border-bottom:1px solid #242628; +} +.member_setup .list li a { + display: block; + padding: 7px 0 6px 12px; + color:#c4c4c4; +} +.member_setup .list li a span { + background:url(<%= asset_path "add_mamber.png" %>) left top no-repeat; + text-shadow: 0px 1px 0px #000; + line-height: 18px; + padding: 2px 0 1px 35px; +} +.member_setup .list li a:hover span { + background-position:left bottom; + color:#eeeeee; +} +.users .list .set_1 { + background-position:left bottom; + border-top:1px solid #406cc3; + border-bottom:1px solid #242628; +} +.users .list .set_1 a span { + background-position:left bottom; + color:#eeeeee; +} +.user_role_models .list .set_2 { + background-position:left bottom; + border-top:1px solid #406cc3; + border-bottom:1px solid #242628; +} +.user_role_models .list .set_2 a span { + background-position:left bottom; + color:#eeeeee; +} +.user_info_models .list .set_3 { + background-position:left bottom; + border-top:1px solid #406cc3; + border-bottom:1px solid #242628; +} +.user_info_models .list .set_3 a span { + background-position:left bottom; + color:#eeeeee; +} +.main { + height: 100%; + margin-left: 260px; + padding-right: 40px; + position: relative; +} +.main_list { + padding-top: 70px; +} +.main_list ul { + clear:both; +} +#porfile { + padding-top: 100px; +} +/*add_buttom*/ +.button_bar { + float: right; + -moz-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; + -webkit-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; + box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; + background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #4f4f4f), color-stop(1, #000000) ); + background:-moz-linear-gradient( center top, #4f4f4f 5%, #000000 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#4f4f4f', endColorstr='#000000'); + background-color:#4f4f4f; + -moz-border-radius:5px; + -webkit-border-radius:5px; + border-radius:5px; + display:inline-block; + padding:0; + margin:10px 0; +} +.button_bar a { + text-decoration:none; + text-shadow:0px -1px 0px #000000; + font-size:12px; + color:#EDEDED; + border-right:1px solid #555; + -moz-box-shadow:1px 0px 0px black; + -webkit-box-shadow:1px 0px 0px black; + box-shadow:1px 0px 0px black; + padding: 6px 10px 4px; + display: inline-block; + float: left; +} +.button_bar a:active { + padding: 7px 10px 3px; + text-shadow:0px 1px 0px #000000; + background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #000000), color-stop(1, #4f4f4f) ); + background:-moz-linear-gradient( center top, #000000 5%, #4f4f4f 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#4f4f4f'); +} +.button_bar a:last-child { + border-right:none; + -moz-box-shadow:none; + -webkit-box-shadow:none; + box-shadow:none; + -moz-border-radius:0px 5px 5px 0px; + -webkit-border-radius:0px 5px 5px 0px; + border-radius:0px 5px 5px 0px; +} +.button_bar a:first-child { + -moz-border-radius:5px 0px 0px 5px; + -webkit-border-radius:5px 0px 0px 5px; + border-radius:5px 0px 0px 5px; +} +.button_bar a.new { + -moz-border-radius:5px; + -webkit-border-radius:5px; + border-radius:5px; +} +.button_bar a:hover { + color:#FFFFFF; +} \ No newline at end of file diff --git a/app/assets/javascripts/user_attribute_model_form.js b/app/assets/javascripts/user_attribute_model_form.js index 6b8d454b..1e1e2ef5 100644 --- a/app/assets/javascripts/user_attribute_model_form.js +++ b/app/assets/javascripts/user_attribute_model_form.js @@ -30,4 +30,4 @@ $('.select_type select').live('change', function(){ { $(this).next().hide(); } -}); \ No newline at end of file +}); \ No newline at end of file diff --git a/app/assets/stylesheets/_form.html.erb b/app/assets/stylesheets/_form.html.erb new file mode 100644 index 00000000..edbcae39 --- /dev/null +++ b/app/assets/stylesheets/_form.html.erb @@ -0,0 +1,57 @@ +
+

<%= t("admin.user_#{@attribute}") %>

+
+ + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + +
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @user_attribute_model.key %> + <%= text_field_tag "user_#{@attribute}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> +
+
+
+ + +
+

Attributes

+
+ + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + + + + + + <%= render :partial => 'admin/user_attribute_models/attribute_model', :collection => @user_attribute_model.attribute_models %> + +
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
<%= t(:add) %>
+
+
+ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "user_attribute_model_form" %> +<% end -%> diff --git a/app/assets/stylesheets/admin.css.erb b/app/assets/stylesheets/admin.css.erb index 7322013b..59324e97 100644 --- a/app/assets/stylesheets/admin.css.erb +++ b/app/assets/stylesheets/admin.css.erb @@ -1,8 +1,9 @@ -/* - *This is a manifest file that'll automatically include all the stylesheets available in this directory - *and any sub-directories. You're free to add application-wide styles to this file and they'll appear at - *the top of the compiled file, but it's generally better to create a new file per style scope. - *= require_self - *= require message - *= require admin_back_end +/* + *This is a manifest file that'll automatically include all the stylesheets available in this directory + *and any sub-directories. You're free to add application-wide styles to this file and they'll appear at + *the top of the compiled file, but it's generally better to create a new file per style scope. + *= require reset + *= require_self + *= require message + *= require admin_back_end */ \ No newline at end of file diff --git a/app/assets/stylesheets/admin_back_end.css.erb b/app/assets/stylesheets/admin_back_end.css.erb index fea5605e..89f2c874 100644 --- a/app/assets/stylesheets/admin_back_end.css.erb +++ b/app/assets/stylesheets/admin_back_end.css.erb @@ -1,354 +1,490 @@ -html, body{ - height: 100%; - margin: 0; - padding: 0; -} -html{ - background: url(<%= asset_path "body.jpg" %>) no-repeat scroll 0 0 transparent; - background-size: cover; -} - -body{ - color: #000000; - font-family: helvetica,arial,sans-serif; - margin: 0; - padding: 0; -} - -#panel_banner_link{ - background: url(<%= asset_path "orbitbar1.png" %>) repeat-x scroll 0 0; - height: 52px; - left: 0; - position: absolute; - top: 0; - width: 100%; -} -.hmenu{ - height: 40px; - position: absolute; - right: 0; - top: 1px; - width: 250px; -} - - -#orbit{ - background: url(<%= asset_path "bar_orbit.png" %>) no-repeat scroll 0 0 transparent; - cursor:pointer; - height: 43px; - left: 10px; - position: relative; - width: 41px; -} - -#orbit:hover{ - background-position:0 -43px; - box-shadow: 0 3px 3px #000000; -} -#orbit:hover #orblist{ - display:block; -} -#orblist{ - background: none repeat scroll 0 0 #FFFFFF; - border-radius: 0 3px 3px 3px; - box-shadow: 0 3px 3px #000000; - display: none; - margin: 0; - padding: 10px; - position: absolute; - top: 43px; - width: 130px; -} -#orblist li{ - border-bottom:1px solid #aaa; - list-style:none; -} -.orblink{ - color: #333333; - display: block; - font: 12px/100% arial,sans-serif; - padding: 5px; - text-decoration: none; -} -.orblink:hover{ - background:#eee; - color:#333; -} - -#log_out a{ - background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right 0 transparent; - border: medium none !important; - display: block !important; - height: 40px !important; - line-height: normal !important; - padding: 0 !important; - position: absolute; - right: 0px; - text-indent: -10000px; - top: 0px; - width: 43px !important; -} -#log_out a:hover{ - background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right bottom transparent !important; -} -.lang{ - color: #FFFFFF; - font-size: 15px; - line-height: 40px; - position: absolute; - right: 55px; - top: 0; -} - -.lang a{ - color:#fff; - text-decoration:none; -} - -.lang a:hover{ - text-decoration:underline; -} - -#panel_container{ - height: 100%; -} - -#panel_container h1{ - color: #FFFFFF; - font: 32px/100% helvetica,arial,sans-serif; - margin: 0 0 20px; - padding: 0; - text-shadow: 0 0 5px #000000; -} - -#panel_header{ - background: none repeat scroll 0 0 #F1F1F1; - border-bottom: 1px solid #818181; - padding: 10px; -} -#panel_header :after { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; -} -#panel_header #nav{ - margin:0; - padding:0; - width:100%; -} - -#panel_header #nav li{ - float: left; - list-style: none outside none; -} - -#panel_header #nav li a{ - background: none repeat scroll 0 0 #fff; - border-radius: 13px 13px 13px 13px; - border: 1px solid #D6D6D6; - color: #000000; - float: left; - font-size:15px; - margin: 0 20px 0 0; - padding: 5px 10px; - text-decoration: none; -} - -#panel_header #nav li a:hover{ - background: none repeat scroll 0 0 #818181; - border-radius: 13px 13px 13px 13px; - color: #fff; -} - -#panel_content{ - height: 100%; -} - -.main{ - float: left; - height: 100%; - padding: 0 1%; - width: 81%; -} -.main2{ - padding: 62px 0 0; -} -.main table{ - border-collapse: collapse; - width:100%; -} -.main table th{ - border-bottom: 1px solid #222222; - color: #FFFFFF; - font: 20px/100% helvetica,arial,sans-serif; - letter-spacing: 0.05em; - padding: 10px; - text-shadow: 0 0 3px #000000; -} -.main table td{ - background: none repeat scroll 0 0 rgba(0, 0, 0, 0.5); - border-bottom: 1px solid #222222; - color: #FFFFFF; - padding: 10px; - text-align: center; -} - -.main table td a{ - background: none repeat scroll 0 0 #FFFFFF; - border-radius: 5px 5px 5px 5px; - color: #000000; - padding: 5px; - text-decoration: none; -} - -.main table td a:hover{ - background: none repeat scroll 0 0 #eee; - border-radius: 5px 5px 5px 5px; - color: #333; -} -.secondary{ - background: none repeat scroll 0 0 rgba(0, 0, 0, 0.75); - box-shadow: 3px 0 3px #000000; - float: left; - height: 100%; - padding: 0 1%; - width: 14%; -} -.secondary2{ - padding: 62px 0 0; -} -.secondary ul{ - margin: 0; - padding: 0; -} -.secondary ul li{ - list-style:none; -} -.secondary ul li a{ - border-bottom: 1px solid #333; - color: #AAAAAA; - display: block; - padding: 14px 0; - text-align: left; - text-decoration: none; -} -.seclink1{ - background: url(<%= asset_path "icon1.png" %>) no-repeat scroll 20px 8px transparent; - border-bottom: 1px solid #333; - color: #AAAAAA; - display: block; - padding: 14px 0 14px 60px !important; - text-align: left; - text-decoration: none; -} -.seclink2{ - background: url(<%= asset_path "icon2.png" %>) no-repeat scroll 20px 14px transparent; - border-bottom: 1px solid #333; - color: #AAAAAA; - display: block; - padding: 14px 0 14px 60px !important; - text-align: left; - text-decoration: none; -} -.secondary ul li a:hover{ - color: #fff; -} - -#panel_footer{ - background: none repeat scroll 0 0 #FFFFFF; - display:none; - clear: both; - padding: 10px; -} -#panel_footer p{ - margin:0; -} -label{ - color: #FFFFFF; - display: block; - text-shadow: 0 0 5px #000000; - width: 130px; -} -p{ - margin:0 0 10px; -} -#panel_main p label{ - float: left; - padding: 3px; - width: 100px; -} -#panel_main .translation_missing{ - float: left; - padding: 3px; - width: 100px; - -} -.text{ - border: 1px solid #818181; - border-radius: 3px 3px 3px 3px; - font: 12px/100% helvetica,arial,sans-serif; - padding: 3px; - width: 205px; -} - -#site_info{ - background: none repeat scroll 0 0 #FFFFFF; - border-radius: 5px 5px 5px 5px; - box-shadow: 0 0 5px #000000; -/* height: 289px;*/ - margin: 0 0 20px; - overflow: hidden; - width: 600px; -} -#siteinfo_title{ - background: none repeat scroll 0 0 #333333; - color: #FFFFFF; - font: 24px/50px arial,sans-serif; - height: 50px; - margin: 0; - padding: 0 0 0 20px; - text-shadow: 0 1px 0 #000000; -} -#siteinfo_tb{ - background: none repeat scroll 0 0 #FFFFFF; -} -#siteinfo_tb td{ - background: none repeat scroll 0 0 transparent; - border-bottom: 1px solid #333333; - color: #333333; -} - -.buy_btn{ - float:left; - margin: 0 10px 0 0; -} -.main table td .buy_btn a{ - background: url("/assets/buy_btn.png") no-repeat scroll 0 0 transparent; - color: #000000; - display: block; - font-size: 22px; - height: 37px; - line-height: 37px; - text-align: center; - text-decoration: none; - text-shadow: 0 1px 0 #FFFFFF; - width: 170px; - padding: 0px; -} -.buy_btn a:hover{ - background-position:0 bottom; -} -.bought_btn{ - background: url("/assets/bought_btn.png") no-repeat scroll 0 0 transparent; - color: #FFFFFF; - float:left; - font-size: 22px; - height: 37px; - line-height: 37px; - margin: 0 10px 0 0; - text-align: center; - text-shadow: 0 1px 0 #C06408; - width: 170px; +html, body{ + height: 100%; + margin: 0; + padding: 0; +} +html{ + background: url(<%= asset_path "body.jpg" %>) no-repeat scroll 0 0 transparent; + background-size: cover; +} + +body{ + color: #000000; + font-family: Helvetica, '微軟正黑體'; +} + +#panel_banner_link{ + background: url(<%= asset_path "orbitbar1.png" %>) repeat-x scroll 0 0; + height: 50px; + left: 0; + position: fixed; + top: 0; + width: 100%; + z-index: 5; +} +.hmenu{ + height: 40px; + position: absolute; + right: 0; + top: 1px; + width: 250px; +} +#orbit{ + background: url(<%= asset_path "bar_orbit.png" %>) no-repeat scroll 0 0 transparent; + cursor:pointer; + height: 43px; + left: 10px; + position: relative; + width: 41px; +} +#orbit:hover{ + background-position:0 -43px; + box-shadow: 0 3px 3px #000000; +} +#orbit:hover #orblist{ + display:block; +} +#orblist{ + background: none repeat scroll 0 0 #FFFFFF; + border-radius: 0 3px 3px 3px; + box-shadow: 0 3px 3px #000000; + display: none; + margin: 0; + padding: 10px; + position: absolute; + top: 43px; + width: 130px; +} +#orblist li{ + border-bottom:1px solid #aaa; + list-style:none; +} +.orblink{ + color: #333333; + display: block; + font: 12px/100% arial,sans-serif; + padding: 5px; + text-decoration: none; +} +.orblink:hover{ + background:#eee; + color:#333; +} + +#log_out a{ + background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right 0 transparent; + border: medium none !important; + display: block !important; + height: 40px !important; + line-height: normal !important; + padding: 0 !important; + position: absolute; + right: 0px; + text-indent: -10000px; + top: 0px; + width: 43px !important; +} +#log_out a:hover{ + background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right bottom transparent !important; +} +.lang{ + color: #FFFFFF; + font-size: 15px; + line-height: 40px; + position: absolute; + right: 55px; + top: 0; +} +.lang a{ + color:#fff; + text-decoration:none; +} +.lang a:hover{ + text-decoration:underline; +} +#content{ + height: 100%; +} +#panel_footer{ + background-color: #101010; + bottom: 0; + color: #FFFFFF; + font-size: 11px; + padding: 10px; + position: fixed; + width: 100%; + left: 0; + box-shadow: 0 -3px 4px #000; +} +#sidebar { + background: url(<%= asset_path "75.png" %>) repeat scroll left top transparent; + box-shadow: 3px 0 4px #472A12; + border-right: 1px solid #121212; + height: 100%; + left: 0; + position: fixed; + top: 0; + width: 220px; +} +#search { + background: url(<%= asset_path "search_block_bg.jpg" %>) repeat-x scroll left top transparent; + height: 20px; + margin-top: 43px; + padding: 15px 12px; +} +#search input { + background: url(<%= asset_path "search_bg.png" %>) no-repeat scroll left top transparent; + border: medium none; + font-family: Helvetica; + height: 20px; + padding: 0 20px; + width: 154px; +} +h1 { + background: url(<%= asset_path "h1_bg.png" %>) repeat-x scroll left top transparent; + border-bottom: 1px solid #1B1B1B; + border-top: 1px solid #424344; + color: #FFFFFF; + font-size: 12px; + font-weight: normal; + height: 21px; + line-height: 21px; + margin: 0; + padding-left: 10px; + text-shadow: 0 -1px 0 #000000; +} +.member_setup .list { + color:#fff; + font-size:12px; + background:url(<%= asset_path "line.png" %>) repeat-x left bottom; +} +.member_setup .list li { + background:url(<%= asset_path "sidebar_li.jpg" %>) repeat-x left top; + border-top:1px solid #424344; + border-bottom:1px solid #000000; +} +.member_setup .list li:hover { + background-position:left bottom; + border-top:1px solid #406cc3; + border-bottom:1px solid #242628; +} +.member_setup .list li a { + display: block; + padding: 7px 0 6px 12px; + color:#c4c4c4; +} +.member_setup .list li a span { + background:url(<%= asset_path "add_mamber.png" %>) left top no-repeat; + text-shadow: 0px 1px 0px #000; + line-height: 18px; + padding: 2px 0 1px 35px; +} +.member_setup .list li a:hover span { + background-position:left bottom; + color:#eeeeee; +} +#sidebar .users .list .set_1 { + background-position:left bottom; + border-top:1px solid #406cc3; + border-bottom:1px solid #242628; +} +#sidebar .users .list .set_1 a span { + background-position:left bottom; + color:#eeeeee; +} +#sidebar .roles .list .set_2 { + background-position:left bottom; + border-top:1px solid #406cc3; + border-bottom:1px solid #242628; +} +#sidebar .roles .list .set_2 a span { + background-position:left bottom; + color:#eeeeee; +} +#sidebar .infos .list .set_3 { + background-position:left bottom; + border-top:1px solid #406cc3; + border-bottom:1px solid #242628; +} +#sidebar .infos .list .set_3 a span { + background-position:left bottom; + color:#eeeeee; +} +.main { + height: 100%; + margin-left: 260px; + padding-right: 40px; + position: relative; +} +.main_list { + padding-top: 70px; +} +.main_list ul { + clear:both; +} +#porfile { + padding-top: 100px; +} +/*add_buttom*/ +.button_bar { + float: right; + -moz-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; + -webkit-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; + box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; + background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #4f4f4f), color-stop(1, #000000) ); + background:-moz-linear-gradient( center top, #4f4f4f 5%, #000000 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#4f4f4f', endColorstr='#000000'); + background-color:#4f4f4f; + -moz-border-radius:5px; + -webkit-border-radius:5px; + border-radius:5px; + display:inline-block; + padding:0; + margin:10px 0 60px; +} +.button_bar a { + text-decoration:none; + text-shadow:0px -1px 0px #000000; + font-size:12px; + color:#EDEDED; + border-right:1px solid #555; + -moz-box-shadow:1px 0px 0px black; + -webkit-box-shadow:1px 0px 0px black; + box-shadow:1px 0px 0px black; + padding: 6px 10px 4px; + display: inline-block; + float: left; +} +.button_bar a:active { + padding: 7px 10px 3px !important; + text-shadow:0px 1px 0px #000000; + background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #000000), color-stop(1, #4f4f4f) ); + background:-moz-linear-gradient( center top, #000000 5%, #4f4f4f 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#4f4f4f'); +} +.button_bar a:last-child { + border-right:none; + -moz-box-shadow:none; + -webkit-box-shadow:none; + box-shadow:none; + -moz-border-radius:0px 5px 5px 0px; + -webkit-border-radius:0px 5px 5px 0px; + border-radius:0px 5px 5px 0px; +} +.button_bar a:first-child { + -moz-border-radius:5px 0px 0px 5px; + -webkit-border-radius:5px 0px 0px 5px; + border-radius:5px 0px 0px 5px; +} +.button_bar a.new { + padding: 5px 10px; + -moz-border-radius:5px; + -webkit-border-radius:5px; + border-radius:5px; +} +.button_bar a:hover { + color:#FFFFFF; +} +.up { + margin:10px 0; +} +#person { + left: 245px; + position: fixed; + text-align: center; + top: 75px; + width: 140px; + background-color:#FFF; + padding:15px; + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + -moz-box-shadow: 0px 0px 4px #180902; /* Firefox */ + -webkit-box-shadow: 0px 0px 4px #180902;/* Safari 和 Chrome */ + box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */ +} +#file { + display:none; +} +#person img { +} +.user_mail { + border: medium none; + border:1px solid #DDDDDD; + color: #666666; + font-size: 12px; + width: 140px; +} +#person label { + display: block; + margin: 15px 0 0; +} +#person label input { +} +#person label #user_admin { + float:right; + margin: 0; +} +#person label span { + text-align:left; + font-size:11px; + color:#888; + display:block; +} +#person select { + border: 1px solid #DDDDDD; + padding: 0; + width: 140px; +} +#porfile .users{ + margin-left: 180px; +} +.roles_block { + background: url(<%= asset_path "75.png" %>) repeat left top; + min-width:710px; + margin-bottom:50px; + position:relative; + padding-bottom: 20px; + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + -moz-box-shadow: 0px 0px 4px #180902; /* Firefox */ + -webkit-box-shadow: 0px 0px 4px #180902;/* Safari 和 Chrome */ + box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */ +} +.roles_block h2 { + color: #FFFFFF; + font-weight: normal; + margin: 0; + padding: 0; + position: absolute; + text-shadow: 0 3px 2px #000000; + top: -30px; +} +.main hr { + height:8px; + border:none; + margin:0; + border-radius: 5px 5px 0px 0px; + -moz-border-radius: 5px 5px 0px 0px; + -webkit-border-radius: 5px 5px 0px 0px; + border-bottom:1px solid #000; +} +#basic_block hr { + background-color: #666666; +} +#teacher_block hr { + background-color: #0071A9; +} +#student_block hr { + background-color: #AF0045; +} +.info_input { + padding:10px 20px; +} +.info_input table { + color:#fff; + width:100%; + font-size:14px; +} +.info_input table td { + padding:5px 10px 5px 0; + width: 10%; +} +.info_input .list_head { + background:url(<%= asset_path "line.png" %>) left bottom repeat-x; +} +.info_input .list_head td { +} +.info_input .list_item { + color:#AEAEAE; +} +.info_input .add { + display:block; + padding-left:22px; + font-size:12px; + line-height:21px; + height:19px; + background:url(<%= asset_path "icon.png" %>) no-repeat -59px 0; + margin-top: 10px; + color: #DDDDDD; +} + +.main table { + width:100%; +} +.main td { + padding-left:20px; + color:#fff; + font-size:14px; + line-height:40px; +} +.main thead td { + line-height:40px; + font-size:16px; + text-shadow: 0px 1px 1px #3e2914; +} +.main thead td.action { + width:15% +} +.main tbody td.roles { + background-image: url(<%= asset_path "roles_type.jpg" %>); + background-repeat: repeat-x; +} +.main tbody td.teacher { + background-position: 0 -54px; +} +.main tbody td.student { + background-position: 0 -5px; +} +.main tbody td.action a { + background-image: url(<%= asset_path "icon.png" %>); + display: inline-block; + height: 19px; + margin-right: 10px; + top: 8px; + text-indent: -9999px; + width: 19px; + position: relative; +} +.main tbody td.action a.show { + background-position: left top; +} +.main tbody td.action a.show:hover { + background-position: left -19px; +} +.main tbody td.action a.edit { + background-position: -19px top; +} +.main tbody td.action a.edit:hover { + background-position: -19px -19px; +} +.main tbody td.action a.delete { + background-position: -38px top; +} +.main tbody td.action a.delete:hover { + background-position: -38px -19px; +} +.main tbody td.action a.switch { + background: url(<%= asset_path "switch.png" %>) no-repeat left 3px; + width: 40px; +} +.main tbody tr.disable td.action a.switch { + background-position:left bottom; +} +.main tbody td.action a.delete:hover { + background-position: -38px -19px; +} +.main tbody tr.have { + background: url(<%= asset_path "75.png" %>) repeat left top; + -moz-box-shadow: 0px 0px 6px #291508; /* Firefox */ + -webkit-box-shadow: 0px 0px 6px #291508;/* Safari 和 Chrome */ + box-shadow: 0px 0px 6px #291508; /* Opera 10.5 + */ +} +.main tbody tr.disable { + opacity: 0.7; +} +.main tbody tr { + background:none; + height:15px; } \ No newline at end of file diff --git a/app/assets/stylesheets/reset.css b/app/assets/stylesheets/reset.css new file mode 100644 index 00000000..44f2ae77 --- /dev/null +++ b/app/assets/stylesheets/reset.css @@ -0,0 +1,44 @@ +html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { + display: block; +} +a { + text-decoration:none; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} +/*自定*/ +input:focus, select:focus, textarea:focus { + outline:none; + -moz-outline-radius: 0; +} +.clear:after { + content:"."; + clear:both; + display:block; + height:0; + visibility:hidden; +} diff --git a/app/assets/stylesheets/reset.css.erb b/app/assets/stylesheets/reset.css.erb new file mode 100644 index 00000000..44f2ae77 --- /dev/null +++ b/app/assets/stylesheets/reset.css.erb @@ -0,0 +1,44 @@ +html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { + display: block; +} +a { + text-decoration:none; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} +/*自定*/ +input:focus, select:focus, textarea:focus { + outline:none; + -moz-outline-radius: 0; +} +.clear:after { + content:"."; + clear:both; + display:block; + height:0; + visibility:hidden; +} diff --git a/app/controllers/admin/user_info_models_controller.rb b/app/controllers/admin/user_info_models_controller.rb new file mode 100644 index 00000000..60360463 --- /dev/null +++ b/app/controllers/admin/user_info_models_controller.rb @@ -0,0 +1,59 @@ +class Admin::UserInfoModelsController < ApplicationController + + layout "admin" + before_filter :authenticate_user! + before_filter :is_admin? + before_filter :set_attribute, :only => [:index, :show, :new, :edit] + + def index + @user_attribute_models = UserInfoModel.all.entries + render :template => 'admin/user_attribute_models/index' + end + + def show + #@user_attribute_model = UserInfoModel.find(params[:id]) + end + + def new + @user_attribute_model = UserInfoModel.new + render :template => 'admin/user_attribute_models/new' + end + + def edit + @user_attribute_model = UserInfoModel.find(params[:id]) + @i18n_variable = @user_attribute_model.i18n_variable + render :template => 'admin/user_attribute_models/edit' + end + + def create + @user_attribute_model = UserInfoModel.new(params[:user_info_model]) + @user_attribute_model.save + redirect_to :action => :index + end + + def update + @user_attribute_model = UserInfoModel.find(params[:id]) + @user_attribute_model.update_attributes(params[:user_info_model]) + respond_to do |format| + format.html { redirect_to :action => :index } + format.js { render 'admin/user_attribute_models/toggle_enable' } + end + end + + def destroy + @user_attribute_model = UserInfoModel.find(params[:id]) + @user_attribute_model.destroy + + @user_attribute_model.destroy_i18n_variables + + redirect_to :action => :index + end + + protected + + def set_attribute + @attribute = 'info' + @class = 'infos' + end + +end diff --git a/app/controllers/admin/user_role_models_controller.rb b/app/controllers/admin/user_role_models_controller.rb new file mode 100644 index 00000000..bfdf5428 --- /dev/null +++ b/app/controllers/admin/user_role_models_controller.rb @@ -0,0 +1,60 @@ +class Admin::UserRoleModelsController < ApplicationController + + layout "admin" + before_filter :authenticate_user! + before_filter :is_admin? + before_filter :set_attribute, :only => [:index, :show, :new, :edit] + + def index + @user_attribute_models = UserRoleModel.all.entries + render :template => 'admin/user_attribute_models/index' + end + + def show + #@user_attribute_model = UserRoleModel.find(params[:id]) + end + + def new + @user_attribute_model = UserRoleModel.new + render :template => 'admin/user_attribute_models/new' + end + + def edit + @user_attribute_model = UserRoleModel.find(params[:id]) + @i18n_variable = @user_attribute_model.i18n_variable + render :template => 'admin/user_attribute_models/edit' + end + + def create + @user_attribute_model = UserRoleModel.new(params[:user_role_model]) + @user_attribute_model.save + redirect_to :action => :index + end + + def update + @user_attribute_model = UserRoleModel.find(params[:id]) + @user_attribute_model.update_attributes(params[:user_role_model]) + + respond_to do |format| + format.html { redirect_to :action => :index } + format.js { render 'admin/user_attribute_models/toggle_enable' } + end + end + + def destroy + @user_attribute_model = UserRoleModel.find(params[:id]) + @user_attribute_model.destroy + + @user_attribute_model.destroy_i18n_variables + + redirect_to :action => :index + end + + protected + + def set_attribute + @attribute = 'role' + @class = 'roles' + end + +end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 77cada1b..2a6c0a99 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,84 +1,89 @@ -class Admin::UsersController < ApplicationController - - layout "admin" - before_filter :authenticate_user! - - def index - @users = User.all.entries - end - - def show - @user = User.find(params[:id]) - get_info_role_models - end - - def new - @user = User.new - get_info_role_models - end - - def create - @user = User.new(params[:user]) - if @user.save - @user.user_infos.each do |info| - info.save - info.attribute_values.each(&:save) - end - @user.roles.each do |role| - role.save - role.attribute_values.each(&:save) - end - flash[:notice] = t('admin.create_success_user') - redirect_to :action => :index - else - render :action => :new - end - end - - def edit - @user = User.find(params[:id]) - get_info_role_models - end - - def update - @user = User.find(params[:id]) - - # Update changes to the avatar - @user.remove_avatar! if params[:file] - @user.avatar = params[:file] if params[:file] - - if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b - flash.now[:error] = t('admin.cant_revoke_self_admin') - end - if !flash[:error] && @user.update_attributes(params[:user]) - flash[:notice] = t('admin.update_success_user') - redirect_to :action => :index - else - get_info_role_models - render :action => :edit - end - end - - def destroy - if params[:id].eql?(session['warden.user.user.key'][1].to_s) - flash[:error] = t('admin.cant_delete_self') - else - @user = User.find(params[:id]) - @user.destroy - @user.user_attributes.each do |ua| - ua.attribute_values.each(&:destroy) - ua.destroy - end - end - - redirect_to :action => :index - end - - protected - - def get_info_role_models - @roles = Info.excludes('disabled' => true) - @infos = Role.excludes('disabled' => true) - end - -end +class Admin::UsersController < ApplicationController + + layout "admin" + before_filter :authenticate_user! + before_filter :set_attribute, :only => [:index, :show, :new, :edit] + + def index + @users = User.all.entries + end + + def show + @user = User.find(params[:id]) + get_info_role_models + end + + def new + @user = User.new + get_info_role_models + end + + def create + @user = User.new(params[:user]) + if @user.save + @user.user_infos.each do |info| + info.save + info.attribute_values.each(&:save) + end + @user.roles.each do |role| + role.save + role.attribute_values.each(&:save) + end + flash[:notice] = t('admin.create_success_user') + redirect_to :action => :index + else + render :action => :new + end + end + + def edit + @user = User.find(params[:id]) + get_info_role_models + end + + def update + @user = User.find(params[:id]) + + # Update changes to the avatar + @user.remove_avatar! if params[:file] + @user.avatar = params[:file] if params[:file] + + if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b + flash.now[:error] = t('admin.cant_revoke_self_admin') + end + if !flash[:error] && @user.update_attributes(params[:user]) + flash[:notice] = t('admin.update_success_user') + redirect_to :action => :index + else + get_info_role_models + render :action => :edit + end + end + + def destroy + if params[:id].eql?(session['warden.user.user.key'][1].to_s) + flash[:error] = t('admin.cant_delete_self') + else + @user = User.find(params[:id]) + @user.destroy + @user.user_attributes.each do |ua| + ua.attribute_values.each(&:destroy) + ua.destroy + end + end + + redirect_to :action => :index + end + + protected + + def get_info_role_models + @roles = Info.excludes('disabled' => true) + @infos = Role.excludes('disabled' => true) + end + + def set_attribute + @class = 'users' + end + +end \ No newline at end of file diff --git a/app/views/admin/user_attribute_models/_form.html.erb b/app/views/admin/user_attribute_models/_form.html.erb index 659eb353..edbcae39 100644 --- a/app/views/admin/user_attribute_models/_form.html.erb +++ b/app/views/admin/user_attribute_models/_form.html.erb @@ -1,57 +1,57 @@ -
-

<%= t("admin.user_#{@attribute}") %>

-
- - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - -
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @user_attribute_model.key %> - <%= text_field_tag "user_#{@attribute}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> -
-
-
- - -
-

Attributes

-
- - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - - - - - - <%= render :partial => 'admin/user_attribute_models/attribute_model', :collection => @user_attribute_model.attribute_models %> - -
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
<%= t(:add) %>
-
-
- -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "user_attribute_model_form" %> -<% end -%> +
+

<%= t("admin.user_#{@attribute}") %>

+
+ + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + +
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @user_attribute_model.key %> + <%= text_field_tag "user_#{@attribute}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> +
+
+
+ + +
+

Attributes

+
+ + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + + + + + + <%= render :partial => 'admin/user_attribute_models/attribute_model', :collection => @user_attribute_model.attribute_models %> + +
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
<%= t(:add) %>
+
+
+ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "user_attribute_model_form" %> +<% end -%> diff --git a/app/views/admin/user_attribute_models/admin.html.erb b/app/views/admin/user_attribute_models/admin.html.erb new file mode 100644 index 00000000..a4bbbb43 --- /dev/null +++ b/app/views/admin/user_attribute_models/admin.html.erb @@ -0,0 +1,31 @@ + + + + + <%= @title || APP_CONFIG['orbit'] %> + + <%= stylesheet_link_tag "admin" %> + <%= javascript_include_tag "admin" %> + <%= yield :page_specific_css %> + <%= yield :page_specific_javascript %> + <%= csrf_meta_tag %> + + + + +
+ +
+ <%= yield %> +
+
<%= yield :tertiary %>
+ +
+ + diff --git a/app/views/admin/user_attribute_models/edit.html.erb b/app/views/admin/user_attribute_models/edit.html.erb index b70e5275..d0442fb8 100644 --- a/app/views/admin/user_attribute_models/edit.html.erb +++ b/app/views/admin/user_attribute_models/edit.html.erb @@ -1,12 +1,14 @@ -
- <%= form_for @user_attribute_model, :url => eval("admin_user_#{@attribute}_model_path(@user_role_model)") do |f| %> - <%= f.error_messages %> - <%= render :partial => "admin/user_attribute_models/form", :locals => { :f => f, :is_new => false } %> -
- <%= link_to t('update'), "#", :onclick=>"$('#edit_user_role_model_#{@user_attribute_model.id}').submit()" %> -
-
- <%= link_back %> -
- <% end -%> +<% content_for :secondary do %> + <%= render 'side_bar' %> +<% end %> + +
+ <%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %> + <%= f.error_messages %> + <%= render :partial => 'form', :locals => { :f => f } %> +
+ <%= link_back %> + <%= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').submit()" %> +
+ <% end -%>
\ No newline at end of file diff --git a/app/views/admin/user_attribute_models/index.html.erb b/app/views/admin/user_attribute_models/index.html.erb index c7a65d65..87c5bb2c 100644 --- a/app/views/admin/user_attribute_models/index.html.erb +++ b/app/views/admin/user_attribute_models/index.html.erb @@ -1,30 +1,41 @@ -
-
- <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %> -
-
    -
  • - <%= t("admin.#{@attribute}") %> - <%= t('admin.action') %> -
  • - <% @user_attribute_models.each do |user_attribute_model| %> -
  • clear"> - <%= user_attribute_model.i18n_variable[I18n.locale] %> - - - <%= link_to t(:edit), eval("edit_admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'edit' %> - <% if user_attribute_model.is_built_in? %> - <%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %> - <%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %> - <% else %> - <%= link_to t(:delete), eval("admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %> - <% end %> - - -
  • - <% end %> -
-
- <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %> -
-
+<% content_for :secondary do %> + <%= render 'admin/users/side_bar' %> +<% end %> + +
+
+ <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path"), :class => 'new' %> +
+ + + + + + + + + <% @user_attribute_models.each do |user_attribute_model| %> + "> + + + + + + + <% end %> + +
<%= t("admin.#{@attribute}") %><%= t('admin.action') %>
<%= user_attribute_model.i18n_variable[I18n.locale] %> + <%= link_to t(:edit), eval("edit_admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'edit' %> + <% if user_attribute_model.is_built_in? %> + <%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %> + <%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %> + <% else %> + <%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %> + <%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %> + <%= link_to t(:delete), eval("admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %> + <% end %> +
+
+ <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path"), :class => 'new' %> +
+
diff --git a/app/views/admin/user_attribute_models/new.html.erb b/app/views/admin/user_attribute_models/new.html.erb index 4dd1baa6..490561fa 100644 --- a/app/views/admin/user_attribute_models/new.html.erb +++ b/app/views/admin/user_attribute_models/new.html.erb @@ -1,16 +1,18 @@ -
- <%= form_for @user_attribute_model, :url => eval("admin_user_#{@attribute}_models_path") do |f| %> - <%= f.error_messages %> - <%= render :partial => "admin/user_attribute_models/form", :locals => { :f => f, :is_new => true } %> -
- <%= link_to t('create'), "#", :onclick=>"$('#new_user_attribute_model').submit()" %> -
-
- <%= link_back %> -
- <% end -%> -
- - - - +<% content_for :secondary do %> + <%= render 'admin/users/side_bar' %> +<% end %> + +
+ <%= form_for @user_attribute_model, :url => eval("admin_user_#{@attribute}_models_path") do |f| %> + <%= f.error_messages %> + <%= render :partial => "admin/user_attribute_models/form", :locals => { :f => f, :is_new => true } %> +
+ <%= link_back %> + <%= link_to t('create'), "#", :onclick=>"$('#new_user_attribute_model').submit()" %> +
+ <% end -%> +
+ + + + diff --git a/app/views/admin/user_attributes/index.html.erb b/app/views/admin/user_attributes/index.html.erb new file mode 100644 index 00000000..b5965a79 --- /dev/null +++ b/app/views/admin/user_attributes/index.html.erb @@ -0,0 +1,34 @@ +<% content_for :secondary do %> + <%= render 'admin/users/side_bar' %> +<% end %> + +
+
+ <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %> +
+
    +
  • + <%= t("admin.#{@attribute}") %> + <%= t('admin.action') %> +
  • + <% @user_attribute_models.each do |user_attribute_model| %> +
  • clear"> + <%= user_attribute_model.i18n_variable[I18n.locale] %> + + + <%= link_to t(:edit), eval("edit_admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'edit' %> + <% if user_attribute_model.is_built_in? %> + <%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %> + <%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %> + <% else %> + <%= link_to t(:delete), eval("admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %> + <% end %> + + +
  • + <% end %> +
+
+ <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %> +
+
diff --git a/app/views/admin/user_attributes/new.html.erb b/app/views/admin/user_attributes/new.html.erb new file mode 100644 index 00000000..f04da0e5 --- /dev/null +++ b/app/views/admin/user_attributes/new.html.erb @@ -0,0 +1,16 @@ +

New user attribute: <%= @user_attribute.key %>

+ +<% form_for @user_attribute, :url => admin_user_attributes_path do |f| %> + +

+ <%= f.label :key, "Key" %> + <%= f.text_field :key %> +

+ + <%= render :partial => "form", :locals => { :f => f } %> + +

+ <%= f.submit %> +

+ +<% end -%> diff --git a/app/views/admin/users/_form.html.erb b/app/views/admin/users/_form.html.erb index 72c0e475..bbf39e4d 100644 --- a/app/views/admin/users/_form.html.erb +++ b/app/views/admin/users/_form.html.erb @@ -1,40 +1,47 @@ -
- <% if @user.avatar? %> - <%= image_tag(@user.avatar.thumb.url) %> - <% else %> - <%= image_tag "person.png" %> - <% end %> - <%= file_field_tag 'file' %> - <%= hidden_field_tag :avatar_cache %> - <%= f.text_field :email, :onfocus => "this.value='';", :onblur => "if(this.value==''){this.value=#{t('admin.email')};}", :value => (@user.email.blank? ? t('admin.email') : @user.email), :class => 'user_mail' %> - - <%= f.select :active_role, @user_role_models.sort_by{|role| role.key }.collect {|role| [ role.i18n_variable[I18n.locale], role.key ]}, :selected => (@user.active_role || 'student') %> -
- -<% @user_info_models.each do |ua| %> -
-

<%= ua.i18n_variable[I18n.locale] %>

-
- <%= render :partial => 'user_attribute', - :object => (@user.user_infos.detect {|u| u.key == ua.key } || @user.user_infos.build), - :locals => {:ua => ua, :type => 'info'} %> -
-<% end -%> - -
- <% @user_role_models.each do |ua| %> - - <% end -%> -
- -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "user_form" %> -<% end -%> +
+ <% if @user.avatar? %> + <%= image_tag(@user.avatar.thumb.url) %> + <% else %> + <%= image_tag "person.png" %> + <% end %> + <%= file_field_tag 'file' %> + <%= hidden_field_tag :avatar_cache %> + + + +
+ +<% @user_info_models.each do |ua| %> +
+

<%= ua.i18n_variable[I18n.locale] %>

+
+ <%= render :partial => 'user_attribute', + :object => (@user.user_infos.detect {|u| u.key == ua.key } || @user.user_infos.build), + :locals => {:ua => ua, :type => 'info'} %> +
+<% end -%> + +
+ <% @user_role_models.each do |ua| %> + + <% end -%> +
+ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "user_form" %> +<% end -%> diff --git a/app/views/admin/users/_show_user_attribute.html.erb b/app/views/admin/users/_show_user_attribute.html.erb index a6468944..b83295d7 100644 --- a/app/views/admin/users/_show_user_attribute.html.erb +++ b/app/views/admin/users/_show_user_attribute.html.erb @@ -1,27 +1,27 @@ -
- - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - <% am.get_enabled_attribute_models.each do |attr| %> - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - <% end %> - -
<%= t("admin.key") %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= attr.i18n_variable[I18n.locale] %> - <% if attr["locale"] && attr["markup"] == 'text_field' %> - <%= show_user_attribute(object, attr.key, locale) %> - <% else %> - <%= show_user_attribute(object, attr.key) %> - <% end %> -
+
+ + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + <% am.get_enabled_attribute_models.each do |attr| %> + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + <% end %> + +
<%= t("admin.key") %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= attr.i18n_variable[I18n.locale] %> + <% if attr["locale"] && attr["markup"] == 'text_field' %> + <%= show_user_attribute(object, attr.key, locale) %> + <% else %> + <%= show_user_attribute(object, attr.key) %> + <% end %> +
\ No newline at end of file diff --git a/app/views/admin/users/_side_bar.html.erb b/app/views/admin/users/_side_bar.html.erb index 8b8393db..ce0e1296 100644 --- a/app/views/admin/users/_side_bar.html.erb +++ b/app/views/admin/users/_side_bar.html.erb @@ -1,11 +1,11 @@ -
-

<%= t('admin.setup_member') %>

-
    -
  • <%= link_to content_tag(:span, t('admin.list_users')), admin_users_path %>
  • -
  • <%= link_to content_tag(:span, t('admin.list_roles')), admin_roles_path %>
  • -
  • <%= link_to content_tag(:span, t('admin.list_infos')), admin_infos_path %>
  • -
+
+

<%= t('admin.setup_member') %>

+
    +
  • <%= link_to content_tag(:span, t('admin.list_users')), admin_users_path %>
  • +
  • <%= link_to content_tag(:span, t('admin.list_roles')), admin_roles_path %>
  • +
  • <%= link_to content_tag(:span, t('admin.list_infos')), admin_infos_path %>
  • +
\ No newline at end of file diff --git a/app/views/admin/users/_user_attribute.html.erb b/app/views/admin/users/_user_attribute.html.erb index 1ee17890..0a4bd269 100644 --- a/app/views/admin/users/_user_attribute.html.erb +++ b/app/views/admin/users/_user_attribute.html.erb @@ -1,44 +1,44 @@ -<%= fields_for "user[user_#{type}s]", user_attribute, :index => nil do |f| %> - <%= f.hidden_field :key, :value => ua.key %> - <%= f.hidden_field :id unless user_attribute.new_record? %> - -
- - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - <% ua.get_enabled_attribute_models.each do |attr| %> - <% value = user_attribute.attribute_values.detect{|v| v.key == attr.key } %> - <%= hidden_field_tag "user[user_#{type}s][][attribute_values][][id]", value.id rescue nil %> - <%= hidden_field_tag "user[user_#{type}s][][attribute_values][][key]", attr.key %> - - - <% if attr["locale"] && attr["markup"] == 'text_field' %> - <%= hidden_field_tag "user[user_#{type}s][][attribute_values][][non_locale]", nil %> - <% @site_valid_locales.each do |locale| %> - - <% end -%> - <% else %> - - <% end -%> - - <% end %> - -
<%= t("admin.key") %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= attr.i18n_variable[I18n.locale] %> - <%= text_field_tag "user[user_#{type}s][][attribute_values][][#{locale}]", (value[locale] rescue nil) %> - > - <% if attr["markup"] == "text_field" %> - <%= text_field_tag "user[user_#{type}s][][attribute_values][][non_locale]", (value['non_locale'] rescue nil) %> - <% elsif attr["markup"] == "select" %> - <%= select_tag "user[user_#{type}s][][attribute_values][][non_locale]", options_for_select(attr["options"], value['non_locale']) %> - <% end -%> -
-
- -<% end %> +<%= fields_for "user[user_#{type}s]", user_attribute, :index => nil do |f| %> + <%= f.hidden_field :key, :value => ua.key %> + <%= f.hidden_field :id unless user_attribute.new_record? %> + +
+ + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + <% ua.get_enabled_attribute_models.each do |attr| %> + <% value = user_attribute.attribute_values.detect{|v| v.key == attr.key } %> + <%= hidden_field_tag "user[user_#{type}s][][attribute_values][][id]", value.id rescue nil %> + <%= hidden_field_tag "user[user_#{type}s][][attribute_values][][key]", attr.key %> + + + <% if attr["locale"] && attr["markup"] == 'text_field' %> + <%= hidden_field_tag "user[user_#{type}s][][attribute_values][][non_locale]", nil %> + <% @site_valid_locales.each do |locale| %> + + <% end -%> + <% else %> + + <% end -%> + + <% end %> + +
<%= t("admin.key") %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= attr.i18n_variable[I18n.locale] %> + <%= text_field_tag "user[user_#{type}s][][attribute_values][][#{locale}]", (value[locale] rescue nil) %> + > + <% if attr["markup"] == "text_field" %> + <%= text_field_tag "user[user_#{type}s][][attribute_values][][non_locale]", (value['non_locale'] rescue nil) %> + <% elsif attr["markup"] == "select" %> + <%= select_tag "user[user_#{type}s][][attribute_values][][non_locale]", options_for_select(attr["options"], value['non_locale']) %> + <% end -%> +
+
+ +<% end %> diff --git a/app/views/admin/users/edit.html.erb b/app/views/admin/users/edit.html.erb index d848ead2..d0442fb8 100644 --- a/app/views/admin/users/edit.html.erb +++ b/app/views/admin/users/edit.html.erb @@ -1,12 +1,14 @@ -
- <%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %> - <%= f.error_messages %> - <%= render :partial => 'form', :locals => { :f => f } %> -
- <%= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').submit()" %> -
-
- <%= link_back %> -
- <% end -%> +<% content_for :secondary do %> + <%= render 'side_bar' %> +<% end %> + +
+ <%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %> + <%= f.error_messages %> + <%= render :partial => 'form', :locals => { :f => f } %> +
+ <%= link_back %> + <%= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').submit()" %> +
+ <% end -%>
\ No newline at end of file diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index d2385790..82abfd81 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -1,32 +1,43 @@ -
- <%= flash_messages %> -
- <%= link_to t('admin.new_user'), new_admin_user_path %> -
-
    -
  • - <%= t('admin.role') %> - <%= t('admin.name') %> - - <%= t('admin.admin') %> - <%= t('admin.action') %> -
  • - <% @users.each do |user| %> -
  • - <% active_role = UserRoleModel.get_role_model_from_key(user.active_role) %> - <%= active_role.i18n_variable[I18n.locale] rescue nil %> - <%= user.name ? user.name : 'bob' %> - - <%= user.admin ? t(:yes_) : t(:no_) %> - - <%= link_to t(:show), admin_user_path(user), :class => 'show' %> - <%= link_to t(:edit), edit_admin_user_path(user), :class => 'edit' %> - <%= link_to t(:delete), admin_user_path(user), :class => 'delete', :confirm => t('sure?'), :method => :delete %> - -
  • - <% end %> -
-
- <%= link_to t('admin.new_user'), new_admin_user_path %> -
-
+<% content_for :secondary do %> + <%= render 'side_bar' %> +<% end %> + +
+ <%= flash_messages %> +
+ <%= link_to t('admin.new_user'), new_admin_user_path, :class => 'new' %> +
+ + + + + + + + + + + + <% @users.each do |user| %> + <% active_role = UserRoleModel.get_role_model_from_key(user.active_role) %> + + + + + + + + + + + <% end %> + +
<%= t('admin.role') %><%= t('admin.name') %><%= t('admin.admin') %><%= t('admin.action') %>
<%= active_role.i18n_variable[I18n.locale] rescue nil %><%= user.name ? user.name : 'bob' %><%= user.admin ? t(:yes_) : t(:no_) %> + <%= link_to t(:show), admin_user_path(user), :class => 'show' %> + <%= link_to t(:edit), edit_admin_user_path(user), :class => 'edit' %> + <%= link_to t(:delete), admin_user_path(user), :class => 'delete', :confirm => t('sure?'), :method => :delete %> +
+
+ <%= link_to t('admin.new_user'), new_admin_user_path, :class => 'new' %> +
+
diff --git a/app/views/admin/users/new.html.erb b/app/views/admin/users/new.html.erb index cb6c8c72..0ff34529 100644 --- a/app/views/admin/users/new.html.erb +++ b/app/views/admin/users/new.html.erb @@ -1,17 +1,19 @@ -
- <%= form_for @user, :url => admin_users_path, :html => { :multipart => true } do |f| %> - <%= f.error_messages %> - <%= render :partial => 'form', :locals => { :f => f } %> -
- <%= link_to t('create'), "#", :onclick=>"$('#new_user').submit()" %> -
-
- <%= link_back %> -
- <% end -%> -
- - - - - +<% content_for :secondary do %> + <%= render 'side_bar' %> +<% end %> + +
+ <%= form_for @user, :url => admin_users_path, :html => { :multipart => true } do |f| %> + <%= f.error_messages %> + <%= render :partial => 'form', :locals => { :f => f } %> +
+ <%= link_back %> + <%= link_to t('create'), "#", :onclick=>"$('#new_user').submit()" %> +
+ <% end -%> +
+ + + + + diff --git a/app/views/admin/users/show.html.erb b/app/views/admin/users/show.html.erb index 87f2d689..3e195892 100644 --- a/app/views/admin/users/show.html.erb +++ b/app/views/admin/users/show.html.erb @@ -1,28 +1,34 @@ -
- -
- <% if @user.avatar? %> - <%= image_tag(@user.avatar.thumb.url) %> - <% else %> - <%= image_tag "person.png" %> - <% end %> - <%= link_to t(:edit), edit_admin_user_path(@user), :id => 'edit' %> -
- - <% @user_info_models.each do |am| %> -
-

<%= am.i18n_variable[I18n.locale] %>

-
- <%= render :partial => 'show_user_attribute', :locals => {:am => am, :object => @user.get_info_from_model_key(am.key)} %> -
- <% end -%> - -
- <% active_role = UserRoleModel.get_role_model_from_key(@user.active_role) %> -

<%= active_role.i18n_variable[I18n.locale] %>

-
- <%= render :partial => 'show_user_attribute', :locals => {:am => active_role, :object => @user.get_role_from_model_key(active_role.key)} %> -
- -
- +<% content_for :secondary do %> + <%= render 'side_bar' %> +<% end %> + +
+ +
+ <% if @user.avatar? %> + <%= image_tag(@user.avatar.thumb.url) %> + <% else %> + <%= image_tag "person.png" %> + <% end %> +
+ + <% @user_info_models.each do |am| %> +
+

<%= am.i18n_variable[I18n.locale] %>

+
+ <%= render :partial => 'show_user_attribute', :locals => {:am => am, :object => @user.get_info_from_model_key(am.key)} %> +
+ <% end -%> + +
+ <% active_role = UserRoleModel.get_role_model_from_key(@user.active_role) %> +

<%= active_role.i18n_variable[I18n.locale] %>

+
+ <%= render :partial => 'show_user_attribute', :locals => {:am => active_role, :object => @user.get_role_from_model_key(active_role.key)} %> +
+
+ <%= link_to t(:edit), edit_admin_user_path(@user) %> + <%= link_back %> +
+
+ diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 54e7e6c2..a4bbbb43 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -1,36 +1,31 @@ - - - - - <%= @title || APP_CONFIG['orbit'] %> - - <%= stylesheet_link_tag "admin" %> - <%= javascript_include_tag "admin" %> - <%= yield :page_specific_css %> - <%= yield :page_specific_javascript %> - <%= csrf_meta_tag %> - - - - - -
-
-
-
<%= yield :secondary %>
-
-
-
<%= yield %>
-
-
<%= yield :tertiary %>
-
- -
- - + + + + + <%= @title || APP_CONFIG['orbit'] %> + + <%= stylesheet_link_tag "admin" %> + <%= javascript_include_tag "admin" %> + <%= yield :page_specific_css %> + <%= yield :page_specific_javascript %> + <%= csrf_meta_tag %> + + + + +
+ +
+ <%= yield %> +
+
<%= yield :tertiary %>
+ +
+ + diff --git a/app/views/layouts/admin.html.erb.back20111207 b/app/views/layouts/admin.html.erb.back20111207 new file mode 100644 index 00000000..54e7e6c2 --- /dev/null +++ b/app/views/layouts/admin.html.erb.back20111207 @@ -0,0 +1,36 @@ + + + + + <%= @title || APP_CONFIG['orbit'] %> + + <%= stylesheet_link_tag "admin" %> + <%= javascript_include_tag "admin" %> + <%= yield :page_specific_css %> + <%= yield :page_specific_javascript %> + <%= csrf_meta_tag %> + + + + + +
+
+
+
<%= yield :secondary %>
+
+
+
<%= yield %>
+
+
<%= yield :tertiary %>
+
+ +
+ + diff --git a/edit.html.erb b/edit.html.erb new file mode 100644 index 00000000..14c158fc --- /dev/null +++ b/edit.html.erb @@ -0,0 +1,14 @@ +<% content_for :secondary do %> + <%= render 'side_bar' %> +<% end %> + +
+ <%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %> + <%= f.error_messages %> + <%= render :partial => 'form', :locals => { :f => f } %> +
+ <%= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').submit()" %> + <%= link_back %> +
+ <% end -%> +
\ No newline at end of file diff --git a/index.html.erb b/index.html.erb new file mode 100644 index 00000000..b5965a79 --- /dev/null +++ b/index.html.erb @@ -0,0 +1,34 @@ +<% content_for :secondary do %> + <%= render 'admin/users/side_bar' %> +<% end %> + +
+
+ <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %> +
+
    +
  • + <%= t("admin.#{@attribute}") %> + <%= t('admin.action') %> +
  • + <% @user_attribute_models.each do |user_attribute_model| %> +
  • clear"> + <%= user_attribute_model.i18n_variable[I18n.locale] %> + + + <%= link_to t(:edit), eval("edit_admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'edit' %> + <% if user_attribute_model.is_built_in? %> + <%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %> + <%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %> + <% else %> + <%= link_to t(:delete), eval("admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %> + <% end %> + + +
  • + <% end %> +
+
+ <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %> +
+
From d27d7a623c86d82109b497594c110df945825226 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Sun, 18 Dec 2011 10:07:42 +0800 Subject: [PATCH 04/20] Changes for sub_roles Issues: update doesn't create new i18n_variables, role form has bugs --- admin_back_end.css.erb | 278 ------------------ app/assets/javascripts/attribute_form.js.erb | 25 ++ app/assets/javascripts/page_edit.js | 11 +- app/assets/javascripts/site_editor.js | 1 + .../javascripts/user_attribute_model_form.js | 33 --- app/assets/javascripts/user_form.js | 4 +- app/assets/stylesheets/_form.html.erb | 57 ---- app/assets/stylesheets/admin_back_end.css.erb | 8 +- app/controllers/admin/infos_controller.rb | 16 +- app/controllers/admin/roles_controller.rb | 6 +- .../admin/translations_controller.rb | 6 +- .../admin/user_info_models_controller.rb | 59 ---- .../admin/user_role_models_controller.rb | 60 ---- app/controllers/admin/users_controller.rb | 18 +- app/helpers/admin/user_helper.rb | 4 +- app/helpers/application_helper.rb | 7 + app/models/design/design.rb | 2 +- app/models/user/attribute.rb | 2 +- app/models/user/attribute_field.rb | 4 +- app/models/user/role.rb | 2 +- app/models/user/sub_role.rb | 3 +- app/models/user/user.rb | 12 +- .../attributes/_attribute_field.html.erb | 35 +++ .../attributes/_attribute_model.html.erb | 36 --- app/views/admin/attributes/_form.html.erb | 57 ---- app/views/admin/attributes/edit.html.erb | 14 +- app/views/admin/attributes/index.html.erb | 45 +-- app/views/admin/attributes/new.html.erb | 18 +- .../admin/infos/_attribute_field.html.erb | 3 + app/views/admin/infos/_form.html.erb | 70 +++++ app/views/admin/infos/edit.html.erb | 16 - app/views/admin/pages/_show.html.erb | 6 +- .../admin/roles/_attribute_field.html.erb | 3 + app/views/admin/roles/_form.html.erb | 50 ++++ app/views/admin/roles/_form_sub.html.erb | 3 + app/views/admin/roles/_sub_role.html.erb | 70 +++++ .../_attribute_model.html.erb | 36 --- .../user_attribute_models/_form.html.erb | 57 ---- .../user_attribute_models/admin.html.erb | 31 -- .../admin/user_attribute_models/edit.html.erb | 14 - .../user_attribute_models/index.html.erb | 41 --- .../admin/user_attribute_models/new.html.erb | 18 -- .../toggle_enable.js.erb | 3 - .../admin/user_attributes/index.html.erb | 34 --- app/views/admin/user_attributes/new.html.erb | 16 - app/views/admin/users/_form.html.erb | 20 +- .../admin/users/_show_attribute.html.erb | 26 ++ .../admin/users/_show_user_attribute.html.erb | 27 -- .../admin/users/_user_attribute.html.erb | 20 +- app/views/admin/users/edit.html.erb | 2 +- app/views/admin/users/index.html.erb | 3 +- app/views/admin/users/new.html.erb | 2 +- app/views/admin/users/show.html.erb | 18 +- app/views/layouts/admin.html.erb.back20111207 | 36 --- config/application.rb | 2 +- config/locales/en.yml | 18 +- config/locales/zh_tw.yml | 18 +- config/routes.rb | 9 +- edit.html.erb | 14 - index.html.erb | 34 --- lib/tasks/dev.rake | 103 ++++--- spec/models/role_spec.rb | 4 + 62 files changed, 508 insertions(+), 1142 deletions(-) delete mode 100644 admin_back_end.css.erb create mode 100644 app/assets/javascripts/attribute_form.js.erb delete mode 100644 app/assets/javascripts/user_attribute_model_form.js delete mode 100644 app/assets/stylesheets/_form.html.erb delete mode 100644 app/controllers/admin/user_info_models_controller.rb delete mode 100644 app/controllers/admin/user_role_models_controller.rb create mode 100644 app/views/admin/attributes/_attribute_field.html.erb delete mode 100644 app/views/admin/attributes/_attribute_model.html.erb delete mode 100644 app/views/admin/attributes/_form.html.erb create mode 100644 app/views/admin/infos/_attribute_field.html.erb create mode 100644 app/views/admin/infos/_form.html.erb delete mode 100644 app/views/admin/infos/edit.html.erb create mode 100644 app/views/admin/roles/_attribute_field.html.erb create mode 100644 app/views/admin/roles/_form.html.erb create mode 100644 app/views/admin/roles/_form_sub.html.erb create mode 100644 app/views/admin/roles/_sub_role.html.erb delete mode 100644 app/views/admin/user_attribute_models/_attribute_model.html.erb delete mode 100644 app/views/admin/user_attribute_models/_form.html.erb delete mode 100644 app/views/admin/user_attribute_models/admin.html.erb delete mode 100644 app/views/admin/user_attribute_models/edit.html.erb delete mode 100644 app/views/admin/user_attribute_models/index.html.erb delete mode 100644 app/views/admin/user_attribute_models/new.html.erb delete mode 100644 app/views/admin/user_attribute_models/toggle_enable.js.erb delete mode 100644 app/views/admin/user_attributes/index.html.erb delete mode 100644 app/views/admin/user_attributes/new.html.erb create mode 100644 app/views/admin/users/_show_attribute.html.erb delete mode 100644 app/views/admin/users/_show_user_attribute.html.erb delete mode 100644 app/views/layouts/admin.html.erb.back20111207 delete mode 100644 edit.html.erb delete mode 100644 index.html.erb diff --git a/admin_back_end.css.erb b/admin_back_end.css.erb deleted file mode 100644 index a0eff84e..00000000 --- a/admin_back_end.css.erb +++ /dev/null @@ -1,278 +0,0 @@ -html, body{ - height: 100%; - margin: 0; - padding: 0; -} -html{ - background: url(<%= asset_path "body.jpg" %>) no-repeat scroll 0 0 transparent; - background-size: cover; -} - -body{ - color: #000000; - font-family: Helvetica, '微軟正黑體'; -} - -#panel_banner_link{ - background: url(<%= asset_path "orbitbar1.png" %>) repeat-x scroll 0 0; - height: 50px; - left: 0; - position: fixed; - top: 0; - width: 100%; - z-index: 5; -} -.hmenu{ - height: 40px; - position: absolute; - right: 0; - top: 1px; - width: 250px; -} -#orbit{ - background: url(<%= asset_path "bar_orbit.png" %>) no-repeat scroll 0 0 transparent; - cursor:pointer; - height: 43px; - left: 10px; - position: relative; - width: 41px; -} -#orbit:hover{ - background-position:0 -43px; - box-shadow: 0 3px 3px #000000; -} -#orbit:hover #orblist{ - display:block; -} -#orblist{ - background: none repeat scroll 0 0 #FFFFFF; - border-radius: 0 3px 3px 3px; - box-shadow: 0 3px 3px #000000; - display: none; - margin: 0; - padding: 10px; - position: absolute; - top: 43px; - width: 130px; -} -#orblist li{ - border-bottom:1px solid #aaa; - list-style:none; -} -.orblink{ - color: #333333; - display: block; - font: 12px/100% arial,sans-serif; - padding: 5px; - text-decoration: none; -} -.orblink:hover{ - background:#eee; - color:#333; -} - -#log_out a{ - background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right 0 transparent; - border: medium none !important; - display: block !important; - height: 40px !important; - line-height: normal !important; - padding: 0 !important; - position: absolute; - right: 0px; - text-indent: -10000px; - top: 0px; - width: 43px !important; -} -#log_out a:hover{ - background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right bottom transparent !important; -} -.lang{ - color: #FFFFFF; - font-size: 15px; - line-height: 40px; - position: absolute; - right: 55px; - top: 0; -} - -.lang a{ - color:#fff; - text-decoration:none; -} - -.lang a:hover{ - text-decoration:underline; -} - -#content{ - height: 100%; -} -#sidebar { - background: url(<%= asset_path "75.png" %>) repeat scroll left top transparent; - box-shadow: 3px 0 4px #472A12; - border-right: 1px solid #121212; - height: 100%; - left: 0; - position: fixed; - top: 0; - width: 220px; -} -#search { - background: url(<%= asset_path "search_block_bg.jpg" %>) repeat-x scroll left top transparent; - height: 20px; - margin-top: 43px; - padding: 15px 12px; -} -#search input { - background: url(<%= asset_path "search_bg.png" %>) no-repeat scroll left top transparent; - border: medium none; - font-family: Helvetica; - height: 20px; - padding: 0 20px; - width: 154px; -} -h1 { - background: url(<%= asset_path "h1_bg.png" %>) repeat-x scroll left top transparent; - border-bottom: 1px solid #1B1B1B; - border-top: 1px solid #424344; - color: #FFFFFF; - font-size: 12px; - font-weight: normal; - height: 21px; - line-height: 21px; - margin: 0; - padding-left: 10px; - text-shadow: 0 -1px 0 #000000; -} -.member_setup .list { - color:#fff; - font-size:12px; - background:url(<%= asset_path "line.png" %>) repeat-x left bottom; -} -.member_setup .list li { - background:url(<%= asset_path "sidebar_li.jpg" %>) repeat-x left top; - border-top:1px solid #424344; - border-bottom:1px solid #000000; -} -.member_setup .list li:hover { - background-position:left bottom; - border-top:1px solid #406cc3; - border-bottom:1px solid #242628; -} -.member_setup .list li a { - display: block; - padding: 7px 0 6px 12px; - color:#c4c4c4; -} -.member_setup .list li a span { - background:url(<%= asset_path "add_mamber.png" %>) left top no-repeat; - text-shadow: 0px 1px 0px #000; - line-height: 18px; - padding: 2px 0 1px 35px; -} -.member_setup .list li a:hover span { - background-position:left bottom; - color:#eeeeee; -} -.users .list .set_1 { - background-position:left bottom; - border-top:1px solid #406cc3; - border-bottom:1px solid #242628; -} -.users .list .set_1 a span { - background-position:left bottom; - color:#eeeeee; -} -.user_role_models .list .set_2 { - background-position:left bottom; - border-top:1px solid #406cc3; - border-bottom:1px solid #242628; -} -.user_role_models .list .set_2 a span { - background-position:left bottom; - color:#eeeeee; -} -.user_info_models .list .set_3 { - background-position:left bottom; - border-top:1px solid #406cc3; - border-bottom:1px solid #242628; -} -.user_info_models .list .set_3 a span { - background-position:left bottom; - color:#eeeeee; -} -.main { - height: 100%; - margin-left: 260px; - padding-right: 40px; - position: relative; -} -.main_list { - padding-top: 70px; -} -.main_list ul { - clear:both; -} -#porfile { - padding-top: 100px; -} -/*add_buttom*/ -.button_bar { - float: right; - -moz-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; - -webkit-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; - box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; - background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #4f4f4f), color-stop(1, #000000) ); - background:-moz-linear-gradient( center top, #4f4f4f 5%, #000000 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#4f4f4f', endColorstr='#000000'); - background-color:#4f4f4f; - -moz-border-radius:5px; - -webkit-border-radius:5px; - border-radius:5px; - display:inline-block; - padding:0; - margin:10px 0; -} -.button_bar a { - text-decoration:none; - text-shadow:0px -1px 0px #000000; - font-size:12px; - color:#EDEDED; - border-right:1px solid #555; - -moz-box-shadow:1px 0px 0px black; - -webkit-box-shadow:1px 0px 0px black; - box-shadow:1px 0px 0px black; - padding: 6px 10px 4px; - display: inline-block; - float: left; -} -.button_bar a:active { - padding: 7px 10px 3px; - text-shadow:0px 1px 0px #000000; - background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #000000), color-stop(1, #4f4f4f) ); - background:-moz-linear-gradient( center top, #000000 5%, #4f4f4f 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#4f4f4f'); -} -.button_bar a:last-child { - border-right:none; - -moz-box-shadow:none; - -webkit-box-shadow:none; - box-shadow:none; - -moz-border-radius:0px 5px 5px 0px; - -webkit-border-radius:0px 5px 5px 0px; - border-radius:0px 5px 5px 0px; -} -.button_bar a:first-child { - -moz-border-radius:5px 0px 0px 5px; - -webkit-border-radius:5px 0px 0px 5px; - border-radius:5px 0px 0px 5px; -} -.button_bar a.new { - -moz-border-radius:5px; - -webkit-border-radius:5px; - border-radius:5px; -} -.button_bar a:hover { - color:#FFFFFF; -} \ No newline at end of file diff --git a/app/assets/javascripts/attribute_form.js.erb b/app/assets/javascripts/attribute_form.js.erb new file mode 100644 index 00000000..6109099f --- /dev/null +++ b/app/assets/javascripts/attribute_form.js.erb @@ -0,0 +1,25 @@ +$('.attributes_block a.delete').live('click', function(){ + $(this).parents('.list_item').remove(); +}); + +$('#attributes a.remove_existing_record').live('click', function(){ + $(this).next('.should_destroy').attr('value', 1); + $("#attribute_" + $(this).prev().attr('value')).hide(); +}); + +$('#attributes_block a.switch').live('click', function(){ + $(this).parent().toggleClass('disable'); + var $am = $(this).next('.built_in_state') + $am.attr('value', ($am.attr('value') == "false") ? "true" : "false"); +}); + +$('.select_type select').live('change', function(){ + if(this.value == 'select') + { + $(this).next().show(); + } + else + { + $(this).next().hide(); + } +}); \ No newline at end of file diff --git a/app/assets/javascripts/page_edit.js b/app/assets/javascripts/page_edit.js index 71c4ef59..18f258ba 100644 --- a/app/assets/javascripts/page_edit.js +++ b/app/assets/javascripts/page_edit.js @@ -1,4 +1,7 @@ -$("div.editable").live("mouseenter mouseleave", - function (event) { - $(this).children('.edit_link').toggle(); - }); \ No newline at end of file +$("div.editable").live("mouseenter mouseleave", function (event) { + $(this).children('.edit_link').toggle(); +}); + +$("#page_design_id").live('change', function() { + $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_themes'); +}); \ No newline at end of file diff --git a/app/assets/javascripts/site_editor.js b/app/assets/javascripts/site_editor.js index 835884d0..98405564 100644 --- a/app/assets/javascripts/site_editor.js +++ b/app/assets/javascripts/site_editor.js @@ -6,4 +6,5 @@ // //= require jquery //= require jquery_ujs +//= require page_edit //= require side_bar_history \ No newline at end of file diff --git a/app/assets/javascripts/user_attribute_model_form.js b/app/assets/javascripts/user_attribute_model_form.js deleted file mode 100644 index 1e1e2ef5..00000000 --- a/app/assets/javascripts/user_attribute_model_form.js +++ /dev/null @@ -1,33 +0,0 @@ -$('#attributes_block a.delete').live('click', function(){ - $(this).parent().parent().parent().remove(); -}); - -$('#attributes_block a.add').click(function(){ - $('#attributes').append("<%= escape_javascript(render(:partial => 'admin/user_attribute_models/attribute_model', :object => @user_attribute_model.attribute_models.build)) %>"); -}); - -$('#attributes_block a.remove_existing_record').click(function(){ - $(this).next('.should_destroy').attr('value', 1); - $(this).parent().parent().hide(); -}); - -$('#attributes_block a.change_built_in').click(function(){ - $(this).parent().toggleClass('disable'); - var $am = $(this).next('.built_in_state') - $am.attr('value', ($am.attr('value') == "false") ? "true" : "false"); -}); - -$('.select_mulitlingual input').live('click', function(){ - $(this).next().attr('value', this.checked); -}); - -$('.select_type select').live('change', function(){ - if(this.value == 'select') - { - $(this).next().show(); - } - else - { - $(this).next().hide(); - } -}); \ No newline at end of file diff --git a/app/assets/javascripts/user_form.js b/app/assets/javascripts/user_form.js index 21a4b454..168f5437 100644 --- a/app/assets/javascripts/user_form.js +++ b/app/assets/javascripts/user_form.js @@ -1,6 +1,6 @@ $(document).ready(function(){ - $('#user_active_role').change(function(){ - $('#role_models .roles_block').hide(); + $('#active_role').change(function(){ + $('#roles .attributes_block').hide(); $('#'+this.value+'_block').toggle(); }); }); \ No newline at end of file diff --git a/app/assets/stylesheets/_form.html.erb b/app/assets/stylesheets/_form.html.erb deleted file mode 100644 index edbcae39..00000000 --- a/app/assets/stylesheets/_form.html.erb +++ /dev/null @@ -1,57 +0,0 @@ -
-

<%= t("admin.user_#{@attribute}") %>

-
- - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - -
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @user_attribute_model.key %> - <%= text_field_tag "user_#{@attribute}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> -
-
-
- - -
-

Attributes

-
- - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - - - - - - <%= render :partial => 'admin/user_attribute_models/attribute_model', :collection => @user_attribute_model.attribute_models %> - -
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
<%= t(:add) %>
-
-
- -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "user_attribute_model_form" %> -<% end -%> diff --git a/app/assets/stylesheets/admin_back_end.css.erb b/app/assets/stylesheets/admin_back_end.css.erb index 89f2c874..f7f3a222 100644 --- a/app/assets/stylesheets/admin_back_end.css.erb +++ b/app/assets/stylesheets/admin_back_end.css.erb @@ -222,7 +222,7 @@ h1 { .main_list ul { clear:both; } -#porfile { +#profile { padding-top: 100px; } /*add_buttom*/ @@ -336,10 +336,10 @@ h1 { padding: 0; width: 140px; } -#porfile .users{ +#profile .users{ margin-left: 180px; } -.roles_block { +.attributes_block { background: url(<%= asset_path "75.png" %>) repeat left top; min-width:710px; margin-bottom:50px; @@ -352,7 +352,7 @@ h1 { -webkit-box-shadow: 0px 0px 4px #180902;/* Safari 和 Chrome */ box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */ } -.roles_block h2 { +.attributes_block h2 { color: #FFFFFF; font-weight: normal; margin: 0; diff --git a/app/controllers/admin/infos_controller.rb b/app/controllers/admin/infos_controller.rb index a00bd94e..bc86b662 100644 --- a/app/controllers/admin/infos_controller.rb +++ b/app/controllers/admin/infos_controller.rb @@ -11,16 +11,18 @@ class Admin::InfosController < ApplicationController end def show - #@attribute = Info.find(params[:id]) + end def new @attribute = Info.new + render :template => 'admin/attributes/new' end def edit @attribute = Info.find(params[:id]) @i18n_variable = @attribute.i18n_variable + render :template => 'admin/attributes/edit' end def create @@ -32,6 +34,10 @@ class Admin::InfosController < ApplicationController def update @attribute = Info.find(params[:id]) @attribute.update_attributes(params[:info]) + respond_to do |format| + format.html { redirect_to :action => :index } + format.js { render 'admin/attributes/toggle_enable' } + end end def destroy @@ -40,10 +46,18 @@ class Admin::InfosController < ApplicationController redirect_to :action => :index end + def add_attribute_field + @attribute = Info.find(params[:id]) rescue nil + if !@attribute + @attribute = Info.new + end + end + protected def set_attribute @attribute_type = 'info' + @class = 'infos' end end diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index f3a17dd7..65c86f36 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -11,16 +11,18 @@ class Admin::RolesController < ApplicationController end def show - #@attribute = Role.find(params[:id]) + end def new @attribute = Role.new + render :template => 'admin/attributes/new' end def edit @attribute = Role.find(params[:id]) @i18n_variable = @attribute.i18n_variable + render :template => 'admin/attributes/edit' end def create @@ -32,7 +34,6 @@ class Admin::RolesController < ApplicationController def update @attribute = Role.find(params[:id]) @attribute.update_attributes(params[:role]) - respond_to do |format| format.html { redirect_to :action => :index } format.js { render 'admin/attributes/toggle_enable' } @@ -49,6 +50,7 @@ class Admin::RolesController < ApplicationController def set_attribute @attribute_type = 'role' + @class = 'roles' end end diff --git a/app/controllers/admin/translations_controller.rb b/app/controllers/admin/translations_controller.rb index 590ad556..54da8762 100644 --- a/app/controllers/admin/translations_controller.rb +++ b/app/controllers/admin/translations_controller.rb @@ -68,11 +68,11 @@ class Admin::TranslationsController < ApplicationController result << var if var.document_class.eql?('language') result end - @user_role_model_i18n_variables = @i18n_variables.inject([]) do |result, var| - result << var if var.document_class.eql?('UserRoleModel') + @role_i18n_variables = @i18n_variables.inject([]) do |result, var| + result << var if var.document_class.eql?('Role') result end - @user_info_model_i18n_variables = @i18n_variables.inject([]) do |result, var| + @info_i18n_variables = @i18n_variables.inject([]) do |result, var| result << var if var.document_class.eql?('UserInfoModel') result end diff --git a/app/controllers/admin/user_info_models_controller.rb b/app/controllers/admin/user_info_models_controller.rb deleted file mode 100644 index 60360463..00000000 --- a/app/controllers/admin/user_info_models_controller.rb +++ /dev/null @@ -1,59 +0,0 @@ -class Admin::UserInfoModelsController < ApplicationController - - layout "admin" - before_filter :authenticate_user! - before_filter :is_admin? - before_filter :set_attribute, :only => [:index, :show, :new, :edit] - - def index - @user_attribute_models = UserInfoModel.all.entries - render :template => 'admin/user_attribute_models/index' - end - - def show - #@user_attribute_model = UserInfoModel.find(params[:id]) - end - - def new - @user_attribute_model = UserInfoModel.new - render :template => 'admin/user_attribute_models/new' - end - - def edit - @user_attribute_model = UserInfoModel.find(params[:id]) - @i18n_variable = @user_attribute_model.i18n_variable - render :template => 'admin/user_attribute_models/edit' - end - - def create - @user_attribute_model = UserInfoModel.new(params[:user_info_model]) - @user_attribute_model.save - redirect_to :action => :index - end - - def update - @user_attribute_model = UserInfoModel.find(params[:id]) - @user_attribute_model.update_attributes(params[:user_info_model]) - respond_to do |format| - format.html { redirect_to :action => :index } - format.js { render 'admin/user_attribute_models/toggle_enable' } - end - end - - def destroy - @user_attribute_model = UserInfoModel.find(params[:id]) - @user_attribute_model.destroy - - @user_attribute_model.destroy_i18n_variables - - redirect_to :action => :index - end - - protected - - def set_attribute - @attribute = 'info' - @class = 'infos' - end - -end diff --git a/app/controllers/admin/user_role_models_controller.rb b/app/controllers/admin/user_role_models_controller.rb deleted file mode 100644 index bfdf5428..00000000 --- a/app/controllers/admin/user_role_models_controller.rb +++ /dev/null @@ -1,60 +0,0 @@ -class Admin::UserRoleModelsController < ApplicationController - - layout "admin" - before_filter :authenticate_user! - before_filter :is_admin? - before_filter :set_attribute, :only => [:index, :show, :new, :edit] - - def index - @user_attribute_models = UserRoleModel.all.entries - render :template => 'admin/user_attribute_models/index' - end - - def show - #@user_attribute_model = UserRoleModel.find(params[:id]) - end - - def new - @user_attribute_model = UserRoleModel.new - render :template => 'admin/user_attribute_models/new' - end - - def edit - @user_attribute_model = UserRoleModel.find(params[:id]) - @i18n_variable = @user_attribute_model.i18n_variable - render :template => 'admin/user_attribute_models/edit' - end - - def create - @user_attribute_model = UserRoleModel.new(params[:user_role_model]) - @user_attribute_model.save - redirect_to :action => :index - end - - def update - @user_attribute_model = UserRoleModel.find(params[:id]) - @user_attribute_model.update_attributes(params[:user_role_model]) - - respond_to do |format| - format.html { redirect_to :action => :index } - format.js { render 'admin/user_attribute_models/toggle_enable' } - end - end - - def destroy - @user_attribute_model = UserRoleModel.find(params[:id]) - @user_attribute_model.destroy - - @user_attribute_model.destroy_i18n_variables - - redirect_to :action => :index - end - - protected - - def set_attribute - @attribute = 'role' - @class = 'roles' - end - -end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 2a6c0a99..b8df3312 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -10,18 +10,18 @@ class Admin::UsersController < ApplicationController def show @user = User.find(params[:id]) - get_info_role_models + get_info_and_roles end def new @user = User.new - get_info_role_models + get_info_and_roles end def create @user = User.new(params[:user]) if @user.save - @user.user_infos.each do |info| + @user.infos.each do |info| info.save info.attribute_values.each(&:save) end @@ -38,7 +38,7 @@ class Admin::UsersController < ApplicationController def edit @user = User.find(params[:id]) - get_info_role_models + get_info_and_roles end def update @@ -55,7 +55,7 @@ class Admin::UsersController < ApplicationController flash[:notice] = t('admin.update_success_user') redirect_to :action => :index else - get_info_role_models + get_info_and_roles render :action => :edit end end @@ -66,7 +66,7 @@ class Admin::UsersController < ApplicationController else @user = User.find(params[:id]) @user.destroy - @user.user_attributes.each do |ua| + @user.attributes.each do |ua| ua.attribute_values.each(&:destroy) ua.destroy end @@ -77,9 +77,9 @@ class Admin::UsersController < ApplicationController protected - def get_info_role_models - @roles = Info.excludes('disabled' => true) - @infos = Role.excludes('disabled' => true) + def get_info_and_roles + @infos = Info.excludes('disabled' => true) + @roles = Role.excludes('disabled' => true) end def set_attribute diff --git a/app/helpers/admin/user_helper.rb b/app/helpers/admin/user_helper.rb index 6ebd056f..22da150e 100644 --- a/app/helpers/admin/user_helper.rb +++ b/app/helpers/admin/user_helper.rb @@ -1,7 +1,7 @@ module Admin::UserHelper - def show_user_attribute(object, key, locale = '') - attribute = object.attribute_values.detect {|av| av.key.to_s.eql?(key.to_s) || av[locale.to_s].eql?(locale.to_s) } rescue nil + def show_attribute(object, field_id, locale = '') + attribute = object.attribute_values.detect {|av| av.attribute_field_id.eql?(field_id) || av[locale.to_s].eql?(locale.to_s) } rescue nil if attribute if locale.to_s.blank? attribute['key'] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b8a9c49e..c8754b31 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -48,5 +48,12 @@ module ApplicationHelper message % item end end + + def add_attribute(partial, f, attribute) + new_object = f.object.send(attribute).build + fields = f.fields_for(attribute, new_object, :child_index => "new_#{attribute}") do |f| + render :partial => partial, :object => new_object, :locals => {:f => f} + end + end end diff --git a/app/models/design/design.rb b/app/models/design/design.rb index f1f676b6..f39a4816 100644 --- a/app/models/design/design.rb +++ b/app/models/design/design.rb @@ -36,7 +36,7 @@ class Design self.files = (attrs << 'images') end - # Update or create the attribute_model records + # Update or create the attribute records def files=(attrs) case attrs.last when 'layout' diff --git a/app/models/user/attribute.rb b/app/models/user/attribute.rb index aee7c36c..c53adebb 100644 --- a/app/models/user/attribute.rb +++ b/app/models/user/attribute.rb @@ -7,7 +7,7 @@ class Attribute field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false - embeds_many :attribute_fields + has_many :attribute_fields, :autosave => true, :dependent => :destroy has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :i18n_variable, :allow_destroy => true accepts_nested_attributes_for :attribute_fields, :allow_destroy => true diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index 56bb02b7..8f3167e7 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -5,12 +5,12 @@ class AttributeField field :key field :markup - field :locale, :type => Boolean + field :locale, :type => Boolean, :default => true field :list_options, :type => Array field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false - embedded_in :attribute + belongs_to :attribute has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy has_many :attribute_values validates_uniqueness_of :key diff --git a/app/models/user/role.rb b/app/models/user/role.rb index 90294f58..86f7266f 100644 --- a/app/models/user/role.rb +++ b/app/models/user/role.rb @@ -7,7 +7,7 @@ class Role field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false - embeds_many :sub_roles + has_many :sub_roles, :autosave => true, :dependent => :destroy has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy has_many :users accepts_nested_attributes_for :i18n_variable, :allow_destroy => true diff --git a/app/models/user/sub_role.rb b/app/models/user/sub_role.rb index 496055c2..63b8cf92 100644 --- a/app/models/user/sub_role.rb +++ b/app/models/user/sub_role.rb @@ -1,5 +1,6 @@ class SubRole < Attribute - + + belongs_to :role has_many :users # Get an sub_role from key diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 2eca43dd..a06233d1 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -16,14 +16,18 @@ class User accepts_nested_attributes_for :attribute_values, :allow_destroy => true def name - infos = self.user_infos.detect {|info| info.key.to_s.eql?('profile') } - if infos - first_name = infos.attribute_values.detect {|value| value.key.to_s.eql?('first_name') }[I18n.locale.to_s] rescue nil - last_name = infos.attribute_values.detect {|value| value.key.to_s.eql?('last_name') }[I18n.locale.to_s] rescue nil + info = Class::Info.first(:conditions => {:key => 'profile'}) + if info + first_name = get_attribute_values.detect {|value| value.key.to_s.eql?('first_name') }[I18n.locale.to_s] rescue nil + last_name = get_attribute_values.detect {|value| value.key.to_s.eql?('last_name') }[I18n.locale.to_s] rescue nil return "#{first_name} #{last_name}" else return nil end end + def get_attribute_values + @attribute_values ||= self.attribute_values.to_a + end + end diff --git a/app/views/admin/attributes/_attribute_field.html.erb b/app/views/admin/attributes/_attribute_field.html.erb new file mode 100644 index 00000000..d8fb5ade --- /dev/null +++ b/app/views/admin/attributes/_attribute_field.html.erb @@ -0,0 +1,35 @@ +" class="list_item"> + <%= attribute_field.new_record? ? (f.text_field :key) : attribute_field.key %> + + <%= f.check_box :locale %> + + <%= f.fields_for :i18n_variable, (attribute_field.i18n_variable.nil? ? attribute_field.build_i18n_variable : attribute_field.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> + <%= f.text_field locale, :style => "width:130px" %> + <% end %> + <%= f.hidden_field :id %> + <% end %> + + <%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %> +
> + <%= t('admin.options') %>: + <%= f.select "select_list_options", attribute_field.select_list_options, :style => "width:130px" %> +
+ + + + <% if attribute_field.new_record? %> + <%= t(:delete) %> + <% else %> + <%= f.hidden_field :id %> + <% if attribute_field.is_built_in? %> + + <%= f.hidden_field :disabled, :value => attribute_field.is_disabled? , :class => 'built_in_state' %> + <% else %> + <%= t(:delete) %> + <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %> + <% end %> + <% end %> + + + \ No newline at end of file diff --git a/app/views/admin/attributes/_attribute_model.html.erb b/app/views/admin/attributes/_attribute_model.html.erb deleted file mode 100644 index 89c1ef89..00000000 --- a/app/views/admin/attributes/_attribute_model.html.erb +++ /dev/null @@ -1,36 +0,0 @@ -<%= fields_for "user_#{@attribute_type}_model[attribute_models][]", attribute_model, :index => nil do |f| %> - - <%= attribute_model.new_record? ? (f.text_field :key) : attribute_model.key %> - - <%= check_box_tag "locale[]", value = '', attribute_model.locale.nil? ? true : attribute_model.locale %> - <%= hidden_field_tag "user_#{@attribute_type}_model[attribute_models][][locale]", attribute_model.locale.nil? ? true : attribute_model.locale %> - - <% @site_valid_locales.each do |locale| %> - <%= text_field_tag "user_#{@attribute_type}_model[attribute_models][][i18n_variable][#{locale}]", (attribute_model.i18n_variable[locale] rescue nil), :style => "width:130px" %> - <% end %> - - <%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %> -
> - <%= t('admin.options') %>: - <%= text_field_tag "user_#{@attribute_type}_model[attribute_models][][select_list_options]", attribute_model.select_list_options, :style => "width:130px" %> -
- - - - <% if attribute_model.new_record? %> - <%= t(:delete) %> - <% else %> - <% if attribute_model.is_built_in? %> - - <%= hidden_field_tag "user_#{@attribute_type}_model[attribute_models][][disabled]", attribute_model.is_disabled? , :class => 'built_in_state' %> - <% else %> - <%= t(:delete) %> - <%= hidden_field_tag "user_#{@attribute_type}_model[attribute_models][][should_destroy]", nil , :class => 'should_destroy' %> - <% end %> - <%= f.hidden_field :id %> - <%= f.hidden_field :key %> - <% end %> - - - -<% end %> \ No newline at end of file diff --git a/app/views/admin/attributes/_form.html.erb b/app/views/admin/attributes/_form.html.erb deleted file mode 100644 index 5d66152c..00000000 --- a/app/views/admin/attributes/_form.html.erb +++ /dev/null @@ -1,57 +0,0 @@ -
-

<%= t("admin.user_#{@attribute_type}") %>

-
- - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - -
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %> - <%= text_field_tag "user_#{@attribute_type}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> -
-
-
- - -
-

Attributes

-
- - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - - - - - - <%= render :partial => 'admin/attributes/attribute_model', :collection => @attribute.attribute_models %> - -
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
<%= t(:add) %>
-
-
- -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "attribute_form" %> -<% end -%> diff --git a/app/views/admin/attributes/edit.html.erb b/app/views/admin/attributes/edit.html.erb index e0f75789..d45382f6 100644 --- a/app/views/admin/attributes/edit.html.erb +++ b/app/views/admin/attributes/edit.html.erb @@ -2,15 +2,13 @@ <%= render 'admin/users/side_bar' %> <% end %> -
- <%= form_for @attribute, :url => eval("admin_user_#{@attribute_type}_model_path(@user_role_model)") do |f| %> +
+ <%= form_for @attribute, :url => eval("admin_#{@attribute_type}_path(@attribute)") do |f| %> <%= f.error_messages %> - <%= render :partial => "admin/attributes/form", :locals => { :f => f, :is_new => false } %> -
- <%= link_to t('update'), "#", :onclick=>"$('#edit_user_role_model_#{@attribute.id}').submit()" %> -
-
+ <%= render :partial => "admin/#{@attribute_type}s/form", :locals => { :f => f, :is_new => false } %> +
<%= link_back %> + <%= link_to t('update'), "#", :onclick=>"$('#edit_#{@attribute_type}_#{@attribute.id}').submit()" %>
- <% end -%> + <% end %>
\ No newline at end of file diff --git a/app/views/admin/attributes/index.html.erb b/app/views/admin/attributes/index.html.erb index efd8c775..71ec1699 100644 --- a/app/views/admin/attributes/index.html.erb +++ b/app/views/admin/attributes/index.html.erb @@ -3,32 +3,37 @@ <% end %>
-
- <%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path") %> +
+ <%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path"), :class => 'new' %>
-
    -
  • - <%= t("admin.#{@attribute_type}") %> - <%= t('admin.action') %> -
  • + + + + + + + + <% @attributes.each do |attribute| %> -
  • clear"> - <%= attribute.i18n_variable[I18n.locale] %> - +
  • "> + + + + + <% end %> - -
    - <%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path") %> +
    +
    <%= t("admin.#{@attribute_type}") %><%= t('admin.action') %>
    <%= attribute.i18n_variable[I18n.locale] %> + <%= link_to t(:edit), eval("edit_admin_#{@attribute_type}_path(attribute)"), :class => 'edit' %> - <% if attribute.is_built_in? %> - <%= link_to t(:enable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' %> - <%= link_to t(:disable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' %> - <% else %> + <%= link_to t(:enable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' %> + <%= link_to t(:disable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' %> + <% if !attribute.is_built_in? %> <%= link_to t(:delete), eval("admin_#{@attribute_type}_path(attribute)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %> <% end %> - - - +
    +
    + <%= link_to t("admin.new_#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path"), :class => 'new' %>
diff --git a/app/views/admin/attributes/new.html.erb b/app/views/admin/attributes/new.html.erb index 431814d1..2e96e8f9 100644 --- a/app/views/admin/attributes/new.html.erb +++ b/app/views/admin/attributes/new.html.erb @@ -2,19 +2,13 @@ <%= render 'admin/users/side_bar' %> <% end %> -
- <%= form_for @attribute, :url => eval("admin_infos_path") do |f| %> +
+ <%= form_for @attribute, :url => eval("admin_#{@attribute_type}s_path") do |f| %> <%= f.error_messages %> - <%= render :partial => "admin/infos/form", :locals => { :f => f, :is_new => true } %> -
- <%= link_to t('create'), "#", :onclick=>"$('#new_attribute').submit()" %> -
-
+ <%= render :partial => "admin/#{@attribute_type}s/form", :locals => { :f => f, :is_new => true } %> +
<%= link_back %> + <%= link_to t('create'), "#", :onclick=>"$('#new_#{@attribute_type}').submit()" %>
<% end -%> -
- - - - +
\ No newline at end of file diff --git a/app/views/admin/infos/_attribute_field.html.erb b/app/views/admin/infos/_attribute_field.html.erb new file mode 100644 index 00000000..12ed7828 --- /dev/null +++ b/app/views/admin/infos/_attribute_field.html.erb @@ -0,0 +1,3 @@ +<%= f.fields_for :attribute_fields, attribute_field do |f| %> + <%= render :partial => 'admin/attributes/attribute_field', :object => attribute_field, :locals => {:f => f} %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/infos/_form.html.erb b/app/views/admin/infos/_form.html.erb new file mode 100644 index 00000000..75ded177 --- /dev/null +++ b/app/views/admin/infos/_form.html.erb @@ -0,0 +1,70 @@ +
+

<%= t("admin.#{@attribute_type}") %>

+
+ + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + +
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %> + <%= text_field_tag "#{@attribute_type}[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> +
+
+
+ + +
+

Attributes

+
+ + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + + + + + + <% @attribute.attribute_fields.each do |attribute_field| %> + <%= render :partial => 'attribute_field', :object => attribute_field, :locals => {:f => f} %> + <% end %> + +
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
+ <%= hidden_field_tag 'attribute_field_count', @attribute.attribute_fields.count %> + <%= t(:add) %> +
+
+
+ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "attribute_form" %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/infos/edit.html.erb b/app/views/admin/infos/edit.html.erb deleted file mode 100644 index e0f75789..00000000 --- a/app/views/admin/infos/edit.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -<% content_for :secondary do %> - <%= render 'admin/users/side_bar' %> -<% end %> - -
- <%= form_for @attribute, :url => eval("admin_user_#{@attribute_type}_model_path(@user_role_model)") do |f| %> - <%= f.error_messages %> - <%= render :partial => "admin/attributes/form", :locals => { :f => f, :is_new => false } %> -
- <%= link_to t('update'), "#", :onclick=>"$('#edit_user_role_model_#{@attribute.id}').submit()" %> -
-
- <%= link_back %> -
- <% end -%> -
\ No newline at end of file diff --git a/app/views/admin/pages/_show.html.erb b/app/views/admin/pages/_show.html.erb index a4b78e2f..1937fe92 100644 --- a/app/views/admin/pages/_show.html.erb +++ b/app/views/admin/pages/_show.html.erb @@ -1,7 +1,3 @@ <%= flash_messages %> -<%= parse_page_edit(@item).html_safe %> - -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "page_edit" %> -<% end -%> +<%= parse_page_edit(@item).html_safe %> \ No newline at end of file diff --git a/app/views/admin/roles/_attribute_field.html.erb b/app/views/admin/roles/_attribute_field.html.erb new file mode 100644 index 00000000..12ed7828 --- /dev/null +++ b/app/views/admin/roles/_attribute_field.html.erb @@ -0,0 +1,3 @@ +<%= f.fields_for :attribute_fields, attribute_field do |f| %> + <%= render :partial => 'admin/attributes/attribute_field', :object => attribute_field, :locals => {:f => f} %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/roles/_form.html.erb b/app/views/admin/roles/_form.html.erb new file mode 100644 index 00000000..7026db95 --- /dev/null +++ b/app/views/admin/roles/_form.html.erb @@ -0,0 +1,50 @@ +
+

<%= t("admin.#{@attribute_type}") %>

+
+ + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + +
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %> + <%= text_field_tag "#{@attribute_type}[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> +
+
+
+ +
+

Sub roles

+ <% @attribute.sub_roles.each do |sub_role| %> + <%= render :partial => 'form_sub', :object => sub_role, :locals => {:f => f} %> + <% end %> +
+
+ +
+ <%= hidden_field_tag 'attribute_field_count', @attribute.sub_roles.count %> + <%= t(:add) %> +
+ +<% content_for :page_specific_javascript do %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/roles/_form_sub.html.erb b/app/views/admin/roles/_form_sub.html.erb new file mode 100644 index 00000000..09dac402 --- /dev/null +++ b/app/views/admin/roles/_form_sub.html.erb @@ -0,0 +1,3 @@ +<%= f.fields_for :sub_roles, form_sub do |f| %> + <%= render :partial => 'sub_role', :object => form_sub, :locals => {:f => f} %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/roles/_sub_role.html.erb b/app/views/admin/roles/_sub_role.html.erb new file mode 100644 index 00000000..04c85ff5 --- /dev/null +++ b/app/views/admin/roles/_sub_role.html.erb @@ -0,0 +1,70 @@ + +
+ + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + +
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= sub_role.new_record? ? (f.text_field :key, {:style => "width:150px"}) : sub_role.key %> + <%= f.text_field "i18n_variable[#{locale}]", :value => (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> +
+
+

Attributes

+
+ + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + + + + + + + + <% sub_role.attribute_fields.each do |attribute_field| %> + <%= render :partial => 'attribute_field', :object => attribute_field, :locals => {:f => f} %> + <% end %> + +
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
+ <%= hidden_field_tag 'attribute_field_count', sub_role.attribute_fields.count %> + <%= t(:add) %> + <%= hidden_field_tag 'sub_role_temp_id', 'new_sub_roles' %> +
+
+
+
+ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "attribute_form" %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/user_attribute_models/_attribute_model.html.erb b/app/views/admin/user_attribute_models/_attribute_model.html.erb deleted file mode 100644 index 819f584b..00000000 --- a/app/views/admin/user_attribute_models/_attribute_model.html.erb +++ /dev/null @@ -1,36 +0,0 @@ -<%= fields_for "user_#{@attribute}_model[attribute_models][]", attribute_model, :index => nil do |f| %> - - <%= attribute_model.new_record? ? (f.text_field :key) : attribute_model.key %> - - <%= check_box_tag "locale[]", value = '', attribute_model.locale.nil? ? true : attribute_model.locale %> - <%= hidden_field_tag "user_#{@attribute}_model[attribute_models][][locale]", attribute_model.locale.nil? ? true : attribute_model.locale %> - - <% @site_valid_locales.each do |locale| %> - <%= text_field_tag "user_#{@attribute}_model[attribute_models][][i18n_variable][#{locale}]", (attribute_model.i18n_variable[locale] rescue nil), :style => "width:130px" %> - <% end %> - - <%= f.select :markup, LIST[:markups], {}, {:style => "width:90px"} %> -
> - <%= t('admin.options') %>: - <%= text_field_tag "user_#{@attribute}_model[attribute_models][][select_list_options]", attribute_model.select_list_options, :style => "width:130px" %> -
- - - - <% if attribute_model.new_record? %> - <%= t(:delete) %> - <% else %> - <% if attribute_model.is_built_in? %> - - <%= hidden_field_tag "user_#{@attribute}_model[attribute_models][][disabled]", attribute_model.is_disabled? , :class => 'built_in_state' %> - <% else %> - <%= t(:delete) %> - <%= hidden_field_tag "user_#{@attribute}_model[attribute_models][][should_destroy]", nil , :class => 'should_destroy' %> - <% end %> - <%= f.hidden_field :id %> - <%= f.hidden_field :key %> - <% end %> - - - -<% end %> \ No newline at end of file diff --git a/app/views/admin/user_attribute_models/_form.html.erb b/app/views/admin/user_attribute_models/_form.html.erb deleted file mode 100644 index edbcae39..00000000 --- a/app/views/admin/user_attribute_models/_form.html.erb +++ /dev/null @@ -1,57 +0,0 @@ -
-

<%= t("admin.user_#{@attribute}") %>

-
- - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - -
<%= t('admin.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @user_attribute_model.key %> - <%= text_field_tag "user_#{@attribute}_model[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :style => "width:150px" %> -
-
-
- - -
-

Attributes

-
- - - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - - - - - - - - <%= render :partial => 'admin/user_attribute_models/attribute_model', :collection => @user_attribute_model.attribute_models %> - -
<%= t('admin.key') %><%= t('admin.multilingual') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('admin.type')%> 
<%= t(:add) %>
-
-
- -<% content_for :page_specific_javascript do %> - <%= javascript_include_tag "user_attribute_model_form" %> -<% end -%> diff --git a/app/views/admin/user_attribute_models/admin.html.erb b/app/views/admin/user_attribute_models/admin.html.erb deleted file mode 100644 index a4bbbb43..00000000 --- a/app/views/admin/user_attribute_models/admin.html.erb +++ /dev/null @@ -1,31 +0,0 @@ - - - - - <%= @title || APP_CONFIG['orbit'] %> - - <%= stylesheet_link_tag "admin" %> - <%= javascript_include_tag "admin" %> - <%= yield :page_specific_css %> - <%= yield :page_specific_javascript %> - <%= csrf_meta_tag %> - - - - -
- -
- <%= yield %> -
-
<%= yield :tertiary %>
- -
- - diff --git a/app/views/admin/user_attribute_models/edit.html.erb b/app/views/admin/user_attribute_models/edit.html.erb deleted file mode 100644 index d0442fb8..00000000 --- a/app/views/admin/user_attribute_models/edit.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -<% content_for :secondary do %> - <%= render 'side_bar' %> -<% end %> - -
- <%= form_for @user, :url => admin_user_path(@user), :html => { :multipart => true } do |f| %> - <%= f.error_messages %> - <%= render :partial => 'form', :locals => { :f => f } %> -
- <%= link_back %> - <%= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').submit()" %> -
- <% end -%> -
\ No newline at end of file diff --git a/app/views/admin/user_attribute_models/index.html.erb b/app/views/admin/user_attribute_models/index.html.erb deleted file mode 100644 index 87c5bb2c..00000000 --- a/app/views/admin/user_attribute_models/index.html.erb +++ /dev/null @@ -1,41 +0,0 @@ -<% content_for :secondary do %> - <%= render 'admin/users/side_bar' %> -<% end %> - -
-
- <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path"), :class => 'new' %> -
- - - - - - - - - <% @user_attribute_models.each do |user_attribute_model| %> - "> - - - - - - - <% end %> - -
<%= t("admin.#{@attribute}") %><%= t('admin.action') %>
<%= user_attribute_model.i18n_variable[I18n.locale] %> - <%= link_to t(:edit), eval("edit_admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'edit' %> - <% if user_attribute_model.is_built_in? %> - <%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %> - <%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %> - <% else %> - <%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %> - <%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %> - <%= link_to t(:delete), eval("admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %> - <% end %> -
-
- <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path"), :class => 'new' %> -
-
diff --git a/app/views/admin/user_attribute_models/new.html.erb b/app/views/admin/user_attribute_models/new.html.erb deleted file mode 100644 index 490561fa..00000000 --- a/app/views/admin/user_attribute_models/new.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<% content_for :secondary do %> - <%= render 'admin/users/side_bar' %> -<% end %> - -
- <%= form_for @user_attribute_model, :url => eval("admin_user_#{@attribute}_models_path") do |f| %> - <%= f.error_messages %> - <%= render :partial => "admin/user_attribute_models/form", :locals => { :f => f, :is_new => true } %> -
- <%= link_back %> - <%= link_to t('create'), "#", :onclick=>"$('#new_user_attribute_model').submit()" %> -
- <% end -%> -
- - - - diff --git a/app/views/admin/user_attribute_models/toggle_enable.js.erb b/app/views/admin/user_attribute_models/toggle_enable.js.erb deleted file mode 100644 index 153c24a8..00000000 --- a/app/views/admin/user_attribute_models/toggle_enable.js.erb +++ /dev/null @@ -1,3 +0,0 @@ -$("#enable_<%= @user_attribute_model.id %>").toggle(); -$("#disable_<%= @user_attribute_model.id %>").toggle(); -$("#attribute_<%= @user_attribute_model.id %>").toggleClass('disable'); \ No newline at end of file diff --git a/app/views/admin/user_attributes/index.html.erb b/app/views/admin/user_attributes/index.html.erb deleted file mode 100644 index b5965a79..00000000 --- a/app/views/admin/user_attributes/index.html.erb +++ /dev/null @@ -1,34 +0,0 @@ -<% content_for :secondary do %> - <%= render 'admin/users/side_bar' %> -<% end %> - -
-
- <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %> -
-
    -
  • - <%= t("admin.#{@attribute}") %> - <%= t('admin.action') %> -
  • - <% @user_attribute_models.each do |user_attribute_model| %> -
  • clear"> - <%= user_attribute_model.i18n_variable[I18n.locale] %> - - - <%= link_to t(:edit), eval("edit_admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'edit' %> - <% if user_attribute_model.is_built_in? %> - <%= link_to t(:enable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? 'none' : ''}", :class => 'switch' %> - <%= link_to t(:disable), eval("admin_user_#{@attribute}_model_path(user_attribute_model, :authenticity_token => form_authenticity_token, :user_#{@attribute}_model => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{user_attribute_model.id}", :style => "display:#{user_attribute_model.is_disabled? ? '' : 'none'}", :class => 'switch' %> - <% else %> - <%= link_to t(:delete), eval("admin_user_#{@attribute}_model_path(user_attribute_model)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %> - <% end %> - - -
  • - <% end %> -
-
- <%= link_to t("admin.new_user_#{@attribute}"), eval("new_admin_user_#{@attribute}_model_path") %> -
-
diff --git a/app/views/admin/user_attributes/new.html.erb b/app/views/admin/user_attributes/new.html.erb deleted file mode 100644 index f04da0e5..00000000 --- a/app/views/admin/user_attributes/new.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -

New user attribute: <%= @user_attribute.key %>

- -<% form_for @user_attribute, :url => admin_user_attributes_path do |f| %> - -

- <%= f.label :key, "Key" %> - <%= f.text_field :key %> -

- - <%= render :partial => "form", :locals => { :f => f } %> - -

- <%= f.submit %> -

- -<% end -%> diff --git a/app/views/admin/users/_form.html.erb b/app/views/admin/users/_form.html.erb index bbf39e4d..5c57284b 100644 --- a/app/views/admin/users/_form.html.erb +++ b/app/views/admin/users/_form.html.erb @@ -16,27 +16,27 @@
-<% @user_info_models.each do |ua| %> -
+<% @infos.each do |ua| %> +

<%= ua.i18n_variable[I18n.locale] %>


- <%= render :partial => 'user_attribute', - :object => (@user.user_infos.detect {|u| u.key == ua.key } || @user.user_infos.build), + <%= render :partial => 'attribute', + :object => (@user.infos.detect {|u| u.key == ua.key } || @user.infos.build), :locals => {:ua => ua, :type => 'info'} %>
<% end -%> -
- <% @user_role_models.each do |ua| %> - <% content_for :page_specific_javascript do %> - <%= javascript_include_tag "attribute_form" %> -<% end %> \ No newline at end of file +<% end unless !sub_role.new_record? %> \ No newline at end of file From afbffe37d52e98b5660105f589503c9ab671f1ca Mon Sep 17 00:00:00 2001 From: chris2tof Date: Tue, 20 Dec 2011 14:35:28 +0800 Subject: [PATCH 06/20] Users can now be saved with sub_roles --- app/assets/javascripts/user_form.js | 6 ++- app/controllers/admin/roles_controller.rb | 2 - app/controllers/admin/users_controller.rb | 13 +----- app/models/user/attribute_field.rb | 2 +- app/models/user/attribute_value.rb | 4 ++ app/models/user/sub_role.rb | 2 +- app/models/user/user.rb | 10 ++++- app/views/admin/users/_form.html.erb | 26 +++++------ app/views/admin/users/_info.html.erb | 40 +++++++++++++++++ .../admin/users/_show_attribute.html.erb | 2 +- app/views/admin/users/_show_sub_role.html.erb | 4 ++ app/views/admin/users/_sub_role.html.erb | 37 ++++++++++++++++ .../admin/users/_sub_role_selector.html.erb | 4 ++ .../admin/users/_user_attribute.html.erb | 44 ------------------- app/views/admin/users/show.html.erb | 11 ++--- lib/tasks/dev.rake | 6 +-- 16 files changed, 125 insertions(+), 88 deletions(-) create mode 100644 app/views/admin/users/_info.html.erb create mode 100644 app/views/admin/users/_show_sub_role.html.erb create mode 100644 app/views/admin/users/_sub_role.html.erb create mode 100644 app/views/admin/users/_sub_role_selector.html.erb delete mode 100644 app/views/admin/users/_user_attribute.html.erb diff --git a/app/assets/javascripts/user_form.js b/app/assets/javascripts/user_form.js index 168f5437..183d8270 100644 --- a/app/assets/javascripts/user_form.js +++ b/app/assets/javascripts/user_form.js @@ -1,6 +1,10 @@ $(document).ready(function(){ - $('#active_role').change(function(){ + $('#user_role_id').change(function(){ $('#roles .attributes_block').hide(); $('#'+this.value+'_block').toggle(); }); + + $('.sub_role_select').change(function(){ + $('#sub_role_' + this.value).toggle(); + }); }); \ No newline at end of file diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index f0321368..65c86f36 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -26,14 +26,12 @@ class Admin::RolesController < ApplicationController end def create - puts params.to_yaml @attribute = Role.new(params[:role]) @attribute.save redirect_to :action => :index end def update - puts params.to_yaml @attribute = Role.find(params[:id]) @attribute.update_attributes(params[:role]) respond_to do |format| diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index b8df3312..f7135beb 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -19,16 +19,9 @@ class Admin::UsersController < ApplicationController end def create + puts params.to_yaml @user = User.new(params[:user]) if @user.save - @user.infos.each do |info| - info.save - info.attribute_values.each(&:save) - end - @user.roles.each do |role| - role.save - role.attribute_values.each(&:save) - end flash[:notice] = t('admin.create_success_user') redirect_to :action => :index else @@ -66,10 +59,6 @@ class Admin::UsersController < ApplicationController else @user = User.find(params[:id]) @user.destroy - @user.attributes.each do |ua| - ua.attribute_values.each(&:destroy) - ua.destroy - end end redirect_to :action => :index diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb index 7ea385a9..42bbf910 100644 --- a/app/models/user/attribute_field.rb +++ b/app/models/user/attribute_field.rb @@ -14,7 +14,7 @@ class AttributeField has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy has_many :attribute_values - validates_uniqueness_of :key + # validates_uniqueness_of :key # Convert the string list_options into an array def select_list_options=(var) diff --git a/app/models/user/attribute_value.rb b/app/models/user/attribute_value.rb index 8b15bf3d..47c84085 100644 --- a/app/models/user/attribute_value.rb +++ b/app/models/user/attribute_value.rb @@ -8,4 +8,8 @@ class AttributeValue belongs_to :attribute_field belongs_to :user + def method_missing(field) + self[field] + end + end diff --git a/app/models/user/sub_role.rb b/app/models/user/sub_role.rb index 63b8cf92..cdefb5f5 100644 --- a/app/models/user/sub_role.rb +++ b/app/models/user/sub_role.rb @@ -1,7 +1,7 @@ class SubRole < Attribute belongs_to :role - has_many :users + has_and_belongs_to_many :users # Get an sub_role from key def self.get_sub_role_from_key(key) diff --git a/app/models/user/user.rb b/app/models/user/user.rb index a06233d1..10b874ad 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -12,7 +12,7 @@ class User has_many :attribute_values, :autosave => true, :dependent => :destroy belongs_to :role - belongs_to :sub_role + has_and_belongs_to_many :sub_roles accepts_nested_attributes_for :attribute_values, :allow_destroy => true def name @@ -27,7 +27,13 @@ class User end def get_attribute_values - @attribute_values ||= self.attribute_values.to_a + @attribute_values ||= self.attribute_values + end + + def get_value_from_field_id(field_id) + values = get_attribute_values + value = values.detect {|value| value.attribute_field_id == field_id} rescue nil + value ? value : self.attribute_values.build end end diff --git a/app/views/admin/users/_form.html.erb b/app/views/admin/users/_form.html.erb index 5c57284b..602afc2d 100644 --- a/app/views/admin/users/_form.html.erb +++ b/app/views/admin/users/_form.html.erb @@ -16,32 +16,26 @@
-<% @infos.each do |ua| %> -
-

<%= ua.i18n_variable[I18n.locale] %>

-
- <%= render :partial => 'attribute', - :object => (@user.infos.detect {|u| u.key == ua.key } || @user.infos.build), - :locals => {:ua => ua, :type => 'info'} %> -
-<% end -%> + +<%= render :partial => 'info', :collection => @infos, :locals => {:f => f} %> +
- <% @roles.each do |ua| %> - + <% content_for :page_specific_javascript do %> <%= javascript_include_tag "user_form" %> <% end -%> diff --git a/app/views/admin/users/_info.html.erb b/app/views/admin/users/_info.html.erb new file mode 100644 index 00000000..a7d44ea9 --- /dev/null +++ b/app/views/admin/users/_info.html.erb @@ -0,0 +1,40 @@ +
+

<%= info.i18n_variable[I18n.locale] %>

+
+
+ + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + <% info.get_enabled_attribute_fields.each do |attr| %> + <%= f.fields_for :attribute_values, @user.get_value_from_field_id(attr.id) do |f| %> + + + <% if attr["locale"] && attr["markup"] == 'text_field' %> + <% @site_valid_locales.each do |locale| %> + + <% end %> + <% else %> + + <% end -%> + <%= f.hidden_field :attribute_field_id, :value => attr.id %> + <%= f.hidden_field :key, :value => attr.key %> + + <% end %> + <% end %> + +
<%= t("admin.key") %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= attr.i18n_variable[I18n.locale] %><%= f.text_field locale %>> + <% if attr["markup"] == "text_field" %> + <%= f.text_field :non_locale %> + <% elsif attr["markup"] == "select" %> + <%= f.select :non_locale, options_for_select(attr["options"], value['non_locale']) %> + <% end -%> +
+
+
\ No newline at end of file diff --git a/app/views/admin/users/_show_attribute.html.erb b/app/views/admin/users/_show_attribute.html.erb index 22f89b93..ec33f84b 100644 --- a/app/views/admin/users/_show_attribute.html.erb +++ b/app/views/admin/users/_show_attribute.html.erb @@ -7,7 +7,7 @@ <% end %> - <% a.get_enabled_attribute_fields.each do |attr| %> + <% show_attribute.get_enabled_attribute_fields.each do |attr| %> <%= attr.i18n_variable[I18n.locale] %> <% @site_valid_locales.each do |locale| %> diff --git a/app/views/admin/users/_show_sub_role.html.erb b/app/views/admin/users/_show_sub_role.html.erb new file mode 100644 index 00000000..22d8b758 --- /dev/null +++ b/app/views/admin/users/_show_sub_role.html.erb @@ -0,0 +1,4 @@ +
+

<%= show_sub_role.i18n_variable[I18n.locale] %>

+ <%= render :partial => 'show_attribute', :object => show_sub_role %> +
\ No newline at end of file diff --git a/app/views/admin/users/_sub_role.html.erb b/app/views/admin/users/_sub_role.html.erb new file mode 100644 index 00000000..f55b8b48 --- /dev/null +++ b/app/views/admin/users/_sub_role.html.erb @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/app/views/admin/users/_sub_role_selector.html.erb b/app/views/admin/users/_sub_role_selector.html.erb new file mode 100644 index 00000000..6d7924ca --- /dev/null +++ b/app/views/admin/users/_sub_role_selector.html.erb @@ -0,0 +1,4 @@ +<% role.sub_roles.each do |sub_role| %> + <%= sub_role.i18n_variable[I18n.locale] %> + <%= check_box_tag "user[sub_role_ids][]", sub_role.id, @user.sub_role_ids.include?(sub_role.id), :class => 'sub_role_select' %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/users/_user_attribute.html.erb b/app/views/admin/users/_user_attribute.html.erb deleted file mode 100644 index 65225ce5..00000000 --- a/app/views/admin/users/_user_attribute.html.erb +++ /dev/null @@ -1,44 +0,0 @@ -<%= fields_for "user[#{type}s]", attribute, :index => nil do |f| %> - <%= f.hidden_field :key, :value => ua.key %> - <%= f.hidden_field :id unless attribute.new_record? %> - -
- - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - <% ua.get_enabled_attribute_fields.each do |attr| %> - <% value = attribute.attribute_values.detect{|v| v.key == attr.key } %> - <%= hidden_field_tag "user[#{type}s][][attribute_values][][id]", value.id rescue nil %> - <%= hidden_field_tag "user[#{type}s][][attribute_values][][key]", attr.key %> - - - <% if attr["locale"] && attr["markup"] == 'text_field' %> - <%= hidden_field_tag "user[#{type}s][][attribute_values][][non_locale]", nil %> - <% @site_valid_locales.each do |locale| %> - - <% end -%> - <% else %> - - <% end -%> - - <% end %> - -
<%= t("admin.key") %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %>
<%= attr.i18n_variable[I18n.locale] %> - <%= text_field_tag "user[#{type}s][][attribute_values][][#{locale}]", (value[locale] rescue nil) %> - > - <% if attr["markup"] == "text_field" %> - <%= text_field_tag "user[#{type}s][][attribute_values][][non_locale]", (value['non_locale'] rescue nil) %> - <% elsif attr["markup"] == "select" %> - <%= select_tag "user[#{type}s][][attribute_values][][non_locale]", options_for_select(attr["options"], value['non_locale']) %> - <% end -%> -
-
- -<% end %> diff --git a/app/views/admin/users/show.html.erb b/app/views/admin/users/show.html.erb index 2e8221b8..bbada72c 100644 --- a/app/views/admin/users/show.html.erb +++ b/app/views/admin/users/show.html.erb @@ -5,24 +5,25 @@
- <% if @user.avatar? %> - <%= image_tag(@user.avatar.thumb.url) %> + <% if @user.avatar? %> + <%= image_tag(@user.avatar.thumb.url) %> <% else %> - <%= image_tag "person.png" %> + <%= image_tag "person.png" %> <% end %> +
<% @infos.each do |a| %>

<%= a.i18n_variable[I18n.locale] %>


- <%= render :partial => 'show_attribute', :locals => {:a => a} %> + <%= render :partial => 'show_attribute', :object => a %>
<% end -%>

<%= @user.role.i18n_variable[I18n.locale] %>


- <%#= render :partial => 'show_attribute', :locals => {:a => active_role, :object => @user.get_role_from_key(active_role.key)} %> + <%= render :partial => 'show_sub_role', :collection => @user.sub_roles %>
<%= link_to t(:edit), edit_admin_user_path(@user) %> diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index cb376f9c..e397e202 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -46,7 +46,7 @@ namespace :dev do sr_1_1 = r_1.sub_roles.build( :key => 'good_teacher', :i18n_variable => var_1_1, :built_in => true ) sr_1_1.attribute_fields.build( :key => 'field', :locale => true, :i18n_variable => var_1_1_1, :markup => 'text_field', :list_options => [], :built_in => true ) sr_1_1.attribute_fields.build( :key => 'department', :locale => true, :i18n_variable => var_1_1_2, :markup => 'text_field', :list_options => [], :built_in => true ) - sr_1_2 = r_1.sub_roles.build( :key => 'bad_teacher', :i18n_variable => var_1_1 ) + sr_1_2 = r_1.sub_roles.build( :key => 'bad_teacher', :i18n_variable => var_1_2 ) sr_1_2.attribute_fields.build( :key => 'field', :locale => true, :i18n_variable => var_1_2_1, :markup => 'text_field', :list_options => [] ) sr_1_2.attribute_fields.build( :key => 'department', :locale => true, :i18n_variable => var_1_2_2, :markup => 'text_field', :list_options => [] ) sr_1_2.attribute_fields.build( :key => 'speciality', :locale => true, :i18n_variable => var_1_2_3, :markup => 'text_field', :list_options => [] ) @@ -124,7 +124,7 @@ namespace :dev do - user = User.create( :email => 'chris@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :role_id => r_1.id, :sub_role_id => sr_1_2.id ) + user = User.create( :email => 'chris@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :role_id => r_1.id, :sub_role_ids => [sr_1_2.id] ) AttributeValue.create( :user => user, :attribute_field => i_1.attribute_fields[0], :key => 'first_name', :en => 'Christophe', :zh_tw => '順發' ) AttributeValue.create( :user_id => user.id, :attribute_field_id => i_1.attribute_fields[1].id, :key => 'last_name', :en => 'Vilayphiou', :zh_tw => '林' ) AttributeValue.create( :user_id => user.id, :attribute_field_id => sr_1_2.attribute_fields[0].id, :key => 'field', :en => 'Computer Architecture', :zh_tw => '計算機系統結構' ) @@ -132,7 +132,7 @@ namespace :dev do AttributeValue.create( :user_id => user.id, :attribute_field_id => sr_1_2.attribute_fields[2].id, :key => 'speciality', :en => 'HSR', :zh_tw => '高鐵' ) - user = User.create( :email => 'matt@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :role_id => r_2.id, :sub_role_id => sr_2_1.id ) + user = User.create( :email => 'matt@rulingcom.com', :password => 'password', :password_confirmation => 'password', :admin => true, :role_id => r_2.id, :sub_role_ids => [sr_2_1.id ] ) AttributeValue.create( :user_id => user.id, :attribute_field_id => i_1.attribute_fields[0].id, :key => 'first_name', :en => 'Matt', :zh_tw => '儒淵' ) AttributeValue.create( :user_id => user.id, :attribute_field_id => i_1.attribute_fields[1].id, :key => 'last_name', :en => 'Fu', :zh_tw => '傅' ) AttributeValue.create( :user_id => user.id, :attribute_field_id => sr_2_1.attribute_fields[0].id, :key => 'major', :en => 'Information management', :zh_tw => '信息化管理' ) From a09f8e45514858fc1943e3b01ba4fe695b8a4849 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Tue, 20 Dec 2011 16:47:17 +0800 Subject: [PATCH 07/20] merge with november_presentation --- .rvmrc | 1 - Gemfile | 2 + Gemfile.lock | 1 + app/assets/javascripts/page_edit.js | 16 +- app/controllers/admin/app_auths_controller.rb | 17 + .../admin/module_apps_controller.rb | 9 + app/controllers/admin/pages_controller.rb | 2 + app/controllers/application_controller.rb | 4 +- app/controllers/pages_controller.rb | 35 +- app/models/app_auth.rb | 77 + app/models/module_app.rb | 6 +- app/models/page.rb | 2 + app/models/purchase/purchase.rb | 4 + app/models/user/user.rb | 7 + app/views/admin/app_auths/_auth_unit.html.erb | 3 + app/views/admin/app_auths/index.html.erb | 32 + .../admin/module_apps/_app_selector.html.erb | 1 + .../module_apps/reload_frontend_pages.js.erb | 1 + app/views/admin/pages/_form.html.erb | 7 +- config/list.yml | 1 + config/routes.rb | 14 +- lib/fraisier/layout.html | 8 +- lib/parser.rb | 34 +- lib/tasks/dev.rake | 2 +- public/static/kernel.js | 21 +- spec/models/app_auth_basic.rb | 137 + spec/models/app_auth_spec.rb | 81 + spec/spec_helper.rb | 1 - vendor/built_in_modules/blog/.gitignore | 4 - vendor/built_in_modules/blog/Gemfile | 32 - vendor/built_in_modules/blog/Gemfile.lock | 83 - vendor/built_in_modules/blog/README | 256 - vendor/built_in_modules/blog/Rakefile | 7 - .../app/controllers/application_controller.rb | 23 - .../panel/blog/comments_controller.rb | 7 - .../blog/app/helpers/application_helper.rb | 2 - .../blog/app/models/comment.rb | 7 - .../built_in_modules/blog/app/models/post.rb | 8 - .../app/views/layouts/application.html.erb | 14 - .../app/views/panel/blog/posts/edit.html.erb | 8 - .../app/views/panel/blog/posts/index.html.erb | 25 - .../app/views/panel/blog/posts/new.html.erb | 6 - vendor/built_in_modules/blog/config.ru | 4 - .../blog/config/application.rb | 49 - vendor/built_in_modules/blog/config/boot.rb | 6 - .../blog/config/environment.rb | 5 - .../blog/config/environments/development.rb | 26 - .../blog/config/environments/production.rb | 49 - .../blog/config/environments/test.rb | 35 - .../initializers/backtrace_silencers.rb | 7 - .../blog/config/initializers/inflections.rb | 10 - .../blog/config/initializers/mime_types.rb | 5 - .../blog/config/initializers/secret_token.rb | 7 - .../blog/config/initializers/session_store.rb | 8 - .../blog/config/locales/en.yml | 18 - .../blog/config/locales/zh_tw.yml | 10 - .../built_in_modules/blog/config/mongoid.yml | 23 - vendor/built_in_modules/blog/config/routes.rb | 66 - vendor/built_in_modules/blog/db/seeds.rb | 7 - .../built_in_modules/blog/doc/README_FOR_APP | 2 - .../built_in_modules/blog/lib/tasks/.gitkeep | 0 vendor/built_in_modules/blog/public/404.html | 26 - vendor/built_in_modules/blog/public/422.html | 26 - vendor/built_in_modules/blog/public/500.html | 26 - .../built_in_modules/blog/public/favicon.ico | 0 .../blog/public/images/rails.png | Bin 6646 -> 0 bytes .../built_in_modules/blog/public/index.html | 239 - .../blog/public/javascripts/application.js | 2 - .../blog/public/javascripts/controls.js | 965 --- .../blog/public/javascripts/dragdrop.js | 974 --- .../blog/public/javascripts/effects.js | 1123 --- .../blog/public/javascripts/prototype.js | 6001 ----------------- .../blog/public/javascripts/rails.js | 191 - .../built_in_modules/blog/public/robots.txt | 5 - .../blog/public/stylesheets/.gitkeep | 0 vendor/built_in_modules/blog/script/rails | 6 - .../blog/test/performance/browsing_test.rb | 9 - .../built_in_modules/blog/test/test_helper.rb | 7 - .../blog/vendor/plugins/.gitkeep | 0 vendor/plugins/NewBlog/NewBlog.json | 9 +- .../panel/blog/back_end}/posts_controller.rb | 8 +- .../panel/blog/comments_controller.rb | 7 - .../blog/front_end/comments_controller.rb | 7 + .../panel/blog/front_end/posts_controller.rb | 17 + .../panel/blog/posts_controller.rb | 111 - .../panel/blog/widget/posts_controller.rb | 15 + .../panel/blog/back_end}/posts/_form.html.erb | 0 .../panel/blog/back_end/posts/edit.html.erb | 8 + .../blog/{ => back_end}/posts/index.html.erb | 8 +- .../{ => back_end}/posts/latest_post.html.erb | 0 .../blog/{ => back_end}/posts/new.html.erb | 4 +- .../panel/blog/back_end}/posts/show.html.erb | 4 +- .../front_end/posts/_post_frontend.html.erb | 7 + .../panel/blog/front_end/posts/index.html.erb | 11 + .../blog/{ => front_end}/posts/show.html.erb | 6 +- .../app/views/panel/blog/posts/_form.html.erb | 14 - .../app/views/panel/blog/posts/edit.html.erb | 8 - .../posts/index.html.erb} | 2 +- .../posts/latest_post.html.erb} | 0 .../plugins/NewBlog/config/locales/zh_tw.yml | 310 + vendor/plugins/NewBlog/config/routes.rb | 22 +- 101 files changed, 891 insertions(+), 10632 deletions(-) delete mode 100644 .rvmrc create mode 100644 app/controllers/admin/app_auths_controller.rb create mode 100644 app/controllers/admin/module_apps_controller.rb create mode 100644 app/models/app_auth.rb create mode 100644 app/views/admin/app_auths/_auth_unit.html.erb create mode 100644 app/views/admin/app_auths/index.html.erb create mode 100644 app/views/admin/module_apps/_app_selector.html.erb create mode 100644 app/views/admin/module_apps/reload_frontend_pages.js.erb create mode 100644 spec/models/app_auth_basic.rb create mode 100644 spec/models/app_auth_spec.rb delete mode 100644 vendor/built_in_modules/blog/.gitignore delete mode 100644 vendor/built_in_modules/blog/Gemfile delete mode 100644 vendor/built_in_modules/blog/Gemfile.lock delete mode 100644 vendor/built_in_modules/blog/README delete mode 100644 vendor/built_in_modules/blog/Rakefile delete mode 100644 vendor/built_in_modules/blog/app/controllers/application_controller.rb delete mode 100644 vendor/built_in_modules/blog/app/controllers/panel/blog/comments_controller.rb delete mode 100644 vendor/built_in_modules/blog/app/helpers/application_helper.rb delete mode 100644 vendor/built_in_modules/blog/app/models/comment.rb delete mode 100644 vendor/built_in_modules/blog/app/models/post.rb delete mode 100644 vendor/built_in_modules/blog/app/views/layouts/application.html.erb delete mode 100644 vendor/built_in_modules/blog/app/views/panel/blog/posts/edit.html.erb delete mode 100644 vendor/built_in_modules/blog/app/views/panel/blog/posts/index.html.erb delete mode 100644 vendor/built_in_modules/blog/app/views/panel/blog/posts/new.html.erb delete mode 100644 vendor/built_in_modules/blog/config.ru delete mode 100644 vendor/built_in_modules/blog/config/application.rb delete mode 100644 vendor/built_in_modules/blog/config/boot.rb delete mode 100644 vendor/built_in_modules/blog/config/environment.rb delete mode 100644 vendor/built_in_modules/blog/config/environments/development.rb delete mode 100644 vendor/built_in_modules/blog/config/environments/production.rb delete mode 100644 vendor/built_in_modules/blog/config/environments/test.rb delete mode 100644 vendor/built_in_modules/blog/config/initializers/backtrace_silencers.rb delete mode 100644 vendor/built_in_modules/blog/config/initializers/inflections.rb delete mode 100644 vendor/built_in_modules/blog/config/initializers/mime_types.rb delete mode 100644 vendor/built_in_modules/blog/config/initializers/secret_token.rb delete mode 100644 vendor/built_in_modules/blog/config/initializers/session_store.rb delete mode 100644 vendor/built_in_modules/blog/config/locales/en.yml delete mode 100644 vendor/built_in_modules/blog/config/locales/zh_tw.yml delete mode 100644 vendor/built_in_modules/blog/config/mongoid.yml delete mode 100644 vendor/built_in_modules/blog/config/routes.rb delete mode 100644 vendor/built_in_modules/blog/db/seeds.rb delete mode 100644 vendor/built_in_modules/blog/doc/README_FOR_APP delete mode 100644 vendor/built_in_modules/blog/lib/tasks/.gitkeep delete mode 100644 vendor/built_in_modules/blog/public/404.html delete mode 100644 vendor/built_in_modules/blog/public/422.html delete mode 100644 vendor/built_in_modules/blog/public/500.html delete mode 100644 vendor/built_in_modules/blog/public/favicon.ico delete mode 100644 vendor/built_in_modules/blog/public/images/rails.png delete mode 100644 vendor/built_in_modules/blog/public/index.html delete mode 100644 vendor/built_in_modules/blog/public/javascripts/application.js delete mode 100644 vendor/built_in_modules/blog/public/javascripts/controls.js delete mode 100644 vendor/built_in_modules/blog/public/javascripts/dragdrop.js delete mode 100644 vendor/built_in_modules/blog/public/javascripts/effects.js delete mode 100644 vendor/built_in_modules/blog/public/javascripts/prototype.js delete mode 100644 vendor/built_in_modules/blog/public/javascripts/rails.js delete mode 100644 vendor/built_in_modules/blog/public/robots.txt delete mode 100644 vendor/built_in_modules/blog/public/stylesheets/.gitkeep delete mode 100755 vendor/built_in_modules/blog/script/rails delete mode 100644 vendor/built_in_modules/blog/test/performance/browsing_test.rb delete mode 100644 vendor/built_in_modules/blog/test/test_helper.rb delete mode 100644 vendor/built_in_modules/blog/vendor/plugins/.gitkeep rename vendor/{built_in_modules/blog/app/controllers/panel/blog => plugins/NewBlog/app/controllers/panel/blog/back_end}/posts_controller.rb (94%) delete mode 100644 vendor/plugins/NewBlog/app/controllers/panel/blog/comments_controller.rb create mode 100644 vendor/plugins/NewBlog/app/controllers/panel/blog/front_end/comments_controller.rb create mode 100644 vendor/plugins/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb delete mode 100644 vendor/plugins/NewBlog/app/controllers/panel/blog/posts_controller.rb create mode 100644 vendor/plugins/NewBlog/app/controllers/panel/blog/widget/posts_controller.rb rename vendor/{built_in_modules/blog/app/views/panel/blog => plugins/NewBlog/app/views/panel/blog/back_end}/posts/_form.html.erb (100%) create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/edit.html.erb rename vendor/plugins/NewBlog/app/views/panel/blog/{ => back_end}/posts/index.html.erb (51%) rename vendor/plugins/NewBlog/app/views/panel/blog/{ => back_end}/posts/latest_post.html.erb (100%) rename vendor/plugins/NewBlog/app/views/panel/blog/{ => back_end}/posts/new.html.erb (56%) rename vendor/{built_in_modules/blog/app/views/panel/blog => plugins/NewBlog/app/views/panel/blog/back_end}/posts/show.html.erb (77%) create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/_post_frontend.html.erb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/index.html.erb rename vendor/plugins/NewBlog/app/views/panel/blog/{ => front_end}/posts/show.html.erb (79%) delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/_form.html.erb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/edit.html.erb rename vendor/plugins/NewBlog/app/views/panel/blog/{posts/widget_index.html.erb => widget/posts/index.html.erb} (77%) rename vendor/plugins/NewBlog/app/views/panel/blog/{posts/widget_latest_post.html.erb => widget/posts/latest_post.html.erb} (100%) diff --git a/.rvmrc b/.rvmrc deleted file mode 100644 index fe5e9622..00000000 --- a/.rvmrc +++ /dev/null @@ -1 +0,0 @@ -rvm ruby-1.9.2-p290@orbit diff --git a/Gemfile b/Gemfile index 82636879..93d151f6 100644 --- a/Gemfile +++ b/Gemfile @@ -33,6 +33,8 @@ end gem 'ruby-debug19' group :test, :development do + gem 'spork' + gem 'database_cleaner' #Strategies for cleaning databases. Can be used to ensure a clean state for testing. gem "rspec", "~> 2.0" gem "rspec-rails", "~> 2.0" gem "factory_girl_rails" diff --git a/Gemfile.lock b/Gemfile.lock index 9d030c56..ac60fca1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -190,6 +190,7 @@ DEPENDENCIES carrierwave (= 0.5.4) ckeditor coffee-rails + database_cleaner delorean devise execjs diff --git a/app/assets/javascripts/page_edit.js b/app/assets/javascripts/page_edit.js index 18f258ba..50e974b4 100644 --- a/app/assets/javascripts/page_edit.js +++ b/app/assets/javascripts/page_edit.js @@ -4,4 +4,18 @@ $("div.editable").live("mouseenter mouseleave", function (event) { $("#page_design_id").live('change', function() { $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_themes'); -}); \ No newline at end of file +}); + +$("#page_module_app").live('change', function() { + var app_id = $(this).val(); + if(app_id!=''){ + $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_frontend_pages',function(data, textStatus){ + if(textStatus == 'success'){ + $(this).after(data); + } + }); + } + else{ + $("#app_page_url").remove(); + } +}); diff --git a/app/controllers/admin/app_auths_controller.rb b/app/controllers/admin/app_auths_controller.rb new file mode 100644 index 00000000..f2c01451 --- /dev/null +++ b/app/controllers/admin/app_auths_controller.rb @@ -0,0 +1,17 @@ +class Admin::AppAuthsController < ApplicationController + layout "admin" + before_filter :authenticate_user! + before_filter :is_admin? + + def index + @roles = Role.all.entries + apps = Purchase.where(:type =>"App") + @app_auth_data = apps.entries.map do |app| + app_c = eval(app.app_controller) + obj = app_c.new + obj_auth = obj.send "auth" + [:app_obj => app,:auth_field => obj_auth] + end + end + +end \ No newline at end of file diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb new file mode 100644 index 00000000..55be4135 --- /dev/null +++ b/app/controllers/admin/module_apps_controller.rb @@ -0,0 +1,9 @@ +class Admin::ModuleAppsController < ApplicationController + +def reload_frontend_pages + @module_app = ModuleApp.find(params[:id]) + respond_to do |format| + format.js {} + end +end +end \ No newline at end of file diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 224113c3..23f58444 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -19,6 +19,7 @@ class Admin::PagesController < ApplicationController def new @item = Page.new + @apps = ModuleApp.all @item.is_published = true @item.parent_id = @parent_item.id rescue nil @designs = Design.all.entries @@ -27,6 +28,7 @@ class Admin::PagesController < ApplicationController def edit @item = Page.find(params[:id]) + @apps = ModuleApp.all @i18n_variable = @item.i18n_variable @designs = Design.all.entries @design = @item.design diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 68b32238..cf04bfe0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -36,9 +36,9 @@ class ApplicationController < ActionController::Base end # Render the page - def render_page + def render_page(url = nil) if @item - render :text => parse_page(@item) + render :text => parse_page(@item,url) else render :text => '404 Not Found' end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 710c7e47..693243c2 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -9,19 +9,28 @@ class PagesController < ApplicationController end end - def show - begin - item = Item.first(:conditions => {:full_name => params[:page_name]}) - case item._type - when 'Page' - @item = item - render_page - when 'Link' - redirect_to "http://#{item[:url]}" - end - rescue - render :file => "#{Rails.root}/public/404.html", :status => :not_found - end + def appfront + + pre_uri = URI.split request.env['HTTP_REFERER'] + pre_item_fullname = pre_uri[5][1..-1] + @item = Item.first(:conditions => {:full_name => pre_item_fullname}) + redirect_to (request.env['HTTP_REFERER'].partition("?")[0]+"?app_url=#{request.fullpath}") + end + def show + begin + item = Item.first(:conditions => {:full_name => params[:page_name]}) + case item._type + when 'Page' + @item = item + render_page ((params[:app_url]+'?inner='+"true" if params[:app_url])) + when 'Link' + redirect_to "http://#{item[:url]}" + end + rescue + render :file => "#{Rails.root}/public/404.html", :status => :not_found + end + end + end diff --git a/app/models/app_auth.rb b/app/models/app_auth.rb new file mode 100644 index 00000000..9602fda0 --- /dev/null +++ b/app/models/app_auth.rb @@ -0,0 +1,77 @@ +class AppAuth + include Mongoid::Document + include Mongoid::Timestamps + # after_save :update_block_list,:update_privilage_list + + field :title + field :token + field :all ,type: Boolean,default: false + belongs_to :module_app + + belongs_to :users + # belongs_to :users,as: :block_users, :inverse_of => :privilege_apps + has_and_belongs_to_many :blocked_users, :inverse_of => nil, :class_name => "User" + has_and_belongs_to_many :privilege_users, :inverse_of => nil, :class_name => "User" + + + has_and_belongs_to_many :roles + + def add_user_to_black_list user + unless self.blocked_users.include?(user) + self.blocked_users << user + self.save! + else + false #should put error message for user existed in list already + end + end + + + def remove_user_from_black_list user + if self.blocked_users.include? user + self.blocked_users.delete user + self.save! + else + false #should put error message for user not existed in list + end + end + + + def add_user_to_privilege_list user + unless self.privilege_users.include? user + self.privilege_users << user + self.save! + else + false #should put error message for user existed in list already + end + end + + + def remove_user_from_privilege_list user + if self.privilege_users.include? user + self.privilege_users.delete user + self.save! + else + false #should put error message for user not existed in list + end + end + + def auth_users + if self.all? + User.all.entries + else + ary= self.roles.collect do |role| + role.users + end + ary << self.privilege_users + ary.flatten! + end + end + + def auth_users_after_block_list + auth_users - self.blocked_users + end + + # protected + + +end \ No newline at end of file diff --git a/app/models/module_app.rb b/app/models/module_app.rb index f692fb21..31a02025 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -2,7 +2,7 @@ class ModuleApp include Mongoid::Document include Mongoid::Timestamps - field :name_of_app + field :title field :version field :organization field :author @@ -10,4 +10,8 @@ class ModuleApp field :update_info field :create_date + field :app_pages ,type: Array + + has_one :app_auth,dependent: :delete + end diff --git a/app/models/page.rb b/app/models/page.rb index dad89219..1e716d4d 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -1,10 +1,12 @@ class Page < Item field :content + field :app_frontend_url field :theme_id, :type => BSON::ObjectId, :default => nil belongs_to :design has_many :page_parts + belongs_to :module_app embeds_many :custom_images, as: :design_image diff --git a/app/models/purchase/purchase.rb b/app/models/purchase/purchase.rb index a8a9bcfd..104e3a8e 100644 --- a/app/models/purchase/purchase.rb +++ b/app/models/purchase/purchase.rb @@ -9,4 +9,8 @@ class Purchase field :downloaded, :type => Boolean field :download_date, :type => Date + field :type + field :app_controller + has_many :app_auths + end diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 10b874ad..1e956b80 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -11,10 +11,17 @@ class User field :active_role has_many :attribute_values, :autosave => true, :dependent => :destroy + has_many :app_auths,as: :privilege_apps,:inverse_of => :privilege_lists + has_many :blocked_apps, :inverse_of => :blocked_users, :class_name => "AppAuth" + has_many :privilege_apps, :inverse_of => :privilege_users, :class_name => "AppAuth" belongs_to :role has_and_belongs_to_many :sub_roles accepts_nested_attributes_for :attribute_values, :allow_destroy => true + def avb_apps + query = AppAuth.any_of({all: true},{privilege_user_ids: self.id},{roles: self.role.id}).excludes(blocked_user_ids: self.id) + end + def name info = Class::Info.first(:conditions => {:key => 'profile'}) if info diff --git a/app/views/admin/app_auths/_auth_unit.html.erb b/app/views/admin/app_auths/_auth_unit.html.erb new file mode 100644 index 00000000..5a246fc3 --- /dev/null +++ b/app/views/admin/app_auths/_auth_unit.html.erb @@ -0,0 +1,3 @@ +
+ <%= unit%> +
\ No newline at end of file diff --git a/app/views/admin/app_auths/index.html.erb b/app/views/admin/app_auths/index.html.erb new file mode 100644 index 00000000..0d804b2b --- /dev/null +++ b/app/views/admin/app_auths/index.html.erb @@ -0,0 +1,32 @@ +<% content_for :secondary do %> +
+
+

User Role

+
    + <% @roles.each do |role| %> +
  • <%= link_to content_tag(:span, "Role") %>
  • + <% end -%> +
+
+
+<% end -%> + +

<%= t('admin.list_app_auths') %>

+ + + + + + + +<% @app_auth_data.each do |app| %> + + + <% app[0][:auth_field].each do |unit| %> + + <%end%> + +<% end %> +
<%= t('admin.app.name') %><%= t('admin.description') %>
<%= app[0][:app_obj].title %> + <%= render :partial => "auth_unit",:locals => {:unit => unit } %> +
diff --git a/app/views/admin/module_apps/_app_selector.html.erb b/app/views/admin/module_apps/_app_selector.html.erb new file mode 100644 index 00000000..90c2aee1 --- /dev/null +++ b/app/views/admin/module_apps/_app_selector.html.erb @@ -0,0 +1 @@ +<%= f.select :module_app, @apps.collect { |t| [t.title.capitalize, t.id] }, {:include_blank => true} ,{:rel => admin_module_apps_path } %> \ No newline at end of file diff --git a/app/views/admin/module_apps/reload_frontend_pages.js.erb b/app/views/admin/module_apps/reload_frontend_pages.js.erb new file mode 100644 index 00000000..d9589cc9 --- /dev/null +++ b/app/views/admin/module_apps/reload_frontend_pages.js.erb @@ -0,0 +1 @@ +$('#app_page_url').html("<%= escape_javascript(select 'page','app_frontend_url', @module_app.app_pages) %>"); \ No newline at end of file diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index 845e4d37..d0c00d16 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -30,8 +30,13 @@ <%= f.select :theme_id, @default_design.themes.collect { |t| [t.name.capitalize, t.id] }, :include_blank => true %> <% end %>

- +

+ <%= t('admin.module_app') %> + <%= render :partial => "admin/module_apps/app_selector", :locals => { :f => f } %> + +

<%= f.label :is_published, "#{t('admin.is_published')} ?" %> <%= f.radio_button :is_published, true %>Yes <%= f.radio_button :is_published, false %> No

+ diff --git a/config/list.yml b/config/list.yml index b6390b9c..e7e8c41d 100644 --- a/config/list.yml +++ b/config/list.yml @@ -1,6 +1,7 @@ forbidden_item_names: - admin - panel + - appfront markups: - text_field diff --git a/config/routes.rb b/config/routes.rb index 640dc92f..f2b4cc17 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,12 +7,13 @@ PrototypeR4::Application.routes.draw do match '/site/public_key', :to => CentralServerExchangeApp match '/site/update', :to => GithubApp match '/purchase/:type', :to => CentralServerExchangeApp - match "/panel/:app_name/frontend/:action" => redirect {|params| "/panel/#{params[:app_name]}/#{params[:action]}" } - + # routes for admin namespace :admin do resources :assets + resources :app_auths + resources :designs do collection do get 'upload_package' @@ -37,6 +38,11 @@ PrototypeR4::Application.routes.draw do get 'reload_themes' end end + resources :module_apps do + member do + get 'reload_frontend_pages' + end + end resources :page_parts resources :purchases do collection do @@ -60,6 +66,10 @@ PrototypeR4::Application.routes.draw do namespace :panel do resources :users end + + match '/panel/:app_name/front_end/*page_name' => 'pages#appfront', :via => "get",:constraints => lambda { |request| + !request.query_string.include?("inner=true") + } # routes for gridfs files match "/gridfs/*path" => "gridfs#serve" diff --git a/lib/fraisier/layout.html b/lib/fraisier/layout.html index 5fea7a2a..b2b97924 100644 --- a/lib/fraisier/layout.html +++ b/lib/fraisier/layout.html @@ -24,10 +24,10 @@
- - -
-
+ + +
+
' end c.define_tag 'content' do |tag| - part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } ret = '' - ret << "
" - ret << "' - ret << part.i18n_variable[I18n.locale.to_s] rescue '' - ret << '
' + if (tag.attributes["main"] == "true" && !page.module_app.nil?) + ret << "
" + else + part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } + ret << "
" + ret << "' + ret << part.i18n_variable[I18n.locale.to_s] rescue '' + ret << '
' + end end c.define_tag 'link' do |tag| item = Item.first(:conditions => { :full_name => tag.attr['name'] }) diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index e397e202..6fe6c0b9 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -118,7 +118,7 @@ namespace :dev do home = Page.create!( :i18n_variable_id => var_10.id, :design_id => design_1.id, :name => 'home', :is_published => true, :theme_id => theme.id ) home.page_parts.create!( :name => 'content_1', :content => File.open("#{Rails.root}/lib/template/home.page").read, :kind => 'text', :i18n_variable_id => var_13.id ) - + ModuleApp.create.from_json(File.open("#{Rails.root}/vendor/plugins/NewBlog/NewBlog.json").read).save Post.create(:title=>"1st post",:body=>"Long long time ago.....") Post.create(:title=>"2ec post",:body=>"And?.....") diff --git a/public/static/kernel.js b/public/static/kernel.js index bde5dd05..fcc06681 100644 --- a/public/static/kernel.js +++ b/public/static/kernel.js @@ -1,11 +1,20 @@ $(document).ready(function() { + + $.each($(".dymanic_load"),function(){ - $(this).load($(this).attr("path"), - function(respText,textSta,XML){ - if(textSta == 'error') - {$(this).html("Loading Failed");} - }); + if($(this).attr("path")==''){$(this).html("App setting Failed");} + + if($(this).attr("path")!=''){ + ajax_load_proc($(this),$(this).attr("path")); } + } ); $("#main_content").addClass("module"); - }); \ No newline at end of file + }); + +function ajax_load_proc(wapper,url){ + wapper.load(url,function(respText,textSta,XML){ + if(textSta == 'error') + wapper.html("Loading Failed"); + }); +} \ No newline at end of file diff --git a/spec/models/app_auth_basic.rb b/spec/models/app_auth_basic.rb new file mode 100644 index 00000000..3a2ae0f2 --- /dev/null +++ b/spec/models/app_auth_basic.rb @@ -0,0 +1,137 @@ +require 'spec_helper' +require 'ruby-debug' + + +describe AppAuth do + + before do + User.all.destroy + UserRole.all.destroy + AppAuth.all.destroy + ModuleApp.all.destroy + + #Create some fixtures of Main Role + main_role_key = ["Stud","Teacher","Staff"] + @new_main_role_list = main_role_key.each do |role| + new_role = UserRole.new :key => role + + new_role.save + end + #Create some users of User + user_emails = ["a_good_stud","a_bad_stud","a_teacher","a_staff"] + user_emails.each do |user_email| + email=user_email+"@rulingcom.com" + new_user = User.new :email=> email + new_user.save + end + + @stud_MRK = UserRole.first(conditions:{key:"Stud"}) + @teacher_MRK = UserRole.first(conditions:{key:"Teacher"}) + @staff_MRK = UserRole.first(conditions:{key:"Staff"}) + + @good_stu = User.first(conditions:{email:"a_good_stud@rulingcom.com"}) + @bad_stu = User.first(conditions:{email:"a_bad_stud@rulingcom.com"}) + @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"}) + @staff = User.first(conditions:{email:"a_staff@rulingcom.com"}) + + #setting Roles for users + @good_stu.user_role = @stud_MRK + @bad_stu.user_role = @stud_MRK + @teacher.user_role = @teacher_MRK + @staff.user_role = @staff_MRK + + @good_stu.save! + @bad_stu.save! + @teacher.save! + @staff.save! + + end + describe "Testing basic structure" do + before do + @app_auth = AppAuth.new() + #all stud has access right + @app_auth.user_roles << @stud_MRK + + #a_bad_stud add to block to app_auth + @app_auth.blocked_users << @bad_stu + + #all teacher has access right + @app_auth.user_roles << @teacher_MRK + + @app_auth.privilege_users << @staff + @app_auth.save! + end + context "Should just initialize all obj that is needed" do + + it "Testing @app_auth init result" do + @app_auth.user_roles.should have(2).item + end + + it "@app_auth should have UserRoles: Stud , Teacher " do + key_ary = @app_auth.user_roles.collect do |role| + role.key + end + key_ary.should == ["Stud","Teacher"] + end + + it "@app_auth should have one Privialage user which is belongs to Staff" do + p_user_ary = @app_auth.privilege_users.collect do |p_user| + p_user.user_role.key + end + p_user_ary.should include("Staff") + end + + it "@app_auth should have one student listed at blocklist" do + @bad_stu = User.first(conditions:{email:"a_bad_stud@rulingcom.com"}) + @app_auth.blocked_users.should have(1).item + @app_auth.blocked_users.should include(@bad_stu) + end + + it "[Development #1]-1.Authorizing roles: roles + blocklist" do + @good_stu = User.first(conditions:{email:"a_good_stud@rulingcom.com"}) + @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"}) + @staff = User.first(conditions:{email:"a_staff@rulingcom.com"}) + ary = [@good_stu,@teacher,@staff] + @app_auth.auth_users_after_block_list.should == ary + end + + it "[Development #1]-2.Authorizing single users: list of users [new_user1~2]" do + user_emails = ["new_user1","new_user2","new_user3","new_user4"] + user_emails.each do |user_email| + email=user_email+"@rulingcom.com" + new_user = User.new :email=> email + new_user.save + end + user1= User.first(conditions:{email:"new_user1@rulingcom.com"}) + user2= User.first(conditions:{email:"new_user2@rulingcom.com"}) + user3= User.first(conditions:{email:"new_user3@rulingcom.com"}) + user4= User.first(conditions:{email:"new_user4@rulingcom.com"}) + + @app_auth.privilege_users << user1 + @app_auth.privilege_users << user2 + + @app_auth.auth_users_after_block_list.should include(user1,user2) + @app_auth.auth_users_after_block_list.should_not include(user3,user4) + + end + + it "[Development #1]-3.Authorizing roles and single users: roles + blocklist + list of users" do + @app_auth.auth_users.should have(4).item + end + + it "[Development #1]-4.Authorizing all: blocklist" do + @bad_stu = User.first(conditions:{email:"a_bad_stud@rulingcom.com"}) + @new_app_auth = (AppAuth.new :all => true) + @new_app_auth.blocked_users << @bad_stu + + @new_app_auth.auth_users.should == User.all.entries + @new_app_auth.auth_users_after_block_list.should_not include(@bad_stu) + @new_app_auth.save! + end + end + + + + end + +end \ No newline at end of file diff --git a/spec/models/app_auth_spec.rb b/spec/models/app_auth_spec.rb new file mode 100644 index 00000000..7353f29d --- /dev/null +++ b/spec/models/app_auth_spec.rb @@ -0,0 +1,81 @@ +require 'spec_helper' +require 'ruby-debug' + +describe AppAuth do + + before(:all) do + @app_ary = [ + {"name" => "G_app_1" , "all" => false,"blockusers" => ["a_bad_stud@rulingcom.com"]}, + {"name" => "G_app_2" , "all" => true,"blockusers" => ["a_bad_stud@rulingcom.com"]}, + {"name" => "G_app_3_for_bad" , "all" => true,"blockusers" => []} + ] + + @app_ary.each do |t| + a = ModuleApp.new :title => t["name"] + blocked_users = t["blockusers"].collect do |b_user| + User.first(conditions:{email:b_user}) + end + a.create_app_auth :all=> t["all"],:blocked_users => blocked_users + a.save! + end + @good_stud_become_bad = User.first(conditions:{email:"a_good_stud@rulingcom.com"}) + @bad_stud_become_good = User.first(conditions:{email:"a_bad_stud@rulingcom.com"}) + @g_app_1 = ModuleApp.first(conditions:{title:"G_app_1"}) + @g_app_2 = ModuleApp.first(conditions:{title:"G_app_2"}) + @g_app_3 = ModuleApp.first(conditions:{title:"G_app_3_for_bad"}) + end + + describe "[Init status check]" do + it "bad_stud_become_good status " do + @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth + @bad_stud_become_good.avb_apps.should_not include @g_app_2.app_auth + @bad_stud_become_good.avb_apps.should include @g_app_3.app_auth + end + + it "good_stud_become_bad status " do + @good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth + @good_stud_become_bad.avb_apps.should include @g_app_2.app_auth + @good_stud_become_bad.avb_apps.should include @g_app_3.app_auth + end + end + + describe ".add_user_to_black_list sutd" do + it "When good stud is blocked with app1 and app2" do + @g_app_1.app_auth.add_user_to_black_list @good_stud_become_bad + @g_app_2.app_auth.add_user_to_black_list @good_stud_become_bad + @good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth + @good_stud_become_bad.avb_apps.should_not include @g_app_2.app_auth + end + end + + describe ".remove_user_from_black_list sutd" do + it "When bad stud is authed with app1 and app2" do + @g_app_1.app_auth.remove_user_from_black_list @bad_stud_become_good + @g_app_2.app_auth.remove_user_from_black_list @bad_stud_become_good + #@bad_stud_become_good.avb_apps.should include @g_app_1.app_auth + @bad_stud_become_good.avb_apps.should include @g_app_2.app_auth + end + end + + describe ".add_user_to_privilege_list sutd" do + it "When bad stud is auth for one more app" do + @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth #shouldn't have at first time since app1 is not sat for all + @g_app_1.app_auth.add_user_to_privilege_list @bad_stud_become_good #change status + @bad_stud_become_good.avb_apps.should include @g_app_1.app_auth #check + end + end + + describe ".remove_user_from_privilege_list sutd" do + it "admin mistake. remove user from privilege list" do + @g_app_1.app_auth.remove_user_from_privilege_list @bad_stud_become_good + @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth + end + end + + after(:all) do + @app_ary.each do |item| + ModuleApp.first(conditions: {title: item["name"]}).destroy + end + end + +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a4b16f6c..77a57396 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -55,4 +55,3 @@ end # and during each_run! # - These instructions should self-destruct in 10 seconds. If they don't, # feel free to delete them. -# \ No newline at end of file diff --git a/vendor/built_in_modules/blog/.gitignore b/vendor/built_in_modules/blog/.gitignore deleted file mode 100644 index f0fa30c5..00000000 --- a/vendor/built_in_modules/blog/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.bundle -db/*.sqlite3 -log/*.log -tmp/ diff --git a/vendor/built_in_modules/blog/Gemfile b/vendor/built_in_modules/blog/Gemfile deleted file mode 100644 index 3597088b..00000000 --- a/vendor/built_in_modules/blog/Gemfile +++ /dev/null @@ -1,32 +0,0 @@ -source 'http://rubygems.org' - -gem 'rails', '3.0.5' - -# Bundle edge Rails instead: -# gem 'rails', :git => 'git://github.com/rails/rails.git' - -gem 'mongoid', '2.0.0.rc.6' -gem 'bson_ext' - -# Use unicorn as the web server -# gem 'unicorn' - -# Deploy with Capistrano -# gem 'capistrano' - -# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+) -# gem 'ruby-debug' -# gem 'ruby-debug19', :require => 'ruby-debug' - -# Bundle the extra gems: -# gem 'bj' -# gem 'nokogiri' -# gem 'sqlite3-ruby', :require => 'sqlite3' -# gem 'aws-s3', :require => 'aws/s3' - -# Bundle gems for the local environment. Make sure to -# put test-only gems in this group so their generators -# and rake tasks are available in development mode: -# group :development, :test do -# gem 'webrat' -# end diff --git a/vendor/built_in_modules/blog/Gemfile.lock b/vendor/built_in_modules/blog/Gemfile.lock deleted file mode 100644 index 039714de..00000000 --- a/vendor/built_in_modules/blog/Gemfile.lock +++ /dev/null @@ -1,83 +0,0 @@ -GEM - remote: http://rubygems.org/ - specs: - abstract (1.0.0) - actionmailer (3.0.5) - actionpack (= 3.0.5) - mail (~> 2.2.15) - actionpack (3.0.5) - activemodel (= 3.0.5) - activesupport (= 3.0.5) - builder (~> 2.1.2) - erubis (~> 2.6.6) - i18n (~> 0.4) - rack (~> 1.2.1) - rack-mount (~> 0.6.13) - rack-test (~> 0.5.7) - tzinfo (~> 0.3.23) - activemodel (3.0.5) - activesupport (= 3.0.5) - builder (~> 2.1.2) - i18n (~> 0.4) - activerecord (3.0.5) - activemodel (= 3.0.5) - activesupport (= 3.0.5) - arel (~> 2.0.2) - tzinfo (~> 0.3.23) - activeresource (3.0.5) - activemodel (= 3.0.5) - activesupport (= 3.0.5) - activesupport (3.0.5) - arel (2.0.9) - bson (1.2.4) - bson_ext (1.2.4) - builder (2.1.2) - erubis (2.6.6) - abstract (>= 1.0.0) - i18n (0.5.0) - mail (2.2.15) - activesupport (>= 2.3.6) - i18n (>= 0.4.0) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.16) - mongo (1.2.4) - bson (>= 1.2.4) - mongoid (2.0.0.rc.6) - activemodel (~> 3.0) - mongo (~> 1.2) - tzinfo (~> 0.3.22) - will_paginate (~> 3.0.pre) - polyglot (0.3.1) - rack (1.2.2) - rack-mount (0.6.13) - rack (>= 1.0.0) - rack-test (0.5.7) - rack (>= 1.0) - rails (3.0.5) - actionmailer (= 3.0.5) - actionpack (= 3.0.5) - activerecord (= 3.0.5) - activeresource (= 3.0.5) - activesupport (= 3.0.5) - bundler (~> 1.0) - railties (= 3.0.5) - railties (3.0.5) - actionpack (= 3.0.5) - activesupport (= 3.0.5) - rake (>= 0.8.7) - thor (~> 0.14.4) - rake (0.8.7) - thor (0.14.6) - treetop (1.4.9) - polyglot (>= 0.3.1) - tzinfo (0.3.25) - will_paginate (3.0.pre2) - -PLATFORMS - ruby - -DEPENDENCIES - bson_ext - mongoid (= 2.0.0.rc.6) - rails (= 3.0.5) diff --git a/vendor/built_in_modules/blog/README b/vendor/built_in_modules/blog/README deleted file mode 100644 index fe7013d5..00000000 --- a/vendor/built_in_modules/blog/README +++ /dev/null @@ -1,256 +0,0 @@ -== Welcome to Rails - -Rails is a web-application framework that includes everything needed to create -database-backed web applications according to the Model-View-Control pattern. - -This pattern splits the view (also called the presentation) into "dumb" -templates that are primarily responsible for inserting pre-built data in between -HTML tags. The model contains the "smart" domain objects (such as Account, -Product, Person, Post) that holds all the business logic and knows how to -persist themselves to a database. The controller handles the incoming requests -(such as Save New Account, Update Product, Show Post) by manipulating the model -and directing data to the view. - -In Rails, the model is handled by what's called an object-relational mapping -layer entitled Active Record. This layer allows you to present the data from -database rows as objects and embellish these data objects with business logic -methods. You can read more about Active Record in -link:files/vendor/rails/activerecord/README.html. - -The controller and view are handled by the Action Pack, which handles both -layers by its two parts: Action View and Action Controller. These two layers -are bundled in a single package due to their heavy interdependence. This is -unlike the relationship between the Active Record and Action Pack that is much -more separate. Each of these packages can be used independently outside of -Rails. You can read more about Action Pack in -link:files/vendor/rails/actionpack/README.html. - - -== Getting Started - -1. At the command prompt, create a new Rails application: - rails new myapp (where myapp is the application name) - -2. Change directory to myapp and start the web server: - cd myapp; rails server (run with --help for options) - -3. Go to http://localhost:3000/ and you'll see: - "Welcome aboard: You're riding Ruby on Rails!" - -4. Follow the guidelines to start developing your application. You can find -the following resources handy: - -* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html -* Ruby on Rails Tutorial Book: http://www.railstutorial.org/ - - -== Debugging Rails - -Sometimes your application goes wrong. Fortunately there are a lot of tools that -will help you debug it and get it back on the rails. - -First area to check is the application log files. Have "tail -f" commands -running on the server.log and development.log. Rails will automatically display -debugging and runtime information to these files. Debugging info will also be -shown in the browser on requests from 127.0.0.1. - -You can also log your own messages directly into the log file from your code -using the Ruby logger class from inside your controllers. Example: - - class WeblogController < ActionController::Base - def destroy - @weblog = Weblog.find(params[:id]) - @weblog.destroy - logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") - end - end - -The result will be a message in your log file along the lines of: - - Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1! - -More information on how to use the logger is at http://www.ruby-doc.org/core/ - -Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are -several books available online as well: - -* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe) -* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) - -These two books will bring you up to speed on the Ruby language and also on -programming in general. - - -== Debugger - -Debugger support is available through the debugger command when you start your -Mongrel or WEBrick server with --debugger. This means that you can break out of -execution at any point in the code, investigate and change the model, and then, -resume execution! You need to install ruby-debug to run the server in debugging -mode. With gems, use sudo gem install ruby-debug. Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find(:all) - debugger - end - end - -So the controller will accept the action, run the first line, then present you -with a IRB prompt in the server window. Here you can do things like: - - >> @posts.inspect - => "[#nil, "body"=>nil, "id"=>"1"}>, - #"Rails", "body"=>"Only ten..", "id"=>"2"}>]" - >> @posts.first.title = "hello from a debugger" - => "hello from a debugger" - -...and even better, you can examine how your runtime objects actually work: - - >> f = @posts.first - => #nil, "body"=>nil, "id"=>"1"}> - >> f. - Display all 152 possibilities? (y or n) - -Finally, when you're ready to resume execution, you can enter "cont". - - -== Console - -The console is a Ruby shell, which allows you to interact with your -application's domain model. Here you'll have all parts of the application -configured, just like it is when the application is running. You can inspect -domain models, change values, and save to the database. Starting the script -without arguments will launch it in the development environment. - -To start the console, run rails console from the application -directory. - -Options: - -* Passing the -s, --sandbox argument will rollback any modifications - made to the database. -* Passing an environment name as an argument will load the corresponding - environment. Example: rails console production. - -To reload your controllers and models after launching the console run -reload! - -More information about irb can be found at: -link:http://www.rubycentral.com/pickaxe/irb.html - - -== dbconsole - -You can go to the command line of your database directly through rails -dbconsole. You would be connected to the database with the credentials -defined in database.yml. Starting the script without arguments will connect you -to the development database. Passing an argument will connect you to a different -database, like rails dbconsole production. Currently works for MySQL, -PostgreSQL and SQLite 3. - -== Description of Contents - -The default directory structure of a generated Ruby on Rails application: - - |-- app - | |-- controllers - | |-- helpers - | |-- mailers - | |-- models - | `-- views - | `-- layouts - |-- config - | |-- environments - | |-- initializers - | `-- locales - |-- db - |-- doc - |-- lib - | `-- tasks - |-- log - |-- public - | |-- images - | |-- javascripts - | `-- stylesheets - |-- script - |-- test - | |-- fixtures - | |-- functional - | |-- integration - | |-- performance - | `-- unit - |-- tmp - | |-- cache - | |-- pids - | |-- sessions - | `-- sockets - `-- vendor - `-- plugins - -app - Holds all the code that's specific to this particular application. - -app/controllers - Holds controllers that should be named like weblogs_controller.rb for - automated URL mapping. All controllers should descend from - ApplicationController which itself descends from ActionController::Base. - -app/models - Holds models that should be named like post.rb. Models descend from - ActiveRecord::Base by default. - -app/views - Holds the template files for the view that should be named like - weblogs/index.html.erb for the WeblogsController#index action. All views use - eRuby syntax by default. - -app/views/layouts - Holds the template files for layouts to be used with views. This models the - common header/footer method of wrapping views. In your views, define a layout - using the layout :default and create a file named default.html.erb. - Inside default.html.erb, call <% yield %> to render the view using this - layout. - -app/helpers - Holds view helpers that should be named like weblogs_helper.rb. These are - generated for you automatically when using generators for controllers. - Helpers can be used to wrap functionality for your views into methods. - -config - Configuration files for the Rails environment, the routing map, the database, - and other dependencies. - -db - Contains the database schema in schema.rb. db/migrate contains all the - sequence of Migrations for your schema. - -doc - This directory is where your application documentation will be stored when - generated using rake doc:app - -lib - Application specific libraries. Basically, any kind of custom code that - doesn't belong under controllers, models, or helpers. This directory is in - the load path. - -public - The directory available for the web server. Contains subdirectories for - images, stylesheets, and javascripts. Also contains the dispatchers and the - default HTML files. This should be set as the DOCUMENT_ROOT of your web - server. - -script - Helper scripts for automation and generation. - -test - Unit and functional tests along with fixtures. When using the rails generate - command, template test files will be generated for you and placed in this - directory. - -vendor - External libraries that the application depends on. Also includes the plugins - subdirectory. If the app has frozen rails, those gems also go here, under - vendor/rails/. This directory is in the load path. diff --git a/vendor/built_in_modules/blog/Rakefile b/vendor/built_in_modules/blog/Rakefile deleted file mode 100644 index 52e48e6f..00000000 --- a/vendor/built_in_modules/blog/Rakefile +++ /dev/null @@ -1,7 +0,0 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - -require File.expand_path('../config/application', __FILE__) -require 'rake' - -Blog::Application.load_tasks diff --git a/vendor/built_in_modules/blog/app/controllers/application_controller.rb b/vendor/built_in_modules/blog/app/controllers/application_controller.rb deleted file mode 100644 index 307a4acd..00000000 --- a/vendor/built_in_modules/blog/app/controllers/application_controller.rb +++ /dev/null @@ -1,23 +0,0 @@ -class ApplicationController < ActionController::Base - protect_from_forgery - before_filter :set_locale - - # Set I18n.locale - def set_locale - # update session if passed - session[:locale] = params[:locale] if params[:locale] - - # set locale based on session or default - begin - # check if locale is valid for non site pages - if !VALID_LOCALES.include?(session[:locale]) - I18n.locale = I18n.default_locale - else - I18n.locale = session[:locale] - end - rescue - I18n.locale = I18n.default_locale - end - end - -end diff --git a/vendor/built_in_modules/blog/app/controllers/panel/blog/comments_controller.rb b/vendor/built_in_modules/blog/app/controllers/panel/blog/comments_controller.rb deleted file mode 100644 index 971f58a6..00000000 --- a/vendor/built_in_modules/blog/app/controllers/panel/blog/comments_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Panel::Blog::CommentsController < ApplicationController - def create - @post = Post.find(params[:post_id]) - @comment = @post.comments.create!(params[:comment]) - redirect_to panel_blog_post_url(@post) - end -end \ No newline at end of file diff --git a/vendor/built_in_modules/blog/app/helpers/application_helper.rb b/vendor/built_in_modules/blog/app/helpers/application_helper.rb deleted file mode 100644 index de6be794..00000000 --- a/vendor/built_in_modules/blog/app/helpers/application_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ApplicationHelper -end diff --git a/vendor/built_in_modules/blog/app/models/comment.rb b/vendor/built_in_modules/blog/app/models/comment.rb deleted file mode 100644 index a85b7a43..00000000 --- a/vendor/built_in_modules/blog/app/models/comment.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Comment - include Mongoid::Document - include Mongoid::Timestamps - field :name, :type => String - field :body, :type => String - embedded_in :post, :inverse_of => :comments -end \ No newline at end of file diff --git a/vendor/built_in_modules/blog/app/models/post.rb b/vendor/built_in_modules/blog/app/models/post.rb deleted file mode 100644 index f60c1c19..00000000 --- a/vendor/built_in_modules/blog/app/models/post.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Post - include Mongoid::Document - include Mongoid::Timestamps - field :title, :type => String - field :body, :type => String - embeds_many :comments - validates_presence_of :title, :body -end \ No newline at end of file diff --git a/vendor/built_in_modules/blog/app/views/layouts/application.html.erb b/vendor/built_in_modules/blog/app/views/layouts/application.html.erb deleted file mode 100644 index e8c46989..00000000 --- a/vendor/built_in_modules/blog/app/views/layouts/application.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - - - - Blog - <%= stylesheet_link_tag :all %> - <%= javascript_include_tag :defaults %> - <%= csrf_meta_tag %> - - - -<%= yield %> - - - diff --git a/vendor/built_in_modules/blog/app/views/panel/blog/posts/edit.html.erb b/vendor/built_in_modules/blog/app/views/panel/blog/posts/edit.html.erb deleted file mode 100644 index 8b2b1f1d..00000000 --- a/vendor/built_in_modules/blog/app/views/panel/blog/posts/edit.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -

<%= t('blog.editing_post') %>

- -<%= form_for @post, :url => panel_blog_post_path(@post) do |f| %> - <%= render :partial => 'form', :locals => {:f => f} %> -<% end %> - -<%= link_to t('blog.show'), panel_blog_post_path(@post) %> | -<%= link_back %> diff --git a/vendor/built_in_modules/blog/app/views/panel/blog/posts/index.html.erb b/vendor/built_in_modules/blog/app/views/panel/blog/posts/index.html.erb deleted file mode 100644 index 346cd133..00000000 --- a/vendor/built_in_modules/blog/app/views/panel/blog/posts/index.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -

<%= t('blog.list_post') %>

- - - - - - - - - - -<% @posts.each do |post| %> - - - - - - - -<% end %> -
<%= t('blog.title') %><%= t('blog.body') %>
<%= post.title %><%= post.body %><%= link_to t('blog.show'), panel_blog_post_path(post) %><%= link_to t('blog.edit'), edit_panel_blog_post_path(post) %><%= link_to t('blog.delete'), panel_blog_post_path(post), :confirm => t('blog.sure?'), :method => :delete %>
- -
- -<%= link_to t('blog.new_post'), new_panel_blog_post_path %> \ No newline at end of file diff --git a/vendor/built_in_modules/blog/app/views/panel/blog/posts/new.html.erb b/vendor/built_in_modules/blog/app/views/panel/blog/posts/new.html.erb deleted file mode 100644 index 5e6eee2f..00000000 --- a/vendor/built_in_modules/blog/app/views/panel/blog/posts/new.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -

<%= t('blog.new_post') %>

-<%= form_for @post, :url => panel_blog_posts_path do |f| %> - <%= render :partial => 'form', :locals => {:f => f} %> -<% end %> - -<%= link_back %> diff --git a/vendor/built_in_modules/blog/config.ru b/vendor/built_in_modules/blog/config.ru deleted file mode 100644 index ddf869e9..00000000 --- a/vendor/built_in_modules/blog/config.ru +++ /dev/null @@ -1,4 +0,0 @@ -# This file is used by Rack-based servers to start the application. - -require ::File.expand_path('../config/environment', __FILE__) -run Blog::Application diff --git a/vendor/built_in_modules/blog/config/application.rb b/vendor/built_in_modules/blog/config/application.rb deleted file mode 100644 index 36550e43..00000000 --- a/vendor/built_in_modules/blog/config/application.rb +++ /dev/null @@ -1,49 +0,0 @@ -require File.expand_path('../boot', __FILE__) - -# Pick the frameworks you want: -# require "active_record/railtie" -require "action_controller/railtie" -require "action_mailer/railtie" -require "active_resource/railtie" -require "rails/test_unit/railtie" - -# If you have a Gemfile, require the gems listed there, including any gems -# you've limited to :test, :development, or :production. -Bundler.require(:default, Rails.env) if defined?(Bundler) - -module Blog - class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - # Custom directories with classes and modules you want to be autoloadable. - # config.autoload_paths += %W(#{config.root}/extras) - - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named. - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - - # Activate observers that should always be running. - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - config.i18n.default_locale = :en - - # JavaScript files you want as :defaults (application.js is always included). - # config.action_view.javascript_expansions[:defaults] = %w(jquery rails) - - # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = "utf-8" - - # Configure sensitive parameters which will be filtered from the log file. - config.filter_parameters += [:password] - end -end - -VALID_LOCALES = ["en", "zh_tw"] \ No newline at end of file diff --git a/vendor/built_in_modules/blog/config/boot.rb b/vendor/built_in_modules/blog/config/boot.rb deleted file mode 100644 index 4489e586..00000000 --- a/vendor/built_in_modules/blog/config/boot.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'rubygems' - -# Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) - -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) diff --git a/vendor/built_in_modules/blog/config/environment.rb b/vendor/built_in_modules/blog/config/environment.rb deleted file mode 100644 index 8f728b7c..00000000 --- a/vendor/built_in_modules/blog/config/environment.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Load the rails application -require File.expand_path('../application', __FILE__) - -# Initialize the rails application -Blog::Application.initialize! diff --git a/vendor/built_in_modules/blog/config/environments/development.rb b/vendor/built_in_modules/blog/config/environments/development.rb deleted file mode 100644 index 4fd91e28..00000000 --- a/vendor/built_in_modules/blog/config/environments/development.rb +++ /dev/null @@ -1,26 +0,0 @@ -Blog::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development - # since you don't have to restart the webserver when you make code changes. - config.cache_classes = false - - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true - - # Show full error reports and disable caching - config.consider_all_requests_local = true - config.action_view.debug_rjs = true - config.action_controller.perform_caching = false - - # Don't care if the mailer can't send - config.action_mailer.raise_delivery_errors = false - - # Print deprecation notices to the Rails logger - config.active_support.deprecation = :log - - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin -end - diff --git a/vendor/built_in_modules/blog/config/environments/production.rb b/vendor/built_in_modules/blog/config/environments/production.rb deleted file mode 100644 index e8d52164..00000000 --- a/vendor/built_in_modules/blog/config/environments/production.rb +++ /dev/null @@ -1,49 +0,0 @@ -Blog::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - - # The production environment is meant for finished, "live" apps. - # Code is not reloaded between requests - config.cache_classes = true - - # Full error reports are disabled and caching is turned on - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Specifies the header that your server uses for sending files - config.action_dispatch.x_sendfile_header = "X-Sendfile" - - # For nginx: - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' - - # If you have no front-end server that supports something like X-Sendfile, - # just comment this out and Rails will serve the files - - # See everything in the log (default is :info) - # config.log_level = :debug - - # Use a different logger for distributed setups - # config.logger = SyslogLogger.new - - # Use a different cache store in production - # config.cache_store = :mem_cache_store - - # Disable Rails's static asset server - # In production, Apache or nginx will already do this - config.serve_static_assets = false - - # Enable serving of images, stylesheets, and javascripts from an asset server - # config.action_controller.asset_host = "http://assets.example.com" - - # Disable delivery errors, bad email addresses will be ignored - # config.action_mailer.raise_delivery_errors = false - - # Enable threaded mode - # config.threadsafe! - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) - config.i18n.fallbacks = true - - # Send deprecation notices to registered listeners - config.active_support.deprecation = :notify -end diff --git a/vendor/built_in_modules/blog/config/environments/test.rb b/vendor/built_in_modules/blog/config/environments/test.rb deleted file mode 100644 index 95b9bc2d..00000000 --- a/vendor/built_in_modules/blog/config/environments/test.rb +++ /dev/null @@ -1,35 +0,0 @@ -Blog::Application.configure do - # Settings specified here will take precedence over those in config/application.rb - - # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that - # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! - config.cache_classes = true - - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true - - # Show full error reports and disable caching - config.consider_all_requests_local = true - config.action_controller.perform_caching = false - - # Raise exceptions instead of rendering exception templates - config.action_dispatch.show_exceptions = false - - # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false - - # Tell Action Mailer not to deliver emails to the real world. - # The :test delivery method accumulates sent emails in the - # ActionMailer::Base.deliveries array. - config.action_mailer.delivery_method = :test - - # Use SQL instead of Active Record's schema dumper when creating the test database. - # This is necessary if your schema can't be completely dumped by the schema dumper, - # like if you have constraints or database-specific column types - # config.active_record.schema_format = :sql - - # Print deprecation notices to the stderr - config.active_support.deprecation = :stderr -end diff --git a/vendor/built_in_modules/blog/config/initializers/backtrace_silencers.rb b/vendor/built_in_modules/blog/config/initializers/backtrace_silencers.rb deleted file mode 100644 index 59385cdf..00000000 --- a/vendor/built_in_modules/blog/config/initializers/backtrace_silencers.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } - -# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. -# Rails.backtrace_cleaner.remove_silencers! diff --git a/vendor/built_in_modules/blog/config/initializers/inflections.rb b/vendor/built_in_modules/blog/config/initializers/inflections.rb deleted file mode 100644 index 9e8b0131..00000000 --- a/vendor/built_in_modules/blog/config/initializers/inflections.rb +++ /dev/null @@ -1,10 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format -# (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' -# inflect.uncountable %w( fish sheep ) -# end diff --git a/vendor/built_in_modules/blog/config/initializers/mime_types.rb b/vendor/built_in_modules/blog/config/initializers/mime_types.rb deleted file mode 100644 index 72aca7e4..00000000 --- a/vendor/built_in_modules/blog/config/initializers/mime_types.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new mime types for use in respond_to blocks: -# Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/vendor/built_in_modules/blog/config/initializers/secret_token.rb b/vendor/built_in_modules/blog/config/initializers/secret_token.rb deleted file mode 100644 index 3c7ca823..00000000 --- a/vendor/built_in_modules/blog/config/initializers/secret_token.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -Rails.application.config.secret_token = '1ab256be6fbbf61d656ffefa1ad203ac5f3a65d9e65cd054b772558e3c0cc4e4db462f66dad09e8d62f21aa05c55c2453edb28dcead1b09625013b4417ba038c' diff --git a/vendor/built_in_modules/blog/config/initializers/session_store.rb b/vendor/built_in_modules/blog/config/initializers/session_store.rb deleted file mode 100644 index 2caea820..00000000 --- a/vendor/built_in_modules/blog/config/initializers/session_store.rb +++ /dev/null @@ -1,8 +0,0 @@ -# Be sure to restart your server when you modify this file. - -Rails.application.config.session_store :cookie_store, :key => '_blog_session' - -# Use the database for sessions instead of the cookie-based default, -# which shouldn't be used to store highly confidential information -# (create the session table with "rails generate session_migration") -# Blog::Application.config.session_store :active_record_store diff --git a/vendor/built_in_modules/blog/config/locales/en.yml b/vendor/built_in_modules/blog/config/locales/en.yml deleted file mode 100644 index 92af0896..00000000 --- a/vendor/built_in_modules/blog/config/locales/en.yml +++ /dev/null @@ -1,18 +0,0 @@ -# Sample localization file for English. Add more files in this directory for other locales. -# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. - -en: - blog: - body: Body - comments: Comments - create_post_success: Post was successfully created. - delete: Delete - edit: Edit - editing_post: Editing post - list_post: Listing posts - new_post: New post - show: Show - sure?: Are you sure? - title: Title - update_post_success: Post was successfully updated. - diff --git a/vendor/built_in_modules/blog/config/locales/zh_tw.yml b/vendor/built_in_modules/blog/config/locales/zh_tw.yml deleted file mode 100644 index d3b32272..00000000 --- a/vendor/built_in_modules/blog/config/locales/zh_tw.yml +++ /dev/null @@ -1,10 +0,0 @@ -zh_tw: - blog: - create_post_success: 郵政已成功創建。 - delete: 刪除 - edit: 編輯 - list_post: - new_post: 新員額 - show: 顯示 - sure?: 你肯定嗎? - update_post_success: 郵政已成功更新。 \ No newline at end of file diff --git a/vendor/built_in_modules/blog/config/mongoid.yml b/vendor/built_in_modules/blog/config/mongoid.yml deleted file mode 100644 index 96bf0ab7..00000000 --- a/vendor/built_in_modules/blog/config/mongoid.yml +++ /dev/null @@ -1,23 +0,0 @@ -defaults: &defaults - host: localhost - # slaves: - # - host: slave1.local - # port: 27018 - # - host: slave2.local - # port: 27019 - -development: - <<: *defaults - database: blog_dev - -test: - <<: *defaults - database: blog_test - -# set these environment variables on your prod server -production: - host: <%= ENV['MONGOID_HOST'] %> - port: <%= ENV['MONGOID_PORT'] %> - username: <%= ENV['MONGOID_USERNAME'] %> - password: <%= ENV['MONGOID_PASSWORD'] %> - database: <%= ENV['MONGOID_DATABASE'] %> \ No newline at end of file diff --git a/vendor/built_in_modules/blog/config/routes.rb b/vendor/built_in_modules/blog/config/routes.rb deleted file mode 100644 index d4605f40..00000000 --- a/vendor/built_in_modules/blog/config/routes.rb +++ /dev/null @@ -1,66 +0,0 @@ -Rails.application.routes.draw do - - namespace :panel do - namespace :blog do - resources :posts - resources :comments - end - end - - # The priority is based upon order of creation: - # first created -> highest priority. - - # Sample of regular route: - # match 'products/:id' => 'catalog#view' - # Keep in mind you can assign values other than :controller and :action - - # Sample of named route: - # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase - # This route can be invoked with purchase_url(:id => product.id) - - # Sample resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Sample resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Sample resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Sample resource route with more complex sub-resources - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', :on => :collection - # end - # end - - # Sample resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end - - # You can have the root of your site routed with "root" - # just remember to delete public/index.html. - # root :to => "welcome#index" - - # See how all your routes lay out with "rake routes" - - # This is a legacy wild controller route that's not recommended for RESTful applications. - # Note: This route will make all actions in every controller accessible via GET requests. - # match ':controller(/:action(/:id(.:format)))' -end diff --git a/vendor/built_in_modules/blog/db/seeds.rb b/vendor/built_in_modules/blog/db/seeds.rb deleted file mode 100644 index 664d8c74..00000000 --- a/vendor/built_in_modules/blog/db/seeds.rb +++ /dev/null @@ -1,7 +0,0 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) -# Mayor.create(:name => 'Daley', :city => cities.first) diff --git a/vendor/built_in_modules/blog/doc/README_FOR_APP b/vendor/built_in_modules/blog/doc/README_FOR_APP deleted file mode 100644 index fe41f5cc..00000000 --- a/vendor/built_in_modules/blog/doc/README_FOR_APP +++ /dev/null @@ -1,2 +0,0 @@ -Use this README file to introduce your application and point to useful places in the API for learning more. -Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries. diff --git a/vendor/built_in_modules/blog/lib/tasks/.gitkeep b/vendor/built_in_modules/blog/lib/tasks/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/built_in_modules/blog/public/404.html b/vendor/built_in_modules/blog/public/404.html deleted file mode 100644 index 9a48320a..00000000 --- a/vendor/built_in_modules/blog/public/404.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - The page you were looking for doesn't exist (404) - - - - - -
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

-
- - diff --git a/vendor/built_in_modules/blog/public/422.html b/vendor/built_in_modules/blog/public/422.html deleted file mode 100644 index 83660ab1..00000000 --- a/vendor/built_in_modules/blog/public/422.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - The change you wanted was rejected (422) - - - - - -
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

-
- - diff --git a/vendor/built_in_modules/blog/public/500.html b/vendor/built_in_modules/blog/public/500.html deleted file mode 100644 index b80307fc..00000000 --- a/vendor/built_in_modules/blog/public/500.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - We're sorry, but something went wrong (500) - - - - - -
-

We're sorry, but something went wrong.

-

We've been notified about this issue and we'll take a look at it shortly.

-
- - diff --git a/vendor/built_in_modules/blog/public/favicon.ico b/vendor/built_in_modules/blog/public/favicon.ico deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/built_in_modules/blog/public/images/rails.png b/vendor/built_in_modules/blog/public/images/rails.png deleted file mode 100644 index d5edc04e65f555e3ba4dcdaad39dc352e75b575e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6646 zcmVpVcQya!6@Dsmj@#jv7C*qh zIhOJ6_K0n?*d`*T7TDuW-}m`9Kz3~>+7`DUkbAraU%yi+R{N~~XA2B%zt-4=tLimUer9!2M~N{G5bftFij_O&)a zsHnOppFIzebQ`RA0$!yUM-lg#*o@_O2wf422iLnM6cU(ktYU8#;*G!QGhIy9+ZfzKjLuZo%@a z-i@9A`X%J{^;2q&ZHY3C(B%gqCPW!8{9C0PMcNZccefK){s|V5-xxtHQc@uf>XqhD z7#N^siWqetgq29aX>G^olMf=bbRF6@Y(}zYxw6o!9WBdG1unP}<(V;zKlcR2p86fq zYjaqB^;Ycq>Wy@5T1xOzG3tucG3e%nPvajaN{CrFbnzv^9&K3$NrDm*eQe4`BGQ2bI;dFEwyt>hK%X!L6)82aOZp zsrGcJ#7PoX7)s|~t6is?FfX*7vWdREi58tiY4S)t6u*|kv?J)d_$r+CH#eZ?Ef+I_ z(eVlX8dh~4QP?o*E`_MgaNFIKj*rtN(0Raj3ECjSXcWfd#27NYs&~?t`QZFT}!Zaf=ldZIhi}LhQlqLo+o5(Pvui&{7PD__^53f9j>HW`Q z_V8X5j~$|GP9qXu0C#!@RX2}lXD35@3N5{BkUi%jtaPQ*H6OX2zIz4QPuqmTv3`vG{zc>l3t0B9E75h< z8&twGh%dp7WPNI+tRl%#gf2}Epg8st+~O4GjtwJsXfN;EjAmyr6z5dnaFU(;IV~QK zW62fogF~zA``(Q>_SmD!izc6Y4zq*97|NAPHp1j5X7Op2%;GLYm>^HEMyObo6s7l) zE3n|aOHi5~B84!}b^b*-aL2E)>OEJX_tJ~t<#VJ?bT?lDwyDB&5SZ$_1aUhmAY}#* zs@V1I+c5md9%R-o#_DUfqVtRk>59{+Opd5Yu%dAU#VQW}^m}x-30ftBx#527{^pI4 z6l2C6C7QBG$~NLYb3rVdLD#Z{+SleOp`(Lg5J}`kxdTHe(nV5BdpLrD=l|)e$gEqA zwI6vuX-PFCtcDIH>bGY2dwq&^tf+&R?)nY-@7_j%4CMRAF}C9w%p86W<2!aSY$p+k zrkFtG=cGo38RnrG28;?PNk%7a@faaXq&MS*&?1Z`7Ojw7(#>}ZG4nMAs3VXxfdW>i zY4VX02c5;f7jDPY_7@Oa)CHH}cH<3y#}_!nng^W+h1e-RL*YFYOteC@h?BtJZ+?sE zy)P5^8Mregx{nQaw1NY-|3>{Z)|0`?zc?G2-acYiSU`tj#sSGfm7k86ZQ0SQgPevcklHxM9<~4yW zR796sisf1|!#{Z=e^)0;_8iUhL8g(;j$l=02FTPZ(dZV@s#aQ`DHkLM6=YsbE4iQ!b#*374l0Jw5;jD%J;vQayq=nD8-kHI~f9Ux|32SJUM`> zGp2UGK*4t?cRKi!2he`zI#j0f${I#f-jeT?u_C7S4WsA0)ryi-1L0(@%pa^&g5x=e z=KW9+Nn(=)1T&S8g_ug%dgk*~l2O-$r9#zEGBdQsweO%t*6F4c8JC36JtTizCyy+E4h%G(+ z5>y$%0txMuQ$e~wjFgN(xrAndHQo`Za+K*?gUVDTBV&Ap^}|{w#CIq{DRe}+l@(Ec zCCV6f_?dY_{+f{}6XGn!pL_up?}@>KijT^$w#Lb6iHW&^8RP~g6y=vZBXx~B9nI^i zGexaPjcd(%)zGw!DG_dDwh-7x6+ST#R^${iz_M$uM!da8SxgB_;Z0G%Y*HpvLjKw; zX=ir7i1O$-T|*TBoH$dlW+TLf5j5sep^DlDtkox;Kg{Q%EXWedJq@J@%VAcK)j3y1 zShM!CS#qax;D@RND%2t3W6kv+#Ky0F9<3YKDbV^XJ=^$s(Vtza8V72YY)577nnldI zHMA0PUo!F3j(ubV*CM@PiK<^|RM2(DuCbG7`W}Rg(xdYC>C~ z;1KJGLN&$cRxSZunjXcntykmpFJ7;dk>shY(DdK&3K_JDJ6R%D`e~6Qv67@Rwu+q9 z*|NG{r}4F8f{Dfzt0+cZMd$fvlX3Q`dzM46@r?ISxr;9gBTG2rmfiGOD*#c*3f)cc zF+PFZobY$-^}J8 z%n=h4;x2}cP!@SiVd!v;^Wwo0(N??-ygDr7gG^NKxDjSo{5T{?$|Qo5;8V!~D6O;F*I zuY!gd@+2j_8Rn=UWDa#*4E2auWoGYDddMW7t0=yuC(xLWky?vLimM~!$3fgu!dR>p z?L?!8z>6v$|MsLb&dU?ob)Zd!B)!a*Z2eTE7 zKCzP&e}XO>CT%=o(v+WUY`Az*`9inbTG& z_9_*oQKw;sc8{ipoBC`S4Tb7a%tUE)1fE+~ib$;|(`|4QbXc2>VzFi%1nX%ti;^s3~NIL0R}!!a{0A zyCRp0F7Y&vcP&3`&Dzv5!&#h}F2R-h&QhIfq*ts&qO13{_CP}1*sLz!hI9VoTSzTu zok5pV0+~jrGymE~{TgbS#nN5+*rF7ij)cnSLQw0Ltc70zmk|O!O(kM<3zw-sUvkx~ z2`y+{xAwKSa-0}n7{$I@Zop7CWy%_xIeN1e-7&OjQ6vZZPbZ^3_ z(~=;ZSP98S2oB#35b1~_x`2gWiPdIVddEf`AD9<@c_s)TM;3J$T_l?pr{<7PTgdiy zBc5IGx)g~n=s+Z$RzYCmv8PlJu%gkh^;%mTGMc)UwRINVD~K;`Rl!5@hhGg;y>5qj zq|u-Yf0q_~Y+Mbivkkfa0nAOzB1acnytogsj_m7FB(-FjihMek#GAU4M!iXCgdK8a zjoKm?*|iz7;dHm4$^hh(`Ufl>yb>$hjIA-;>{>C}G0Di%bGvUsJkfLAV|xq32c>RqJqTBJ3Dx zYC;*Dt|S$b6)aCJFnK(Eey$M1DpVV~_MIhwK> zygo(jWC|_IRw|456`roEyXtkNLWNAt-4N1qyN$I@DvBzt;e|?g<*HK1%~cq|^u*}C zmMrwh>{QAq?Ar~4l^DqT%SQ)w)FA(#7#u+N;>E975rYML>)LgE`2<7nN=C1pC{IkV zVw}_&v6j&S?QVh*)wF3#XmE@0($^BVl1969csLKUBNer{suVd!a~B!0MxWY?=(GD6 zy$G&ERFR#i6G4=2F?R4}Mz3B?3tnpoX3)qFF2sh9-Jn*e%9F>i{WG7$_~XyOO2!+@ z6k+38KyD@-0=uee54D0!Z1@B^ilj~StchdOn(*qvg~s5QJpWGc!6U^Aj!xt-HZn_V zS%|fyQ5YS@EP2lBIodXCLjG_+a)%En+7jzngk@J>6D~^xbxKkvf-R0-c%mX+o{?&j zZZ%RxFeav8Y0gkwtdtrwUb-i0Egd2C=ADu%w5VV-hNJvl)GZ?M;y$!?b=S+wKRK7Q zcOjPT!p<*#8m;TsBih=@Xc&c)?Vy`Ys>IvK@|1%N+M6J-^RCRaZcPP2eQh9DEGZr+ z?8B~wF14mk4Xkuen{wY^CWwS1PI<8gikY*)3?RSo5l8es4*J z43k_BIwc}of=6Pfs%xIxlMDGOJN zvl!a>G)52XMqA%fbgkZi%)%bN*ZzZw2!rn4@+J)2eK#kWuEW{)W~-`y1vhA5-7p%R z&f5N!a9f8cK1Xa=O}=9{wg%}Ur^+8Y(!UCeqw>%wj@|bYHD-bZO~mk3L$9_^MmF3G zvCiK^e@q6G?tHkM8%GqsBMZaB20W$UEt_5r~jc#WlR>Bv{6W>A=!#InoY zLOd04@Rz?*7PpW8u|+}bt`?+Z(GsX{Br4A2$ZZ(26Degmr9`O=t2KgHTL*==R3xcP z&Y(J7hC@6_x8zVz!CX3l4Xtss6i7r#E6kXMNN1~>9KTRzewfp))ij%)SBBl0fZdYP zd!zzQD5u8yk-u|41|Rqz7_tCFUMThZJVj)yQf6^Cwtn|Ew6cm5J|u1Bq>MWX-AfB&NE;C z62@=-0le`E6-CurMKjoIy)BuUmhMGJb}pPx!@GLWMT+wH2R?wA=MEy)o57~feFp8P zY@YXAyt4<1FD<|iw{FGQu~GEI<4C64)V*QiVk+VzOV^9GWf4ir#oYgHJz!wq>iZV#_6@_{)&lum)4x z_Of*CLVQ7wdT#XT-(h0qH%mcIF7yzMIvvTN3bPceK>PpJi(=3Nny zbSn}p$dGKQUlX&-t~RR)#F7I<8NCD^yke(vdf#4^aAh}M-{tS9-&^tC4`KU_pToXy z+|K8sx}a)Kh{h{;*V1#hs1xB%(?j>)g~`Wv(9F)f=Qn)(daVB7hZtcp^#LrEr1T1J zZSJ*lVyVVjhy)mkex9Whn=EinKDHe@KlfQI-Fl7M?-c~HnW0;C;+MbUY8?FToy;A+ zs&Nc7VZ=Of+e!G6s#+S5WBU)kgQq_I1@!uH74GJ-+O|%0HXm9Mqlvp|j%0`T>fr9^ zK;qo>XdwZW<>%tTA+<(1^6(>=-2N;hRgBnjvEjN;VbKMbFg--WrGy|XESoH1p|M4` z86(gC^vB4qScASZ&cdpT{~QDN-jC|GJ(RYoW1VW4!SSn- zhQds9&RBKn6M&GVK_Aayt(Hekbnw=tr>f z^o@v9_*iQO1*zeOrts9Q-$pc@!StS&kz$cF`s@pM`rmJXTP&h5G)A74!0e%ZJbl}( zssI|_!%~_hZFypv*S^JE5N&Kvmx7KiG<|fGMO=WrH+@Yhuj+KwiS#l4>@%2nl zS)mDikfmokO4q2A)hRVZBq2-5q&XC>%HOLkOYxZ66(s86?=0s4z5xbiOV)}L-&6b)h6(~CIaR#JNw~46+WBiU7IhB zq!NuR4!TsYnyBg>@G=Ib*cMq^k<}AMpCeYEf&dzfiGI-wOQ7hb+nA zkN7_){y&c3xC0 AQ~&?~ diff --git a/vendor/built_in_modules/blog/public/index.html b/vendor/built_in_modules/blog/public/index.html deleted file mode 100644 index 75d5edd0..00000000 --- a/vendor/built_in_modules/blog/public/index.html +++ /dev/null @@ -1,239 +0,0 @@ - - - - Ruby on Rails: Welcome aboard - - - - -
- - -
- - - - -
-

Getting started

-

Here’s how to get rolling:

- -
    -
  1. -

    Use rails generate to create your models and controllers

    -

    To see all available options, run it without parameters.

    -
  2. - -
  3. -

    Set up a default route and remove or rename this file

    -

    Routes are set up in config/routes.rb.

    -
  4. - -
  5. -

    Create your database

    -

    Run rake db:migrate to create your database. If you're not using SQLite (the default), edit config/database.yml with your username and password.

    -
  6. -
-
-
- - -
- - diff --git a/vendor/built_in_modules/blog/public/javascripts/application.js b/vendor/built_in_modules/blog/public/javascripts/application.js deleted file mode 100644 index fe457769..00000000 --- a/vendor/built_in_modules/blog/public/javascripts/application.js +++ /dev/null @@ -1,2 +0,0 @@ -// Place your application-specific JavaScript functions and classes here -// This file is automatically included by javascript_include_tag :defaults diff --git a/vendor/built_in_modules/blog/public/javascripts/controls.js b/vendor/built_in_modules/blog/public/javascripts/controls.js deleted file mode 100644 index 7392fb66..00000000 --- a/vendor/built_in_modules/blog/public/javascripts/controls.js +++ /dev/null @@ -1,965 +0,0 @@ -// script.aculo.us controls.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009 - -// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// (c) 2005-2009 Ivan Krstic (http://blogs.law.harvard.edu/ivan) -// (c) 2005-2009 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 = Class.create({ - baseInitialize: function(element, update, options) { - element = $(element); - this.element = element; - this.update = $(update); - this.hasFocus = false; - this.changed = false; - this.active = false; - this.index = 0; - this.entryCount = 0; - this.oldElementValue = this.element.value; - - 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); - // Force carriage returns as token delimiters anyway - if (!this.options.tokens.include('\n')) - this.options.tokens.push('\n'); - - 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, 'keydown', this.onKeyPress.bindAsEventListener(this)); - }, - - show: function() { - if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update); - if(!this.iefix && - (Prototype.Browser.IE) && - (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(); - Event.stop(event); - return; - case Event.KEY_DOWN: - this.markNext(); - this.render(); - Event.stop(event); - return; - } - else - if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN || - (Prototype.Browser.WebKit > 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 = $(selectedElement).select('.' + this.options.select) || []; - if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select); - } else - value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal'); - - var bounds = this.getTokenBounds(); - if (bounds[0] != -1) { - var newValue = this.element.value.substr(0, bounds[0]); - var whitespace = this.element.value.substr(bounds[0]).match(/^\s+/); - if (whitespace) - newValue += whitespace[0]; - this.element.value = newValue + value + this.element.value.substr(bounds[1]); - } else { - this.element.value = value; - } - this.oldElementValue = this.element.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; - this.tokenBounds = null; - if(this.getToken().length>=this.options.minChars) { - this.getUpdatedChoices(); - } else { - this.active = false; - this.hide(); - } - this.oldElementValue = this.element.value; - }, - - getToken: function() { - var bounds = this.getTokenBounds(); - return this.element.value.substring(bounds[0], bounds[1]).strip(); - }, - - getTokenBounds: function() { - if (null != this.tokenBounds) return this.tokenBounds; - var value = this.element.value; - if (value.strip().empty()) return [-1, 0]; - var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue); - var offset = (diff == this.oldElementValue.length ? 1 : 0); - var prevTokenPos = -1, nextTokenPos = value.length; - var tp; - for (var index = 0, l = this.options.tokens.length; index < l; ++index) { - tp = value.lastIndexOf(this.options.tokens[index], diff + offset - 1); - if (tp > prevTokenPos) prevTokenPos = tp; - tp = value.indexOf(this.options.tokens[index], diff + offset); - if (-1 != tp && tp < nextTokenPos) nextTokenPos = tp; - } - return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]); - } -}); - -Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) { - var boundary = Math.min(newS.length, oldS.length); - for (var index = 0; index < boundary; ++index) - if (newS[index] != oldS[index]) - return index; - return boundary; -}; - -Ajax.Autocompleter = Class.create(Autocompleter.Base, { - 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() { - this.startIndicator(); - - var 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.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 "
      " + ret.join('') + "
    "; - } - }, options || { }); - } -}); - -// AJAX in-place editor and collection editor -// Full rewrite by Christophe Porteneuve (April 2007). - -// 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({ - initialize: function(element, url, options) { - this.url = url; - this.element = element = $(element); - this.prepareOptions(); - this._controls = { }; - arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!! - Object.extend(this.options, options || { }); - if (!this.options.formId && this.element.id) { - this.options.formId = this.element.id + '-inplaceeditor'; - if ($(this.options.formId)) - this.options.formId = ''; - } - if (this.options.externalControl) - this.options.externalControl = $(this.options.externalControl); - if (!this.options.externalControl) - this.options.externalControlOnly = false; - this._originalBackground = this.element.getStyle('background-color') || 'transparent'; - this.element.title = this.options.clickToEditText; - this._boundCancelHandler = this.handleFormCancellation.bind(this); - this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this); - this._boundFailureHandler = this.handleAJAXFailure.bind(this); - this._boundSubmitHandler = this.handleFormSubmission.bind(this); - this._boundWrapperHandler = this.wrapUp.bind(this); - this.registerListeners(); - }, - checkForEscapeOrReturn: function(e) { - if (!this._editing || e.ctrlKey || e.altKey || e.shiftKey) return; - if (Event.KEY_ESC == e.keyCode) - this.handleFormCancellation(e); - else if (Event.KEY_RETURN == e.keyCode) - this.handleFormSubmission(e); - }, - createControl: function(mode, handler, extraClasses) { - var control = this.options[mode + 'Control']; - var text = this.options[mode + 'Text']; - if ('button' == control) { - var btn = document.createElement('input'); - btn.type = 'submit'; - btn.value = text; - btn.className = 'editor_' + mode + '_button'; - if ('cancel' == mode) - btn.onclick = this._boundCancelHandler; - this._form.appendChild(btn); - this._controls[mode] = btn; - } else if ('link' == control) { - var link = document.createElement('a'); - link.href = '#'; - link.appendChild(document.createTextNode(text)); - link.onclick = 'cancel' == mode ? this._boundCancelHandler : this._boundSubmitHandler; - link.className = 'editor_' + mode + '_link'; - if (extraClasses) - link.className += ' ' + extraClasses; - this._form.appendChild(link); - this._controls[mode] = link; - } - }, - createEditField: function() { - var text = (this.options.loadTextURL ? this.options.loadingText : this.getText()); - var fld; - if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) { - fld = document.createElement('input'); - fld.type = 'text'; - var size = this.options.size || this.options.cols || 0; - if (0 < size) fld.size = size; - } else { - fld = document.createElement('textarea'); - fld.rows = (1 >= this.options.rows ? this.options.autoRows : this.options.rows); - fld.cols = this.options.cols || 40; - } - fld.name = this.options.paramName; - fld.value = text; // No HTML breaks conversion anymore - fld.className = 'editor_field'; - if (this.options.submitOnBlur) - fld.onblur = this._boundSubmitHandler; - this._controls.editor = fld; - if (this.options.loadTextURL) - this.loadExternalText(); - this._form.appendChild(this._controls.editor); - }, - createForm: function() { - var ipe = this; - function addText(mode, condition) { - var text = ipe.options['text' + mode + 'Controls']; - if (!text || condition === false) return; - ipe._form.appendChild(document.createTextNode(text)); - }; - this._form = $(document.createElement('form')); - this._form.id = this.options.formId; - this._form.addClassName(this.options.formClassName); - this._form.onsubmit = this._boundSubmitHandler; - this.createEditField(); - if ('textarea' == this._controls.editor.tagName.toLowerCase()) - this._form.appendChild(document.createElement('br')); - if (this.options.onFormCustomization) - this.options.onFormCustomization(this, this._form); - addText('Before', this.options.okControl || this.options.cancelControl); - this.createControl('ok', this._boundSubmitHandler); - addText('Between', this.options.okControl && this.options.cancelControl); - this.createControl('cancel', this._boundCancelHandler, 'editor_cancel'); - addText('After', this.options.okControl || this.options.cancelControl); - }, - destroy: function() { - if (this._oldInnerHTML) - this.element.innerHTML = this._oldInnerHTML; - this.leaveEditMode(); - this.unregisterListeners(); - }, - enterEditMode: function(e) { - if (this._saving || this._editing) return; - this._editing = true; - this.triggerCallback('onEnterEditMode'); - if (this.options.externalControl) - this.options.externalControl.hide(); - this.element.hide(); - this.createForm(); - this.element.parentNode.insertBefore(this._form, this.element); - if (!this.options.loadTextURL) - this.postProcessEditField(); - if (e) Event.stop(e); - }, - enterHover: function(e) { - if (this.options.hoverClassName) - this.element.addClassName(this.options.hoverClassName); - if (this._saving) return; - this.triggerCallback('onEnterHover'); - }, - getText: function() { - return this.element.innerHTML.unescapeHTML(); - }, - handleAJAXFailure: function(transport) { - this.triggerCallback('onFailure', transport); - if (this._oldInnerHTML) { - this.element.innerHTML = this._oldInnerHTML; - this._oldInnerHTML = null; - } - }, - handleFormCancellation: function(e) { - this.wrapUp(); - if (e) Event.stop(e); - }, - handleFormSubmission: function(e) { - var form = this._form; - var value = $F(this._controls.editor); - this.prepareSubmission(); - var params = this.options.callback(form, value) || ''; - if (Object.isString(params)) - params = params.toQueryParams(); - params.editorId = this.element.id; - if (this.options.htmlResponse) { - var options = Object.extend({ evalScripts: true }, this.options.ajaxOptions); - Object.extend(options, { - parameters: params, - onComplete: this._boundWrapperHandler, - onFailure: this._boundFailureHandler - }); - new Ajax.Updater({ success: this.element }, this.url, options); - } else { - var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); - Object.extend(options, { - parameters: params, - onComplete: this._boundWrapperHandler, - onFailure: this._boundFailureHandler - }); - new Ajax.Request(this.url, options); - } - if (e) Event.stop(e); - }, - leaveEditMode: function() { - this.element.removeClassName(this.options.savingClassName); - this.removeForm(); - this.leaveHover(); - this.element.style.backgroundColor = this._originalBackground; - this.element.show(); - if (this.options.externalControl) - this.options.externalControl.show(); - this._saving = false; - this._editing = false; - this._oldInnerHTML = null; - this.triggerCallback('onLeaveEditMode'); - }, - leaveHover: function(e) { - if (this.options.hoverClassName) - this.element.removeClassName(this.options.hoverClassName); - if (this._saving) return; - this.triggerCallback('onLeaveHover'); - }, - loadExternalText: function() { - this._form.addClassName(this.options.loadingClassName); - this._controls.editor.disabled = true; - var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); - Object.extend(options, { - parameters: 'editorId=' + encodeURIComponent(this.element.id), - onComplete: Prototype.emptyFunction, - onSuccess: function(transport) { - this._form.removeClassName(this.options.loadingClassName); - var text = transport.responseText; - if (this.options.stripLoadedTextTags) - text = text.stripTags(); - this._controls.editor.value = text; - this._controls.editor.disabled = false; - this.postProcessEditField(); - }.bind(this), - onFailure: this._boundFailureHandler - }); - new Ajax.Request(this.options.loadTextURL, options); - }, - postProcessEditField: function() { - var fpc = this.options.fieldPostCreation; - if (fpc) - $(this._controls.editor)['focus' == fpc ? 'focus' : 'activate'](); - }, - prepareOptions: function() { - this.options = Object.clone(Ajax.InPlaceEditor.DefaultOptions); - Object.extend(this.options, Ajax.InPlaceEditor.DefaultCallbacks); - [this._extraDefaultOptions].flatten().compact().each(function(defs) { - Object.extend(this.options, defs); - }.bind(this)); - }, - prepareSubmission: function() { - this._saving = true; - this.removeForm(); - this.leaveHover(); - this.showSaving(); - }, - registerListeners: function() { - this._listeners = { }; - var listener; - $H(Ajax.InPlaceEditor.Listeners).each(function(pair) { - listener = this[pair.value].bind(this); - this._listeners[pair.key] = listener; - if (!this.options.externalControlOnly) - this.element.observe(pair.key, listener); - if (this.options.externalControl) - this.options.externalControl.observe(pair.key, listener); - }.bind(this)); - }, - removeForm: function() { - if (!this._form) return; - this._form.remove(); - this._form = null; - this._controls = { }; - }, - showSaving: function() { - this._oldInnerHTML = this.element.innerHTML; - this.element.innerHTML = this.options.savingText; - this.element.addClassName(this.options.savingClassName); - this.element.style.backgroundColor = this._originalBackground; - this.element.show(); - }, - triggerCallback: function(cbName, arg) { - if ('function' == typeof this.options[cbName]) { - this.options[cbName](this, arg); - } - }, - unregisterListeners: function() { - $H(this._listeners).each(function(pair) { - if (!this.options.externalControlOnly) - this.element.stopObserving(pair.key, pair.value); - if (this.options.externalControl) - this.options.externalControl.stopObserving(pair.key, pair.value); - }.bind(this)); - }, - wrapUp: function(transport) { - this.leaveEditMode(); - // Can't use triggerCallback due to backward compatibility: requires - // binding + direct element - this._boundComplete(transport, this.element); - } -}); - -Object.extend(Ajax.InPlaceEditor.prototype, { - dispose: Ajax.InPlaceEditor.prototype.destroy -}); - -Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, { - initialize: function($super, element, url, options) { - this._extraDefaultOptions = Ajax.InPlaceCollectionEditor.DefaultOptions; - $super(element, url, options); - }, - - createEditField: function() { - var list = document.createElement('select'); - list.name = this.options.paramName; - list.size = 1; - this._controls.editor = list; - this._collection = this.options.collection || []; - if (this.options.loadCollectionURL) - this.loadCollection(); - else - this.checkForExternalText(); - this._form.appendChild(this._controls.editor); - }, - - loadCollection: function() { - this._form.addClassName(this.options.loadingClassName); - this.showLoadingText(this.options.loadingCollectionText); - var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); - Object.extend(options, { - parameters: 'editorId=' + encodeURIComponent(this.element.id), - onComplete: Prototype.emptyFunction, - onSuccess: function(transport) { - var js = transport.responseText.strip(); - if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check - throw('Server returned an invalid collection representation.'); - this._collection = eval(js); - this.checkForExternalText(); - }.bind(this), - onFailure: this.onFailure - }); - new Ajax.Request(this.options.loadCollectionURL, options); - }, - - showLoadingText: function(text) { - this._controls.editor.disabled = true; - var tempOption = this._controls.editor.firstChild; - if (!tempOption) { - tempOption = document.createElement('option'); - tempOption.value = ''; - this._controls.editor.appendChild(tempOption); - tempOption.selected = true; - } - tempOption.update((text || '').stripScripts().stripTags()); - }, - - checkForExternalText: function() { - this._text = this.getText(); - if (this.options.loadTextURL) - this.loadExternalText(); - else - this.buildOptionList(); - }, - - loadExternalText: function() { - this.showLoadingText(this.options.loadingText); - var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); - Object.extend(options, { - parameters: 'editorId=' + encodeURIComponent(this.element.id), - onComplete: Prototype.emptyFunction, - onSuccess: function(transport) { - this._text = transport.responseText.strip(); - this.buildOptionList(); - }.bind(this), - onFailure: this.onFailure - }); - new Ajax.Request(this.options.loadTextURL, options); - }, - - buildOptionList: function() { - this._form.removeClassName(this.options.loadingClassName); - this._collection = this._collection.map(function(entry) { - return 2 === entry.length ? entry : [entry, entry].flatten(); - }); - var marker = ('value' in this.options) ? this.options.value : this._text; - var textFound = this._collection.any(function(entry) { - return entry[0] == marker; - }.bind(this)); - this._controls.editor.update(''); - var option; - this._collection.each(function(entry, index) { - option = document.createElement('option'); - option.value = entry[0]; - option.selected = textFound ? entry[0] == marker : 0 == index; - option.appendChild(document.createTextNode(entry[1])); - this._controls.editor.appendChild(option); - }.bind(this)); - this._controls.editor.disabled = false; - Field.scrollFreeActivate(this._controls.editor); - } -}); - -//**** DEPRECATION LAYER FOR InPlace[Collection]Editor! **** -//**** This only exists for a while, in order to let **** -//**** users adapt to the new API. Read up on the new **** -//**** API and convert your code to it ASAP! **** - -Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) { - if (!options) return; - function fallback(name, expr) { - if (name in options || expr === undefined) return; - options[name] = expr; - }; - fallback('cancelControl', (options.cancelLink ? 'link' : (options.cancelButton ? 'button' : - options.cancelLink == options.cancelButton == false ? false : undefined))); - fallback('okControl', (options.okLink ? 'link' : (options.okButton ? 'button' : - options.okLink == options.okButton == false ? false : undefined))); - fallback('highlightColor', options.highlightcolor); - fallback('highlightEndColor', options.highlightendcolor); -}; - -Object.extend(Ajax.InPlaceEditor, { - DefaultOptions: { - ajaxOptions: { }, - autoRows: 3, // Use when multi-line w/ rows == 1 - cancelControl: 'link', // 'link'|'button'|false - cancelText: 'cancel', - clickToEditText: 'Click to edit', - externalControl: null, // id|elt - externalControlOnly: false, - fieldPostCreation: 'activate', // 'activate'|'focus'|false - formClassName: 'inplaceeditor-form', - formId: null, // id|elt - highlightColor: '#ffff99', - highlightEndColor: '#ffffff', - hoverClassName: '', - htmlResponse: true, - loadingClassName: 'inplaceeditor-loading', - loadingText: 'Loading...', - okControl: 'button', // 'link'|'button'|false - okText: 'ok', - paramName: 'value', - rows: 1, // If 1 and multi-line, uses autoRows - savingClassName: 'inplaceeditor-saving', - savingText: 'Saving...', - size: 0, - stripLoadedTextTags: false, - submitOnBlur: false, - textAfterControls: '', - textBeforeControls: '', - textBetweenControls: '' - }, - DefaultCallbacks: { - callback: function(form) { - return Form.serialize(form); - }, - onComplete: function(transport, element) { - // For backward compatibility, this one is bound to the IPE, and passes - // the element directly. It was too often customized, so we don't break it. - new Effect.Highlight(element, { - startcolor: this.options.highlightColor, keepBackgroundImage: true }); - }, - onEnterEditMode: null, - onEnterHover: function(ipe) { - ipe.element.style.backgroundColor = ipe.options.highlightColor; - if (ipe._effect) - ipe._effect.cancel(); - }, - onFailure: function(transport, ipe) { - alert('Error communication with the server: ' + transport.responseText.stripTags()); - }, - onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls. - onLeaveEditMode: null, - onLeaveHover: function(ipe) { - ipe._effect = new Effect.Highlight(ipe.element, { - startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor, - restorecolor: ipe._originalBackground, keepBackgroundImage: true - }); - } - }, - Listeners: { - click: 'enterEditMode', - keydown: 'checkForEscapeOrReturn', - mouseover: 'enterHover', - mouseout: 'leaveHover' - } -}); - -Ajax.InPlaceCollectionEditor.DefaultOptions = { - loadingCollectionText: 'Loading options...' -}; - -// Delayed observer, like Form.Element.Observer, -// but waits for delay after last key input -// Ideal for live-search fields - -Form.Element.DelayedObserver = Class.create({ - 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)); - } -}); \ No newline at end of file diff --git a/vendor/built_in_modules/blog/public/javascripts/dragdrop.js b/vendor/built_in_modules/blog/public/javascripts/dragdrop.js deleted file mode 100644 index 15c6dbca..00000000 --- a/vendor/built_in_modules/blog/public/javascripts/dragdrop.js +++ /dev/null @@ -1,974 +0,0 @@ -// script.aculo.us dragdrop.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009 - -// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// -// 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(Object.isUndefined(Effect)) - 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(Object.isArray(containment)) { - 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 drop, affected = []; - - this.drops.each( function(drop) { - if(Droppables.isAffected(point, element, drop)) - affected.push(drop); - }); - - if(affected.length>0) - drop = Droppables.findDeepestChild(affected); - - if(this.last_active && this.last_active != drop) this.deactivate(this.last_active); - if (drop) { - Position.within(drop.element, point[0], point[1]); - if(drop.onHover) - drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element)); - - if (drop != this.last_active) 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); - return true; - } - }, - - 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({ - 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 = Object.isNumber(element._opacity) ? 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, - quiet: 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] || Object.isUndefined(arguments[1].endeffect)) - 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 && Object.isString(options.handle)) - 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.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(!Object.isUndefined(Draggable._dragging[this.element]) && - Draggable._dragging[this.element]) return; - if(Event.isLeftClick(event)) { - // abort on form elements, fixes a Firefox issue - var src = Event.element(event); - if((tag_name = src.tagName.toUpperCase()) && ( - tag_name=='INPUT' || - tag_name=='SELECT' || - tag_name=='OPTION' || - tag_name=='BUTTON' || - tag_name=='TEXTAREA')) return; - - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - var pos = this.element.cumulativeOffset(); - 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.delta) - this.delta = this.currentDelta(); - - 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); - this._originallyAbsolute = (this.element.getStyle('position') == 'absolute'); - if (!this._originallyAbsolute) - 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); - - if(!this.options.quiet){ - 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(Prototype.Browser.WebKit) window.scrollBy(0,0); - - Event.stop(event); - }, - - finishDrag: function(event, success) { - this.dragging = false; - - if(this.options.quiet){ - Position.prepare(); - var pointer = [Event.pointerX(event), Event.pointerY(event)]; - Droppables.show(pointer, this.element); - } - - if(this.options.ghosting) { - if (!this._originallyAbsolute) - Position.relativize(this.element); - delete this._originallyAbsolute; - Element.remove(this._clone); - this._clone = null; - } - - var dropped = false; - if(success) { - dropped = Droppables.fire(event, this.element); - if (!dropped) dropped = false; - } - if(dropped && this.options.onDropped) this.options.onDropped(this.element); - Draggables.notify('onEnd', this, event); - - var revert = this.options.revert; - if(revert && Object.isFunction(revert)) revert = revert(this.element); - - var d = this.currentDelta(); - if(revert && this.options.reverteffect) { - if (dropped == 0 || revert != 'failure') - 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 = this.element.cumulativeOffset(); - 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(Object.isFunction(this.options.snap)) { - p = this.options.snap(p[0],p[1],this); - } else { - if(Object.isArray(this.options.snap)) { - p = p.map( function(v, i) { - return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this)); - } else { - p = p.map( function(v) { - return (v/this.options.snap).round()*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 }; - } -}); - -Draggable._dragging = { }; - -/*--------------------------------------------------------------------------*/ - -var SortableObserver = Class.create({ - 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.toUpperCase() != "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){ - element = $(element); - var s = Sortable.sortables[element.id]; - - 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, - quiet: false, - scroll: false, - scrollSensitivity: 20, - scrollSpeed: 15, - format: this.SERIALIZE_RULE, - - // these take arrays of elements or ids and can be - // used for better initialization performance - elements: false, - handles: false, - - 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, - quiet: options.quiet, - 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); - } - - (options.elements || this.findElements(element, options) || []).each( function(e,i) { - var handle = options.handles ? $(options.handles[i]) : - (options.handle ? $(e).select('.' + 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.identify()] = 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 = dropon.cumulativeOffset(); - 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')]; -}; \ No newline at end of file diff --git a/vendor/built_in_modules/blog/public/javascripts/effects.js b/vendor/built_in_modules/blog/public/javascripts/effects.js deleted file mode 100644 index c81e6c7d..00000000 --- a/vendor/built_in_modules/blog/public/javascripts/effects.js +++ /dev/null @@ -1,1123 +0,0 @@ -// script.aculo.us effects.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009 - -// Copyright (c) 2005-2009 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 (Prototype.Browser.WebKit) window.scrollBy(0,0); - 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) { } -}; - -/*--------------------------------------------------------------------------*/ - -var Effect = { - _elementDoesNotExistError: { - name: 'ElementDoesNotExistError', - message: 'The specified DOM element does not exist, but is required for this effect to operate' - }, - Transitions: { - linear: Prototype.K, - sinoidal: function(pos) { - return (-Math.cos(pos*Math.PI)/2) + .5; - }, - reverse: function(pos) { - return 1-pos; - }, - flicker: function(pos) { - var pos = ((-Math.cos(pos*Math.PI)/4) + .75) + Math.random()/4; - return pos > 1 ? 1 : pos; - }, - wobble: function(pos) { - return (-Math.cos(pos*Math.PI*(9*pos))/2) + .5; - }, - pulse: function(pos, pulses) { - return (-Math.cos((pos*((pulses||5)-.5)*2)*Math.PI)/2) + .5; - }, - spring: function(pos) { - return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6)); - }, - none: function(pos) { - return 0; - }, - full: function(pos) { - return 1; - } - }, - DefaultOptions: { - duration: 1.0, // seconds - fps: 100, // 100= assume 66fps max. - sync: false, // true for combining - from: 0.0, - to: 1.0, - delay: 0.0, - queue: 'parallel' - }, - tagifyText: function(element) { - var tagifyStyle = 'position:relative'; - if (Prototype.Browser.IE) tagifyStyle += ';zoom:1'; - - element = $(element); - $A(element.childNodes).each( function(child) { - if (child.nodeType==3) { - child.nodeValue.toArray().each( function(character) { - element.insertBefore( - new Element('span', {style: tagifyStyle}).update( - character == ' ' ? String.fromCharCode(160) : character), - child); - }); - Element.remove(child); - } - }); - }, - multiple: function(element, effect) { - var elements; - if (((typeof element == 'object') || - Object.isFunction(element)) && - (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, options) { - element = $(element); - effect = (effect || 'appear').toLowerCase(); - - return Effect[ Effect.PAIRS[ effect ][ element.visible() ? 1 : 0 ] ](element, Object.extend({ - queue: { position:'end', scope:(element.id || 'global'), limit: 1 } - }, options || {})); - } -}; - -Effect.DefaultOptions.transition = Effect.Transitions.sinoidal; - -/* ------------- core effects ------------- */ - -Effect.ScopedQueue = Class.create(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 = Object.isString(effect.options.queue) ? - 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), 15); - }, - 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(); - for(var i=0, len=this.effects.length;i= 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.totalTime, - frame = (pos * this.totalFrames).round(); - if (frame > this.currentFrame) { - this.render(pos); - this.currentFrame = frame; - } - } - }, - cancel: function() { - if (!this.options.sync) - Effect.Queues.get(Object.isString(this.options.queue) ? - '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() { - var data = $H(); - for(property in this) - if (!Object.isFunction(this[property])) data.set(property, this[property]); - return '#'; - } -}); - -Effect.Parallel = Class.create(Effect.Base, { - 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.Tween = Class.create(Effect.Base, { - initialize: function(object, from, to) { - object = Object.isString(object) ? $(object) : object; - var args = $A(arguments), method = args.last(), - options = args.length == 5 ? args[3] : null; - this.method = Object.isFunction(method) ? method.bind(object) : - Object.isFunction(object[method]) ? object[method].bind(object) : - function(value) { object[method] = value }; - this.start(Object.extend({ from: from, to: to }, options || { })); - }, - update: function(position) { - this.method(position); - } -}); - -Effect.Event = Class.create(Effect.Base, { - initialize: function() { - this.start(Object.extend({ duration: 0 }, arguments[0] || { })); - }, - update: Prototype.emptyFunction -}); - -Effect.Opacity = Class.create(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - // make this work on IE on elements without 'layout' - if (Prototype.Browser.IE && (!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(Effect.Base, { - 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() { - this.element.makePositioned(); - this.originalLeft = parseFloat(this.element.getStyle('left') || '0'); - this.originalTop = parseFloat(this.element.getStyle('top') || '0'); - if (this.options.mode == 'absolute') { - this.options.x = this.options.x - this.originalLeft; - this.options.y = this.options.y - this.originalTop; - } - }, - update: function(position) { - this.element.setStyle({ - left: (this.options.x * position + this.originalLeft).round() + 'px', - top: (this.options.y * position + this.originalTop).round() + '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(Effect.Base, { - 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 = width.round() + 'px'; - if (this.options.scaleY) d.height = height.round() + '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(Effect.Base, { - 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 = { }; - if (!this.options.keepBackgroundImage) { - 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+((this._base[i]+(this._delta[i]*position)).round().toColorPart()); }.bind(this)) }); - }, - finish: function() { - this.element.setStyle(Object.extend(this.oldStyle, { - backgroundColor: this.options.restorecolor - })); - } -}); - -Effect.ScrollTo = function(element) { - var options = arguments[1] || { }, - scrollOffsets = document.viewport.getScrollOffsets(), - elementOffsets = $(element).cumulativeOffset(); - - if (options.offset) elementOffsets[1] += options.offset; - - return new Effect.Tween(null, - scrollOffsets.top, - elementOffsets[1], - options, - function(p){ scrollTo(scrollOffsets.left, p.round()); } - ); -}; - -/* ------------- 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 options = Object.extend({ - distance: 20, - duration: 0.5 - }, arguments[1] || {}); - var distance = parseFloat(options.distance); - var split = parseFloat(options.duration) / 10.0; - var oldStyle = { - top: element.getStyle('top'), - left: element.getStyle('left') }; - return new Effect.Move(element, - { x: distance, y: 0, duration: split, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { - new Effect.Move(effect.element, - { x: -distance, y: 0, duration: split, 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'); - var elementDimensions = element.getDimensions(); - return new Effect.Scale(element, window.opera ? 0 : 1, - Object.extend({ scaleContent: false, - scaleX: false, - scaleMode: 'box', - scaleFrom: 100, - 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().show(); - }, - afterUpdateInternal: function(effect) { - effect.element.down().setStyle({bottom: - (effect.dims[0] - effect.element.clientHeight) + 'px' }); - }, - afterFinishInternal: function(effect) { - effect.element.hide().undoClipping().undoPositioned(); - effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); - } - }, 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] || { }, - oldOpacity = element.getInlineOpacity(), - transition = options.transition || Effect.Transitions.linear, - reverser = function(pos){ - return 1 - transition((-Math.cos((pos*(options.pulses||5)*2)*Math.PI)/2) + .5); - }; - - 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(Effect.Base, { - initialize: function(element) { - this.element = $(element); - if (!this.element) throw(Effect._elementDoesNotExistError); - var options = Object.extend({ - style: { } - }, arguments[1] || { }); - - if (!Object.isString(options.style)) this.style = $H(options.style); - else { - if (options.style.include(':')) - this.style = options.style.parseStyle(); - else { - this.element.addClassName(options.style); - this.style = $H(this.element.getStyles()); - this.element.removeClassName(options.style); - var css = this.element.getStyles(); - this.style = this.style.reject(function(style) { - return style.value == css[style.key]; - }); - options.afterFinishInternal = function(effect) { - effect.element.addClassName(effect.options.style); - effect.transforms.each(function(transform) { - effect.element.style[transform.style] = ''; - }); - }; - } - } - 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.style.map(function(pair){ - var property = pair[0], value = pair[1], unit = null; - - if (value.parseColor('#zzzzzz') != '#zzzzzz') { - value = value.parseColor(); - unit = 'color'; - } else if (property == 'opacity') { - value = parseFloat(value); - if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout)) - this.element.setStyle({zoom: 1}); - } else if (Element.CSS_LENGTH.test(value)) { - var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/); - value = parseFloat(components[1]); - unit = (components.length == 3) ? components[2] : null; - } - - var originalValue = this.element.getStyle(property); - return { - style: property.camelize(), - originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0), - targetValue: unit=='color' ? parseColor(value) : value, - unit: 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 = { }, transform, i = this.transforms.length; - while(i--) - style[(transform = this.transforms[i]).style] = - transform.unit=='color' ? '#'+ - (Math.round(transform.originalValue[0]+ - (transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart() + - (Math.round(transform.originalValue[1]+ - (transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() + - (Math.round(transform.originalValue[2]+ - (transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() : - (transform.originalValue + - (transform.targetValue - transform.originalValue) * position).toFixed(3) + - (transform.unit === null ? '' : transform.unit); - this.element.setStyle(style, true); - } -}); - -Effect.Transform = Class.create({ - initialize: function(tracks){ - this.tracks = []; - this.options = arguments[1] || { }; - this.addTracks(tracks); - }, - addTracks: function(tracks){ - tracks.each(function(track){ - track = $H(track); - var data = track.values().first(); - this.tracks.push($H({ - ids: 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 ids = track.get('ids'), effect = track.get('effect'), options = track.get('options'); - var elements = [$(ids) || $$(ids)].flatten(); - return elements.map(function(e){ return new effect(e, Object.extend({ sync:true }, options)) }); - }).flatten(), - this.options - ); - } -}); - -Element.CSS_PROPERTIES = $w( - 'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' + - 'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' + - 'borderRightColor borderRightStyle borderRightWidth borderSpacing ' + - 'borderTopColor borderTopStyle borderTopWidth bottom clip color ' + - 'fontSize fontWeight height left letterSpacing lineHeight ' + - 'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+ - 'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' + - 'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' + - 'right textIndent top width wordSpacing zIndex'); - -Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/; - -String.__parseStyleElement = document.createElement('div'); -String.prototype.parseStyle = function(){ - var style, styleRules = $H(); - if (Prototype.Browser.WebKit) - style = new Element('div',{style:this}).style; - else { - String.__parseStyleElement.innerHTML = '
    '; - style = String.__parseStyleElement.childNodes[0].style; - } - - Element.CSS_PROPERTIES.each(function(property){ - if (style[property]) styleRules.set(property, style[property]); - }); - - if (Prototype.Browser.IE && this.include('opacity')) - styleRules.set('opacity', this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]); - - return styleRules; -}; - -if (document.defaultView && document.defaultView.getComputedStyle) { - Element.getStyles = function(element) { - var css = document.defaultView.getComputedStyle($(element), null); - return Element.CSS_PROPERTIES.inject({ }, function(styles, property) { - styles[property] = css[property]; - return styles; - }); - }; -} else { - Element.getStyles = function(element) { - element = $(element); - var css = element.currentStyle, styles; - styles = Element.CSS_PROPERTIES.inject({ }, function(results, property) { - results[property] = css[property]; - return results; - }); - if (!styles.opacity) styles.opacity = element.getOpacity(); - return styles; - }; -} - -Effect.Methods = { - morph: function(element, style) { - element = $(element); - new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || { })); - return element; - }, - visualEffect: function(element, effect, options) { - element = $(element); - var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1); - new Effect[klass](element, options); - return element; - }, - highlight: function(element, options) { - element = $(element); - new Effect.Highlight(element, options); - return element; - } -}; - -$w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+ - 'pulsate shake puff squish switchOff dropOut').each( - function(effect) { - Effect.Methods[effect] = function(element, options){ - element = $(element); - Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options); - return element; - }; - } -); - -$w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each( - function(f) { Effect.Methods[f] = Element[f]; } -); - -Element.addMethods(Effect.Methods); \ No newline at end of file diff --git a/vendor/built_in_modules/blog/public/javascripts/prototype.js b/vendor/built_in_modules/blog/public/javascripts/prototype.js deleted file mode 100644 index 06249a6a..00000000 --- a/vendor/built_in_modules/blog/public/javascripts/prototype.js +++ /dev/null @@ -1,6001 +0,0 @@ -/* Prototype JavaScript framework, version 1.7_rc2 - * (c) 2005-2010 Sam Stephenson - * - * Prototype is freely distributable under the terms of an MIT-style license. - * For details, see the Prototype web site: http://www.prototypejs.org/ - * - *--------------------------------------------------------------------------*/ - -var Prototype = { - - Version: '1.7_rc2', - - Browser: (function(){ - var ua = navigator.userAgent; - var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]'; - return { - IE: !!window.attachEvent && !isOpera, - Opera: isOpera, - WebKit: ua.indexOf('AppleWebKit/') > -1, - Gecko: ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1, - MobileSafari: /Apple.*Mobile/.test(ua) - } - })(), - - BrowserFeatures: { - XPath: !!document.evaluate, - - SelectorsAPI: !!document.querySelector, - - ElementExtensions: (function() { - var constructor = window.Element || window.HTMLElement; - return !!(constructor && constructor.prototype); - })(), - SpecificElementExtensions: (function() { - if (typeof window.HTMLDivElement !== 'undefined') - return true; - - var div = document.createElement('div'), - form = document.createElement('form'), - isSupported = false; - - if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) { - isSupported = true; - } - - div = form = null; - - return isSupported; - })() - }, - - ScriptFragment: ']*>([\\S\\s]*?)<\/script>', - JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, - - emptyFunction: function() { }, - - K: function(x) { return x } -}; - -if (Prototype.Browser.MobileSafari) - Prototype.BrowserFeatures.SpecificElementExtensions = false; - - -var Abstract = { }; - - -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; - } -}; - -/* Based on Alex Arnell's inheritance implementation. */ - -var Class = (function() { - - var IS_DONTENUM_BUGGY = (function(){ - for (var p in { toString: 1 }) { - if (p === 'toString') return false; - } - return true; - })(); - - function subclass() {}; - function create() { - var parent = null, properties = $A(arguments); - if (Object.isFunction(properties[0])) - parent = properties.shift(); - - function klass() { - this.initialize.apply(this, arguments); - } - - Object.extend(klass, Class.Methods); - klass.superclass = parent; - klass.subclasses = []; - - if (parent) { - subclass.prototype = parent.prototype; - klass.prototype = new subclass; - parent.subclasses.push(klass); - } - - for (var i = 0, length = properties.length; i < length; i++) - klass.addMethods(properties[i]); - - if (!klass.prototype.initialize) - klass.prototype.initialize = Prototype.emptyFunction; - - klass.prototype.constructor = klass; - return klass; - } - - function addMethods(source) { - var ancestor = this.superclass && this.superclass.prototype, - properties = Object.keys(source); - - if (IS_DONTENUM_BUGGY) { - if (source.toString != Object.prototype.toString) - properties.push("toString"); - if (source.valueOf != Object.prototype.valueOf) - properties.push("valueOf"); - } - - for (var i = 0, length = properties.length; i < length; i++) { - var property = properties[i], value = source[property]; - if (ancestor && Object.isFunction(value) && - value.argumentNames()[0] == "$super") { - var method = value; - value = (function(m) { - return function() { return ancestor[m].apply(this, arguments); }; - })(property).wrap(method); - - value.valueOf = method.valueOf.bind(method); - value.toString = method.toString.bind(method); - } - this.prototype[property] = value; - } - - return this; - } - - return { - create: create, - Methods: { - addMethods: addMethods - } - }; -})(); -(function() { - - var _toString = Object.prototype.toString, - NULL_TYPE = 'Null', - UNDEFINED_TYPE = 'Undefined', - BOOLEAN_TYPE = 'Boolean', - NUMBER_TYPE = 'Number', - STRING_TYPE = 'String', - OBJECT_TYPE = 'Object', - BOOLEAN_CLASS = '[object Boolean]', - NUMBER_CLASS = '[object Number]', - STRING_CLASS = '[object String]', - ARRAY_CLASS = '[object Array]', - NATIVE_JSON_STRINGIFY_SUPPORT = window.JSON && - typeof JSON.stringify === 'function' && - JSON.stringify(0) === '0' && - typeof JSON.stringify(Prototype.K) === 'undefined'; - - function Type(o) { - switch(o) { - case null: return NULL_TYPE; - case (void 0): return UNDEFINED_TYPE; - } - var type = typeof o; - switch(type) { - case 'boolean': return BOOLEAN_TYPE; - case 'number': return NUMBER_TYPE; - case 'string': return STRING_TYPE; - } - return OBJECT_TYPE; - } - - function extend(destination, source) { - for (var property in source) - destination[property] = source[property]; - return destination; - } - - function inspect(object) { - try { - if (isUndefined(object)) return 'undefined'; - if (object === null) return 'null'; - return object.inspect ? object.inspect() : String(object); - } catch (e) { - if (e instanceof RangeError) return '...'; - throw e; - } - } - - function toJSON(value) { - return Str('', { '': value }, []); - } - - function Str(key, holder, stack) { - var value = holder[key], - type = typeof value; - - if (Type(value) === OBJECT_TYPE && typeof value.toJSON === 'function') { - value = value.toJSON(key); - } - - var _class = _toString.call(value); - - switch (_class) { - case NUMBER_CLASS: - case BOOLEAN_CLASS: - case STRING_CLASS: - value = value.valueOf(); - } - - switch (value) { - case null: return 'null'; - case true: return 'true'; - case false: return 'false'; - } - - type = typeof value; - switch (type) { - case 'string': - return value.inspect(true); - case 'number': - return isFinite(value) ? String(value) : 'null'; - case 'object': - - for (var i = 0, length = stack.length; i < length; i++) { - if (stack[i] === value) { throw new TypeError(); } - } - stack.push(value); - - var partial = []; - if (_class === ARRAY_CLASS) { - for (var i = 0, length = value.length; i < length; i++) { - var str = Str(i, value, stack); - partial.push(typeof str === 'undefined' ? 'null' : str); - } - partial = '[' + partial.join(',') + ']'; - } else { - var keys = Object.keys(value); - for (var i = 0, length = keys.length; i < length; i++) { - var key = keys[i], str = Str(key, value, stack); - if (typeof str !== "undefined") { - partial.push(key.inspect(true)+ ':' + str); - } - } - partial = '{' + partial.join(',') + '}'; - } - stack.pop(); - return partial; - } - } - - function stringify(object) { - return JSON.stringify(object); - } - - function toQueryString(object) { - return $H(object).toQueryString(); - } - - function toHTML(object) { - return object && object.toHTML ? object.toHTML() : String.interpret(object); - } - - function keys(object) { - if (Type(object) !== OBJECT_TYPE) { throw new TypeError(); } - var results = []; - for (var property in object) { - if (object.hasOwnProperty(property)) { - results.push(property); - } - } - return results; - } - - function values(object) { - var results = []; - for (var property in object) - results.push(object[property]); - return results; - } - - function clone(object) { - return extend({ }, object); - } - - function isElement(object) { - return !!(object && object.nodeType == 1); - } - - function isArray(object) { - return _toString.call(object) === ARRAY_CLASS; - } - - var hasNativeIsArray = (typeof Array.isArray == 'function') - && Array.isArray([]) && !Array.isArray({}); - - if (hasNativeIsArray) { - isArray = Array.isArray; - } - - function isHash(object) { - return object instanceof Hash; - } - - function isFunction(object) { - return typeof object === "function"; - } - - function isString(object) { - return _toString.call(object) === STRING_CLASS; - } - - function isNumber(object) { - return _toString.call(object) === NUMBER_CLASS; - } - - function isUndefined(object) { - return typeof object === "undefined"; - } - - extend(Object, { - extend: extend, - inspect: inspect, - toJSON: NATIVE_JSON_STRINGIFY_SUPPORT ? stringify : toJSON, - toQueryString: toQueryString, - toHTML: toHTML, - keys: Object.keys || keys, - values: values, - clone: clone, - isElement: isElement, - isArray: isArray, - isHash: isHash, - isFunction: isFunction, - isString: isString, - isNumber: isNumber, - isUndefined: isUndefined - }); -})(); -Object.extend(Function.prototype, (function() { - var slice = Array.prototype.slice; - - function update(array, args) { - var arrayLength = array.length, length = args.length; - while (length--) array[arrayLength + length] = args[length]; - return array; - } - - function merge(array, args) { - array = slice.call(array, 0); - return update(array, args); - } - - function argumentNames() { - var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1] - .replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, '') - .replace(/\s+/g, '').split(','); - return names.length == 1 && !names[0] ? [] : names; - } - - function bind(context) { - if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this; - var __method = this, args = slice.call(arguments, 1); - return function() { - var a = merge(args, arguments); - return __method.apply(context, a); - } - } - - function bindAsEventListener(context) { - var __method = this, args = slice.call(arguments, 1); - return function(event) { - var a = update([event || window.event], args); - return __method.apply(context, a); - } - } - - function curry() { - if (!arguments.length) return this; - var __method = this, args = slice.call(arguments, 0); - return function() { - var a = merge(args, arguments); - return __method.apply(this, a); - } - } - - function delay(timeout) { - var __method = this, args = slice.call(arguments, 1); - timeout = timeout * 1000; - return window.setTimeout(function() { - return __method.apply(__method, args); - }, timeout); - } - - function defer() { - var args = update([0.01], arguments); - return this.delay.apply(this, args); - } - - function wrap(wrapper) { - var __method = this; - return function() { - var a = update([__method.bind(this)], arguments); - return wrapper.apply(this, a); - } - } - - function methodize() { - if (this._methodized) return this._methodized; - var __method = this; - return this._methodized = function() { - var a = update([this], arguments); - return __method.apply(null, a); - }; - } - - return { - argumentNames: argumentNames, - bind: bind, - bindAsEventListener: bindAsEventListener, - curry: curry, - delay: delay, - defer: defer, - wrap: wrap, - methodize: methodize - } -})()); - - - -(function(proto) { - - - function toISOString() { - return this.getUTCFullYear() + '-' + - (this.getUTCMonth() + 1).toPaddedString(2) + '-' + - this.getUTCDate().toPaddedString(2) + 'T' + - this.getUTCHours().toPaddedString(2) + ':' + - this.getUTCMinutes().toPaddedString(2) + ':' + - this.getUTCSeconds().toPaddedString(2) + 'Z'; - } - - - function toJSON() { - return this.toISOString(); - } - - if (!proto.toISOString) proto.toISOString = toISOString; - if (!proto.toJSON) proto.toJSON = toJSON; - -})(Date.prototype); - - -RegExp.prototype.match = RegExp.prototype.test; - -RegExp.escape = function(str) { - return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); -}; -var PeriodicalExecuter = Class.create({ - 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); - }, - - execute: function() { - this.callback(this); - }, - - stop: function() { - if (!this.timer) return; - clearInterval(this.timer); - this.timer = null; - }, - - onTimerEvent: function() { - if (!this.currentlyExecuting) { - try { - this.currentlyExecuting = true; - this.execute(); - this.currentlyExecuting = false; - } catch(e) { - this.currentlyExecuting = false; - throw e; - } - } - } -}); -Object.extend(String, { - interpret: function(value) { - return value == null ? '' : String(value); - }, - specialChar: { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '\\': '\\\\' - } -}); - -Object.extend(String.prototype, (function() { - var NATIVE_JSON_PARSE_SUPPORT = window.JSON && - typeof JSON.parse === 'function' && - JSON.parse('{"test": true}').test; - - function prepareReplacement(replacement) { - if (Object.isFunction(replacement)) return replacement; - var template = new Template(replacement); - return function(match) { return template.evaluate(match) }; - } - - function gsub(pattern, replacement) { - var result = '', source = this, match; - replacement = prepareReplacement(replacement); - - if (Object.isString(pattern)) - pattern = RegExp.escape(pattern); - - if (!(pattern.length || pattern.source)) { - replacement = replacement(''); - return replacement + source.split('').join(replacement) + 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; - } - - function sub(pattern, replacement, count) { - replacement = prepareReplacement(replacement); - count = Object.isUndefined(count) ? 1 : count; - - return this.gsub(pattern, function(match) { - if (--count < 0) return match[0]; - return replacement(match); - }); - } - - function scan(pattern, iterator) { - this.gsub(pattern, iterator); - return String(this); - } - - function truncate(length, truncation) { - length = length || 30; - truncation = Object.isUndefined(truncation) ? '...' : truncation; - return this.length > length ? - this.slice(0, length - truncation.length) + truncation : String(this); - } - - function strip() { - return this.replace(/^\s+/, '').replace(/\s+$/, ''); - } - - function stripTags() { - return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, ''); - } - - function stripScripts() { - return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); - } - - function extractScripts() { - var matchAll = new RegExp(Prototype.ScriptFragment, 'img'), - matchOne = new RegExp(Prototype.ScriptFragment, 'im'); - return (this.match(matchAll) || []).map(function(scriptTag) { - return (scriptTag.match(matchOne) || ['', ''])[1]; - }); - } - - function evalScripts() { - return this.extractScripts().map(function(script) { return eval(script) }); - } - - function escapeHTML() { - return this.replace(/&/g,'&').replace(//g,'>'); - } - - function unescapeHTML() { - return this.stripTags().replace(/</g,'<').replace(/>/g,'>').replace(/&/g,'&'); - } - - - function toQueryParams(separator) { - var match = this.strip().match(/([^?#]*)(#.*)?$/); - if (!match) return { }; - - return match[1].split(separator || '&').inject({ }, function(hash, pair) { - if ((pair = pair.split('='))[0]) { - var key = decodeURIComponent(pair.shift()), - value = pair.length > 1 ? pair.join('=') : pair[0]; - - if (value != undefined) value = decodeURIComponent(value); - - if (key in hash) { - if (!Object.isArray(hash[key])) hash[key] = [hash[key]]; - hash[key].push(value); - } - else hash[key] = value; - } - return hash; - }); - } - - function toArray() { - return this.split(''); - } - - function succ() { - return this.slice(0, this.length - 1) + - String.fromCharCode(this.charCodeAt(this.length - 1) + 1); - } - - function times(count) { - return count < 1 ? '' : new Array(count + 1).join(this); - } - - function camelize() { - return this.replace(/-+(.)?/g, function(match, chr) { - return chr ? chr.toUpperCase() : ''; - }); - } - - function capitalize() { - return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); - } - - function underscore() { - return this.replace(/::/g, '/') - .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2') - .replace(/([a-z\d])([A-Z])/g, '$1_$2') - .replace(/-/g, '_') - .toLowerCase(); - } - - function dasherize() { - return this.replace(/_/g, '-'); - } - - function inspect(useDoubleQuotes) { - var escapedString = this.replace(/[\x00-\x1f\\]/g, function(character) { - if (character in String.specialChar) { - return String.specialChar[character]; - } - return '\\u00' + character.charCodeAt().toPaddedString(2, 16); - }); - if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; - return "'" + escapedString.replace(/'/g, '\\\'') + "'"; - } - - function unfilterJSON(filter) { - return this.replace(filter || Prototype.JSONFilter, '$1'); - } - - function isJSON() { - var str = this; - if (str.blank()) return false; - str = str.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@'); - str = str.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'); - str = str.replace(/(?:^|:|,)(?:\s*\[)+/g, ''); - return (/^[\],:{}\s]*$/).test(str); - } - - function evalJSON(sanitize) { - var json = this.unfilterJSON(), - cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; - if (cx.test(json)) { - json = json.replace(cx, function (a) { - return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }); - } - try { - if (!sanitize || json.isJSON()) return eval('(' + json + ')'); - } catch (e) { } - throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); - } - - function parseJSON() { - var json = this.unfilterJSON(); - return JSON.parse(json); - } - - function include(pattern) { - return this.indexOf(pattern) > -1; - } - - function startsWith(pattern) { - return this.lastIndexOf(pattern, 0) === 0; - } - - function endsWith(pattern) { - var d = this.length - pattern.length; - return d >= 0 && this.indexOf(pattern, d) === d; - } - - function empty() { - return this == ''; - } - - function blank() { - return /^\s*$/.test(this); - } - - function interpolate(object, pattern) { - return new Template(this, pattern).evaluate(object); - } - - return { - gsub: gsub, - sub: sub, - scan: scan, - truncate: truncate, - strip: String.prototype.trim || strip, - stripTags: stripTags, - stripScripts: stripScripts, - extractScripts: extractScripts, - evalScripts: evalScripts, - escapeHTML: escapeHTML, - unescapeHTML: unescapeHTML, - toQueryParams: toQueryParams, - parseQuery: toQueryParams, - toArray: toArray, - succ: succ, - times: times, - camelize: camelize, - capitalize: capitalize, - underscore: underscore, - dasherize: dasherize, - inspect: inspect, - unfilterJSON: unfilterJSON, - isJSON: isJSON, - evalJSON: NATIVE_JSON_PARSE_SUPPORT ? parseJSON : evalJSON, - include: include, - startsWith: startsWith, - endsWith: endsWith, - empty: empty, - blank: blank, - interpolate: interpolate - }; -})()); - -var Template = Class.create({ - initialize: function(template, pattern) { - this.template = template.toString(); - this.pattern = pattern || Template.Pattern; - }, - - evaluate: function(object) { - if (object && Object.isFunction(object.toTemplateReplacements)) - object = object.toTemplateReplacements(); - - return this.template.gsub(this.pattern, function(match) { - if (object == null) return (match[1] + ''); - - var before = match[1] || ''; - if (before == '\\') return match[2]; - - var ctx = object, expr = match[3], - pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/; - - match = pattern.exec(expr); - if (match == null) return before; - - while (match != null) { - var comp = match[1].startsWith('[') ? match[2].replace(/\\\\]/g, ']') : match[1]; - ctx = ctx[comp]; - if (null == ctx || '' == match[3]) break; - expr = expr.substring('[' == match[3] ? match[1].length : match[0].length); - match = pattern.exec(expr); - } - - return before + String.interpret(ctx); - }); - } -}); -Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; - -var $break = { }; - -var Enumerable = (function() { - function each(iterator, context) { - var index = 0; - try { - this._each(function(value) { - iterator.call(context, value, index++); - }); - } catch (e) { - if (e != $break) throw e; - } - return this; - } - - function eachSlice(number, iterator, context) { - var index = -number, slices = [], array = this.toArray(); - if (number < 1) return array; - while ((index += number) < array.length) - slices.push(array.slice(index, index+number)); - return slices.collect(iterator, context); - } - - function all(iterator, context) { - iterator = iterator || Prototype.K; - var result = true; - this.each(function(value, index) { - result = result && !!iterator.call(context, value, index); - if (!result) throw $break; - }); - return result; - } - - function any(iterator, context) { - iterator = iterator || Prototype.K; - var result = false; - this.each(function(value, index) { - if (result = !!iterator.call(context, value, index)) - throw $break; - }); - return result; - } - - function collect(iterator, context) { - iterator = iterator || Prototype.K; - var results = []; - this.each(function(value, index) { - results.push(iterator.call(context, value, index)); - }); - return results; - } - - function detect(iterator, context) { - var result; - this.each(function(value, index) { - if (iterator.call(context, value, index)) { - result = value; - throw $break; - } - }); - return result; - } - - function findAll(iterator, context) { - var results = []; - this.each(function(value, index) { - if (iterator.call(context, value, index)) - results.push(value); - }); - return results; - } - - function grep(filter, iterator, context) { - iterator = iterator || Prototype.K; - var results = []; - - if (Object.isString(filter)) - filter = new RegExp(RegExp.escape(filter)); - - this.each(function(value, index) { - if (filter.match(value)) - results.push(iterator.call(context, value, index)); - }); - return results; - } - - function include(object) { - if (Object.isFunction(this.indexOf)) - if (this.indexOf(object) != -1) return true; - - var found = false; - this.each(function(value) { - if (value == object) { - found = true; - throw $break; - } - }); - return found; - } - - function inGroupsOf(number, fillWith) { - fillWith = Object.isUndefined(fillWith) ? null : fillWith; - return this.eachSlice(number, function(slice) { - while(slice.length < number) slice.push(fillWith); - return slice; - }); - } - - function inject(memo, iterator, context) { - this.each(function(value, index) { - memo = iterator.call(context, memo, value, index); - }); - return memo; - } - - function invoke(method) { - var args = $A(arguments).slice(1); - return this.map(function(value) { - return value[method].apply(value, args); - }); - } - - function max(iterator, context) { - iterator = iterator || Prototype.K; - var result; - this.each(function(value, index) { - value = iterator.call(context, value, index); - if (result == null || value >= result) - result = value; - }); - return result; - } - - function min(iterator, context) { - iterator = iterator || Prototype.K; - var result; - this.each(function(value, index) { - value = iterator.call(context, value, index); - if (result == null || value < result) - result = value; - }); - return result; - } - - function partition(iterator, context) { - iterator = iterator || Prototype.K; - var trues = [], falses = []; - this.each(function(value, index) { - (iterator.call(context, value, index) ? - trues : falses).push(value); - }); - return [trues, falses]; - } - - function pluck(property) { - var results = []; - this.each(function(value) { - results.push(value[property]); - }); - return results; - } - - function reject(iterator, context) { - var results = []; - this.each(function(value, index) { - if (!iterator.call(context, value, index)) - results.push(value); - }); - return results; - } - - function sortBy(iterator, context) { - return this.map(function(value, index) { - return { - value: value, - criteria: iterator.call(context, value, index) - }; - }).sort(function(left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }).pluck('value'); - } - - function toArray() { - return this.map(); - } - - function zip() { - var iterator = Prototype.K, args = $A(arguments); - if (Object.isFunction(args.last())) - iterator = args.pop(); - - var collections = [this].concat(args).map($A); - return this.map(function(value, index) { - return iterator(collections.pluck(index)); - }); - } - - function size() { - return this.toArray().length; - } - - function inspect() { - return '#'; - } - - - - - - - - - - return { - each: each, - eachSlice: eachSlice, - all: all, - every: all, - any: any, - some: any, - collect: collect, - map: collect, - detect: detect, - findAll: findAll, - select: findAll, - filter: findAll, - grep: grep, - include: include, - member: include, - inGroupsOf: inGroupsOf, - inject: inject, - invoke: invoke, - max: max, - min: min, - partition: partition, - pluck: pluck, - reject: reject, - sortBy: sortBy, - toArray: toArray, - entries: toArray, - zip: zip, - size: size, - inspect: inspect, - find: detect - }; -})(); - -function $A(iterable) { - if (!iterable) return []; - if ('toArray' in Object(iterable)) return iterable.toArray(); - var length = iterable.length || 0, results = new Array(length); - while (length--) results[length] = iterable[length]; - return results; -} - - -function $w(string) { - if (!Object.isString(string)) return []; - string = string.strip(); - return string ? string.split(/\s+/) : []; -} - -Array.from = $A; - - -(function() { - var arrayProto = Array.prototype, - slice = arrayProto.slice, - _each = arrayProto.forEach; // use native browser JS 1.6 implementation if available - - function each(iterator) { - for (var i = 0, length = this.length; i < length; i++) - iterator(this[i]); - } - if (!_each) _each = each; - - function clear() { - this.length = 0; - return this; - } - - function first() { - return this[0]; - } - - function last() { - return this[this.length - 1]; - } - - function compact() { - return this.select(function(value) { - return value != null; - }); - } - - function flatten() { - return this.inject([], function(array, value) { - if (Object.isArray(value)) - return array.concat(value.flatten()); - array.push(value); - return array; - }); - } - - function without() { - var values = slice.call(arguments, 0); - return this.select(function(value) { - return !values.include(value); - }); - } - - function reverse(inline) { - return (inline === false ? this.toArray() : this)._reverse(); - } - - function uniq(sorted) { - return this.inject([], function(array, value, index) { - if (0 == index || (sorted ? array.last() != value : !array.include(value))) - array.push(value); - return array; - }); - } - - function intersect(array) { - return this.uniq().findAll(function(item) { - return array.detect(function(value) { return item === value }); - }); - } - - - function clone() { - return slice.call(this, 0); - } - - function size() { - return this.length; - } - - function inspect() { - return '[' + this.map(Object.inspect).join(', ') + ']'; - } - - function indexOf(item, i) { - i || (i = 0); - var length = this.length; - if (i < 0) i = length + i; - for (; i < length; i++) - if (this[i] === item) return i; - return -1; - } - - function lastIndexOf(item, i) { - i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1; - var n = this.slice(0, i).reverse().indexOf(item); - return (n < 0) ? n : i - n - 1; - } - - function concat() { - var array = slice.call(this, 0), item; - for (var i = 0, length = arguments.length; i < length; i++) { - item = arguments[i]; - if (Object.isArray(item) && !('callee' in item)) { - for (var j = 0, arrayLength = item.length; j < arrayLength; j++) - array.push(item[j]); - } else { - array.push(item); - } - } - return array; - } - - Object.extend(arrayProto, Enumerable); - - if (!arrayProto._reverse) - arrayProto._reverse = arrayProto.reverse; - - Object.extend(arrayProto, { - _each: _each, - clear: clear, - first: first, - last: last, - compact: compact, - flatten: flatten, - without: without, - reverse: reverse, - uniq: uniq, - intersect: intersect, - clone: clone, - toArray: clone, - size: size, - inspect: inspect - }); - - var CONCAT_ARGUMENTS_BUGGY = (function() { - return [].concat(arguments)[0][0] !== 1; - })(1,2) - - if (CONCAT_ARGUMENTS_BUGGY) arrayProto.concat = concat; - - if (!arrayProto.indexOf) arrayProto.indexOf = indexOf; - if (!arrayProto.lastIndexOf) arrayProto.lastIndexOf = lastIndexOf; -})(); -function $H(object) { - return new Hash(object); -}; - -var Hash = Class.create(Enumerable, (function() { - function initialize(object) { - this._object = Object.isHash(object) ? object.toObject() : Object.clone(object); - } - - - function _each(iterator) { - for (var key in this._object) { - var value = this._object[key], pair = [key, value]; - pair.key = key; - pair.value = value; - iterator(pair); - } - } - - function set(key, value) { - return this._object[key] = value; - } - - function get(key) { - if (this._object[key] !== Object.prototype[key]) - return this._object[key]; - } - - function unset(key) { - var value = this._object[key]; - delete this._object[key]; - return value; - } - - function toObject() { - return Object.clone(this._object); - } - - - - function keys() { - return this.pluck('key'); - } - - function values() { - return this.pluck('value'); - } - - function index(value) { - var match = this.detect(function(pair) { - return pair.value === value; - }); - return match && match.key; - } - - function merge(object) { - return this.clone().update(object); - } - - function update(object) { - return new Hash(object).inject(this, function(result, pair) { - result.set(pair.key, pair.value); - return result; - }); - } - - function toQueryPair(key, value) { - if (Object.isUndefined(value)) return key; - return key + '=' + encodeURIComponent(String.interpret(value)); - } - - function toQueryString() { - return this.inject([], function(results, pair) { - var key = encodeURIComponent(pair.key), values = pair.value; - - if (values && typeof values == 'object') { - if (Object.isArray(values)) - return results.concat(values.map(toQueryPair.curry(key))); - } else results.push(toQueryPair(key, values)); - return results; - }).join('&'); - } - - function inspect() { - return '#'; - } - - function clone() { - return new Hash(this); - } - - return { - initialize: initialize, - _each: _each, - set: set, - get: get, - unset: unset, - toObject: toObject, - toTemplateReplacements: toObject, - keys: keys, - values: values, - index: index, - merge: merge, - update: update, - toQueryString: toQueryString, - inspect: inspect, - toJSON: toObject, - clone: clone - }; -})()); - -Hash.from = $H; -Object.extend(Number.prototype, (function() { - function toColorPart() { - return this.toPaddedString(2, 16); - } - - function succ() { - return this + 1; - } - - function times(iterator, context) { - $R(0, this, true).each(iterator, context); - return this; - } - - function toPaddedString(length, radix) { - var string = this.toString(radix || 10); - return '0'.times(length - string.length) + string; - } - - function abs() { - return Math.abs(this); - } - - function round() { - return Math.round(this); - } - - function ceil() { - return Math.ceil(this); - } - - function floor() { - return Math.floor(this); - } - - return { - toColorPart: toColorPart, - succ: succ, - times: times, - toPaddedString: toPaddedString, - abs: abs, - round: round, - ceil: ceil, - floor: floor - }; -})()); - -function $R(start, end, exclusive) { - return new ObjectRange(start, end, exclusive); -} - -var ObjectRange = Class.create(Enumerable, (function() { - function initialize(start, end, exclusive) { - this.start = start; - this.end = end; - this.exclusive = exclusive; - } - - function _each(iterator) { - var value = this.start; - while (this.include(value)) { - iterator(value); - value = value.succ(); - } - } - - function include(value) { - if (value < this.start) - return false; - if (this.exclusive) - return value < this.end; - return value <= this.end; - } - - return { - initialize: initialize, - _each: _each, - include: include - }; -})()); - - - -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 (Object.isFunction(responder[callback])) { - 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 = Class.create({ - initialize: function(options) { - this.options = { - method: 'post', - asynchronous: true, - contentType: 'application/x-www-form-urlencoded', - encoding: 'UTF-8', - parameters: '', - evalJSON: true, - evalJS: true - }; - Object.extend(this.options, options || { }); - - this.options.method = this.options.method.toLowerCase(); - - if (Object.isString(this.options.parameters)) - this.options.parameters = this.options.parameters.toQueryParams(); - else if (Object.isHash(this.options.parameters)) - this.options.parameters = this.options.parameters.toObject(); - } -}); -Ajax.Request = Class.create(Ajax.Base, { - _complete: false, - - initialize: function($super, url, options) { - $super(options); - this.transport = Ajax.getTransport(); - this.request(url); - }, - - request: function(url) { - this.url = url; - this.method = this.options.method; - var params = Object.clone(this.options.parameters); - - if (!['get', 'post'].include(this.method)) { - params['_method'] = this.method; - this.method = 'post'; - } - - this.parameters = params; - - if (params = Object.toQueryString(params)) { - if (this.method == 'get') - this.url += (this.url.include('?') ? '&' : '?') + params; - else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) - params += '&_='; - } - - try { - var response = new Ajax.Response(this); - if (this.options.onCreate) this.options.onCreate(response); - Ajax.Responders.dispatch('onCreate', this, response); - - this.transport.open(this.method.toUpperCase(), this.url, - this.options.asynchronous); - - if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1); - - this.transport.onreadystatechange = this.onStateChange.bind(this); - this.setRequestHeaders(); - - this.body = this.method == 'post' ? (this.options.postBody || params) : null; - this.transport.send(this.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'; - } - - if (typeof this.options.requestHeaders == 'object') { - var extras = this.options.requestHeaders; - - if (Object.isFunction(extras.push)) - 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() { - var status = this.getStatus(); - return !status || (status >= 200 && status < 300); - }, - - getStatus: function() { - try { - return this.transport.status || 0; - } catch (e) { return 0 } - }, - - respondToReadyState: function(readyState) { - var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this); - - if (state == 'Complete') { - try { - this._complete = true; - (this.options['on' + response.status] - || this.options['on' + (this.success() ? 'Success' : 'Failure')] - || Prototype.emptyFunction)(response, response.headerJSON); - } catch (e) { - this.dispatchException(e); - } - - var contentType = response.getHeader('Content-type'); - if (this.options.evalJS == 'force' - || (this.options.evalJS && this.isSameOrigin() && contentType - && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))) - this.evalResponse(); - } - - try { - (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON); - Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON); - } catch (e) { - this.dispatchException(e); - } - - if (state == 'Complete') { - this.transport.onreadystatechange = Prototype.emptyFunction; - } - }, - - isSameOrigin: function() { - var m = this.url.match(/^\s*https?:\/\/[^\/]*/); - return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({ - protocol: location.protocol, - domain: document.domain, - port: location.port ? ':' + location.port : '' - })); - }, - - getHeader: function(name) { - try { - return this.transport.getResponseHeader(name) || null; - } catch (e) { return null; } - }, - - evalResponse: function() { - try { - return eval((this.transport.responseText || '').unfilterJSON()); - } catch (e) { - this.dispatchException(e); - } - }, - - dispatchException: function(exception) { - (this.options.onException || Prototype.emptyFunction)(this, exception); - Ajax.Responders.dispatch('onException', this, exception); - } -}); - -Ajax.Request.Events = - ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; - - - - - - - - -Ajax.Response = Class.create({ - initialize: function(request){ - this.request = request; - var transport = this.transport = request.transport, - readyState = this.readyState = transport.readyState; - - if ((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) { - this.status = this.getStatus(); - this.statusText = this.getStatusText(); - this.responseText = String.interpret(transport.responseText); - this.headerJSON = this._getHeaderJSON(); - } - - if (readyState == 4) { - var xml = transport.responseXML; - this.responseXML = Object.isUndefined(xml) ? null : xml; - this.responseJSON = this._getResponseJSON(); - } - }, - - status: 0, - - statusText: '', - - getStatus: Ajax.Request.prototype.getStatus, - - getStatusText: function() { - try { - return this.transport.statusText || ''; - } catch (e) { return '' } - }, - - getHeader: Ajax.Request.prototype.getHeader, - - getAllHeaders: function() { - try { - return this.getAllResponseHeaders(); - } catch (e) { return null } - }, - - getResponseHeader: function(name) { - return this.transport.getResponseHeader(name); - }, - - getAllResponseHeaders: function() { - return this.transport.getAllResponseHeaders(); - }, - - _getHeaderJSON: function() { - var json = this.getHeader('X-JSON'); - if (!json) return null; - json = decodeURIComponent(escape(json)); - try { - return json.evalJSON(this.request.options.sanitizeJSON || - !this.request.isSameOrigin()); - } catch (e) { - this.request.dispatchException(e); - } - }, - - _getResponseJSON: function() { - var options = this.request.options; - if (!options.evalJSON || (options.evalJSON != 'force' && - !(this.getHeader('Content-type') || '').include('application/json')) || - this.responseText.blank()) - return null; - try { - return this.responseText.evalJSON(options.sanitizeJSON || - !this.request.isSameOrigin()); - } catch (e) { - this.request.dispatchException(e); - } - } -}); - -Ajax.Updater = Class.create(Ajax.Request, { - initialize: function($super, container, url, options) { - this.container = { - success: (container.success || container), - failure: (container.failure || (container.success ? null : container)) - }; - - options = Object.clone(options); - var onComplete = options.onComplete; - options.onComplete = (function(response, json) { - this.updateContent(response.responseText); - if (Object.isFunction(onComplete)) onComplete(response, json); - }).bind(this); - - $super(url, options); - }, - - updateContent: function(responseText) { - var receiver = this.container[this.success() ? 'success' : 'failure'], - options = this.options; - - if (!options.evalScripts) responseText = responseText.stripScripts(); - - if (receiver = $(receiver)) { - if (options.insertion) { - if (Object.isString(options.insertion)) { - var insertion = { }; insertion[options.insertion] = responseText; - receiver.insert(insertion); - } - else options.insertion(receiver, responseText); - } - else receiver.update(responseText); - } - } -}); - -Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { - initialize: function($super, container, url, options) { - $super(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(response) { - if (this.options.decay) { - this.decay = (response.responseText == this.lastText ? - this.decay * this.options.decay : 1); - - this.lastText = response.responseText; - } - this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency); - }, - - 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 (Object.isString(element)) - 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(Element.extend(query.snapshotItem(i))); - return results; - }; -} - -/*--------------------------------------------------------------------------*/ - -if (!Node) var Node = { }; - -if (!Node.ELEMENT_NODE) { - Object.extend(Node, { - ELEMENT_NODE: 1, - ATTRIBUTE_NODE: 2, - TEXT_NODE: 3, - CDATA_SECTION_NODE: 4, - ENTITY_REFERENCE_NODE: 5, - ENTITY_NODE: 6, - PROCESSING_INSTRUCTION_NODE: 7, - COMMENT_NODE: 8, - DOCUMENT_NODE: 9, - DOCUMENT_TYPE_NODE: 10, - DOCUMENT_FRAGMENT_NODE: 11, - NOTATION_NODE: 12 - }); -} - - - -(function(global) { - - var HAS_EXTENDED_CREATE_ELEMENT_SYNTAX = (function(){ - try { - var el = document.createElement(''); - return el.tagName.toLowerCase() === 'input' && el.name === 'x'; - } - catch(err) { - return false; - } - })(); - - var element = global.Element; - - global.Element = function(tagName, attributes) { - attributes = attributes || { }; - tagName = tagName.toLowerCase(); - var cache = Element.cache; - if (HAS_EXTENDED_CREATE_ELEMENT_SYNTAX && attributes.name) { - tagName = '<' + tagName + ' name="' + attributes.name + '">'; - delete attributes.name; - return Element.writeAttribute(document.createElement(tagName), attributes); - } - if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName)); - return Element.writeAttribute(cache[tagName].cloneNode(false), attributes); - }; - - Object.extend(global.Element, element || { }); - if (element) global.Element.prototype = element.prototype; - -})(this); - -Element.idCounter = 1; -Element.cache = { }; - -function purgeElement(element) { - var uid = element._prototypeUID; - if (uid) { - Element.stopObserving(element); - element._prototypeUID = void 0; - delete Element.Storage[uid]; - } -} - -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 = $(element); - element.style.display = 'none'; - return element; - }, - - show: function(element) { - element = $(element); - element.style.display = ''; - return element; - }, - - remove: function(element) { - element = $(element); - element.parentNode.removeChild(element); - return element; - }, - - update: (function(){ - - var SELECT_ELEMENT_INNERHTML_BUGGY = (function(){ - var el = document.createElement("select"), - isBuggy = true; - el.innerHTML = ""; - if (el.options && el.options[0]) { - isBuggy = el.options[0].nodeName.toUpperCase() !== "OPTION"; - } - el = null; - return isBuggy; - })(); - - var TABLE_ELEMENT_INNERHTML_BUGGY = (function(){ - try { - var el = document.createElement("table"); - if (el && el.tBodies) { - el.innerHTML = "test"; - var isBuggy = typeof el.tBodies[0] == "undefined"; - el = null; - return isBuggy; - } - } catch (e) { - return true; - } - })(); - - var SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING = (function () { - var s = document.createElement("script"), - isBuggy = false; - try { - s.appendChild(document.createTextNode("")); - isBuggy = !s.firstChild || - s.firstChild && s.firstChild.nodeType !== 3; - } catch (e) { - isBuggy = true; - } - s = null; - return isBuggy; - })(); - - function update(element, content) { - element = $(element); - - var descendants = element.getElementsByTagName('*'), - i = descendants.length; - while (i--) purgeElement(descendants[i]); - - if (content && content.toElement) - content = content.toElement(); - - if (Object.isElement(content)) - return element.update().insert(content); - - content = Object.toHTML(content); - - var tagName = element.tagName.toUpperCase(); - - if (tagName === 'SCRIPT' && SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING) { - element.text = content; - return element; - } - - if (SELECT_ELEMENT_INNERHTML_BUGGY || TABLE_ELEMENT_INNERHTML_BUGGY) { - if (tagName in Element._insertionTranslations.tags) { - while (element.firstChild) { - element.removeChild(element.firstChild); - } - Element._getContentFromAnonymousElement(tagName, content.stripScripts()) - .each(function(node) { - element.appendChild(node) - }); - } - else { - element.innerHTML = content.stripScripts(); - } - } - else { - element.innerHTML = content.stripScripts(); - } - - content.evalScripts.bind(content).defer(); - return element; - } - - return update; - })(), - - replace: function(element, content) { - element = $(element); - if (content && content.toElement) content = content.toElement(); - else if (!Object.isElement(content)) { - content = Object.toHTML(content); - var range = element.ownerDocument.createRange(); - range.selectNode(element); - content.evalScripts.bind(content).defer(); - content = range.createContextualFragment(content.stripScripts()); - } - element.parentNode.replaceChild(content, element); - return element; - }, - - insert: function(element, insertions) { - element = $(element); - - if (Object.isString(insertions) || Object.isNumber(insertions) || - Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) - insertions = {bottom:insertions}; - - var content, insert, tagName, childNodes; - - for (var position in insertions) { - content = insertions[position]; - position = position.toLowerCase(); - insert = Element._insertionTranslations[position]; - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) { - insert(element, content); - continue; - } - - content = Object.toHTML(content); - - tagName = ((position == 'before' || position == 'after') - ? element.parentNode : element).tagName.toUpperCase(); - - childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); - - if (position == 'top' || position == 'after') childNodes.reverse(); - childNodes.each(insert.curry(element)); - - content.evalScripts.bind(content).defer(); - } - - return element; - }, - - wrap: function(element, wrapper, attributes) { - element = $(element); - if (Object.isElement(wrapper)) - $(wrapper).writeAttribute(attributes || { }); - else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes); - else wrapper = new Element('div', wrapper); - if (element.parentNode) - element.parentNode.replaceChild(wrapper, element); - wrapper.appendChild(element); - return wrapper; - }, - - 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(), - value = (element[property] || '').toString(); - if (value) result += ' ' + attribute + '=' + value.inspect(true); - }); - return result + '>'; - }, - - recursivelyCollect: function(element, property, maximumLength) { - element = $(element); - maximumLength = maximumLength || -1; - var elements = []; - - while (element = element[property]) { - if (element.nodeType == 1) - elements.push(Element.extend(element)); - if (elements.length == maximumLength) - break; - } - - return elements; - }, - - ancestors: function(element) { - return Element.recursivelyCollect(element, 'parentNode'); - }, - - descendants: function(element) { - return Element.select(element, "*"); - }, - - firstDescendant: function(element) { - element = $(element).firstChild; - while (element && element.nodeType != 1) element = element.nextSibling; - return $(element); - }, - - immediateDescendants: function(element) { - var results = [], child = $(element).firstChild; - while (child) { - if (child.nodeType === 1) { - results.push(Element.extend(child)); - } - child = child.nextSibling; - } - return results; - }, - - previousSiblings: function(element, maximumLength) { - return Element.recursivelyCollect(element, 'previousSibling'); - }, - - nextSiblings: function(element) { - return Element.recursivelyCollect(element, 'nextSibling'); - }, - - siblings: function(element) { - element = $(element); - return Element.previousSiblings(element).reverse() - .concat(Element.nextSiblings(element)); - }, - - match: function(element, selector) { - element = $(element); - if (Object.isString(selector)) - return Prototype.Selector.match(element, selector); - return selector.match(element); - }, - - up: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(element.parentNode); - var ancestors = Element.ancestors(element); - return Object.isNumber(expression) ? ancestors[expression] : - Prototype.Selector.find(ancestors, expression, index); - }, - - down: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return Element.firstDescendant(element); - return Object.isNumber(expression) ? Element.descendants(element)[expression] : - Element.select(element, expression)[index || 0]; - }, - - previous: function(element, expression, index) { - element = $(element); - if (Object.isNumber(expression)) index = expression, expression = false; - if (!Object.isNumber(index)) index = 0; - - if (expression) { - return Prototype.Selector.find(element.previousSiblings(), expression, index); - } else { - return element.recursivelyCollect("previousSibling", index + 1)[index]; - } - }, - - next: function(element, expression, index) { - element = $(element); - if (Object.isNumber(expression)) index = expression, expression = false; - if (!Object.isNumber(index)) index = 0; - - if (expression) { - return Prototype.Selector.find(element.nextSiblings(), expression, index); - } else { - var maximumLength = Object.isNumber(index) ? index + 1 : 1; - return element.recursivelyCollect("nextSibling", index + 1)[index]; - } - }, - - - select: function(element) { - element = $(element); - var expressions = Array.prototype.slice.call(arguments, 1).join(', '); - return Prototype.Selector.select(expressions, element); - }, - - adjacent: function(element) { - element = $(element); - var expressions = Array.prototype.slice.call(arguments, 1).join(', '); - return Prototype.Selector.select(expressions, element.parentNode).without(element); - }, - - identify: function(element) { - element = $(element); - var id = Element.readAttribute(element, 'id'); - if (id) return id; - do { id = 'anonymous_element_' + Element.idCounter++ } while ($(id)); - Element.writeAttribute(element, 'id', id); - return id; - }, - - readAttribute: function(element, name) { - element = $(element); - if (Prototype.Browser.IE) { - var t = Element._attributeTranslations.read; - if (t.values[name]) return t.values[name](element, name); - if (t.names[name]) name = t.names[name]; - if (name.include(':')) { - return (!element.attributes || !element.attributes[name]) ? null : - element.attributes[name].value; - } - } - return element.getAttribute(name); - }, - - writeAttribute: function(element, name, value) { - element = $(element); - var attributes = { }, t = Element._attributeTranslations.write; - - if (typeof name == 'object') attributes = name; - else attributes[name] = Object.isUndefined(value) ? true : value; - - for (var attr in attributes) { - name = t.names[attr] || attr; - value = attributes[attr]; - if (t.values[attr]) name = t.values[attr](element, value); - if (value === false || value === null) - element.removeAttribute(name); - else if (value === true) - element.setAttribute(name, name); - else element.setAttribute(name, value); - } - return element; - }, - - getHeight: function(element) { - return Element.getDimensions(element).height; - }, - - getWidth: function(element) { - return Element.getDimensions(element).width; - }, - - classNames: function(element) { - return new Element.ClassNames(element); - }, - - hasClassName: function(element, className) { - if (!(element = $(element))) return; - var elementClassName = element.className; - return (elementClassName.length > 0 && (elementClassName == className || - new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName))); - }, - - addClassName: function(element, className) { - if (!(element = $(element))) return; - if (!Element.hasClassName(element, className)) - element.className += (element.className ? ' ' : '') + className; - return element; - }, - - removeClassName: function(element, className) { - if (!(element = $(element))) return; - element.className = element.className.replace( - new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip(); - return element; - }, - - toggleClassName: function(element, className) { - if (!(element = $(element))) return; - return Element[Element.hasClassName(element, className) ? - 'removeClassName' : 'addClassName'](element, className); - }, - - 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.blank(); - }, - - descendantOf: function(element, ancestor) { - element = $(element), ancestor = $(ancestor); - - if (element.compareDocumentPosition) - return (element.compareDocumentPosition(ancestor) & 8) === 8; - - if (ancestor.contains) - return ancestor.contains(element) && ancestor !== element; - - while (element = element.parentNode) - if (element == ancestor) return true; - - return false; - }, - - scrollTo: function(element) { - element = $(element); - var pos = Element.cumulativeOffset(element); - window.scrollTo(pos[0], pos[1]); - return element; - }, - - getStyle: function(element, style) { - element = $(element); - style = style == 'float' ? 'cssFloat' : style.camelize(); - var value = element.style[style]; - if (!value || value == 'auto') { - var css = document.defaultView.getComputedStyle(element, null); - value = css ? css[style] : null; - } - if (style == 'opacity') return value ? parseFloat(value) : 1.0; - return value == 'auto' ? null : value; - }, - - getOpacity: function(element) { - return $(element).getStyle('opacity'); - }, - - setStyle: function(element, styles) { - element = $(element); - var elementStyle = element.style, match; - if (Object.isString(styles)) { - element.style.cssText += ';' + styles; - return styles.include('opacity') ? - element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element; - } - for (var property in styles) - if (property == 'opacity') element.setOpacity(styles[property]); - else - elementStyle[(property == 'float' || property == 'cssFloat') ? - (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') : - property] = styles[property]; - - return element; - }, - - setOpacity: function(element, value) { - element = $(element); - element.style.opacity = (value == 1 || value === '') ? '' : - (value < 0.00001) ? 0 : value; - return element; - }, - - makePositioned: function(element) { - element = $(element); - var pos = Element.getStyle(element, 'position'); - if (pos == 'static' || !pos) { - element._madePositioned = true; - element.style.position = 'relative'; - if (Prototype.Browser.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.getStyle(element, 'overflow') || 'auto'; - if (element._overflow !== '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; - }, - - cumulativeOffset: function(element) { - var valueT = 0, valueL = 0; - if (element.parentNode) { - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - } while (element); - } - return Element._returnOffset(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.toUpperCase() == 'BODY') break; - var p = Element.getStyle(element, 'position'); - if (p !== 'static') break; - } - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - absolutize: function(element) { - element = $(element); - if (Element.getStyle(element, 'position') == 'absolute') return element; - - var offsets = Element.positionedOffset(element), - top = offsets[1], - left = offsets[0], - width = element.clientWidth, - 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'; - return element; - }, - - relativize: function(element) { - element = $(element); - if (Element.getStyle(element, 'position') == 'relative') return element; - - element.style.position = 'relative'; - var top = parseFloat(element.style.top || 0) - (element._originalTop || 0), - 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; - return element; - }, - - cumulativeScrollOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.scrollTop || 0; - valueL += element.scrollLeft || 0; - element = element.parentNode; - } while (element); - return Element._returnOffset(valueL, valueT); - }, - - getOffsetParent: 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); - }, - - viewportOffset: function(forElement) { - var valueT = 0, - valueL = 0, - element = forElement; - - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - - if (element.offsetParent == document.body && - Element.getStyle(element, 'position') == 'absolute') break; - - } while (element = element.offsetParent); - - element = forElement; - do { - if (!Prototype.Browser.Opera || (element.tagName && (element.tagName.toUpperCase() == 'BODY'))) { - valueT -= element.scrollTop || 0; - valueL -= element.scrollLeft || 0; - } - } while (element = element.parentNode); - - return Element._returnOffset(valueL, valueT); - }, - - clonePosition: function(element, source) { - var options = Object.extend({ - setLeft: true, - setTop: true, - setWidth: true, - setHeight: true, - offsetTop: 0, - offsetLeft: 0 - }, arguments[2] || { }); - - source = $(source); - var p = Element.viewportOffset(source), delta = [0, 0], parent = null; - - element = $(element); - - if (Element.getStyle(element, 'position') == 'absolute') { - parent = Element.getOffsetParent(element); - delta = Element.viewportOffset(parent); - } - - if (parent == document.body) { - delta[0] -= document.body.offsetLeft; - delta[1] -= document.body.offsetTop; - } - - if (options.setLeft) element.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; - if (options.setTop) element.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; - if (options.setWidth) element.style.width = source.offsetWidth + 'px'; - if (options.setHeight) element.style.height = source.offsetHeight + 'px'; - return element; - } -}; - -Object.extend(Element.Methods, { - getElementsBySelector: Element.Methods.select, - - childElements: Element.Methods.immediateDescendants -}); - -Element._attributeTranslations = { - write: { - names: { - className: 'class', - htmlFor: 'for' - }, - values: { } - } -}; - -if (Prototype.Browser.Opera) { - Element.Methods.getStyle = Element.Methods.getStyle.wrap( - function(proceed, element, style) { - switch (style) { - case 'left': case 'top': case 'right': case 'bottom': - if (proceed(element, 'position') === 'static') return null; - case 'height': case 'width': - if (!Element.visible(element)) return null; - - var dim = parseInt(proceed(element, style), 10); - - if (dim !== element['offset' + style.capitalize()]) - return dim + 'px'; - - var properties; - if (style === 'height') { - properties = ['border-top-width', 'padding-top', - 'padding-bottom', 'border-bottom-width']; - } - else { - properties = ['border-left-width', 'padding-left', - 'padding-right', 'border-right-width']; - } - return properties.inject(dim, function(memo, property) { - var val = proceed(element, property); - return val === null ? memo : memo - parseInt(val, 10); - }) + 'px'; - default: return proceed(element, style); - } - } - ); - - Element.Methods.readAttribute = Element.Methods.readAttribute.wrap( - function(proceed, element, attribute) { - if (attribute === 'title') return element.title; - return proceed(element, attribute); - } - ); -} - -else if (Prototype.Browser.IE) { - Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap( - function(proceed, element) { - element = $(element); - if (!element.parentNode) return $(document.body); - var position = element.getStyle('position'); - if (position !== 'static') return proceed(element); - element.setStyle({ position: 'relative' }); - var value = proceed(element); - element.setStyle({ position: position }); - return value; - } - ); - - $w('positionedOffset viewportOffset').each(function(method) { - Element.Methods[method] = Element.Methods[method].wrap( - function(proceed, element) { - element = $(element); - if (!element.parentNode) return Element._returnOffset(0, 0); - var position = element.getStyle('position'); - if (position !== 'static') return proceed(element); - var offsetParent = element.getOffsetParent(); - if (offsetParent && offsetParent.getStyle('position') === 'fixed') - offsetParent.setStyle({ zoom: 1 }); - element.setStyle({ position: 'relative' }); - var value = proceed(element); - element.setStyle({ position: position }); - return value; - } - ); - }); - - Element.Methods.getStyle = function(element, style) { - element = $(element); - style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); - var value = element.style[style]; - if (!value && element.currentStyle) value = element.currentStyle[style]; - - if (style == 'opacity') { - if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) - if (value[1]) return parseFloat(value[1]) / 100; - return 1.0; - } - - if (value == 'auto') { - if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none')) - return element['offset' + style.capitalize()] + 'px'; - return null; - } - return value; - }; - - Element.Methods.setOpacity = function(element, value) { - function stripAlpha(filter){ - return filter.replace(/alpha\([^\)]*\)/gi,''); - } - element = $(element); - var currentStyle = element.currentStyle; - if ((currentStyle && !currentStyle.hasLayout) || - (!currentStyle && element.style.zoom == 'normal')) - element.style.zoom = 1; - - var filter = element.getStyle('filter'), style = element.style; - if (value == 1 || value === '') { - (filter = stripAlpha(filter)) ? - style.filter = filter : style.removeAttribute('filter'); - return element; - } else if (value < 0.00001) value = 0; - style.filter = stripAlpha(filter) + - 'alpha(opacity=' + (value * 100) + ')'; - return element; - }; - - Element._attributeTranslations = (function(){ - - var classProp = 'className', - forProp = 'for', - el = document.createElement('div'); - - el.setAttribute(classProp, 'x'); - - if (el.className !== 'x') { - el.setAttribute('class', 'x'); - if (el.className === 'x') { - classProp = 'class'; - } - } - el = null; - - el = document.createElement('label'); - el.setAttribute(forProp, 'x'); - if (el.htmlFor !== 'x') { - el.setAttribute('htmlFor', 'x'); - if (el.htmlFor === 'x') { - forProp = 'htmlFor'; - } - } - el = null; - - return { - read: { - names: { - 'class': classProp, - 'className': classProp, - 'for': forProp, - 'htmlFor': forProp - }, - values: { - _getAttr: function(element, attribute) { - return element.getAttribute(attribute); - }, - _getAttr2: function(element, attribute) { - return element.getAttribute(attribute, 2); - }, - _getAttrNode: function(element, attribute) { - var node = element.getAttributeNode(attribute); - return node ? node.value : ""; - }, - _getEv: (function(){ - - var el = document.createElement('div'), f; - el.onclick = Prototype.emptyFunction; - var value = el.getAttribute('onclick'); - - if (String(value).indexOf('{') > -1) { - f = function(element, attribute) { - attribute = element.getAttribute(attribute); - if (!attribute) return null; - attribute = attribute.toString(); - attribute = attribute.split('{')[1]; - attribute = attribute.split('}')[0]; - return attribute.strip(); - }; - } - else if (value === '') { - f = function(element, attribute) { - attribute = element.getAttribute(attribute); - if (!attribute) return null; - return attribute.strip(); - }; - } - el = null; - return f; - })(), - _flag: function(element, attribute) { - return $(element).hasAttribute(attribute) ? attribute : null; - }, - style: function(element) { - return element.style.cssText.toLowerCase(); - }, - title: function(element) { - return element.title; - } - } - } - } - })(); - - Element._attributeTranslations.write = { - names: Object.extend({ - cellpadding: 'cellPadding', - cellspacing: 'cellSpacing' - }, Element._attributeTranslations.read.names), - values: { - checked: function(element, value) { - element.checked = !!value; - }, - - style: function(element, value) { - element.style.cssText = value ? value : ''; - } - } - }; - - Element._attributeTranslations.has = {}; - - $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' + - 'encType maxLength readOnly longDesc frameBorder').each(function(attr) { - Element._attributeTranslations.write.names[attr.toLowerCase()] = attr; - Element._attributeTranslations.has[attr.toLowerCase()] = attr; - }); - - (function(v) { - Object.extend(v, { - href: v._getAttr2, - src: v._getAttr2, - type: v._getAttr, - action: v._getAttrNode, - disabled: v._flag, - checked: v._flag, - readonly: v._flag, - multiple: v._flag, - onload: v._getEv, - onunload: v._getEv, - onclick: v._getEv, - ondblclick: v._getEv, - onmousedown: v._getEv, - onmouseup: v._getEv, - onmouseover: v._getEv, - onmousemove: v._getEv, - onmouseout: v._getEv, - onfocus: v._getEv, - onblur: v._getEv, - onkeypress: v._getEv, - onkeydown: v._getEv, - onkeyup: v._getEv, - onsubmit: v._getEv, - onreset: v._getEv, - onselect: v._getEv, - onchange: v._getEv - }); - })(Element._attributeTranslations.read.values); - - if (Prototype.BrowserFeatures.ElementExtensions) { - (function() { - function _descendants(element) { - var nodes = element.getElementsByTagName('*'), results = []; - for (var i = 0, node; node = nodes[i]; i++) - if (node.tagName !== "!") // Filter out comment nodes. - results.push(node); - return results; - } - - Element.Methods.down = function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return element.firstDescendant(); - return Object.isNumber(expression) ? _descendants(element)[expression] : - Element.select(element, expression)[index || 0]; - } - })(); - } - -} - -else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) { - Element.Methods.setOpacity = function(element, value) { - element = $(element); - element.style.opacity = (value == 1) ? 0.999999 : - (value === '') ? '' : (value < 0.00001) ? 0 : value; - return element; - }; -} - -else if (Prototype.Browser.WebKit) { - Element.Methods.setOpacity = function(element, value) { - element = $(element); - element.style.opacity = (value == 1 || value === '') ? '' : - (value < 0.00001) ? 0 : value; - - if (value == 1) - if (element.tagName.toUpperCase() == 'IMG' && element.width) { - element.width++; element.width--; - } else try { - var n = document.createTextNode(' '); - element.appendChild(n); - element.removeChild(n); - } catch (e) { } - - return element; - }; - - Element.Methods.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 Element._returnOffset(valueL, valueT); - }; -} - -if ('outerHTML' in document.documentElement) { - Element.Methods.replace = function(element, content) { - element = $(element); - - if (content && content.toElement) content = content.toElement(); - if (Object.isElement(content)) { - element.parentNode.replaceChild(content, element); - return element; - } - - content = Object.toHTML(content); - var parent = element.parentNode, tagName = parent.tagName.toUpperCase(); - - if (Element._insertionTranslations.tags[tagName]) { - var nextSibling = element.next(), - fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); - parent.removeChild(element); - if (nextSibling) - fragments.each(function(node) { parent.insertBefore(node, nextSibling) }); - else - fragments.each(function(node) { parent.appendChild(node) }); - } - else element.outerHTML = content.stripScripts(); - - content.evalScripts.bind(content).defer(); - return element; - }; -} - -Element._returnOffset = function(l, t) { - var result = [l, t]; - result.left = l; - result.top = t; - return result; -}; - -Element._getContentFromAnonymousElement = function(tagName, html) { - var div = new Element('div'), - t = Element._insertionTranslations.tags[tagName]; - if (t) { - div.innerHTML = t[0] + html + t[1]; - for (var i = t[2]; i--; ) { - div = div.firstChild; - } - } - else { - div.innerHTML = html; - } - return $A(div.childNodes); -}; - -Element._insertionTranslations = { - before: function(element, node) { - element.parentNode.insertBefore(node, element); - }, - top: function(element, node) { - element.insertBefore(node, element.firstChild); - }, - bottom: function(element, node) { - element.appendChild(node); - }, - after: function(element, node) { - element.parentNode.insertBefore(node, element.nextSibling); - }, - tags: { - TABLE: ['', '
    ', 1], - TBODY: ['', '
    ', 2], - TR: ['', '
    ', 3], - TD: ['
    ', '
    ', 4], - SELECT: ['', 1] - } -}; - -(function() { - var tags = Element._insertionTranslations.tags; - Object.extend(tags, { - THEAD: tags.TBODY, - TFOOT: tags.TBODY, - TH: tags.TD - }); -})(); - -Element.Methods.Simulated = { - hasAttribute: function(element, attribute) { - attribute = Element._attributeTranslations.has[attribute] || attribute; - var node = $(element).getAttributeNode(attribute); - return !!(node && node.specified); - } -}; - -Element.Methods.ByTag = { }; - -Object.extend(Element, Element.Methods); - -(function(div) { - - if (!Prototype.BrowserFeatures.ElementExtensions && div['__proto__']) { - window.HTMLElement = { }; - window.HTMLElement.prototype = div['__proto__']; - Prototype.BrowserFeatures.ElementExtensions = true; - } - - div = null; - -})(document.createElement('div')); - -Element.extend = (function() { - - function checkDeficiency(tagName) { - if (typeof window.Element != 'undefined') { - var proto = window.Element.prototype; - if (proto) { - var id = '_' + (Math.random()+'').slice(2), - el = document.createElement(tagName); - proto[id] = 'x'; - var isBuggy = (el[id] !== 'x'); - delete proto[id]; - el = null; - return isBuggy; - } - } - return false; - } - - function extendElementWith(element, methods) { - for (var property in methods) { - var value = methods[property]; - if (Object.isFunction(value) && !(property in element)) - element[property] = value.methodize(); - } - } - - var HTMLOBJECTELEMENT_PROTOTYPE_BUGGY = checkDeficiency('object'); - - if (Prototype.BrowserFeatures.SpecificElementExtensions) { - if (HTMLOBJECTELEMENT_PROTOTYPE_BUGGY) { - return function(element) { - if (element && typeof element._extendedByPrototype == 'undefined') { - var t = element.tagName; - if (t && (/^(?:object|applet|embed)$/i.test(t))) { - extendElementWith(element, Element.Methods); - extendElementWith(element, Element.Methods.Simulated); - extendElementWith(element, Element.Methods.ByTag[t.toUpperCase()]); - } - } - return element; - } - } - return Prototype.K; - } - - var Methods = { }, ByTag = Element.Methods.ByTag; - - var extend = Object.extend(function(element) { - if (!element || typeof element._extendedByPrototype != 'undefined' || - element.nodeType != 1 || element == window) return element; - - var methods = Object.clone(Methods), - tagName = element.tagName.toUpperCase(); - - if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]); - - extendElementWith(element, methods); - - element._extendedByPrototype = Prototype.emptyFunction; - return element; - - }, { - refresh: function() { - if (!Prototype.BrowserFeatures.ElementExtensions) { - Object.extend(Methods, Element.Methods); - Object.extend(Methods, Element.Methods.Simulated); - } - } - }); - - extend.refresh(); - return extend; -})(); - -if (document.documentElement.hasAttribute) { - Element.hasAttribute = function(element, attribute) { - return element.hasAttribute(attribute); - }; -} -else { - Element.hasAttribute = Element.Methods.Simulated.hasAttribute; -} - -Element.addMethods = function(methods) { - var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; - - if (!methods) { - Object.extend(Form, Form.Methods); - Object.extend(Form.Element, Form.Element.Methods); - Object.extend(Element.Methods.ByTag, { - "FORM": Object.clone(Form.Methods), - "INPUT": Object.clone(Form.Element.Methods), - "SELECT": Object.clone(Form.Element.Methods), - "TEXTAREA": Object.clone(Form.Element.Methods) - }); - } - - if (arguments.length == 2) { - var tagName = methods; - methods = arguments[1]; - } - - if (!tagName) Object.extend(Element.Methods, methods || { }); - else { - if (Object.isArray(tagName)) tagName.each(extend); - else extend(tagName); - } - - function extend(tagName) { - tagName = tagName.toUpperCase(); - if (!Element.Methods.ByTag[tagName]) - Element.Methods.ByTag[tagName] = { }; - Object.extend(Element.Methods.ByTag[tagName], methods); - } - - function copy(methods, destination, onlyIfAbsent) { - onlyIfAbsent = onlyIfAbsent || false; - for (var property in methods) { - var value = methods[property]; - if (!Object.isFunction(value)) continue; - if (!onlyIfAbsent || !(property in destination)) - destination[property] = value.methodize(); - } - } - - function findDOMClass(tagName) { - var klass; - var trans = { - "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph", - "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList", - "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading", - "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote", - "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION": - "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD": - "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR": - "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET": - "FrameSet", "IFRAME": "IFrame" - }; - if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName.capitalize() + 'Element'; - if (window[klass]) return window[klass]; - - var element = document.createElement(tagName), - proto = element['__proto__'] || element.constructor.prototype; - - element = null; - return proto; - } - - var elementPrototype = window.HTMLElement ? HTMLElement.prototype : - Element.prototype; - - if (F.ElementExtensions) { - copy(Element.Methods, elementPrototype); - copy(Element.Methods.Simulated, elementPrototype, true); - } - - if (F.SpecificElementExtensions) { - for (var tag in Element.Methods.ByTag) { - var klass = findDOMClass(tag); - if (Object.isUndefined(klass)) continue; - copy(T[tag], klass.prototype); - } - } - - Object.extend(Element, Element.Methods); - delete Element.ByTag; - - if (Element.extend.refresh) Element.extend.refresh(); - Element.cache = { }; -}; - - -document.viewport = { - - getDimensions: function() { - return { width: this.getWidth(), height: this.getHeight() }; - }, - - getScrollOffsets: function() { - return Element._returnOffset( - window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, - window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop); - } -}; - -(function(viewport) { - var B = Prototype.Browser, doc = document, element, property = {}; - - function getRootElement() { - if (B.WebKit && !doc.evaluate) - return document; - - if (B.Opera && window.parseFloat(window.opera.version()) < 9.5) - return document.body; - - return document.documentElement; - } - - function define(D) { - if (!element) element = getRootElement(); - - property[D] = 'client' + D; - - viewport['get' + D] = function() { return element[property[D]] }; - return viewport['get' + D](); - } - - viewport.getWidth = define.curry('Width'); - - viewport.getHeight = define.curry('Height'); -})(document.viewport); - - -Element.Storage = { - UID: 1 -}; - -Element.addMethods({ - getStorage: function(element) { - if (!(element = $(element))) return; - - var uid; - if (element === window) { - uid = 0; - } else { - if (typeof element._prototypeUID === "undefined") - element._prototypeUID = Element.Storage.UID++; - uid = element._prototypeUID; - } - - if (!Element.Storage[uid]) - Element.Storage[uid] = $H(); - - return Element.Storage[uid]; - }, - - store: function(element, key, value) { - if (!(element = $(element))) return; - - if (arguments.length === 2) { - Element.getStorage(element).update(key); - } else { - Element.getStorage(element).set(key, value); - } - - return element; - }, - - retrieve: function(element, key, defaultValue) { - if (!(element = $(element))) return; - var hash = Element.getStorage(element), value = hash.get(key); - - if (Object.isUndefined(value)) { - hash.set(key, defaultValue); - value = defaultValue; - } - - return value; - }, - - clone: function(element, deep) { - if (!(element = $(element))) return; - var clone = element.cloneNode(deep); - clone._prototypeUID = void 0; - if (deep) { - var descendants = Element.select(clone, '*'), - i = descendants.length; - while (i--) { - descendants[i]._prototypeUID = void 0; - } - } - return Element.extend(clone); - }, - - purge: function(element) { - if (!(element = $(element))) return; - purgeElement(element); - - var descendants = element.getElementsByTagName('*'), - i = descendants.length; - - while (i--) purgeElement(descendants[i]); - - return null; - } -}); - -(function() { - - function toDecimal(pctString) { - var match = pctString.match(/^(\d+)%?$/i); - if (!match) return null; - return (Number(match[1]) / 100); - } - - function getPixelValue(value, property) { - if (Object.isElement(value)) { - element = value; - value = element.getStyle(property); - } - if (value === null) { - return null; - } - - if ((/^(?:-)?\d+(\.\d+)?(px)?$/i).test(value)) { - return window.parseFloat(value); - } - - if (/\d/.test(value) && element.runtimeStyle) { - var style = element.style.left, rStyle = element.runtimeStyle.left; - element.runtimeStyle.left = element.currentStyle.left; - element.style.left = value || 0; - value = element.style.pixelLeft; - element.style.left = style; - element.runtimeStyle.left = rStyle; - - return value; - } - - if (value.include('%')) { - var decimal = toDecimal(value); - var whole; - if (property.include('left') || property.include('right') || - property.include('width')) { - whole = $(element.parentNode).measure('width'); - } else if (property.include('top') || property.include('bottom') || - property.include('height')) { - whole = $(element.parentNode).measure('height'); - } - - return whole * decimal; - } - - return 0; - } - - function toCSSPixels(number) { - if (Object.isString(number) && number.endsWith('px')) { - return number; - } - return number + 'px'; - } - - function isDisplayed(element) { - var originalElement = element; - while (element && element.parentNode) { - var display = element.getStyle('display'); - if (display === 'none') { - return false; - } - element = $(element.parentNode); - } - return true; - } - - var hasLayout = Prototype.K; - if ('currentStyle' in document.documentElement) { - hasLayout = function(element) { - if (!element.currentStyle.hasLayout) { - element.style.zoom = 1; - } - return element; - }; - } - - function cssNameFor(key) { - if (key.include('border')) key = key + '-width'; - return key.camelize(); - } - - Element.Layout = Class.create(Hash, { - initialize: function($super, element, preCompute) { - $super(); - this.element = $(element); - - Element.Layout.PROPERTIES.each( function(property) { - this._set(property, null); - }, this); - - if (preCompute) { - this._preComputing = true; - this._begin(); - Element.Layout.PROPERTIES.each( this._compute, this ); - this._end(); - this._preComputing = false; - } - }, - - _set: function(property, value) { - return Hash.prototype.set.call(this, property, value); - }, - - set: function(property, value) { - throw "Properties of Element.Layout are read-only."; - }, - - get: function($super, property) { - var value = $super(property); - return value === null ? this._compute(property) : value; - }, - - _begin: function() { - if (this._prepared) return; - - var element = this.element; - if (isDisplayed(element)) { - this._prepared = true; - return; - } - - var originalStyles = { - position: element.style.position || '', - width: element.style.width || '', - visibility: element.style.visibility || '', - display: element.style.display || '' - }; - - element.store('prototype_original_styles', originalStyles); - - var position = element.getStyle('position'), - width = element.getStyle('width'); - - element.setStyle({ - position: 'absolute', - visibility: 'hidden', - display: 'block' - }); - - var positionedWidth = element.getStyle('width'); - - var newWidth; - if (width && (positionedWidth === width)) { - newWidth = getPixelValue(width); - } else if (width && (position === 'absolute' || position === 'fixed')) { - newWidth = getPixelValue(width); - } else { - var parent = element.parentNode, pLayout = $(parent).getLayout(); - - newWidth = pLayout.get('width') - - this.get('margin-left') - - this.get('border-left') - - this.get('padding-left') - - this.get('padding-right') - - this.get('border-right') - - this.get('margin-right'); - } - - element.setStyle({ width: newWidth + 'px' }); - - this._prepared = true; - }, - - _end: function() { - var element = this.element; - var originalStyles = element.retrieve('prototype_original_styles'); - element.store('prototype_original_styles', null); - element.setStyle(originalStyles); - this._prepared = false; - }, - - _compute: function(property) { - var COMPUTATIONS = Element.Layout.COMPUTATIONS; - if (!(property in COMPUTATIONS)) { - throw "Property not found."; - } - return this._set(property, COMPUTATIONS[property].call(this, this.element)); - }, - - toObject: function() { - var args = $A(arguments); - var keys = (args.length === 0) ? Element.Layout.PROPERTIES : - args.join(' ').split(' '); - var obj = {}; - keys.each( function(key) { - if (!Element.Layout.PROPERTIES.include(key)) return; - var value = this.get(key); - if (value != null) obj[key] = value; - }, this); - return obj; - }, - - toHash: function() { - var obj = this.toObject.apply(this, arguments); - return new Hash(obj); - }, - - toCSS: function() { - var args = $A(arguments); - var keys = (args.length === 0) ? Element.Layout.PROPERTIES : - args.join(' ').split(' '); - var css = {}; - - keys.each( function(key) { - if (!Element.Layout.PROPERTIES.include(key)) return; - if (Element.Layout.COMPOSITE_PROPERTIES.include(key)) return; - - var value = this.get(key); - if (value != null) css[cssNameFor(key)] = value + 'px'; - }, this); - return css; - }, - - inspect: function() { - return "#"; - } - }); - - Object.extend(Element.Layout, { - PROPERTIES: $w('height width top left right bottom border-left border-right border-top border-bottom padding-left padding-right padding-top padding-bottom margin-top margin-bottom margin-left margin-right padding-box-width padding-box-height border-box-width border-box-height margin-box-width margin-box-height'), - - COMPOSITE_PROPERTIES: $w('padding-box-width padding-box-height margin-box-width margin-box-height border-box-width border-box-height'), - - COMPUTATIONS: { - 'height': function(element) { - if (!this._preComputing) this._begin(); - - var bHeight = this.get('border-box-height'); - if (bHeight <= 0) return 0; - - var bTop = this.get('border-top'), - bBottom = this.get('border-bottom'); - - var pTop = this.get('padding-top'), - pBottom = this.get('padding-bottom'); - - if (!this._preComputing) this._end(); - - return bHeight - bTop - bBottom - pTop - pBottom; - }, - - 'width': function(element) { - if (!this._preComputing) this._begin(); - - var bWidth = this.get('border-box-width'); - if (bWidth <= 0) return 0; - - var bLeft = this.get('border-left'), - bRight = this.get('border-right'); - - var pLeft = this.get('padding-left'), - pRight = this.get('padding-right'); - - if (!this._preComputing) this._end(); - - return bWidth - bLeft - bRight - pLeft - pRight; - }, - - 'padding-box-height': function(element) { - var height = this.get('height'), - pTop = this.get('padding-top'), - pBottom = this.get('padding-bottom'); - - return height + pTop + pBottom; - }, - - 'padding-box-width': function(element) { - var width = this.get('width'), - pLeft = this.get('padding-left'), - pRight = this.get('padding-right'); - - return width + pLeft + pRight; - }, - - 'border-box-height': function(element) { - return element.offsetHeight; - }, - - 'border-box-width': function(element) { - return element.offsetWidth; - }, - - 'margin-box-height': function(element) { - var bHeight = this.get('border-box-height'), - mTop = this.get('margin-top'), - mBottom = this.get('margin-bottom'); - - if (bHeight <= 0) return 0; - - return bHeight + mTop + mBottom; - }, - - 'margin-box-width': function(element) { - var bWidth = this.get('border-box-width'), - mLeft = this.get('margin-left'), - mRight = this.get('margin-right'); - - if (bWidth <= 0) return 0; - - return bWidth + mLeft + mRight; - }, - - 'top': function(element) { - var offset = element.positionedOffset(); - return offset.top; - }, - - 'bottom': function(element) { - var offset = element.positionedOffset(), - parent = element.getOffsetParent(), - pHeight = parent.measure('height'); - - var mHeight = this.get('border-box-height'); - - return pHeight - mHeight - offset.top; - }, - - 'left': function(element) { - var offset = element.positionedOffset(); - return offset.left; - }, - - 'right': function(element) { - var offset = element.positionedOffset(), - parent = element.getOffsetParent(), - pWidth = parent.measure('width'); - - var mWidth = this.get('border-box-width'); - - return pWidth - mWidth - offset.left; - }, - - 'padding-top': function(element) { - return getPixelValue(element, 'paddingTop'); - }, - - 'padding-bottom': function(element) { - return getPixelValue(element, 'paddingBottom'); - }, - - 'padding-left': function(element) { - return getPixelValue(element, 'paddingLeft'); - }, - - 'padding-right': function(element) { - return getPixelValue(element, 'paddingRight'); - }, - - 'border-top': function(element) { - return Object.isNumber(element.clientTop) ? element.clientTop : - getPixelValue(element, 'borderTopWidth'); - }, - - 'border-bottom': function(element) { - return Object.isNumber(element.clientBottom) ? element.clientBottom : - getPixelValue(element, 'borderBottomWidth'); - }, - - 'border-left': function(element) { - return Object.isNumber(element.clientLeft) ? element.clientLeft : - getPixelValue(element, 'borderLeftWidth'); - }, - - 'border-right': function(element) { - return Object.isNumber(element.clientRight) ? element.clientRight : - getPixelValue(element, 'borderRightWidth'); - }, - - 'margin-top': function(element) { - return getPixelValue(element, 'marginTop'); - }, - - 'margin-bottom': function(element) { - return getPixelValue(element, 'marginBottom'); - }, - - 'margin-left': function(element) { - return getPixelValue(element, 'marginLeft'); - }, - - 'margin-right': function(element) { - return getPixelValue(element, 'marginRight'); - } - } - }); - - if ('getBoundingClientRect' in document.documentElement) { - Object.extend(Element.Layout.COMPUTATIONS, { - 'right': function(element) { - var parent = hasLayout(element.getOffsetParent()); - var rect = element.getBoundingClientRect(), - pRect = parent.getBoundingClientRect(); - - return (pRect.right - rect.right).round(); - }, - - 'bottom': function(element) { - var parent = hasLayout(element.getOffsetParent()); - var rect = element.getBoundingClientRect(), - pRect = parent.getBoundingClientRect(); - - return (pRect.bottom - rect.bottom).round(); - } - }); - } - - Element.Offset = Class.create({ - initialize: function(left, top) { - this.left = left.round(); - this.top = top.round(); - - this[0] = this.left; - this[1] = this.top; - }, - - relativeTo: function(offset) { - return new Element.Offset( - this.left - offset.left, - this.top - offset.top - ); - }, - - inspect: function() { - return "#".interpolate(this); - }, - - toString: function() { - return "[#{left}, #{top}]".interpolate(this); - }, - - toArray: function() { - return [this.left, this.top]; - } - }); - - function getLayout(element, preCompute) { - return new Element.Layout(element, preCompute); - } - - function measure(element, property) { - return $(element).getLayout().get(property); - } - - function getDimensions(element) { - var layout = $(element).getLayout(); - return { - width: layout.get('width'), - height: layout.get('height') - }; - } - - function getOffsetParent(element) { - if (isDetached(element)) return $(document.body); - - var isInline = (Element.getStyle(element, 'display') === 'inline'); - if (!isInline && 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.nodeName === 'HTML') ? $(document.body) : $(element); - } - } - - return $(document.body); - } - - - function cumulativeOffset(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - } while (element); - return new Element.Offset(valueL, valueT); - } - - function positionedOffset(element) { - var layout = element.getLayout(); - - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - if (element) { - if (isBody(element)) break; - var p = Element.getStyle(element, 'position'); - if (p !== 'static') break; - } - } while (element); - - valueL -= layout.get('margin-top'); - valueT -= layout.get('margin-left'); - - return new Element.Offset(valueL, valueT); - } - - function cumulativeScrollOffset(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.scrollTop || 0; - valueL += element.scrollLeft || 0; - element = element.parentNode; - } while (element); - return new Element.Offset(valueL, valueT); - } - - function viewportOffset(forElement) { - var valueT = 0, valueL = 0, docBody = document.body; - - var element = forElement; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - if (element.offsetParent == docBody && - Element.getStyle(element, 'position') == 'absolute') break; - } while (element = element.offsetParent); - - element = forElement; - do { - if (element != docBody) { - valueT -= element.scrollTop || 0; - valueL -= element.scrollLeft || 0; - } - } while (element = element.parentNode); - return new Element.Offset(valueL, valueT); - } - - function absolutize(element) { - element = $(element); - - if (Element.getStyle(element, 'position') === 'absolute') { - return element; - } - - var offsetParent = getOffsetParent(element); - var eOffset = element.viewportOffset(), - pOffset = offsetParent.viewportOffset(); - - var offset = eOffset.relativeTo(pOffset); - var layout = element.getLayout(); - - element.store('prototype_absolutize_original_styles', { - left: element.getStyle('left'), - top: element.getStyle('top'), - width: element.getStyle('width'), - height: element.getStyle('height') - }); - - element.setStyle({ - position: 'absolute', - top: offset.top + 'px', - left: offset.left + 'px', - width: layout.get('width') + 'px', - height: layout.get('height') + 'px' - }); - - return element; - } - - function relativize(element) { - element = $(element); - if (Element.getStyle(element, 'position') === 'relative') { - return element; - } - - var originalStyles = - element.retrieve('prototype_absolutize_original_styles'); - - if (originalStyles) element.setStyle(originalStyles); - return element; - } - - Element.addMethods({ - getLayout: getLayout, - measure: measure, - getDimensions: getDimensions, - getOffsetParent: getOffsetParent, - cumulativeOffset: cumulativeOffset, - positionedOffset: positionedOffset, - cumulativeScrollOffset: cumulativeScrollOffset, - viewportOffset: viewportOffset, - absolutize: absolutize, - relativize: relativize - }); - - function isBody(element) { - return element.nodeName.toUpperCase() === 'BODY'; - } - - function isDetached(element) { - return element !== document.body && - !Element.descendantOf(element, document.body); - } - - if ('getBoundingClientRect' in document.documentElement) { - Element.addMethods({ - viewportOffset: function(element) { - element = $(element); - if (isDetached(element)) return new Element.Offset(0, 0); - - var rect = element.getBoundingClientRect(), - docEl = document.documentElement; - return new Element.Offset(rect.left - docEl.clientLeft, - rect.top - docEl.clientTop); - }, - - positionedOffset: function(element) { - element = $(element); - var parent = element.getOffsetParent(); - if (isDetached(element)) return new Element.Offset(0, 0); - - if (element.offsetParent && - element.offsetParent.nodeName.toUpperCase() === 'HTML') { - return positionedOffset(element); - } - - var eOffset = element.viewportOffset(), - pOffset = isBody(parent) ? viewportOffset(parent) : - parent.viewportOffset(); - var retOffset = eOffset.relativeTo(pOffset); - - var layout = element.getLayout(); - var top = retOffset.top - layout.get('margin-top'); - var left = retOffset.left - layout.get('margin-left'); - - return new Element.Offset(left, top); - } - }); - } -})(); -window.$$ = function() { - var expression = $A(arguments).join(', '); - return Prototype.Selector.select(expression, document); -}; - -Prototype.Selector = (function() { - - function select() { - throw new Error('Method "Prototype.Selector.select" must be defined.'); - } - - function match() { - throw new Error('Method "Prototype.Selector.match" must be defined.'); - } - - function find(elements, expression, index) { - index = index || 0; - var match = Prototype.Selector.match, length = elements.length, matchIndex = 0, i; - - for (i = 0; i < length; i++) { - if (match(elements[i], expression) && index == matchIndex++) { - return Element.extend(elements[i]); - } - } - } - - function extendElements(elements) { - for (var i = 0, length = elements.length; i < length; i++) { - Element.extend(elements[i]); - } - return elements; - } - - - var K = Prototype.K; - - return { - select: select, - match: match, - find: find, - extendElements: (Element.extend === K) ? K : extendElements, - extendElement: Element.extend - }; -})(); -Prototype._original_property = window.Sizzle; -/*! - * Sizzle CSS Selector Engine - v1.0 - * Copyright 2009, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * More information: http://sizzlejs.com/ - */ -(function(){ - -var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, - done = 0, - toString = Object.prototype.toString, - hasDuplicate = false, - baseHasDuplicate = true; - -[0, 0].sort(function(){ - baseHasDuplicate = false; - return 0; -}); - -var Sizzle = function(selector, context, results, seed) { - results = results || []; - var origContext = context = context || document; - - if ( context.nodeType !== 1 && context.nodeType !== 9 ) { - return []; - } - - if ( !selector || typeof selector !== "string" ) { - return results; - } - - var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context), - soFar = selector; - - while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) { - soFar = m[3]; - - parts.push( m[1] ); - - if ( m[2] ) { - extra = m[3]; - break; - } - } - - if ( parts.length > 1 && origPOS.exec( selector ) ) { - if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { - set = posProcess( parts[0] + parts[1], context ); - } else { - set = Expr.relative[ parts[0] ] ? - [ context ] : - Sizzle( parts.shift(), context ); - - while ( parts.length ) { - selector = parts.shift(); - - if ( Expr.relative[ selector ] ) - selector += parts.shift(); - - set = posProcess( selector, set ); - } - } - } else { - if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && - Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { - var ret = Sizzle.find( parts.shift(), context, contextXML ); - context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0]; - } - - if ( context ) { - var ret = seed ? - { expr: parts.pop(), set: makeArray(seed) } : - Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); - set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set; - - if ( parts.length > 0 ) { - checkSet = makeArray(set); - } else { - prune = false; - } - - while ( parts.length ) { - var cur = parts.pop(), pop = cur; - - if ( !Expr.relative[ cur ] ) { - cur = ""; - } else { - pop = parts.pop(); - } - - if ( pop == null ) { - pop = context; - } - - Expr.relative[ cur ]( checkSet, pop, contextXML ); - } - } else { - checkSet = parts = []; - } - } - - if ( !checkSet ) { - checkSet = set; - } - - if ( !checkSet ) { - throw "Syntax error, unrecognized expression: " + (cur || selector); - } - - if ( toString.call(checkSet) === "[object Array]" ) { - if ( !prune ) { - results.push.apply( results, checkSet ); - } else if ( context && context.nodeType === 1 ) { - for ( var i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { - results.push( set[i] ); - } - } - } else { - for ( var i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && checkSet[i].nodeType === 1 ) { - results.push( set[i] ); - } - } - } - } else { - makeArray( checkSet, results ); - } - - if ( extra ) { - Sizzle( extra, origContext, results, seed ); - Sizzle.uniqueSort( results ); - } - - return results; -}; - -Sizzle.uniqueSort = function(results){ - if ( sortOrder ) { - hasDuplicate = baseHasDuplicate; - results.sort(sortOrder); - - if ( hasDuplicate ) { - for ( var i = 1; i < results.length; i++ ) { - if ( results[i] === results[i-1] ) { - results.splice(i--, 1); - } - } - } - } - - return results; -}; - -Sizzle.matches = function(expr, set){ - return Sizzle(expr, null, null, set); -}; - -Sizzle.find = function(expr, context, isXML){ - var set, match; - - if ( !expr ) { - return []; - } - - for ( var i = 0, l = Expr.order.length; i < l; i++ ) { - var type = Expr.order[i], match; - - if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { - var left = match[1]; - match.splice(1,1); - - if ( left.substr( left.length - 1 ) !== "\\" ) { - match[1] = (match[1] || "").replace(/\\/g, ""); - set = Expr.find[ type ]( match, context, isXML ); - if ( set != null ) { - expr = expr.replace( Expr.match[ type ], "" ); - break; - } - } - } - } - - if ( !set ) { - set = context.getElementsByTagName("*"); - } - - return {set: set, expr: expr}; -}; - -Sizzle.filter = function(expr, set, inplace, not){ - var old = expr, result = [], curLoop = set, match, anyFound, - isXMLFilter = set && set[0] && isXML(set[0]); - - while ( expr && set.length ) { - for ( var type in Expr.filter ) { - if ( (match = Expr.match[ type ].exec( expr )) != null ) { - var filter = Expr.filter[ type ], found, item; - anyFound = false; - - if ( curLoop == result ) { - result = []; - } - - if ( Expr.preFilter[ type ] ) { - match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); - - if ( !match ) { - anyFound = found = true; - } else if ( match === true ) { - continue; - } - } - - if ( match ) { - for ( var i = 0; (item = curLoop[i]) != null; i++ ) { - if ( item ) { - found = filter( item, match, i, curLoop ); - var pass = not ^ !!found; - - if ( inplace && found != null ) { - if ( pass ) { - anyFound = true; - } else { - curLoop[i] = false; - } - } else if ( pass ) { - result.push( item ); - anyFound = true; - } - } - } - } - - if ( found !== undefined ) { - if ( !inplace ) { - curLoop = result; - } - - expr = expr.replace( Expr.match[ type ], "" ); - - if ( !anyFound ) { - return []; - } - - break; - } - } - } - - if ( expr == old ) { - if ( anyFound == null ) { - throw "Syntax error, unrecognized expression: " + expr; - } else { - break; - } - } - - old = expr; - } - - return curLoop; -}; - -var Expr = Sizzle.selectors = { - order: [ "ID", "NAME", "TAG" ], - match: { - ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/, - CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/, - NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/, - ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, - TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/, - CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/, - POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/, - PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/ - }, - leftMatch: {}, - attrMap: { - "class": "className", - "for": "htmlFor" - }, - attrHandle: { - href: function(elem){ - return elem.getAttribute("href"); - } - }, - relative: { - "+": function(checkSet, part, isXML){ - var isPartStr = typeof part === "string", - isTag = isPartStr && !/\W/.test(part), - isPartStrNotTag = isPartStr && !isTag; - - if ( isTag && !isXML ) { - part = part.toUpperCase(); - } - - for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { - if ( (elem = checkSet[i]) ) { - while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} - - checkSet[i] = isPartStrNotTag || elem && elem.nodeName === part ? - elem || false : - elem === part; - } - } - - if ( isPartStrNotTag ) { - Sizzle.filter( part, checkSet, true ); - } - }, - ">": function(checkSet, part, isXML){ - var isPartStr = typeof part === "string"; - - if ( isPartStr && !/\W/.test(part) ) { - part = isXML ? part : part.toUpperCase(); - - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - if ( elem ) { - var parent = elem.parentNode; - checkSet[i] = parent.nodeName === part ? parent : false; - } - } - } else { - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - if ( elem ) { - checkSet[i] = isPartStr ? - elem.parentNode : - elem.parentNode === part; - } - } - - if ( isPartStr ) { - Sizzle.filter( part, checkSet, true ); - } - } - }, - "": function(checkSet, part, isXML){ - var doneName = done++, checkFn = dirCheck; - - if ( !/\W/.test(part) ) { - var nodeCheck = part = isXML ? part : part.toUpperCase(); - checkFn = dirNodeCheck; - } - - checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); - }, - "~": function(checkSet, part, isXML){ - var doneName = done++, checkFn = dirCheck; - - if ( typeof part === "string" && !/\W/.test(part) ) { - var nodeCheck = part = isXML ? part : part.toUpperCase(); - checkFn = dirNodeCheck; - } - - checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); - } - }, - find: { - ID: function(match, context, isXML){ - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); - return m ? [m] : []; - } - }, - NAME: function(match, context, isXML){ - if ( typeof context.getElementsByName !== "undefined" ) { - var ret = [], results = context.getElementsByName(match[1]); - - for ( var i = 0, l = results.length; i < l; i++ ) { - if ( results[i].getAttribute("name") === match[1] ) { - ret.push( results[i] ); - } - } - - return ret.length === 0 ? null : ret; - } - }, - TAG: function(match, context){ - return context.getElementsByTagName(match[1]); - } - }, - preFilter: { - CLASS: function(match, curLoop, inplace, result, not, isXML){ - match = " " + match[1].replace(/\\/g, "") + " "; - - if ( isXML ) { - return match; - } - - for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { - if ( elem ) { - if ( not ^ (elem.className && (" " + elem.className + " ").indexOf(match) >= 0) ) { - if ( !inplace ) - result.push( elem ); - } else if ( inplace ) { - curLoop[i] = false; - } - } - } - - return false; - }, - ID: function(match){ - return match[1].replace(/\\/g, ""); - }, - TAG: function(match, curLoop){ - for ( var i = 0; curLoop[i] === false; i++ ){} - return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase(); - }, - CHILD: function(match){ - if ( match[1] == "nth" ) { - var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( - match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" || - !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); - - match[2] = (test[1] + (test[2] || 1)) - 0; - match[3] = test[3] - 0; - } - - match[0] = done++; - - return match; - }, - ATTR: function(match, curLoop, inplace, result, not, isXML){ - var name = match[1].replace(/\\/g, ""); - - if ( !isXML && Expr.attrMap[name] ) { - match[1] = Expr.attrMap[name]; - } - - if ( match[2] === "~=" ) { - match[4] = " " + match[4] + " "; - } - - return match; - }, - PSEUDO: function(match, curLoop, inplace, result, not){ - if ( match[1] === "not" ) { - if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { - match[3] = Sizzle(match[3], null, null, curLoop); - } else { - var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); - if ( !inplace ) { - result.push.apply( result, ret ); - } - return false; - } - } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { - return true; - } - - return match; - }, - POS: function(match){ - match.unshift( true ); - return match; - } - }, - filters: { - enabled: function(elem){ - return elem.disabled === false && elem.type !== "hidden"; - }, - disabled: function(elem){ - return elem.disabled === true; - }, - checked: function(elem){ - return elem.checked === true; - }, - selected: function(elem){ - elem.parentNode.selectedIndex; - return elem.selected === true; - }, - parent: function(elem){ - return !!elem.firstChild; - }, - empty: function(elem){ - return !elem.firstChild; - }, - has: function(elem, i, match){ - return !!Sizzle( match[3], elem ).length; - }, - header: function(elem){ - return /h\d/i.test( elem.nodeName ); - }, - text: function(elem){ - return "text" === elem.type; - }, - radio: function(elem){ - return "radio" === elem.type; - }, - checkbox: function(elem){ - return "checkbox" === elem.type; - }, - file: function(elem){ - return "file" === elem.type; - }, - password: function(elem){ - return "password" === elem.type; - }, - submit: function(elem){ - return "submit" === elem.type; - }, - image: function(elem){ - return "image" === elem.type; - }, - reset: function(elem){ - return "reset" === elem.type; - }, - button: function(elem){ - return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON"; - }, - input: function(elem){ - return /input|select|textarea|button/i.test(elem.nodeName); - } - }, - setFilters: { - first: function(elem, i){ - return i === 0; - }, - last: function(elem, i, match, array){ - return i === array.length - 1; - }, - even: function(elem, i){ - return i % 2 === 0; - }, - odd: function(elem, i){ - return i % 2 === 1; - }, - lt: function(elem, i, match){ - return i < match[3] - 0; - }, - gt: function(elem, i, match){ - return i > match[3] - 0; - }, - nth: function(elem, i, match){ - return match[3] - 0 == i; - }, - eq: function(elem, i, match){ - return match[3] - 0 == i; - } - }, - filter: { - PSEUDO: function(elem, match, i, array){ - var name = match[1], filter = Expr.filters[ name ]; - - if ( filter ) { - return filter( elem, i, match, array ); - } else if ( name === "contains" ) { - return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0; - } else if ( name === "not" ) { - var not = match[3]; - - for ( var i = 0, l = not.length; i < l; i++ ) { - if ( not[i] === elem ) { - return false; - } - } - - return true; - } - }, - CHILD: function(elem, match){ - var type = match[1], node = elem; - switch (type) { - case 'only': - case 'first': - while ( (node = node.previousSibling) ) { - if ( node.nodeType === 1 ) return false; - } - if ( type == 'first') return true; - node = elem; - case 'last': - while ( (node = node.nextSibling) ) { - if ( node.nodeType === 1 ) return false; - } - return true; - case 'nth': - var first = match[2], last = match[3]; - - if ( first == 1 && last == 0 ) { - return true; - } - - var doneName = match[0], - parent = elem.parentNode; - - if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { - var count = 0; - for ( node = parent.firstChild; node; node = node.nextSibling ) { - if ( node.nodeType === 1 ) { - node.nodeIndex = ++count; - } - } - parent.sizcache = doneName; - } - - var diff = elem.nodeIndex - last; - if ( first == 0 ) { - return diff == 0; - } else { - return ( diff % first == 0 && diff / first >= 0 ); - } - } - }, - ID: function(elem, match){ - return elem.nodeType === 1 && elem.getAttribute("id") === match; - }, - TAG: function(elem, match){ - return (match === "*" && elem.nodeType === 1) || elem.nodeName === match; - }, - CLASS: function(elem, match){ - return (" " + (elem.className || elem.getAttribute("class")) + " ") - .indexOf( match ) > -1; - }, - ATTR: function(elem, match){ - var name = match[1], - result = Expr.attrHandle[ name ] ? - Expr.attrHandle[ name ]( elem ) : - elem[ name ] != null ? - elem[ name ] : - elem.getAttribute( name ), - value = result + "", - type = match[2], - check = match[4]; - - return result == null ? - type === "!=" : - type === "=" ? - value === check : - type === "*=" ? - value.indexOf(check) >= 0 : - type === "~=" ? - (" " + value + " ").indexOf(check) >= 0 : - !check ? - value && result !== false : - type === "!=" ? - value != check : - type === "^=" ? - value.indexOf(check) === 0 : - type === "$=" ? - value.substr(value.length - check.length) === check : - type === "|=" ? - value === check || value.substr(0, check.length + 1) === check + "-" : - false; - }, - POS: function(elem, match, i, array){ - var name = match[2], filter = Expr.setFilters[ name ]; - - if ( filter ) { - return filter( elem, i, match, array ); - } - } - } -}; - -var origPOS = Expr.match.POS; - -for ( var type in Expr.match ) { - Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); - Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source ); -} - -var makeArray = function(array, results) { - array = Array.prototype.slice.call( array, 0 ); - - if ( results ) { - results.push.apply( results, array ); - return results; - } - - return array; -}; - -try { - Array.prototype.slice.call( document.documentElement.childNodes, 0 ); - -} catch(e){ - makeArray = function(array, results) { - var ret = results || []; - - if ( toString.call(array) === "[object Array]" ) { - Array.prototype.push.apply( ret, array ); - } else { - if ( typeof array.length === "number" ) { - for ( var i = 0, l = array.length; i < l; i++ ) { - ret.push( array[i] ); - } - } else { - for ( var i = 0; array[i]; i++ ) { - ret.push( array[i] ); - } - } - } - - return ret; - }; -} - -var sortOrder; - -if ( document.documentElement.compareDocumentPosition ) { - sortOrder = function( a, b ) { - if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { - if ( a == b ) { - hasDuplicate = true; - } - return 0; - } - - var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; - if ( ret === 0 ) { - hasDuplicate = true; - } - return ret; - }; -} else if ( "sourceIndex" in document.documentElement ) { - sortOrder = function( a, b ) { - if ( !a.sourceIndex || !b.sourceIndex ) { - if ( a == b ) { - hasDuplicate = true; - } - return 0; - } - - var ret = a.sourceIndex - b.sourceIndex; - if ( ret === 0 ) { - hasDuplicate = true; - } - return ret; - }; -} else if ( document.createRange ) { - sortOrder = function( a, b ) { - if ( !a.ownerDocument || !b.ownerDocument ) { - if ( a == b ) { - hasDuplicate = true; - } - return 0; - } - - var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); - aRange.setStart(a, 0); - aRange.setEnd(a, 0); - bRange.setStart(b, 0); - bRange.setEnd(b, 0); - var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange); - if ( ret === 0 ) { - hasDuplicate = true; - } - return ret; - }; -} - -(function(){ - var form = document.createElement("div"), - id = "script" + (new Date).getTime(); - form.innerHTML = ""; - - var root = document.documentElement; - root.insertBefore( form, root.firstChild ); - - if ( !!document.getElementById( id ) ) { - Expr.find.ID = function(match, context, isXML){ - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); - return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []; - } - }; - - Expr.filter.ID = function(elem, match){ - var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); - return elem.nodeType === 1 && node && node.nodeValue === match; - }; - } - - root.removeChild( form ); - root = form = null; // release memory in IE -})(); - -(function(){ - - var div = document.createElement("div"); - div.appendChild( document.createComment("") ); - - if ( div.getElementsByTagName("*").length > 0 ) { - Expr.find.TAG = function(match, context){ - var results = context.getElementsByTagName(match[1]); - - if ( match[1] === "*" ) { - var tmp = []; - - for ( var i = 0; results[i]; i++ ) { - if ( results[i].nodeType === 1 ) { - tmp.push( results[i] ); - } - } - - results = tmp; - } - - return results; - }; - } - - div.innerHTML = ""; - if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && - div.firstChild.getAttribute("href") !== "#" ) { - Expr.attrHandle.href = function(elem){ - return elem.getAttribute("href", 2); - }; - } - - div = null; // release memory in IE -})(); - -if ( document.querySelectorAll ) (function(){ - var oldSizzle = Sizzle, div = document.createElement("div"); - div.innerHTML = "

    "; - - if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { - return; - } - - Sizzle = function(query, context, extra, seed){ - context = context || document; - - if ( !seed && context.nodeType === 9 && !isXML(context) ) { - try { - return makeArray( context.querySelectorAll(query), extra ); - } catch(e){} - } - - return oldSizzle(query, context, extra, seed); - }; - - for ( var prop in oldSizzle ) { - Sizzle[ prop ] = oldSizzle[ prop ]; - } - - div = null; // release memory in IE -})(); - -if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ - var div = document.createElement("div"); - div.innerHTML = "
    "; - - if ( div.getElementsByClassName("e").length === 0 ) - return; - - div.lastChild.className = "e"; - - if ( div.getElementsByClassName("e").length === 1 ) - return; - - Expr.order.splice(1, 0, "CLASS"); - Expr.find.CLASS = function(match, context, isXML) { - if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { - return context.getElementsByClassName(match[1]); - } - }; - - div = null; // release memory in IE -})(); - -function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - var sibDir = dir == "previousSibling" && !isXML; - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - if ( elem ) { - if ( sibDir && elem.nodeType === 1 ){ - elem.sizcache = doneName; - elem.sizset = i; - } - elem = elem[dir]; - var match = false; - - while ( elem ) { - if ( elem.sizcache === doneName ) { - match = checkSet[elem.sizset]; - break; - } - - if ( elem.nodeType === 1 && !isXML ){ - elem.sizcache = doneName; - elem.sizset = i; - } - - if ( elem.nodeName === cur ) { - match = elem; - break; - } - - elem = elem[dir]; - } - - checkSet[i] = match; - } - } -} - -function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - var sibDir = dir == "previousSibling" && !isXML; - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - if ( elem ) { - if ( sibDir && elem.nodeType === 1 ) { - elem.sizcache = doneName; - elem.sizset = i; - } - elem = elem[dir]; - var match = false; - - while ( elem ) { - if ( elem.sizcache === doneName ) { - match = checkSet[elem.sizset]; - break; - } - - if ( elem.nodeType === 1 ) { - if ( !isXML ) { - elem.sizcache = doneName; - elem.sizset = i; - } - if ( typeof cur !== "string" ) { - if ( elem === cur ) { - match = true; - break; - } - - } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { - match = elem; - break; - } - } - - elem = elem[dir]; - } - - checkSet[i] = match; - } - } -} - -var contains = document.compareDocumentPosition ? function(a, b){ - return a.compareDocumentPosition(b) & 16; -} : function(a, b){ - return a !== b && (a.contains ? a.contains(b) : true); -}; - -var isXML = function(elem){ - return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || - !!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML"; -}; - -var posProcess = function(selector, context){ - var tmpSet = [], later = "", match, - root = context.nodeType ? [context] : context; - - while ( (match = Expr.match.PSEUDO.exec( selector )) ) { - later += match[0]; - selector = selector.replace( Expr.match.PSEUDO, "" ); - } - - selector = Expr.relative[selector] ? selector + "*" : selector; - - for ( var i = 0, l = root.length; i < l; i++ ) { - Sizzle( selector, root[i], tmpSet ); - } - - return Sizzle.filter( later, tmpSet ); -}; - - -window.Sizzle = Sizzle; - -})(); - -;(function(engine) { - var extendElements = Prototype.Selector.extendElements; - - function select(selector, scope) { - return extendElements(engine(selector, scope || document)); - } - - function match(element, selector) { - return engine.matches(selector, [element]).length == 1; - } - - Prototype.Selector.engine = engine; - Prototype.Selector.select = select; - Prototype.Selector.match = match; -})(Sizzle); - -window.Sizzle = Prototype._original_property; -delete Prototype._original_property; - -var Form = { - reset: function(form) { - form = $(form); - form.reset(); - return form; - }, - - serializeElements: function(elements, options) { - if (typeof options != 'object') options = { hash: !!options }; - else if (Object.isUndefined(options.hash)) options.hash = true; - var key, value, submitted = false, submit = options.submit; - - var data = elements.inject({ }, function(result, element) { - if (!element.disabled && element.name) { - key = element.name; value = $(element).getValue(); - if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted && - submit !== false && (!submit || key == submit) && (submitted = true)))) { - if (key in result) { - if (!Object.isArray(result[key])) result[key] = [result[key]]; - result[key].push(value); - } - else result[key] = value; - } - } - return result; - }); - - return options.hash ? data : Object.toQueryString(data); - } -}; - -Form.Methods = { - serialize: function(form, options) { - return Form.serializeElements(Form.getElements(form), options); - }, - - getElements: function(form) { - var elements = $(form).getElementsByTagName('*'), - element, - arr = [ ], - serializers = Form.Element.Serializers; - for (var i = 0; element = elements[i]; i++) { - arr.push(element); - } - return arr.inject([], function(elements, child) { - if (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(form).invoke('disable'); - return form; - }, - - enable: function(form) { - form = $(form); - Form.getElements(form).invoke('enable'); - return form; - }, - - findFirstElement: function(form) { - var elements = $(form).getElements().findAll(function(element) { - return 'hidden' != element.type && !element.disabled; - }); - var firstByIndex = elements.findAll(function(element) { - return element.hasAttribute('tabIndex') && element.tabIndex >= 0; - }).sortBy(function(element) { return element.tabIndex }).first(); - - return firstByIndex ? firstByIndex : elements.find(function(element) { - return /^(?:input|select|textarea)$/i.test(element.tagName); - }); - }, - - focusFirstElement: function(form) { - form = $(form); - form.findFirstElement().activate(); - return form; - }, - - request: function(form, options) { - form = $(form), options = Object.clone(options || { }); - - var params = options.parameters, action = form.readAttribute('action') || ''; - if (action.blank()) action = window.location.href; - options.parameters = form.serialize(true); - - if (params) { - if (Object.isString(params)) params = params.toQueryParams(); - Object.extend(options.parameters, params); - } - - if (form.hasAttribute('method') && !options.method) - options.method = form.method; - - return new Ajax.Request(action, options); - } -}; - -/*--------------------------------------------------------------------------*/ - - -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 Object.toQueryString(pair); - } - } - return ''; - }, - - getValue: function(element) { - element = $(element); - var method = element.tagName.toLowerCase(); - return Form.Element.Serializers[method](element); - }, - - setValue: function(element, value) { - element = $(element); - var method = element.tagName.toLowerCase(); - Form.Element.Serializers[method](element, value); - return element; - }, - - clear: function(element) { - $(element).value = ''; - return element; - }, - - present: function(element) { - return $(element).value != ''; - }, - - activate: function(element) { - element = $(element); - try { - element.focus(); - if (element.select && (element.tagName.toLowerCase() != 'input' || - !(/^(?:button|reset|submit)$/i.test(element.type)))) - element.select(); - } catch (e) { } - return element; - }, - - disable: function(element) { - element = $(element); - element.disabled = true; - return element; - }, - - enable: function(element) { - element = $(element); - element.disabled = false; - return element; - } -}; - -/*--------------------------------------------------------------------------*/ - -var Field = Form.Element; - -var $F = Form.Element.Methods.getValue; - -/*--------------------------------------------------------------------------*/ - -Form.Element.Serializers = { - input: function(element, value) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - return Form.Element.Serializers.inputSelector(element, value); - default: - return Form.Element.Serializers.textarea(element, value); - } - }, - - inputSelector: function(element, value) { - if (Object.isUndefined(value)) return element.checked ? element.value : null; - else element.checked = !!value; - }, - - textarea: function(element, value) { - if (Object.isUndefined(value)) return element.value; - else element.value = value; - }, - - select: function(element, value) { - if (Object.isUndefined(value)) - return this[element.type == 'select-one' ? - 'selectOne' : 'selectMany'](element); - else { - var opt, currentValue, single = !Object.isArray(value); - for (var i = 0, length = element.length; i < length; i++) { - opt = element.options[i]; - currentValue = this.optionValue(opt); - if (single) { - if (currentValue == value) { - opt.selected = true; - return; - } - } - else opt.selected = value.include(currentValue); - } - } - }, - - 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) { - return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; - } -}; - -/*--------------------------------------------------------------------------*/ - - -Abstract.TimedObserver = Class.create(PeriodicalExecuter, { - initialize: function($super, element, frequency, callback) { - $super(callback, frequency); - this.element = $(element); - this.lastValue = this.getValue(); - }, - - execute: function() { - var value = this.getValue(); - if (Object.isString(this.lastValue) && Object.isString(value) ? - this.lastValue != value : String(this.lastValue) != String(value)) { - this.callback(this.element, value); - this.lastValue = value; - } - } -}); - -Form.Element.Observer = Class.create(Abstract.TimedObserver, { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.Observer = Class.create(Abstract.TimedObserver, { - getValue: function() { - return Form.serialize(this.element); - } -}); - -/*--------------------------------------------------------------------------*/ - -Abstract.EventObserver = Class.create({ - 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, 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(Abstract.EventObserver, { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.EventObserver = Class.create(Abstract.EventObserver, { - getValue: function() { - return Form.serialize(this.element); - } -}); -(function() { - - var 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, - KEY_INSERT: 45, - - cache: {} - }; - - var docEl = document.documentElement; - var MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED = 'onmouseenter' in docEl - && 'onmouseleave' in docEl; - - var _isButton; - if (Prototype.Browser.IE) { - var buttonMap = { 0: 1, 1: 4, 2: 2 }; - _isButton = function(event, code) { - return event.button === buttonMap[code]; - }; - } else if (Prototype.Browser.WebKit) { - _isButton = function(event, code) { - switch (code) { - case 0: return event.which == 1 && !event.metaKey; - case 1: return event.which == 1 && event.metaKey; - default: return false; - } - }; - } else { - _isButton = function(event, code) { - return event.which ? (event.which === code + 1) : (event.button === code); - }; - } - - function isLeftClick(event) { return _isButton(event, 0) } - - function isMiddleClick(event) { return _isButton(event, 1) } - - function isRightClick(event) { return _isButton(event, 2) } - - function element(event) { - event = Event.extend(event); - - var node = event.target, type = event.type, - currentTarget = event.currentTarget; - - if (currentTarget && currentTarget.tagName) { - if (type === 'load' || type === 'error' || - (type === 'click' && currentTarget.tagName.toLowerCase() === 'input' - && currentTarget.type === 'radio')) - node = currentTarget; - } - - if (node.nodeType == Node.TEXT_NODE) - node = node.parentNode; - - return Element.extend(node); - } - - function findElement(event, expression) { - var element = Event.element(event); - if (!expression) return element; - while (element) { - if (Object.isElement(element) && Prototype.Selector.match(element, expression)) { - return Element.extend(element); - } - element = element.parentNode; - } - } - - function pointer(event) { - return { x: pointerX(event), y: pointerY(event) }; - } - - function pointerX(event) { - var docElement = document.documentElement, - body = document.body || { scrollLeft: 0 }; - - return event.pageX || (event.clientX + - (docElement.scrollLeft || body.scrollLeft) - - (docElement.clientLeft || 0)); - } - - function pointerY(event) { - var docElement = document.documentElement, - body = document.body || { scrollTop: 0 }; - - return event.pageY || (event.clientY + - (docElement.scrollTop || body.scrollTop) - - (docElement.clientTop || 0)); - } - - - function stop(event) { - Event.extend(event); - event.preventDefault(); - event.stopPropagation(); - - event.stopped = true; - } - - Event.Methods = { - isLeftClick: isLeftClick, - isMiddleClick: isMiddleClick, - isRightClick: isRightClick, - - element: element, - findElement: findElement, - - pointer: pointer, - pointerX: pointerX, - pointerY: pointerY, - - stop: stop - }; - - - var methods = Object.keys(Event.Methods).inject({ }, function(m, name) { - m[name] = Event.Methods[name].methodize(); - return m; - }); - - if (Prototype.Browser.IE) { - function _relatedTarget(event) { - var element; - switch (event.type) { - case 'mouseover': element = event.fromElement; break; - case 'mouseout': element = event.toElement; break; - default: return null; - } - return Element.extend(element); - } - - Object.extend(methods, { - stopPropagation: function() { this.cancelBubble = true }, - preventDefault: function() { this.returnValue = false }, - inspect: function() { return '[object Event]' } - }); - - Event.extend = function(event, element) { - if (!event) return false; - if (event._extendedByPrototype) return event; - - event._extendedByPrototype = Prototype.emptyFunction; - var pointer = Event.pointer(event); - - Object.extend(event, { - target: event.srcElement || element, - relatedTarget: _relatedTarget(event), - pageX: pointer.x, - pageY: pointer.y - }); - - return Object.extend(event, methods); - }; - } else { - Event.prototype = window.Event.prototype || document.createEvent('HTMLEvents').__proto__; - Object.extend(Event.prototype, methods); - Event.extend = Prototype.K; - } - - function _createResponder(element, eventName, handler) { - var registry = Element.retrieve(element, 'prototype_event_registry'); - - if (Object.isUndefined(registry)) { - CACHE.push(element); - registry = Element.retrieve(element, 'prototype_event_registry', $H()); - } - - var respondersForEvent = registry.get(eventName); - if (Object.isUndefined(respondersForEvent)) { - respondersForEvent = []; - registry.set(eventName, respondersForEvent); - } - - if (respondersForEvent.pluck('handler').include(handler)) return false; - - var responder; - if (eventName.include(":")) { - responder = function(event) { - if (Object.isUndefined(event.eventName)) - return false; - - if (event.eventName !== eventName) - return false; - - Event.extend(event, element); - handler.call(element, event); - }; - } else { - if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED && - (eventName === "mouseenter" || eventName === "mouseleave")) { - if (eventName === "mouseenter" || eventName === "mouseleave") { - responder = function(event) { - Event.extend(event, element); - - var parent = event.relatedTarget; - while (parent && parent !== element) { - try { parent = parent.parentNode; } - catch(e) { parent = element; } - } - - if (parent === element) return; - - handler.call(element, event); - }; - } - } else { - responder = function(event) { - Event.extend(event, element); - handler.call(element, event); - }; - } - } - - responder.handler = handler; - respondersForEvent.push(responder); - return responder; - } - - function _destroyCache() { - for (var i = 0, length = CACHE.length; i < length; i++) { - Event.stopObserving(CACHE[i]); - CACHE[i] = null; - } - } - - var CACHE = []; - - if (Prototype.Browser.IE) - window.attachEvent('onunload', _destroyCache); - - if (Prototype.Browser.WebKit) - window.addEventListener('unload', Prototype.emptyFunction, false); - - - var _getDOMEventName = Prototype.K, - translations = { mouseenter: "mouseover", mouseleave: "mouseout" }; - - if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED) { - _getDOMEventName = function(eventName) { - return (translations[eventName] || eventName); - }; - } - - function observe(element, eventName, handler) { - element = $(element); - - var responder = _createResponder(element, eventName, handler); - - if (!responder) return element; - - if (eventName.include(':')) { - if (element.addEventListener) - element.addEventListener("dataavailable", responder, false); - else { - element.attachEvent("ondataavailable", responder); - element.attachEvent("onfilterchange", responder); - } - } else { - var actualEventName = _getDOMEventName(eventName); - - if (element.addEventListener) - element.addEventListener(actualEventName, responder, false); - else - element.attachEvent("on" + actualEventName, responder); - } - - return element; - } - - function stopObserving(element, eventName, handler) { - element = $(element); - - var registry = Element.retrieve(element, 'prototype_event_registry'); - if (!registry) return element; - - if (!eventName) { - registry.each( function(pair) { - var eventName = pair.key; - stopObserving(element, eventName); - }); - return element; - } - - var responders = registry.get(eventName); - if (!responders) return element; - - if (!handler) { - responders.each(function(r) { - stopObserving(element, eventName, r.handler); - }); - return element; - } - - var responder = responders.find( function(r) { return r.handler === handler; }); - if (!responder) return element; - - if (eventName.include(':')) { - if (element.removeEventListener) - element.removeEventListener("dataavailable", responder, false); - else { - element.detachEvent("ondataavailable", responder); - element.detachEvent("onfilterchange", responder); - } - } else { - var actualEventName = _getDOMEventName(eventName); - if (element.removeEventListener) - element.removeEventListener(actualEventName, responder, false); - else - element.detachEvent('on' + actualEventName, responder); - } - - registry.set(eventName, responders.without(responder)); - - return element; - } - - function fire(element, eventName, memo, bubble) { - element = $(element); - - if (Object.isUndefined(bubble)) - bubble = true; - - if (element == document && document.createEvent && !element.dispatchEvent) - element = document.documentElement; - - var event; - if (document.createEvent) { - event = document.createEvent('HTMLEvents'); - event.initEvent('dataavailable', true, true); - } else { - event = document.createEventObject(); - event.eventType = bubble ? 'ondataavailable' : 'onfilterchange'; - } - - event.eventName = eventName; - event.memo = memo || { }; - - if (document.createEvent) - element.dispatchEvent(event); - else - element.fireEvent(event.eventType, event); - - return Event.extend(event); - } - - Event.Handler = Class.create({ - initialize: function(element, eventName, selector, callback) { - this.element = $(element); - this.eventName = eventName; - this.selector = selector; - this.callback = callback; - this.handler = this.handleEvent.bind(this); - }, - - start: function() { - Event.observe(this.element, this.eventName, this.handler); - return this; - }, - - stop: function() { - Event.stopObserving(this.element, this.eventName, this.handler); - return this; - }, - - handleEvent: function(event) { - var element = event.findElement(this.selector); - if (element) this.callback.call(this.element, event, element); - } - }); - - function on(element, eventName, selector, callback) { - element = $(element); - if (Object.isFunction(selector) && Object.isUndefined(callback)) { - callback = selector, selector = null; - } - - return new Event.Handler(element, eventName, selector, callback).start(); - } - - Object.extend(Event, Event.Methods); - - Object.extend(Event, { - fire: fire, - observe: observe, - stopObserving: stopObserving, - on: on - }); - - Element.addMethods({ - fire: fire, - - observe: observe, - - stopObserving: stopObserving, - - on: on - }); - - Object.extend(document, { - fire: fire.methodize(), - - observe: observe.methodize(), - - stopObserving: stopObserving.methodize(), - - on: on.methodize(), - - loaded: false - }); - - if (window.Event) Object.extend(window.Event, Event); - else window.Event = Event; -})(); - -(function() { - /* Support for the DOMContentLoaded event is based on work by Dan Webb, - Matthias Miller, Dean Edwards, John Resig, and Diego Perini. */ - - var timer; - - function fireContentLoadedEvent() { - if (document.loaded) return; - if (timer) window.clearTimeout(timer); - document.loaded = true; - document.fire('dom:loaded'); - } - - function checkReadyState() { - if (document.readyState === 'complete') { - document.stopObserving('readystatechange', checkReadyState); - fireContentLoadedEvent(); - } - } - - function pollDoScroll() { - try { document.documentElement.doScroll('left'); } - catch(e) { - timer = pollDoScroll.defer(); - return; - } - fireContentLoadedEvent(); - } - - if (document.addEventListener) { - document.addEventListener('DOMContentLoaded', fireContentLoadedEvent, false); - } else { - document.observe('readystatechange', checkReadyState); - if (window == top) - timer = pollDoScroll.defer(); - } - - Event.observe(window, 'load', fireContentLoadedEvent); -})(); - -Element.addMethods(); - -/*------------------------------- DEPRECATED -------------------------------*/ - -Hash.toQueryString = Object.toQueryString; - -var Toggle = { display: Element.toggle }; - -Element.Methods.childOf = Element.Methods.descendantOf; - -var Insertion = { - Before: function(element, content) { - return Element.insert(element, {before:content}); - }, - - Top: function(element, content) { - return Element.insert(element, {top:content}); - }, - - Bottom: function(element, content) { - return Element.insert(element, {bottom:content}); - }, - - After: function(element, content) { - return Element.insert(element, {after:content}); - } -}; - -var $continue = new Error('"throw $continue" is deprecated, use "return" instead'); - -var Position = { - includeScrollOffsets: false, - - prepare: function() { - this.deltaX = window.pageXOffset - || document.documentElement.scrollLeft - || document.body.scrollLeft - || 0; - this.deltaY = window.pageYOffset - || document.documentElement.scrollTop - || document.body.scrollTop - || 0; - }, - - within: function(element, x, y) { - if (this.includeScrollOffsets) - return this.withinIncludingScrolloffsets(element, x, y); - this.xcomp = x; - this.ycomp = y; - this.offset = Element.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 = Element.cumulativeScrollOffset(element); - - this.xcomp = x + offsetcache[0] - this.deltaX; - this.ycomp = y + offsetcache[1] - this.deltaY; - this.offset = Element.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); - }, - - 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; - }, - - - cumulativeOffset: Element.Methods.cumulativeOffset, - - positionedOffset: Element.Methods.positionedOffset, - - absolutize: function(element) { - Position.prepare(); - return Element.absolutize(element); - }, - - relativize: function(element) { - Position.prepare(); - return Element.relativize(element); - }, - - realOffset: Element.Methods.cumulativeScrollOffset, - - offsetParent: Element.Methods.getOffsetParent, - - page: Element.Methods.viewportOffset, - - clone: function(source, target, options) { - options = options || { }; - return Element.clonePosition(target, source, options); - } -}; - -/*--------------------------------------------------------------------------*/ - -if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){ - function iter(name) { - return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]"; - } - - instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ? - function(element, className) { - className = className.toString().strip(); - var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className); - return cond ? document._getElementsByXPath('.//*' + cond, element) : []; - } : function(element, className) { - className = className.toString().strip(); - var elements = [], classNames = (/\s/.test(className) ? $w(className) : null); - if (!classNames && !className) return elements; - - var nodes = $(element).getElementsByTagName('*'); - className = ' ' + className + ' '; - - for (var i = 0, child, cn; child = nodes[i]; i++) { - if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) || - (classNames && classNames.all(function(name) { - return !name.toString().blank() && cn.include(' ' + name + ' '); - })))) - elements.push(Element.extend(child)); - } - return elements; - }; - - return function(className, parentElement) { - return $(parentElement || document.body).getElementsByClassName(className); - }; -}(Element.Methods); - -/*--------------------------------------------------------------------------*/ - -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); - -/*--------------------------------------------------------------------------*/ - -(function() { - window.Selector = Class.create({ - initialize: function(expression) { - this.expression = expression.strip(); - }, - - findElements: function(rootElement) { - return Prototype.Selector.select(this.expression, rootElement); - }, - - match: function(element) { - return Prototype.Selector.match(element, this.expression); - }, - - toString: function() { - return this.expression; - }, - - inspect: function() { - return "#"; - } - }); - - Object.extend(Selector, { - matchElements: function(elements, expression) { - var match = Prototype.Selector.match, - results = []; - - for (var i = 0, length = elements.length; i < length; i++) { - var element = elements[i]; - if (match(element, expression)) { - results.push(Element.extend(element)); - } - } - return results; - }, - - findElement: function(elements, expression, index) { - index = index || 0; - var matchIndex = 0, element; - for (var i = 0, length = elements.length; i < length; i++) { - element = elements[i]; - if (Prototype.Selector.match(element, expression) && index === matchIndex++) { - return Element.extend(element); - } - } - }, - - findChildElements: function(element, expressions) { - var selector = expressions.toArray().join(', '); - return Prototype.Selector.select(selector, element || document); - } - }); -})(); diff --git a/vendor/built_in_modules/blog/public/javascripts/rails.js b/vendor/built_in_modules/blog/public/javascripts/rails.js deleted file mode 100644 index aed6aed3..00000000 --- a/vendor/built_in_modules/blog/public/javascripts/rails.js +++ /dev/null @@ -1,191 +0,0 @@ -(function() { - // Technique from Juriy Zaytsev - // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ - function isEventSupported(eventName) { - var el = document.createElement('div'); - eventName = 'on' + eventName; - var isSupported = (eventName in el); - if (!isSupported) { - el.setAttribute(eventName, 'return;'); - isSupported = typeof el[eventName] == 'function'; - } - el = null; - return isSupported; - } - - function isForm(element) { - return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM' - } - - function isInput(element) { - if (Object.isElement(element)) { - var name = element.nodeName.toUpperCase() - return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA' - } - else return false - } - - var submitBubbles = isEventSupported('submit'), - changeBubbles = isEventSupported('change') - - if (!submitBubbles || !changeBubbles) { - // augment the Event.Handler class to observe custom events when needed - Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap( - function(init, element, eventName, selector, callback) { - init(element, eventName, selector, callback) - // is the handler being attached to an element that doesn't support this event? - if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) || - (!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) { - // "submit" => "emulated:submit" - this.eventName = 'emulated:' + this.eventName - } - } - ) - } - - if (!submitBubbles) { - // discover forms on the page by observing focus events which always bubble - document.on('focusin', 'form', function(focusEvent, form) { - // special handler for the real "submit" event (one-time operation) - if (!form.retrieve('emulated:submit')) { - form.on('submit', function(submitEvent) { - var emulated = form.fire('emulated:submit', submitEvent, true) - // if custom event received preventDefault, cancel the real one too - if (emulated.returnValue === false) submitEvent.preventDefault() - }) - form.store('emulated:submit', true) - } - }) - } - - if (!changeBubbles) { - // discover form inputs on the page - document.on('focusin', 'input, select, texarea', function(focusEvent, input) { - // special handler for real "change" events - if (!input.retrieve('emulated:change')) { - input.on('change', function(changeEvent) { - input.fire('emulated:change', changeEvent, true) - }) - input.store('emulated:change', true) - } - }) - } - - function handleRemote(element) { - var method, url, params; - - var event = element.fire("ajax:before"); - if (event.stopped) return false; - - if (element.tagName.toLowerCase() === 'form') { - method = element.readAttribute('method') || 'post'; - url = element.readAttribute('action'); - params = element.serialize(); - } else { - method = element.readAttribute('data-method') || 'get'; - url = element.readAttribute('href'); - params = {}; - } - - new Ajax.Request(url, { - method: method, - parameters: params, - evalScripts: true, - - onComplete: function(request) { element.fire("ajax:complete", request); }, - onSuccess: function(request) { element.fire("ajax:success", request); }, - onFailure: function(request) { element.fire("ajax:failure", request); } - }); - - element.fire("ajax:after"); - } - - function handleMethod(element) { - var method = element.readAttribute('data-method'), - url = element.readAttribute('href'), - csrf_param = $$('meta[name=csrf-param]')[0], - csrf_token = $$('meta[name=csrf-token]')[0]; - - var form = new Element('form', { method: "POST", action: url, style: "display: none;" }); - element.parentNode.insert(form); - - if (method !== 'post') { - var field = new Element('input', { type: 'hidden', name: '_method', value: method }); - form.insert(field); - } - - if (csrf_param) { - var param = csrf_param.readAttribute('content'), - token = csrf_token.readAttribute('content'), - field = new Element('input', { type: 'hidden', name: param, value: token }); - form.insert(field); - } - - form.submit(); - } - - - document.on("click", "*[data-confirm]", function(event, element) { - var message = element.readAttribute('data-confirm'); - if (!confirm(message)) event.stop(); - }); - - document.on("click", "a[data-remote]", function(event, element) { - if (event.stopped) return; - handleRemote(element); - event.stop(); - }); - - document.on("click", "a[data-method]", function(event, element) { - if (event.stopped) return; - handleMethod(element); - event.stop(); - }); - - document.on("submit", function(event) { - var element = event.findElement(), - message = element.readAttribute('data-confirm'); - if (message && !confirm(message)) { - event.stop(); - return false; - } - - var inputs = element.select("input[type=submit][data-disable-with]"); - inputs.each(function(input) { - input.disabled = true; - input.writeAttribute('data-original-value', input.value); - input.value = input.readAttribute('data-disable-with'); - }); - - var element = event.findElement("form[data-remote]"); - if (element) { - handleRemote(element); - event.stop(); - } - }); - - document.on("ajax:after", "form", function(event, element) { - var inputs = element.select("input[type=submit][disabled=true][data-disable-with]"); - inputs.each(function(input) { - input.value = input.readAttribute('data-original-value'); - input.removeAttribute('data-original-value'); - input.disabled = false; - }); - }); - - Ajax.Responders.register({ - onCreate: function(request) { - var csrf_meta_tag = $$('meta[name=csrf-token]')[0]; - - if (csrf_meta_tag) { - var header = 'X-CSRF-Token', - token = csrf_meta_tag.readAttribute('content'); - - if (!request.options.requestHeaders) { - request.options.requestHeaders = {}; - } - request.options.requestHeaders[header] = token; - } - } - }); -})(); diff --git a/vendor/built_in_modules/blog/public/robots.txt b/vendor/built_in_modules/blog/public/robots.txt deleted file mode 100644 index 085187fa..00000000 --- a/vendor/built_in_modules/blog/public/robots.txt +++ /dev/null @@ -1,5 +0,0 @@ -# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file -# -# To ban all spiders from the entire site uncomment the next two lines: -# User-Agent: * -# Disallow: / diff --git a/vendor/built_in_modules/blog/public/stylesheets/.gitkeep b/vendor/built_in_modules/blog/public/stylesheets/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/built_in_modules/blog/script/rails b/vendor/built_in_modules/blog/script/rails deleted file mode 100755 index f8da2cff..00000000 --- a/vendor/built_in_modules/blog/script/rails +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby -# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. - -APP_PATH = File.expand_path('../../config/application', __FILE__) -require File.expand_path('../../config/boot', __FILE__) -require 'rails/commands' diff --git a/vendor/built_in_modules/blog/test/performance/browsing_test.rb b/vendor/built_in_modules/blog/test/performance/browsing_test.rb deleted file mode 100644 index 867fc8c9..00000000 --- a/vendor/built_in_modules/blog/test/performance/browsing_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' -require 'rails/performance_test_help' - -# Profiling results for each test method are written to tmp/performance. -class BrowsingTest < ActionDispatch::PerformanceTest - def test_homepage - get '/' - end -end diff --git a/vendor/built_in_modules/blog/test/test_helper.rb b/vendor/built_in_modules/blog/test/test_helper.rb deleted file mode 100644 index 82985177..00000000 --- a/vendor/built_in_modules/blog/test/test_helper.rb +++ /dev/null @@ -1,7 +0,0 @@ -ENV["RAILS_ENV"] = "test" -require File.expand_path('../../config/environment', __FILE__) -require 'rails/test_help' - -class ActiveSupport::TestCase - # Add more helper methods to be used by all tests here... -end diff --git a/vendor/built_in_modules/blog/vendor/plugins/.gitkeep b/vendor/built_in_modules/blog/vendor/plugins/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/plugins/NewBlog/NewBlog.json b/vendor/plugins/NewBlog/NewBlog.json index 1c0faa55..ce9c80d3 100755 --- a/vendor/plugins/NewBlog/NewBlog.json +++ b/vendor/plugins/NewBlog/NewBlog.json @@ -1,9 +1,10 @@ { "title": "NewBlog", - "version": "0.1", - "organization": "Rulingcom", + "version": "0.1", + "organization": "Rulingcom", "author": "RD dep", "intro": "A simple blog……", "update_info": "Some info", - "create_date": "11-11-2011" -} \ No newline at end of file + "create_date": "11-11-2011", + "app_pages": ["/panel/blog/front_end/"] +} diff --git a/vendor/built_in_modules/blog/app/controllers/panel/blog/posts_controller.rb b/vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb similarity index 94% rename from vendor/built_in_modules/blog/app/controllers/panel/blog/posts_controller.rb rename to vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb index 27c373dc..f853d54c 100644 --- a/vendor/built_in_modules/blog/app/controllers/panel/blog/posts_controller.rb +++ b/vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb @@ -1,9 +1,7 @@ -class Panel::Blog::PostsController < ApplicationController +class Panel::Blog::BackEnd::PostsController < ApplicationController - layout 'panel' + layout 'admin' - # GET /posts - # GET /posts.xml def index @posts = Post.all @@ -83,4 +81,4 @@ class Panel::Blog::PostsController < ApplicationController format.xml { head :ok } end end -end \ No newline at end of file +end diff --git a/vendor/plugins/NewBlog/app/controllers/panel/blog/comments_controller.rb b/vendor/plugins/NewBlog/app/controllers/panel/blog/comments_controller.rb deleted file mode 100644 index 971f58a6..00000000 --- a/vendor/plugins/NewBlog/app/controllers/panel/blog/comments_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Panel::Blog::CommentsController < ApplicationController - def create - @post = Post.find(params[:post_id]) - @comment = @post.comments.create!(params[:comment]) - redirect_to panel_blog_post_url(@post) - end -end \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/controllers/panel/blog/front_end/comments_controller.rb b/vendor/plugins/NewBlog/app/controllers/panel/blog/front_end/comments_controller.rb new file mode 100644 index 00000000..78a28b01 --- /dev/null +++ b/vendor/plugins/NewBlog/app/controllers/panel/blog/front_end/comments_controller.rb @@ -0,0 +1,7 @@ +class Panel::Blog::FrontEnd::CommentsController < ApplicationController + def create + @post = Post.find(params[:post_id]) + @comment = @post.comments.create!(params[:comment]) + redirect_to panel_blog_front_end_post_url(@post) + end +end \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb b/vendor/plugins/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb new file mode 100644 index 00000000..df089756 --- /dev/null +++ b/vendor/plugins/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb @@ -0,0 +1,17 @@ +class Panel::Blog::FrontEnd::PostsController < ApplicationController + + layout 'production' + + # GET /posts + # GET /posts.xml + + def index + @posts = Post.all + end + + def show + @post = Post.find(params[:id]) + end + + +end diff --git a/vendor/plugins/NewBlog/app/controllers/panel/blog/posts_controller.rb b/vendor/plugins/NewBlog/app/controllers/panel/blog/posts_controller.rb deleted file mode 100644 index 41468846..00000000 --- a/vendor/plugins/NewBlog/app/controllers/panel/blog/posts_controller.rb +++ /dev/null @@ -1,111 +0,0 @@ -class Panel::Blog::PostsController < ApplicationController - - layout 'admin' - - # GET /posts - # GET /posts.xml - def widget_index - @posts = Post.all - widget_default_layout - end - def widget_latest_post - @post = Post.all.last - widget_default_layout - end - def index - @posts = Post.all - - respond_to do |format| - format.html # index.html.erb - format.xml { render :xml => @posts } - end - end - - # GET /posts/1 - # GET /posts/1.xml - def show - @post = Post.find(params[:id]) - - respond_to do |format| - format.html # show.html.erb - format.xml { render :xml => @post } - end - end - - # GET /posts/new - # GET /posts/new.xml - def new - @post = Post.new - - respond_to do |format| - format.html # new.html.erb - format.xml { render :xml => @post } - end - end - - # GET /posts/1/edit - def edit - @post = Post.find(params[:id]) - end - - # POST /posts - # POST /posts.xml - def create - @post = Post.new(params[:post]) - - respond_to do |format| - if @post.save - format.html { redirect_to(panel_blog_post_url(@post), :notice => t('blog.create_post_success')) } - format.xml { render :xml => @post, :status => :created, :location => @post } - else - format.html { render :action => "new" } - format.xml { render :xml => @post.errors, :status => :unprocessable_entity } - end - end - end - - # PUT /posts/1 - # PUT /posts/1.xml - def update - @post = Post.find(params[:id]) - - respond_to do |format| - if @post.update_attributes(params[:post]) - format.html { redirect_to(panel_blog_post_url(@post), :notice => t('blog.update_post_success')) } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @post.errors, :status => :unprocessable_entity } - end - end - end - - # DELETE /posts/1 - # DELETE /posts/1.xml - def destroy - @post = Post.find(params[:id]) - @post.destroy - - respond_to do |format| - format.html { redirect_to(panel_blog_posts_url) } - format.xml { head :ok } - end - end -end - - -def widget_default_layout - respond_to do |format| - format.html { - if params[:edit_view] - #in the case of editing,should be displayed in modal window and - #be restricted by the border developer sat. - render :layout => 'admin' - else - #in the case of fetching data for ajax display,should - render :layout => 'production' - end - } - format.xml { render :xml => @posts } - end -end diff --git a/vendor/plugins/NewBlog/app/controllers/panel/blog/widget/posts_controller.rb b/vendor/plugins/NewBlog/app/controllers/panel/blog/widget/posts_controller.rb new file mode 100644 index 00000000..20e14616 --- /dev/null +++ b/vendor/plugins/NewBlog/app/controllers/panel/blog/widget/posts_controller.rb @@ -0,0 +1,15 @@ +class Panel::Blog::Widget::PostsController < ApplicationController + + layout 'production' + + # GET /posts + # GET /posts.xml + def index + @posts = Post.all + end + + def latest_post + @post = Post.all.last + end + +end diff --git a/vendor/built_in_modules/blog/app/views/panel/blog/posts/_form.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb similarity index 100% rename from vendor/built_in_modules/blog/app/views/panel/blog/posts/_form.html.erb rename to vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/edit.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/edit.html.erb new file mode 100644 index 00000000..6db16236 --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/edit.html.erb @@ -0,0 +1,8 @@ +

    <%= t('blog.editing_post') %>

    + +<%= form_for @post, :url => panel_blog_back_end_post_path(@post) do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> + +<%= link_to t('blog.show'), panel_blog_back_end_post_path(@post) %> | +<%= link_back %> diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb similarity index 51% rename from vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb rename to vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb index 477429cd..25eca5f7 100644 --- a/vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb +++ b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb @@ -1,6 +1,6 @@ <% content_for :secondary do %>
      -
    • <%= link_to t('blog.new_post'), new_panel_blog_post_path, :class => 'seclink1' %>
    • +
    • <%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path, :class => 'seclink1' %>
    <% end -%> @@ -21,9 +21,9 @@ <%= post.title %> <%= truncate(post.body,:length=>15) %> - <%= link_to t('blog.show'), panel_blog_post_path(post) %> - <%= link_to t('blog.edit'), edit_panel_blog_post_path(post) %> - <%= link_to t('blog.delete'), panel_blog_post_path(post), :confirm => t('blog.sure?'), :method => :delete %> + <%= link_to t('blog.show'), panel_blog_back_end_post_path(post) %> + <%= link_to t('blog.edit'), edit_panel_blog_back_end_post_path(post) %> + <%= link_to t('blog.delete'), panel_blog_back_end_post_path(post), :confirm => t('blog.sure?'), :method => :delete %> <% end %> diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/latest_post.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/panel/blog/posts/latest_post.html.erb rename to vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb similarity index 56% rename from vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb rename to vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb index fc4e591d..03508f90 100644 --- a/vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb +++ b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb @@ -1,12 +1,12 @@ <% content_for :secondary do %>
      -
    • <%= link_to t('blog.index'), panel_blog_posts_path, :class => 'seclink2' %>
    • +
    • <%= link_to t('blog.index'), panel_blog_back_end_posts_path, :class => 'seclink2' %>
    <% end -%> <%= flash_messages %>

    <%= t('blog.new_post') %>

    -<%= form_for @post, :url => panel_blog_posts_path do |f| %> +<%= form_for @post, :url => panel_blog_back_end_posts_path do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <% end %> diff --git a/vendor/built_in_modules/blog/app/views/panel/blog/posts/show.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/show.html.erb similarity index 77% rename from vendor/built_in_modules/blog/app/views/panel/blog/posts/show.html.erb rename to vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/show.html.erb index 7fce5fd1..0755b4e6 100644 --- a/vendor/built_in_modules/blog/app/views/panel/blog/posts/show.html.erb +++ b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/show.html.erb @@ -18,7 +18,7 @@

    <% end %> -<%= form_for Comment.new, :url => panel_blog_comments_path do |f| %> +<%= form_for Comment.new, :url => panel_blog_front_end_comments_path do |f| %>

    <%= f.label :name, "Author" %>
    @@ -34,5 +34,5 @@ <% end %> -<%= link_to t('blog.edit'), edit_panel_blog_post_path(@post) %> | +<%= link_to t('blog.edit'), edit_panel_blog_back_end_post_path(@post) %> | <%= link_back %> \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/_post_frontend.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/_post_frontend.html.erb new file mode 100644 index 00000000..09dfa10e --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/_post_frontend.html.erb @@ -0,0 +1,7 @@ +

    +<%= post_frontend.title %>
    +

    + <%= truncate(post_frontend.body,:length=>25) %> + <%= link_to 'Read more...',panel_blog_front_end_post_path(post_frontend) %> +

    +
    diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/index.html.erb new file mode 100644 index 00000000..aaa1d8ce --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/index.html.erb @@ -0,0 +1,11 @@ +<% content_for :secondary do %> +
      +
    • <%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path, :class => 'seclink1' %>
    • +
    +<% end -%> + +<%= flash_messages %> + +

    <%= t('blog.front_end_index') %>

    + +<%= render :partial => "post_frontend", :collection => @posts %> diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/show.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb similarity index 79% rename from vendor/plugins/NewBlog/app/views/panel/blog/posts/show.html.erb rename to vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb index 7fce5fd1..46842f96 100644 --- a/vendor/plugins/NewBlog/app/views/panel/blog/posts/show.html.erb +++ b/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb @@ -18,7 +18,7 @@

    <% end %> -<%= form_for Comment.new, :url => panel_blog_comments_path do |f| %> +<%= form_for Comment.new, :url => panel_blog_front_end_comments_path do |f| %>

    <%= f.label :name, "Author" %>
    @@ -32,7 +32,3 @@ <%= f.submit "Add Comment" %>

    <% end %> - - -<%= link_to t('blog.edit'), edit_panel_blog_post_path(@post) %> | -<%= link_back %> \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/_form.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/_form.html.erb deleted file mode 100644 index 3c459566..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/posts/_form.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - - <%= f.error_messages %> - -
    - <%= f.label :title %>
    - <%= f.text_field :title %> -
    -
    - <%= f.label :body %>
    - <%= f.text_area :body %> -
    -
    - <%= f.submit %> -
    diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/edit.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/edit.html.erb deleted file mode 100644 index 8b2b1f1d..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/posts/edit.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -

    <%= t('blog.editing_post') %>

    - -<%= form_for @post, :url => panel_blog_post_path(@post) do |f| %> - <%= render :partial => 'form', :locals => {:f => f} %> -<% end %> - -<%= link_to t('blog.show'), panel_blog_post_path(@post) %> | -<%= link_back %> diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb similarity index 77% rename from vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb rename to vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb index cd16cfc7..0ea7639f 100644 --- a/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb +++ b/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb @@ -8,7 +8,7 @@ <% @posts.each do |post| %> - <%= link_to post.title,panel_blog_post_path(post) %> + <%= link_to post.title,panel_blog_front_end_post_path(post) %> <%= post.body.truncate(14) %> <% end %> diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb rename to vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb diff --git a/vendor/plugins/NewBlog/config/locales/zh_tw.yml b/vendor/plugins/NewBlog/config/locales/zh_tw.yml index d34b583d..4ef309e6 100644 --- a/vendor/plugins/NewBlog/config/locales/zh_tw.yml +++ b/vendor/plugins/NewBlog/config/locales/zh_tw.yml @@ -17,4 +17,314 @@ zh_tw: sure?: 您肯定嗎? update: 更新 yes_: "Yes" + + admin: + action: 行動 + add_language: 新增語言 + admin: 管理 + action: 行動 + announcement: 公告 + asset: 資產 + attributes: 屬性 + cant_delete_self: 您不可以刪除自己。 + cant_revoke_self_admin: 您不可以撤銷自己的管理作用。 + class: 階級 + content: 內容 + create_error_link: 創建連接時出錯。 + create_error_page: 創建頁面時出錯。 + create_success_home: 首頁已成功創建。 + create_success_layout: 樣板已成功創建。 + create_success_link: 連結已成功創建。 + create_success_page: 頁面已成功創建。 + create_success_snippet: 片段已成功創建 + create_success_user: 用戶已成功創建。。 + data: 數據 + delete_language: 刪除語言 + description: 描述 + disable_language: 禁用語言 + editing_home: 編輯首頁 + editing_layout: 編輯樣板 + editing_link: 編輯連結 + editing_page: 編輯頁面 + editing_snippet: 編輯片段 + editing_user_info: 編輯用戶資料 + editing_user_role: 編輯用戶角色 + email: Email + enable_language: 啟用語言 + file_name: 檔名 + file_size: 檔案大小 + format: 格式 + home: 首頁 + id: ID + info: 資料 + is_published: 被出版 + item: 項目 + key: 關鍵 + language: 語言 + layout: 佈局 + layout_name: 佈局名字 + list_assets: 資產清單 + list_items: 項目清單 + list_layouts: 佈局清單 + list_snippets: 斷片清單 + list_users: 使用清單 + list_user_infos: 用戶資料清單 + list_user_roles: 用戶角色清單 + member: 會員 + move_down: 往下移 + move_up: 往上移 + multilingual: 多種語言 + my_avatar: 我的頭像 + no_home_page: 您沒有首頁 + no_layout: 您沒有佈局 + name: 名稱 + new_asset: 新增資產 + new_component: 新增元件 + new_home: 新增首頁 + new_layout: 新增樣板 + new_link: 新增連結 + new_page: 新增頁面 + new_snippet: 新增片段 + new_user: 新增使用 + new_user_info: 新增用戶資料 + new_user_role: 新增用戶角色 + non_multilingual: 非多種語言 + options: 選項 + orig_upload_file: 原上傳檔名 + position: 位置 + published?: 發布? + role: 角色 + roles: 角色。 + title: 標題 + translation: 翻譯 + type: 類型 + update_error_link: 更新鏈接時出現錯誤。 + update_error_page: 更新頁面時出現錯誤。 + update_success_content: 內容已成功更新。 + update_success_home: 首頁已成功更新。 + update_success_layout: 樣板已成功更新。 + update_success_link: 連結已成功更新。 + update_success_page: 頁面已成功更新。 + update_success_snippet: 片段已成功更新。 + update_success_user: 用戶已成功更新 + url: URL + user: 用戶 + user_info: 用戶資料 + user_panel: 用戶面板 + user_role: 用戶角色 + + panel: + + + +# Chinese (Taiwan) translations for Ruby on Rails +# by tsechingho (http://github.com/tsechingho) + date: + formats: + default: "%Y-%m-%d" + short: "%b%d日" + long: "%Y年%b%d日" + day_names: [星期日, 星期一, 星期二, 星期三, 星期四, 星期五, 星期六] + abbr_day_names: [日, 一, 二, 三, 四, 五, 六] + month_names: [~, 一月, 二月, 三月, 四月, 五月, 六月, 七月, 八月, 九月, 十月, 十一月, 十二月] + abbr_month_names: [~, 1月, 2月, 3月, 4月, 5月, 6月, 7月, 8月, 9月, 10月, 11月, 12月] + order: [ :year, :month, :day ] + + time: + formats: + default: "%Y年%b%d日 %A %H:%M:%S %Z" + short: "%b%d日 %H:%M" + long: "%Y年%b%d日 %H:%M" + am: "上午" + pm: "下午" + + datetime: + distance_in_words: + half_a_minute: "半分鐘" + less_than_x_seconds: + one: "不到一秒" + other: "不到 %{count} 秒" + x_seconds: + one: "一秒" + other: "%{count} 秒" + less_than_x_minutes: + one: "不到一分鐘" + other: "不到 %{count} 分鐘" + x_minutes: + one: "一分鐘" + other: "%{count} 分鐘" + about_x_hours: + one: "大約一小時" + other: "大約 %{count} 小時" + x_days: + one: "一天" + other: "%{count} 天" + about_x_months: + one: "大約一個月" + other: "大約 %{count} 個月" + x_months: + one: "一個月" + other: "%{count} 個月" + about_x_years: + one: "大約一年" + other: "大約 %{count} 年" + over_x_years: + one: "一年多" + other: "%{count} 年多" + almost_x_years: + one: "接近一年" + other: "接近 %{count} 年" + prompts: + year: "年" + month: "月" + day: "日" + hour: "時" + minute: "分" + second: "秒" + + number: + format: + separator: "." + delimiter: "," + precision: 3 + significant: false + strip_insignificant_zeros: false + currency: + format: + format: "%u %n" + unit: "NT$" + separator: "." + delimiter: "," + precision: 2 + significant: false + strip_insignificant_zeros: false + percentage: + format: + delimiter: "" + precision: + format: + delimiter: "" + human: + format: + delimiter: "" + precision: 1 + significant: false + strip_insignificant_zeros: false + storage_units: + format: "%n %u" + units: + byte: + one: "Byte" + other: "Bytes" + kb: "KB" + mb: "MB" + gb: "GB" + tb: "TB" + decimal_units: + format: "%n %u" + units: + # 10^-21 zepto, 10^-24 yocto + atto: "渺" # 10^-18 + femto: "飛" # 10^-15 毫微微 + pico: "漠" # 10^-12 微微 + nano: "奈" # 10^-9 毫微 + micro: "微" # 10^-6 + mili: "毫" # 10^-3 milli + centi: "厘" # 10^-2 + deci: "分" # 10^-1 + unit: "" + ten: + one: "十" + other: "十" # 10^1 + hundred: "百" # 10^2 + thousand: "千" # 10^3 kilo + million: "百萬" # 10^6 mega + billion: "十億" # 10^9 giga + trillion: "兆" # 10^12 tera + quadrillion: "千兆" # 10^15 peta + # 10^18 exa, 10^21 zetta, 10^24 yotta + + support: + array: + words_connector: ", " + two_words_connector: " 和 " + last_word_connector: ", 和 " + select: + prompt: "請選擇" + + activerecord: + errors: + template: # ~ 2.3.5 backward compatible + header: + one: "有 1 個錯誤發生使得「%{model}」無法被儲存。" + other: "有 %{count} 個錯誤發生使得「%{model}」無法被儲存。" + body: "以下欄位發生問題:" + full_messages: + format: "%{attribute} %{message}" + messages: + inclusion: "沒有包含在列表中" + exclusion: "是被保留的關鍵字" + invalid: "是無效的" + confirmation: "不符合確認值" + accepted: "必須是可被接受的" + empty: "不能留空" + blank: "不能是空白字元" + too_long: "過長(最長是 %{count} 個字)" + too_short: "過短(最短是 %{count} 個字)" + wrong_length: "字數錯誤(必須是 %{count} 個字)" + not_a_number: "不是數字" + not_an_integer: "必須是整數" + greater_than: "必須大於 %{count}" + greater_than_or_equal_to: "必須大於或等於 %{count}" + equal_to: "必須等於 %{count}" + less_than: "必須小於 %{count}" + less_than_or_equal_to: "必須小於或等於 %{count}" + odd: "必須是奇數" + even: "必須是偶數" + taken: "已經被使用" + record_invalid: "校驗失敗: %{errors}" + + activemodel: + errors: + template: + header: + one: "有 1 個錯誤發生使得「%{model}」無法被儲存。" + other: "有 %{count} 個錯誤發生使得「%{model}」無法被儲存。" + body: "以下欄位發生問題:" + + errors: + format: "%{attribute} %{message}" + messages: + inclusion: "沒有包含在列表中" + exclusion: "是被保留的關鍵字" + invalid: "是無效的" + confirmation: "不符合確認值" + accepted: "必須是可被接受的" + empty: "不能留空" + blank: "不能是空白字元" + too_long: "過長(最長是 %{count} 個字)" + too_short: "過短(最短是 %{count} 個字)" + wrong_length: "字數錯誤(必須是 %{count} 個字)" + not_a_number: "不是數字" + not_an_integer: "必須是整數" + greater_than: "必須大於 %{count}" + greater_than_or_equal_to: "必須大於或等於 %{count}" + equal_to: "必須等於 %{count}" + less_than: "必須小於 %{count}" + less_than_or_equal_to: "必須小於或等於 %{count}" + odd: "必須是奇數" + even: "必須是偶數" + template: + header: + one: "有 1 個錯誤發生使得「%{model}」無法被儲存。" + other: "有 %{count} 個錯誤發生使得「%{model}」無法被儲存。" + body: "以下欄位發生問題:" + + helpers: + select: + prompt: "請選擇" + submit: + create: "新增%{model}" + update: "更新%{model}" + submit: "儲存%{model}" diff --git a/vendor/plugins/NewBlog/config/routes.rb b/vendor/plugins/NewBlog/config/routes.rb index b619df18..22cef244 100644 --- a/vendor/plugins/NewBlog/config/routes.rb +++ b/vendor/plugins/NewBlog/config/routes.rb @@ -2,12 +2,24 @@ Rails.application.routes.draw do namespace :panel do namespace :blog do - root :to => "posts#index" - resources :posts - resources :comments - match "widget_latest_post" => "posts#widget_latest_post" - match "widget_index" => "posts#widget_index" + namespace :back_end do + root :to => "posts#index" + resources :posts + resources :comments + end + namespace :front_end do + root :to => "posts#index" + match "show/:id" => "posts#show" ,:as => :post + match "comments" => "comments#create",:as => :comments + end + namespace :widget do + root :to => "posts#index" + match "latest_post" => "posts#latest_post" + end end end + # match "appfront/blog/front_end/show/:id" => "posts#frontend_show" ,:as => :appfront_blog_show + + match "/appfront/*path" => redirect("/panel/*path") end From 95c40d2e53c8ff0b99789e8e0e55115ff42eda32 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Thu, 22 Dec 2011 01:27:26 +0800 Subject: [PATCH 08/20] Add plugins directories --- config/application.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/config/application.rb b/config/application.rb index be6f64d0..0e438497 100644 --- a/config/application.rb +++ b/config/application.rb @@ -15,10 +15,11 @@ Bundler.require *Rails.groups(:assets) if defined?(Bundler) module PrototypeR4 class Application < Rails::Application -# config.paths.vendor.plugins.instance_variable_set("@paths", config.paths.vendor.plugins.instance_variable_get("@paths") + ["#{config.root}/vendor/built_in_modules"]) - # config.paths.vendor.plugins.instance_variable_set("@paths", config.paths.vendor.plugins.instance_variable_get("@paths") + ["#{config.root}/vendor/downloaded_modules"]) - # config.paths.vendor.plugins.instance_variable_set("@paths", config.paths.vendor.plugins.instance_variable_get("@paths") + ["#{config.root}/vendor/radius"]) - + # Add directories for plugins + config.paths["vendor/plugins"] += %W(#{config.root}/vendor/built_in_modules) + config.paths["vendor/plugins"] += %W(#{config.root}/vendor/downloaded_modules) + + # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. From e7c9816139709a97d398ccca7b17487eb90a3329 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Thu, 22 Dec 2011 01:38:27 +0800 Subject: [PATCH 09/20] Move NewBlog to built_in_modules and delete "vendor/templates" --- app/assets/javascripts/rss.js | 513 ++++++++++++++++++ app/views/admin/designs/_new.html.erb | 10 + app/views/admin/designs/new.js.erb | 1 + .../NewBlog/.gitignore | 0 .../NewBlog/Gemfile | 0 .../NewBlog/Gemfile.lock | 0 .../NewBlog/MIT-LICENSE | 0 .../NewBlog/NewBlog.gemspec | 0 .../NewBlog/NewBlog.json | 0 .../NewBlog/README.rdoc | 0 .../NewBlog/Rakefile | 0 .../app/assets/images/NewBlog/.gitkeep | 0 .../app/assets/javascripts/NewBlog/.gitkeep | 0 .../app/assets/stylesheets/NewBlog/.gitkeep | 0 .../stylesheets/NewBlog/application.css | 0 .../assets/stylesheets/NewBlog/production.css | 0 .../NewBlog/app/controllers/.gitkeep | 0 .../app/controllers/application_controller.rb | 0 .../panel/blog/back_end/posts_controller.rb | 0 .../blog/front_end/comments_controller.rb | 0 .../panel/blog/front_end/posts_controller.rb | 0 .../panel/blog/widget/posts_controller.rb | 0 .../NewBlog/app/helpers/.gitkeep | 0 .../NewBlog/app/helpers/application_helper.rb | 0 .../NewBlog/app/mailers/.gitkeep | 0 .../NewBlog/app/models/.gitkeep | 0 .../NewBlog/app/models/comment.rb | 0 .../NewBlog/app/models/post.rb | 0 .../NewBlog/app/views/.gitkeep | 0 .../app/views/layouts/application.html.erb | 0 .../app/views/layouts/edit_view.html.erb | 0 .../app/views/layouts/production.html.erb | 0 .../panel/blog/back_end/posts/_form.html.erb | 0 .../panel/blog/back_end/posts/edit.html.erb | 0 .../panel/blog/back_end/posts/index.html.erb | 0 .../blog/back_end/posts/latest_post.html.erb | 0 .../panel/blog/back_end/posts/new.html.erb | 0 .../panel/blog/back_end/posts/show.html.erb | 0 .../front_end/posts/_post_frontend.html.erb | 0 .../panel/blog/front_end/posts/index.html.erb | 0 .../panel/blog/front_end/posts/show.html.erb | 0 .../panel/blog/widget/posts/index.html.erb | 0 .../blog/widget/posts/latest_post.html.erb | 0 .../NewBlog/config/locales/en.yml | 0 .../NewBlog/config/locales/zh_tw.yml | 0 .../NewBlog/config/routes.rb | 0 .../NewBlog/lib/NewBlog.rb | 0 .../NewBlog/lib/NewBlog/engine.rb | 0 .../NewBlog/lib/NewBlog/version.rb | 0 .../NewBlog/lib/tasks/NewBlog_tasks.rake | 0 .../NewBlog/script/rails | 0 .../NewBlog/test/NewBlog_test.rb | 0 .../NewBlog/test/dummy/Rakefile | 0 .../app/assets/javascripts/application.js | 0 .../app/assets/stylesheets/application.css | 0 .../app/controllers/application_controller.rb | 0 .../dummy/app/helpers/application_helper.rb | 0 .../NewBlog/test/dummy/app/mailers/.gitkeep | 0 .../NewBlog/test/dummy/app/models/.gitkeep | 0 .../app/views/layouts/application.html.erb | 0 .../NewBlog/test/dummy/config.ru | 0 .../NewBlog/test/dummy/config/application.rb | 0 .../NewBlog/test/dummy/config/boot.rb | 0 .../NewBlog/test/dummy/config/database.yml | 0 .../NewBlog/test/dummy/config/environment.rb | 0 .../dummy/config/environments/development.rb | 0 .../dummy/config/environments/production.rb | 0 .../test/dummy/config/environments/test.rb | 0 .../initializers/backtrace_silencers.rb | 0 .../dummy/config/initializers/inflections.rb | 0 .../dummy/config/initializers/mime_types.rb | 0 .../dummy/config/initializers/secret_token.rb | 0 .../config/initializers/session_store.rb | 0 .../config/initializers/wrap_parameters.rb | 0 .../NewBlog/test/dummy/config/locales/en.yml | 0 .../NewBlog/test/dummy/config/mongoid.yml | 0 .../NewBlog/test/dummy/config/routes.rb | 0 .../NewBlog/test/dummy/lib/assets/.gitkeep | 0 .../NewBlog/test/dummy/log/.gitkeep | 0 .../NewBlog/test/dummy/public/404.html | 0 .../NewBlog/test/dummy/public/422.html | 0 .../NewBlog/test/dummy/public/500.html | 0 .../NewBlog/test/dummy/public/favicon.ico | 0 .../NewBlog/test/dummy/script/rails | 0 .../test/integration/navigation_test.rb | 0 .../NewBlog/test/test_helper.rb | 0 .../templates/sunrise/stylesheets/sunrise.css | 3 - 87 files changed, 524 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/rss.js create mode 100644 app/views/admin/designs/_new.html.erb create mode 100644 app/views/admin/designs/new.js.erb rename vendor/{plugins => built_in_modules}/NewBlog/.gitignore (100%) rename vendor/{plugins => built_in_modules}/NewBlog/Gemfile (100%) rename vendor/{plugins => built_in_modules}/NewBlog/Gemfile.lock (100%) rename vendor/{plugins => built_in_modules}/NewBlog/MIT-LICENSE (100%) rename vendor/{plugins => built_in_modules}/NewBlog/NewBlog.gemspec (100%) rename vendor/{plugins => built_in_modules}/NewBlog/NewBlog.json (100%) rename vendor/{plugins => built_in_modules}/NewBlog/README.rdoc (100%) rename vendor/{plugins => built_in_modules}/NewBlog/Rakefile (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/assets/images/NewBlog/.gitkeep (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/assets/javascripts/NewBlog/.gitkeep (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/assets/stylesheets/NewBlog/.gitkeep (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/assets/stylesheets/NewBlog/application.css (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/assets/stylesheets/NewBlog/production.css (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/controllers/.gitkeep (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/controllers/application_controller.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/controllers/panel/blog/front_end/comments_controller.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/controllers/panel/blog/widget/posts_controller.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/helpers/.gitkeep (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/helpers/application_helper.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/mailers/.gitkeep (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/models/.gitkeep (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/models/comment.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/models/post.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/.gitkeep (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/layouts/application.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/layouts/edit_view.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/layouts/production.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/panel/blog/back_end/posts/edit.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/panel/blog/back_end/posts/show.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/panel/blog/front_end/posts/_post_frontend.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/panel/blog/front_end/posts/index.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/panel/blog/widget/posts/index.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/config/locales/en.yml (100%) rename vendor/{plugins => built_in_modules}/NewBlog/config/locales/zh_tw.yml (100%) rename vendor/{plugins => built_in_modules}/NewBlog/config/routes.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/lib/NewBlog.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/lib/NewBlog/engine.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/lib/NewBlog/version.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/lib/tasks/NewBlog_tasks.rake (100%) rename vendor/{plugins => built_in_modules}/NewBlog/script/rails (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/NewBlog_test.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/Rakefile (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/app/assets/javascripts/application.js (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/app/assets/stylesheets/application.css (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/app/controllers/application_controller.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/app/helpers/application_helper.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/app/mailers/.gitkeep (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/app/models/.gitkeep (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/app/views/layouts/application.html.erb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config.ru (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/application.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/boot.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/database.yml (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/environment.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/environments/development.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/environments/production.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/environments/test.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/initializers/backtrace_silencers.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/initializers/inflections.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/initializers/mime_types.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/initializers/secret_token.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/initializers/session_store.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/initializers/wrap_parameters.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/locales/en.yml (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/mongoid.yml (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/config/routes.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/lib/assets/.gitkeep (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/log/.gitkeep (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/public/404.html (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/public/422.html (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/public/500.html (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/public/favicon.ico (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/dummy/script/rails (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/integration/navigation_test.rb (100%) rename vendor/{plugins => built_in_modules}/NewBlog/test/test_helper.rb (100%) delete mode 100644 vendor/templates/sunrise/stylesheets/sunrise.css diff --git a/app/assets/javascripts/rss.js b/app/assets/javascripts/rss.js new file mode 100644 index 00000000..36309900 --- /dev/null +++ b/app/assets/javascripts/rss.js @@ -0,0 +1,513 @@ +//Created by Harry Bomrah on Sep 21 2011 +$rss = jQuery.noConflict(); +var rcom={ +//Pass dom and will return binded dom with starting year till current +insertDatePanel : function(dom,year){ + if(!year)year=1901; + if(dom=="")return false; + domid=dom.attr("id"); + var dt = new Date(); + current_year=dt.getFullYear(); + var dthtml="Year: Date: Month: "; + dom.html(dthtml); +}, + +//loading overlay around a dom... +loadingWrapper : function(dom, display){ + if(display){ + dom.prepend("
    "); + $rss("#loading_wrapper").height(dom.height()); + $rss("#loading_wrapper").width(dom.width()); + }else{ + domId=dom.attr("id"); + $rss("#"+domId+" #loading_wrapper").remove(); + } + }, + +//validating a dom.... +validate : function(dom, validation, errormsg){ + var domValue = dom.val(); + var error = false; + var regex=""; + var msg = ""; + switch(validation){ + case "required": + if(domValue=="")error=true; + msg="Cannot be empty."; + break; + case "email": + regex=/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; + msg="Invalid Email Address."; + break; + case "number": + regex=/^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$/; + msg = "Only numbers are accepted."; + break; + case "alphanumeric": + regex=/^\s*[a-zA-Z0-9,\s]+\s*$/; + msg="Only numbers, alphabets and spaces are allowed."; + break; + } + domId=dom.attr("name"); + if(errormsg=="")errormsg=msg; + if(regex!="")if(!regex.test(domValue))error=true; + if(error){$rss("#"+domId+"_error").remove();dom.after(""+errormsg+"");return false;} else{ $rss("#"+domId+"_error").remove();return true;} + }, + +bindToSpinner : function(dom,data,callbackFn){ + var domId = dom.attr("id"); + var dhtml=""; + var spinnerValue=Array(); + var spinnerDisplay=Array(); + $rss.each(data,function(i,it){ + $rss.each(data[i],function(key,it){ + spinnerValue.push(it); + }); + }); + dhtml=""; + dom.html(dhtml); + if(typeof callbackFn=="function") + callbackFn.call(this, dhtml); + }, + + //binds the recieved json to a table +bindToTable : function(dom,data,headers,actions,css_class,callbackFn){ + if(!css_class)css_class=""; + var dhtml=""; + var domId = dom.attr("id"); + if(actions){ + var btnTitles=Array(); + var btnFunctions=Array(); + $rss.each(actions,function(title,func){ + btnTitles.push(title); + btnFunctions.push(func); + }); + rcom.translate(btnTitles,function(convertedData){ + btnTitles=convertedData.slice(); + + rcom.translate(headers,function(convertedData){ + headers=convertedData; + if(!data)return; + $rss.each(headers,function(i,head){ + dhtml+=""; + }); + dhtml+=""; + if(data.length==0)dhtml+=""; + $rss.each(data,function(i,item){ + var cl=""; + if(i%2!=0)cl="even"; + dhtml+=""; + $rss.each(item,function(i,it){ + if(i!="id"){ + if(it==null)it="Not Set"; + dhtml+=""; + } + }) + dhtml+=""; + dhtml+=""; + }); + dhtml+="
    "+head+"
    No Data
    "+it+""; + for(x=0;x"+btnTitles[x]+""; + } + dhtml+="
    "; + dom.html(dhtml); + }); + }); + }else{ + rcom.translate(headers,function(convertedData){ + headers=convertedData; + if(!data)return; + if(headers.length>0){ + $rss.each(headers,function(i,head){ + dhtml+=""+head+""; + }); + } + dhtml+=""; + if(data.length==0)dhtml+="No Data"; + + $rss.each(data,function(i,item){ + var cl=""; + if(i%2!=0)cl="even"; + dhtml+=""; + $rss.each(item,function(i,it){ + if(i!="id"){ + if(it==null)it="Not Set"; + dhtml+=""+it+""; + } + }) + dhtml+=""; + }); + dhtml+=""; + dom.html(dhtml); + }); + } + + if(typeof callbackFn=="function") + callbackFn.call(this, dhtml); +}, + //convert to date string which can be directly inserted in database or according to any format. +convertToInsertableDate : function(y,m,d,format){ + var dt=""; + if(m<10)m="0"+m; + if(d<10)d="0"+d; + switch(format){ + case "yyyy-mm-dd": + dt= y+"-"+m+"-"+d; + break; + case "dd-mm-yyyy": + dt= d+"-"+m+"-"+y; + break; + case "mm-dd-yyyy": + dt= m+"-"+d+"-"+y; + break; + default: + dt= y+"-"+m+"-"+d; + break; + } + return dt; + }, +//a fucntion to show specific divs and hide all other +showDoms : function(doms){ + $rss("body").find("div").each(function(){$rss(this).hide();}); + $rss.each(doms,function(i,dom){ + dom.show(); + }); + }, + +//a function to translate the word or array.. +translate : function(data,callbackFn){ + var cdata=""; + var status =true; + if(!data){ + if(typeof callbackFn=="function") + callbackFn.call(this,cdata); + status=false; + } + if(data==""){ + if(typeof callbackFn=="function") + callbackFn.call(this,cdata); + status=false; + } + if(status){ + $rss.getJSON("../../classes/translate.php", {fn:"translateThis",tData:data},function(convertedData){ + if(typeof callbackFn=="function") + callbackFn.call(this, convertedData); + }); + } + }, + +// a function to bind JSON to list +bindToList : function(dom,data,callbackFn){ + var domId = dom.attr("id"); + var dhtml=""; + var listValue=Array(); + var listDisplay=Array(); + $rss.each(data,function(i,it){ + $rss.each(data[i],function(key,it){ + listValue.push(it); + }); + }); + dhtml="
      "; + for(i=0,y=1,z=0;i"+listValue[y]+""; + } + dhtml+="
    "; + dom.html(dhtml); + if(typeof callbackFn=="function") + callbackFn.call(this,dhtml); + }, +makeDraggable : function(handler,dom){ + handler.css("position","absolute"); + dom.css("position","absolute"); + var puranix=0; + var nayeex=0; + var puraniy=0; + var nayeey=0; + var offset=""; + var zIndex=dom.css("z-index"); + handler.mousedown(function(e){ + puranix=e.clientX; + puraniy=e.clientY; + offset=dom.offset(); + $rss(this).mousemove(function(e){ + nayeex=e.clientX-puranix; + nayeex+=offset.left; + nayeey=e.clientY-puraniy; + nayeey+=offset.top; + dom.css({"left":nayeex+"px","top":nayeey+"px","z-index":"9999"}); + }) + }).mouseup(function(){ + $rss(this).unbind("mousemove"); + dom.css("z-index",zIndex); + }) + }, + +//automatically scrolls to the bottom of the div +scrollToBottom : function(dom){ + var domId = dom.attr("id"); +// var domScrollHeight = document.getElementById(domId).scrollHeight; + var obj = document.getElementById(domId); + + if((obj.scrollTop+100) >= (obj.scrollHeight - obj.offsetHeight)) + dom.scrollTop(obj.scrollHeight); + }, + +/*ajax loading of images... needs following settings +dom:in which images ve to be loaded +url:the server url for making ajax calls +limit:how many images to load +divClass:the class of div surrounding each image +nameClass:class for span showing name +fn:function to be called in on the server +imageSrc:the image source of all the images. +bindTo:to bind images to a onclick function or else will be binded to normal a tag. +urlKey:to specify the key of the value.. if bindTo is used, this will be neglected.. +returns json; +*/ +loadImages : function(settings,callbackFn){ + + var dom = settings.dom; + var domid= dom.attr("id"); + var temp_array=Array(); + var starting = $rss("#"+domid+" img:last").attr("id"); + if(typeof starting != 'undefined'){ + starting = starting.substr(4,starting.length-1); + }else{starting = 0}; + var temp_var=""; + var json = ""; + var dhtml=""; + var extraparam=""; + if(typeof settings.extraParam != "undefined"){ + extraparam = settings.extraParam; + } + $rss.getJSON(settings.url,{fn:settings.fn,id:settings.whereId,limit:settings.limit,start:starting,extra:extraparam},function(images){ + json = eval(images); + $rss.each(images,function(i,pic){ + var temp_array=Array(); + var a_var=Array(); + var name_var=""; + var title=""; + $rss.each(pic,function(i,value){ + temp_array.push(value); + }) + if(temp_array.length>=4){ + name_var=""+temp_array[3]+"
    " + } + if(temp_array[2]==null) + title = ""; + else + title = temp_array[2]; + if(typeof settings.bindTo!="undefined"){ + a_var[1]="onclick='"+settings.bindTo+"("+temp_array[0]+");return false;'"; + a_var[0]=""; + }else{a_var[0]='?'+settings.urlKey+'='+temp_array[0];a_var[1]="";} + dhtml="
    "+name_var; + dom.delay(100).append(dhtml); + $rss("#pic_"+pic.id).delay(100).fadeIn(200); + + }) + if(typeof callbackFn=="function") + callbackFn.call(this,json); + }) + + + }, + +//function to get url variables... +getUrlVars : function(){ + var vars = [], hash; + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); + for(var i = 0; i < hashes.length; i++){ + hash = hashes[i].split('='); + vars.push(hash[0]); + vars[hash[0]] = hash[1]; + } + return vars; +}, +/*function to open a modalwindow on a page.. self reliant no images, no css needed. +settings + +width:in percentage or pixcel +height:in percentage or pixcel +closeBtn:true or false +envClose:closing through background click, true or flase +loadDiv:load html from a div +loadPage:load a page +loadHtml: load html + +*/ +modalWindow : function(settings,callbackFn){ + + var envClose = settings.envClose; + var dhtml=""; + if(typeof envClose == "undefined") + envClose = true; + var closeBtn = settings.closeBtn; + if(typeof closeBtn == "undefined") + closeBtn = true; + + var rgmaskHeight = $rss(window).height(); + var rgmaskWidth = $rss(window).width(); + var tempheight = settings.height; + var tempwidth = settings.width; + + if(typeof tempheight!="undefined"){ + if(tempheight.charAt(tempheight.length-1)=='%') + tempheight=(rgmaskHeight*parseInt(tempheight.substr(0,tempheight.length)))/100; + }else{tempheight="auto";} + + if(typeof tempwidth!="undefined"){ + if(tempwidth.charAt(tempwidth.length-1)=='%') + tempwidth=(rgmaskWidth*parseInt(tempwidth.substr(0,tempwidth.length)))/100; + }else{tempwidth="auto";} + + $rss("body").append('
    '); + $rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.9,'z-index':199}); + $rss("body").append('
    '); + $rss("#rgWindow").css({"position": "fixed", "z-index": "999", "background": "#fff", "border": "solid 3px #ccc", "padding": "20px", "overflow": "hidden", "border-radius": "12px", "-webkit-border-radius": "12px", "-moz-border-radius": "12px", "-ms-border-radius": "12px", "box-shadow": "0 0 20px rgba(0,0,0,0.9)","-webkit-box-shadow": "0 0 20px rgba(0,0,0,0.9)","-moz-box-shadow": "0 0 20px rgba(0,0,0,0.9)","-ms-box-shadow": "0 0 20px rgba(0,0,0,0.9)"}); + var rgWTop = (rgmaskHeight-20)/2; + var rgWLeft = (rgmaskWidth-20)/2; + $rss("#rgWindow").css({top:rgWTop+"px", left:rgWLeft+"px"}); + if(typeof settings.loadDiv!="undefined"){ + dhtml = $rss("#"+settings.loadDiv).html(); + $rss("#rgWindow").html(dhtml).hide(); + prepareWindow(); + } + if(typeof settings.loadHtml!="undefined"){ + dhtml = settings.loadHtml; + $rss("#rgWindow").html(dhtml).hide(); + prepareWindow(); + } + if(typeof settings.loadPage!="undefined"){ + $rss("#rgWindow").load(settings.loadPage,function(){$rss(this).hide();dhtml=$rss(this).html();prepareWindow();}); + } + function prepareWindow(){ + if(tempheight!="auto") + rgWTop = (rgmaskHeight-tempheight)/2; + else{ + tempheight=$rss("#rgWindow").height(); + rgWTop=(rgmaskHeight-tempheight)/2; + } + if(tempwidth!="auto") + rgWLeft = (rgmaskWidth-tempwidth)/2; + else{ + tempwidth=$rss("#rgWindow").width(); + rgWLeft=(rgmaskWidth-tempwidth)/2; + } + $rss("#rgWindow").empty().show(); + var closebtn = ""; + if(closeBtn) + closebtn='X'; + $rss("#rgWindow").animate({"width":tempwidth+"px","height":tempheight+"px",top:rgWTop+"px", left:rgWLeft+"px"},500,function(){$rss("#rgWindow").html(closebtn+"
    "+dhtml+"
    "); + $rss("#close_modal").mouseover(function(){$rss(this).css("color","#999");}).mouseout(function(){$rss(this).css("color","#666");}) + $rss("#close_modal").click(function(){ + $rss("#rgWindow").empty(); + var x = (rgmaskHeight-20)/2; + var y = (rgmaskWidth-20)/2; + $rss("#rgWindow").animate({top:x+"px", left:y+"px","width":"50px","height":"50px"},300,function(){$rss(this).fadeOut(100).remove();$rss("#rgsheath").fadeOut(500).remove();}); + return false; + }) + if(envClose) + $rss("#rgsheath").click(function(){ + $rss("#rgWindow").empty(); + var x = (rgmaskHeight-20)/2; + var y = (rgmaskWidth-20)/2; + $rss("#rgWindow").animate({top:x+"px", left:y+"px","width":"50px","height":"50px"},300,function(){$rss(this).fadeOut(100).remove();$rss("#rgsheath").fadeOut(500).remove();});}) + + if(typeof callbackFn=="function") + callbackFn.call(this,dhtml); + }); + } +}, +modalWindowClose : function(callbackFn){ + if($rss("#rgWindow").length>0){ + $rss("#rgWindow").empty(); + var rgmaskHeight = $rss(window).height(); + var rgmaskWidth = $rss(window).width(); + var x = (rgmaskHeight-20)/2; + var y = (rgmaskWidth-20)/2 + $rss("#rgWindow").animate({top:x+"px", left:y+"px","width":"50px","height":"50px"},300,function(){$rss(this).fadeOut(100).remove();$rss("#rgsheath").fadeOut(500).remove();}) + } + if(typeof callbackFn=="function") + callbackFn.call(this,"harry"); +}, +bindDomToHead : function(dom){ + var gc = dom.css("background"); + var t = dom.offset(); + var gw = dom.width(); + $rss(window).scroll(function(){ + var wt = $rss(window).scrollTop(); + if ( wt > t.top ) { + var cssObj = { + 'position':'fixed', + 'top':0, + 'width':gw, + 'background':gc, + 'box-shadow':'0 1px 0 rgba(0,0,0,0.2)', + 'z-index':99 + } + dom.css(cssObj); + } else { + dom.attr('style',""); + } + }); +}, +progressBar : function(dom,settings){ + var domid = dom.prop("id"); + if($rss("#rss_progressbar_div_"+domid).length==0){ + if(typeof settings.top == "undefined") + settings.value = 1; + if(typeof settings.top == "undefined") + settings.top = (dom.height()-12)/2; + dom.append(""); + $rss("#rss_progressbar_div_"+domid).fadeIn(500); + } +}, +progressBarValue : function(dom,value){ + var domid = dom.prop("id"); + if($rss("#rss_progressbar_div_"+domid).length==1){ + $rss("#rss_progressbar_"+domid).animate({"width":value+"%"},100); + + } +}, +progressBarClose : function(dom){ + var domid = dom.prop("id"); + $rss("#rss_progressbar_div_"+domid).fadeOut(500,function(){$(this).remove();}); +}, +getInternetExplorerVersion: function(){ + var rv = -1; // Return value assumes failure. + if (navigator.appName == 'Microsoft Internet Explorer') + { + var ua = navigator.userAgent; + var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); + if (re.exec(ua) != null) + rv = parseFloat( RegExp.$1 ); + } + return rv; + } +} +$ = jQuery.noConflict(); \ No newline at end of file diff --git a/app/views/admin/designs/_new.html.erb b/app/views/admin/designs/_new.html.erb new file mode 100644 index 00000000..ded2237a --- /dev/null +++ b/app/views/admin/designs/_new.html.erb @@ -0,0 +1,10 @@ +

    <%= t('admin.new_design') %>

    + +<%= form_for :design, :url => admin_designs_path do |f| %> + <%= f.error_messages %> + <%= render :partial => "form", :locals => { :f => f } %> + +

    + <%= f.submit t('create') %> <%= link_back %> +

    +<% end %> diff --git a/app/views/admin/designs/new.js.erb b/app/views/admin/designs/new.js.erb new file mode 100644 index 00000000..7b41a5c0 --- /dev/null +++ b/app/views/admin/designs/new.js.erb @@ -0,0 +1 @@ +rcom.modalWindow({loadHtml:"<%= escape_javascript(render(:partial => 'new')) %>"}); \ No newline at end of file diff --git a/vendor/plugins/NewBlog/.gitignore b/vendor/built_in_modules/NewBlog/.gitignore similarity index 100% rename from vendor/plugins/NewBlog/.gitignore rename to vendor/built_in_modules/NewBlog/.gitignore diff --git a/vendor/plugins/NewBlog/Gemfile b/vendor/built_in_modules/NewBlog/Gemfile similarity index 100% rename from vendor/plugins/NewBlog/Gemfile rename to vendor/built_in_modules/NewBlog/Gemfile diff --git a/vendor/plugins/NewBlog/Gemfile.lock b/vendor/built_in_modules/NewBlog/Gemfile.lock similarity index 100% rename from vendor/plugins/NewBlog/Gemfile.lock rename to vendor/built_in_modules/NewBlog/Gemfile.lock diff --git a/vendor/plugins/NewBlog/MIT-LICENSE b/vendor/built_in_modules/NewBlog/MIT-LICENSE similarity index 100% rename from vendor/plugins/NewBlog/MIT-LICENSE rename to vendor/built_in_modules/NewBlog/MIT-LICENSE diff --git a/vendor/plugins/NewBlog/NewBlog.gemspec b/vendor/built_in_modules/NewBlog/NewBlog.gemspec similarity index 100% rename from vendor/plugins/NewBlog/NewBlog.gemspec rename to vendor/built_in_modules/NewBlog/NewBlog.gemspec diff --git a/vendor/plugins/NewBlog/NewBlog.json b/vendor/built_in_modules/NewBlog/NewBlog.json similarity index 100% rename from vendor/plugins/NewBlog/NewBlog.json rename to vendor/built_in_modules/NewBlog/NewBlog.json diff --git a/vendor/plugins/NewBlog/README.rdoc b/vendor/built_in_modules/NewBlog/README.rdoc similarity index 100% rename from vendor/plugins/NewBlog/README.rdoc rename to vendor/built_in_modules/NewBlog/README.rdoc diff --git a/vendor/plugins/NewBlog/Rakefile b/vendor/built_in_modules/NewBlog/Rakefile similarity index 100% rename from vendor/plugins/NewBlog/Rakefile rename to vendor/built_in_modules/NewBlog/Rakefile diff --git a/vendor/plugins/NewBlog/app/assets/images/NewBlog/.gitkeep b/vendor/built_in_modules/NewBlog/app/assets/images/NewBlog/.gitkeep similarity index 100% rename from vendor/plugins/NewBlog/app/assets/images/NewBlog/.gitkeep rename to vendor/built_in_modules/NewBlog/app/assets/images/NewBlog/.gitkeep diff --git a/vendor/plugins/NewBlog/app/assets/javascripts/NewBlog/.gitkeep b/vendor/built_in_modules/NewBlog/app/assets/javascripts/NewBlog/.gitkeep similarity index 100% rename from vendor/plugins/NewBlog/app/assets/javascripts/NewBlog/.gitkeep rename to vendor/built_in_modules/NewBlog/app/assets/javascripts/NewBlog/.gitkeep diff --git a/vendor/plugins/NewBlog/app/assets/stylesheets/NewBlog/.gitkeep b/vendor/built_in_modules/NewBlog/app/assets/stylesheets/NewBlog/.gitkeep similarity index 100% rename from vendor/plugins/NewBlog/app/assets/stylesheets/NewBlog/.gitkeep rename to vendor/built_in_modules/NewBlog/app/assets/stylesheets/NewBlog/.gitkeep diff --git a/vendor/plugins/NewBlog/app/assets/stylesheets/NewBlog/application.css b/vendor/built_in_modules/NewBlog/app/assets/stylesheets/NewBlog/application.css similarity index 100% rename from vendor/plugins/NewBlog/app/assets/stylesheets/NewBlog/application.css rename to vendor/built_in_modules/NewBlog/app/assets/stylesheets/NewBlog/application.css diff --git a/vendor/plugins/NewBlog/app/assets/stylesheets/NewBlog/production.css b/vendor/built_in_modules/NewBlog/app/assets/stylesheets/NewBlog/production.css similarity index 100% rename from vendor/plugins/NewBlog/app/assets/stylesheets/NewBlog/production.css rename to vendor/built_in_modules/NewBlog/app/assets/stylesheets/NewBlog/production.css diff --git a/vendor/plugins/NewBlog/app/controllers/.gitkeep b/vendor/built_in_modules/NewBlog/app/controllers/.gitkeep similarity index 100% rename from vendor/plugins/NewBlog/app/controllers/.gitkeep rename to vendor/built_in_modules/NewBlog/app/controllers/.gitkeep diff --git a/vendor/plugins/NewBlog/app/controllers/application_controller.rb b/vendor/built_in_modules/NewBlog/app/controllers/application_controller.rb similarity index 100% rename from vendor/plugins/NewBlog/app/controllers/application_controller.rb rename to vendor/built_in_modules/NewBlog/app/controllers/application_controller.rb diff --git a/vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb b/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb similarity index 100% rename from vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb rename to vendor/built_in_modules/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb diff --git a/vendor/plugins/NewBlog/app/controllers/panel/blog/front_end/comments_controller.rb b/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/comments_controller.rb similarity index 100% rename from vendor/plugins/NewBlog/app/controllers/panel/blog/front_end/comments_controller.rb rename to vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/comments_controller.rb diff --git a/vendor/plugins/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb b/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb similarity index 100% rename from vendor/plugins/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb rename to vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb diff --git a/vendor/plugins/NewBlog/app/controllers/panel/blog/widget/posts_controller.rb b/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/widget/posts_controller.rb similarity index 100% rename from vendor/plugins/NewBlog/app/controllers/panel/blog/widget/posts_controller.rb rename to vendor/built_in_modules/NewBlog/app/controllers/panel/blog/widget/posts_controller.rb diff --git a/vendor/plugins/NewBlog/app/helpers/.gitkeep b/vendor/built_in_modules/NewBlog/app/helpers/.gitkeep similarity index 100% rename from vendor/plugins/NewBlog/app/helpers/.gitkeep rename to vendor/built_in_modules/NewBlog/app/helpers/.gitkeep diff --git a/vendor/plugins/NewBlog/app/helpers/application_helper.rb b/vendor/built_in_modules/NewBlog/app/helpers/application_helper.rb similarity index 100% rename from vendor/plugins/NewBlog/app/helpers/application_helper.rb rename to vendor/built_in_modules/NewBlog/app/helpers/application_helper.rb diff --git a/vendor/plugins/NewBlog/app/mailers/.gitkeep b/vendor/built_in_modules/NewBlog/app/mailers/.gitkeep similarity index 100% rename from vendor/plugins/NewBlog/app/mailers/.gitkeep rename to vendor/built_in_modules/NewBlog/app/mailers/.gitkeep diff --git a/vendor/plugins/NewBlog/app/models/.gitkeep b/vendor/built_in_modules/NewBlog/app/models/.gitkeep similarity index 100% rename from vendor/plugins/NewBlog/app/models/.gitkeep rename to vendor/built_in_modules/NewBlog/app/models/.gitkeep diff --git a/vendor/plugins/NewBlog/app/models/comment.rb b/vendor/built_in_modules/NewBlog/app/models/comment.rb similarity index 100% rename from vendor/plugins/NewBlog/app/models/comment.rb rename to vendor/built_in_modules/NewBlog/app/models/comment.rb diff --git a/vendor/plugins/NewBlog/app/models/post.rb b/vendor/built_in_modules/NewBlog/app/models/post.rb similarity index 100% rename from vendor/plugins/NewBlog/app/models/post.rb rename to vendor/built_in_modules/NewBlog/app/models/post.rb diff --git a/vendor/plugins/NewBlog/app/views/.gitkeep b/vendor/built_in_modules/NewBlog/app/views/.gitkeep similarity index 100% rename from vendor/plugins/NewBlog/app/views/.gitkeep rename to vendor/built_in_modules/NewBlog/app/views/.gitkeep diff --git a/vendor/plugins/NewBlog/app/views/layouts/application.html.erb b/vendor/built_in_modules/NewBlog/app/views/layouts/application.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/layouts/application.html.erb rename to vendor/built_in_modules/NewBlog/app/views/layouts/application.html.erb diff --git a/vendor/plugins/NewBlog/app/views/layouts/edit_view.html.erb b/vendor/built_in_modules/NewBlog/app/views/layouts/edit_view.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/layouts/edit_view.html.erb rename to vendor/built_in_modules/NewBlog/app/views/layouts/edit_view.html.erb diff --git a/vendor/plugins/NewBlog/app/views/layouts/production.html.erb b/vendor/built_in_modules/NewBlog/app/views/layouts/production.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/layouts/production.html.erb rename to vendor/built_in_modules/NewBlog/app/views/layouts/production.html.erb diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb b/vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb rename to vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/edit.html.erb b/vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/edit.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/edit.html.erb rename to vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/edit.html.erb diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb b/vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb rename to vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb b/vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb rename to vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb b/vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb rename to vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/show.html.erb b/vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/show.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/show.html.erb rename to vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/show.html.erb diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/_post_frontend.html.erb b/vendor/built_in_modules/NewBlog/app/views/panel/blog/front_end/posts/_post_frontend.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/_post_frontend.html.erb rename to vendor/built_in_modules/NewBlog/app/views/panel/blog/front_end/posts/_post_frontend.html.erb diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/index.html.erb b/vendor/built_in_modules/NewBlog/app/views/panel/blog/front_end/posts/index.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/index.html.erb rename to vendor/built_in_modules/NewBlog/app/views/panel/blog/front_end/posts/index.html.erb diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb b/vendor/built_in_modules/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb rename to vendor/built_in_modules/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb b/vendor/built_in_modules/NewBlog/app/views/panel/blog/widget/posts/index.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb rename to vendor/built_in_modules/NewBlog/app/views/panel/blog/widget/posts/index.html.erb diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb b/vendor/built_in_modules/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb similarity index 100% rename from vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb rename to vendor/built_in_modules/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb diff --git a/vendor/plugins/NewBlog/config/locales/en.yml b/vendor/built_in_modules/NewBlog/config/locales/en.yml similarity index 100% rename from vendor/plugins/NewBlog/config/locales/en.yml rename to vendor/built_in_modules/NewBlog/config/locales/en.yml diff --git a/vendor/plugins/NewBlog/config/locales/zh_tw.yml b/vendor/built_in_modules/NewBlog/config/locales/zh_tw.yml similarity index 100% rename from vendor/plugins/NewBlog/config/locales/zh_tw.yml rename to vendor/built_in_modules/NewBlog/config/locales/zh_tw.yml diff --git a/vendor/plugins/NewBlog/config/routes.rb b/vendor/built_in_modules/NewBlog/config/routes.rb similarity index 100% rename from vendor/plugins/NewBlog/config/routes.rb rename to vendor/built_in_modules/NewBlog/config/routes.rb diff --git a/vendor/plugins/NewBlog/lib/NewBlog.rb b/vendor/built_in_modules/NewBlog/lib/NewBlog.rb similarity index 100% rename from vendor/plugins/NewBlog/lib/NewBlog.rb rename to vendor/built_in_modules/NewBlog/lib/NewBlog.rb diff --git a/vendor/plugins/NewBlog/lib/NewBlog/engine.rb b/vendor/built_in_modules/NewBlog/lib/NewBlog/engine.rb similarity index 100% rename from vendor/plugins/NewBlog/lib/NewBlog/engine.rb rename to vendor/built_in_modules/NewBlog/lib/NewBlog/engine.rb diff --git a/vendor/plugins/NewBlog/lib/NewBlog/version.rb b/vendor/built_in_modules/NewBlog/lib/NewBlog/version.rb similarity index 100% rename from vendor/plugins/NewBlog/lib/NewBlog/version.rb rename to vendor/built_in_modules/NewBlog/lib/NewBlog/version.rb diff --git a/vendor/plugins/NewBlog/lib/tasks/NewBlog_tasks.rake b/vendor/built_in_modules/NewBlog/lib/tasks/NewBlog_tasks.rake similarity index 100% rename from vendor/plugins/NewBlog/lib/tasks/NewBlog_tasks.rake rename to vendor/built_in_modules/NewBlog/lib/tasks/NewBlog_tasks.rake diff --git a/vendor/plugins/NewBlog/script/rails b/vendor/built_in_modules/NewBlog/script/rails similarity index 100% rename from vendor/plugins/NewBlog/script/rails rename to vendor/built_in_modules/NewBlog/script/rails diff --git a/vendor/plugins/NewBlog/test/NewBlog_test.rb b/vendor/built_in_modules/NewBlog/test/NewBlog_test.rb similarity index 100% rename from vendor/plugins/NewBlog/test/NewBlog_test.rb rename to vendor/built_in_modules/NewBlog/test/NewBlog_test.rb diff --git a/vendor/plugins/NewBlog/test/dummy/Rakefile b/vendor/built_in_modules/NewBlog/test/dummy/Rakefile similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/Rakefile rename to vendor/built_in_modules/NewBlog/test/dummy/Rakefile diff --git a/vendor/plugins/NewBlog/test/dummy/app/assets/javascripts/application.js b/vendor/built_in_modules/NewBlog/test/dummy/app/assets/javascripts/application.js similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/app/assets/javascripts/application.js rename to vendor/built_in_modules/NewBlog/test/dummy/app/assets/javascripts/application.js diff --git a/vendor/plugins/NewBlog/test/dummy/app/assets/stylesheets/application.css b/vendor/built_in_modules/NewBlog/test/dummy/app/assets/stylesheets/application.css similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/app/assets/stylesheets/application.css rename to vendor/built_in_modules/NewBlog/test/dummy/app/assets/stylesheets/application.css diff --git a/vendor/plugins/NewBlog/test/dummy/app/controllers/application_controller.rb b/vendor/built_in_modules/NewBlog/test/dummy/app/controllers/application_controller.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/app/controllers/application_controller.rb rename to vendor/built_in_modules/NewBlog/test/dummy/app/controllers/application_controller.rb diff --git a/vendor/plugins/NewBlog/test/dummy/app/helpers/application_helper.rb b/vendor/built_in_modules/NewBlog/test/dummy/app/helpers/application_helper.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/app/helpers/application_helper.rb rename to vendor/built_in_modules/NewBlog/test/dummy/app/helpers/application_helper.rb diff --git a/vendor/plugins/NewBlog/test/dummy/app/mailers/.gitkeep b/vendor/built_in_modules/NewBlog/test/dummy/app/mailers/.gitkeep similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/app/mailers/.gitkeep rename to vendor/built_in_modules/NewBlog/test/dummy/app/mailers/.gitkeep diff --git a/vendor/plugins/NewBlog/test/dummy/app/models/.gitkeep b/vendor/built_in_modules/NewBlog/test/dummy/app/models/.gitkeep similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/app/models/.gitkeep rename to vendor/built_in_modules/NewBlog/test/dummy/app/models/.gitkeep diff --git a/vendor/plugins/NewBlog/test/dummy/app/views/layouts/application.html.erb b/vendor/built_in_modules/NewBlog/test/dummy/app/views/layouts/application.html.erb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/app/views/layouts/application.html.erb rename to vendor/built_in_modules/NewBlog/test/dummy/app/views/layouts/application.html.erb diff --git a/vendor/plugins/NewBlog/test/dummy/config.ru b/vendor/built_in_modules/NewBlog/test/dummy/config.ru similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config.ru rename to vendor/built_in_modules/NewBlog/test/dummy/config.ru diff --git a/vendor/plugins/NewBlog/test/dummy/config/application.rb b/vendor/built_in_modules/NewBlog/test/dummy/config/application.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/application.rb rename to vendor/built_in_modules/NewBlog/test/dummy/config/application.rb diff --git a/vendor/plugins/NewBlog/test/dummy/config/boot.rb b/vendor/built_in_modules/NewBlog/test/dummy/config/boot.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/boot.rb rename to vendor/built_in_modules/NewBlog/test/dummy/config/boot.rb diff --git a/vendor/plugins/NewBlog/test/dummy/config/database.yml b/vendor/built_in_modules/NewBlog/test/dummy/config/database.yml similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/database.yml rename to vendor/built_in_modules/NewBlog/test/dummy/config/database.yml diff --git a/vendor/plugins/NewBlog/test/dummy/config/environment.rb b/vendor/built_in_modules/NewBlog/test/dummy/config/environment.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/environment.rb rename to vendor/built_in_modules/NewBlog/test/dummy/config/environment.rb diff --git a/vendor/plugins/NewBlog/test/dummy/config/environments/development.rb b/vendor/built_in_modules/NewBlog/test/dummy/config/environments/development.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/environments/development.rb rename to vendor/built_in_modules/NewBlog/test/dummy/config/environments/development.rb diff --git a/vendor/plugins/NewBlog/test/dummy/config/environments/production.rb b/vendor/built_in_modules/NewBlog/test/dummy/config/environments/production.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/environments/production.rb rename to vendor/built_in_modules/NewBlog/test/dummy/config/environments/production.rb diff --git a/vendor/plugins/NewBlog/test/dummy/config/environments/test.rb b/vendor/built_in_modules/NewBlog/test/dummy/config/environments/test.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/environments/test.rb rename to vendor/built_in_modules/NewBlog/test/dummy/config/environments/test.rb diff --git a/vendor/plugins/NewBlog/test/dummy/config/initializers/backtrace_silencers.rb b/vendor/built_in_modules/NewBlog/test/dummy/config/initializers/backtrace_silencers.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/initializers/backtrace_silencers.rb rename to vendor/built_in_modules/NewBlog/test/dummy/config/initializers/backtrace_silencers.rb diff --git a/vendor/plugins/NewBlog/test/dummy/config/initializers/inflections.rb b/vendor/built_in_modules/NewBlog/test/dummy/config/initializers/inflections.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/initializers/inflections.rb rename to vendor/built_in_modules/NewBlog/test/dummy/config/initializers/inflections.rb diff --git a/vendor/plugins/NewBlog/test/dummy/config/initializers/mime_types.rb b/vendor/built_in_modules/NewBlog/test/dummy/config/initializers/mime_types.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/initializers/mime_types.rb rename to vendor/built_in_modules/NewBlog/test/dummy/config/initializers/mime_types.rb diff --git a/vendor/plugins/NewBlog/test/dummy/config/initializers/secret_token.rb b/vendor/built_in_modules/NewBlog/test/dummy/config/initializers/secret_token.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/initializers/secret_token.rb rename to vendor/built_in_modules/NewBlog/test/dummy/config/initializers/secret_token.rb diff --git a/vendor/plugins/NewBlog/test/dummy/config/initializers/session_store.rb b/vendor/built_in_modules/NewBlog/test/dummy/config/initializers/session_store.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/initializers/session_store.rb rename to vendor/built_in_modules/NewBlog/test/dummy/config/initializers/session_store.rb diff --git a/vendor/plugins/NewBlog/test/dummy/config/initializers/wrap_parameters.rb b/vendor/built_in_modules/NewBlog/test/dummy/config/initializers/wrap_parameters.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/initializers/wrap_parameters.rb rename to vendor/built_in_modules/NewBlog/test/dummy/config/initializers/wrap_parameters.rb diff --git a/vendor/plugins/NewBlog/test/dummy/config/locales/en.yml b/vendor/built_in_modules/NewBlog/test/dummy/config/locales/en.yml similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/locales/en.yml rename to vendor/built_in_modules/NewBlog/test/dummy/config/locales/en.yml diff --git a/vendor/plugins/NewBlog/test/dummy/config/mongoid.yml b/vendor/built_in_modules/NewBlog/test/dummy/config/mongoid.yml similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/mongoid.yml rename to vendor/built_in_modules/NewBlog/test/dummy/config/mongoid.yml diff --git a/vendor/plugins/NewBlog/test/dummy/config/routes.rb b/vendor/built_in_modules/NewBlog/test/dummy/config/routes.rb similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/config/routes.rb rename to vendor/built_in_modules/NewBlog/test/dummy/config/routes.rb diff --git a/vendor/plugins/NewBlog/test/dummy/lib/assets/.gitkeep b/vendor/built_in_modules/NewBlog/test/dummy/lib/assets/.gitkeep similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/lib/assets/.gitkeep rename to vendor/built_in_modules/NewBlog/test/dummy/lib/assets/.gitkeep diff --git a/vendor/plugins/NewBlog/test/dummy/log/.gitkeep b/vendor/built_in_modules/NewBlog/test/dummy/log/.gitkeep similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/log/.gitkeep rename to vendor/built_in_modules/NewBlog/test/dummy/log/.gitkeep diff --git a/vendor/plugins/NewBlog/test/dummy/public/404.html b/vendor/built_in_modules/NewBlog/test/dummy/public/404.html similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/public/404.html rename to vendor/built_in_modules/NewBlog/test/dummy/public/404.html diff --git a/vendor/plugins/NewBlog/test/dummy/public/422.html b/vendor/built_in_modules/NewBlog/test/dummy/public/422.html similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/public/422.html rename to vendor/built_in_modules/NewBlog/test/dummy/public/422.html diff --git a/vendor/plugins/NewBlog/test/dummy/public/500.html b/vendor/built_in_modules/NewBlog/test/dummy/public/500.html similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/public/500.html rename to vendor/built_in_modules/NewBlog/test/dummy/public/500.html diff --git a/vendor/plugins/NewBlog/test/dummy/public/favicon.ico b/vendor/built_in_modules/NewBlog/test/dummy/public/favicon.ico similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/public/favicon.ico rename to vendor/built_in_modules/NewBlog/test/dummy/public/favicon.ico diff --git a/vendor/plugins/NewBlog/test/dummy/script/rails b/vendor/built_in_modules/NewBlog/test/dummy/script/rails similarity index 100% rename from vendor/plugins/NewBlog/test/dummy/script/rails rename to vendor/built_in_modules/NewBlog/test/dummy/script/rails diff --git a/vendor/plugins/NewBlog/test/integration/navigation_test.rb b/vendor/built_in_modules/NewBlog/test/integration/navigation_test.rb similarity index 100% rename from vendor/plugins/NewBlog/test/integration/navigation_test.rb rename to vendor/built_in_modules/NewBlog/test/integration/navigation_test.rb diff --git a/vendor/plugins/NewBlog/test/test_helper.rb b/vendor/built_in_modules/NewBlog/test/test_helper.rb similarity index 100% rename from vendor/plugins/NewBlog/test/test_helper.rb rename to vendor/built_in_modules/NewBlog/test/test_helper.rb diff --git a/vendor/templates/sunrise/stylesheets/sunrise.css b/vendor/templates/sunrise/stylesheets/sunrise.css deleted file mode 100644 index 9b1e02f0..00000000 --- a/vendor/templates/sunrise/stylesheets/sunrise.css +++ /dev/null @@ -1,3 +0,0 @@ -body { - background-color :red; -} From 708a174345c991bb38be6a58f3aea6e30895e448 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Thu, 22 Dec 2011 11:27:37 +0800 Subject: [PATCH 10/20] Remove radius from plugins, put it in Gemfile --- Gemfile | 2 + Gemfile.lock | 3 + lib/parser.rb | 1 + lib/tasks/dev.rake | 2 +- vendor/plugins/radius/.gitignore | 4 - vendor/plugins/radius/CHANGELOG | 42 - vendor/plugins/radius/LICENSE | 19 - vendor/plugins/radius/QUICKSTART.rdoc | 322 ----- vendor/plugins/radius/README.rdoc | 100 -- vendor/plugins/radius/Rakefile | 8 - vendor/plugins/radius/VERSION | 1 - vendor/plugins/radius/lib/radius.rb | 11 - vendor/plugins/radius/lib/radius/context.rb | 147 -- .../lib/radius/delegating_open_struct.rb | 37 - vendor/plugins/radius/lib/radius/error.rb | 43 - .../plugins/radius/lib/radius/ord_string.rb | 13 - vendor/plugins/radius/lib/radius/parse_tag.rb | 24 - vendor/plugins/radius/lib/radius/parser.rb | 79 -- .../lib/radius/parser/JavaScanner.class | Bin 16807 -> 0 bytes .../radius/lib/radius/parser/JavaScanner.java | 634 --------- .../radius/lib/radius/parser/JavaScanner.rl | 179 --- .../radius/lib/radius/parser/java_scanner.jar | Bin 9560 -> 0 bytes .../radius/lib/radius/parser/scanner.rb | 1255 ----------------- .../radius/lib/radius/parser/scanner.rl | 125 -- .../lib/radius/parser/squiggle_scanner.rb | 1238 ---------------- .../lib/radius/parser/squiggle_scanner.rl | 126 -- .../plugins/radius/lib/radius/tag_binding.rb | 71 - .../radius/lib/radius/tag_definitions.rb | 78 - vendor/plugins/radius/lib/radius/utility.rb | 40 - vendor/plugins/radius/lib/radius/version.rb | 8 - vendor/plugins/radius/radius.gemspec | 94 -- vendor/plugins/radius/tasks/jeweler.rake | 22 - vendor/plugins/radius/tasks/rdoc.rake | 13 - vendor/plugins/radius/tasks/rubinius.rake | 4 - vendor/plugins/radius/tasks/scan.rake | 79 -- vendor/plugins/radius/tasks/test.rake | 7 - vendor/plugins/radius/test/benchmarks.rb | 35 - vendor/plugins/radius/test/context_test.rb | 61 - .../plugins/radius/test/multithreaded_test.rb | 62 - vendor/plugins/radius/test/ord_string_test.rb | 18 - vendor/plugins/radius/test/parser_test.rb | 307 ---- vendor/plugins/radius/test/quickstart_test.rb | 151 -- vendor/plugins/radius/test/squiggle_test.rb | 281 ---- vendor/plugins/radius/test/test_helper.rb | 36 - vendor/plugins/radius/test/utility_test.rb | 30 - 45 files changed, 7 insertions(+), 5805 deletions(-) delete mode 100644 vendor/plugins/radius/.gitignore delete mode 100644 vendor/plugins/radius/CHANGELOG delete mode 100644 vendor/plugins/radius/LICENSE delete mode 100644 vendor/plugins/radius/QUICKSTART.rdoc delete mode 100644 vendor/plugins/radius/README.rdoc delete mode 100644 vendor/plugins/radius/Rakefile delete mode 100644 vendor/plugins/radius/VERSION delete mode 100644 vendor/plugins/radius/lib/radius.rb delete mode 100644 vendor/plugins/radius/lib/radius/context.rb delete mode 100644 vendor/plugins/radius/lib/radius/delegating_open_struct.rb delete mode 100644 vendor/plugins/radius/lib/radius/error.rb delete mode 100644 vendor/plugins/radius/lib/radius/ord_string.rb delete mode 100644 vendor/plugins/radius/lib/radius/parse_tag.rb delete mode 100644 vendor/plugins/radius/lib/radius/parser.rb delete mode 100644 vendor/plugins/radius/lib/radius/parser/JavaScanner.class delete mode 100644 vendor/plugins/radius/lib/radius/parser/JavaScanner.java delete mode 100644 vendor/plugins/radius/lib/radius/parser/JavaScanner.rl delete mode 100644 vendor/plugins/radius/lib/radius/parser/java_scanner.jar delete mode 100644 vendor/plugins/radius/lib/radius/parser/scanner.rb delete mode 100644 vendor/plugins/radius/lib/radius/parser/scanner.rl delete mode 100644 vendor/plugins/radius/lib/radius/parser/squiggle_scanner.rb delete mode 100644 vendor/plugins/radius/lib/radius/parser/squiggle_scanner.rl delete mode 100644 vendor/plugins/radius/lib/radius/tag_binding.rb delete mode 100644 vendor/plugins/radius/lib/radius/tag_definitions.rb delete mode 100644 vendor/plugins/radius/lib/radius/utility.rb delete mode 100644 vendor/plugins/radius/lib/radius/version.rb delete mode 100644 vendor/plugins/radius/radius.gemspec delete mode 100644 vendor/plugins/radius/tasks/jeweler.rake delete mode 100644 vendor/plugins/radius/tasks/rdoc.rake delete mode 100644 vendor/plugins/radius/tasks/rubinius.rake delete mode 100644 vendor/plugins/radius/tasks/scan.rake delete mode 100644 vendor/plugins/radius/tasks/test.rake delete mode 100644 vendor/plugins/radius/test/benchmarks.rb delete mode 100644 vendor/plugins/radius/test/context_test.rb delete mode 100644 vendor/plugins/radius/test/multithreaded_test.rb delete mode 100644 vendor/plugins/radius/test/ord_string_test.rb delete mode 100644 vendor/plugins/radius/test/parser_test.rb delete mode 100644 vendor/plugins/radius/test/quickstart_test.rb delete mode 100644 vendor/plugins/radius/test/squiggle_test.rb delete mode 100644 vendor/plugins/radius/test/test_helper.rb delete mode 100644 vendor/plugins/radius/test/utility_test.rb diff --git a/Gemfile b/Gemfile index 93d151f6..4fe1340a 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,8 @@ gem 'jquery-rails' gem 'sprockets' +gem 'radius' + # For linux gem 'therubyracer' diff --git a/Gemfile.lock b/Gemfile.lock index ac60fca1..8e073610 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -59,6 +59,7 @@ GEM execjs coffee-script-source (1.1.3) columnize (0.3.5) + database_cleaner (0.7.0) delorean (1.1.1) chronic devise (1.5.2) @@ -106,6 +107,7 @@ GEM rack rack-test (0.6.1) rack (>= 1.0) + radius (0.7.1) rails (3.1.3) actionmailer (= 3.1.3) actionpack (= 3.1.3) @@ -198,6 +200,7 @@ DEPENDENCIES jquery-rails mini_magick mongoid! + radius rails rake rcov diff --git a/lib/parser.rb b/lib/parser.rb index 7475a01e..389ea35a 100644 --- a/lib/parser.rb +++ b/lib/parser.rb @@ -1,4 +1,5 @@ module Parser + require 'radius' def parser_context(page, attributes = {},appfront_url = nil) Radius::Context.new do |c| diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 6fe6c0b9..e493f347 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -118,7 +118,7 @@ namespace :dev do home = Page.create!( :i18n_variable_id => var_10.id, :design_id => design_1.id, :name => 'home', :is_published => true, :theme_id => theme.id ) home.page_parts.create!( :name => 'content_1', :content => File.open("#{Rails.root}/lib/template/home.page").read, :kind => 'text', :i18n_variable_id => var_13.id ) - ModuleApp.create.from_json(File.open("#{Rails.root}/vendor/plugins/NewBlog/NewBlog.json").read).save + ModuleApp.create.from_json(File.open("#{Rails.root}/vendor/built_in_modules/NewBlog/NewBlog.json").read).save Post.create(:title=>"1st post",:body=>"Long long time ago.....") Post.create(:title=>"2ec post",:body=>"And?.....") diff --git a/vendor/plugins/radius/.gitignore b/vendor/plugins/radius/.gitignore deleted file mode 100644 index 23ab7917..00000000 --- a/vendor/plugins/radius/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -doc -*.dot -pkg -*.rbc diff --git a/vendor/plugins/radius/CHANGELOG b/vendor/plugins/radius/CHANGELOG deleted file mode 100644 index 4efb14f7..00000000 --- a/vendor/plugins/radius/CHANGELOG +++ /dev/null @@ -1,42 +0,0 @@ -= Change Log - -== edge -* Support for Rubinius [jlong] -* Support for Ruby 1.9 [aemadrid] -* More tests [aemadrid] -* Fixed issue #5 - problem with other namespace tags [jemmyw] -* Switched to Jeweler for better gem management [jlong] -* Allow operation in a threaded environment (parser per-thread, shared context) -* Allow switching scanners that tokenize templates. -* Include SquiggleScanner to parse tags that look like "{ hello /}" - -== 0.6.1 -* Fixed a problem with non-tags that have no prefix or tag name (see test_parse_chirpy_bird) - -== 0.6.0 (private release) -* Split radius.rb into multiple files. -* Ported the really hairy regexes from Radius::Parser to a single Ragel machine. -* Added and refactored tests. -* Refactored Rakefile and other administrativia. - -== 0.5.1 -* Fixed a problem with parsing quotes where a single tag preceding a double tag would consume the start tag of the double tag if both contained attributes. - -== 0.5.0 -* Created a DSL for tag definitions (introducing a DSL makes this version of Radiant incompatible with the last). The DSL has the following features: - - full support for nested tags - - global and local tag variables - - Contexts can now be defined dynamically (instead of being subclassed) - - see the QUICKSTART for more info -* Many refactorings of the library and unit tests. -* Changed the license to the MIT-LICENSE. -* Updated documentation to reflect the changes. -* Updated the version number to reflect the maturity of the code base. - -== 0.0.2 -* Refactored Parser to use Context#render_tag instead of #send when rendering tags defined on a Context. -* UndefinedTagError is now thrown when Parser tries to render a tag which doesn't exist on a Context. -* Added Context#tag_missing which works like method_method missing on Object, but is tag specific. - -== 0.0.1 -* First release. diff --git a/vendor/plugins/radius/LICENSE b/vendor/plugins/radius/LICENSE deleted file mode 100644 index f6f3aa75..00000000 --- a/vendor/plugins/radius/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2006-2010, John W. Long - -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/vendor/plugins/radius/QUICKSTART.rdoc b/vendor/plugins/radius/QUICKSTART.rdoc deleted file mode 100644 index d4972e95..00000000 --- a/vendor/plugins/radius/QUICKSTART.rdoc +++ /dev/null @@ -1,322 +0,0 @@ -= Radius Quick Start - - -== Defining Tags - -Before you can parse a template with Radius you need to create a Context object which defines -the tags that will be used in the template. This is actually quite simple: - - require 'radius' - - context = Radius::Context.new - context.define_tag "hello" do |tag| - "Hello #{tag.attr['name'] || 'World'}!" - end - -Once you have defined a context you can easily create a Parser: - - parser = Radius::Parser.new(context) - puts parser.parse('

    ') - puts parser.parse('

    ') - -This code will output: - -

    Hello World!

    -

    Hello John!

    - -Note how you can pass attributes from the template to the context using the attributes hash. -Above, the first tag that was parsed didn't have a name attribute so the code in the +hello+ -tag definition uses "World" instead. The second time the tag is parsed the name attribute is -set to "John" which is used to create the string "Hello John!". Tags that do not follow this -rule will be treated as if they were undefined (like normal methods). - - -== Container Tags - -Radius also allows you to define "container" tags. That is, tags that contain content and -that may optionally manipulate it in some way. For example, if you have RedCloth installed -you could define another tag to parse and create Textile output: - - require 'redcloth' - - context.define_tag "textile" do |tag| - contents = tag.expand - RedCloth.new(contents).to_html - end - -(The code tag.expand above returns the contents of the template between the start and end -tags.) - -With the code above your parser can easily handle Textile: - - parser.parse('h1. Hello **World**!') - -This code will output: - -

    Hello World!

    - - -== Nested Tags - -But wait!--it gets better. Because container tags can manipulate the content they contain -you can use them to iterate over collections: - - context = Radius::Context.new - - context.define_tag "stooge" do |tag| - content = '' - ["Larry", "Moe", "Curly"].each do |name| - tag.locals.name = name - content << tag.expand - end - content - end - - context.define_tag "stooge:name" do |tag| - tag.locals.name - end - - parser = Radius::Parser.new(context) - - template = <<-TEMPLATE -
      - -
    • -
      -
    - TEMPLATE - - puts parser.parse(template) - -This code will output: - -
      - -
    • Larry
    • - -
    • Moe
    • - -
    • Curly
    • - -
    - -Note how the definition for the +name+ tag is defined. Because "name" is prefixed -with "stooge:" the +name+ tag cannot appear outside the +stooge+ tag. Had it been defined -simply as "name" it would be valid anywhere, even outside the +stooge+ tag (which was -not what we wanted). Using the colon operator you can define tags with any amount of -nesting. - - -== Exposing Objects to Templates - -During normal operation, you will often want to expose certain objects to your templates. -Writing the tags to do this all by hand would be cumbersome of Radius did not provide -several mechanisms to make this easier. The first is a way of exposing objects as tags -on the context object. To expose an object simply call the +define_tag+ -method with the +for+ option: - - context.define_tag "count", :for => 1 - -This would expose the object 1 to the template as the +count+ tag. It's basically the -equivalent of writing: - - context.define_tag("count") { 1 } - -So far this doesn't save you a whole lot of typing, but suppose you want to expose certain -methods that are on that object? You could do this: - - context.define_tag "user", :for => user, :expose => [ :name, :age, :email ] - -This will add a total of four tags to the context. One for the user variable, and -one for each of the three methods listed in the +expose+ clause. You could now get the user's -name inside your template like this: - - - -If "John" was the value stored in user.name the template would render as "John". - - -== Tag Shorthand - -In the example above we made reference to user.name in our template by using the -following code: - - - -There is a much easer way to refer to the user.name variable. Use the colon operator -to "scope" the reference to name: - - - -Radius allows you to use this shortcut for all tags. - - -== Changing the Tag Prefix - -By default, all Radius tags must begin with "radius". You can change this by altering the -tag_prefix attribute on a Parser. For example: - - parser = Radius::Parser.new(context, :tag_prefix => 'r') - -Now, when parsing templates with +parser+, Radius will require that every tag begin with "r" -instead of "radius". - - -== Custom Behavior for Undefined Tags - -Context#tag_missing behaves much like Object#method_missing only it allows you to define -specific behavior for when a tag is not defined on a Context. For example: - - class LazyContext < Radius::Context - def tag_missing(tag, attr, &block) - "ERROR: Undefined tag `#{tag}' with attributes #{attr.inspect}" - end - end - - parser = Radius::Parser.new(LazyContext.new, :tag_prefix => 'lazy') - puts parser.parse('') - -This will output: - - ERROR: Undefined tag `weird' with attributes {"value"=>"true"} - -Normally, when the Radius Parser encounters an undefined tag for a Context it raises an -UndefinedTagError, but since we have defined #tag_missing on LazyContext the Parser now -outputs a nicely formated error message when we parse a string that does not contain a -valid tag. - - -== Tag Bindings - -Radius passes a TagBinding into the block of the Context#define_tag method. The tag -binding is useful for a number of tasks. A tag binding has an #expand instance method -which processes a tag's contents and returns the result. It also has a #attr method -which returns a hash of the attributes that were passed into the tag. TagBinding also -contains the TagBinding#single? and TagBinding#double? methods which return true or false -based on wether the tag is a container tag or not. More about the methods which are -available on tag bindings can be found on the Radius::TagBinding documentation page. - - -== Tag Binding Locals, Globals, and Context Sensitive Tags - -A TagBinding also contains two OpenStruct-like objects which are useful when developing -tags. TagBinding#globals is useful for storing variables which you would like to be -accessible to all tags: - - context.define_tag "inc" do |tag| - tag.globals.count ||= 0 - tag.globals.count += 1 - "" - end - - context.define_tag "count" do |tag| - tag.globals.count || 0 - end - -TagBinding#locals mirrors the variables that are in TagBinding#globals, but allows child -tags to redefine variables. This is valuable when defining context sensitive tags: - - class Person - attr_accessor :name, :friend - def initialize(name) - @name = name - end - end - - jack = Person.new('Jack') - jill = Person.new('Jill') - jack.friend = jill - jill.friend = jack - - context = Radius::Context.new do |c| - c.define_tag "jack" do |tag| - tag.locals.person = jack - tag.expand - end - c.define_tag "jill" do |tag| - tag.locals.person = jill - tag.expand - end - c.define_tag "name" do |tag| - tag.locals.person.name rescue tag.missing! - end - c.define_tag "friend" do |tag| - tag.locals.person = tag.locals.person.friend rescue tag.missing! - tag.expand - end - end - - parser = Radius::Parser.new(context, :tag_prefix => 'r') - - parser.parse('') #=> "Jack" - parser.parse('') #=> "Jill" - parser.parse('') #=> "Jack" - parser.parse('') #=> "Jack" - parser.parse(' and ') #=> "Jack and Jill" - parser.parse('') # raises a Radius::UndefinedTagError exception - -Notice how TagBinding#locals enables intelligent nesting. "" evaluates to -"Jill", but "" evaluates to "Jack". Locals lose scope as soon as -the tag they were defined in closes. Globals on the other hand, never lose scope. - -The final line in the example above demonstrates that calling "" raises a -TagMissing error. This is because of the way the name tag was defined: - - tag.locals.person.name rescue tag.missing! - -If person is not defined on locals it will return nil. Calling #name on nil would normally -raise a NoMethodError exception, but because of the 'rescue' clause the TagBinding#missing! -method is called which fires off Context#tag_missing. By default Context#tag_missing raises -a UndefinedTagError exception. The 'rescue tag.missing!' idiom is extremly useful for adding -simple error checking to context sensitive tags. - - -== Tag Specificity - -When Radius is presented with two tags that have the same name, but different nesting -Radius uses an algorithm similar to the way winning rules are calculated in Cascading Style -Sheets (CSS) to determine which definition should be used. Each time a tag is encountered -in a template potential tags are assigned specificity values and the tag with the highest -specificity wins. - -For example, given the following tag definitions: - - nesting - extra:nesting - parent:child:nesting - -And template: - - - -Radius will calculate specificity values like this: - - nesting => 1.0.0.0 - extra:nesting => 1.0.1.0 - parent:child:nesting => 1.1.0.1 - -Meaning that parent:child:nesting will win. If a template contained: - - - -The following specificity values would be assigned to each of the tag definitions: - - nesting => 1.0.0.0 - extra:nesting => 1.1.0.0 - parent:child:nesting => 1.0.1.1 - -Meaning that extra:nesting would win because it is more "specific". - -Values are assigned by assigning points to each of the tags from right to left. -Given a tag found in a template with nesting four levels deep, the maximum -specificity a tag could be assigned would be: - - 1.1.1.1 - -One point for each of the levels. - -In practice, you don't need to understand this topic to be effective with Radius. -For the most part you will find that Radius resolves tags precisely the way that -you would expect. If you find this section confusing forget about it and refer -back to it if you find that tags are resolving differently from the way that you -expected. diff --git a/vendor/plugins/radius/README.rdoc b/vendor/plugins/radius/README.rdoc deleted file mode 100644 index 1c16bcd0..00000000 --- a/vendor/plugins/radius/README.rdoc +++ /dev/null @@ -1,100 +0,0 @@ -= Radius -- Powerful Tag-Based Templates - -Radius is a powerful tag-based template language for Ruby inspired by the -template languages used in MovableType[http://www.movabletype.org] and -TextPattern[http://www.textpattern.com]. It uses tags similar to XML, but can -be used to generate any form of plain text (HTML, e-mail, etc...). - - -== Usage - -With Radius, it is extremely easy to create custom tags and parse them. Here's a small -example: - - require 'radius' - - # Define tags on a context that will be available to a template: - context = Radius::Context.new do |c| - c.define_tag 'hello' do - 'Hello world' - end - c.define_tag 'repeat' do |tag| - number = (tag.attr['times'] || '1').to_i - result = '' - number.times { result << tag.expand } - result - end - end - - # Create a parser to parse tags that begin with 'r:' - parser = Radius::Parser.new(context, :tag_prefix => 'r') - - # Parse tags and output the result - puts parser.parse(%{A small example:\n* !\n}) - -Output: - - A small example: - * Hello world! - * Hello world! - * Hello world! - - -== Quick Start - -Read the QUICKSTART file to get up and running with Radius. - - -== Requirements - -Radius does not have any external requirements for using the library in your -own programs. - -Ragel is required to create the ruby parser from the Ragel specification, -and both Ragel and Graphviz are required to draw the state graph for the -parser. - - -== Installation - -It is recommended that you install Radius using the RubyGems packaging system: - - % gem install --remote radius - - -== License - -Radius is released under the MIT license and is copyright (c) 2006-2010 -John W. Long. A copy of the MIT license can be found in the LICENSE file. - - -== Roadmap - -This is a prioritized roadmap for future releases: - -1. Clean up the current code base. [Done] - -2. Add support for multi-level contexts: tags should be able to be - defined to only be valid within other sets of tags. [Done] - -3. Create a simple DSL for defining contexts. [Done] - -4. Optimize for speed, modify scan.rl to emit C. - - -== Development - -The latest version of Radius can be found on RubyForge: - -http://rubyforge.org/projects/radius - -Experimental and development versions of Radius can be found on Github: - -http://github.com/jlong/radius - -If you are interested in helping with the development of Radius, feel free to -fork the project on GitHub and send me a pull request. - - -John Long :: -http://wiseheartdesign.com diff --git a/vendor/plugins/radius/Rakefile b/vendor/plugins/radius/Rakefile deleted file mode 100644 index 13823529..00000000 --- a/vendor/plugins/radius/Rakefile +++ /dev/null @@ -1,8 +0,0 @@ -require 'rubygems' -require 'rake' - -require File.dirname(__FILE__) + '/lib/radius/version' - -Dir['tasks/**/*.rake'].each { |t| load t } - -task :default => :test diff --git a/vendor/plugins/radius/VERSION b/vendor/plugins/radius/VERSION deleted file mode 100644 index 8e3db852..00000000 --- a/vendor/plugins/radius/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.7.0.prerelease \ No newline at end of file diff --git a/vendor/plugins/radius/lib/radius.rb b/vendor/plugins/radius/lib/radius.rb deleted file mode 100644 index c0468ff8..00000000 --- a/vendor/plugins/radius/lib/radius.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'radius/version' -require 'radius/error' -require 'radius/tag_definitions' -require 'radius/delegating_open_struct' -require 'radius/tag_binding' -require 'radius/context' -require 'radius/parse_tag' -require 'radius/ord_string' -require 'radius/parser/scanner' -require 'radius/parser' -require 'radius/utility' diff --git a/vendor/plugins/radius/lib/radius/context.rb b/vendor/plugins/radius/lib/radius/context.rb deleted file mode 100644 index e1ebc688..00000000 --- a/vendor/plugins/radius/lib/radius/context.rb +++ /dev/null @@ -1,147 +0,0 @@ -module Radius - # - # A context contains the tag definitions which are available for use in a template. - # See the QUICKSTART for a detailed explaination its - # usage. - # - class Context - # A hash of tag definition blocks that define tags accessible on a Context. - attr_accessor :definitions # :nodoc: - attr_accessor :globals # :nodoc: - - # Creates a new Context object. - def initialize(&block) - @definitions = {} - @tag_binding_stack = [] - @globals = DelegatingOpenStruct.new - with(&block) if block_given? - end - - # Yield an instance of self for tag definitions: - # - # context.with do |c| - # c.define_tag 'test' do - # 'test' - # end - # end - # - def with - yield self - self - end - - # Creates a tag definition on a context. Several options are available to you - # when creating a tag: - # - # +for+:: Specifies an object that the tag is in reference to. This is - # applicable when a block is not passed to the tag, or when the - # +expose+ option is also used. - # - # +expose+:: Specifies that child tags should be set for each of the methods - # contained in this option. May be either a single symbol/string or - # an array of symbols/strings. - # - # +attributes+:: Specifies whether or not attributes should be exposed - # automatically. Useful for ActiveRecord objects. Boolean. Defaults - # to +true+. - # - def define_tag(name, options = {}, &block) - type = Utility.impartial_hash_delete(options, :type).to_s - klass = Utility.constantize('Radius::TagDefinitions::' + Utility.camelize(type) + 'TagFactory') rescue raise(ArgumentError.new("Undefined type `#{type}' in options hash")) - klass.new(self).define_tag(name, options, &block) - end - - # Returns the value of a rendered tag. Used internally by Parser#parse. - def render_tag(name, attributes = {}, &block) - if name =~ /^(.+?):(.+)$/ - render_tag($1) { render_tag($2, attributes, &block) } - else - tag_definition_block = @definitions[qualified_tag_name(name.to_s)] - if tag_definition_block - stack(name, attributes, block) do |tag| - tag_definition_block.call(tag).to_s - end - else - tag_missing(name, attributes, &block) - end - end - end - - # Like method_missing for objects, but fired when a tag is undefined. - # Override in your own Context to change what happens when a tag is - # undefined. By default this method raises an UndefinedTagError. - def tag_missing(name, attributes, &block) - raise UndefinedTagError.new(name) - end - - # Returns the state of the current render stack. Useful from inside - # a tag definition. Normally just use TagBinding#nesting. - def current_nesting - @tag_binding_stack.collect { |tag| tag.name }.join(':') - end - - # make a usable copy of this context - def dup # :nodoc: - rv = self.class.new - rv.globals = globals.dup - rv.definitions = definitions.dup - rv - end - - private - - # A convienence method for managing the various parts of the - # tag binding stack. - def stack(name, attributes, block) - previous = @tag_binding_stack.last - previous_locals = previous.nil? ? globals : previous.locals - locals = DelegatingOpenStruct.new(previous_locals) - binding = TagBinding.new(self, locals, name, attributes, block) - @tag_binding_stack.push(binding) - result = yield(binding) - @tag_binding_stack.pop - result - end - - # Returns a fully qualified tag name based on state of the - # tag binding stack. - def qualified_tag_name(name) - nesting_parts = @tag_binding_stack.collect { |tag| tag.name } - nesting_parts << name unless nesting_parts.last == name - specific_name = nesting_parts.join(':') # specific_name always has the highest specificity - unless @definitions.has_key? specific_name - possible_matches = @definitions.keys.grep(/(^|:)#{name}$/) - specificity = possible_matches.inject({}) { |hash, tag| hash[numeric_specificity(tag, nesting_parts)] = tag; hash } - max = specificity.keys.max - if max != 0 - specificity[max] - else - name - end - else - specific_name - end - end - - # Returns the specificity for +tag_name+ at nesting defined - # by +nesting_parts+ as a number. - def numeric_specificity(tag_name, nesting_parts) - nesting_parts = nesting_parts.dup - name_parts = tag_name.split(':') - specificity = 0 - value = 1 - if nesting_parts.last == name_parts.last - while nesting_parts.size > 0 - if nesting_parts.last == name_parts.last - specificity += value - name_parts.pop - end - nesting_parts.pop - value *= 0.1 - end - specificity = 0 if (name_parts.size > 0) - end - specificity - end - end -end diff --git a/vendor/plugins/radius/lib/radius/delegating_open_struct.rb b/vendor/plugins/radius/lib/radius/delegating_open_struct.rb deleted file mode 100644 index 1a95bee8..00000000 --- a/vendor/plugins/radius/lib/radius/delegating_open_struct.rb +++ /dev/null @@ -1,37 +0,0 @@ -module Radius - class DelegatingOpenStruct # :nodoc: - attr_accessor :object - - def initialize(object = nil) - @object = object - @hash = {} - end - - def dup - rv = self.class.new - rv.instance_variable_set(:@hash, @hash.dup) - rv - end - - def method_missing(method, *args, &block) - symbol = (method.to_s =~ /^(.*?)=$/) ? $1.intern : method - if (0..1).include?(args.size) - if args.size == 1 - @hash[symbol] = args.first - else - if @hash.has_key?(symbol) - @hash[symbol] - else - unless object.nil? - @object.send(method, *args, &block) - else - nil - end - end - end - else - super - end - end - end -end diff --git a/vendor/plugins/radius/lib/radius/error.rb b/vendor/plugins/radius/lib/radius/error.rb deleted file mode 100644 index a7725f1d..00000000 --- a/vendor/plugins/radius/lib/radius/error.rb +++ /dev/null @@ -1,43 +0,0 @@ -module Radius - # Abstract base class for all parsing errors. - class ParseError < StandardError - end - - # Occurs when the Parser expects an end tag for one tag and finds the end tag for another. - class WrongEndTagError < ParseError - def initialize(expected_tag, got_tag, stack) - stack_message = " with stack #{stack.inspect}" if stack - super("wrong end tag `#{got_tag}' found for start tag `#{expected_tag}'#{stack_message}") - end - end - - # Occurs when Parser cannot find an end tag for a given tag in a template or when - # tags are miss-matched in a template. - class MissingEndTagError < ParseError - # Create a new MissingEndTagError object for +tag_name+. - def initialize(tag_name, stack) - stack_message = " with stack #{stack.inspect}" if stack - super("end tag not found for start tag `#{tag_name}'#{stack_message}") - end - end - - # Occurs when Context#render_tag cannot find the specified tag on a Context. - class UndefinedTagError < ParseError - # Create a new UndefinedTagError object for +tag_name+. - def initialize(tag_name) - super("undefined tag `#{tag_name}'") - end - end - - class TastelessTagError < ParseError #:nodoc: - def initialize(tag, stack) - super("internal error with tasteless tag #{tag.inspect} and stack #{stack.inspect}") - end - end - - class UndefinedFlavorError < ParseError #:nodoc: - def initialize(tag, stack) - super("internal error with unknown flavored tag #{tag.inspect} and stack #{stack.inspect}") - end - end -end \ No newline at end of file diff --git a/vendor/plugins/radius/lib/radius/ord_string.rb b/vendor/plugins/radius/lib/radius/ord_string.rb deleted file mode 100644 index f97093a5..00000000 --- a/vendor/plugins/radius/lib/radius/ord_string.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Radius - class OrdString < String - if RUBY_VERSION[0,3] == '1.9' - def [](*args) - if args.size == 1 && args.first.is_a?(Integer) - slice(args.first).ord - else - super - end - end - end - end -end \ No newline at end of file diff --git a/vendor/plugins/radius/lib/radius/parse_tag.rb b/vendor/plugins/radius/lib/radius/parse_tag.rb deleted file mode 100644 index cdc51be5..00000000 --- a/vendor/plugins/radius/lib/radius/parse_tag.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Radius - class ParseTag # :nodoc: - def initialize(&b) - @block = b - end - - def on_parse(&b) - @block = b - end - - def to_s - @block.call(self) if @block - end - end - - class ParseContainerTag < ParseTag # :nodoc: - attr_accessor :name, :attributes, :contents - - def initialize(name = "", attributes = {}, contents = [], &b) - @name, @attributes, @contents = name, attributes, contents - super(&b) - end - end -end \ No newline at end of file diff --git a/vendor/plugins/radius/lib/radius/parser.rb b/vendor/plugins/radius/lib/radius/parser.rb deleted file mode 100644 index 42609434..00000000 --- a/vendor/plugins/radius/lib/radius/parser.rb +++ /dev/null @@ -1,79 +0,0 @@ -module Radius - # - # The Radius parser. Initialize a parser with a Context object that - # defines how tags should be expanded. See the QUICKSTART[link:files/QUICKSTART.html] - # for a detailed explaination of its usage. - # - class Parser - # The Context object used to expand template tags. - attr_accessor :context - - # The string that prefixes all tags that are expanded by a parser - # (the part in the tag name before the first colon). - attr_accessor :tag_prefix - - # The class that performs tokenization of the input string - attr_accessor :scanner - - # Creates a new parser object initialized with a Context. - def initialize(context = Context.new, options = {}) - if context.kind_of?(Hash) and options.empty? - options, context = context, (context[:context] || context['context']) - end - options = Utility.symbolize_keys(options) - self.context = context ? context.dup : Context.new - self.tag_prefix = options[:tag_prefix] || 'radius' - self.scanner = options[:scanner] || default_scanner - end - - # Parses string for tags, expands them, and returns the result. - def parse(string) - @stack = [ ParseContainerTag.new { |t| Utility.array_to_s(t.contents) } ] - tokenize(string) - stack_up - @stack.last.to_s - end - - protected - # Convert the string into a list of text blocks and scanners (tokens) - def tokenize(string) - @tokens = scanner.operate(tag_prefix, string) - end - - def stack_up - @tokens.each do |t| - if t.is_a? String - @stack.last.contents << t - next - end - case t[:flavor] - when :open - @stack.push(ParseContainerTag.new(t[:name], t[:attrs])) - when :self - @stack.last.contents << ParseTag.new {@context.render_tag(t[:name], t[:attrs])} - when :close - popped = @stack.pop - raise WrongEndTagError.new(popped.name, t[:name], @stack) if popped.name != t[:name] - popped.on_parse { |b| @context.render_tag(popped.name, popped.attributes) { Utility.array_to_s(b.contents) } } - @stack.last.contents << popped - when :tasteless - raise TastelessTagError.new(t, @stack) - else - raise UndefinedFlavorError.new(t, @stack) - end - end - raise MissingEndTagError.new(@stack.last.name, @stack) if @stack.length != 1 - end - - def default_scanner - if RUBY_PLATFORM == 'java' - require 'java' - require 'radius/parser/java_scanner.jar' - ::Radius.send(:include_package, 'radius.parser') - Radius::JavaScanner.new(JRuby.runtime) - else - Radius::Scanner.new - end - end - end -end diff --git a/vendor/plugins/radius/lib/radius/parser/JavaScanner.class b/vendor/plugins/radius/lib/radius/parser/JavaScanner.class deleted file mode 100644 index e16e7b7c9d7df9c15ce9869bfdbf341189698748..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16807 zcmd^Gd0br8^*{H`zzo9x_W=V8JA{NC5+D<{tYqI4AehCF2@Fd@AQ^^iW^sx8zVC4t z<1Q$oMjN$NYt=4pZLL;qZEbD)YpZsP%I_>g0wnFH=J)3>`o8DhbI(2J+h*W~{EgnGKzmnbH;S*Fr66XQz1g>`v8$z}+ZW)bS_RR=O##2Rv%3)m zxTQux+;B^GduMBhud&0|*&1lWR@ZO?_GmpBzrC~BxAV9iJuHv>_NI0psyOD5SPgjn zts@l+_t+Q`h7|<58oLADfbaP55{H{w{9RkdHk!kYzOI%=)~Uc5oFLTW4=7Lz6hzeE zOa;81fmPm)9-jpRa}v%=P_Cuj-yLXdY47xQ9PjM&`@8%k2*(9|osBgeUERK}o&dE> zR1g_dfh}9S?Va4cySp*a=I`ohZNquYS-i=+-CNv&(^y;^@Z&UB<*rg-t?6pUwU1id z-sxM~vt^^tU+3M}ft-lifVXM$67N>7;|-(067aSvSaA|fC+Z#(GxNROZB=7sDM1Nc~o3dbNr~@!{JFSqun17r6+0~6|B^pHcIQ*m?epfQ4%MH zF3BW}k~tQ^)MV@0>ht4mprGo%TKL>C3n;q0wlFwX|h+u#KS_Ufh%GKy<%$)P}W z)OPjwn|yQIDfsk4jMdsEZ)c~^Uqo^1gc&f?1}{3{yYM{)v7>jYWg9p7ngULE30^*- zO=8^%(_p$2UV-mB;Z^v76JCSY(GMrQ0Y9|CkDTyh_=$qht$tri`%d)H32(w%PIw#M z!657O()JkQ4FvqSafG&Xc(-@?ozMh(Y;eR0@4_ZUH)mMD+a2(A_`18D@KgAi6Mhcw zIbj*pIAIpSY?$MOg#`1dIv3_SVF8sE5iBNHLhuWC-w7YUFEM1s-mgrn=gIaZLHGcwGAPq5;RI6Hy%&f*31^b$AlF=g#;-;K+MQHI-ZSf_8t zus4+_>@_EDVWPEOno@NDRt1nQ~)QN2Z*x!xCz|IrxTL2v zxAHvTEvM0o#|8yAj2y=B;>53@>L`chAOdepKTDDQCfglWGq2ZR_!N(1B*;_8g4< z+%*acNAiOXov10ev*0q?16?8o8F)^dipPr>ym0$O1looX6KO|dikli!+|8Kc*2WY! zHm11WF~vQODQi|BkHTM zzGg(d4ouX8no%cAX0Wgk$Wr-B62O*>2B}gfF9zt$}xPl`Pf(@bh zgJ2r~dqXe8klb-rSi@uN;d;b4e0>0LLpaV(IwV6Wq~e&;p%J-ZV0;CoHrNn_72J}8 zjy!^0LXoqdG!BBJGQ`dH1|Xa`(au4LIBqPmVRUO$u(g1_8{4X}wQvB&vQ1>Wt;9#g z${jKQG6n@ShE%X2jzfR5ARBUVEsAi~N+AH{un#KG?IvgrI$w<|W1w_w-jfiWr=EaN z0+pAKC7Kn{D6>)pR&b%#IEciUiovLI(4$B+878(;hkxpIhwZB^mb%qeYu)M)q@hS{ zp>?b6NOhW<1p=a50-*${|KB z`;kXt`BX39dLg@1M2uoCPGt5ZVwC7`#8MrLSVoM=+KK34#uQ?d>j=aOW>gZRN^8Vw zZ6Z!3#x!P3*U?y>K{GXz9GJz<)v$B3i93g_&ZV|_+%})M3%K(_W-MZzi)n_Ju<%k6 zUdC<9Sbc)4Vl;5uY214?G1joeT9kP7Sh$2@NC4h84mzYrc&J0c z@VHV}9}dItShd=USBMT@wK`P0R;{+_%vG!Hx_A|ah@OgQ(=!q6dM;v^o{#9z3lYP0 z1ENzmBSvT+Vx(?GjMCc?wF&1UF-^D@Nwf(!BZ)EL4kWQAJc`6+LO+r?69$mPoA4Bp z1QT9C;x^$`B#9=xh9t>^_mCu;@EMX66aIoE)r7wzNi*SJNYYLC8cBw!B9LU7Dh0_n zQxze}GSy@x<4skCWP+&{A;~t?G9)>sYDAK2s!k+%rrL%i-&Ea53QV;ZNujAOKvHC? ztB@3%>UJa(O?5YtNkU3Ybr04`P4zI6G9in>S-iZ zraHW8?6TG2vf;5(mM#1RS+?-|P4(>IkkuAlS-;wJ#x9CpN&!=AWu*cDff`f5_GP3{}bePg(9EcbQkbZm{& z#fb5G8e#%#bF;QY9fq7F9f6q4np0R?Dr-w)ZRxBngSBO{wsEX2i?xksZ4+2qHfzga zZMm#1kG18qwgT2x$l8inTQO^!sHdX!Nvx-Y^^~%nGS)Mh^>}!^Q+T}Pth0i3R+Lur?SpztaCc+nZbHyGJlrNL|ZjF8*w(b&f(U%%%7*%A%8xX7jStY_gci`UCiTM z!hSAgKbNtF<*Z=^`?->Rt7YHn*tdH2Z58|0z}ik@ZMZw3tu?G|Eo)oH+D>O}>sebP zYumuuysT{_YinX{&8)%4-nOu}t*pO|Iqhs^6U%I7D;+Geg>7}RtuD5;m2GWfTYk3H z&9(w;tA}lEXU#iU^G?>hi#6|N&1bOYJ*;^zYu?A2_mgH5&Lq_)oJG1#IGdE4a1LoV z;Q*<}t%vlRa2^>j;e1*>6D}a-CR|9`O}L2En{YAdH{lX8V8W$h;W7#j6E3ItFyRWZ zccs|7O6*-N_O20o*NVOC#NPE{?*=h+qgc2}EZi)Tw}|Ae6gegw6v^8}@^+EDLnQAM z$-8KlOt_n-$%K1kDECUgUKz@L(*2Nhzh8#(fH?o4IRB71|FAg!h&cbKSa?iS_leGa zVLmPnJ|WBjVLmC$L18{6em*VCXT;CLqU>4m^Er|Hj`(>*{Cr;gd_nwtQT+U_`1w8Y z^Cj`~W%2VBvG9FS_Nvr=Ahp-TiPweshB)y26x#M|P;JL1H< z;>1tIiJyrRKNlz76GOicL+{H`iebp0e@Sm7Pbc!g#dG z!J}2-JX+=C(W(fxry|*&iV}NT?3rROTI|J$y;!m55_@rCFJ9~=h&{L1OB8!aVlP?j zrHH*$v6m+H(s`0qh8W5eL*v9ymKYi@h9-!iY+h8A!;7kN#cZCK%@?x;VzyAs7Kzzn zF*{MrP7<>vVvnC$rs9W|sU}MYk93$K9m++rLR_j8m#RdvS|q26eWMDI; z`z#q)jcA!ITIR^W=E_j!$x!CYP!`Bg7Rpc-iJ`?}Xo*-@Dyo->FUv(_g@~*aUus3N zPJF4C4y(kM2Jz)I@dXcH6mDz8m$l-{I`QRn@nyaE(kS*eh#{{S+9-ya#89&s@`<4q zG1MxC+Qd-17}_L;HjAMSF|9QN2}kZWE?oYTaTlAclHG^>zuA9TF%z>5yis zU1Dgr7&=1??GZzJ#g~1eY`-WwQBzcAh9ZUzEx7PhBWlE)p#l zicCF~VPUiD^na>-&SZ^ZLFW{88Y zVatQBVdeN57JN&`x5N;9%?!o2IU8PfdIb!n_fC3e*LEs}5jf~|FPy+hugwv}i{!V) zC`Qe1f+ls3CWv8fEGcmj#1X_ZGlBZL2@<)U#9foAR|-KYiKY>xa}pqfF_UHGC7qeV0=d*LkCe+hI#mm)T11k?RGNrc2|bBMQ9`YyR4pTzOsyV*Db!F-P(f9B zGq;@Zl6xi2E~egtvs)9K-TdRTi#9{>qO^w%FHU+;LL`_2A){dg4s6un1Wu|(5JXZn zihzeF`48$FL%diLaS_B3#1k)pN^XKgswUBDB~uT{d{9FgK{~Z&5M+|bI1~9D-b`<`LvmwSb_IposbwQ#YAV5*a(8#PbkLAt)!PAgCm$I&ng8!wJPdV+1Gk z-r$5@HYRIer>sE~WewbvH5i94v-mEGXw#Dr?b?GFrYjH~x*9Q@^9WA89Lo`UC1Rwm zM~u>5M6I_VntB&vwBC=1DFezQV9MZ1B$zUwbONRfZbX79gIkec%HR+Zw+Rm-!IZ%x zNHAsa3=&Kkyo>}>2CpN*l);-wFlF#A5=QuldPE|U)IbKW2*CMkHOoAGl3WoQF&1yj2QgDz~O_Ih`?sF_X-VyteDFanLmj+C7i}9-|wmw&NLb#v1%w?q-<)m+_EHF}h~28BE& zVT;M3SmqQoKD2TsxdV{QI4sB^+ZBhC#D8i z#4a7eq|KolNhDlvAmS9s2x*HHNjxr4o93lbCNGtW)=k8W(al6+^+qBtUOyElwRq{5 zAT_s;L?KDM#41_bO%ZofwU4xC$_M zY}I>-Y?Hb7^D{wp^D{vOgxMp^?ZVt4ako?A4)fvEeYXVM8Pc{#+V)D@K55%8%FdK! zJxiALY+;@w%mczaSMMX8=bd=ie+CbZ_@$B@94#Soa5Vm?_tUwNo~e9r!~!&Y0%XTSiC}RziS%Zf)Org^S{$Ux96ZnT^ zJbvIQl02#6GhH?Fr!s#UbEea(;VCi^aVDP`XYqNehISbI0}~!+@UP3%I+t7LaqE0; zUBIW&h0I^XXVS&YS;FO|e6C!^=e6Z*aRr}1SMmw8md}-Sd}geteF#sHbTVyV{%Op| zaUf?6MW9~G{NYn1an|#Ra`+TUr%o?x*vOJitf84T_~?*?r$`!UE03j(eI7nV(nvS+ zNIPhI)x)PqI!ku(scK9RMs+$iqi>ZuzxezKl~dj za%$MW+0;0PU@kj3kDZ*)PA*{27ET#))f4}f(@);t!t@q9T!ih;(CHc*0+Ii`1OgVp^2xVnWw?W)6l|$Zsn{NOh@rL%)mTJZmFN@>a_@q<$K393t$_uI~B63!@o zJsq6U?%<5BJ)V@b;-^e_h2mwy%dY8bApA2VqK#2FVO(}FhBG=DabrfwNX95e&1f=4 zGsZB+GP)S?sDi!X850=ssDhkCM*JEE%gKx>jH!%ijOmOSjG2s>@6cbFu@4ECPf)c$Ou~gI7Ol5i>;$$v+xIBf+I2Xt3*h(yzqrf<2nj0~fS9Gxv6Ufsh4ROit^tU{k0UE>RHKhE z?G{g%#pAGe!Yv-B#S>xiM51sMUfSY`E_}`t$X}uNlZo!OtGgN7_T}u4q@x?GR@3r1lQI<}z=BFgq2W z?}G%FS?WpZ1Gg*bK$0r;B)gIiBo7^g>|?A4M0o-d`ht$WGmUjcd*XVB-tB`#mpR#! z(g#UI6Z;^U)VW>mgRsSw;z@I*xZE48&7KTbhAZt(2Pa3-FN_3^WQkpk-5_{ny*6T?@o*Nl`kb2B)*RWaZ&J7_W z4KF)pSbwwcMB60WJM`8u+tv+bY(0dn9}Ze4uhG8anBg>6VktS0PSos!45T+27f9hG z^J;84Hm|aF27Me$|Kjo5iq{Uj4&e0^UPthH9j~|W`Ws$f;}SUV!jFzsDqh8S&A{)N zQ3qXW1zv0L+JILJUgzL7h}S!KeU5A9=vBWja5-Gj1CUu6+N<7ohvpB!xSP~ldCx%B z>L+1*fh&w#2Vg>UHo^ep3_vbLGR0pA2F=%(prY_zbw`0KToi@$s%wzv>{XY#?G&@Y zkBr^;88L^v8^0LFubd+rdevqWjObO(1+EC`9M!8DkQdpjmKV4pg{ON}4c|C#P=$j)#K__Dg+UZ3Nx<&?*MGZapQ297uE|OpyBuf z(L;IeP7rWvyila|%uhZp{o2ebwl0I;z z`za|{UKZ^6ZG1`j57xfEvJZ;>&CNajSP+UoaY0`qk;dRA(>wIDW1Ga$TMk4k+COfC zFe|SAQCxpl?Cp@;2gP{PAA}ew;II=zslB5YEI4V3wo8M){Wi{nJ8-NsAVk$bn3@d{ zY7Qi+xsaviL$+D~d1@gPszvx?!^KdlmViesgG#j=rm0$(sp?>ks)q#_*mY_xG+=PA zRbE)HHiB2-H{)tEw5l%rp_Cu4Q31GF^}s>39qv#&;a;^14yoPnpxO(Mt9|&J)cyD~ zt~24+cw>C34!~#XBKTZg3`f-^%Azh+c6FI@swWC4qo;T9ei^dJ=W#bn0igBBI%{Zjq zFdkGtF`iIw8*i$2jCa+$#z*RX;}i9P@u~XA_^bNZ_)>jh{8RnL_)7iWlBE7@NmZX) zGSwHB@#^oEV)YM8i8^ZWsIM#)YRFP!fMu?MU&0$!OM_vv_zb(H%?P(_H=LGTMwDg0 zp)F?{F_v?USjz=Qyyape!E%|AWVyyjw%lo?Sne~@EDso&mOf*g_b) zY1XC2bn8lEhIOqm)7oy-SUZe4R=+XVdZsbYdY-Y^dZAHkz0#<&-eS~S?>1Ihj~J`1 zFB)sCFBy&29~c{~Zx~+dkBuhldq%VM1H)(i$Y`^EYHYIp#n@~;YIIn?F}8##qdUZE z?4;jISe8Kf5PnFUW`pfE*unqr#GfWeX_pOlEB+@ODJvW7A^h<}=C`yS^n)~n4dIVxPO(4w0Inf$o@#%x{||`x25(+a=t$P7Dk4YXhwv90 zr#KLCByW9QZDCvik zK`8Bq4Q+-4;h0{(GNv~P}vU&gHY8E#m9f^Q-VPY z_=DF_G~|R!@D98Qe~EP;{;FsIqwqt>gD>#uVaF#&98{|;n59b4nZ4M@fPMc9G*=%N diff --git a/vendor/plugins/radius/lib/radius/parser/JavaScanner.java b/vendor/plugins/radius/lib/radius/parser/JavaScanner.java deleted file mode 100644 index b45cb731..00000000 --- a/vendor/plugins/radius/lib/radius/parser/JavaScanner.java +++ /dev/null @@ -1,634 +0,0 @@ - -// line 1 "JavaScanner.rl" - -// line 84 "JavaScanner.rl" - - -package radius.parser; - -import java.util.HashMap; -import java.util.LinkedList; -import org.jruby.Ruby; // runtime -import org.jruby.RubyObject; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.RubyArray; -import org.jruby.RubyString; -import org.jruby.RubyHash; -import org.jruby.RubySymbol; - -public class JavaScanner { - - Ruby runtime = null; - RubyArray rv = null; - - void pass_through(String str) { - RubyObject last = ((RubyObject)rv.last()); - if ( rv.size() > 0 && last != null && (last instanceof RubyString) ){ - // XXX concat changes for ruby 1.9 - ((RubyString) last).concat(RubyString.newString(runtime, str)); - } else { - rv.append(RubyString.newString(runtime, str)); - } - } - - void tag(String prefix, String name, RubyHash attr, RubySymbol flavor) { - RubyHash tag = RubyHash.newHash(runtime); - tag.op_aset( - runtime.getCurrentContext(), - RubySymbol.newSymbol(runtime, "prefix"), - RubyString.newString(runtime, prefix) - ); - tag.op_aset( - runtime.getCurrentContext(), - RubySymbol.newSymbol(runtime, "name"), - RubyString.newString(runtime, name) - ); - tag.op_aset( - runtime.getCurrentContext(), - RubySymbol.newSymbol(runtime, "attrs"), - attr - ); - tag.op_aset( - runtime.getCurrentContext(), - RubySymbol.newSymbol(runtime, "flavor"), - flavor - ); - rv.append(tag); - } - - public JavaScanner(Ruby runtime) { - this.runtime = runtime; - } - - -// line 65 "JavaScanner.java" -private static byte[] init__parser_actions_0() -{ - return new byte [] { - 0, 1, 0, 1, 3, 1, 4, 1, 5, 1, 6, 1, - 7, 1, 8, 1, 9, 1, 10, 1, 14, 1, 15, 1, - 19, 1, 21, 1, 22, 1, 23, 2, 1, 2, 2, 5, - 6, 2, 6, 7, 2, 9, 5, 2, 9, 10, 2, 10, - 9, 2, 11, 20, 2, 12, 20, 2, 13, 20, 2, 16, - 17, 2, 16, 18, 3, 5, 6, 7, 3, 9, 5, 6, - 3, 16, 6, 17, 4, 9, 5, 6, 7, 4, 16, 5, - 6, 17, 5, 16, 9, 5, 6, 17 - }; -} - -private static final byte _parser_actions[] = init__parser_actions_0(); - - -private static short[] init__parser_key_offsets_0() -{ - return new short [] { - 0, 0, 11, 21, 34, 47, 61, 65, 70, 72, 74, 87, - 100, 101, 103, 118, 133, 149, 155, 161, 176, 179, 182, 185, - 200, 202, 204, 219, 235, 241, 247, 250, 253, 269, 285, 302, - 309, 315, 331, 335, 351, 366, 369, 371, 381, 392, 402, 416, - 420, 420, 421, 430, 430, 430, 432, 434, 437, 440, 442, 444 - }; -} - -private static final short _parser_key_offsets[] = init__parser_key_offsets_0(); - - -private static char[] init__parser_trans_keys_0() -{ - return new char [] { - 58, 63, 95, 45, 46, 48, 57, 65, 90, 97, 122, 63, - 95, 45, 46, 48, 58, 65, 90, 97, 122, 32, 47, 62, - 63, 95, 9, 13, 45, 58, 65, 90, 97, 122, 32, 47, - 62, 63, 95, 9, 13, 45, 58, 65, 90, 97, 122, 32, - 61, 63, 95, 9, 13, 45, 46, 48, 58, 65, 90, 97, - 122, 32, 61, 9, 13, 32, 34, 39, 9, 13, 34, 92, - 34, 92, 32, 47, 62, 63, 95, 9, 13, 45, 58, 65, - 90, 97, 122, 32, 47, 62, 63, 95, 9, 13, 45, 58, - 65, 90, 97, 122, 62, 34, 92, 32, 34, 47, 62, 63, - 92, 95, 9, 13, 45, 58, 65, 90, 97, 122, 32, 34, - 47, 62, 63, 92, 95, 9, 13, 45, 58, 65, 90, 97, - 122, 32, 34, 61, 63, 92, 95, 9, 13, 45, 46, 48, - 58, 65, 90, 97, 122, 32, 34, 61, 92, 9, 13, 32, - 34, 39, 92, 9, 13, 32, 34, 47, 62, 63, 92, 95, - 9, 13, 45, 58, 65, 90, 97, 122, 34, 62, 92, 34, - 39, 92, 34, 39, 92, 32, 39, 47, 62, 63, 92, 95, - 9, 13, 45, 58, 65, 90, 97, 122, 39, 92, 39, 92, - 32, 39, 47, 62, 63, 92, 95, 9, 13, 45, 58, 65, - 90, 97, 122, 32, 39, 61, 63, 92, 95, 9, 13, 45, - 46, 48, 58, 65, 90, 97, 122, 32, 39, 61, 92, 9, - 13, 32, 34, 39, 92, 9, 13, 34, 39, 92, 34, 39, - 92, 32, 34, 39, 47, 62, 63, 92, 95, 9, 13, 45, - 58, 65, 90, 97, 122, 32, 34, 39, 47, 62, 63, 92, - 95, 9, 13, 45, 58, 65, 90, 97, 122, 32, 34, 39, - 61, 63, 92, 95, 9, 13, 45, 46, 48, 58, 65, 90, - 97, 122, 32, 34, 39, 61, 92, 9, 13, 32, 34, 39, - 92, 9, 13, 32, 34, 39, 47, 62, 63, 92, 95, 9, - 13, 45, 58, 65, 90, 97, 122, 34, 39, 62, 92, 32, - 34, 39, 47, 62, 63, 92, 95, 9, 13, 45, 58, 65, - 90, 97, 122, 32, 39, 47, 62, 63, 92, 95, 9, 13, - 45, 58, 65, 90, 97, 122, 39, 62, 92, 39, 92, 63, - 95, 45, 46, 48, 57, 65, 90, 97, 122, 58, 63, 95, - 45, 46, 48, 57, 65, 90, 97, 122, 63, 95, 45, 46, - 48, 58, 65, 90, 97, 122, 32, 62, 63, 95, 9, 13, - 45, 46, 48, 58, 65, 90, 97, 122, 32, 62, 9, 13, - 60, 47, 63, 95, 45, 57, 65, 90, 97, 122, 34, 92, - 34, 92, 34, 39, 92, 34, 39, 92, 39, 92, 39, 92, - 0 - }; -} - -private static final char _parser_trans_keys[] = init__parser_trans_keys_0(); - - -private static byte[] init__parser_single_lengths_0() -{ - return new byte [] { - 0, 3, 2, 5, 5, 4, 2, 3, 2, 2, 5, 5, - 1, 2, 7, 7, 6, 4, 4, 7, 3, 3, 3, 7, - 2, 2, 7, 6, 4, 4, 3, 3, 8, 8, 7, 5, - 4, 8, 4, 8, 7, 3, 2, 2, 3, 2, 4, 2, - 0, 1, 3, 0, 0, 2, 2, 3, 3, 2, 2, 0 - }; -} - -private static final byte _parser_single_lengths[] = init__parser_single_lengths_0(); - - -private static byte[] init__parser_range_lengths_0() -{ - return new byte [] { - 0, 4, 4, 4, 4, 5, 1, 1, 0, 0, 4, 4, - 0, 0, 4, 4, 5, 1, 1, 4, 0, 0, 0, 4, - 0, 0, 4, 5, 1, 1, 0, 0, 4, 4, 5, 1, - 1, 4, 0, 4, 4, 0, 0, 4, 4, 4, 5, 1, - 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; -} - -private static final byte _parser_range_lengths[] = init__parser_range_lengths_0(); - - -private static short[] init__parser_index_offsets_0() -{ - return new short [] { - 0, 0, 8, 15, 25, 35, 45, 49, 54, 57, 60, 70, - 80, 82, 85, 97, 109, 121, 127, 133, 145, 149, 153, 157, - 169, 172, 175, 187, 199, 205, 211, 215, 219, 232, 245, 258, - 265, 271, 284, 289, 302, 314, 318, 321, 328, 336, 343, 353, - 357, 358, 360, 367, 368, 369, 372, 375, 379, 383, 386, 389 - }; -} - -private static final short _parser_index_offsets[] = init__parser_index_offsets_0(); - - -private static byte[] init__parser_indicies_0() -{ - return new byte [] { - 2, 1, 1, 1, 1, 1, 1, 0, 3, 3, 3, 3, - 3, 3, 0, 4, 6, 7, 5, 5, 4, 5, 5, 5, - 0, 8, 10, 11, 9, 9, 8, 9, 9, 9, 0, 13, - 15, 14, 14, 13, 14, 14, 14, 14, 12, 16, 17, 16, - 12, 17, 18, 19, 17, 12, 21, 22, 20, 24, 25, 23, - 26, 28, 29, 27, 27, 26, 27, 27, 27, 12, 30, 32, - 33, 31, 31, 30, 31, 31, 31, 12, 34, 12, 35, 25, - 23, 36, 24, 38, 39, 37, 25, 37, 36, 37, 37, 37, - 23, 40, 24, 42, 43, 41, 25, 41, 40, 41, 41, 41, - 23, 44, 24, 46, 45, 25, 45, 44, 45, 45, 45, 45, - 23, 47, 24, 48, 25, 47, 23, 48, 49, 50, 25, 48, - 23, 51, 21, 53, 54, 52, 22, 52, 51, 52, 52, 52, - 20, 24, 55, 25, 23, 57, 58, 59, 56, 61, 35, 62, - 60, 64, 24, 66, 67, 65, 68, 65, 64, 65, 65, 65, - 63, 24, 68, 63, 61, 68, 63, 69, 24, 71, 72, 70, - 68, 70, 69, 70, 70, 70, 63, 73, 24, 75, 74, 68, - 74, 73, 74, 74, 74, 74, 63, 76, 24, 77, 68, 76, - 63, 77, 78, 79, 68, 77, 63, 80, 58, 59, 56, 81, - 81, 62, 60, 82, 61, 35, 84, 85, 83, 62, 83, 82, - 83, 83, 83, 60, 86, 61, 35, 88, 89, 87, 62, 87, - 86, 87, 87, 87, 60, 90, 61, 35, 92, 91, 62, 91, - 90, 91, 91, 91, 91, 60, 93, 61, 35, 94, 62, 93, - 60, 94, 95, 96, 62, 94, 60, 97, 80, 58, 99, 100, - 98, 59, 98, 97, 98, 98, 98, 56, 61, 35, 101, 62, - 60, 97, 57, 58, 99, 100, 98, 59, 98, 97, 98, 98, - 98, 56, 103, 21, 105, 106, 104, 107, 104, 103, 104, 104, - 104, 102, 24, 108, 68, 63, 21, 107, 102, 109, 109, 109, - 109, 109, 109, 0, 111, 110, 110, 110, 110, 110, 110, 0, - 112, 112, 112, 112, 112, 112, 0, 113, 115, 114, 114, 113, - 114, 114, 114, 114, 0, 116, 117, 116, 0, 118, 120, 119, - 123, 122, 122, 122, 122, 122, 121, 124, 125, 24, 25, 23, - 24, 25, 23, 61, 35, 62, 60, 61, 35, 62, 60, 24, - 68, 63, 24, 68, 63, 126, 0 - }; -} - -private static final byte _parser_indicies[] = init__parser_indicies_0(); - - -private static byte[] init__parser_trans_targs_0() -{ - return new byte [] { - 49, 1, 2, 3, 4, 3, 12, 52, 4, 5, 12, 52, - 49, 6, 5, 7, 6, 7, 8, 42, 9, 10, 13, 9, - 10, 13, 11, 5, 12, 52, 11, 5, 12, 52, 51, 14, - 15, 16, 20, 54, 15, 16, 20, 54, 17, 16, 18, 17, - 18, 19, 21, 15, 16, 20, 54, 53, 22, 23, 14, 31, - 22, 23, 31, 24, 26, 27, 41, 58, 25, 26, 27, 41, - 58, 28, 27, 29, 28, 29, 30, 40, 23, 32, 33, 34, - 38, 56, 33, 34, 38, 56, 35, 34, 36, 35, 36, 37, - 39, 33, 34, 38, 56, 55, 24, 26, 27, 41, 58, 25, - 57, 44, 44, 45, 46, 47, 46, 59, 47, 59, 0, 49, - 50, 49, 1, 43, 49, 49, 49 - }; -} - -private static final byte _parser_trans_targs[] = init__parser_trans_targs_0(); - - -private static byte[] init__parser_trans_actions_0() -{ - return new byte [] { - 27, 0, 31, 3, 5, 0, 5, 5, 0, 11, 0, 0, - 29, 13, 0, 13, 0, 0, 0, 0, 15, 43, 15, 0, - 17, 0, 7, 64, 34, 34, 0, 37, 9, 9, 0, 17, - 7, 64, 34, 81, 0, 37, 9, 72, 13, 0, 13, 0, - 0, 17, 0, 40, 76, 68, 86, 58, 15, 46, 43, 15, - 0, 17, 0, 0, 7, 64, 34, 81, 0, 0, 37, 9, - 72, 13, 0, 13, 0, 0, 0, 17, 43, 17, 7, 64, - 34, 81, 0, 37, 9, 72, 13, 0, 13, 0, 0, 17, - 17, 40, 76, 68, 86, 58, 15, 40, 76, 68, 86, 15, - 58, 1, 0, 31, 3, 5, 0, 5, 0, 0, 0, 23, - 61, 25, 1, 0, 52, 49, 55 - }; -} - -private static final byte _parser_trans_actions[] = init__parser_trans_actions_0(); - - -private static byte[] init__parser_to_state_actions_0() -{ - return new byte [] { - 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, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 19, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; -} - -private static final byte _parser_to_state_actions[] = init__parser_to_state_actions_0(); - - -private static byte[] init__parser_from_state_actions_0() -{ - return new byte [] { - 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, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; -} - -private static final byte _parser_from_state_actions[] = init__parser_from_state_actions_0(); - - -private static short[] init__parser_eof_trans_0() -{ - return new short [] { - 0, 1, 1, 1, 1, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, 1, 1, - 0, 0, 122, 125, 126, 125, 126, 125, 126, 125, 126, 127 - }; -} - -private static final short _parser_eof_trans[] = init__parser_eof_trans_0(); - - -static final int parser_start = 49; -static final int parser_first_final = 49; -static final int parser_error = 0; - -static final int parser_en_Closeout = 48; -static final int parser_en_main = 49; - - -// line 143 "JavaScanner.rl" - - public RubyArray operate(String tag_prefix, String input) { - char[] data = input.toCharArray(); - String disposable_string; - - String name = ""; - String prefix = ""; - RubySymbol flavor = RubySymbol.newSymbol(runtime, "tasteless".intern()); - RubyHash attributes = RubyHash.newHash(runtime); - - int tagstart = 0; - int mark_pfx = 0; - int mark_stg = 0; - int mark_attr = 0; - int mark_nat = 0; - int mark_vat = 0; - - String nat = ""; - String vat = ""; - - int cs; - int p = 0; - int pe = data.length; - int eof = pe; - int act; - int ts; - int te; - - rv = RubyArray.newArray(runtime); - char[] remainder = data; - - -// line 351 "JavaScanner.java" - { - cs = parser_start; - ts = -1; - te = -1; - act = 0; - } - -// line 175 "JavaScanner.rl" - -// line 361 "JavaScanner.java" - { - int _klen; - int _trans = 0; - int _acts; - int _nacts; - int _keys; - int _goto_targ = 0; - - _goto: while (true) { - switch ( _goto_targ ) { - case 0: - if ( p == pe ) { - _goto_targ = 4; - continue _goto; - } - if ( cs == 0 ) { - _goto_targ = 5; - continue _goto; - } -case 1: - _acts = _parser_from_state_actions[cs]; - _nacts = (int) _parser_actions[_acts++]; - while ( _nacts-- > 0 ) { - switch ( _parser_actions[_acts++] ) { - case 15: -// line 1 "NONE" - {ts = p;} - break; -// line 390 "JavaScanner.java" - } - } - - _match: do { - _keys = _parser_key_offsets[cs]; - _trans = _parser_index_offsets[cs]; - _klen = _parser_single_lengths[cs]; - if ( _klen > 0 ) { - int _lower = _keys; - int _mid; - int _upper = _keys + _klen - 1; - while (true) { - if ( _upper < _lower ) - break; - - _mid = _lower + ((_upper-_lower) >> 1); - if ( data[p] < _parser_trans_keys[_mid] ) - _upper = _mid - 1; - else if ( data[p] > _parser_trans_keys[_mid] ) - _lower = _mid + 1; - else { - _trans += (_mid - _keys); - break _match; - } - } - _keys += _klen; - _trans += _klen; - } - - _klen = _parser_range_lengths[cs]; - if ( _klen > 0 ) { - int _lower = _keys; - int _mid; - int _upper = _keys + (_klen<<1) - 2; - while (true) { - if ( _upper < _lower ) - break; - - _mid = _lower + (((_upper-_lower) >> 1) & ~1); - if ( data[p] < _parser_trans_keys[_mid] ) - _upper = _mid - 2; - else if ( data[p] > _parser_trans_keys[_mid+1] ) - _lower = _mid + 2; - else { - _trans += ((_mid - _keys)>>1); - break _match; - } - } - _trans += _klen; - } - } while (false); - - _trans = _parser_indicies[_trans]; -case 3: - cs = _parser_trans_targs[_trans]; - - if ( _parser_trans_actions[_trans] != 0 ) { - _acts = _parser_trans_actions[_trans]; - _nacts = (int) _parser_actions[_acts++]; - while ( _nacts-- > 0 ) - { - switch ( _parser_actions[_acts++] ) - { - case 0: -// line 4 "JavaScanner.rl" - { mark_pfx = p; } - break; - case 1: -// line 5 "JavaScanner.rl" - { - prefix = input.substring(mark_pfx, p); - } - break; - case 2: -// line 8 "JavaScanner.rl" - { - if ( !prefix.equals(tag_prefix) ) { - // have to manually add ':' / Sep - // pass the text through & reset state - pass_through(input.substring(tagstart, p) + ":"); - prefix = ""; - {cs = 49; _goto_targ = 2; if (true) continue _goto;} - } - } - break; - case 3: -// line 18 "JavaScanner.rl" - { mark_stg = p; } - break; - case 4: -// line 19 "JavaScanner.rl" - { name = input.substring(mark_stg, p); } - break; - case 5: -// line 20 "JavaScanner.rl" - { mark_attr = p; } - break; - case 6: -// line 21 "JavaScanner.rl" - { - attributes.op_aset( - runtime.getCurrentContext(), - RubyString.newString(runtime, nat), - RubyString.newString(runtime, vat) - ); - } - break; - case 7: -// line 29 "JavaScanner.rl" - { mark_nat = p; } - break; - case 8: -// line 30 "JavaScanner.rl" - { nat = input.substring(mark_nat, p); } - break; - case 9: -// line 31 "JavaScanner.rl" - { mark_vat = p; } - break; - case 10: -// line 32 "JavaScanner.rl" - { vat = input.substring(mark_vat, p); } - break; - case 11: -// line 34 "JavaScanner.rl" - { flavor = RubySymbol.newSymbol(runtime, "open".intern()); } - break; - case 12: -// line 35 "JavaScanner.rl" - { flavor = RubySymbol.newSymbol(runtime, "self".intern()); } - break; - case 13: -// line 36 "JavaScanner.rl" - { flavor = RubySymbol.newSymbol(runtime, "close".intern()); } - break; - case 16: -// line 1 "NONE" - {te = p+1;} - break; - case 17: -// line 72 "JavaScanner.rl" - {act = 1;} - break; - case 18: -// line 79 "JavaScanner.rl" - {act = 2;} - break; - case 19: -// line 79 "JavaScanner.rl" - {te = p+1;{ - pass_through(input.substring(p, p + 1)); - tagstart = p + 1; - }} - break; - case 20: -// line 72 "JavaScanner.rl" - {te = p;p--;{ - tag(prefix, name, attributes, flavor); - prefix = ""; - name = ""; - attributes = RubyHash.newHash(runtime); - flavor = RubySymbol.newSymbol(runtime, "tasteless".intern()); - }} - break; - case 21: -// line 79 "JavaScanner.rl" - {te = p;p--;{ - pass_through(input.substring(p, p + 1)); - tagstart = p + 1; - }} - break; - case 22: -// line 79 "JavaScanner.rl" - {{p = ((te))-1;}{ - pass_through(input.substring(p, p + 1)); - tagstart = p + 1; - }} - break; - case 23: -// line 1 "NONE" - { switch( act ) { - case 1: - {{p = ((te))-1;} - tag(prefix, name, attributes, flavor); - prefix = ""; - name = ""; - attributes = RubyHash.newHash(runtime); - flavor = RubySymbol.newSymbol(runtime, "tasteless".intern()); - } - break; - case 2: - {{p = ((te))-1;} - pass_through(input.substring(p, p + 1)); - tagstart = p + 1; - } - break; - } - } - break; -// line 590 "JavaScanner.java" - } - } - } - -case 2: - _acts = _parser_to_state_actions[cs]; - _nacts = (int) _parser_actions[_acts++]; - while ( _nacts-- > 0 ) { - switch ( _parser_actions[_acts++] ) { - case 14: -// line 1 "NONE" - {ts = -1;} - break; -// line 604 "JavaScanner.java" - } - } - - if ( cs == 0 ) { - _goto_targ = 5; - continue _goto; - } - if ( ++p != pe ) { - _goto_targ = 1; - continue _goto; - } -case 4: - if ( p == eof ) - { - if ( _parser_eof_trans[cs] > 0 ) { - _trans = _parser_eof_trans[cs] - 1; - _goto_targ = 3; - continue _goto; - } - } - -case 5: - } - break; } - } - -// line 176 "JavaScanner.rl" - - return rv; - } -} diff --git a/vendor/plugins/radius/lib/radius/parser/JavaScanner.rl b/vendor/plugins/radius/lib/radius/parser/JavaScanner.rl deleted file mode 100644 index b53601a1..00000000 --- a/vendor/plugins/radius/lib/radius/parser/JavaScanner.rl +++ /dev/null @@ -1,179 +0,0 @@ -%%{ - machine parser; - - action _prefix { mark_pfx = p; } - action prefix { - prefix = input.substring(mark_pfx, p); - } - action _check_prefix { - if ( !prefix.equals(tag_prefix) ) { - // have to manually add ':' / Sep - // pass the text through & reset state - pass_through(input.substring(tagstart, p) + ":"); - prefix = ""; - fgoto main; - } - } - - action _starttag { mark_stg = p; } - action starttag { name = input.substring(mark_stg, p); } - action _attr { mark_attr = p; } - action attr { - attributes.op_aset( - runtime.getCurrentContext(), - RubyString.newString(runtime, nat), - RubyString.newString(runtime, vat) - ); - } - - action _nameattr { mark_nat = p; } - action nameattr { nat = input.substring(mark_nat, p); } - action _valattr { mark_vat = p; } - action valattr { vat = input.substring(mark_vat, p); } - - action opentag { flavor = RubySymbol.newSymbol(runtime, "open".intern()); } - action selftag { flavor = RubySymbol.newSymbol(runtime, "self".intern()); } - action closetag { flavor = RubySymbol.newSymbol(runtime, "close".intern()); } - - Closeout := empty; - - # words - PrefixChar = [\-A-Za-z0-9._?] ; - NameChar = [\-A-Za-z0-9._:?] ; - TagName = NameChar+ >_starttag %starttag; - Prefix = PrefixChar+ >_prefix %prefix; - Open = "<"; - Sep = ":" >_check_prefix; - End = "/"; - Close = ">"; - - Name = Prefix Sep TagName; - - NameAttr = NameChar+ >_nameattr %nameattr; - Q1Char = ( "\\\'" | [^'] ) ; - Q1Attr = Q1Char* >_valattr %valattr; - Q2Char = ( "\\\"" | [^"] ) ; - Q2Attr = Q2Char* >_valattr %valattr; - - Attr = NameAttr space* "=" space* ('"' Q2Attr '"' | "'" Q1Attr "'") space* >_attr %attr; - Attrs = (space+ Attr* | empty); - - CloseTrailer = End Close %selftag; - OpenTrailer = Close %opentag; - - Trailer = (OpenTrailer | CloseTrailer); - - OpenOrSelfTag = Name Attrs? Trailer; - CloseTag = End Name space* Close %closetag; - - SomeTag = Open (OpenOrSelfTag | CloseTag); - - main := |* - SomeTag => { - tag(prefix, name, attributes, flavor); - prefix = ""; - name = ""; - attributes = RubyHash.newHash(runtime); - flavor = RubySymbol.newSymbol(runtime, "tasteless".intern()); - }; - any => { - pass_through(input.substring(p, p + 1)); - tagstart = p + 1; - }; - *|; -}%% - -package radius.parser; - -import java.util.HashMap; -import java.util.LinkedList; -import org.jruby.Ruby; // runtime -import org.jruby.RubyObject; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.RubyArray; -import org.jruby.RubyString; -import org.jruby.RubyHash; -import org.jruby.RubySymbol; - -public class JavaScanner { - - Ruby runtime = null; - RubyArray rv = null; - - void pass_through(String str) { - RubyObject last = ((RubyObject)rv.last()); - if ( rv.size() > 0 && last != null && (last instanceof RubyString) ){ - // XXX concat changes for ruby 1.9 - ((RubyString) last).concat(RubyString.newString(runtime, str)); - } else { - rv.append(RubyString.newString(runtime, str)); - } - } - - void tag(String prefix, String name, RubyHash attr, RubySymbol flavor) { - RubyHash tag = RubyHash.newHash(runtime); - tag.op_aset( - runtime.getCurrentContext(), - RubySymbol.newSymbol(runtime, "prefix"), - RubyString.newString(runtime, prefix) - ); - tag.op_aset( - runtime.getCurrentContext(), - RubySymbol.newSymbol(runtime, "name"), - RubyString.newString(runtime, name) - ); - tag.op_aset( - runtime.getCurrentContext(), - RubySymbol.newSymbol(runtime, "attrs"), - attr - ); - tag.op_aset( - runtime.getCurrentContext(), - RubySymbol.newSymbol(runtime, "flavor"), - flavor - ); - rv.append(tag); - } - - public JavaScanner(Ruby runtime) { - this.runtime = runtime; - } - - %% write data; - - public RubyArray operate(String tag_prefix, String input) { - char[] data = input.toCharArray(); - String disposable_string; - - String name = ""; - String prefix = ""; - RubySymbol flavor = RubySymbol.newSymbol(runtime, "tasteless".intern()); - RubyHash attributes = RubyHash.newHash(runtime); - - int tagstart = 0; - int mark_pfx = 0; - int mark_stg = 0; - int mark_attr = 0; - int mark_nat = 0; - int mark_vat = 0; - - String nat = ""; - String vat = ""; - - int cs; - int p = 0; - int pe = data.length; - int eof = pe; - int act; - int ts; - int te; - - rv = RubyArray.newArray(runtime); - char[] remainder = data; - - %% write init; - %% write exec; - - return rv; - } -} diff --git a/vendor/plugins/radius/lib/radius/parser/java_scanner.jar b/vendor/plugins/radius/lib/radius/parser/java_scanner.jar deleted file mode 100644 index f652a9ffc6375e55489a19b2b32d8291e748e80a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9560 zcma)ibyOVPvM<5iB{-n-uJ-d(j;(uB0YL)!xu9oc4-0DtZ%=M_3lC2l4{l`( z9}8_O3s+Yg4+eQ>3m-QRE-PmXPtSOWi^iJfOK~zx&SFG1?g3%%Xv!U?`SNu{9tsGd z8c=0ibyR}nR8fsn<KhZzZ@(XS&`$KHlM&qg?>- zHIuZ!N?^S~EOLy_Z?%jTrX>TQL|;bwAwMITkMM+W?89Y%4>@28*j4UWQOz5E(#&(( zhCN=lm+3ks@DS86lQeIe}C|MCWF z4W&5UW#B0NI>bqMQ~3=OukJ)0DjN1t02>wAjJ<#RqIX=#A!NWj zi*zI8Xl*O?MBxG9y1^)^WJG{|ztt;_590)I#>C!kdiSs$G6=Q?`oN<>+}GE&A_-;+ zz1#6zGAuy~-%r5PDfIYAi<&PHsTDI#iw7rQHB2KtfIuI`S)_RcJ z)}-UbyFYgrJN&p#nSK7${LU-R^Zn@&E?A+uGJ(cLypP13DB>q|fB#6ned6oYcl+_;J2+^pCSW{g+;sAT|J&5;ZjssM%O}e~ zhb%F%fs`nlaGK-H>m38%P!v2IK5?<3!dRq`rm=qYeJS$_@KfTanlARm8Ds%k&%xDZ zetcEuLDC+z_@{}GT0j=Y=Z3gcL-`6$APQ2qn@d_#K}+ym<ORJNa#Y7$V?zg0io^ zIhz=pCQg`R$kD4zuAT5$^%u8B!aXv^+@c1%vHbPbSKa-ScFwP| z_wIlH3T}V<1M#ci-&_CJi6^9YXIw^ufKV!pfI$1dZT&yCec$M9pz+X;{GbcMWevsO1(gW!?#?Au~L_z+Zs69EYC%E*LyAklJB%iO7e2 zo9aS}z8b_gZOa(9!n^O7#iW|h99Cq(G$qIM0C6x4{S`~HDIk&H2zVuw%p5JI^zBu0 zDb-~oQl8chx=&M-;Tj^Qmy3eC_E5U{a^xlnd$OvoIr3W;ciMq`YV3z{p5`~%k}Krs z0uR|ToYZHzD?w*eC_nz3R)uWFQ&S51pvr7CDoY!`*Jks$P>nTDkss z7=`B27o9yW_4S3A*8&x(Eo!X_y6Q@rV7y;uNea{7U=Cw9H{Khq`S~)d`*_yEoaSwF zTrJK>pK#yHv2$4sRcPX8_&I8IAsVSE@SX=byQl=1JG@?xl=^bG{RNtnsZ0NUeu?qX z#drh>){A{F$g0l+Ez%Mi2(k_7@r2iP>UOLPcs16O5X>8{8OiXv*I*`k%Q&hREe%_3 zR1w&@uyX)1RLGYk1}`3d6lV6%UdU!cwA=h<;mOm{Glg0ZR zUAn+4k<{ILJ#l?aLp%+&oqT7eWY+e|bg51HN_u~jdPsDk4^=x}wX~px?icl=G?+Id znY#D2?22L%MxN+5Tc{MUehVerEhccWOvkeARVC}h-uCWezZ56y#H{&5&E-qoeGyFC zx)XH?^cryK>m5!vv4>%81q+&7l6J;#&7PN@%%0;#g!+~N1)3k;dLf&9K`#B8V|h4qTZ>6vWgKdu9ZM~cxx?L%eDl1`siQO1=sY`-++An;N(7w?<)fe0&yy4*J z>oQ>EZ|uZ=fz<6m@yFMNt<|TIguME8+qiyDfA#&j-t4D@k5iB4E8IZCFCXb>dXSAP z2zZB1aF>}jns&@w)t-FheSBQLV~aXj?)FE(loQaMFRogAXyB0-`O_3AHn6UHh1z~W ztSpLSd{S$x93kp~Sl__Qha&v&YKtOPFBs3);^F8P^1aYk?=4=EMXZxWoite(6Al+! z7?Td~Z%C5s^(uElUR$gp&@P=MlrQ6z*9@BsCmZH zzF5Q>ZZPLcE<8i9&ge!zDxL}XBcjL=M0&b{uQi93VCr6d9_f25I0`lX^U6s-ijP2& z7C{U@zF{l+8agWuM#OMXj+Rtcqb#8Jot#^nycYE0t89R)r1jzgU*}cDZXShM@?=qkk`4;H{4^2dTFLfX9nigo}t$%y?i zzKUEGFxgNiZeB}quROD0gw9)=M{5M2R%ltDpm6-j66ym~E4KWo4*sYDxcj>ze|8Ehiz69pC!gyQ{~)@H|rjxjiIB;H1*K6zzw~Tz2lg=kL&8+W^o4f z2gH{w6QfW!7!e6BSHN0Hfb&ndk(+xU@iTXZc7>oY9NLbAYPaYw=MSh+)8%gN$54MS z0&(hc*%|rc1$eUjG0OEfrr0F;lf~1+z44GRq6fhuZpFP+MV&{5J2BQ@>I<--9gO+aEJ zM^TxWVi5vmPHzgCtm0`|mX?KmbdvOT6pNhVbE%iyulgWw0Xl}qFT!IGKOlFe7p|%| zFVKgxsfa^g4MBp?7t{R_Eh>s}muWj(BsK)F*=^Pf^D|sxyGI}z)XjpK?d{clC3Z`@ z)BMjfZSi?7?@q^mhUI2MMnqpLh_;j@_)MEU%hCiN+>zbsU8xOWsu?t%3z-Ab7CBvatZ*oMILXjIVBGfl?ii)EDp}tVw;9W zs`T`Uxhs7`2^GqTIZS;+dKGp{harxt@Zz-kMo_xm^cbb~2SY5k-Fho{IyP9MmwKF5H=P5^%RJx4_37mDJc$BCG0?#yqZ zpGt~k?tb(cWIxJ=#I_CdE(n`FS=Za*7&+`P*jJ|0oY&c!r$(9=>s+p#*B#S+04h%A z4o>=OhUq?pDxz7%RaOr194_K2@P1a%FkimE>r4sFKovG^siVs?sd`wDO9#5Qf`y2 zvDBGoNpqy@IfXui8@ZDzwU|rBjC_vzX5@~`TDxPsCXO`?+$GJ?nB!~>9yD^NA8XkG zK+OAw3U>)T@UXh&9xeKc3ok&kZ`;0i$ow>6eW)f3dL7&C1m12c{4O%<-eun^?Z3q$ z?gp5t+X?>JY2d#F5O+(S_7uvJ8qO-RFv$tqkKP3xy6AO1W=HN5+3i)Hf zGsTBwb8zlCc+K3t+uXj&(bZcE8iIq@{l5*Z-vM0|+SFduR6{!3$9LM;KcKNt&X}wk z9tLIfgzpYlVJd1->HnJJLp;`(4$m??b*;2WD#)q$9v(E1-_(86-87vPe zV6*z~@aS&h*$lRaIj~v#_X+%4>i9uvh4zIk9~qE3LFVW2R1NwJKy|C2zy#Gw`Jzb@R=Bk#+=h*LREPBW9@ilq(;OP7J2+ z&)GzH8L&22rsPS~6|18z#BzQfN+%jhN3FAoU#Zt~7FKc=HgGmzZsvn_Ul)#YLj|G> znY0!-pooR`FqSn2s6cEXsaB&Lu?vY@RbiPLaZ_w0E#%)RGmbwG=?)kZbgE?ryX5XHawTLf11$Zm)y!K;FOBMryBjk zZN7+Ekue>FiY1lWfpdt@oL8I#^)X8lS7z}b@hnko+_bOktg7R z>%v{sS$CLys}dg-K8|2)q!DD}^Ol!g6GqJ8UY zz71xIb21#fXaxxtBgPBK>)Hier78se1k2PLRV!z4tBJwSEYrKBHYuK~1MSeFWeEDXM*&I3O?VMnT4}>*EkvQmFj_A#- zoo8Hb&usZy4(%zkP*Re;=s{k=kW5!V3^*k-OVvu;=Mh}$&xWT4vlL0juCOH>`^q3C zFi&;PPJ5&?Zg;Ma_8z8Pmn2F&+iLl%S5QQEqD)7t> zY_BpTzaF(cJ_XfZa3A}pgc5lUCu`UQgN=Jy5q9;5)IPNokPr)N*e?c~%Yq{8ywub_ zl@yS#8U)o%aeRkbiM(@y73nTq8}%}x2pe089IQM}rw2iGNCAzer%JaKVOKEPypn~W zHZa=MNzqGJ{R676dh$(dG+1YnV$4XoZV4EU5_FM|pgQSc&}fId#@^ z>HzTg&by62gE0>wc&hRD&E zo;$>&I0L0(34z>siio8Jp0v#bjj2Yv8t$fo)#k^BHOR8LUJX5wGWo12u zSu;iqh62@j6Ko87f6H)@@o?H2_BW<_2H4~P*bj3IP%=h%-ivuMxl`1nd`KnAn$IUF zGTygV*VcOja)+vycovF#X$sj1tCild@FyL>7Npt}AxPzlc09RLRi3TJ172M7ejM++ zr!Tb}=_VA)L!4=gQ9(he6m;#GMow*=;YW~?311F*h=ekZreE>&wU%RWHwyAtqvp z(S!0AurP3ACrf`?hL&CfLhZmS4UhnJe+lj;GURT~OX?6ZxdWB<^c|bzdy}s49TI{Y zafbk1|86Finv-JW?d1vdcXZS@R}fyWlthyjoW&IyZENAw+8tgXQAZmHF6KZY!At7 z{xK28yHZN@cQvnxeoH@pa9em}*?VMYlEeyRx@?Pnl&PV=i;aH#9Q~Lr5woMxmA-QU zfJZNMr@SyzIin1LVPhf_$Ld8&Wc6Cljt>{6nbZKI&9lboO>#hVkhMZDpmd|D#!gBe z&zyj~zh$dbf#2uUA*152UPRKJu1tzwDA6}M-?M2sDuK8R9BD#`Lv*$*)0hrQV%x|? zq>@WKygJOb!Blw%WKT&gFG z$IsV3p+w%yFS=#Wm(VNInm-iz)c1;n$cJ2W4A#gZQ+km}e^~g~##-kf0xuh(v3YUgc?W|CaQwKMH7JbPZvEIq#fB`QXTE_0e;_uUzj7K0dW0E93Ktiixjz_ZL^c!v-)vx;lOWCv6Tvg ziByk6o;k_AA^F)zL*RtVl*|v4RCt~cq2N?Jwx!hRkD$!lqi=L`L(&X&p5OQ5wZ3K2 zYZV=^fI?u3+zQEcRC10903spiPY+@ToEX5K5VTPU8n?#+%7ZBi{;OR$1~v*#0DKUF zQVnQXGbtp;P{}d9AzH`ueb4D4{^nhkC(}j=QOd9X7-yFf|GMqd>aR5BmYo*pE=sWFf#0 zCfZ1S32eshkbK?DK+;h(#wPsf)yc07NdtBvWkqDZ-17GY^>-|aTehUM5mXYG?B7{3 z0|~G08NgRc`n}8{aU8t&beeUc&=jYnMAi=)()9VEh7u^A_rwcu*0KX_{E5vANrQ(~_~dl2N(&jbGMLgCw^FFOjhHY9ouQ`B$&YeL*D4S*LfT zqTTzHzXL05M)D^T%w`hIrV?nMmC*#Vi3G_E>YhAm$#m*`|K{YH=IqlOFJWhxsHdo( zUQ%YR4yIQ51eMnvgU{X3>1E!FD8bcjX51gQW5C~kRDRx`Az?K7?FMSBnj=nOKSiU{ zDw9UH5G614nIpPy!vTHXn%SThQS9Y2hT+pWp`UVtE&gW0YqcK6b&$; z{XwuD9@CfT)Q?D}F1SMcW+%H7xm_Pe-xPn*!RB&sH&;50%xL`iw3#w4zWXStKdWOr zI~`JFZRabujLXF6a*g8?2)KN+!U7~8ARl`FOGS{k_gqBJ=y#TLW-i9i=?iQqu)8@wlvB_EPe z$p>j``lnP<=Og>wwrG=u^90Y4ZNy|;H~HJy*PBb%_(w%wJ)`JWU3C4m@j^y&+a+~% z{pU9ve$6M)1c$y@>H>&n+2Kj`@T$3w_z`s^c6*{jHkKIN9_SSrRfUlq7^e4bsDcIF zwhPYZp5Iiq@CP((uAWb>(-l&Zw(^#5IIlNsW$PX!Wc#AeZ5j}{A!UfhiWDwLpHoko zTugzrH(Ad)-ulD+-IN85dp)|2MrEa%$dMdH9~Reqs#@@LJDsKK9&IlaH+`1=93U(= zn>MZ+{MxPcsi(MBz+sv8D%ByhB`}Plqx>PVC&n6AUoF3mpmH;%dy^4#C!ul7)=vmKL1_ih#gSEZg)OvX8kTOGJtfk z>YdSXg2%|UjJh|t#earKYYwYz`Lkebet2i(2wl$t^;lKcD}ibRC2ryy83I4heLi*W z!AY#9rdLaQ(*iYT=;`LM^0&73#UYx*Bs1gy%U{7JTd;v1;JKbrot0{fBbWEc=+263 z6NR5u`{EVk_T}!8tL^|=Y3tLD*Jq4L7IJHAUYJ+Xr_DFt*_1ZNE#U1PY4yMeU_S@f z5K%B=o&fPz(T*|SvowGf{Pm~@wbMv(i8JqclRlN>QmT2?)%AIb?kKzYQAq+!i@$hR}4__ zJW<>0{RVcjK*io;2a#(?qpW5~)FZ;6$_pH&n1Y)n*H=emJ9yG}w|g@}^pf z+<>a90g35ik7t&~Il%p+v zKBm7;7b%j^5kJnTcpX%cr=yIge zsiC|rrzKCUXo(YCSRWQWrrwji&ihg4zkLS|vj1%mWF7cPLZDlx2h@v3lB;E0&@w~rc>eg|;*?)yTXrQh9J z=G}J0S+p;U4{G8;a4gt{m}MMq4-cD*fK?&qbf&e60Mj}o-q9$HXG&lo)78j&vX+zI zc1@3>!PzN(wV4z)yyQ69fD(V-JReWweE71d86L0OJb|5mCJ&qTiPCZlShBC}GOw)b zvgcdtwySLEa=mkr{7V^)ehI|_wQ=pK&) zySs!+(PEgZBce2n!M|8qA1VL556g7BybP6*y?UgSO-cCb4L2hvd_$~2bsKU$qzDGyrJvk+)s&vjO?dTfm%cBjVhoLsBsvXzv-ptTgY|1O#)cK+V_ zK#W@gIJ4x+JmF(7P-9Q<%hnT$rpgOMOoacL*z^3S`=7=?(R}_j?B9t#f5$LCtN#`D zPqd%E6aV*wp1%=7p4I<9de6UO{ySacZ_L|g>d^m;`CsIXe+K;TNC1BWUOn@W{zt%n ZPy#enP*DF0KzY8Lo=GIje=$f9{sWx;gt!0z diff --git a/vendor/plugins/radius/lib/radius/parser/scanner.rb b/vendor/plugins/radius/lib/radius/parser/scanner.rb deleted file mode 100644 index 693a2855..00000000 --- a/vendor/plugins/radius/lib/radius/parser/scanner.rb +++ /dev/null @@ -1,1255 +0,0 @@ -# coding: utf-8 - -# line 1 "scanner.rl" - -# line 84 "scanner.rl" - - -module Radius - class Scanner - def operate(prefix, data) - data = Radius::OrdString.new data - buf = "" - csel = "" - @prematch = '' - @starttag = nil - @attrs = {} - @flavor = :tasteless - @cursor = 0 - @tagstart = 0 - @nodes = [''] - remainder = data.dup - - until remainder.length == 0 - p = perform_parse(prefix, remainder) - remainder = remainder[p..-1] - end - - return @nodes - end - - private - def perform_parse(prefix, data) - stack = [] - p = 0 - ts = 0 - te = 0 - act = 0 - eof = data.length - - @prefix = prefix - -# line 42 "scanner.rb" -class << self - attr_accessor :_parser_trans_keys - private :_parser_trans_keys, :_parser_trans_keys= -end -self._parser_trans_keys = [ - 0, 0, 45, 122, 45, 122, - 9, 122, 9, 122, 9, - 122, 9, 61, 9, 39, - 34, 92, 34, 92, 9, 122, - 9, 122, 62, 62, 34, - 92, 9, 122, 9, 122, - 9, 122, 9, 92, 9, 92, - 9, 122, 34, 92, 34, - 92, 34, 92, 9, 122, - 39, 92, 39, 92, 9, 122, - 9, 122, 9, 92, 9, - 92, 34, 92, 34, 92, - 9, 122, 9, 122, 9, 122, - 9, 92, 9, 92, 9, - 122, 34, 92, 9, 122, - 9, 122, 39, 92, 39, 92, - 45, 122, 45, 122, 45, - 122, 9, 122, 9, 62, - 0, 0, 60, 60, 45, 122, - 0, 0, 0, 0, 34, - 92, 34, 92, 34, 92, - 34, 92, 39, 92, 39, 92, - 0, 0, 0 -] - -class << self - attr_accessor :_parser_key_spans - private :_parser_key_spans, :_parser_key_spans= -end -self._parser_key_spans = [ - 0, 78, 78, 114, 114, 114, 53, 31, - 59, 59, 114, 114, 1, 59, 114, 114, - 114, 84, 84, 114, 59, 59, 59, 114, - 54, 54, 114, 114, 84, 84, 59, 59, - 114, 114, 114, 84, 84, 114, 59, 114, - 114, 54, 54, 78, 78, 78, 114, 54, - 0, 1, 78, 0, 0, 59, 59, 59, - 59, 54, 54, 0 -] - -class << self - attr_accessor :_parser_index_offsets - private :_parser_index_offsets, :_parser_index_offsets= -end -self._parser_index_offsets = [ - 0, 0, 79, 158, 273, 388, 503, 557, - 589, 649, 709, 824, 939, 941, 1001, 1116, - 1231, 1346, 1431, 1516, 1631, 1691, 1751, 1811, - 1926, 1981, 2036, 2151, 2266, 2351, 2436, 2496, - 2556, 2671, 2786, 2901, 2986, 3071, 3186, 3246, - 3361, 3476, 3531, 3586, 3665, 3744, 3823, 3938, - 3993, 3994, 3996, 4075, 4076, 4077, 4137, 4197, - 4257, 4317, 4372, 4427 -] - -class << self - attr_accessor :_parser_indicies - private :_parser_indicies, :_parser_indicies= -end -self._parser_indicies = [ - 1, 1, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 0, 0, - 0, 0, 1, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 1, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 3, - 3, 0, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 0, 0, 0, - 0, 3, 0, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 0, 0, 0, - 0, 3, 0, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 0, 4, 4, - 4, 4, 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 4, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 5, 6, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, - 0, 0, 0, 7, 5, 0, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, - 0, 0, 0, 0, 5, 0, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, - 0, 8, 8, 8, 8, 8, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 8, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 9, 9, 10, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 11, 9, - 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 9, - 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 13, 13, 13, 13, - 13, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 13, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 14, 14, 12, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 12, 12, - 15, 12, 14, 12, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 12, 12, - 12, 12, 14, 12, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 12, 16, - 16, 16, 16, 16, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 16, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 17, 12, 17, 17, 17, - 17, 17, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 17, 12, 18, 12, - 12, 12, 12, 19, 12, 21, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 22, - 20, 24, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 25, 23, 26, 26, 26, - 26, 26, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 26, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 27, 27, 28, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 12, - 12, 12, 29, 27, 12, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 12, - 12, 12, 12, 27, 12, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 12, - 30, 30, 30, 30, 30, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 30, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 31, 31, 32, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 12, 12, 12, 33, 31, 12, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 12, 12, 12, 12, 31, 12, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 12, 34, 12, 35, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 25, - 23, 36, 36, 36, 36, 36, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 36, 23, 24, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 37, 37, 38, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 23, 23, 23, 39, 37, - 23, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 23, 25, 23, 23, 37, - 23, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 23, 40, 40, 40, 40, - 40, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 40, 23, 24, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 41, 41, 42, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 23, 23, - 23, 43, 41, 23, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 23, 25, - 23, 23, 41, 23, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 23, 44, - 44, 44, 44, 44, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 44, 23, - 24, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 45, 45, 23, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 45, 23, 23, 46, 23, 45, 23, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 45, 23, 25, 23, 23, 45, 23, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 45, 23, 47, 47, 47, 47, 47, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 47, 23, 24, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 48, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 25, 23, 48, - 48, 48, 48, 48, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 48, 23, - 49, 23, 23, 23, 23, 50, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 25, 23, 51, 51, 51, 51, - 51, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 51, 20, 21, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 52, 52, 53, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 20, 20, - 20, 54, 52, 20, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 20, 22, - 20, 20, 52, 20, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 20, 24, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 55, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 25, 23, 57, 56, 56, 56, 56, - 58, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 59, 56, 61, - 60, 60, 60, 60, 35, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 62, 60, 64, 64, 64, 64, 64, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 64, 63, 63, 63, 63, 63, - 63, 24, 63, 63, 63, 63, 63, 65, - 65, 66, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 63, 63, 63, - 67, 65, 63, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 63, 68, 63, - 63, 65, 63, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 63, 24, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 68, 63, 61, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 68, 63, 69, 69, 69, 69, - 69, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 69, 63, 63, 63, 63, - 63, 63, 24, 63, 63, 63, 63, 63, - 70, 70, 71, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 63, 63, - 63, 72, 70, 63, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 63, 68, - 63, 63, 70, 63, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 63, 73, - 73, 73, 73, 73, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 73, 63, - 63, 63, 63, 63, 63, 24, 63, 63, - 63, 63, 63, 74, 74, 63, 74, 74, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 63, 63, 75, 63, 74, 63, 74, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 63, 68, 63, 63, 74, 63, 74, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 63, 76, 76, 76, 76, 76, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 76, 63, 63, 63, 63, 63, 63, - 24, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 77, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 68, 63, 77, - 77, 77, 77, 77, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 77, 63, - 78, 63, 63, 63, 63, 79, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 68, 63, 80, 56, 56, 56, - 56, 58, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 59, 56, - 81, 60, 60, 60, 60, 81, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 62, 60, 82, 82, 82, 82, - 82, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 82, 60, 61, 60, 60, - 60, 60, 35, 60, 60, 60, 60, 60, - 83, 83, 84, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 60, 60, - 60, 85, 83, 60, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 60, 62, - 60, 60, 83, 60, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 60, 86, - 86, 86, 86, 86, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 86, 60, - 61, 60, 60, 60, 60, 35, 60, 60, - 60, 60, 60, 87, 87, 88, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, - 87, 60, 60, 60, 89, 87, 60, 87, - 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, - 87, 60, 62, 60, 60, 87, 60, 87, - 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, - 87, 60, 90, 90, 90, 90, 90, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 90, 60, 61, 60, 60, 60, 60, - 35, 60, 60, 60, 60, 60, 91, 91, - 60, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 60, 60, 92, 60, - 91, 60, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 60, 62, 60, 60, - 91, 60, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 60, 93, 93, 93, - 93, 93, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 93, 60, 61, 60, - 60, 60, 60, 35, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 94, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 62, 60, 94, 94, 94, 94, 94, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 94, 60, 95, 60, 60, 60, 60, - 96, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 62, 60, 97, - 97, 97, 97, 97, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 97, 56, - 80, 56, 56, 56, 56, 58, 56, 56, - 56, 56, 56, 98, 98, 99, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 56, 56, 56, 100, 98, 56, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 56, 59, 56, 56, 98, 56, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 56, 61, 60, 60, 60, 60, 35, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 101, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 62, 60, 97, 97, - 97, 97, 97, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 97, 56, 57, - 56, 56, 56, 56, 58, 56, 56, 56, - 56, 56, 98, 98, 99, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 56, 56, 56, 100, 98, 56, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 56, 59, 56, 56, 98, 56, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 56, 103, 103, 103, 103, 103, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 103, 102, 102, 102, 102, 102, 102, 21, - 102, 102, 102, 102, 102, 104, 104, 105, - 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 102, 102, 102, 106, 104, - 102, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 102, 107, 102, 102, 104, - 102, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 102, 24, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 108, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 68, 63, 21, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 107, 102, 109, 109, 0, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 0, - 0, 0, 0, 0, 109, 0, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, - 0, 0, 0, 0, 109, 0, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, - 0, 110, 110, 0, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 111, 0, - 0, 0, 0, 110, 0, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 0, - 0, 0, 0, 110, 0, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 110, - 110, 110, 110, 110, 110, 110, 110, 0, - 112, 112, 0, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 0, 0, - 0, 0, 112, 0, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 0, 0, - 0, 0, 112, 0, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 112, 112, 112, 0, 113, - 113, 113, 113, 113, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 113, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 114, 114, 0, 114, 114, - 114, 114, 114, 114, 114, 114, 114, 114, - 114, 0, 0, 0, 115, 114, 0, 114, - 114, 114, 114, 114, 114, 114, 114, 114, - 114, 114, 114, 114, 114, 114, 114, 114, - 114, 114, 114, 114, 114, 114, 114, 114, - 114, 0, 0, 0, 0, 114, 0, 114, - 114, 114, 114, 114, 114, 114, 114, 114, - 114, 114, 114, 114, 114, 114, 114, 114, - 114, 114, 114, 114, 114, 114, 114, 114, - 114, 0, 116, 116, 116, 116, 116, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 116, 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, 117, - 0, 118, 120, 119, 122, 122, 123, 122, - 122, 122, 122, 122, 122, 122, 122, 122, - 122, 121, 121, 121, 121, 121, 122, 121, - 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 121, 121, 121, 121, 122, 121, - 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 121, 124, 125, 24, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 25, - 23, 24, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 25, 23, 61, 60, 60, - 60, 60, 35, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 62, - 60, 61, 60, 60, 60, 60, 35, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 62, 60, 24, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 68, 63, 24, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 68, 63, 126, 0 -] - -class << self - attr_accessor :_parser_trans_targs - private :_parser_trans_targs, :_parser_trans_targs= -end -self._parser_trans_targs = [ - 49, 1, 2, 3, 4, 3, 12, 52, - 4, 5, 12, 52, 49, 6, 5, 7, - 6, 7, 8, 42, 9, 10, 13, 9, - 10, 13, 11, 5, 12, 52, 11, 5, - 12, 52, 51, 14, 15, 16, 20, 54, - 15, 16, 20, 54, 17, 16, 18, 17, - 18, 19, 21, 15, 16, 20, 54, 53, - 22, 23, 14, 31, 22, 23, 31, 24, - 26, 27, 41, 58, 25, 26, 27, 41, - 58, 28, 27, 29, 28, 29, 30, 40, - 23, 32, 33, 34, 38, 56, 33, 34, - 38, 56, 35, 34, 36, 35, 36, 37, - 39, 33, 34, 38, 56, 55, 24, 26, - 27, 41, 58, 25, 57, 44, 44, 45, - 46, 47, 46, 59, 47, 59, 0, 49, - 50, 49, 1, 43, 49, 49, 49 -] - -class << self - attr_accessor :_parser_trans_actions - private :_parser_trans_actions, :_parser_trans_actions= -end -self._parser_trans_actions = [ - 1, 0, 2, 3, 4, 0, 4, 4, - 0, 5, 0, 0, 6, 7, 0, 7, - 0, 0, 0, 0, 8, 9, 8, 0, - 10, 0, 11, 12, 13, 13, 0, 14, - 15, 15, 0, 10, 11, 12, 13, 16, - 0, 14, 15, 17, 7, 0, 7, 0, - 0, 10, 0, 18, 19, 20, 21, 22, - 8, 23, 9, 8, 0, 10, 0, 0, - 11, 12, 13, 16, 0, 0, 14, 15, - 17, 7, 0, 7, 0, 0, 0, 10, - 9, 10, 11, 12, 13, 16, 0, 14, - 15, 17, 7, 0, 7, 0, 0, 10, - 10, 18, 19, 20, 21, 22, 8, 18, - 19, 20, 21, 8, 22, 24, 0, 2, - 3, 4, 0, 4, 0, 0, 0, 27, - 28, 29, 24, 0, 30, 31, 32 -] - -class << self - attr_accessor :_parser_to_state_actions - private :_parser_to_state_actions, :_parser_to_state_actions= -end -self._parser_to_state_actions = [ - 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, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 25, 25, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 -] - -class << self - attr_accessor :_parser_from_state_actions - private :_parser_from_state_actions, :_parser_from_state_actions= -end -self._parser_from_state_actions = [ - 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, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 26, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0 -] - -class << self - attr_accessor :_parser_eof_trans - private :_parser_eof_trans, :_parser_eof_trans= -end -self._parser_eof_trans = [ - 0, 1, 1, 1, 1, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 1, 1, 1, 1, 1, - 0, 0, 122, 125, 126, 125, 126, 125, - 126, 125, 126, 127 -] - -class << self - attr_accessor :parser_start -end -self.parser_start = 49; -class << self - attr_accessor :parser_first_final -end -self.parser_first_final = 49; -class << self - attr_accessor :parser_error -end -self.parser_error = 0; - -class << self - attr_accessor :parser_en_Closeout -end -self.parser_en_Closeout = 48; -class << self - attr_accessor :parser_en_main -end -self.parser_en_main = 49; - - -# line 120 "scanner.rl" - -# line 780 "scanner.rb" -begin - p ||= 0 - pe ||= data.length - cs = parser_start - ts = nil - te = nil - act = 0 -end - -# line 121 "scanner.rl" - -# line 792 "scanner.rb" -begin - testEof = false - _slen, _trans, _keys, _inds, _acts, _nacts = nil - _goto_level = 0 - _resume = 10 - _eof_trans = 15 - _again = 20 - _test_eof = 30 - _out = 40 - while true - if _goto_level <= 0 - if p == pe - _goto_level = _test_eof - next - end - if cs == 0 - _goto_level = _out - next - end - end - if _goto_level <= _resume - case _parser_from_state_actions[cs] - when 26 then -# line 1 "scanner.rl" - begin -ts = p - end -# line 1 "scanner.rl" -# line 821 "scanner.rb" - end - _keys = cs << 1 - _inds = _parser_index_offsets[cs] - _slen = _parser_key_spans[cs] - _trans = if ( _slen > 0 && - _parser_trans_keys[_keys] <= data[p] && - data[p] <= _parser_trans_keys[_keys + 1] - ) then - _parser_indicies[ _inds + data[p] - _parser_trans_keys[_keys] ] - else - _parser_indicies[ _inds + _slen ] - end - end - if _goto_level <= _eof_trans - cs = _parser_trans_targs[_trans] - if _parser_trans_actions[_trans] != 0 - case _parser_trans_actions[_trans] - when 24 then -# line 5 "scanner.rl" - begin - mark_pfx = p end -# line 5 "scanner.rl" - when 2 then -# line 6 "scanner.rl" - begin - - if data[mark_pfx..p-1] != @prefix - closing = data[mark_pfx-1,1] == '/' - @nodes.last << data[mark_pfx-(closing ? 2 : 1)..p] - begin - p += 1 - _goto_level = _out - next - end - - end - end -# line 6 "scanner.rl" - when 3 then -# line 13 "scanner.rl" - begin - mark_stg = p end -# line 13 "scanner.rl" - when 4 then -# line 14 "scanner.rl" - begin - @starttag = data[mark_stg..p-1] end -# line 14 "scanner.rl" - when 11 then -# line 15 "scanner.rl" - begin - mark_attr = p end -# line 15 "scanner.rl" - when 15 then -# line 16 "scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 16 "scanner.rl" - when 5 then -# line 25 "scanner.rl" - begin - mark_nat = p end -# line 25 "scanner.rl" - when 7 then -# line 26 "scanner.rl" - begin - @nat = data[mark_nat..p-1] end -# line 26 "scanner.rl" - when 8 then -# line 27 "scanner.rl" - begin - mark_vat = p end -# line 27 "scanner.rl" - when 10 then -# line 28 "scanner.rl" - begin - @vat = data[mark_vat..p-1] end -# line 28 "scanner.rl" - when 27 then -# line 79 "scanner.rl" - begin -te = p+1 - begin - @nodes.last << data[p] - @tagstart = p - end - end -# line 79 "scanner.rl" - when 29 then -# line 79 "scanner.rl" - begin -te = p -p = p - 1; begin - @nodes.last << data[p] - @tagstart = p - end - end -# line 79 "scanner.rl" - when 1 then -# line 79 "scanner.rl" - begin - begin p = ((te))-1; end - begin - @nodes.last << data[p] - @tagstart = p - end - end -# line 79 "scanner.rl" - when 6 then -# line 1 "scanner.rl" - begin - case act - when 1 then - begin begin p = ((te))-1; end - - tag = {:prefix=>@prefix, :name=>@starttag, :flavor => @flavor, :attrs => @attrs} - @prefix = nil - @name = nil - @flavor = :tasteless - @attrs = {} - @nodes << tag << '' - begin - p += 1 - _goto_level = _out - next - end - - end - when 2 then - begin begin p = ((te))-1; end - - @nodes.last << data[p] - @tagstart = p - end -end - end -# line 1 "scanner.rl" - when 13 then -# line 15 "scanner.rl" - begin - mark_attr = p end -# line 15 "scanner.rl" -# line 16 "scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 16 "scanner.rl" - when 14 then -# line 16 "scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 16 "scanner.rl" -# line 25 "scanner.rl" - begin - mark_nat = p end -# line 25 "scanner.rl" - when 18 then -# line 27 "scanner.rl" - begin - mark_vat = p end -# line 27 "scanner.rl" -# line 15 "scanner.rl" - begin - mark_attr = p end -# line 15 "scanner.rl" - when 9 then -# line 27 "scanner.rl" - begin - mark_vat = p end -# line 27 "scanner.rl" -# line 28 "scanner.rl" - begin - @vat = data[mark_vat..p-1] end -# line 28 "scanner.rl" - when 23 then -# line 28 "scanner.rl" - begin - @vat = data[mark_vat..p-1] end -# line 28 "scanner.rl" -# line 27 "scanner.rl" - begin - mark_vat = p end -# line 27 "scanner.rl" - when 31 then -# line 30 "scanner.rl" - begin - @flavor = :open end -# line 30 "scanner.rl" -# line 70 "scanner.rl" - begin -te = p -p = p - 1; begin - tag = {:prefix=>@prefix, :name=>@starttag, :flavor => @flavor, :attrs => @attrs} - @prefix = nil - @name = nil - @flavor = :tasteless - @attrs = {} - @nodes << tag << '' - begin - p += 1 - _goto_level = _out - next - end - - end - end -# line 70 "scanner.rl" - when 30 then -# line 31 "scanner.rl" - begin - @flavor = :self end -# line 31 "scanner.rl" -# line 70 "scanner.rl" - begin -te = p -p = p - 1; begin - tag = {:prefix=>@prefix, :name=>@starttag, :flavor => @flavor, :attrs => @attrs} - @prefix = nil - @name = nil - @flavor = :tasteless - @attrs = {} - @nodes << tag << '' - begin - p += 1 - _goto_level = _out - next - end - - end - end -# line 70 "scanner.rl" - when 32 then -# line 32 "scanner.rl" - begin - @flavor = :close end -# line 32 "scanner.rl" -# line 70 "scanner.rl" - begin -te = p -p = p - 1; begin - tag = {:prefix=>@prefix, :name=>@starttag, :flavor => @flavor, :attrs => @attrs} - @prefix = nil - @name = nil - @flavor = :tasteless - @attrs = {} - @nodes << tag << '' - begin - p += 1 - _goto_level = _out - next - end - - end - end -# line 70 "scanner.rl" - when 22 then -# line 1 "scanner.rl" - begin -te = p+1 - end -# line 1 "scanner.rl" -# line 70 "scanner.rl" - begin -act = 1; end -# line 70 "scanner.rl" - when 28 then -# line 1 "scanner.rl" - begin -te = p+1 - end -# line 1 "scanner.rl" -# line 79 "scanner.rl" - begin -act = 2; end -# line 79 "scanner.rl" - when 12 then -# line 15 "scanner.rl" - begin - mark_attr = p end -# line 15 "scanner.rl" -# line 16 "scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 16 "scanner.rl" -# line 25 "scanner.rl" - begin - mark_nat = p end -# line 25 "scanner.rl" - when 20 then -# line 27 "scanner.rl" - begin - mark_vat = p end -# line 27 "scanner.rl" -# line 15 "scanner.rl" - begin - mark_attr = p end -# line 15 "scanner.rl" -# line 16 "scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 16 "scanner.rl" - when 17 then -# line 1 "scanner.rl" - begin -te = p+1 - end -# line 1 "scanner.rl" -# line 16 "scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 16 "scanner.rl" -# line 70 "scanner.rl" - begin -act = 1; end -# line 70 "scanner.rl" - when 19 then -# line 27 "scanner.rl" - begin - mark_vat = p end -# line 27 "scanner.rl" -# line 15 "scanner.rl" - begin - mark_attr = p end -# line 15 "scanner.rl" -# line 16 "scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 16 "scanner.rl" -# line 25 "scanner.rl" - begin - mark_nat = p end -# line 25 "scanner.rl" - when 16 then -# line 1 "scanner.rl" - begin -te = p+1 - end -# line 1 "scanner.rl" -# line 15 "scanner.rl" - begin - mark_attr = p end -# line 15 "scanner.rl" -# line 16 "scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 16 "scanner.rl" -# line 70 "scanner.rl" - begin -act = 1; end -# line 70 "scanner.rl" - when 21 then -# line 1 "scanner.rl" - begin -te = p+1 - end -# line 1 "scanner.rl" -# line 27 "scanner.rl" - begin - mark_vat = p end -# line 27 "scanner.rl" -# line 15 "scanner.rl" - begin - mark_attr = p end -# line 15 "scanner.rl" -# line 16 "scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 16 "scanner.rl" -# line 70 "scanner.rl" - begin -act = 1; end -# line 70 "scanner.rl" -# line 1211 "scanner.rb" - end - end - end - if _goto_level <= _again - case _parser_to_state_actions[cs] - when 25 then -# line 1 "scanner.rl" - begin -ts = nil; end -# line 1 "scanner.rl" -# line 1222 "scanner.rb" - end - - if cs == 0 - _goto_level = _out - next - end - p += 1 - if p != pe - _goto_level = _resume - next - end - end - if _goto_level <= _test_eof - if p == eof - if _parser_eof_trans[cs] > 0 - _trans = _parser_eof_trans[cs] - 1; - _goto_level = _eof_trans - next; - end - end - - end - if _goto_level <= _out - break - end -end - end - -# line 122 "scanner.rl" - return p - end - end -end diff --git a/vendor/plugins/radius/lib/radius/parser/scanner.rl b/vendor/plugins/radius/lib/radius/parser/scanner.rl deleted file mode 100644 index 6c38f5b8..00000000 --- a/vendor/plugins/radius/lib/radius/parser/scanner.rl +++ /dev/null @@ -1,125 +0,0 @@ -%%{ - machine parser; - - - action _prefix { mark_pfx = p } - action prefix { - if data[mark_pfx..p-1] != @prefix - closing = data[mark_pfx-1,1] == '/' - @nodes.last << data[mark_pfx-(closing ? 2 : 1)..p] - fbreak; - end - } - action _starttag { mark_stg = p } - action starttag { @starttag = data[mark_stg..p-1] } - action _attr { mark_attr = p } - action attr { - @attrs[@nat] = @vat - } - - action prematch { - @prematch_end = p - @prematch = data[0..p] if p > 0 - } - - action _nameattr { mark_nat = p } - action nameattr { @nat = data[mark_nat..p-1] } - action _valattr { mark_vat = p } - action valattr { @vat = data[mark_vat..p-1] } - - action opentag { @flavor = :open } - action selftag { @flavor = :self } - action closetag { @flavor = :close } - - action stopparse { - @cursor = p; - fbreak; - } - - - Closeout := empty; - - # words - PrefixChar = [\-A-Za-z0-9._?] ; - NameChar = [\-A-Za-z0-9._:?] ; - TagName = NameChar+ >_starttag %starttag; - Prefix = PrefixChar+ >_prefix %prefix; - - Name = Prefix ":" TagName; - - NameAttr = NameChar+ >_nameattr %nameattr; - Q1Char = ( "\\\'" | [^'] ) ; - Q1Attr = Q1Char* >_valattr %valattr; - Q2Char = ( "\\\"" | [^"] ) ; - Q2Attr = Q2Char* >_valattr %valattr; - - Attr = NameAttr space* "=" space* ('"' Q2Attr '"' | "'" Q1Attr "'") space* >_attr %attr; - Attrs = (space+ Attr* | empty); - - CloseTrailer = "/>" %selftag; - OpenTrailer = ">" %opentag; - - Trailer = (OpenTrailer | CloseTrailer); - - OpenOrSelfTag = Name Attrs? Trailer; - CloseTag = "/" Name space* ">" %closetag; - - SomeTag = '<' (OpenOrSelfTag | CloseTag); - - main := |* - SomeTag => { - tag = {:prefix=>@prefix, :name=>@starttag, :flavor => @flavor, :attrs => @attrs} - @prefix = nil - @name = nil - @flavor = :tasteless - @attrs = {} - @nodes << tag << '' - fbreak; - }; - any => { - @nodes.last << data[p] - @tagstart = p - }; - *|; -}%% - -module Radius - class Scanner - def operate(prefix, data) - data = Radius::OrdString.new data - buf = "" - csel = "" - @prematch = '' - @starttag = nil - @attrs = {} - @flavor = :tasteless - @cursor = 0 - @tagstart = 0 - @nodes = [''] - remainder = data.dup - - until remainder.length == 0 - p = perform_parse(prefix, remainder) - remainder = remainder[p..-1] - end - - return @nodes - end - - private - def perform_parse(prefix, data) - stack = [] - p = 0 - ts = 0 - te = 0 - act = 0 - eof = data.length - - @prefix = prefix - %% write data; - %% write init; - %% write exec; - return p - end - end -end diff --git a/vendor/plugins/radius/lib/radius/parser/squiggle_scanner.rb b/vendor/plugins/radius/lib/radius/parser/squiggle_scanner.rb deleted file mode 100644 index ea04faa2..00000000 --- a/vendor/plugins/radius/lib/radius/parser/squiggle_scanner.rb +++ /dev/null @@ -1,1238 +0,0 @@ -# coding: utf-8 - -# line 1 "squiggle_scanner.rl" - -# line 85 "squiggle_scanner.rl" - - -module Radius - class SquiggleScanner - def operate(prefix, data) - data = Radius::OrdString.new data - buf = "" - csel = "" - @prematch = '' - @starttag = nil - @attrs = {} - @flavor = :tasteless - @cursor = 0 - @tagstart = 0 - @nodes = [''] - remainder = data.dup - - until remainder.length == 0 - p = perform_parse(prefix, remainder) - remainder = remainder[p..-1] - end - - return @nodes - end - - private - def perform_parse(prefix, data) - stack = [] - p = 0 - ts = 0 - te = 0 - act = 0 - eof = data.length - - @prefix = prefix - -# line 42 "squiggle_scanner.rb" -class << self - attr_accessor :_parser_trans_keys - private :_parser_trans_keys, :_parser_trans_keys= -end -self._parser_trans_keys = [ - 0, 0, 9, 122, 9, 125, - 9, 125, 9, 122, 9, - 61, 9, 39, 34, 92, - 34, 92, 9, 125, 9, 125, - 125, 125, 34, 92, 9, - 125, 9, 125, 9, 122, - 9, 92, 9, 92, 9, 125, - 34, 125, 34, 92, 34, - 92, 9, 125, 39, 92, - 39, 92, 9, 125, 9, 122, - 9, 92, 9, 92, 34, - 92, 34, 92, 9, 125, - 9, 125, 9, 122, 9, 92, - 9, 92, 9, 125, 34, - 125, 9, 125, 9, 125, - 39, 125, 39, 92, 45, 122, - 9, 125, 9, 125, 0, - 0, 123, 123, 9, 122, - 0, 0, 0, 0, 34, 92, - 34, 92, 34, 92, 34, - 92, 39, 92, 39, 92, - 0, 0, 0 -] - -class << self - attr_accessor :_parser_key_spans - private :_parser_key_spans, :_parser_key_spans= -end -self._parser_key_spans = [ - 0, 114, 117, 117, 114, 53, 31, 59, - 59, 117, 117, 1, 59, 117, 117, 114, - 84, 84, 117, 92, 59, 59, 117, 54, - 54, 117, 114, 84, 84, 59, 59, 117, - 117, 114, 84, 84, 117, 92, 117, 117, - 87, 54, 78, 117, 117, 0, 1, 114, - 0, 0, 59, 59, 59, 59, 54, 54, - 0 -] - -class << self - attr_accessor :_parser_index_offsets - private :_parser_index_offsets, :_parser_index_offsets= -end -self._parser_index_offsets = [ - 0, 0, 115, 233, 351, 466, 520, 552, - 612, 672, 790, 908, 910, 970, 1088, 1206, - 1321, 1406, 1491, 1609, 1702, 1762, 1822, 1940, - 1995, 2050, 2168, 2283, 2368, 2453, 2513, 2573, - 2691, 2809, 2924, 3009, 3094, 3212, 3305, 3423, - 3541, 3629, 3684, 3763, 3881, 3999, 4000, 4002, - 4117, 4118, 4119, 4179, 4239, 4299, 4359, 4414, - 4469 -] - -class << self - attr_accessor :_parser_indicies - private :_parser_indicies, :_parser_indicies= -end -self._parser_indicies = [ - 1, 1, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 2, 3, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 0, 0, 0, 0, 2, 0, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 0, 0, 0, 0, 2, 0, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 0, 4, 4, 4, 4, 4, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 5, - 5, 6, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 0, 0, 0, - 0, 5, 0, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 0, 0, 0, - 0, 5, 0, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 0, 0, 7, - 0, 8, 8, 8, 8, 8, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 8, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 9, 9, 10, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 9, - 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 0, 0, 9, - 0, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 0, 0, 11, 0, 13, - 13, 13, 13, 13, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 13, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 14, 14, 12, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 12, 12, 15, 12, 14, 12, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 12, 12, 12, 12, 14, 12, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, - 14, 12, 16, 16, 16, 16, 16, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 16, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 17, 12, - 17, 17, 17, 17, 17, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 17, - 12, 18, 12, 12, 12, 12, 19, 12, - 21, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 22, 20, 24, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 25, 23, - 26, 26, 26, 26, 26, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 26, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 27, 27, 28, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 12, 12, 12, 12, 27, 12, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 12, 12, 12, 12, 27, 12, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 27, 27, 27, 27, 27, 27, - 27, 27, 12, 12, 29, 12, 30, 30, - 30, 30, 30, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 30, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 31, 31, 32, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 12, 12, 12, 12, 31, 12, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 12, 12, 12, 12, 31, 12, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, - 12, 12, 33, 12, 34, 12, 35, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 25, 23, 36, 36, 36, 36, 36, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 36, 23, 24, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 37, 37, - 38, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 23, 23, 23, 23, - 37, 23, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 23, 25, 23, 23, - 37, 23, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 23, 23, 39, 23, - 40, 40, 40, 40, 40, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 40, - 23, 24, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 41, 41, 42, 41, - 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 23, 23, 23, 23, 41, 23, - 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 23, 25, 23, 23, 41, 23, - 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 23, 23, 43, 23, 44, 44, - 44, 44, 44, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 44, 23, 24, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 45, 45, 23, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 23, 23, 46, 23, 45, 23, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 23, 25, 23, 23, 45, 23, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, - 23, 47, 47, 47, 47, 47, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 47, 23, 24, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 48, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 25, 23, 48, 48, - 48, 48, 48, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 48, 23, 49, - 23, 23, 23, 23, 50, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 25, 23, 51, 51, 51, 51, 51, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 51, 20, 21, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 52, - 52, 53, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 20, 20, 20, - 20, 52, 20, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 20, 22, 20, - 20, 52, 20, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 20, 20, 54, - 20, 24, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 25, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 55, 23, 57, 56, - 56, 56, 56, 58, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 59, 56, 61, 60, 60, 60, 60, 35, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 62, 60, 64, 64, - 64, 64, 64, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 64, 63, 63, - 63, 63, 63, 63, 24, 63, 63, 63, - 63, 63, 65, 65, 66, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, - 63, 63, 63, 63, 65, 63, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, - 63, 67, 63, 63, 65, 63, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, - 65, 65, 65, 65, 65, 65, 65, 65, - 63, 63, 68, 63, 24, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 67, 63, 61, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 67, 63, 69, 69, 69, 69, 69, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 69, 63, 63, 63, 63, 63, 63, - 24, 63, 63, 63, 63, 63, 70, 70, - 71, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 63, 63, 63, 63, - 70, 63, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 63, 67, 63, 63, - 70, 63, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 63, 63, 72, 63, - 73, 73, 73, 73, 73, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 73, - 63, 63, 63, 63, 63, 63, 24, 63, - 63, 63, 63, 63, 74, 74, 63, 74, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 74, 63, 63, 75, 63, 74, 63, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 74, 63, 67, 63, 63, 74, 63, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 74, 74, 74, 74, 74, 74, 74, - 74, 74, 63, 76, 76, 76, 76, 76, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 76, 63, 63, 63, 63, 63, - 63, 24, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 77, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 67, 63, - 77, 77, 77, 77, 77, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 77, - 63, 78, 63, 63, 63, 63, 79, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 67, 63, 80, 56, 56, - 56, 56, 58, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 59, - 56, 81, 60, 60, 60, 60, 81, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 62, 60, 82, 82, 82, - 82, 82, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 82, 60, 61, 60, - 60, 60, 60, 35, 60, 60, 60, 60, - 60, 83, 83, 84, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 60, - 60, 60, 60, 83, 60, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 60, - 62, 60, 60, 83, 60, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 60, - 60, 85, 60, 86, 86, 86, 86, 86, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 86, 60, 61, 60, 60, 60, - 60, 35, 60, 60, 60, 60, 60, 87, - 87, 88, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 60, 60, 60, - 60, 87, 60, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 60, 62, 60, - 60, 87, 60, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 60, 60, 89, - 60, 90, 90, 90, 90, 90, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 90, 60, 61, 60, 60, 60, 60, 35, - 60, 60, 60, 60, 60, 91, 91, 60, - 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 60, 60, 92, 60, 91, - 60, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 60, 62, 60, 60, 91, - 60, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 60, 93, 93, 93, 93, - 93, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 93, 60, 61, 60, 60, - 60, 60, 35, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 94, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 62, - 60, 94, 94, 94, 94, 94, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 94, 60, 95, 60, 60, 60, 60, 96, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 62, 60, 97, 97, - 97, 97, 97, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 97, 56, 80, - 56, 56, 56, 56, 58, 56, 56, 56, - 56, 56, 98, 98, 99, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 56, 56, 56, 56, 98, 56, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 56, 59, 56, 56, 98, 56, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 56, 56, 100, 56, 61, 60, 60, 60, - 60, 35, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 62, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 101, - 60, 97, 97, 97, 97, 97, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, - 97, 56, 57, 56, 56, 56, 56, 58, - 56, 56, 56, 56, 56, 98, 98, 99, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 56, 56, 56, 56, 98, - 56, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 56, 59, 56, 56, 98, - 56, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, - 98, 98, 98, 56, 56, 100, 56, 103, - 103, 103, 103, 103, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 103, 102, - 102, 102, 102, 102, 102, 21, 102, 102, - 102, 102, 102, 104, 104, 105, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, - 104, 102, 102, 102, 102, 104, 102, 104, - 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, - 104, 102, 106, 102, 102, 104, 102, 104, - 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 104, 104, 104, 104, 104, - 104, 102, 102, 107, 102, 24, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 67, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 108, 63, 21, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 102, 102, 102, 102, 102, 102, - 102, 102, 106, 102, 109, 109, 0, 109, - 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 0, 0, 0, 0, 109, 0, - 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 0, 0, 0, 0, 109, 0, - 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 0, 110, 110, 110, 110, 110, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 110, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 111, - 111, 0, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 0, 0, 0, - 0, 111, 0, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 0, 0, 0, - 0, 111, 0, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 0, 0, 112, - 0, 113, 113, 113, 113, 113, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 113, 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, 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, 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, 114, 0, 115, - 117, 116, 1, 1, 1, 1, 1, 118, - 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 118, 118, - 118, 1, 118, 118, 118, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 2, 2, - 3, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 118, 118, 118, 118, - 2, 118, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 118, 118, 118, 118, - 2, 118, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 118, 119, 120, 24, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 25, 23, 24, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 25, 23, 61, - 60, 60, 60, 60, 35, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 62, 60, 61, 60, 60, 60, 60, - 35, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 62, 60, 24, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 67, 63, 24, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 67, 63, 121, 0 -] - -class << self - attr_accessor :_parser_trans_targs - private :_parser_trans_targs, :_parser_trans_targs= -end -self._parser_trans_targs = [ - 46, 1, 2, 42, 3, 2, 11, 49, - 3, 4, 11, 49, 46, 5, 4, 6, - 5, 6, 7, 41, 8, 9, 12, 8, - 9, 12, 10, 4, 11, 49, 10, 4, - 11, 49, 48, 13, 14, 15, 19, 51, - 14, 15, 19, 51, 16, 15, 17, 16, - 17, 18, 20, 14, 15, 19, 51, 50, - 21, 22, 13, 30, 21, 22, 30, 23, - 25, 26, 40, 24, 55, 25, 26, 40, - 55, 27, 26, 28, 27, 28, 29, 39, - 22, 31, 32, 33, 37, 53, 32, 33, - 37, 53, 34, 33, 35, 34, 35, 36, - 38, 32, 33, 37, 53, 52, 23, 25, - 26, 40, 24, 55, 54, 43, 44, 43, - 56, 44, 56, 0, 46, 47, 46, 46, - 46, 46 -] - -class << self - attr_accessor :_parser_trans_actions - private :_parser_trans_actions, :_parser_trans_actions= -end -self._parser_trans_actions = [ - 1, 0, 2, 0, 3, 0, 3, 3, - 0, 4, 0, 0, 5, 6, 0, 6, - 0, 0, 0, 0, 7, 8, 7, 0, - 9, 0, 10, 11, 12, 12, 0, 13, - 14, 14, 0, 9, 10, 11, 12, 15, - 0, 13, 14, 16, 6, 0, 6, 0, - 0, 9, 0, 17, 18, 19, 20, 21, - 7, 22, 8, 7, 0, 9, 0, 0, - 10, 11, 12, 0, 15, 0, 13, 14, - 16, 6, 0, 6, 0, 0, 0, 9, - 8, 9, 10, 11, 12, 15, 0, 13, - 14, 16, 6, 0, 6, 0, 0, 9, - 9, 17, 18, 19, 20, 21, 7, 17, - 18, 19, 7, 20, 21, 2, 3, 0, - 3, 0, 0, 0, 25, 26, 27, 28, - 29, 30 -] - -class << self - attr_accessor :_parser_to_state_actions - private :_parser_to_state_actions, :_parser_to_state_actions= -end -self._parser_to_state_actions = [ - 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, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 23, 23, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0 -] - -class << self - attr_accessor :_parser_from_state_actions - private :_parser_from_state_actions, :_parser_from_state_actions= -end -self._parser_from_state_actions = [ - 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, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 24, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0 -] - -class << self - attr_accessor :_parser_eof_trans - private :_parser_eof_trans, :_parser_eof_trans= -end -self._parser_eof_trans = [ - 0, 1, 1, 1, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 1, 1, 1, 0, 0, 119, - 120, 121, 120, 121, 120, 121, 120, 121, - 122 -] - -class << self - attr_accessor :parser_start -end -self.parser_start = 46; -class << self - attr_accessor :parser_first_final -end -self.parser_first_final = 46; -class << self - attr_accessor :parser_error -end -self.parser_error = 0; - -class << self - attr_accessor :parser_en_Closeout -end -self.parser_en_Closeout = 45; -class << self - attr_accessor :parser_en_main -end -self.parser_en_main = 46; - - -# line 121 "squiggle_scanner.rl" - -# line 784 "squiggle_scanner.rb" -begin - p ||= 0 - pe ||= data.length - cs = parser_start - ts = nil - te = nil - act = 0 -end - -# line 122 "squiggle_scanner.rl" - -# line 796 "squiggle_scanner.rb" -begin - testEof = false - _slen, _trans, _keys, _inds, _acts, _nacts = nil - _goto_level = 0 - _resume = 10 - _eof_trans = 15 - _again = 20 - _test_eof = 30 - _out = 40 - while true - if _goto_level <= 0 - if p == pe - _goto_level = _test_eof - next - end - if cs == 0 - _goto_level = _out - next - end - end - if _goto_level <= _resume - case _parser_from_state_actions[cs] - when 24 then -# line 1 "squiggle_scanner.rl" - begin -ts = p - end -# line 1 "squiggle_scanner.rl" -# line 825 "squiggle_scanner.rb" - end - _keys = cs << 1 - _inds = _parser_index_offsets[cs] - _slen = _parser_key_spans[cs] - _trans = if ( _slen > 0 && - _parser_trans_keys[_keys] <= data[p] && - data[p] <= _parser_trans_keys[_keys + 1] - ) then - _parser_indicies[ _inds + data[p] - _parser_trans_keys[_keys] ] - else - _parser_indicies[ _inds + _slen ] - end - end - if _goto_level <= _eof_trans - cs = _parser_trans_targs[_trans] - if _parser_trans_actions[_trans] != 0 - case _parser_trans_actions[_trans] - when 2 then -# line 12 "squiggle_scanner.rl" - begin - mark_stg = p end -# line 12 "squiggle_scanner.rl" - when 3 then -# line 13 "squiggle_scanner.rl" - begin - @starttag = data[mark_stg..p-1] end -# line 13 "squiggle_scanner.rl" - when 10 then -# line 14 "squiggle_scanner.rl" - begin - mark_attr = p end -# line 14 "squiggle_scanner.rl" - when 14 then -# line 15 "squiggle_scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 15 "squiggle_scanner.rl" - when 4 then -# line 24 "squiggle_scanner.rl" - begin - mark_nat = p end -# line 24 "squiggle_scanner.rl" - when 6 then -# line 25 "squiggle_scanner.rl" - begin - @nat = data[mark_nat..p-1] end -# line 25 "squiggle_scanner.rl" - when 7 then -# line 26 "squiggle_scanner.rl" - begin - mark_vat = p end -# line 26 "squiggle_scanner.rl" - when 9 then -# line 27 "squiggle_scanner.rl" - begin - @vat = data[mark_vat..p-1] end -# line 27 "squiggle_scanner.rl" - when 25 then -# line 80 "squiggle_scanner.rl" - begin -te = p+1 - begin - @nodes.last << data[p] - @tagstart = p - end - end -# line 80 "squiggle_scanner.rl" - when 27 then -# line 80 "squiggle_scanner.rl" - begin -te = p -p = p - 1; begin - @nodes.last << data[p] - @tagstart = p - end - end -# line 80 "squiggle_scanner.rl" - when 1 then -# line 80 "squiggle_scanner.rl" - begin - begin p = ((te))-1; end - begin - @nodes.last << data[p] - @tagstart = p - end - end -# line 80 "squiggle_scanner.rl" - when 5 then -# line 1 "squiggle_scanner.rl" - begin - case act - when 1 then - begin begin p = ((te))-1; end - - tag = {:prefix=>@prefix, :name=>@starttag, :flavor => @flavor, :attrs => @attrs} - @prefix = nil - @name = nil - @flavor = :tasteless - @attrs = {} - @nodes << tag << '' - begin - p += 1 - _goto_level = _out - next - end - - end - when 2 then - begin begin p = ((te))-1; end - - @nodes.last << data[p] - @tagstart = p - end -end - end -# line 1 "squiggle_scanner.rl" - when 12 then -# line 14 "squiggle_scanner.rl" - begin - mark_attr = p end -# line 14 "squiggle_scanner.rl" -# line 15 "squiggle_scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 15 "squiggle_scanner.rl" - when 13 then -# line 15 "squiggle_scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 15 "squiggle_scanner.rl" -# line 24 "squiggle_scanner.rl" - begin - mark_nat = p end -# line 24 "squiggle_scanner.rl" - when 17 then -# line 26 "squiggle_scanner.rl" - begin - mark_vat = p end -# line 26 "squiggle_scanner.rl" -# line 14 "squiggle_scanner.rl" - begin - mark_attr = p end -# line 14 "squiggle_scanner.rl" - when 8 then -# line 26 "squiggle_scanner.rl" - begin - mark_vat = p end -# line 26 "squiggle_scanner.rl" -# line 27 "squiggle_scanner.rl" - begin - @vat = data[mark_vat..p-1] end -# line 27 "squiggle_scanner.rl" - when 22 then -# line 27 "squiggle_scanner.rl" - begin - @vat = data[mark_vat..p-1] end -# line 27 "squiggle_scanner.rl" -# line 26 "squiggle_scanner.rl" - begin - mark_vat = p end -# line 26 "squiggle_scanner.rl" - when 29 then -# line 29 "squiggle_scanner.rl" - begin - @flavor = :open end -# line 29 "squiggle_scanner.rl" -# line 71 "squiggle_scanner.rl" - begin -te = p -p = p - 1; begin - tag = {:prefix=>@prefix, :name=>@starttag, :flavor => @flavor, :attrs => @attrs} - @prefix = nil - @name = nil - @flavor = :tasteless - @attrs = {} - @nodes << tag << '' - begin - p += 1 - _goto_level = _out - next - end - - end - end -# line 71 "squiggle_scanner.rl" - when 28 then -# line 30 "squiggle_scanner.rl" - begin - @flavor = :self end -# line 30 "squiggle_scanner.rl" -# line 71 "squiggle_scanner.rl" - begin -te = p -p = p - 1; begin - tag = {:prefix=>@prefix, :name=>@starttag, :flavor => @flavor, :attrs => @attrs} - @prefix = nil - @name = nil - @flavor = :tasteless - @attrs = {} - @nodes << tag << '' - begin - p += 1 - _goto_level = _out - next - end - - end - end -# line 71 "squiggle_scanner.rl" - when 30 then -# line 31 "squiggle_scanner.rl" - begin - @flavor = :close end -# line 31 "squiggle_scanner.rl" -# line 71 "squiggle_scanner.rl" - begin -te = p -p = p - 1; begin - tag = {:prefix=>@prefix, :name=>@starttag, :flavor => @flavor, :attrs => @attrs} - @prefix = nil - @name = nil - @flavor = :tasteless - @attrs = {} - @nodes << tag << '' - begin - p += 1 - _goto_level = _out - next - end - - end - end -# line 71 "squiggle_scanner.rl" - when 21 then -# line 1 "squiggle_scanner.rl" - begin -te = p+1 - end -# line 1 "squiggle_scanner.rl" -# line 71 "squiggle_scanner.rl" - begin -act = 1; end -# line 71 "squiggle_scanner.rl" - when 26 then -# line 1 "squiggle_scanner.rl" - begin -te = p+1 - end -# line 1 "squiggle_scanner.rl" -# line 80 "squiggle_scanner.rl" - begin -act = 2; end -# line 80 "squiggle_scanner.rl" - when 11 then -# line 14 "squiggle_scanner.rl" - begin - mark_attr = p end -# line 14 "squiggle_scanner.rl" -# line 15 "squiggle_scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 15 "squiggle_scanner.rl" -# line 24 "squiggle_scanner.rl" - begin - mark_nat = p end -# line 24 "squiggle_scanner.rl" - when 19 then -# line 26 "squiggle_scanner.rl" - begin - mark_vat = p end -# line 26 "squiggle_scanner.rl" -# line 14 "squiggle_scanner.rl" - begin - mark_attr = p end -# line 14 "squiggle_scanner.rl" -# line 15 "squiggle_scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 15 "squiggle_scanner.rl" - when 16 then -# line 1 "squiggle_scanner.rl" - begin -te = p+1 - end -# line 1 "squiggle_scanner.rl" -# line 15 "squiggle_scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 15 "squiggle_scanner.rl" -# line 71 "squiggle_scanner.rl" - begin -act = 1; end -# line 71 "squiggle_scanner.rl" - when 18 then -# line 26 "squiggle_scanner.rl" - begin - mark_vat = p end -# line 26 "squiggle_scanner.rl" -# line 14 "squiggle_scanner.rl" - begin - mark_attr = p end -# line 14 "squiggle_scanner.rl" -# line 15 "squiggle_scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 15 "squiggle_scanner.rl" -# line 24 "squiggle_scanner.rl" - begin - mark_nat = p end -# line 24 "squiggle_scanner.rl" - when 15 then -# line 1 "squiggle_scanner.rl" - begin -te = p+1 - end -# line 1 "squiggle_scanner.rl" -# line 14 "squiggle_scanner.rl" - begin - mark_attr = p end -# line 14 "squiggle_scanner.rl" -# line 15 "squiggle_scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 15 "squiggle_scanner.rl" -# line 71 "squiggle_scanner.rl" - begin -act = 1; end -# line 71 "squiggle_scanner.rl" - when 20 then -# line 1 "squiggle_scanner.rl" - begin -te = p+1 - end -# line 1 "squiggle_scanner.rl" -# line 26 "squiggle_scanner.rl" - begin - mark_vat = p end -# line 26 "squiggle_scanner.rl" -# line 14 "squiggle_scanner.rl" - begin - mark_attr = p end -# line 14 "squiggle_scanner.rl" -# line 15 "squiggle_scanner.rl" - begin - - @attrs[@nat] = @vat - end -# line 15 "squiggle_scanner.rl" -# line 71 "squiggle_scanner.rl" - begin -act = 1; end -# line 71 "squiggle_scanner.rl" -# line 1194 "squiggle_scanner.rb" - end - end - end - if _goto_level <= _again - case _parser_to_state_actions[cs] - when 23 then -# line 1 "squiggle_scanner.rl" - begin -ts = nil; end -# line 1 "squiggle_scanner.rl" -# line 1205 "squiggle_scanner.rb" - end - - if cs == 0 - _goto_level = _out - next - end - p += 1 - if p != pe - _goto_level = _resume - next - end - end - if _goto_level <= _test_eof - if p == eof - if _parser_eof_trans[cs] > 0 - _trans = _parser_eof_trans[cs] - 1; - _goto_level = _eof_trans - next; - end - end - - end - if _goto_level <= _out - break - end -end - end - -# line 123 "squiggle_scanner.rl" - return p - end - end -end diff --git a/vendor/plugins/radius/lib/radius/parser/squiggle_scanner.rl b/vendor/plugins/radius/lib/radius/parser/squiggle_scanner.rl deleted file mode 100644 index 4ebb55c5..00000000 --- a/vendor/plugins/radius/lib/radius/parser/squiggle_scanner.rl +++ /dev/null @@ -1,126 +0,0 @@ -%%{ - machine parser; - - -# action _prefix { mark_pfx = p } -# action prefix { -# if data[mark_pfx..p-1] != @prefix -# @nodes.last << data[mark_pfx-1..p] -# fbreak; -# end -# } - action _starttag { mark_stg = p } - action starttag { @starttag = data[mark_stg..p-1] } - action _attr { mark_attr = p } - action attr { - @attrs[@nat] = @vat - } - - action prematch { - @prematch_end = p - @prematch = data[0..p] if p > 0 - } - - action _nameattr { mark_nat = p } - action nameattr { @nat = data[mark_nat..p-1] } - action _valattr { mark_vat = p } - action valattr { @vat = data[mark_vat..p-1] } - - action opentag { @flavor = :open } - action selftag { @flavor = :self } - action closetag { @flavor = :close } - - action stopparse { - @cursor = p; - fbreak; - } - - - Closeout := empty; - - # words -# PrefixChar = [\-A-Za-z0-9._?] ; - NameChar = [\-A-Za-z0-9._:?] ; - TagName = NameChar+ >_starttag %starttag; -# Prefix = PrefixChar+ >_prefix %prefix; - -# Name = Prefix ":" TagName; - - NameAttr = NameChar+ >_nameattr %nameattr; - Q1Char = ( "\\\'" | [^'] ) ; - Q1Attr = Q1Char* >_valattr %valattr; - Q2Char = ( "\\\"" | [^"] ) ; - Q2Attr = Q2Char* >_valattr %valattr; - - Attr = NameAttr space* "=" space* ('"' Q2Attr '"' | "'" Q1Attr "'") space* >_attr %attr; - Attrs = (space+ Attr* | empty); - - CloseTrailer = "/}" %selftag; - OpenTrailer = "}" %opentag; - - Trailer = (OpenTrailer | CloseTrailer); - -# OpenOrSelfTag = Name Attrs? Trailer; - OpenOrSelfTag = TagName Attrs? Trailer; -# CloseTag = "/" Name space* "}" %closetag; - CloseTag = "/" TagName space* "}" %closetag; - - SomeTag = '{' space* (OpenOrSelfTag | CloseTag); - - main := |* - SomeTag => { - tag = {:prefix=>@prefix, :name=>@starttag, :flavor => @flavor, :attrs => @attrs} - @prefix = nil - @name = nil - @flavor = :tasteless - @attrs = {} - @nodes << tag << '' - fbreak; - }; - any => { - @nodes.last << data[p] - @tagstart = p - }; - *|; -}%% - -module Radius - class SquiggleScanner - def operate(prefix, data) - data = Radius::OrdString.new data - buf = "" - csel = "" - @prematch = '' - @starttag = nil - @attrs = {} - @flavor = :tasteless - @cursor = 0 - @tagstart = 0 - @nodes = [''] - remainder = data.dup - - until remainder.length == 0 - p = perform_parse(prefix, remainder) - remainder = remainder[p..-1] - end - - return @nodes - end - - private - def perform_parse(prefix, data) - stack = [] - p = 0 - ts = 0 - te = 0 - act = 0 - eof = data.length - - @prefix = prefix - %% write data; - %% write init; - %% write exec; - return p - end - end -end diff --git a/vendor/plugins/radius/lib/radius/tag_binding.rb b/vendor/plugins/radius/lib/radius/tag_binding.rb deleted file mode 100644 index 6a27d684..00000000 --- a/vendor/plugins/radius/lib/radius/tag_binding.rb +++ /dev/null @@ -1,71 +0,0 @@ -module Radius - # - # A tag binding is passed into each tag definition and contains helper methods for working - # with tags. Use it to gain access to the attributes that were passed to the tag, to - # render the tag contents, and to do other tasks. - # - class TagBinding - # The Context that the TagBinding is associated with. Used internally. Try not to use - # this object directly. - attr_reader :context - - # The locals object for the current tag. - attr_reader :locals - - # The name of the tag (as used in a template string). - attr_reader :name - - # The attributes of the tag. Also aliased as TagBinding#attr. - attr_reader :attributes - alias :attr :attributes - - # The render block. When called expands the contents of the tag. Use TagBinding#expand - # instead. - attr_reader :block - - # Creates a new TagBinding object. - def initialize(context, locals, name, attributes, block) - @context, @locals, @name, @attributes, @block = context, locals, name, attributes, block - end - - # Evaluates the current tag and returns the rendered contents. - def expand - double? ? block.call : '' - end - - # Returns true if the current tag is a single tag. - def single? - block.nil? - end - - # Returns true if the current tag is a container tag. - def double? - not single? - end - - # The globals object from which all locals objects ultimately inherit their values. - def globals - @context.globals - end - - # Returns a list of the way tags are nested around the current tag as a string. - def nesting - @context.current_nesting - end - - # Fires off Context#tag_missing for the current tag. - def missing! - @context.tag_missing(name, attributes, &block) - end - - # Renders the tag using the current context . - def render(tag, attributes = {}, &block) - @context.render_tag(tag, attributes, &block) - end - - # Shortcut for accessing tag.attr[key] - def [](key) - attr[key] - end - end -end \ No newline at end of file diff --git a/vendor/plugins/radius/lib/radius/tag_definitions.rb b/vendor/plugins/radius/lib/radius/tag_definitions.rb deleted file mode 100644 index ca530f6d..00000000 --- a/vendor/plugins/radius/lib/radius/tag_definitions.rb +++ /dev/null @@ -1,78 +0,0 @@ -module Radius - module TagDefinitions # :nodoc: - class TagFactory # :nodoc: - def initialize(context) - @context = context - end - - def define_tag(name, options, &block) - options = prepare_options(name, options) - validate_params(name, options, &block) - construct_tag_set(name, options, &block) - expose_methods_as_tags(name, options) - end - - protected - - # Adds the tag definition to the context. Override in subclasses to add additional tags - # (child tags) when the tag is created. - def construct_tag_set(name, options, &block) - if block - @context.definitions[name.to_s] = block - else - lp = last_part(name) - @context.define_tag(name) do |tag| - if tag.single? - options[:for] - else - tag.locals.send("#{ lp }=", options[:for]) unless options[:for].nil? - tag.expand - end - end - end - end - - # Normalizes options pased to tag definition. Override in decendants to preform - # additional normalization. - def prepare_options(name, options) - options = Utility.symbolize_keys(options) - options[:expose] = expand_array_option(options[:expose]) - object = options[:for] - options[:attributes] = object.respond_to?(:attributes) unless options.has_key? :attributes - options[:expose] += object.attributes.keys if options[:attributes] - options - end - - # Validates parameters passed to tag definition. Override in decendants to add custom - # validations. - def validate_params(name, options, &block) - unless options.has_key? :for - raise ArgumentError.new("tag definition must contain a :for option or a block") unless block - raise ArgumentError.new("tag definition must contain a :for option when used with the :expose option") unless options[:expose].empty? - end - end - - # Exposes the methods of an object as child tags. - def expose_methods_as_tags(name, options) - options[:expose].each do |method| - tag_name = "#{name}:#{method}" - lp = last_part(name) - @context.define_tag(tag_name) do |tag| - object = tag.locals.send(lp) - object.send(method) - end - end - end - - protected - - def expand_array_option(value) - [*value].compact.map { |m| m.to_s.intern } - end - - def last_part(name) - name.split(':').last - end - end - end -end diff --git a/vendor/plugins/radius/lib/radius/utility.rb b/vendor/plugins/radius/lib/radius/utility.rb deleted file mode 100644 index aa10bc58..00000000 --- a/vendor/plugins/radius/lib/radius/utility.rb +++ /dev/null @@ -1,40 +0,0 @@ -module Radius - module Utility # :nodoc: - def self.symbolize_keys(hash) - new_hash = {} - hash.keys.each do |k| - new_hash[k.to_s.intern] = hash[k] - end - new_hash - end - - def self.impartial_hash_delete(hash, key) - string = key.to_s - symbol = string.intern - value1 = hash.delete(symbol) - value2 = hash.delete(string) - value1 || value2 - end - - def self.constantize(camelized_string) - raise "invalid constant name `#{camelized_string}'" unless camelized_string.split('::').all? { |part| part =~ /^[A-Za-z]+$/ } - Object.module_eval(camelized_string) - end - - def self.camelize(underscored_string) - string = '' - underscored_string.split('_').each { |part| string << part.capitalize } - string - end - - if RUBY_VERSION[0,3] == '1.8' - def self.array_to_s(c) - c.to_s - end - else - def self.array_to_s(c) - c.map{|x| x.is_a?(Array) ? array_to_s(x) : x.to_s }.join - end - end - end -end \ No newline at end of file diff --git a/vendor/plugins/radius/lib/radius/version.rb b/vendor/plugins/radius/lib/radius/version.rb deleted file mode 100644 index 77615b18..00000000 --- a/vendor/plugins/radius/lib/radius/version.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Radius #:nodoc: - def self.version - @version ||= begin - filename = File.join(File.dirname(__FILE__), '..', '..', 'VERSION') - IO.read(filename).strip - end - end -end diff --git a/vendor/plugins/radius/radius.gemspec b/vendor/plugins/radius/radius.gemspec deleted file mode 100644 index 76f64b48..00000000 --- a/vendor/plugins/radius/radius.gemspec +++ /dev/null @@ -1,94 +0,0 @@ -# Generated by jeweler -# DO NOT EDIT THIS FILE DIRECTLY -# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{radius} - s.version = "0.7.0.prerelease" - - s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version= - s.authors = ["John W. Long (me@johnwlong.com)", "David Chelimsky (dchelimsky@gmail.com)", "Bryce Kerley (bkerley@brycekerley.net)"] - s.date = %q{2010-05-24} - s.description = %q{Radius is a powerful tag-based template language for Ruby inspired by the template languages used in MovableType and TextPattern. It uses tags similar to XML, but can be used to generate any form of plain text (HTML, e-mail, etc...).} - s.email = %q{me@johnwlong.com} - s.extra_rdoc_files = [ - "CHANGELOG", - "LICENSE", - "QUICKSTART.rdoc", - "README.rdoc" - ] - s.files = [ - "CHANGELOG", - "LICENSE", - "QUICKSTART.rdoc", - "README.rdoc", - "Rakefile", - "VERSION", - "lib/radius.rb", - "lib/radius/context.rb", - "lib/radius/delegating_open_struct.rb", - "lib/radius/error.rb", - "lib/radius/parse_tag.rb", - "lib/radius/parser.rb", - "lib/radius/parser/JavaScanner$Flavor.class", - "lib/radius/parser/JavaScanner$Tag.class", - "lib/radius/parser/JavaScanner.class", - "lib/radius/parser/JavaScanner.java", - "lib/radius/parser/JavaScanner.rl", - "lib/radius/parser/java_scanner.jar", - "lib/radius/parser/squiggle_scanner.rb", - "lib/radius/parser/squiggle_scanner.rl", - "lib/radius/parser/scan.rb", - "lib/radius/parser/scan.rl", - "lib/radius/parser/scan_19.rb", - "lib/radius/tag_binding.rb", - "lib/radius/tag_definitions.rb", - "lib/radius/utility.rb", - "lib/radius/version.rb", - "tasks/jeweler.rake", - "tasks/rdoc.rake", - "tasks/rubinius.rake", - "tasks/scan.rake", - "tasks/test.rake", - "test/benchmarks.rb", - "test/context_test.rb", - "test/multithreaded_test.rb", - "test/ord_string_test.rb", - "test/parser_test.rb", - "test/quickstart_test.rb", - "test/squiggle_test.rb", - "test/test_helper.rb", - "test/utility_test.rb" - ] - s.homepage = %q{http://github.com/jlong/radius} - s.rdoc_options = ["--charset=UTF-8"] - s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.7} - s.summary = %q{A tag-based templating language for Ruby.} - s.test_files = [ - "test/context_test.rb", - "test/ord_string_test.rb", - "test/parser_test.rb", - "test/quickstart_test.rb", - "test/test_helper.rb", - "test/multithreaded_test.rb", - "test/squiggle_test.rb", - "test/utility_test.rb", - "test/benchmarks.rb" - ] - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 3 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - s.add_development_dependency(%q, [">= 0"]) - else - s.add_dependency(%q, [">= 0"]) - end - else - s.add_dependency(%q, [">= 0"]) - end -end - diff --git a/vendor/plugins/radius/tasks/jeweler.rake b/vendor/plugins/radius/tasks/jeweler.rake deleted file mode 100644 index 36b63355..00000000 --- a/vendor/plugins/radius/tasks/jeweler.rake +++ /dev/null @@ -1,22 +0,0 @@ -begin - require 'jeweler' - Jeweler::Tasks.new do |gem| - gem.name = "radius" - gem.summary = "A tag-based templating language for Ruby." - gem.description = "Radius is a powerful tag-based template language for Ruby inspired by the template languages used in MovableType and TextPattern. It uses tags similar to XML, but can be used to generate any form of plain text (HTML, e-mail, etc...)." - gem.email = "me@johnwlong.com" - gem.homepage = "http://github.com/jlong/radius" - gem.authors = [ - "John W. Long (me@johnwlong.com)", - "David Chelimsky (dchelimsky@gmail.com)", - "Bryce Kerley (bkerley@brycekerley.net)" - ] - gem.files = FileList["[A-Z]*", "{bin,lib,tasks,test}/**/*"].exclude("tmp") - gem.extra_rdoc_files = ['README.rdoc', 'QUICKSTART.rdoc', 'LICENSE', 'CHANGELOG'] - gem.add_development_dependency('RedCloth') - # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings - end - Jeweler::GemcutterTasks.new -rescue LoadError - puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler" -end diff --git a/vendor/plugins/radius/tasks/rdoc.rake b/vendor/plugins/radius/tasks/rdoc.rake deleted file mode 100644 index 8e41484c..00000000 --- a/vendor/plugins/radius/tasks/rdoc.rake +++ /dev/null @@ -1,13 +0,0 @@ -require 'rake/rdoctask' -Rake::RDocTask.new do |rdoc| - version = File.exist?('VERSION') ? File.read('VERSION') : "" - - rdoc.rdoc_dir = 'rdoc' - rdoc.title = "Radius #{version}" - rdoc.main = "README.rdoc" - rdoc.rdoc_files.include('*.rdoc') - rdoc.rdoc_files.include('LICENSE') - rdoc.rdoc_files.include('CHANGELOG') - rdoc.rdoc_files.include('QUICKSTART.rdoc') - rdoc.rdoc_files.include('lib/**/*.rb') -end \ No newline at end of file diff --git a/vendor/plugins/radius/tasks/rubinius.rake b/vendor/plugins/radius/tasks/rubinius.rake deleted file mode 100644 index 14103512..00000000 --- a/vendor/plugins/radius/tasks/rubinius.rake +++ /dev/null @@ -1,4 +0,0 @@ -desc "remove Rubinius rbc files" -task "rubinius:clean" do - (Dir['**/*.rbc']).each { |f| rm f } -end \ No newline at end of file diff --git a/vendor/plugins/radius/tasks/scan.rake b/vendor/plugins/radius/tasks/scan.rake deleted file mode 100644 index 6c194c28..00000000 --- a/vendor/plugins/radius/tasks/scan.rake +++ /dev/null @@ -1,79 +0,0 @@ -namespace :scan do - desc 'Generate the parsers' - task 'build' => [ - 'lib/radius/parser/scanner.rb', - 'lib/radius/parser/squiggle_scanner.rb', - 'lib/radius/parser/java_scanner.jar' - ] - - desc 'Generate a PDF state graph from the parsers' - task 'graph' => ['doc/scanner.pdf', 'doc/squiggle_scanner.pdf'] - - desc 'turn the scanner.rl file into a ruby file' - file 'lib/radius/parser/scanner.rb' => 'lib/radius/parser/scanner.rl' do |t| - cd 'lib/radius/parser' do - sh "ragel -R -F1 scanner.rl" - end - end - - desc 'turn the squiggle_scanner.rl file into a ruby file' - file 'lib/radius/parser/squiggle_scanner.rb' => - ['lib/radius/parser/squiggle_scanner.rl'] \ - do |t| - cd 'lib/radius/parser' do - sh "ragel -R -F1 squiggle_scanner.rl" - end - end - - desc 'package JavaScanner into a jar file' - file 'lib/radius/parser/java_scanner.jar' => 'lib/radius/parser/JavaScanner.class' do - cd 'lib' do - sh "jar -cf radius/parser/java_scanner.jar radius/parser/*.class" - end - end - - desc 'turn the JavaScanner.java file into a java class file' - file 'lib/radius/parser/JavaScanner.class' => 'lib/radius/parser/JavaScanner.java' do |t| - cd 'lib' do - jruby_path = ENV['JRUBY_HOME'] || '/usr/local/jruby/current' - sh "javac -cp #{jruby_path}/lib/jruby.jar radius/parser/JavaScanner.java" - end - end - - desc 'turn the JavaScanner.rl file into a java source file' - file 'lib/radius/parser/JavaScanner.java' => 'lib/radius/parser/JavaScanner.rl' do |t| - cd 'lib/radius/parser' do - sh "ragel -J -F1 JavaScanner.rl" - end - end - - desc 'pdf of the ragel scanner' - file 'doc/scanner.pdf' => 'lib/radius/parser/scanner.dot' do |t| - cd 'lib/radius/parser' do - sh "dot -Tpdf -o ../../../doc/scanner.pdf scanner.dot" - end - end - - desc 'pdf of the ragel squiggle scanner' - file 'doc/squiggle_scanner.pdf' => - ['lib/radius/parser/squiggle_scanner.dot'] \ - do |t| - cd 'lib/radius/parser' do - sh "dot -Tpdf -o ../../../doc/squiggle_scanner.pdf squiggle_scanner.dot" - end - end - - file 'lib/radius/parser/scanner.dot' => 'lib/radius/parser/scanner.rl' do |t| - cd 'lib/radius/parser' do - sh "ragel -Vp scanner.rl > scanner.dot" - end - end - - file 'lib/radius/parser/squiggle_scanner.dot' => - ['lib/radius/parser/squiggle_scanner.rl'] \ - do |t| - cd 'lib/radius/parser' do - sh "ragel -Vp squiggle_scanner.rl > squiggle_scanner.dot" - end - end -end diff --git a/vendor/plugins/radius/tasks/test.rake b/vendor/plugins/radius/tasks/test.rake deleted file mode 100644 index 5d20c325..00000000 --- a/vendor/plugins/radius/tasks/test.rake +++ /dev/null @@ -1,7 +0,0 @@ -require 'rake/testtask' - -Rake::TestTask.new do |t| - t.libs << "lib" << "test" - t.test_files = FileList['test/*_test.rb'] - t.verbose = true -end \ No newline at end of file diff --git a/vendor/plugins/radius/test/benchmarks.rb b/vendor/plugins/radius/test/benchmarks.rb deleted file mode 100644 index 40d5b179..00000000 --- a/vendor/plugins/radius/test/benchmarks.rb +++ /dev/null @@ -1,35 +0,0 @@ -$: << File.join(File.dirname(__FILE__), '..', 'lib') -require 'radius' - -if RUBY_PLATFORM == 'java' - require 'java' - require 'radius/parser/jscanner' -end - -require 'benchmark' - -document = < - Middle Top - - Middle Bottom - -After it all -EOF - -amount = 1000 - -Benchmark.bmbm do |bm| - bm.report('vanilla') do - scanner = Radius::Scanner.new(:scanner => Radius::Scanner) - amount.times { scanner.operate('r', document) } - end - - if RUBY_PLATFORM == 'java' - bm.report('JavaScanner') do - scanner = Radius::JavaScanner.new(JRuby.runtime) - amount.times { scanner.operate('r', document) } - end - end -end diff --git a/vendor/plugins/radius/test/context_test.rb b/vendor/plugins/radius/test/context_test.rb deleted file mode 100644 index 79b911b9..00000000 --- a/vendor/plugins/radius/test/context_test.rb +++ /dev/null @@ -1,61 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/test_helper') - -class RadiusContextTest < Test::Unit::TestCase - include RadiusTestHelper - - def setup - @context = new_context - end - - def test_initialize - @context = Radius::Context.new - end - - def test_initialize_with_block - @context = Radius::Context.new do |c| - assert_kind_of Radius::Context, c - c.define_tag('test') { 'just a test' } - end - assert_not_equal Hash.new, @context.definitions - end - - def test_with - got = @context.with do |c| - assert_equal @context, c - end - assert_equal @context, got - end - - def test_render_tag - define_global_tag "hello" do |tag| - "Hello #{tag.attr['name'] || 'World'}!" - end - assert_render_tag_output 'Hello World!', 'hello' - assert_render_tag_output 'Hello John!', 'hello', 'name' => 'John' - end - - def test_render_tag__undefined_tag - e = assert_raises(Radius::UndefinedTagError) { @context.render_tag('undefined_tag') } - assert_equal "undefined tag `undefined_tag'", e.message - end - - def test_tag_missing - class << @context - def tag_missing(tag, attr, &block) - "undefined tag `#{tag}' with attributes #{attr.inspect}" - end - end - - text = '' - expected = %{undefined tag `undefined_tag' with attributes {"cool"=>"beans"}} - assert_nothing_raised { text = @context.render_tag('undefined_tag', 'cool' => 'beans') } - assert_equal expected, text - end - - private - - def assert_render_tag_output(output, *render_tag_params) - assert_equal output, @context.render_tag(*render_tag_params) - end - -end diff --git a/vendor/plugins/radius/test/multithreaded_test.rb b/vendor/plugins/radius/test/multithreaded_test.rb deleted file mode 100644 index 8ee9739b..00000000 --- a/vendor/plugins/radius/test/multithreaded_test.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'test/unit' -require 'radius' - -class MultithreadTest < Test::Unit::TestCase - - def setup - Thread.abort_on_exception - @context = Radius::Context.new do |c| - c.define_tag('thread') do |tag| - "#{tag.locals.thread_id} / #{tag.globals.object_id}" - end - end - end - - if RUBY_PLATFORM == 'java' - require 'java' - # call once before the thread to keep from using hidden require in a thread - Radius::Parser.new - def test_runs_multithreaded - lock = java.lang.String.new("lock") - threads = [] - 1000.times do |t| - thread = Thread.new do - parser = Radius::Parser.new(@context, :tag_prefix => 'r') - parser.context.globals.thread_id = Thread.current.object_id - expected = "#{Thread.current.object_id} / "+ - "#{parser.context.globals.object_id}" - actual = parser.parse('') - assert_equal expected, actual - end - lock.synchronized do - threads << thread - end - end - lock.synchronized do - threads.each{|t| t.join } - end - end - else - def test_runs_multithreaded - threads = [] - mute = Mutex.new - 1000.times do |t| - thread = Thread.new do - parser = Radius::Parser.new(@context, :tag_prefix => 'r') - parser.context.globals.thread_id = Thread.current.object_id - expected = "#{Thread.current.object_id} / "+ - "#{parser.context.globals.object_id}" - actual = parser.parse('') - assert_equal expected, actual - end - mute.synchronize do - threads << thread - end - end - mute.synchronize do - threads.each{|t| t.join } - end - end - end - -end diff --git a/vendor/plugins/radius/test/ord_string_test.rb b/vendor/plugins/radius/test/ord_string_test.rb deleted file mode 100644 index bcb50995..00000000 --- a/vendor/plugins/radius/test/ord_string_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'test/unit' -require 'radius' - -class RadiusOrdStringTest < Test::Unit::TestCase - - def test_string_slice_integer - str = Radius::OrdString.new "abc" - assert_equal str[0], 97 - assert_equal str[1], 98 - assert_equal str[2], 99 - end - - def test_string_slice_range - str = Radius::OrdString.new "abc" - assert_equal str[0..-1], "abc" - end - -end \ No newline at end of file diff --git a/vendor/plugins/radius/test/parser_test.rb b/vendor/plugins/radius/test/parser_test.rb deleted file mode 100644 index ffb1719a..00000000 --- a/vendor/plugins/radius/test/parser_test.rb +++ /dev/null @@ -1,307 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/test_helper') - -class RadiusParserTest < Test::Unit::TestCase - include RadiusTestHelper - - def setup - @context = new_context - @parser = Radius::Parser.new(@context, :tag_prefix => 'r') - end - - def test_initialize - @parser = Radius::Parser.new - assert_kind_of Radius::Context, @parser.context - end - - def test_initialize_with_params - @parser = Radius::Parser.new(TestContext.new) - assert_kind_of TestContext, @parser.context - - @parser = Radius::Parser.new(:context => TestContext.new) - assert_kind_of TestContext, @parser.context - - @parser = Radius::Parser.new('context' => TestContext.new) - assert_kind_of TestContext, @parser.context - - @parser = Radius::Parser.new(:tag_prefix => 'r') - assert_kind_of Radius::Context, @parser.context - assert_equal 'r', @parser.tag_prefix - - @parser = Radius::Parser.new(TestContext.new, :tag_prefix => 'r') - assert_kind_of TestContext, @parser.context - assert_equal 'r', @parser.tag_prefix - end - - def test_parse_individual_tags_and_parameters - define_tag "add" do |tag| - tag.attr["param1"].to_i + tag.attr["param2"].to_i - end - assert_parse_output "<3>", %{<>} - end - - def test_parse_attributes - attributes = %{{"a"=>"1", "b"=>"2", "c"=>"3", "d"=>"'"}} - assert_parse_output attributes, %{} - assert_parse_output attributes, %{} - end - - def test_parse_attributes_with_slashes_or_angle_brackets - slash = %{{"slash"=>"/"}} - angle = %{{"angle"=>">"}} - assert_parse_output slash, %{} - assert_parse_output slash, %{} - assert_parse_output angle, %{} - end - - def test_parse_quotes - assert_parse_output "test []", %{ } - end - - def test_things_that_should_be_left_alone - [ - %{ test="2"="4" }, - %{="2" } - ].each do |middle| - assert_parsed_is_unchanged "" - assert_parsed_is_unchanged "" - end - end - - def test_tags_inside_html_tags - assert_parse_output %{
    tags in yo tags
    }, - %{
    tags in yo tags
    } - end - - def test_parse_result_is_always_a_string - define_tag("twelve") { 12 } - assert_parse_output "12", "" - end - - def test_parse_double_tags - assert_parse_output "test".reverse, "test" - assert_parse_output "tset TEST", "test test" - end - - def test_parse_tag_nesting - define_tag("parent", :for => '') - define_tag("parent:child", :for => '') - define_tag("extra", :for => '') - define_tag("nesting") { |tag| tag.nesting } - define_tag("extra:nesting") { |tag| tag.nesting.gsub(':', ' > ') } - define_tag("parent:child:nesting") { |tag| tag.nesting.gsub(':', ' * ') } - assert_parse_output "nesting", "" - assert_parse_output "parent:nesting", "" - assert_parse_output "extra > nesting", "" - assert_parse_output "parent * child * nesting", "" - assert_parse_output "parent > extra > nesting", "" - assert_parse_output "parent > child > extra > nesting", "" - assert_parse_output "parent * extra * child * nesting", "" - assert_parse_output "parent > extra > child > extra > nesting", "" - assert_parse_output "parent > extra > child > extra > nesting", "" - assert_parse_output "extra * parent * child * nesting", "" - assert_parse_output "extra > parent > nesting", "" - assert_parse_output "extra * parent * child * nesting", "" - assert_raises(Radius::UndefinedTagError) { @parser.parse("") } - end - def test_parse_tag_nesting_2 - define_tag("parent", :for => '') - define_tag("parent:child", :for => '') - define_tag("content") { |tag| tag.nesting } - assert_parse_output 'parent:child:content', '' - end - - def test_parse_tag__binding_do_missing - define_tag 'test' do |tag| - tag.missing! - end - e = assert_raises(Radius::UndefinedTagError) { @parser.parse("") } - assert_equal "undefined tag `test'", e.message - end - - def test_parse_chirpy_bird - # :> chirp chirp - assert_parse_output "<:", "<:" - end - - def test_parse_tag__binding_render_tag - define_tag('test') { |tag| "Hello #{tag.attr['name']}!" } - define_tag('hello') { |tag| tag.render('test', tag.attr) } - assert_parse_output 'Hello John!', '' - end - - def test_accessing_tag_attributes_through_tag_indexer - define_tag('test') { |tag| "Hello #{tag['name']}!" } - assert_parse_output 'Hello John!', '' - end - - def test_parse_tag__binding_render_tag_with_block - define_tag('test') { |tag| "Hello #{tag.expand}!" } - define_tag('hello') { |tag| tag.render('test') { tag.expand } } - assert_parse_output 'Hello John!', 'John' - end - - def test_tag_locals - define_tag "outer" do |tag| - tag.locals.var = 'outer' - tag.expand - end - define_tag "outer:inner" do |tag| - tag.locals.var = 'inner' - tag.expand - end - define_tag "outer:var" do |tag| - tag.locals.var - end - assert_parse_output 'outer', "" - assert_parse_output 'outer:inner:outer', "::" - assert_parse_output 'outer:inner:outer:inner:outer', "::::" - assert_parse_output 'outer', "" - end - - def test_tag_globals - define_tag "set" do |tag| - tag.globals.var = tag.attr['value'] - '' - end - define_tag "var" do |tag| - tag.globals.var - end - assert_parse_output " true false", %{ } - end - - def test_parse_loops - @item = nil - define_tag "each" do |tag| - result = [] - ["Larry", "Moe", "Curly"].each do |item| - tag.locals.item = item - result << tag.expand - end - result.join(tag.attr["between"] || "") - end - define_tag "each:item" do |tag| - tag.locals.item - end - assert_parse_output %{Three Stooges: "Larry", "Moe", "Curly"}, %{Three Stooges: ""} - end - - def test_parse_speed - define_tag "set" do |tag| - tag.globals.var = tag.attr['value'] - '' - end - define_tag "var" do |tag| - tag.globals.var - end - parts = %w{decima nobis augue at facer processus commodo legentis odio lectorum dolore nulla esse lius qui nonummy ullamcorper erat ii notare} - multiplier = parts.map{|p| "#{p}=\"#{rand}\""}.join(' ') - assert_nothing_raised do - Timeout.timeout(10) do - assert_parse_output " false", %{ } - end - end - end - - def test_tag_option_for - define_tag 'fun', :for => 'just for kicks' - assert_parse_output 'just for kicks', '' - end - - def test_tag_expose_option - define_tag 'user', :for => users.first, :expose => ['name', :age] - assert_parse_output 'John', '' - assert_parse_output '25', '' - e = assert_raises(Radius::UndefinedTagError) { @parser.parse "" } - assert_equal "undefined tag `email'", e.message - end - - def test_tag_expose_attributes_option_on_by_default - define_tag 'user', :for => user_with_attributes - assert_parse_output 'John', '' - end - def test_tag_expose_attributes_set_to_false - define_tag 'user_without_attributes', :for => user_with_attributes, :attributes => false - assert_raises(Radius::UndefinedTagError) { @parser.parse "" } - end - - def test_tag_options_must_contain_a_for_option_if_methods_are_exposed - e = assert_raises(ArgumentError) { define_tag('fun', :expose => :today) { 'test' } } - assert_equal "tag definition must contain a :for option when used with the :expose option", e.message - end - - def test_parse_fail_on_missing_end_tag - assert_raises(Radius::MissingEndTagError) { @parser.parse("") } - end - - def test_parse_fail_on_wrong_end_tag - assert_raises(Radius::WrongEndTagError) { @parser.parse("") } - end - - def test_parse_with_default_tag_prefix - @parser = Radius::Parser.new(@context) - define_tag("hello") { |tag| "Hello world!" } - assert_equal "

    Hello world!

    ", @parser.parse('

    ') - end - - def test_parse_with_other_radius_like_tags - @parser = Radius::Parser.new(@context, :tag_prefix => "ralph") - define_tag('hello') { "hello" } - assert_equal "", @parser.parse("") - end - - def test_copyin_global_values - @context.globals.foo = 'bar' - assert_equal 'bar', Radius::Parser.new(@context).context.globals.foo - end - - def test_does_not_pollute_copied_globals - @context.globals.foo = 'bar' - parser = Radius::Parser.new(@context) - parser.context.globals.foo = '[baz]' - assert_equal 'bar', @context.globals.foo - end - - def test_parse_with_other_namespaces - @parser = Radius::Parser.new(@context, :tag_prefix => 'r') - assert_equal "hello world", @parser.parse("hello world") - end - - protected - - def assert_parse_output(output, input, message = nil) - r = @parser.parse(input) - assert_equal(output, r, message) - end - - def assert_parsed_is_unchanged(something) - assert_parse_output something, something - end - - class User - attr_accessor :name, :age, :email, :friend - def initialize(name, age, email) - @name, @age, @email = name, age, email - end - def <=>(other) - name <=> other.name - end - end - - class UserWithAttributes < User - def attributes - { :name => name, :age => age, :email => email } - end - end - - def users - [ - User.new('John', 25, 'test@johnwlong.com'), - User.new('James', 27, 'test@jameslong.com') - ] - end - - def user_with_attributes - UserWithAttributes.new('John', 25, 'test@johnwlong.com') - end - -end diff --git a/vendor/plugins/radius/test/quickstart_test.rb b/vendor/plugins/radius/test/quickstart_test.rb deleted file mode 100644 index 5a7bd1b6..00000000 --- a/vendor/plugins/radius/test/quickstart_test.rb +++ /dev/null @@ -1,151 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/test_helper') - -class QuickstartTest < Test::Unit::TestCase - - def test_hello_world - context = Radius::Context.new - context.define_tag "hello" do |tag| - "Hello #{tag.attr['name'] || 'World'}!" - end - parser = Radius::Parser.new(context) - assert_equal "

    Hello World!

    ", parser.parse('

    ') - assert_equal "

    Hello John!

    ", parser.parse('

    ') - end - - def test_example_2 - require 'redcloth' - context = Radius::Context.new - context.define_tag "textile" do |tag| - contents = tag.expand - RedCloth.new(contents).to_html - end - parser = Radius::Parser.new(context) - assert_equal "

    Hello World!

    ", parser.parse('Hello **World**!') - end - - def test_nested_example - context = Radius::Context.new - - context.define_tag "stooge" do |tag| - content = '' - ["Larry", "Moe", "Curly"].each do |name| - tag.locals.name = name - content << tag.expand - end - content - end - - context.define_tag "stooge:name" do |tag| - tag.locals.name - end - - parser = Radius::Parser.new(context) - - template = <<-TEMPLATE -
      - -
    • -
      -
    - TEMPLATE - - output = <<-OUTPUT -
      - -
    • Larry
    • - -
    • Moe
    • - -
    • Curly
    • - -
    - OUTPUT - - assert_equal output, parser.parse(template) - end - - class User - attr_accessor :name, :age, :email - end - def test_exposing_objects_example - parser = Radius::Parser.new - - parser.context.define_tag "count", :for => 1 - assert_equal "1", parser.parse("") - - user = User.new - user.name, user.age, user.email = "John", 29, "john@example.com" - parser.context.define_tag "user", :for => user, :expose => [ :name, :age, :email ] - assert_equal "John", parser.parse("") - - assert_equal "John", parser.parse("") - end - - class LazyContext < Radius::Context - def tag_missing(tag, attr, &block) - "ERROR: Undefined tag `#{tag}' with attributes #{attr.inspect}" - end - end - def test_tag_missing_example - parser = Radius::Parser.new(LazyContext.new, :tag_prefix => 'lazy') - output = %{ERROR: Undefined tag `weird' with attributes {"value"=>"true"}} - assert_equal output, parser.parse('') - end - - def test_tag_globals_example - parser = Radius::Parser.new - - parser.context.define_tag "inc" do |tag| - tag.globals.count ||= 0 - tag.globals.count += 1 - "" - end - - parser.context.define_tag "count" do |tag| - tag.globals.count || 0 - end - - assert_equal "0 1", parser.parse(" ") - end - - class Person - attr_accessor :name, :friend - def initialize(name) - @name = name - end - end - def test_tag_locals_and_globals_example - jack = Person.new('Jack') - jill = Person.new('Jill') - jack.friend = jill - jill.friend = jack - - context = Radius::Context.new do |c| - c.define_tag "jack" do |tag| - tag.locals.person = jack - tag.expand - end - c.define_tag "jill" do |tag| - tag.locals.person = jill - tag.expand - end - c.define_tag "name" do |tag| - tag.locals.person.name rescue tag.missing! - end - c.define_tag "friend" do |tag| - tag.locals.person = tag.locals.person.friend rescue tag.missing! - tag.expand - end - end - - parser = Radius::Parser.new(context, :tag_prefix => 'r') - - assert_equal "Jack", parser.parse('') #=> "Jack" - assert_equal "Jill", parser.parse('') #=> "Jill" - assert_equal "Jack", parser.parse('') #=> "Jack" - assert_equal "Jack", parser.parse('') #=> "Jack" - assert_equal "Jack and Jill", parser.parse(' and ') #=> "Jack and Jill" - assert_raises(Radius::UndefinedTagError) { parser.parse('') } # raises a Radius::UndefinedTagError exception - end - -end diff --git a/vendor/plugins/radius/test/squiggle_test.rb b/vendor/plugins/radius/test/squiggle_test.rb deleted file mode 100644 index bbae01b5..00000000 --- a/vendor/plugins/radius/test/squiggle_test.rb +++ /dev/null @@ -1,281 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/test_helper') -require 'radius/parser/squiggle_scanner' - -class RadiusSquiggleTest < Test::Unit::TestCase - include RadiusTestHelper - - def setup - @context = new_context - @parser = Radius::Parser.new(@context, :scanner => Radius::SquiggleScanner.new) - end - - def test_sane_scanner_default - assert !Radius::Parser.new.scanner.is_a?(Radius::SquiggleScanner) - end - - def test_initialize_with_params - @parser = Radius::Parser.new(:scanner => Radius::SquiggleScanner.new) - assert_kind_of Radius::SquiggleScanner, @parser.scanner - end - - def test_parse_individual_tags_and_parameters - define_tag "add" do |tag| - tag.attr["param1"].to_i + tag.attr["param2"].to_i - end - assert_parse_output "{3}", %[{{ add param1="1" param2='2'/}}] - end - - def test_parse_attributes - attributes = %[{"a"=>"1", "b"=>"2", "c"=>"3", "d"=>"'"}] - assert_parse_output attributes, %[{attr a="1" b='2'c="3"d="'" /}] - assert_parse_output attributes, %[{attr a="1" b='2'c="3"d="'"}{/attr}] - end - - def test_parse_attributes_with_slashes_or_angle_brackets - slash = %[{"slash"=>"/"}] - angle = %[{"angle"=>">"}] - assert_parse_output slash, %[{attr slash="/"}{/attr}] - assert_parse_output slash, %[{attr slash="/"}{attr /}{/attr}] - assert_parse_output angle, %[{attr angle=">"}{/attr}] - end - - def test_parse_quotes - assert_parse_output "test []", %[{echo value="test" /} {wrap attr="test"}{/wrap}] - end - - def test_things_that_should_be_left_alone - [ - %[ test="2"="4" ], - %[="2" ] - ].each do |middle| - assert_parsed_is_unchanged "{attr#{middle}/}" - assert_parsed_is_unchanged "{attr#{middle}}" - end - end - - def test_tags_inside_html_tags - assert_parse_output %[
    tags in yo tags
    ], - %[
    tags in yo tags
    ] - end - - def test_parse_result_is_always_a_string - define_tag("twelve") { 12 } - assert_parse_output "12", "{ twelve /}" - end - - def test_parse_double_tags - assert_parse_output "test".reverse, "{reverse}test{/reverse}" - assert_parse_output "tset TEST", "{reverse}test{/reverse} {capitalize}test{/capitalize}" - end - - def test_parse_tag_nesting - define_tag("parent", :for => '') - define_tag("parent:child", :for => '') - define_tag("extra", :for => '') - define_tag("nesting") { |tag| tag.nesting } - define_tag("extra:nesting") { |tag| tag.nesting.gsub(':', ' > ') } - define_tag("parent:child:nesting") { |tag| tag.nesting.gsub(':', ' * ') } - assert_parse_output "nesting", "{nesting /}" - assert_parse_output "parent:nesting", "{parent:nesting /}" - assert_parse_output "extra > nesting", "{extra:nesting /}" - assert_parse_output "parent * child * nesting", "{parent:child:nesting /}" - assert_parse_output "parent > extra > nesting", "{parent:extra:nesting /}" - assert_parse_output "parent > child > extra > nesting", "{parent:child:extra:nesting /}" - assert_parse_output "parent * extra * child * nesting", "{parent:extra:child:nesting /}" - assert_parse_output "parent > extra > child > extra > nesting", "{parent:extra:child:extra:nesting /}" - assert_parse_output "parent > extra > child > extra > nesting", "{parent}{extra}{child}{extra}{nesting /}{/extra}{/child}{/extra}{/parent}" - assert_parse_output "extra * parent * child * nesting", "{extra:parent:child:nesting /}" - assert_parse_output "extra > parent > nesting", "{extra}{parent:nesting /}{/extra}" - assert_parse_output "extra * parent * child * nesting", "{extra:parent}{child:nesting /}{/extra:parent}" - assert_raises(Radius::UndefinedTagError) { @parser.parse("{child /}") } - end - def test_parse_tag_nesting_2 - define_tag("parent", :for => '') - define_tag("parent:child", :for => '') - define_tag("content") { |tag| tag.nesting } - assert_parse_output 'parent:child:content', '{parent}{child:content /}{/parent}' - end - - def test_parse_tag__binding_do_missing - define_tag 'test' do |tag| - tag.missing! - end - e = assert_raises(Radius::UndefinedTagError) { @parser.parse("{test /}") } - assert_equal "undefined tag `test'", e.message - end - - def test_parse_chirpy_bird - # :> chirp chirp - assert_parse_output "<:", "<:" - end - - def test_parse_tag__binding_render_tag - define_tag('test') { |tag| "Hello #{tag.attr['name']}!" } - define_tag('hello') { |tag| tag.render('test', tag.attr) } - assert_parse_output 'Hello John!', '{hello name="John" /}' - end - - def test_accessing_tag_attributes_through_tag_indexer - define_tag('test') { |tag| "Hello #{tag['name']}!" } - assert_parse_output 'Hello John!', '{test name="John" /}' - end - - def test_parse_tag__binding_render_tag_with_block - define_tag('test') { |tag| "Hello #{tag.expand}!" } - define_tag('hello') { |tag| tag.render('test') { tag.expand } } - assert_parse_output 'Hello John!', '{hello}John{/hello}' - end - - def test_tag_locals - define_tag "outer" do |tag| - tag.locals.var = 'outer' - tag.expand - end - define_tag "outer:inner" do |tag| - tag.locals.var = 'inner' - tag.expand - end - define_tag "outer:var" do |tag| - tag.locals.var - end - assert_parse_output 'outer', "{outer}{var /}{/outer}" - assert_parse_output 'outer:inner:outer', "{outer}{var /}:{inner}{var /}{/inner}:{var /}{/outer}" - assert_parse_output 'outer:inner:outer:inner:outer', "{outer}{var /}:{inner}{var /}:{outer}{var /}{/outer}:{var /}{/inner}:{var /}{/outer}" - assert_parse_output 'outer', "{outer:var /}" - end - - def test_tag_globals - define_tag "set" do |tag| - tag.globals.var = tag.attr['value'] - '' - end - define_tag "var" do |tag| - tag.globals.var - end - assert_parse_output " true false", %[{var /} {set value="true" /} {var /} {set value="false" /} {var /}] - end - - def test_parse_loops - @item = nil - define_tag "each" do |tag| - result = [] - ["Larry", "Moe", "Curly"].each do |item| - tag.locals.item = item - result << tag.expand - end - result.join(tag.attr["between"] || "") - end - define_tag "each:item" do |tag| - tag.locals.item - end - assert_parse_output %[Three Stooges: "Larry", "Moe", "Curly"], %[Three Stooges: {each between=", "}"{item /}"{/each}] - end - - def test_parse_speed - define_tag "set" do |tag| - tag.globals.var = tag.attr['value'] - '' - end - define_tag "var" do |tag| - tag.globals.var - end - parts = %w{decima nobis augue at facer processus commodo legentis odio lectorum dolore nulla esse lius qui nonummy ullamcorper erat ii notare} - multiplier = parts.map{|p| "#{p}=\"#{rand}\""}.join(' ') - assert_nothing_raised do - Timeout.timeout(10) do - assert_parse_output " false", %[{set value="false" #{multiplier} /} {var /}] - end - end - end - - def test_tag_option_for - define_tag 'fun', :for => 'just for kicks' - assert_parse_output 'just for kicks', '{fun /}' - end - - def test_tag_expose_option - define_tag 'user', :for => users.first, :expose => ['name', :age] - assert_parse_output 'John', '{user:name /}' - assert_parse_output '25', '{user}{age /}{/user}' - e = assert_raises(Radius::UndefinedTagError) { @parser.parse "{user:email /}" } - assert_equal "undefined tag `email'", e.message - end - - def test_tag_expose_attributes_option_on_by_default - define_tag 'user', :for => user_with_attributes - assert_parse_output 'John', '{user:name /}' - end - def test_tag_expose_attributes_set_to_false - define_tag 'user_without_attributes', :for => user_with_attributes, :attributes => false - assert_raises(Radius::UndefinedTagError) { @parser.parse "{user_without_attributes:name /}" } - end - - def test_tag_options_must_contain_a_for_option_if_methods_are_exposed - e = assert_raises(ArgumentError) { define_tag('fun', :expose => :today) { 'test' } } - assert_equal "tag definition must contain a :for option when used with the :expose option", e.message - end - - def test_parse_fail_on_missing_end_tag - assert_raises(Radius::MissingEndTagError) { @parser.parse("{reverse}") } - end - - def test_parse_fail_on_wrong_end_tag - assert_raises(Radius::WrongEndTagError) { @parser.parse("{reverse}{capitalize}{/reverse}") } - end - - def test_copyin_global_values - @context.globals.foo = 'bar' - assert_equal 'bar', Radius::Parser.new(@context).context.globals.foo - end - - def test_does_not_pollute_copied_globals - @context.globals.foo = 'bar' - parser = Radius::Parser.new(@context) - parser.context.globals.foo = '[baz]' - assert_equal 'bar', @context.globals.foo - end - - def test_parse_with_other_namespaces - @parser = Radius::Parser.new(@context, :tag_prefix => 'r') - assert_equal "{fb:test}hello world{/fb:test}", @parser.parse("{fb:test}hello world{/fb:test}") - end - - protected - - def assert_parse_output(output, input, message = nil) - r = @parser.parse(input) - assert_equal(output, r, message) - end - - def assert_parsed_is_unchanged(something) - assert_parse_output something, something - end - - class User - attr_accessor :name, :age, :email, :friend - def initialize(name, age, email) - @name, @age, @email = name, age, email - end - def <=>(other) - name <=> other.name - end - end - - class UserWithAttributes < User - def attributes - { :name => name, :age => age, :email => email } - end - end - - def users - [ - User.new('John', 25, 'test@johnwlong.com'), - User.new('James', 27, 'test@jameslong.com') - ] - end - - def user_with_attributes - UserWithAttributes.new('John', 25, 'test@johnwlong.com') - end - -end diff --git a/vendor/plugins/radius/test/test_helper.rb b/vendor/plugins/radius/test/test_helper.rb deleted file mode 100644 index 4b4a8aad..00000000 --- a/vendor/plugins/radius/test/test_helper.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'rubygems' -require 'timeout' - -unless defined? RADIUS_LIB - - RADIUS_LIB = File.join(File.dirname(__FILE__), '..', 'lib') - $LOAD_PATH << RADIUS_LIB - - require 'radius' - require 'test/unit' - - module RadiusTestHelper - class TestContext < Radius::Context; end - - def new_context - Radius::Context.new do |c| - c.define_tag("reverse" ) { |tag| tag.expand.reverse } - c.define_tag("capitalize") { |tag| tag.expand.upcase } - c.define_tag("echo" ) { |tag| tag.attr['value'] } - c.define_tag("wrap" ) { |tag| "[#{tag.expand}]" } - c.define_tag("attr") do |tag| - kv = tag.attr.keys.sort.collect{|k| "#{k.inspect}=>#{tag[k].inspect}"} - "{#{kv.join(', ')}}" - end - end - end - - def define_tag(name, options = {}, &block) - @parser.context.define_tag name, options, &block - end - - def define_global_tag(name, options = {}, &block) - @context.define_tag name, options, &block - end - end -end diff --git a/vendor/plugins/radius/test/utility_test.rb b/vendor/plugins/radius/test/utility_test.rb deleted file mode 100644 index 9d5ac12a..00000000 --- a/vendor/plugins/radius/test/utility_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'test/unit' -require 'radius' - -class RadiusUtilityTest < Test::Unit::TestCase - - def test_symbolize_keys - h = Radius::Utility.symbolize_keys({ 'a' => 1, :b => 2 }) - assert_equal h[:a], 1 - assert_equal h[:b], 2 - end - - def test_impartial_hash_delete - h = { 'a' => 1, :b => 2 } - assert_equal Radius::Utility.impartial_hash_delete(h, :a), 1 - assert_equal Radius::Utility.impartial_hash_delete(h, 'b'), 2 - assert_equal h.empty?, true - end - - def test_constantize - assert_equal Radius::Utility.constantize('String'), String - end - - def test_camelize - assert_equal Radius::Utility.camelize('ab_cd_ef'), 'AbCdEf' - end - - def test_array_to_s - assert_equal Radius::Utility.array_to_s(['a', 1, [:c]]), 'a1c' - end -end \ No newline at end of file From fa27bfc86ba5088a07a1e19f426b66e34ddbe8c8 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Thu, 22 Dec 2011 11:30:46 +0800 Subject: [PATCH 11/20] Delete residual files from radius --- .../lib/radius/parser/JavaScanner$Flavor.class | Bin 1086 -> 0 bytes .../lib/radius/parser/JavaScanner$Tag.class | Bin 800 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 vendor/plugins/radius/lib/radius/parser/JavaScanner$Flavor.class delete mode 100644 vendor/plugins/radius/lib/radius/parser/JavaScanner$Tag.class diff --git a/vendor/plugins/radius/lib/radius/parser/JavaScanner$Flavor.class b/vendor/plugins/radius/lib/radius/parser/JavaScanner$Flavor.class deleted file mode 100644 index 12e0a78f57ff9c78e0b8609f7156374539fe6fd1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1086 zcma)4ZBNrs6n^g7wOuJ=ygNj|ZRiHd1OYW$$jDL>NW)AzNftkKqmq)+nQrBG=}5$A zG<^0)8PB~eIx`KsP0o|&^t?Rx-1Fn-m+t_!@G1crc^w6;sYt7Mq9cW;+-zu=)ahrD zM?BLo%W+e~9LFsU^BkY6*k(x7_wBlAnYPWK9Qe*7~)l{W}6IZ?quJ3V^Z<#+fk}0myRFt zo~!x7NC|Saed;nySYF^BM;A>utUFDgJgTTvd&jVwx6Vm%(RYHgqTLO>;H*>_Nle)b zyzU;u+&?ND7EWk-ws#gd-6*7nQl5LXa?9^$Z4b0HgXp4sch5ZJ?^Qg1rkkxYgol2fsZjwsFM~M>zJyf Fe*srJ>h}Nu diff --git a/vendor/plugins/radius/lib/radius/parser/JavaScanner$Tag.class b/vendor/plugins/radius/lib/radius/parser/JavaScanner$Tag.class deleted file mode 100644 index 2059ee604d16c807f53080bec54331b622368744..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 800 zcmah{T~8B16g|_HUE8j(wjiwK+k#~Q*Z8V2CL}~n)rS%uc$=1?U9xPO*-1K>6Gs(6Ie8md?`*}8!Z1Dgh(8))0uw$Tx= zCR&|^R|1XhxxAD?B;#SwOLZ6z-w0GkXvgwC`J}SCc8F`&nu_n)f$mX&40`WHS0JC#2LT6ii2YoDD|; z;)FM*qcCZ|5@=1of{oVOFb>mq0#}`X@cy3ifs_AE@__S`on!9nV0_Ab&2__AeaSBR zN*~F7#FJWYoauo&3{Bzwv747>>kgh`(ZLdY2Q}0kI0hc$iGv234(737V^?5hy0IfU z6et(y{(i`>{c|-)1=goG{(8=G#|+?2C1Qi$rpo_if#aagjDO%~q}8IP+al61;JRk4 zq86OZBmWtzW0YVsZu`4Ag#QgCe=kSb-_KF;y-JQ5- Date: Thu, 22 Dec 2011 15:43:38 +0800 Subject: [PATCH 12/20] merge with november_presentation --- app/assets/stylesheets/feile.css.erb | 0 app/controllers/admin/app_auths_controller.rb | 2 +- app/models/design/design.rb | 34 +++++++- app/views/admin/designs/_design_file.html.erb | 2 +- app/views/admin/designs/edit.html.erb | 2 +- app/views/admin/designs/new.html.erb | 2 +- config/initializers/fix_using_obj_id.rb | 5 ++ lib/tasks/app_auth.rake | 11 +++ spec/spec_helper.rb | 3 +- .../app/views/panel/blog/posts/index.html.erb | 25 ++++++ vendor/plugins/NewBlog/NewBlog.json | 9 ++ .../panel/blog/back_end/posts_controller.rb | 84 +++++++++++++++++++ .../panel/blog/back_end/posts/_form.html.erb | 13 +++ .../panel/blog/back_end/posts/index.html.erb | 32 +++++++ .../blog/back_end/posts/latest_post.html.erb | 5 ++ .../panel/blog/back_end/posts/new.html.erb | 13 +++ .../panel/blog/front_end/posts/show.html.erb | 34 ++++++++ .../app/views/panel/blog/posts/index.html.erb | 32 +++++++ .../panel/blog/posts/latest_post.html.erb | 5 ++ .../app/views/panel/blog/posts/new.html.erb | 13 +++ .../app/views/panel/blog/posts/show.html.erb | 38 +++++++++ .../panel/blog/posts/widget_index.html.erb | 16 ++++ .../blog/posts/widget_latest_post.html.erb | 7 ++ .../panel/blog/widget/posts/index.html.erb | 16 ++++ .../blog/widget/posts/latest_post.html.erb | 7 ++ .../plugins/NewBlog/config/locales/zh_tw.yml | 20 +++++ vendor/plugins/NewBlog/config/routes.rb | 13 +++ 27 files changed, 437 insertions(+), 6 deletions(-) create mode 100644 app/assets/stylesheets/feile.css.erb create mode 100644 config/initializers/fix_using_obj_id.rb create mode 100644 lib/tasks/app_auth.rake create mode 100644 vendor/built_in_modules/blog/app/views/panel/blog/posts/index.html.erb create mode 100755 vendor/plugins/NewBlog/NewBlog.json create mode 100644 vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/latest_post.html.erb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/show.html.erb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb create mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb create mode 100644 vendor/plugins/NewBlog/config/locales/zh_tw.yml create mode 100644 vendor/plugins/NewBlog/config/routes.rb diff --git a/app/assets/stylesheets/feile.css.erb b/app/assets/stylesheets/feile.css.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/controllers/admin/app_auths_controller.rb b/app/controllers/admin/app_auths_controller.rb index f2c01451..6f3f1c3d 100644 --- a/app/controllers/admin/app_auths_controller.rb +++ b/app/controllers/admin/app_auths_controller.rb @@ -4,7 +4,7 @@ class Admin::AppAuthsController < ApplicationController before_filter :is_admin? def index - @roles = Role.all.entries + @user_roles = UserRole.all.entries apps = Purchase.where(:type =>"App") @app_auth_data = apps.entries.map do |app| app_c = eval(app.app_controller) diff --git a/app/models/design/design.rb b/app/models/design/design.rb index f39a4816..e77f7f0f 100644 --- a/app/models/design/design.rb +++ b/app/models/design/design.rb @@ -24,6 +24,35 @@ class Design after_save :procs_embedded_objects # after_destroy :del_embedded_objects + # validate do + # errors.add('atttribute1', 'error for 1') if files_with_duplicate? + # errors.add('atttribute2', 'error for 1') if files_with_noname? + # end + + def files_with_duplicate? + [self.javascripts, self.images,self.themes].each do |objects_hash| + ary = objects_hash.collect{ |k| k.file_filename} + ary.compact! + # debugger + return true if(ary.count!=ary.uniq.count) + end + false + end + + def files_with_noname? + [self.javascripts, self.images,self.themes].each do |objects_hash| + objects_hash.each{ |k| + return true if(k.file_filename.nil? && !k.to_save?) + } + end + false + end + def new_files=(*attrs) + attrs[0].map do |key,items_ary| #Loop by JSs,Themes,Imgs + self.files=([items_ary, key]) + end + end + def javascripts=(*attrs) self.files = (attrs << 'javascripts') end @@ -45,6 +74,7 @@ class Design files = eval(attrs.last) end attrs[0].each do |a| + if a[:id].blank? && !a[:file].blank? files.build(:file => a[:file], :to_save => true) else @@ -86,12 +116,14 @@ class Design end end end + self.valid? end def process_object(object) if object.to_save if object.file_filename.nil? - new_object = self.send(object._type.downcase.pluralize).build(object) + new_object = self.send(object._type.downcase.pluralize).build(object.attributes) + new_object.file = object.file object.destroy new_object.to_save = false new_object.save diff --git a/app/views/admin/designs/_design_file.html.erb b/app/views/admin/designs/_design_file.html.erb index 205b5350..c2945069 100644 --- a/app/views/admin/designs/_design_file.html.erb +++ b/app/views/admin/designs/_design_file.html.erb @@ -18,7 +18,7 @@ <% end %>

    -<%= fields_for "design[" + field_name + "][]", object.send(field_name).build, :index => nil do |f| %> +<%= fields_for "design[new_files][" + field_name + "][]", object.send(field_name).build, :index => nil do |f| %> <%= f.file_field :file, :class => "multi_files" %>

    <% end %> \ No newline at end of file diff --git a/app/views/admin/designs/edit.html.erb b/app/views/admin/designs/edit.html.erb index 5e7e705a..16ec7d4c 100644 --- a/app/views/admin/designs/edit.html.erb +++ b/app/views/admin/designs/edit.html.erb @@ -1,6 +1,6 @@

    <%= t('admin.editing_design') %>

    -<%= form_for @design, :url => admin_design_path(@design) do |f| %> +<%= form_for @design, :url => admin_design_path(@design),:html => {:multipart => true} do |f| %> <%= f.error_messages %> <%= render :partial => "form", :locals => { :f => f } %>

    diff --git a/app/views/admin/designs/new.html.erb b/app/views/admin/designs/new.html.erb index ded2237a..10316f40 100644 --- a/app/views/admin/designs/new.html.erb +++ b/app/views/admin/designs/new.html.erb @@ -1,6 +1,6 @@

    <%= t('admin.new_design') %>

    -<%= form_for :design, :url => admin_designs_path do |f| %> +<%= form_for :design, :url => admin_designs_path,:html => {:multipart => true} do |f| %> <%= f.error_messages %> <%= render :partial => "form", :locals => { :f => f } %> diff --git a/config/initializers/fix_using_obj_id.rb b/config/initializers/fix_using_obj_id.rb new file mode 100644 index 00000000..a215cb86 --- /dev/null +++ b/config/initializers/fix_using_obj_id.rb @@ -0,0 +1,5 @@ +Module.instance_eval do + def using_object_ids? + false + end +end \ No newline at end of file diff --git a/lib/tasks/app_auth.rake b/lib/tasks/app_auth.rake new file mode 100644 index 00000000..2cf5066e --- /dev/null +++ b/lib/tasks/app_auth.rake @@ -0,0 +1,11 @@ +# encoding: utf-8 + +namespace :app_auth do + + task :build => :environment do + + + + end + +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 77a57396..2529da0f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,6 +5,7 @@ Spork.prefork do # Loading more in this block will cause your tests to run faster. However, # if you change any configuration or code from libraries loaded here, you'll # need to restart spork for it take effect. + # This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) @@ -54,4 +55,4 @@ end # - Any code that is left outside of the blocks will be ran during preforking # and during each_run! # - These instructions should self-destruct in 10 seconds. If they don't, -# feel free to delete them. +# feel free to delete them. \ No newline at end of file diff --git a/vendor/built_in_modules/blog/app/views/panel/blog/posts/index.html.erb b/vendor/built_in_modules/blog/app/views/panel/blog/posts/index.html.erb new file mode 100644 index 00000000..2bb91518 --- /dev/null +++ b/vendor/built_in_modules/blog/app/views/panel/blog/posts/index.html.erb @@ -0,0 +1,25 @@ +

    <%= t('blog.list_post') %>

    + + + + + + + + + + +<% @posts.each do |post| %> + + + + + + + +<% end %> +
    <%= t('blog.title') %><%= t('blog.body') %>
    <%= post.title %><%= post.body %><%= link_to t('blog.show'), panel_blog_post_path(post) %><%= link_to t('blog.edit'), edit_panel_blog_post_path(post) %><%= link_to t('blog.delete'), panel_blog_post_path(post), :confirm => t('blog.sure?'), :method => :delete %>
    + +
    + +<%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path %> \ No newline at end of file diff --git a/vendor/plugins/NewBlog/NewBlog.json b/vendor/plugins/NewBlog/NewBlog.json new file mode 100755 index 00000000..1c0faa55 --- /dev/null +++ b/vendor/plugins/NewBlog/NewBlog.json @@ -0,0 +1,9 @@ +{ + "title": "NewBlog", + "version": "0.1", + "organization": "Rulingcom", + "author": "RD dep", + "intro": "A simple blog……", + "update_info": "Some info", + "create_date": "11-11-2011" +} \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb b/vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb new file mode 100644 index 00000000..f853d54c --- /dev/null +++ b/vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb @@ -0,0 +1,84 @@ +class Panel::Blog::BackEnd::PostsController < ApplicationController + + layout 'admin' + + def index + @posts = Post.all + + respond_to do |format| + format.html # index.html.erb + format.xml { render :xml => @posts } + end + end + + # GET /posts/1 + # GET /posts/1.xml + def show + @post = Post.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.xml { render :xml => @post } + end + end + + # GET /posts/new + # GET /posts/new.xml + def new + @post = Post.new + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @post } + end + end + + # GET /posts/1/edit + def edit + @post = Post.find(params[:id]) + end + + # POST /posts + # POST /posts.xml + def create + @post = Post.new(params[:post]) + + respond_to do |format| + if @post.save + format.html { redirect_to(panel_blog_post_url(@post), :notice => t('blog.create_post_success')) } + format.xml { render :xml => @post, :status => :created, :location => @post } + else + format.html { render :action => "new" } + format.xml { render :xml => @post.errors, :status => :unprocessable_entity } + end + end + end + + # PUT /posts/1 + # PUT /posts/1.xml + def update + @post = Post.find(params[:id]) + + respond_to do |format| + if @post.update_attributes(params[:post]) + format.html { redirect_to(panel_blog_post_url(@post), :notice => t('blog.update_post_success')) } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @post.errors, :status => :unprocessable_entity } + end + end + end + + # DELETE /posts/1 + # DELETE /posts/1.xml + def destroy + @post = Post.find(params[:id]) + @post.destroy + + respond_to do |format| + format.html { redirect_to(panel_blog_posts_url) } + format.xml { head :ok } + end + end +end diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb new file mode 100644 index 00000000..2ce8dfe8 --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb @@ -0,0 +1,13 @@ +<%= f.error_messages %> + +
    + <%= f.label :title %>
    + <%= f.text_field :title %> +
    +
    + <%= f.label :body %>
    + <%= f.text_area :body %> +
    +
    + <%= f.submit %> +
    diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb new file mode 100644 index 00000000..25eca5f7 --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb @@ -0,0 +1,32 @@ +<% content_for :secondary do %> +
      +
    • <%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path, :class => 'seclink1' %>
    • +
    +<% end -%> + +<%= flash_messages %> + +

    <%= t('blog.list_post') %>

    + + + + + + + + + + +<% @posts.each do |post| %> + + + + + + + +<% end %> +
    <%= t('blog.title') %><%= t('blog.body') %>
    <%= post.title %><%= truncate(post.body,:length=>15) %><%= link_to t('blog.show'), panel_blog_back_end_post_path(post) %><%= link_to t('blog.edit'), edit_panel_blog_back_end_post_path(post) %><%= link_to t('blog.delete'), panel_blog_back_end_post_path(post), :confirm => t('blog.sure?'), :method => :delete %>
    + +
    + diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb new file mode 100644 index 00000000..9eb6ebbb --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb @@ -0,0 +1,5 @@ +<%=stylesheet_link_tag "NewBlog/application"%> +

    <%=@post.title%>

    +

    + <%= @post.body%> +

    diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb new file mode 100644 index 00000000..03508f90 --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb @@ -0,0 +1,13 @@ +<% content_for :secondary do %> +
      +
    • <%= link_to t('blog.index'), panel_blog_back_end_posts_path, :class => 'seclink2' %>
    • +
    +<% end -%> + +<%= flash_messages %> +

    <%= t('blog.new_post') %>

    +<%= form_for @post, :url => panel_blog_back_end_posts_path do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> + +<%= link_back %> diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb new file mode 100644 index 00000000..46842f96 --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb @@ -0,0 +1,34 @@ +

    <%= flash_messages %>

    + +

    + <%= t('blog.body') %> + <%=h @post.body %> +

    + +

    <%= t('blog.comments') %>

    + +<% @post.comments.each do |c| %> +

    + <%=h c.name %> said:
    + <%= time_ago_in_words(c.created_at) %> ago +

    + +

    + <%=h c.body %> +

    +<% end %> + +<%= form_for Comment.new, :url => panel_blog_front_end_comments_path do |f| %> +

    + + <%= f.label :name, "Author" %>
    + <%= f.text_field :name %>
    + <%= f.label :body, "Comment Description" %>
    + <%= f.text_area :body %> + <%= hidden_field_tag :post_id, @post.id %> +

    + +

    + <%= f.submit "Add Comment" %> +

    +<% end %> diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb new file mode 100644 index 00000000..477429cd --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb @@ -0,0 +1,32 @@ +<% content_for :secondary do %> +
      +
    • <%= link_to t('blog.new_post'), new_panel_blog_post_path, :class => 'seclink1' %>
    • +
    +<% end -%> + +<%= flash_messages %> + +

    <%= t('blog.list_post') %>

    + + + + + + + + + + +<% @posts.each do |post| %> + + + + + + + +<% end %> +
    <%= t('blog.title') %><%= t('blog.body') %>
    <%= post.title %><%= truncate(post.body,:length=>15) %><%= link_to t('blog.show'), panel_blog_post_path(post) %><%= link_to t('blog.edit'), edit_panel_blog_post_path(post) %><%= link_to t('blog.delete'), panel_blog_post_path(post), :confirm => t('blog.sure?'), :method => :delete %>
    + +
    + diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/latest_post.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/latest_post.html.erb new file mode 100644 index 00000000..9eb6ebbb --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/posts/latest_post.html.erb @@ -0,0 +1,5 @@ +<%=stylesheet_link_tag "NewBlog/application"%> +

    <%=@post.title%>

    +

    + <%= @post.body%> +

    diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb new file mode 100644 index 00000000..fc4e591d --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb @@ -0,0 +1,13 @@ +<% content_for :secondary do %> +
      +
    • <%= link_to t('blog.index'), panel_blog_posts_path, :class => 'seclink2' %>
    • +
    +<% end -%> + +<%= flash_messages %> +

    <%= t('blog.new_post') %>

    +<%= form_for @post, :url => panel_blog_posts_path do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> + +<%= link_back %> diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/show.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/show.html.erb new file mode 100644 index 00000000..7fce5fd1 --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/posts/show.html.erb @@ -0,0 +1,38 @@ +

    <%= flash_messages %>

    + +

    + <%= t('blog.body') %> + <%=h @post.body %> +

    + +

    <%= t('blog.comments') %>

    + +<% @post.comments.each do |c| %> +

    + <%=h c.name %> said:
    + <%= time_ago_in_words(c.created_at) %> ago +

    + +

    + <%=h c.body %> +

    +<% end %> + +<%= form_for Comment.new, :url => panel_blog_comments_path do |f| %> +

    + + <%= f.label :name, "Author" %>
    + <%= f.text_field :name %>
    + <%= f.label :body, "Comment Description" %>
    + <%= f.text_area :body %> + <%= hidden_field_tag :post_id, @post.id %> +

    + +

    + <%= f.submit "Add Comment" %> +

    +<% end %> + + +<%= link_to t('blog.edit'), edit_panel_blog_post_path(@post) %> | +<%= link_back %> \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb new file mode 100644 index 00000000..cd16cfc7 --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb @@ -0,0 +1,16 @@ +<%=stylesheet_link_tag "NewBlog/application"%> +
    + + + + + + + <% @posts.each do |post| %> + + + + + <% end %> +
    <%= t('blog.title') %><%= t('blog.body') %>
    <%= link_to post.title,panel_blog_post_path(post) %><%= post.body.truncate(14) %>
    +
    \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb new file mode 100644 index 00000000..2312fc74 --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb @@ -0,0 +1,7 @@ +<%=stylesheet_link_tag "NewBlog/application"%> +
    +

    <%= @post.title %>

    +

    + <%= @post.body %> +

    +
    \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb new file mode 100644 index 00000000..0ea7639f --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb @@ -0,0 +1,16 @@ +<%=stylesheet_link_tag "NewBlog/application"%> +
    + + + + + + + <% @posts.each do |post| %> + + + + + <% end %> +
    <%= t('blog.title') %><%= t('blog.body') %>
    <%= link_to post.title,panel_blog_front_end_post_path(post) %><%= post.body.truncate(14) %>
    +
    \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb new file mode 100644 index 00000000..2312fc74 --- /dev/null +++ b/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb @@ -0,0 +1,7 @@ +<%=stylesheet_link_tag "NewBlog/application"%> +
    +

    <%= @post.title %>

    +

    + <%= @post.body %> +

    +
    \ No newline at end of file diff --git a/vendor/plugins/NewBlog/config/locales/zh_tw.yml b/vendor/plugins/NewBlog/config/locales/zh_tw.yml new file mode 100644 index 00000000..d34b583d --- /dev/null +++ b/vendor/plugins/NewBlog/config/locales/zh_tw.yml @@ -0,0 +1,20 @@ +zh_tw: + + _locale: 中文 + + add: 新增 + back: 回去 + create: 創造 + delete: 刪除 + disable: 禁用 + edit: 編輯 + enable: 啟用 + hide: 隱藏 + homepage: 首頁 + no_: "No" + nothing: 無 + show: 顯示 + sure?: 您肯定嗎? + update: 更新 + yes_: "Yes" + diff --git a/vendor/plugins/NewBlog/config/routes.rb b/vendor/plugins/NewBlog/config/routes.rb new file mode 100644 index 00000000..b619df18 --- /dev/null +++ b/vendor/plugins/NewBlog/config/routes.rb @@ -0,0 +1,13 @@ +Rails.application.routes.draw do + + namespace :panel do + namespace :blog do + root :to => "posts#index" + resources :posts + resources :comments + match "widget_latest_post" => "posts#widget_latest_post" + match "widget_index" => "posts#widget_index" + end + end + +end From 1f9197e43894f202de67761058049ad1109613e0 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Thu, 22 Dec 2011 15:53:34 +0800 Subject: [PATCH 13/20] Remove NewBlog from plugins --- vendor/plugins/NewBlog/NewBlog.json | 9 -- .../panel/blog/back_end/posts_controller.rb | 84 ------------------- .../panel/blog/back_end/posts/_form.html.erb | 13 --- .../panel/blog/back_end/posts/index.html.erb | 32 ------- .../blog/back_end/posts/latest_post.html.erb | 5 -- .../panel/blog/back_end/posts/new.html.erb | 13 --- .../panel/blog/front_end/posts/show.html.erb | 34 -------- .../app/views/panel/blog/posts/index.html.erb | 32 ------- .../panel/blog/posts/latest_post.html.erb | 5 -- .../app/views/panel/blog/posts/new.html.erb | 13 --- .../app/views/panel/blog/posts/show.html.erb | 38 --------- .../panel/blog/posts/widget_index.html.erb | 16 ---- .../blog/posts/widget_latest_post.html.erb | 7 -- .../panel/blog/widget/posts/index.html.erb | 16 ---- .../blog/widget/posts/latest_post.html.erb | 7 -- .../plugins/NewBlog/config/locales/zh_tw.yml | 20 ----- vendor/plugins/NewBlog/config/routes.rb | 13 --- 17 files changed, 357 deletions(-) delete mode 100755 vendor/plugins/NewBlog/NewBlog.json delete mode 100644 vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/latest_post.html.erb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/show.html.erb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb delete mode 100644 vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb delete mode 100644 vendor/plugins/NewBlog/config/locales/zh_tw.yml delete mode 100644 vendor/plugins/NewBlog/config/routes.rb diff --git a/vendor/plugins/NewBlog/NewBlog.json b/vendor/plugins/NewBlog/NewBlog.json deleted file mode 100755 index 1c0faa55..00000000 --- a/vendor/plugins/NewBlog/NewBlog.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "title": "NewBlog", - "version": "0.1", - "organization": "Rulingcom", - "author": "RD dep", - "intro": "A simple blog……", - "update_info": "Some info", - "create_date": "11-11-2011" -} \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb b/vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb deleted file mode 100644 index f853d54c..00000000 --- a/vendor/plugins/NewBlog/app/controllers/panel/blog/back_end/posts_controller.rb +++ /dev/null @@ -1,84 +0,0 @@ -class Panel::Blog::BackEnd::PostsController < ApplicationController - - layout 'admin' - - def index - @posts = Post.all - - respond_to do |format| - format.html # index.html.erb - format.xml { render :xml => @posts } - end - end - - # GET /posts/1 - # GET /posts/1.xml - def show - @post = Post.find(params[:id]) - - respond_to do |format| - format.html # show.html.erb - format.xml { render :xml => @post } - end - end - - # GET /posts/new - # GET /posts/new.xml - def new - @post = Post.new - - respond_to do |format| - format.html # new.html.erb - format.xml { render :xml => @post } - end - end - - # GET /posts/1/edit - def edit - @post = Post.find(params[:id]) - end - - # POST /posts - # POST /posts.xml - def create - @post = Post.new(params[:post]) - - respond_to do |format| - if @post.save - format.html { redirect_to(panel_blog_post_url(@post), :notice => t('blog.create_post_success')) } - format.xml { render :xml => @post, :status => :created, :location => @post } - else - format.html { render :action => "new" } - format.xml { render :xml => @post.errors, :status => :unprocessable_entity } - end - end - end - - # PUT /posts/1 - # PUT /posts/1.xml - def update - @post = Post.find(params[:id]) - - respond_to do |format| - if @post.update_attributes(params[:post]) - format.html { redirect_to(panel_blog_post_url(@post), :notice => t('blog.update_post_success')) } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @post.errors, :status => :unprocessable_entity } - end - end - end - - # DELETE /posts/1 - # DELETE /posts/1.xml - def destroy - @post = Post.find(params[:id]) - @post.destroy - - respond_to do |format| - format.html { redirect_to(panel_blog_posts_url) } - format.xml { head :ok } - end - end -end diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb deleted file mode 100644 index 2ce8dfe8..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/_form.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -<%= f.error_messages %> - -
    - <%= f.label :title %>
    - <%= f.text_field :title %> -
    -
    - <%= f.label :body %>
    - <%= f.text_area :body %> -
    -
    - <%= f.submit %> -
    diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb deleted file mode 100644 index 25eca5f7..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/index.html.erb +++ /dev/null @@ -1,32 +0,0 @@ -<% content_for :secondary do %> -
      -
    • <%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path, :class => 'seclink1' %>
    • -
    -<% end -%> - -<%= flash_messages %> - -

    <%= t('blog.list_post') %>

    - - - - - - - - - - -<% @posts.each do |post| %> - - - - - - - -<% end %> -
    <%= t('blog.title') %><%= t('blog.body') %>
    <%= post.title %><%= truncate(post.body,:length=>15) %><%= link_to t('blog.show'), panel_blog_back_end_post_path(post) %><%= link_to t('blog.edit'), edit_panel_blog_back_end_post_path(post) %><%= link_to t('blog.delete'), panel_blog_back_end_post_path(post), :confirm => t('blog.sure?'), :method => :delete %>
    - -
    - diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb deleted file mode 100644 index 9eb6ebbb..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/latest_post.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%=stylesheet_link_tag "NewBlog/application"%> -

    <%=@post.title%>

    -

    - <%= @post.body%> -

    diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb deleted file mode 100644 index 03508f90..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/back_end/posts/new.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -<% content_for :secondary do %> -
      -
    • <%= link_to t('blog.index'), panel_blog_back_end_posts_path, :class => 'seclink2' %>
    • -
    -<% end -%> - -<%= flash_messages %> -

    <%= t('blog.new_post') %>

    -<%= form_for @post, :url => panel_blog_back_end_posts_path do |f| %> - <%= render :partial => 'form', :locals => {:f => f} %> -<% end %> - -<%= link_back %> diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb deleted file mode 100644 index 46842f96..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb +++ /dev/null @@ -1,34 +0,0 @@ -

    <%= flash_messages %>

    - -

    - <%= t('blog.body') %> - <%=h @post.body %> -

    - -

    <%= t('blog.comments') %>

    - -<% @post.comments.each do |c| %> -

    - <%=h c.name %> said:
    - <%= time_ago_in_words(c.created_at) %> ago -

    - -

    - <%=h c.body %> -

    -<% end %> - -<%= form_for Comment.new, :url => panel_blog_front_end_comments_path do |f| %> -

    - - <%= f.label :name, "Author" %>
    - <%= f.text_field :name %>
    - <%= f.label :body, "Comment Description" %>
    - <%= f.text_area :body %> - <%= hidden_field_tag :post_id, @post.id %> -

    - -

    - <%= f.submit "Add Comment" %> -

    -<% end %> diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb deleted file mode 100644 index 477429cd..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/posts/index.html.erb +++ /dev/null @@ -1,32 +0,0 @@ -<% content_for :secondary do %> -
      -
    • <%= link_to t('blog.new_post'), new_panel_blog_post_path, :class => 'seclink1' %>
    • -
    -<% end -%> - -<%= flash_messages %> - -

    <%= t('blog.list_post') %>

    - - - - - - - - - - -<% @posts.each do |post| %> - - - - - - - -<% end %> -
    <%= t('blog.title') %><%= t('blog.body') %>
    <%= post.title %><%= truncate(post.body,:length=>15) %><%= link_to t('blog.show'), panel_blog_post_path(post) %><%= link_to t('blog.edit'), edit_panel_blog_post_path(post) %><%= link_to t('blog.delete'), panel_blog_post_path(post), :confirm => t('blog.sure?'), :method => :delete %>
    - -
    - diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/latest_post.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/latest_post.html.erb deleted file mode 100644 index 9eb6ebbb..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/posts/latest_post.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%=stylesheet_link_tag "NewBlog/application"%> -

    <%=@post.title%>

    -

    - <%= @post.body%> -

    diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb deleted file mode 100644 index fc4e591d..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/posts/new.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -<% content_for :secondary do %> -
      -
    • <%= link_to t('blog.index'), panel_blog_posts_path, :class => 'seclink2' %>
    • -
    -<% end -%> - -<%= flash_messages %> -

    <%= t('blog.new_post') %>

    -<%= form_for @post, :url => panel_blog_posts_path do |f| %> - <%= render :partial => 'form', :locals => {:f => f} %> -<% end %> - -<%= link_back %> diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/show.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/show.html.erb deleted file mode 100644 index 7fce5fd1..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/posts/show.html.erb +++ /dev/null @@ -1,38 +0,0 @@ -

    <%= flash_messages %>

    - -

    - <%= t('blog.body') %> - <%=h @post.body %> -

    - -

    <%= t('blog.comments') %>

    - -<% @post.comments.each do |c| %> -

    - <%=h c.name %> said:
    - <%= time_ago_in_words(c.created_at) %> ago -

    - -

    - <%=h c.body %> -

    -<% end %> - -<%= form_for Comment.new, :url => panel_blog_comments_path do |f| %> -

    - - <%= f.label :name, "Author" %>
    - <%= f.text_field :name %>
    - <%= f.label :body, "Comment Description" %>
    - <%= f.text_area :body %> - <%= hidden_field_tag :post_id, @post.id %> -

    - -

    - <%= f.submit "Add Comment" %> -

    -<% end %> - - -<%= link_to t('blog.edit'), edit_panel_blog_post_path(@post) %> | -<%= link_back %> \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb deleted file mode 100644 index cd16cfc7..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_index.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -<%=stylesheet_link_tag "NewBlog/application"%> -
    - - - - - - - <% @posts.each do |post| %> - - - - - <% end %> -
    <%= t('blog.title') %><%= t('blog.body') %>
    <%= link_to post.title,panel_blog_post_path(post) %><%= post.body.truncate(14) %>
    -
    \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb deleted file mode 100644 index 2312fc74..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/posts/widget_latest_post.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<%=stylesheet_link_tag "NewBlog/application"%> -
    -

    <%= @post.title %>

    -

    - <%= @post.body %> -

    -
    \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb deleted file mode 100644 index 0ea7639f..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/index.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -<%=stylesheet_link_tag "NewBlog/application"%> -
    - - - - - - - <% @posts.each do |post| %> - - - - - <% end %> -
    <%= t('blog.title') %><%= t('blog.body') %>
    <%= link_to post.title,panel_blog_front_end_post_path(post) %><%= post.body.truncate(14) %>
    -
    \ No newline at end of file diff --git a/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb b/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb deleted file mode 100644 index 2312fc74..00000000 --- a/vendor/plugins/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<%=stylesheet_link_tag "NewBlog/application"%> -
    -

    <%= @post.title %>

    -

    - <%= @post.body %> -

    -
    \ No newline at end of file diff --git a/vendor/plugins/NewBlog/config/locales/zh_tw.yml b/vendor/plugins/NewBlog/config/locales/zh_tw.yml deleted file mode 100644 index d34b583d..00000000 --- a/vendor/plugins/NewBlog/config/locales/zh_tw.yml +++ /dev/null @@ -1,20 +0,0 @@ -zh_tw: - - _locale: 中文 - - add: 新增 - back: 回去 - create: 創造 - delete: 刪除 - disable: 禁用 - edit: 編輯 - enable: 啟用 - hide: 隱藏 - homepage: 首頁 - no_: "No" - nothing: 無 - show: 顯示 - sure?: 您肯定嗎? - update: 更新 - yes_: "Yes" - diff --git a/vendor/plugins/NewBlog/config/routes.rb b/vendor/plugins/NewBlog/config/routes.rb deleted file mode 100644 index b619df18..00000000 --- a/vendor/plugins/NewBlog/config/routes.rb +++ /dev/null @@ -1,13 +0,0 @@ -Rails.application.routes.draw do - - namespace :panel do - namespace :blog do - root :to => "posts#index" - resources :posts - resources :comments - match "widget_latest_post" => "posts#widget_latest_post" - match "widget_index" => "posts#widget_index" - end - end - -end From a9f06b951787160ee501bd06c71fd421f45fd7e0 Mon Sep 17 00:00:00 2001 From: chris2tof Date: Thu, 22 Dec 2011 16:23:48 +0800 Subject: [PATCH 14/20] Divide parser into sub-parsers --- Gemfile.lock | 3 +- app/controllers/application_controller.rb | 2 +- app/models/design/layout.rb | 2 +- config/application.rb | 1 + lib/parser.rb | 320 ---------------------- lib/parsers/parser_back_end.rb | 119 ++++++++ lib/parsers/parser_common.rb | 34 +++ lib/parsers/parser_front_end.rb | 139 ++++++++++ lib/parsers/parser_layout.rb | 36 +++ 9 files changed, 333 insertions(+), 323 deletions(-) delete mode 100644 lib/parser.rb create mode 100644 lib/parsers/parser_back_end.rb create mode 100644 lib/parsers/parser_common.rb create mode 100644 lib/parsers/parser_front_end.rb create mode 100644 lib/parsers/parser_layout.rb diff --git a/Gemfile.lock b/Gemfile.lock index 8e073610..fcf8f0b9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -43,7 +43,8 @@ GEM arel (2.2.1) bcrypt-ruby (3.0.1) bson (1.5.2) - bson_ext (1.5.1) + bson_ext (1.5.2) + bson (= 1.5.2) builder (3.0.0) carrierwave (0.5.4) activesupport (~> 3.0) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cf04bfe0..481c893f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,7 @@ class ApplicationController < ActionController::Base protect_from_forgery - include Parser + include ParserFrontEnd helper :all before_filter :set_locale, :set_site diff --git a/app/models/design/layout.rb b/app/models/design/layout.rb index 7ae4ceef..0b3bf7d9 100644 --- a/app/models/design/layout.rb +++ b/app/models/design/layout.rb @@ -1,5 +1,5 @@ class Layout < DesignFile - include Parser + include ParserLayout attr_reader :content diff --git a/config/application.rb b/config/application.rb index 0e438497..36e1006e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -27,6 +27,7 @@ module PrototypeR4 # Custom directories with classes and modules you want to be autoloadable. # config.autoload_paths += %W(#{config.root}/extras) config.autoload_paths += %W(#{config.root}/lib) + config.autoload_paths += %W(#{config.root}/lib/parsers) config.autoload_paths += %W(#{config.root}/app/models/ckeditor ) config.autoload_paths += %W(#{config.root}/app/models/design) config.autoload_paths += %W(#{config.root}/app/models/purchase) diff --git a/lib/parser.rb b/lib/parser.rb deleted file mode 100644 index 389ea35a..00000000 --- a/lib/parser.rb +++ /dev/null @@ -1,320 +0,0 @@ -module Parser - require 'radius' - - def parser_context(page, attributes = {},appfront_url = nil) - Radius::Context.new do |c| - c.define_tag 'snippet' do |tag| - snippet = Snippet.first(:conditions => {:name => tag.attr['name']}) - if snippet - snippet.content - else - t('nothing') - end - end - c.define_tag 'language_bar' do - @site.in_use_locales.map{ |locale| - lang = I18nVariable.first(:conditions => {:key => locale})[locale] - if I18n.locale.to_s.eql?(locale) - lang - else - "#{lang}" - end - }.join(' | ') - end - c.define_tag 'locale' do |tag| - case attributes[:locale] - when 'create' - var = I18nVariable.new(:key => (tag.attr['name'] rescue nil), :document_class => 'Text') - @site.valid_locales.each do |locale| - var[locale] = tag.attr[locale] rescue nil - end - var.save! - res = '' - res << "' - when 'show' - var = I18nVariable.find(tag.attr['id']) - res = '' - res << "' - when 'destroy' - var = I18nVariable.find(tag.attr['id']) - var.destroy - end - end - c.define_tag 'multi_lang' do |tag| - tag.expand - end - c.define_tag 'multi_lang:lang' do |tag| - tag.expand if tag.attr['name'].eql?(I18n.locale.to_s) - end - c.define_tag 'css' do |tag| - assets = Asset.any_in(:filename => tag.attr['name'].split(',').map(&:strip)) - res = '' - assets.each do |asset| - res << " " if asset.data.file.content_type.eql?('text/css') - end - res - end - c.define_tag 'stylesheets' do |tag| - res = '' - res << "" if page.design.reset_css - res << " " if page.design.default_css - theme = page.design.themes.detect{ |d| d.id == page.theme_id } - res << "" if theme - res - end - c.define_tag 'javascripts' do |tag| - res = '' - page.design.javascripts.each do |js| - res << "" - end - res << "" - res << "" - res - end - c.define_tag 'image' do |tag| - image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } - image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image - image = page.design.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image - if image - res = "' - end - end - c.define_tag 'layout_part' do |tag| - part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil - part.content - end - c.define_tag 'content' do |tag| - ret = '' - if (tag.attributes["main"] == "true" && !page.module_app.nil?) - ret << "
    " - else - part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil - ret << part.content - end - ret - end - c.define_tag 'link' do |tag| - item = Item.first(:conditions => { :full_name => tag.attr['name'] }) - ret = '' - ret << "" - ret << item.i18n_variable[I18n.locale] - ret << '' - end - c.define_tag 'menu' do |tag| - home = get_homepage - menu = page.design.layout.menu - menu_level(home, 1, menu) - end - end - end - - def parse_page(page ,appfront_url) - if page._type == 'Page' - layout_content = page.design.layout.content.force_encoding('UTF-8') rescue '' - context = parser_context(page,{}, appfront_url) - parser = Radius::Parser.new(context, :tag_prefix => 'r') - parser.parse(parser.parse(layout_content)) - end - end - - def parse_page_edit(page) - if page._type == 'Page' - layout_content = page.design.layout.content.force_encoding('UTF-8') rescue '' - context = parser_context_edit(page) - parser = Radius::Parser.new(context, :tag_prefix => 'r') - parser.parse(parser.parse(layout_content)) - end - end - - def parser_context_edit(page, attributes = {}) - Radius::Context.new do |c| - c.define_tag 'snippet' do |tag| - snippet = Snippet.first(:conditions => {:name => tag.attr['name']}) - if snippet - snippet.content - else - t('nothing') - end - end - c.define_tag 'language_bar' do - @site.in_use_locales.map{ |locale| - lang = I18nVariable.first(:conditions => {:key => locale})[locale] - if I18n.locale.to_s.eql?(locale) - lang - else - "#{lang}" - end - }.join(' | ') - end - c.define_tag 'multi_lang' do |tag| - tag.expand - end - c.define_tag 'multi_lang:lang' do |tag| - tag.expand if tag.attr['name'].eql?(I18n.locale.to_s) - end - c.define_tag 'css' do |tag| - assets = Asset.any_in(:filename => tag.attr['name'].split(',').map(&:strip)) - res = '' - assets.each do |asset| - res << " " if asset.data.file.content_type.eql?('text/css') - end - res - end - c.define_tag 'image' do |tag| - image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } - image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image - image = page.design.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image - if image - res = "' - end - end - c.define_tag 'stylesheets' do |tag| - res = '' - res << "" if page.design.reset_css - res << "" if page.design.default_css - theme = page.design.themes.detect{ |d| d.id == page.theme_id } - res << "" if theme - res - end - c.define_tag 'javascripts' do |tag| - res = '' - page.design.javascripts.each do |js| - res << "" - end - res << "" - res << "" - res - end - c.define_tag 'layout_part' do |tag| - part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } - ret = '' - ret << "
    " - ret << tag.expand - ret << '
    ' - end - c.define_tag 'content' do |tag| - ret = '' - if (tag.attributes["main"] == "true" && !page.module_app.nil?) - ret << "
    " - else - part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } - ret << "
    " - ret << "' - ret << part.i18n_variable[I18n.locale.to_s] rescue '' - ret << '
    ' - end - end - c.define_tag 'link' do |tag| - item = Item.first(:conditions => { :full_name => tag.attr['name'] }) - ret = '' - ret << "" - ret << item.i18n_variable[I18n.locale] - ret << "" - end - c.define_tag 'menu' do |tag| - home = get_homepage - menu = page.design.layout.menu - menu_level(home, 1, menu, true) - end - end - end - - def menu_level(page, current, menu, edit = false) - if current <= menu.levels - res = "" - end - end - - def menu_li(page, current, menu, i, edit) - res = "" - end - - #============= - def parse_layout_contents(layout) - content = layout.content.force_encoding('UTF-8') - context = parser_layout_contents(layout) - parser = Radius::Parser.new(context, :tag_prefix => 'r') - parser.parse(content) - end - - def parser_layout_contents(layout ) - Radius::Context.new do |c| - c.define_tag 'javascripts' do |tag| - end - c.define_tag 'stylesheets' do |tag| - end - c.define_tag 'menu' do |tag| - layout.build_menu(:levels => 0, :values => {}) unless layout.menu - layout.menu.levels = i = tag.attr['level'].to_i - layout.menu.values.merge!({'home' => tag.attr['home']}) if i == 1 - layout.menu.values.merge!({"id_#{i}" => tag.attr['id'], "class_#{i}" => tag.attr['class'], "li_class_#{i}" => tag.attr['li_class'], "li_incremental_#{i}" => tag.attr['li_incremental']}) - layout.menu.save - tag.expand - end - c.define_tag 'content' do |tag| - layout.layout_parts.create(:name => tag.attr['name'], :editable => true) - end - c.define_tag 'image' do |tag| - image = layout.design.images.detect{ |i| i.file_filename.eql?(parse_html_image(tag.expand)) } - image.update_attributes(:name => tag.attr['name'], :html_id => tag.attr['id'], :html_class => tag.attr['class']) - end - end - end - - def parse_html_image(html) - html.scan(/(?<=\)/){ - $1.gsub(' ','').scan(/(?<=src=\")(.*?)(?=\")/){ - return File.basename($1).gsub(/[\\\"]/, '') - } - } - end - - def self.included(base) - base.send :helper_method, :parse_page if base.respond_to? :helper_method - base.send :helper_method, :parse_page_edit if base.respond_to? :helper_method - end - -end diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb new file mode 100644 index 00000000..d11ce9b2 --- /dev/null +++ b/lib/parsers/parser_back_end.rb @@ -0,0 +1,119 @@ +module ParserBackEnd + require 'radius' + include ParserCommon + + def parse_page_edit(page) + if page._type == 'Page' + layout_content = page.design.layout.content.force_encoding('UTF-8') rescue '' + context = parser_context_edit(page) + parser = Radius::Parser.new(context, :tag_prefix => 'r') + parser.parse(parser.parse(layout_content)) + end + end + + def parser_context_edit(page, attributes = {}) + Radius::Context.new do |c| + c.define_tag 'snippet' do |tag| + snippet = Snippet.first(:conditions => {:name => tag.attr['name']}) + if snippet + snippet.content + else + t('nothing') + end + end + c.define_tag 'language_bar' do + @site.in_use_locales.map{ |locale| + lang = I18nVariable.first(:conditions => {:key => locale})[locale] + if I18n.locale.to_s.eql?(locale) + lang + else + "#{lang}" + end + }.join(' | ') + end + c.define_tag 'multi_lang' do |tag| + tag.expand + end + c.define_tag 'multi_lang:lang' do |tag| + tag.expand if tag.attr['name'].eql?(I18n.locale.to_s) + end + c.define_tag 'css' do |tag| + assets = Asset.any_in(:filename => tag.attr['name'].split(',').map(&:strip)) + res = '' + assets.each do |asset| + res << " " if asset.data.file.content_type.eql?('text/css') + end + res + end + c.define_tag 'image' do |tag| + image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } + image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image + image = page.design.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image + if image + res = "' + end + end + c.define_tag 'stylesheets' do |tag| + res = '' + res << "" if page.design.reset_css + res << "" if page.design.default_css + theme = page.design.themes.detect{ |d| d.id == page.theme_id } + res << "" if theme + res + end + c.define_tag 'javascripts' do |tag| + res = '' + page.design.javascripts.each do |js| + res << "" + end + res << "" + res << "" + res + end + c.define_tag 'layout_part' do |tag| + part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } + ret = '' + ret << "
    " + ret << tag.expand + ret << '
    ' + end + c.define_tag 'content' do |tag| + ret = '' + if (tag.attributes["main"] == "true" && !page.module_app.nil?) + ret << "
    " + else + part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } + ret << "
    " + ret << "' + ret << part.i18n_variable[I18n.locale.to_s] rescue '' + ret << '
    ' + end + end + c.define_tag 'link' do |tag| + item = Item.first(:conditions => { :full_name => tag.attr['name'] }) + ret = '' + ret << "" + ret << item.i18n_variable[I18n.locale] + ret << "" + end + c.define_tag 'menu' do |tag| + home = get_homepage + menu = page.design.layout.menu + menu_level(home, 1, menu, true) + end + end + end + + def self.included(base) + base.send :helper_method, :parse_page_edit if base.respond_to? :helper_method + end + +end diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb new file mode 100644 index 00000000..e96c9201 --- /dev/null +++ b/lib/parsers/parser_common.rb @@ -0,0 +1,34 @@ +module ParserCommon + + def menu_level(page, current, menu, edit = false) + if current <= menu.levels + res = "" + end + end + + def menu_li(page, current, menu, i, edit) + res = "" + end + +end diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb new file mode 100644 index 00000000..660a779b --- /dev/null +++ b/lib/parsers/parser_front_end.rb @@ -0,0 +1,139 @@ +module ParserFrontEnd + require 'radius' + include ParserCommon + + def parser_context(page, attributes = {},appfront_url = nil) + Radius::Context.new do |c| + c.define_tag 'snippet' do |tag| + snippet = Snippet.first(:conditions => {:name => tag.attr['name']}) + if snippet + snippet.content + else + t('nothing') + end + end + c.define_tag 'language_bar' do + @site.in_use_locales.map{ |locale| + lang = I18nVariable.first(:conditions => {:key => locale})[locale] + if I18n.locale.to_s.eql?(locale) + lang + else + "#{lang}" + end + }.join(' | ') + end + c.define_tag 'locale' do |tag| + case attributes[:locale] + when 'create' + var = I18nVariable.new(:key => (tag.attr['name'] rescue nil), :document_class => 'Text') + @site.valid_locales.each do |locale| + var[locale] = tag.attr[locale] rescue nil + end + var.save! + res = '' + res << "' + when 'show' + var = I18nVariable.find(tag.attr['id']) + res = '' + res << "' + when 'destroy' + var = I18nVariable.find(tag.attr['id']) + var.destroy + end + end + c.define_tag 'multi_lang' do |tag| + tag.expand + end + c.define_tag 'multi_lang:lang' do |tag| + tag.expand if tag.attr['name'].eql?(I18n.locale.to_s) + end + c.define_tag 'css' do |tag| + assets = Asset.any_in(:filename => tag.attr['name'].split(',').map(&:strip)) + res = '' + assets.each do |asset| + res << " " if asset.data.file.content_type.eql?('text/css') + end + res + end + c.define_tag 'stylesheets' do |tag| + res = '' + res << "" if page.design.reset_css + res << " " if page.design.default_css + theme = page.design.themes.detect{ |d| d.id == page.theme_id } + res << "" if theme + res + end + c.define_tag 'javascripts' do |tag| + res = '' + page.design.javascripts.each do |js| + res << "" + end + res << "" + res << "" + res + end + c.define_tag 'image' do |tag| + image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } + image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image + image = page.design.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image + if image + res = "' + end + end + c.define_tag 'layout_part' do |tag| + part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil + part.content + end + c.define_tag 'content' do |tag| + ret = '' + if (tag.attributes["main"] == "true" && !page.module_app.nil?) + ret << "
    " + else + part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil + ret << part.content + end + ret + end + c.define_tag 'link' do |tag| + item = Item.first(:conditions => { :full_name => tag.attr['name'] }) + ret = '' + ret << "" + ret << item.i18n_variable[I18n.locale] + ret << '' + end + c.define_tag 'menu' do |tag| + home = get_homepage + menu = page.design.layout.menu + menu_level(home, 1, menu) + end + end + end + + def parse_page(page ,appfront_url) + if page._type == 'Page' + layout_content = page.design.layout.content.force_encoding('UTF-8') rescue '' + context = parser_context(page,{}, appfront_url) + parser = Radius::Parser.new(context, :tag_prefix => 'r') + parser.parse(parser.parse(layout_content)) + end + end + + def self.included(base) + base.send :helper_method, :parse_page if base.respond_to? :helper_method + end + +end diff --git a/lib/parsers/parser_layout.rb b/lib/parsers/parser_layout.rb new file mode 100644 index 00000000..c97b8df2 --- /dev/null +++ b/lib/parsers/parser_layout.rb @@ -0,0 +1,36 @@ +module ParserLayout + require 'radius' + include ParserCommon + + def parse_layout_contents(layout) + content = layout.content.force_encoding('UTF-8') + context = parser_layout_contents(layout) + parser = Radius::Parser.new(context, :tag_prefix => 'r') + parser.parse(content) + end + + def parser_layout_contents(layout) + Radius::Context.new do |c| + c.define_tag 'javascripts' do |tag| + end + c.define_tag 'stylesheets' do |tag| + end + c.define_tag 'menu' do |tag| + layout.build_menu(:levels => 0, :values => {}) unless layout.menu + layout.menu.levels = i = tag.attr['level'].to_i + layout.menu.values.merge!({'home' => tag.attr['home']}) if i == 1 + layout.menu.values.merge!({"id_#{i}" => tag.attr['id'], "class_#{i}" => tag.attr['class'], "li_class_#{i}" => tag.attr['li_class'], "li_incremental_#{i}" => tag.attr['li_incremental']}) + layout.menu.save + tag.expand + end + c.define_tag 'content' do |tag| + layout.layout_parts.create(:name => tag.attr['name'], :editable => true) + end + c.define_tag 'image' do |tag| + image = layout.design.images.detect{ |i| i.file_filename.eql?(parse_html_image(tag.expand)) } + image.update_attributes(:name => tag.attr['name'], :html_id => tag.attr['id'], :html_class => tag.attr['class']) + end + end + end + +end From d3ca1647be9078589f7f23acbb9912b6143c54f9 Mon Sep 17 00:00:00 2001 From: Matthew Fu Date: Fri, 23 Dec 2011 13:54:28 +0800 Subject: [PATCH 15/20] fix page form bugs --- app/assets/javascripts/page_edit.js | 4 ++-- app/controllers/admin/pages_controller.rb | 1 + app/controllers/application_controller.rb | 2 +- app/views/admin/module_apps/_app_selector.html.erb | 2 +- app/views/admin/pages/_form.html.erb | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/page_edit.js b/app/assets/javascripts/page_edit.js index 50e974b4..25348105 100644 --- a/app/assets/javascripts/page_edit.js +++ b/app/assets/javascripts/page_edit.js @@ -6,7 +6,7 @@ $("#page_design_id").live('change', function() { $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_themes'); }); -$("#page_module_app").live('change', function() { +$("#page_module_app_id").live('change', function() { var app_id = $(this).val(); if(app_id!=''){ $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_frontend_pages',function(data, textStatus){ @@ -16,6 +16,6 @@ $("#page_module_app").live('change', function() { }); } else{ - $("#app_page_url").remove(); + $("#app_page_url").children().remove(); } }); diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 23f58444..c547d5f2 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -32,6 +32,7 @@ class Admin::PagesController < ApplicationController @i18n_variable = @item.i18n_variable @designs = Design.all.entries @design = @item.design + @app_frontend_urls = @item.module_app.app_pages end def create diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 481c893f..d9c0156c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,7 @@ class ApplicationController < ActionController::Base protect_from_forgery - include ParserFrontEnd + include ParserFrontEnd,ParserBackEnd helper :all before_filter :set_locale, :set_site diff --git a/app/views/admin/module_apps/_app_selector.html.erb b/app/views/admin/module_apps/_app_selector.html.erb index 90c2aee1..f6220cf8 100644 --- a/app/views/admin/module_apps/_app_selector.html.erb +++ b/app/views/admin/module_apps/_app_selector.html.erb @@ -1 +1 @@ -<%= f.select :module_app, @apps.collect { |t| [t.title.capitalize, t.id] }, {:include_blank => true} ,{:rel => admin_module_apps_path } %> \ No newline at end of file +<%= f.select :module_app_id, @apps.collect { |t| [t.title.capitalize, t.id] }, {:include_blank => true} ,{:rel => admin_module_apps_path } %> \ No newline at end of file diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index d0c00d16..8223f0bb 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -33,7 +33,7 @@

    <%= t('admin.module_app') %> <%= render :partial => "admin/module_apps/app_selector", :locals => { :f => f } %> - + <%= select('page','app_frontend_url', @app_frontend_urls ) rescue ''%>

    <%= f.label :is_published, "#{t('admin.is_published')} ?" %> From 7b40706aedd94d61ae158a57354c68089d88a55d Mon Sep 17 00:00:00 2001 From: Matthew Fu Date: Thu, 5 Jan 2012 16:20:51 +0800 Subject: [PATCH 16/20] fixing for app_auth --- app/controllers/admin/app_auths_controller.rb | 2 +- app/controllers/application_controller.rb | 7 + app/models/app_auth.rb | 71 ++++-- app/models/module_app.rb | 4 + app/models/user/user.rb | 5 +- app/views/admin/designs/_form.html.erb | 2 +- app/views/admin/designs/_new.html.erb | 2 +- spec/models/app_auth_basic.rb | 241 ++++++++++++------ vendor/built_in_modules/NewBlog/NewBlog.json | 3 +- 9 files changed, 225 insertions(+), 112 deletions(-) diff --git a/app/controllers/admin/app_auths_controller.rb b/app/controllers/admin/app_auths_controller.rb index 6f3f1c3d..f2c01451 100644 --- a/app/controllers/admin/app_auths_controller.rb +++ b/app/controllers/admin/app_auths_controller.rb @@ -4,7 +4,7 @@ class Admin::AppAuthsController < ApplicationController before_filter :is_admin? def index - @user_roles = UserRole.all.entries + @roles = Role.all.entries apps = Purchase.where(:type =>"App") @app_auth_data = apps.entries.map do |app| app_c = eval(app.app_controller) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d9c0156c..7c964ff5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,6 +5,13 @@ class ApplicationController < ActionController::Base helper :all before_filter :set_locale, :set_site + + def front_end_available(module_app_title='') + app_controller = ModuleApp.first(conditions: {:title => module_app_title} ) + unless app_controller.enable_frontend? + render :text => 'View not available' + end + end def get_all_app_engines ary = ["vender/plugins/NewBlog"] diff --git a/app/models/app_auth.rb b/app/models/app_auth.rb index 9602fda0..b31add3c 100644 --- a/app/models/app_auth.rb +++ b/app/models/app_auth.rb @@ -15,55 +15,72 @@ class AppAuth has_and_belongs_to_many :roles + has_and_belongs_to_many :sub_roles + + attr_protected :roles,:sub_roles,:privilege_users,:blocked_users,:users + + def add_role role + add_operation(:roles,role) + end + + def add_sub_role role + add_operation(:sub_roles,role) + end + + def remove_role role + remove_operation(:roles,role) + end + + def remove_sub_role role + remove_operation(:sub_roles,role) + end def add_user_to_black_list user - unless self.blocked_users.include?(user) - self.blocked_users << user - self.save! - else - false #should put error message for user existed in list already - end + add_operation(:blocked_users,user) end - def remove_user_from_black_list user - if self.blocked_users.include? user - self.blocked_users.delete user + remove_operation(:blocked_users,user) + end + + def add_user_to_privilege_list user + add_operation(:privilege_users,user) + end + + def remove_user_from_privilege_list user + remove_operation(:privilege_users,user) + end + + def remove_operation(item,obj) + if (self.send item).include? obj + (self.send item).delete obj self.save! else false #should put error message for user not existed in list - end + end end - - def add_user_to_privilege_list user - unless self.privilege_users.include? user - self.privilege_users << user + def add_operation(item,obj) + unless (self.send item).include?(obj) + (self.send item) << obj self.save! else false #should put error message for user existed in list already end end - - def remove_user_from_privilege_list user - if self.privilege_users.include? user - self.privilege_users.delete user - self.save! - else - false #should put error message for user not existed in list - end - end - def auth_users if self.all? User.all.entries else - ary= self.roles.collect do |role| - role.users + ary=[] + [:roles,:sub_roles].each do |t_role| + ary += (self.send t_role).collect do |role| + role.users + end end ary << self.privilege_users - ary.flatten! + ary.flatten!.uniq end end diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 31a02025..18e8a6d7 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -9,9 +9,13 @@ class ModuleApp field :intro field :update_info field :create_date + field :enable_frontend,type: Boolean field :app_pages ,type: Array + field :widgets ,type: Array has_one :app_auth,dependent: :delete + + end diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 1e956b80..60199ce7 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -19,7 +19,10 @@ class User accepts_nested_attributes_for :attribute_values, :allow_destroy => true def avb_apps - query = AppAuth.any_of({all: true},{privilege_user_ids: self.id},{roles: self.role.id}).excludes(blocked_user_ids: self.id) + sub_role_ids_ary=self.sub_roles.collect{|t| t.id} + query1 = AppAuth.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: self.id) + query2 = AppAuth.any_of({all: true},{privilege_user_ids: self.id},{role_ids: self.role.id}).excludes(blocked_user_ids: self.id) + (query1 + query2).uniq end def name diff --git a/app/views/admin/designs/_form.html.erb b/app/views/admin/designs/_form.html.erb index b6ba7cb2..fd579e5e 100644 --- a/app/views/admin/designs/_form.html.erb +++ b/app/views/admin/designs/_form.html.erb @@ -38,7 +38,7 @@ <%= f.hidden_field :to_save, :value => true %> <% end %> <% else %> - <%= File.basename (@design.default_css.file.url) %> + <%= File.basename (@design.default_css.file.url) rescue "" %> <% end %>

    diff --git a/app/views/admin/designs/_new.html.erb b/app/views/admin/designs/_new.html.erb index ded2237a..a4aba6c9 100644 --- a/app/views/admin/designs/_new.html.erb +++ b/app/views/admin/designs/_new.html.erb @@ -1,6 +1,6 @@

    <%= t('admin.new_design') %>

    -<%= form_for :design, :url => admin_designs_path do |f| %> +<%= form_for @design, :url => admin_design_path(@design),:html => {:multipart => true} do |f| %> <%= f.error_messages %> <%= render :partial => "form", :locals => { :f => f } %> diff --git a/spec/models/app_auth_basic.rb b/spec/models/app_auth_basic.rb index 3a2ae0f2..0f629119 100644 --- a/spec/models/app_auth_basic.rb +++ b/spec/models/app_auth_basic.rb @@ -6,129 +6,210 @@ describe AppAuth do before do User.all.destroy - UserRole.all.destroy + Role.all.destroy + SubRole.all.destroy AppAuth.all.destroy ModuleApp.all.destroy #Create some fixtures of Main Role main_role_key = ["Stud","Teacher","Staff"] @new_main_role_list = main_role_key.each do |role| - new_role = UserRole.new :key => role - + new_role = Role.new :key => role new_role.save end + #Create Some SubRoles + sub_role_key = ["graduated_school","undergraduated_school","TA","Senior"] + @new_main_role_list = sub_role_key.each do |role| + new_role = SubRole.new :key => role + new_role.save + end + #Create some users of User - user_emails = ["a_good_stud","a_bad_stud","a_teacher","a_staff"] + user_emails = ["a_good_ug_stud_1","a_good_ug_stud_2","a_bad_ug_stud","a_good_g_stud","a_bad_g_stud","a_teacher","a_staff"] user_emails.each do |user_email| email=user_email+"@rulingcom.com" new_user = User.new :email=> email new_user.save end - - @stud_MRK = UserRole.first(conditions:{key:"Stud"}) - @teacher_MRK = UserRole.first(conditions:{key:"Teacher"}) - @staff_MRK = UserRole.first(conditions:{key:"Staff"}) - - @good_stu = User.first(conditions:{email:"a_good_stud@rulingcom.com"}) - @bad_stu = User.first(conditions:{email:"a_bad_stud@rulingcom.com"}) + #MRK = Member Role Key SRK=Sub Role Key + @stud_MRK = Role.first(conditions:{key:"Stud"}) + @teacher_MRK = Role.first(conditions:{key:"Teacher"}) + @staff_MRK = Role.first(conditions:{key:"Staff"}) + + @graduated_SRK = SubRole.first(conditions:{key:"graduated_school"}) + @under_graduated_SRK = SubRole.first(conditions:{key:"undergraduated_school"}) + @ta_SRK = SubRole.first(conditions:{key:"TA"}) + @senior_SRK = SubRole.first(conditions:{key:"Senior"}) + + @stud_MRK.sub_roles += [@graduated,@under_graduated,@ta] + @stud_MRK.save! + + @teacher_MRK.sub_roles = [@senior] + @teacher_MRK.save! + + @good_ug_stu_1 = User.first(conditions:{email:"a_good_ug_stud_1@rulingcom.com"}) + @good_ug_stu_2 = User.first(conditions:{email:"a_good_ug_stud_2@rulingcom.com"}) + @bad_ug_stu = User.first(conditions:{email:"a_bad_ug_stud@rulingcom.com"}) + + @good_g_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"}) + @bad_g_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"}) @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"}) @staff = User.first(conditions:{email:"a_staff@rulingcom.com"}) #setting Roles for users - @good_stu.user_role = @stud_MRK - @bad_stu.user_role = @stud_MRK - @teacher.user_role = @teacher_MRK - @staff.user_role = @staff_MRK + @good_g_stu.role = @stud_MRK + @bad_g_stu.role = @stud_MRK + @good_ug_stu_1.role = @stud_MRK + @good_ug_stu_2.role = @stud_MRK + @bad_ug_stu.role = @stud_MRK + + @good_g_stu.sub_roles = [@graduated_SRK,@ta_SRK] + @bad_g_stu.sub_roles << @graduated_SRK + @good_ug_stu_1.sub_roles << @under_graduated_SRK + @good_ug_stu_2.sub_roles << @under_graduated_SRK + @bad_ug_stu.sub_roles << @under_graduated_SRK - @good_stu.save! - @bad_stu.save! + @teacher.role = @teacher_MRK + @staff.role = @staff_MRK + + @good_g_stu.save! + @bad_g_stu.save! + @good_ug_stu_1.save! + @good_ug_stu_2.save! + @bad_ug_stu.save! + @teacher.save! @staff.save! end - describe "Testing basic structure" do + describe "Starting a ClassBulletin Auth for teacher , staff and ta" do before do - @app_auth = AppAuth.new() - #all stud has access right - @app_auth.user_roles << @stud_MRK + @bulletin_app_auth = AppAuth.new() + #all teacher and staff has access right + @bulletin_app_auth.roles = [@teacher_MRK,@staff_MRK] + #all person with TA sub_role has access right + @bulletin_app_auth.sub_roles << @ta_SRK - #a_bad_stud add to block to app_auth - @app_auth.blocked_users << @bad_stu + #a_bad_ug_stud add to block to bulletin_app_auth + #@bulletin_app_auth.blocked_users << @bad_ug_stu #all teacher has access right - @app_auth.user_roles << @teacher_MRK + # @bulletin_app_auth.roles << @teacher_MRK - @app_auth.privilege_users << @staff - @app_auth.save! + # @bulletin_app_auth.privilege_users << @staff + @bulletin_app_auth.save! end context "Should just initialize all obj that is needed" do - it "Testing @app_auth init result" do - @app_auth.user_roles.should have(2).item + it "Testing @bulletin_app_auth init result" do + @bulletin_app_auth.roles.should have(2).item #teacher staff + @bulletin_app_auth.sub_roles.should have(1).item #ta end - it "@app_auth should have UserRoles: Stud , Teacher " do - key_ary = @app_auth.user_roles.collect do |role| + it "@bulletin_app_auth should have Roles: Staff , Teacher " do + key_ary = @bulletin_app_auth.roles.collect do |role| role.key end - key_ary.should == ["Stud","Teacher"] + key_ary.sort.should == ["Staff","Teacher"].sort end - it "@app_auth should have one Privialage user which is belongs to Staff" do - p_user_ary = @app_auth.privilege_users.collect do |p_user| - p_user.user_role.key - end - p_user_ary.should include("Staff") + it "bulletin_app_auth should have 3 auth users" do + user_ary = [@teacher,@staff,@good_g_stu] + @bulletin_app_auth.auth_users.sort.should == user_ary.sort + check_user_has_app user_ary end - it "@app_auth should have one student listed at blocklist" do - @bad_stu = User.first(conditions:{email:"a_bad_stud@rulingcom.com"}) - @app_auth.blocked_users.should have(1).item - @app_auth.blocked_users.should include(@bad_stu) + it "Adding a undergraduate stud into app_auth by privilege list" do + user_ary = [@teacher,@staff,@good_g_stu,@good_ug_stu_1] + @bulletin_app_auth.add_user_to_privilege_list @good_ug_stu_1 + @bulletin_app_auth.auth_users.sort.should == user_ary.sort + check_user_has_app user_ary end + + it "Adding all graudated-stud into app_auth" do + user_ary = [@teacher,@staff,@good_g_stu,@bad_g_stu] + @bulletin_app_auth.add_sub_role @graduated_SRK + @bulletin_app_auth.auth_users.sort.should == user_ary.sort + check_user_has_app user_ary + end + + it "Blocking bad-graduate student" do + user_ary =[@teacher,@staff,@good_g_stu] + @bulletin_app_auth.add_sub_role @graduated_SRK + @bulletin_app_auth.add_user_to_black_list @bad_g_stu + @bulletin_app_auth.auth_users_after_block_list.sort.should == user_ary.sort + check_user_has_app user_ary + end + + it "Removing all graudated-stud from app_auth" do + user_ary =[@teacher,@staff,@good_g_stu] + @bulletin_app_auth.add_sub_role @graduated_SRK + @bulletin_app_auth.remove_sub_role @graduated_SRK + @bulletin_app_auth.auth_users.sort.should == user_ary.sort + check_user_has_app user_ary + end + + + # it "@bulletin_app_auth should have one Privialage user which is belongs to Staff" do + # p_user_ary = @bulletin_app_auth.privilege_users.collect do |p_user| + # p_user.roles.key + # end + # p_user_ary.should include("Staff") + # end + + # it "@bulletin_app_auth should have one student listed at blocklist" do + # @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"}) + # @bulletin_app_auth.blocked_users.should have(1).item + # @bulletin_app_auth.blocked_users.should include(@bad_stu) + # end - it "[Development #1]-1.Authorizing roles: roles + blocklist" do - @good_stu = User.first(conditions:{email:"a_good_stud@rulingcom.com"}) - @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"}) - @staff = User.first(conditions:{email:"a_staff@rulingcom.com"}) - ary = [@good_stu,@teacher,@staff] - @app_auth.auth_users_after_block_list.should == ary - end - - it "[Development #1]-2.Authorizing single users: list of users [new_user1~2]" do - user_emails = ["new_user1","new_user2","new_user3","new_user4"] - user_emails.each do |user_email| - email=user_email+"@rulingcom.com" - new_user = User.new :email=> email - new_user.save + # it "[Development #1]-1.Authorizing roles: roles + blocklist" do + # @good_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"}) + # @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"}) + # @staff = User.first(conditions:{email:"a_staff@rulingcom.com"}) + # ary = [@good_stu,@teacher,@staff] + # @bulletin_app_auth.auth_users_after_block_list.should == ary + # end + # + # it "[Development #1]-2.Authorizing single users: list of users [new_user1~2]" do + # user_emails = ["new_user1","new_user2","new_user3","new_user4"] + # user_emails.each do |user_email| + # email=user_email+"@rulingcom.com" + # new_user = User.new :email=> email + # new_user.save + # end + # user1= User.first(conditions:{email:"new_user1@rulingcom.com"}) + # user2= User.first(conditions:{email:"new_user2@rulingcom.com"}) + # user3= User.first(conditions:{email:"new_user3@rulingcom.com"}) + # user4= User.first(conditions:{email:"new_user4@rulingcom.com"}) + # + # @bulletin_app_auth.privilege_users << user1 + # @bulletin_app_auth.privilege_users << user2 + # + # @bulletin_app_auth.auth_users_after_block_list.should include(user1,user2) + # @bulletin_app_auth.auth_users_after_block_list.should_not include(user3,user4) + # + # end + # + # it "[Development #1]-3.Authorizing roles and single users: roles + blocklist + list of users" do + # @bulletin_app_auth.auth_users.should have(7).item + # end + # + # it "[Development #1]-4.Authorizing all: blocklist" do + # @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"}) + # @new_bulletin_app_auth = (AppAuth.new :all => true) + # @new_bulletin_app_auth.blocked_users << @bad_stu + # + # @new_bulletin_app_auth.auth_users.should == User.all.entries + # @new_bulletin_app_auth.auth_users_after_block_list.should_not include(@bad_stu) + # @new_bulletin_app_auth.save! + # end + def check_user_has_app(user_ary) + user_ary.each do |user| + user.avb_apps.should include(@bulletin_app_auth) end - user1= User.first(conditions:{email:"new_user1@rulingcom.com"}) - user2= User.first(conditions:{email:"new_user2@rulingcom.com"}) - user3= User.first(conditions:{email:"new_user3@rulingcom.com"}) - user4= User.first(conditions:{email:"new_user4@rulingcom.com"}) - - @app_auth.privilege_users << user1 - @app_auth.privilege_users << user2 - - @app_auth.auth_users_after_block_list.should include(user1,user2) - @app_auth.auth_users_after_block_list.should_not include(user3,user4) - end - - it "[Development #1]-3.Authorizing roles and single users: roles + blocklist + list of users" do - @app_auth.auth_users.should have(4).item - end - - it "[Development #1]-4.Authorizing all: blocklist" do - @bad_stu = User.first(conditions:{email:"a_bad_stud@rulingcom.com"}) - @new_app_auth = (AppAuth.new :all => true) - @new_app_auth.blocked_users << @bad_stu - - @new_app_auth.auth_users.should == User.all.entries - @new_app_auth.auth_users_after_block_list.should_not include(@bad_stu) - @new_app_auth.save! - end - end + end diff --git a/vendor/built_in_modules/NewBlog/NewBlog.json b/vendor/built_in_modules/NewBlog/NewBlog.json index ce9c80d3..32734d3b 100755 --- a/vendor/built_in_modules/NewBlog/NewBlog.json +++ b/vendor/built_in_modules/NewBlog/NewBlog.json @@ -6,5 +6,6 @@ "intro": "A simple blog……", "update_info": "Some info", "create_date": "11-11-2011", - "app_pages": ["/panel/blog/front_end/"] + "app_pages": ["/panel/blog/front_end/"], + "widgets": ["/panel/blog/widget/latest_post","/panel/blog/widget/"] } From 79f778ad8cf6b06e6580cf6b837602885849d17e Mon Sep 17 00:00:00 2001 From: Matthew Fu Date: Thu, 5 Jan 2012 16:21:33 +0800 Subject: [PATCH 17/20] creating for disabling widgets and frontend --- .../admin/module_apps_controller.rb | 16 +++++++++++----- app/views/admin/module_apps/index.html.erb | 0 lib/obit_widget_controller.rb | 6 ++++++ .../panel/blog/front_end/posts_controller.rb | 8 ++++++-- .../panel/blog/widget/posts_controller.rb | 7 ++++++- .../NewBlog/app/helpers/application_helper.rb | 4 ++++ .../NewBlog/app/helpers/new_blog_helper.rb | 5 +++++ .../NewBlog/config/initializers/app_config.rb | 18 ++++++++++++++++++ .../NewBlog/lib/NewBlog/engine.rb | 1 - 9 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 app/views/admin/module_apps/index.html.erb create mode 100644 lib/obit_widget_controller.rb create mode 100644 vendor/built_in_modules/NewBlog/app/helpers/new_blog_helper.rb create mode 100644 vendor/built_in_modules/NewBlog/config/initializers/app_config.rb diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb index 55be4135..98683345 100644 --- a/app/controllers/admin/module_apps_controller.rb +++ b/app/controllers/admin/module_apps_controller.rb @@ -1,9 +1,15 @@ class Admin::ModuleAppsController < ApplicationController + layout "admin" -def reload_frontend_pages - @module_app = ModuleApp.find(params[:id]) - respond_to do |format| - format.js {} + def index + @module_apps = ModuleApp.all.entries + end + + + def reload_frontend_pages + @module_app = ModuleApp.find(params[:id]) + respond_to do |format| + format.js {} + end end -end end \ No newline at end of file diff --git a/app/views/admin/module_apps/index.html.erb b/app/views/admin/module_apps/index.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/lib/obit_widget_controller.rb b/lib/obit_widget_controller.rb new file mode 100644 index 00000000..c9789775 --- /dev/null +++ b/lib/obit_widget_controller.rb @@ -0,0 +1,6 @@ +class ObitWidgetController< ApplicationController + before_filter {|c| c.front_end_available(@app_title)} + layout 'production' + + +end \ No newline at end of file diff --git a/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb b/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb index df089756..fd83cc34 100644 --- a/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb +++ b/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb @@ -1,6 +1,10 @@ -class Panel::Blog::FrontEnd::PostsController < ApplicationController +class Panel::Blog::FrontEnd::PostsController < ObitWidgetController - layout 'production' + + def initialize + super + @app_title = NewBlog::MOUDLEAPP_TITLE + end # GET /posts # GET /posts.xml diff --git a/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/widget/posts_controller.rb b/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/widget/posts_controller.rb index 20e14616..5c165b49 100644 --- a/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/widget/posts_controller.rb +++ b/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/widget/posts_controller.rb @@ -1,7 +1,12 @@ -class Panel::Blog::Widget::PostsController < ApplicationController +class Panel::Blog::Widget::PostsController < ObitWidgetController layout 'production' + def initialize + super + @app_title = NewBlog::MOUDLEAPP_TITLE + end + # GET /posts # GET /posts.xml def index diff --git a/vendor/built_in_modules/NewBlog/app/helpers/application_helper.rb b/vendor/built_in_modules/NewBlog/app/helpers/application_helper.rb index de6be794..0d18e034 100644 --- a/vendor/built_in_modules/NewBlog/app/helpers/application_helper.rb +++ b/vendor/built_in_modules/NewBlog/app/helpers/application_helper.rb @@ -1,2 +1,6 @@ module ApplicationHelper + + def check_show_frontend + front_end_available(NewBlog::MOUDLEAPP_TITLE) + end end diff --git a/vendor/built_in_modules/NewBlog/app/helpers/new_blog_helper.rb b/vendor/built_in_modules/NewBlog/app/helpers/new_blog_helper.rb new file mode 100644 index 00000000..d8ad507e --- /dev/null +++ b/vendor/built_in_modules/NewBlog/app/helpers/new_blog_helper.rb @@ -0,0 +1,5 @@ +module NewBlogHelper + def self.check_show_frontend + ApplicationController.front_end_available(NewBlog::MOUDLEAPP_TITLE) + end +end \ No newline at end of file diff --git a/vendor/built_in_modules/NewBlog/config/initializers/app_config.rb b/vendor/built_in_modules/NewBlog/config/initializers/app_config.rb new file mode 100644 index 00000000..b218d15d --- /dev/null +++ b/vendor/built_in_modules/NewBlog/config/initializers/app_config.rb @@ -0,0 +1,18 @@ +# module NewBlog +# class MyEngine < Rails::Engine +# # Add a load path for this specific Engine +# # config.autoload_paths << File.expand_path("../lib/some/path", __FILE__) +# put "ABC" +# PrototypeR4::Application::Orbit_Apps << "NewBlog" +# +# # initializer "my_engine.add_middleware" do |app| +# # app.middleware.use MyEngine::Middleware +# # end +# end +# +# end +module NewBlog + VERSION = "0.0.1" + MOUDLEAPP_TITLE = "NewBlog" +end +PrototypeR4::Application::Orbit_Apps << "NewBlog" \ No newline at end of file diff --git a/vendor/built_in_modules/NewBlog/lib/NewBlog/engine.rb b/vendor/built_in_modules/NewBlog/lib/NewBlog/engine.rb index 90afca77..e0f0221c 100644 --- a/vendor/built_in_modules/NewBlog/lib/NewBlog/engine.rb +++ b/vendor/built_in_modules/NewBlog/lib/NewBlog/engine.rb @@ -1,6 +1,5 @@ module NewBlog class Engine < Rails::Engine isolate_namespace NewBlog - PrototypeR4::Application::Orbit_Apps << "NewBlog" end end From cae3daa9c4847c082d2605e11b7b79a857f9665c Mon Sep 17 00:00:00 2001 From: Matthew Fu Date: Tue, 10 Jan 2012 18:29:11 +0800 Subject: [PATCH 18/20] Change NewBlog to new_blog --- .../admin/page_parts_controller.rb | 2 +- app/controllers/application_controller.rb | 4 +-- .../obit_frontend_component_controller.rb | 4 +++ app/controllers/obit_frontend_controller.rb | 3 +++ app/controllers/obit_widget_controller.rb | 3 +++ lib/NewBlog.zip | Bin 53263 -> 53327 bytes lib/fraisier/layout.html | 4 +-- lib/tasks/dev.rake | 2 +- .../panel/blog/back_end/posts/edit.html.erb | 8 ------ .../built_in_modules/NewBlog/lib/NewBlog.rb | 5 ---- .../app/views/panel/blog/posts/index.html.erb | 25 ------------------ .../{NewBlog => new_blog}/.gitignore | 0 .../{NewBlog => new_blog}/Gemfile | 0 .../{NewBlog => new_blog}/Gemfile.lock | 0 .../{NewBlog => new_blog}/MIT-LICENSE | 0 .../{NewBlog => new_blog}/README.rdoc | 0 .../{NewBlog => new_blog}/Rakefile | 0 .../app/assets/images/NewBlog/.gitkeep | 0 .../app/assets/javascripts/NewBlog/.gitkeep | 0 .../app/assets/stylesheets/NewBlog/.gitkeep | 0 .../stylesheets/NewBlog/application.css | 0 .../assets/stylesheets/NewBlog/production.css | 0 .../app/controllers/.gitkeep | 0 .../app/controllers/application_controller.rb | 0 .../new_blog}/back_end/posts_controller.rb | 8 +++--- .../new_blog/front_end/comments_controller.rb | 7 +++++ .../new_blog/front_end/posts_controller.rb | 21 +++++++++++++++ .../new_blog}/widget/posts_controller.rb | 2 +- .../app/helpers/.gitkeep | 0 .../app/helpers/application_helper.rb | 0 .../app/helpers/new_blog_helper.rb | 0 .../app/mailers/.gitkeep | 0 .../{NewBlog => new_blog}/app/models/.gitkeep | 0 .../app/models/comment.rb | 0 .../{NewBlog => new_blog}/app/models/post.rb | 0 .../{NewBlog => new_blog}/app/views/.gitkeep | 0 .../app/views/layouts/application.html.erb | 0 .../app/views/layouts/edit_view.html.erb | 0 .../app/views/layouts/production.html.erb | 0 .../new_blog}/back_end/posts/_form.html.erb | 0 .../new_blog/back_end/posts/edit.html.erb | 8 ++++++ .../new_blog}/back_end/posts/index.html.erb | 8 +++--- .../back_end/posts/latest_post.html.erb | 2 +- .../new_blog}/back_end/posts/new.html.erb | 4 +-- .../new_blog}/back_end/posts/show.html.erb | 4 +-- .../front_end/posts/_post_frontend.html.erb | 2 +- .../new_blog}/front_end/posts/index.html.erb | 2 +- .../new_blog}/front_end/posts/show.html.erb | 2 +- .../new_blog}/widget/posts/index.html.erb | 4 +-- .../widget/posts/latest_post.html.erb | 2 +- .../config/initializers/app_config.rb | 18 +++++++++++++ .../config/locales/en.yml | 0 .../config/locales/zh_tw.yml | 0 .../new_blog/config/routes.rb | 25 ++++++++++++++++++ .../built_in_modules/new_blog/lib/NewBlog.rb | 5 ++++ .../lib/new_blog}/engine.rb | 2 +- .../lib/new_blog}/version.rb | 0 .../lib/tasks/NewBlog_tasks.rake | 0 .../new_blog.gemspec} | 0 .../built_in_modules/new_blog/new_blog.json | 12 +++++++++ .../{NewBlog => new_blog}/script/rails | 0 .../test/NewBlog_test.rb | 0 .../{NewBlog => new_blog}/test/dummy/Rakefile | 0 .../app/assets/javascripts/application.js | 0 .../app/assets/stylesheets/application.css | 0 .../app/controllers/application_controller.rb | 0 .../dummy/app/helpers/application_helper.rb | 0 .../test/dummy/app/mailers/.gitkeep | 0 .../test/dummy/app/models/.gitkeep | 0 .../app/views/layouts/application.html.erb | 0 .../test/dummy/config.ru | 0 .../test/dummy/config/application.rb | 0 .../test/dummy/config/boot.rb | 0 .../test/dummy/config/database.yml | 0 .../test/dummy/config/environment.rb | 0 .../dummy/config/environments/development.rb | 0 .../dummy/config/environments/production.rb | 0 .../test/dummy/config/environments/test.rb | 0 .../initializers/backtrace_silencers.rb | 0 .../dummy/config/initializers/inflections.rb | 0 .../dummy/config/initializers/mime_types.rb | 0 .../dummy/config/initializers/secret_token.rb | 0 .../config/initializers/session_store.rb | 0 .../config/initializers/wrap_parameters.rb | 0 .../test/dummy/config/locales/en.yml | 0 .../test/dummy/config/mongoid.yml | 0 .../test/dummy/config/routes.rb | 0 .../test/dummy/lib/assets/.gitkeep | 0 .../test/dummy/log/.gitkeep | 0 .../test/dummy/public/404.html | 0 .../test/dummy/public/422.html | 0 .../test/dummy/public/500.html | 0 .../test/dummy/public/favicon.ico | 0 .../test/dummy/script/rails | 0 .../test/integration/navigation_test.rb | 0 .../{NewBlog => new_blog}/test/test_helper.rb | 0 96 files changed, 133 insertions(+), 65 deletions(-) create mode 100644 app/controllers/obit_frontend_component_controller.rb create mode 100644 app/controllers/obit_frontend_controller.rb create mode 100644 app/controllers/obit_widget_controller.rb delete mode 100644 vendor/built_in_modules/NewBlog/app/views/panel/blog/back_end/posts/edit.html.erb delete mode 100644 vendor/built_in_modules/NewBlog/lib/NewBlog.rb delete mode 100644 vendor/built_in_modules/blog/app/views/panel/blog/posts/index.html.erb rename vendor/built_in_modules/{NewBlog => new_blog}/.gitignore (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/Gemfile (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/Gemfile.lock (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/MIT-LICENSE (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/README.rdoc (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/Rakefile (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/assets/images/NewBlog/.gitkeep (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/assets/javascripts/NewBlog/.gitkeep (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/assets/stylesheets/NewBlog/.gitkeep (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/assets/stylesheets/NewBlog/application.css (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/assets/stylesheets/NewBlog/production.css (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/controllers/.gitkeep (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/controllers/application_controller.rb (100%) rename vendor/built_in_modules/{NewBlog/app/controllers/panel/blog => new_blog/app/controllers/panel/new_blog}/back_end/posts_controller.rb (81%) create mode 100644 vendor/built_in_modules/new_blog/app/controllers/panel/new_blog/front_end/comments_controller.rb create mode 100644 vendor/built_in_modules/new_blog/app/controllers/panel/new_blog/front_end/posts_controller.rb rename vendor/built_in_modules/{NewBlog/app/controllers/panel/blog => new_blog/app/controllers/panel/new_blog}/widget/posts_controller.rb (77%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/helpers/.gitkeep (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/helpers/application_helper.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/helpers/new_blog_helper.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/mailers/.gitkeep (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/models/.gitkeep (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/models/comment.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/models/post.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/views/.gitkeep (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/views/layouts/application.html.erb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/views/layouts/edit_view.html.erb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/app/views/layouts/production.html.erb (100%) rename vendor/built_in_modules/{NewBlog/app/views/panel/blog => new_blog/app/views/panel/new_blog}/back_end/posts/_form.html.erb (100%) create mode 100644 vendor/built_in_modules/new_blog/app/views/panel/new_blog/back_end/posts/edit.html.erb rename vendor/built_in_modules/{NewBlog/app/views/panel/blog => new_blog/app/views/panel/new_blog}/back_end/posts/index.html.erb (50%) rename vendor/built_in_modules/{NewBlog/app/views/panel/blog => new_blog/app/views/panel/new_blog}/back_end/posts/latest_post.html.erb (52%) rename vendor/built_in_modules/{NewBlog/app/views/panel/blog => new_blog/app/views/panel/new_blog}/back_end/posts/new.html.erb (55%) rename vendor/built_in_modules/{NewBlog/app/views/panel/blog => new_blog/app/views/panel/new_blog}/back_end/posts/show.html.erb (76%) rename vendor/built_in_modules/{NewBlog/app/views/panel/blog => new_blog/app/views/panel/new_blog}/front_end/posts/_post_frontend.html.erb (56%) rename vendor/built_in_modules/{NewBlog/app/views/panel/blog => new_blog/app/views/panel/new_blog}/front_end/posts/index.html.erb (65%) rename vendor/built_in_modules/{NewBlog/app/views/panel/blog => new_blog/app/views/panel/new_blog}/front_end/posts/show.html.erb (87%) rename vendor/built_in_modules/{NewBlog/app/views/panel/blog => new_blog/app/views/panel/new_blog}/widget/posts/index.html.erb (64%) rename vendor/built_in_modules/{NewBlog/app/views/panel/blog => new_blog/app/views/panel/new_blog}/widget/posts/latest_post.html.erb (64%) create mode 100644 vendor/built_in_modules/new_blog/config/initializers/app_config.rb rename vendor/built_in_modules/{NewBlog => new_blog}/config/locales/en.yml (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/config/locales/zh_tw.yml (100%) create mode 100644 vendor/built_in_modules/new_blog/config/routes.rb create mode 100644 vendor/built_in_modules/new_blog/lib/NewBlog.rb rename vendor/built_in_modules/{NewBlog/lib/NewBlog => new_blog/lib/new_blog}/engine.rb (64%) rename vendor/built_in_modules/{NewBlog/lib/NewBlog => new_blog/lib/new_blog}/version.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/lib/tasks/NewBlog_tasks.rake (100%) rename vendor/built_in_modules/{NewBlog/NewBlog.gemspec => new_blog/new_blog.gemspec} (100%) create mode 100755 vendor/built_in_modules/new_blog/new_blog.json rename vendor/built_in_modules/{NewBlog => new_blog}/script/rails (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/NewBlog_test.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/Rakefile (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/app/assets/javascripts/application.js (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/app/assets/stylesheets/application.css (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/app/controllers/application_controller.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/app/helpers/application_helper.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/app/mailers/.gitkeep (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/app/models/.gitkeep (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/app/views/layouts/application.html.erb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config.ru (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/application.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/boot.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/database.yml (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/environment.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/environments/development.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/environments/production.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/environments/test.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/initializers/backtrace_silencers.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/initializers/inflections.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/initializers/mime_types.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/initializers/secret_token.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/initializers/session_store.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/initializers/wrap_parameters.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/locales/en.yml (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/mongoid.yml (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/config/routes.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/lib/assets/.gitkeep (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/log/.gitkeep (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/public/404.html (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/public/422.html (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/public/500.html (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/public/favicon.ico (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/dummy/script/rails (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/integration/navigation_test.rb (100%) rename vendor/built_in_modules/{NewBlog => new_blog}/test/test_helper.rb (100%) diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index f77a7782..71e39ae1 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -28,7 +28,7 @@ class Admin::PagePartsController < ApplicationController @partial = 'edit_text' @part_locale = params[:part_locale] || I18n.locale.to_s when 'module' - @plugins=[{:module=>"Blog",:widgets=>[{:name=>"Blog",:path=>"panel/blog/widget_latest_post"},{:name=>"Blog",:path=>"panel/blog/widget_index"}]}] + @plugins=[{:module=>"Blog",:widgets=>[{:name=>"Blog",:path=>"panel/new_blog/widget_latest_post"},{:name=>"Blog",:path=>"panel/new_blog/widget_index"}]}] when 'snippet' end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7c964ff5..0227c252 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,12 +9,12 @@ class ApplicationController < ActionController::Base def front_end_available(module_app_title='') app_controller = ModuleApp.first(conditions: {:title => module_app_title} ) unless app_controller.enable_frontend? - render :text => 'View not available' + render :nothing end end def get_all_app_engines - ary = ["vender/plugins/NewBlog"] + ary = ["vender/plugins/new_blog"] app_engines = ary.collect{|t| Rails::Engine.find t } diff --git a/app/controllers/obit_frontend_component_controller.rb b/app/controllers/obit_frontend_component_controller.rb new file mode 100644 index 00000000..d5bfaac6 --- /dev/null +++ b/app/controllers/obit_frontend_component_controller.rb @@ -0,0 +1,4 @@ +class ObitFrontendComponentController< ApplicationController + before_filter {|c| c.front_end_available(@app_title)} + layout 'production' +end \ No newline at end of file diff --git a/app/controllers/obit_frontend_controller.rb b/app/controllers/obit_frontend_controller.rb new file mode 100644 index 00000000..fb42ac78 --- /dev/null +++ b/app/controllers/obit_frontend_controller.rb @@ -0,0 +1,3 @@ +class ObitFrontendController< ObitFrontendComponentController + +end \ No newline at end of file diff --git a/app/controllers/obit_widget_controller.rb b/app/controllers/obit_widget_controller.rb new file mode 100644 index 00000000..e0a9746d --- /dev/null +++ b/app/controllers/obit_widget_controller.rb @@ -0,0 +1,3 @@ +class ObitWidgetController< ObitFrontendComponentController + +end \ No newline at end of file diff --git a/lib/NewBlog.zip b/lib/NewBlog.zip index f21f2eb22613d1c35e68db8690af47f24e3d43da..3513cabf8668eed283bebaac3103fd657c43901e 100644 GIT binary patch delta 5612 zcmai230PD|5@wnKMrIfehwA~uh@)HrqDat)T*lzRDd5dvP!WTmET}<1Vhp%~0_BAP zLA(_Z8KV*bx#EFxm>AYwvyn}{n7CqA&8M4+Bl#RA_fs zXiG!qYYX+Y@K05dlW&n!A)IX}34yahc~PjPa1KqMPwLec-lv)HzR-p$qj&J{3xQ0F zKg+PQgcC#@n^xe@oQ7w@dBVH+w2zL1un_BBr{lx0R5dy^0-`xq&xJp_PDc(Cls3?# zXQ+n(I8d$N?rsZW6FW$7GlSp>GVt0Xffb@yAqEXCqDc&D)iaR~tI$K=omcowB!^x4 zSwy(YUjfaxfZaEcYHQ@O|Nq;A=^ZCgR}g0wHCV1`@5I z7{k=CEm!s0O4;jwR$L$yRM>q*tW6(ZPOP<5dhrenvy;Onm?Cd_urATDZiTf@4D zV->h>BeKR*ItlUpl;4SP-_(bL!g+AO)C>|l0}1PbX9QuXBwiM*ki+yo!j#O&W0?ov zJ<3*83l3$iu6hw9&)P>W6#4WJ;#;2_Ld5w7ktFfZcf`krNjiz#2A=u};YzJkSE7aE zqnhPMu~3%#A0bc#0aw_XXnwC&K)P7YECnd)L{R#^C>wV({EK^G+HUV)p}SvV*%_r+( zR{EwnO~`&w9<%C;^Ve?bQz5Cp9^T^j&Hg#vW1Oq!9sgl-fKk&FSOp;`6NCnzB3NDrKW0PyICOxdN`Kgt(F(;<={N{ulm?JZCmapq&#JO7JYclT zycdROR%PA72$I=!Zv$&fBRCatoLCYTX~58EcJ9lCrh=YCbE=U+Bbv((WVw+Oy{Oc1asbIcVau#D)Dt@^mH(Z zuy$>|$C|SyTfkBu=DcB*uHPQR?%mmu#_r9_-Ns(jmG?C<;`q*9b!*H(ZYQHNM+Y8s zbN+_~yIv7g^YdNF1D2T|V1Wms24!1t=zIY()h3f0Gkx95cedcXHH2wZFqKcKsDj{O z)i6_9LxCrm(q0zKXQb%qYv^T5cE8K(E8QJMM!lE2;|b#EJu?X6(mfxL`qD1+;SV$x zS;OkWa3WiNfr8#bdm=9=N+j~hMRNw_RgFd8vJXM+6$&oxol1m%*_%#;6ZVA<3IkUD z-M&>sxp9L9#O(Jb@?j;`(6IkY3w9D3YE{XBrM#Y32gs`jA0133k$-kDmyM%QxdIN~ zl&a1gVrLa-`0Otu>kTZOKXPa=#J1AuBMT&*qQJFmCXZ}m8T%eTE3;x#%&5GDg;sP{ z29GLcGhj;f_YO5Oxrl<8Ba?V_vGvw)?nuC}Czu|rU+K#`P;pBF>6O2c?A>@Ykq~`H z*D>c)e<~k(qf3PaWE^uD*}~>yK|CDO;~Tkw=}xU2l1ijdfBZ8N&Zmbc*m&X{f~NY! zI&wKSdGg7n!y3SpM&-#-{I7E=bYx^nr=oadw@#(;7cM@%j9=V3y_zhhonb|4&amwY zgPVGGDJQ#y5Yno2LgZC#Wu{++ZYw-EWCIS>xrCvr4kCoGCY-U1p4~NE%Y^a6GjL|1~5aNzl(PM&s3^fQNLJaAEnIL8 z)l$JDXjg@5yDrcI@d8^)#7u5)XF21T&C&;`fB(3Be~y1oA7M$Ukb(zdlj6Lyz3&`Sd&m(d7=%4HDt8oXLv@ z4+b~PK?VHsyG44?)ZmH!rM_hhDHTSL(m?;;qEU*x7Y`oJZk&k<)t9>P%VH7qH+rJS zZ*R*-%k|h!3jJ>htyig;m)%WHXzo(HPmgu%7s+W?T~Tl}vlkpahO-*idev151;sF& zpctt-N7hWCrdWp46l*jZ5*+j=e*5EyY_ln8)PHMsLcfwd`C5bGl}75yqgyDnHl8_f zxJ5p4PB$N;P*ehwP4t}Vg$t0&5A~vc`+K{WmW2D3;yd7XjwncJ9nW`l{QO;Nl_Jx% zjPjILTX0@$tPXKf8-;We8HhA~*wQBE)2|z(f`g!Fp8}8CJOwXkY5`$lmwwVtp}1uF zpgXKj*0A~&&1p+vI6Wzb>X&W!l0vsPFr20@$MU)!(fg&T%>LGZx5Y_88j&pA?Lw`#rXmZT4{3vo{$wtt?zPN6?GF^B)yB!-vQodopi z#uN^a0yf={q9YkxK;TSH;M?JWR*|jfEL|v}mvv;>-{Ft+vaxV+_85q|<$)G4D+tZj z2;SXW6k49cC=JaP!HOJ>r1!c_q3G>IiylO8*H=ec-H6LQX$Qwn+F<~XZhN2`%nr=# zlrY{XzU7LZe9GKV(&>%7a~aYzcd&-A)s9_Kv^tOGm_ulnKl+>_C2*;WjoFgunKuCAYv zdc%@>Ls@*Zp-^nV|M{loC`)C|!VdSoSU4wCl*T&<&wBR7w!QYTq0oC(juKuFI&$m0 z`eOO-&jM=$-C82f6MBd=Vr(FitcC}|mxONoYNe5T;K}tuK!6iSEL~xfzb%A`_6d2g&?E98Xw?ryN@gfX9H2AwK%{^p z;ygpF48xHwWgwBJtdtr&!ZwMMyu3Qs8uQ`pQi-}yV$7^KxckBtGZUh%^@!K@Npj@1 z~NAJzXsAPi7~h?jwH6iR`9l5 zW@v%J)>tQ~w>(GV8E5r`#w^ZyxkLjFX9Gq#Ik-BxlpT}9n6(Xwoc$l`aO9j}flVik z_V=%T?nGoEKb6B^W@hNv0bJJn=aALNnQ}{z)h#(>E{b2H4dgygNYCm^sv3G z{@6*zw*SWY0;Qnd^%iw@r&}F$*1XyggIRH=%C8GXFaAq@0e}Pwkq;WwBW0k90B&@1`%Gf6nv@Zfq%BzgS?dE z!XMx%hhtt*#(c$Y{~E$0j>D4>Yf#NKhcn)<5saTDyWnTJM6U>mGkO00aDI*@#n?ON zTS~P0^s;35!oFbX@8S8-H*)%fM2!pJo_Pyl)X#!$rE+(Jcbyi&QvW?PK7IawVDZt2 ziURggU5mhBO56?ng(`nB_baV(0lZ^l3!8$YsOUm)G8L(%A@)qkbHNu>C|y{*G{L%qsatS$an$X;AQHxwyHDREo5pAs42F|<5_#9sWeNy<&CaD<;Cgz&3MW-K+} zlcQc7!7(T=M>bF>f+ZiY({N>(N??fl73^D#3#wfN$6pZT^KFa&@=b4EQG~45*?igG zw}}I@=3Q+JEy}X{*+BSNrib8A{OHnG?q)8knr+b(`}C{d9+kbRG78z4aLc*kk?PBw z{?G1=ilVPQ?6K)PHE46|{MG!%=e*DS=>0Ulx^U+!FLa3O6T9M@zPPgIKM&8YktSbr zth?~D@#6)`UzT^>S)eY>ZFPO={-Jv{1Fo%&xBSu@mU$%?q})7hfj)UCiH|lBZ7kjX zW;w3lLHy-Av$cT;fB4p`U)!@GLOc_OqAX3AQ=~x%Uo517D1T8%0|CdQS+sMO|BL2k zMU1Zv-#5p%e%4$eK33wWSJ;zi6)bbXT4v+QpKom=dz~OXMF{2>P2llfZ#Wv;M8PbI z`;H}QPQn;Xv`=E-bXD%)?xh7X<=KTiu{RIo_fC{^(vs=++M5(N?nM1NDVbI!Zb>lH z!5qFxZlr#crkF85zHv@~5A&$I#a$w`^9nx}?!;AXq(|hMx`6X8OS5M}NxJ)(nKdti zb=~HgTCPj`#gJ@rvSuyaL*1}0o9$+uQOIr-A4u=99v67NiJGooMggX--^$8=XhQ|N z>^E#uPUn4`wHK&*`CCfAE&FH2X<|?S;>|Q5>h+r$NOk(_=?rCm_8LZcY&BujbK8a) zC3s^qqq28=L@9{c)kEvhboWIHdti3}bskji{C2kZHus^Tq1;cHM`!W{j5@#nDKpw~ zU>)OG9NNKnZ@;yVZ6rJVH|oTfhdrM0kScq^A(wq?2G2uYYKCMaCOmK-H1?G6g#OIGD|%v3Z}DEaB(!z!ZXsu z&5jj^>g?SvPNmKSmu#SjYfBbV#J5Xcp{HxfQKfFdSm{hSeKe8ketv-i+tS%oKcaLq z)o(3*UaPMjE4@vJp$3q{qw={_*RNtH)orRs)an9nTT!`@RA+pb1JqT9kz2c`%n_bc zUL`K!;bo#rpT3i(vl3cGuPb=JYP;Yp>_2U#jySeUfJrBCgFAyV^}Tmx{A0jnE07-F zFtyo&07z=hQV&BzEA{u#_MZ4|tZ53F5*IW#rRso5-rK=8ta@)XqagC+z^8Tg9Z?&!sU+ z)hUGsjBf>N&%a88HgG-{E8wC6pK5d1)ch7@KWvVn#L||;NehZ3rKN?Pt?yf!+172X zQDj3aFjdh4n6$z(ReEPorCLol3#fGl|F%ko_#bUy%#>gIGFLvcI#ar9UpEjyMSGCF zW{9C}N2dn=Z0AsN6f`u*@mydo78z(XAyDltu!S{hC$?|7niI&ORqcwO`6ITeStfW7 zgcsrse~31K=;cnFh>Td1*6Gm;9GVdW8U1!MQ&x(!Z(;gfkc1Am8nm3(bCge`2gh#6 zQ3X-shX;JOX-z`U;2d;UD*oB0L%AAVGZLjK z?DEY^I2LhBqil~8G=-`XLOVI+pTr>8LQ$0zzt8IQp}x}_Rq5nooi3~l7FEjx#gOp+ z2Eo_(*AH@1rTy1}S+_Tuk;e1!v}TFp#5bSA-5ipwCCuWrGlHxh!q=N? zE!XyN$ZG>pztf|bvVO}NIb^$u)B~P6L-cDw|Ij}B_8ej$)x21%JlWaxCFP*x%0~ zmu$Qw09vwjj)q?4(19GnHs5Nd-JlJ#3%3&X)2mj@gx56=y}X?;zuj)B)jfgP18)%a zkJoG&kUM2El(rKy-C@o3#i(6Fid;9o?)TfZAfPD{Yh0O;|!D~1O6;M|0u#|;2 zeMp9y4-vgjhr`eqC3n6>&j#;q=1m!zRe&|@;ONarv_nHm;n7V#NqkLsjBtY05I!YjH- -
    -
    +
    +
    diff --git a/vendor/built_in_modules/NewBlog/app/views/panel/blog/front_end/posts/index.html.erb b/vendor/built_in_modules/new_blog/app/views/panel/new_blog/front_end/posts/index.html.erb similarity index 65% rename from vendor/built_in_modules/NewBlog/app/views/panel/blog/front_end/posts/index.html.erb rename to vendor/built_in_modules/new_blog/app/views/panel/new_blog/front_end/posts/index.html.erb index aaa1d8ce..27f494c0 100644 --- a/vendor/built_in_modules/NewBlog/app/views/panel/blog/front_end/posts/index.html.erb +++ b/vendor/built_in_modules/new_blog/app/views/panel/new_blog/front_end/posts/index.html.erb @@ -1,6 +1,6 @@ <% content_for :secondary do %>
      -
    • <%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path, :class => 'seclink1' %>
    • +
    • <%= link_to t('blog.new_post'), new_panel_new_blog_back_end_post_path, :class => 'seclink1' %>
    <% end -%> diff --git a/vendor/built_in_modules/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb b/vendor/built_in_modules/new_blog/app/views/panel/new_blog/front_end/posts/show.html.erb similarity index 87% rename from vendor/built_in_modules/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb rename to vendor/built_in_modules/new_blog/app/views/panel/new_blog/front_end/posts/show.html.erb index 46842f96..50f8ef9e 100644 --- a/vendor/built_in_modules/NewBlog/app/views/panel/blog/front_end/posts/show.html.erb +++ b/vendor/built_in_modules/new_blog/app/views/panel/new_blog/front_end/posts/show.html.erb @@ -18,7 +18,7 @@

    <% end %> -<%= form_for Comment.new, :url => panel_blog_front_end_comments_path do |f| %> +<%= form_for Comment.new, :url => panel_new_blog_front_end_comments_path do |f| %>

    <%= f.label :name, "Author" %>
    diff --git a/vendor/built_in_modules/NewBlog/app/views/panel/blog/widget/posts/index.html.erb b/vendor/built_in_modules/new_blog/app/views/panel/new_blog/widget/posts/index.html.erb similarity index 64% rename from vendor/built_in_modules/NewBlog/app/views/panel/blog/widget/posts/index.html.erb rename to vendor/built_in_modules/new_blog/app/views/panel/new_blog/widget/posts/index.html.erb index 0ea7639f..41c8ccf8 100644 --- a/vendor/built_in_modules/NewBlog/app/views/panel/blog/widget/posts/index.html.erb +++ b/vendor/built_in_modules/new_blog/app/views/panel/new_blog/widget/posts/index.html.erb @@ -1,4 +1,4 @@ -<%=stylesheet_link_tag "NewBlog/application"%> +<%=stylesheet_link_tag "new_blog/application"%>

    @@ -8,7 +8,7 @@ <% @posts.each do |post| %> - + <% end %> diff --git a/vendor/built_in_modules/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb b/vendor/built_in_modules/new_blog/app/views/panel/new_blog/widget/posts/latest_post.html.erb similarity index 64% rename from vendor/built_in_modules/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb rename to vendor/built_in_modules/new_blog/app/views/panel/new_blog/widget/posts/latest_post.html.erb index 2312fc74..b4f62484 100644 --- a/vendor/built_in_modules/NewBlog/app/views/panel/blog/widget/posts/latest_post.html.erb +++ b/vendor/built_in_modules/new_blog/app/views/panel/new_blog/widget/posts/latest_post.html.erb @@ -1,4 +1,4 @@ -<%=stylesheet_link_tag "NewBlog/application"%> +<%=stylesheet_link_tag "new_blog/application"%>

    <%= @post.title %>

    diff --git a/vendor/built_in_modules/new_blog/config/initializers/app_config.rb b/vendor/built_in_modules/new_blog/config/initializers/app_config.rb new file mode 100644 index 00000000..c098b837 --- /dev/null +++ b/vendor/built_in_modules/new_blog/config/initializers/app_config.rb @@ -0,0 +1,18 @@ +# module NewBlog +# class MyEngine < Rails::Engine +# # Add a load path for this specific Engine +# # config.autoload_paths << File.expand_path("../lib/some/path", __FILE__) +# put "ABC" +# PrototypeR4::Application::Orbit_Apps << "NewBlog" +# +# # initializer "my_engine.add_middleware" do |app| +# # app.middleware.use MyEngine::Middleware +# # end +# end +# +# end +module NewBlog + VERSION = "0.0.1" + MOUDLEAPP_TITLE = "NewBlog" +end +# PrototypeR4::Application::Orbit_Apps << "NewBlog" \ No newline at end of file diff --git a/vendor/built_in_modules/NewBlog/config/locales/en.yml b/vendor/built_in_modules/new_blog/config/locales/en.yml similarity index 100% rename from vendor/built_in_modules/NewBlog/config/locales/en.yml rename to vendor/built_in_modules/new_blog/config/locales/en.yml diff --git a/vendor/built_in_modules/NewBlog/config/locales/zh_tw.yml b/vendor/built_in_modules/new_blog/config/locales/zh_tw.yml similarity index 100% rename from vendor/built_in_modules/NewBlog/config/locales/zh_tw.yml rename to vendor/built_in_modules/new_blog/config/locales/zh_tw.yml diff --git a/vendor/built_in_modules/new_blog/config/routes.rb b/vendor/built_in_modules/new_blog/config/routes.rb new file mode 100644 index 00000000..c5b65a18 --- /dev/null +++ b/vendor/built_in_modules/new_blog/config/routes.rb @@ -0,0 +1,25 @@ +Rails.application.routes.draw do + + namespace :panel do + namespace :new_blog do + namespace :back_end do + root :to => "posts#index" + resources :posts + resources :comments + end + namespace :front_end do + root :to => "posts#index" + match "show/:id" => "posts#show" ,:as => :post + match "comments" => "comments#create",:as => :comments + end + namespace :widget do + root :to => "posts#index" + match "latest_post" => "posts#latest_post" + end + end + end + + # match "appfront/blog/front_end/show/:id" => "posts#frontend_show" ,:as => :appfront_blog_show + + match "/appfront/*path" => redirect("/panel/*path") +end diff --git a/vendor/built_in_modules/new_blog/lib/NewBlog.rb b/vendor/built_in_modules/new_blog/lib/NewBlog.rb new file mode 100644 index 00000000..4b74cf74 --- /dev/null +++ b/vendor/built_in_modules/new_blog/lib/NewBlog.rb @@ -0,0 +1,5 @@ +require "new_blog/engine" + + +module NewBlog +end diff --git a/vendor/built_in_modules/NewBlog/lib/NewBlog/engine.rb b/vendor/built_in_modules/new_blog/lib/new_blog/engine.rb similarity index 64% rename from vendor/built_in_modules/NewBlog/lib/NewBlog/engine.rb rename to vendor/built_in_modules/new_blog/lib/new_blog/engine.rb index e0f0221c..6879f112 100644 --- a/vendor/built_in_modules/NewBlog/lib/NewBlog/engine.rb +++ b/vendor/built_in_modules/new_blog/lib/new_blog/engine.rb @@ -1,5 +1,5 @@ module NewBlog class Engine < Rails::Engine - isolate_namespace NewBlog + isolate_namespace new_blog end end diff --git a/vendor/built_in_modules/NewBlog/lib/NewBlog/version.rb b/vendor/built_in_modules/new_blog/lib/new_blog/version.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/lib/NewBlog/version.rb rename to vendor/built_in_modules/new_blog/lib/new_blog/version.rb diff --git a/vendor/built_in_modules/NewBlog/lib/tasks/NewBlog_tasks.rake b/vendor/built_in_modules/new_blog/lib/tasks/NewBlog_tasks.rake similarity index 100% rename from vendor/built_in_modules/NewBlog/lib/tasks/NewBlog_tasks.rake rename to vendor/built_in_modules/new_blog/lib/tasks/NewBlog_tasks.rake diff --git a/vendor/built_in_modules/NewBlog/NewBlog.gemspec b/vendor/built_in_modules/new_blog/new_blog.gemspec similarity index 100% rename from vendor/built_in_modules/NewBlog/NewBlog.gemspec rename to vendor/built_in_modules/new_blog/new_blog.gemspec diff --git a/vendor/built_in_modules/new_blog/new_blog.json b/vendor/built_in_modules/new_blog/new_blog.json new file mode 100755 index 00000000..ec18ee08 --- /dev/null +++ b/vendor/built_in_modules/new_blog/new_blog.json @@ -0,0 +1,12 @@ +{ + "title": "NewBlog", + "version": "0.1", + "organization": "Rulingcom", + "author": "RD dep", + "intro": "A simple blog……", + "update_info": "Some info", + "create_date": "11-11-2011", + "app_pages": ["/panel/new_blog/front_end/"], + "widgets": ["/panel/new_blog/widget/latest_post","/panel/new_blog/widget/"], + "enable_frontend": false +} diff --git a/vendor/built_in_modules/NewBlog/script/rails b/vendor/built_in_modules/new_blog/script/rails similarity index 100% rename from vendor/built_in_modules/NewBlog/script/rails rename to vendor/built_in_modules/new_blog/script/rails diff --git a/vendor/built_in_modules/NewBlog/test/NewBlog_test.rb b/vendor/built_in_modules/new_blog/test/NewBlog_test.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/NewBlog_test.rb rename to vendor/built_in_modules/new_blog/test/NewBlog_test.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/Rakefile b/vendor/built_in_modules/new_blog/test/dummy/Rakefile similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/Rakefile rename to vendor/built_in_modules/new_blog/test/dummy/Rakefile diff --git a/vendor/built_in_modules/NewBlog/test/dummy/app/assets/javascripts/application.js b/vendor/built_in_modules/new_blog/test/dummy/app/assets/javascripts/application.js similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/app/assets/javascripts/application.js rename to vendor/built_in_modules/new_blog/test/dummy/app/assets/javascripts/application.js diff --git a/vendor/built_in_modules/NewBlog/test/dummy/app/assets/stylesheets/application.css b/vendor/built_in_modules/new_blog/test/dummy/app/assets/stylesheets/application.css similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/app/assets/stylesheets/application.css rename to vendor/built_in_modules/new_blog/test/dummy/app/assets/stylesheets/application.css diff --git a/vendor/built_in_modules/NewBlog/test/dummy/app/controllers/application_controller.rb b/vendor/built_in_modules/new_blog/test/dummy/app/controllers/application_controller.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/app/controllers/application_controller.rb rename to vendor/built_in_modules/new_blog/test/dummy/app/controllers/application_controller.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/app/helpers/application_helper.rb b/vendor/built_in_modules/new_blog/test/dummy/app/helpers/application_helper.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/app/helpers/application_helper.rb rename to vendor/built_in_modules/new_blog/test/dummy/app/helpers/application_helper.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/app/mailers/.gitkeep b/vendor/built_in_modules/new_blog/test/dummy/app/mailers/.gitkeep similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/app/mailers/.gitkeep rename to vendor/built_in_modules/new_blog/test/dummy/app/mailers/.gitkeep diff --git a/vendor/built_in_modules/NewBlog/test/dummy/app/models/.gitkeep b/vendor/built_in_modules/new_blog/test/dummy/app/models/.gitkeep similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/app/models/.gitkeep rename to vendor/built_in_modules/new_blog/test/dummy/app/models/.gitkeep diff --git a/vendor/built_in_modules/NewBlog/test/dummy/app/views/layouts/application.html.erb b/vendor/built_in_modules/new_blog/test/dummy/app/views/layouts/application.html.erb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/app/views/layouts/application.html.erb rename to vendor/built_in_modules/new_blog/test/dummy/app/views/layouts/application.html.erb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config.ru b/vendor/built_in_modules/new_blog/test/dummy/config.ru similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config.ru rename to vendor/built_in_modules/new_blog/test/dummy/config.ru diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/application.rb b/vendor/built_in_modules/new_blog/test/dummy/config/application.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/application.rb rename to vendor/built_in_modules/new_blog/test/dummy/config/application.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/boot.rb b/vendor/built_in_modules/new_blog/test/dummy/config/boot.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/boot.rb rename to vendor/built_in_modules/new_blog/test/dummy/config/boot.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/database.yml b/vendor/built_in_modules/new_blog/test/dummy/config/database.yml similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/database.yml rename to vendor/built_in_modules/new_blog/test/dummy/config/database.yml diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/environment.rb b/vendor/built_in_modules/new_blog/test/dummy/config/environment.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/environment.rb rename to vendor/built_in_modules/new_blog/test/dummy/config/environment.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/environments/development.rb b/vendor/built_in_modules/new_blog/test/dummy/config/environments/development.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/environments/development.rb rename to vendor/built_in_modules/new_blog/test/dummy/config/environments/development.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/environments/production.rb b/vendor/built_in_modules/new_blog/test/dummy/config/environments/production.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/environments/production.rb rename to vendor/built_in_modules/new_blog/test/dummy/config/environments/production.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/environments/test.rb b/vendor/built_in_modules/new_blog/test/dummy/config/environments/test.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/environments/test.rb rename to vendor/built_in_modules/new_blog/test/dummy/config/environments/test.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/initializers/backtrace_silencers.rb b/vendor/built_in_modules/new_blog/test/dummy/config/initializers/backtrace_silencers.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/initializers/backtrace_silencers.rb rename to vendor/built_in_modules/new_blog/test/dummy/config/initializers/backtrace_silencers.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/initializers/inflections.rb b/vendor/built_in_modules/new_blog/test/dummy/config/initializers/inflections.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/initializers/inflections.rb rename to vendor/built_in_modules/new_blog/test/dummy/config/initializers/inflections.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/initializers/mime_types.rb b/vendor/built_in_modules/new_blog/test/dummy/config/initializers/mime_types.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/initializers/mime_types.rb rename to vendor/built_in_modules/new_blog/test/dummy/config/initializers/mime_types.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/initializers/secret_token.rb b/vendor/built_in_modules/new_blog/test/dummy/config/initializers/secret_token.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/initializers/secret_token.rb rename to vendor/built_in_modules/new_blog/test/dummy/config/initializers/secret_token.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/initializers/session_store.rb b/vendor/built_in_modules/new_blog/test/dummy/config/initializers/session_store.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/initializers/session_store.rb rename to vendor/built_in_modules/new_blog/test/dummy/config/initializers/session_store.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/initializers/wrap_parameters.rb b/vendor/built_in_modules/new_blog/test/dummy/config/initializers/wrap_parameters.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/initializers/wrap_parameters.rb rename to vendor/built_in_modules/new_blog/test/dummy/config/initializers/wrap_parameters.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/locales/en.yml b/vendor/built_in_modules/new_blog/test/dummy/config/locales/en.yml similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/locales/en.yml rename to vendor/built_in_modules/new_blog/test/dummy/config/locales/en.yml diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/mongoid.yml b/vendor/built_in_modules/new_blog/test/dummy/config/mongoid.yml similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/mongoid.yml rename to vendor/built_in_modules/new_blog/test/dummy/config/mongoid.yml diff --git a/vendor/built_in_modules/NewBlog/test/dummy/config/routes.rb b/vendor/built_in_modules/new_blog/test/dummy/config/routes.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/config/routes.rb rename to vendor/built_in_modules/new_blog/test/dummy/config/routes.rb diff --git a/vendor/built_in_modules/NewBlog/test/dummy/lib/assets/.gitkeep b/vendor/built_in_modules/new_blog/test/dummy/lib/assets/.gitkeep similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/lib/assets/.gitkeep rename to vendor/built_in_modules/new_blog/test/dummy/lib/assets/.gitkeep diff --git a/vendor/built_in_modules/NewBlog/test/dummy/log/.gitkeep b/vendor/built_in_modules/new_blog/test/dummy/log/.gitkeep similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/log/.gitkeep rename to vendor/built_in_modules/new_blog/test/dummy/log/.gitkeep diff --git a/vendor/built_in_modules/NewBlog/test/dummy/public/404.html b/vendor/built_in_modules/new_blog/test/dummy/public/404.html similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/public/404.html rename to vendor/built_in_modules/new_blog/test/dummy/public/404.html diff --git a/vendor/built_in_modules/NewBlog/test/dummy/public/422.html b/vendor/built_in_modules/new_blog/test/dummy/public/422.html similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/public/422.html rename to vendor/built_in_modules/new_blog/test/dummy/public/422.html diff --git a/vendor/built_in_modules/NewBlog/test/dummy/public/500.html b/vendor/built_in_modules/new_blog/test/dummy/public/500.html similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/public/500.html rename to vendor/built_in_modules/new_blog/test/dummy/public/500.html diff --git a/vendor/built_in_modules/NewBlog/test/dummy/public/favicon.ico b/vendor/built_in_modules/new_blog/test/dummy/public/favicon.ico similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/public/favicon.ico rename to vendor/built_in_modules/new_blog/test/dummy/public/favicon.ico diff --git a/vendor/built_in_modules/NewBlog/test/dummy/script/rails b/vendor/built_in_modules/new_blog/test/dummy/script/rails similarity index 100% rename from vendor/built_in_modules/NewBlog/test/dummy/script/rails rename to vendor/built_in_modules/new_blog/test/dummy/script/rails diff --git a/vendor/built_in_modules/NewBlog/test/integration/navigation_test.rb b/vendor/built_in_modules/new_blog/test/integration/navigation_test.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/integration/navigation_test.rb rename to vendor/built_in_modules/new_blog/test/integration/navigation_test.rb diff --git a/vendor/built_in_modules/NewBlog/test/test_helper.rb b/vendor/built_in_modules/new_blog/test/test_helper.rb similarity index 100% rename from vendor/built_in_modules/NewBlog/test/test_helper.rb rename to vendor/built_in_modules/new_blog/test/test_helper.rb From 3d9fd359edb6b9abed77a710929e55dc8de5b4ae Mon Sep 17 00:00:00 2001 From: Matthew Fu Date: Tue, 10 Jan 2012 18:30:08 +0800 Subject: [PATCH 19/20] Moving Orbit frontend and widget controller to controllers folder --- lib/obit_widget_controller.rb | 6 ----- vendor/built_in_modules/NewBlog/NewBlog.json | 11 -------- .../blog/front_end/comments_controller.rb | 7 ------ .../panel/blog/front_end/posts_controller.rb | 21 ---------------- .../NewBlog/config/initializers/app_config.rb | 18 ------------- .../built_in_modules/NewBlog/config/routes.rb | 25 ------------------- 6 files changed, 88 deletions(-) delete mode 100644 lib/obit_widget_controller.rb delete mode 100755 vendor/built_in_modules/NewBlog/NewBlog.json delete mode 100644 vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/comments_controller.rb delete mode 100644 vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb delete mode 100644 vendor/built_in_modules/NewBlog/config/initializers/app_config.rb delete mode 100644 vendor/built_in_modules/NewBlog/config/routes.rb diff --git a/lib/obit_widget_controller.rb b/lib/obit_widget_controller.rb deleted file mode 100644 index c9789775..00000000 --- a/lib/obit_widget_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ObitWidgetController< ApplicationController - before_filter {|c| c.front_end_available(@app_title)} - layout 'production' - - -end \ No newline at end of file diff --git a/vendor/built_in_modules/NewBlog/NewBlog.json b/vendor/built_in_modules/NewBlog/NewBlog.json deleted file mode 100755 index 32734d3b..00000000 --- a/vendor/built_in_modules/NewBlog/NewBlog.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "title": "NewBlog", - "version": "0.1", - "organization": "Rulingcom", - "author": "RD dep", - "intro": "A simple blog……", - "update_info": "Some info", - "create_date": "11-11-2011", - "app_pages": ["/panel/blog/front_end/"], - "widgets": ["/panel/blog/widget/latest_post","/panel/blog/widget/"] -} diff --git a/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/comments_controller.rb b/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/comments_controller.rb deleted file mode 100644 index 78a28b01..00000000 --- a/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/comments_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class Panel::Blog::FrontEnd::CommentsController < ApplicationController - def create - @post = Post.find(params[:post_id]) - @comment = @post.comments.create!(params[:comment]) - redirect_to panel_blog_front_end_post_url(@post) - end -end \ No newline at end of file diff --git a/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb b/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb deleted file mode 100644 index fd83cc34..00000000 --- a/vendor/built_in_modules/NewBlog/app/controllers/panel/blog/front_end/posts_controller.rb +++ /dev/null @@ -1,21 +0,0 @@ -class Panel::Blog::FrontEnd::PostsController < ObitWidgetController - - - def initialize - super - @app_title = NewBlog::MOUDLEAPP_TITLE - end - - # GET /posts - # GET /posts.xml - - def index - @posts = Post.all - end - - def show - @post = Post.find(params[:id]) - end - - -end diff --git a/vendor/built_in_modules/NewBlog/config/initializers/app_config.rb b/vendor/built_in_modules/NewBlog/config/initializers/app_config.rb deleted file mode 100644 index b218d15d..00000000 --- a/vendor/built_in_modules/NewBlog/config/initializers/app_config.rb +++ /dev/null @@ -1,18 +0,0 @@ -# module NewBlog -# class MyEngine < Rails::Engine -# # Add a load path for this specific Engine -# # config.autoload_paths << File.expand_path("../lib/some/path", __FILE__) -# put "ABC" -# PrototypeR4::Application::Orbit_Apps << "NewBlog" -# -# # initializer "my_engine.add_middleware" do |app| -# # app.middleware.use MyEngine::Middleware -# # end -# end -# -# end -module NewBlog - VERSION = "0.0.1" - MOUDLEAPP_TITLE = "NewBlog" -end -PrototypeR4::Application::Orbit_Apps << "NewBlog" \ No newline at end of file diff --git a/vendor/built_in_modules/NewBlog/config/routes.rb b/vendor/built_in_modules/NewBlog/config/routes.rb deleted file mode 100644 index 22cef244..00000000 --- a/vendor/built_in_modules/NewBlog/config/routes.rb +++ /dev/null @@ -1,25 +0,0 @@ -Rails.application.routes.draw do - - namespace :panel do - namespace :blog do - namespace :back_end do - root :to => "posts#index" - resources :posts - resources :comments - end - namespace :front_end do - root :to => "posts#index" - match "show/:id" => "posts#show" ,:as => :post - match "comments" => "comments#create",:as => :comments - end - namespace :widget do - root :to => "posts#index" - match "latest_post" => "posts#latest_post" - end - end - end - - # match "appfront/blog/front_end/show/:id" => "posts#frontend_show" ,:as => :appfront_blog_show - - match "/appfront/*path" => redirect("/panel/*path") -end From c0efb5d1bcc28077652a022817ed32d8cc37fabe Mon Sep 17 00:00:00 2001 From: Matthew Fu Date: Thu, 12 Jan 2012 14:13:41 +0800 Subject: [PATCH 20/20] Listing for Module-apps --- app/controllers/admin/app_auths_controller.rb | 17 ++-- .../admin/module_apps_controller.rb | 18 +++++ app/helpers/admin/app_auth_helper.rb | 6 ++ app/views/admin/app_auths/index.html.erb | 80 ++++++++++++------- 4 files changed, 83 insertions(+), 38 deletions(-) create mode 100644 app/helpers/admin/app_auth_helper.rb diff --git a/app/controllers/admin/app_auths_controller.rb b/app/controllers/admin/app_auths_controller.rb index f2c01451..e925b857 100644 --- a/app/controllers/admin/app_auths_controller.rb +++ b/app/controllers/admin/app_auths_controller.rb @@ -4,14 +4,15 @@ class Admin::AppAuthsController < ApplicationController before_filter :is_admin? def index - @roles = Role.all.entries - apps = Purchase.where(:type =>"App") - @app_auth_data = apps.entries.map do |app| - app_c = eval(app.app_controller) - obj = app_c.new - obj_auth = obj.send "auth" - [:app_obj => app,:auth_field => obj_auth] - end + # @roles = Role.all.entries + # apps = Purchase.where(:type =>"App") + # @app_auth_data = apps.entries.map do |app| + # app_c = eval(app.app_controller) + # obj = app_c.new + # obj_auth = obj.send "auth" + # [:app_obj => app,:auth_field => obj_auth] + # end + @module_apps = ModuleApp.all end end \ No newline at end of file diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb index 98683345..142830f1 100644 --- a/app/controllers/admin/module_apps_controller.rb +++ b/app/controllers/admin/module_apps_controller.rb @@ -12,4 +12,22 @@ class Admin::ModuleAppsController < ApplicationController format.js {} end end + + def edit + @module_app = ModuleApp.find(params[:id]) + + end + + def update + @module_app = ModuleApp.find(params[:id]) + unless params['module_app']['enable_frontend'].nil? + @module_app.update_attribute('enable_frontend',params['module_app']['enable_frontend']) + @module_app.save! + end + @attribute = @module_app + respond_to do |format| + format.html { redirect_to :action => :index } + format.js { render 'admin/attributes/toggle_enable' } + end + end end \ No newline at end of file diff --git a/app/helpers/admin/app_auth_helper.rb b/app/helpers/admin/app_auth_helper.rb new file mode 100644 index 00000000..fe63a2a6 --- /dev/null +++ b/app/helpers/admin/app_auth_helper.rb @@ -0,0 +1,6 @@ +module Admin::AppAuthHelper + def on_off_switch(attribute,attribute_type) + link_to t(:enable), eval("admin_#{attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' + link_to t(:disable), eval("admin_#{attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' + end +end \ No newline at end of file diff --git a/app/views/admin/app_auths/index.html.erb b/app/views/admin/app_auths/index.html.erb index 0d804b2b..392f8d2b 100644 --- a/app/views/admin/app_auths/index.html.erb +++ b/app/views/admin/app_auths/index.html.erb @@ -1,32 +1,52 @@ <% content_for :secondary do %> -

    -
    -

    User Role

    -
      - <% @roles.each do |role| %> -
    • <%= link_to content_tag(:span, "Role") %>
    • - <% end -%> -
    -
    -
    -<% end -%> - -

    <%= t('admin.list_app_auths') %>

    - -
    <%= link_to post.title,panel_blog_front_end_post_path(post) %><%= link_to post.title,panel_new_blog_front_end_post_path(post) %> <%= post.body.truncate(14) %>
    - - - - - -<% @app_auth_data.each do |app| %> - - - <% app[0][:auth_field].each do |unit| %> - - <%end%> - + <% #render 'side_bar' %> <% end %> -
    <%= t('admin.app.name') %><%= t('admin.description') %>
    <%= app[0][:app_obj].title %> - <%= render :partial => "auth_unit",:locals => {:unit => unit } %> -
    + +
    + <%= flash_messages %> +
    + <% #link_to t('admin.new_user'), new_admin_user_path, :class => 'new' %> +
    + + + + + + + + + + + + + + <% @module_apps.each do |module_app| %> + "> + + + + + + + + + + + + <% end %> + +
    <%= t('admin.app.title') %><%= t('admin.app.description') %><%= t('admin.app.use_status') %><%= t('admin.app.autdor') %><%= t('admin.app.organization') %><%= t('admin.app.version') %><%= t('admin.action') %>
    <%= module_app.title %><%= module_app.intro %> + <% attribute_type = "module_app" %> + <% attribute = module_app %> + <%= link_to t(:enable), admin_module_app_path(attribute, :authenticity_token => form_authenticity_token, :module_app => {:enable_frontend => true}), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.enable_frontend ? 'none' : ''}", :class => 'switch' %> + <%= link_to t(:disable), admin_module_app_path(attribute, :authenticity_token => form_authenticity_token, :module_app => {:enable_frontend => false}), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.enable_frontend ? '' : 'none'}", :class => 'switch' %> + + <%= module_app.version %> + <%= link_to t(:show), admin_module_app_path(module_app), :class => 'show' %> + <%= link_to t(:edit), edit_admin_module_app_path(module_app), :class => 'edit' %> + <%= link_to t(:delete), admin_module_app_path(module_app), :class => 'delete', :confirm => t('sure?'), :method => :delete %> +
    +
    + <%# link_to t('admin.new_user'), new_admin_user_path, :class => 'new' %> +
    +