+ <%= cookie_policy_script %>
+ <%= render 'footer' %>
diff --git a/app/views/layouts/doorkeeper/application.html.erb b/app/views/layouts/doorkeeper/application.html.erb
index 562005af0..92ebab311 100644
--- a/app/views/layouts/doorkeeper/application.html.erb
+++ b/app/views/layouts/doorkeeper/application.html.erb
@@ -1,23 +1,15 @@
+<% title t('doorkeeper.layouts.application.title') %>
-
-
-
-
- <%= stylesheet_link_tag "doorkeeper/application" %>
- <%= csrf_meta_tags %>
-
-
-
- <%- if flash[:notice].present? %>
-
- <%= flash[:notice] %>
+
+<%= render 'head' %>
+
+
+
+ <%= link_to root_path do %>
+ <%= image_tag("logo.svg", alt: "fablabs.io") %>
+ <% end %>
- <% end -%>
-
- <%= yield %>
-
+ <%= yield %>
+
diff --git a/bin/bundle b/bin/bundle
index f19acf5b5..50da5fdf9 100755
--- a/bin/bundle
+++ b/bin/bundle
@@ -1,3 +1,109 @@
#!/usr/bin/env ruby
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
-load Gem.bin_path('bundler', 'bundle')
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'bundle' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "rubygems"
+
+m = Module.new do
+ module_function
+
+ def invoked_as_script?
+ File.expand_path($0) == File.expand_path(__FILE__)
+ end
+
+ def env_var_version
+ ENV["BUNDLER_VERSION"]
+ end
+
+ def cli_arg_version
+ return unless invoked_as_script? # don't want to hijack other binstubs
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
+ bundler_version = nil
+ update_index = nil
+ ARGV.each_with_index do |a, i|
+ if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
+ bundler_version = a
+ end
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
+ bundler_version = $1
+ update_index = i
+ end
+ bundler_version
+ end
+
+ def gemfile
+ gemfile = ENV["BUNDLE_GEMFILE"]
+ return gemfile if gemfile && !gemfile.empty?
+
+ File.expand_path("../Gemfile", __dir__)
+ end
+
+ def lockfile
+ lockfile =
+ case File.basename(gemfile)
+ when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
+ else "#{gemfile}.lock"
+ end
+ File.expand_path(lockfile)
+ end
+
+ def lockfile_version
+ return unless File.file?(lockfile)
+ lockfile_contents = File.read(lockfile)
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
+ Regexp.last_match(1)
+ end
+
+ def bundler_requirement
+ @bundler_requirement ||=
+ env_var_version ||
+ cli_arg_version ||
+ bundler_requirement_for(lockfile_version)
+ end
+
+ def bundler_requirement_for(version)
+ return "#{Gem::Requirement.default}.a" unless version
+
+ bundler_gem_version = Gem::Version.new(version)
+
+ bundler_gem_version.approximate_recommendation
+ end
+
+ def load_bundler!
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
+
+ activate_bundler
+ end
+
+ def activate_bundler
+ gem_error = activation_error_handling do
+ gem "bundler", bundler_requirement
+ end
+ return if gem_error.nil?
+ require_error = activation_error_handling do
+ require "bundler/version"
+ end
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
+ exit 42
+ end
+
+ def activation_error_handling
+ yield
+ nil
+ rescue StandardError, LoadError => e
+ e
+ end
+end
+
+m.load_bundler!
+
+if m.invoked_as_script?
+ load Gem.bin_path("bundler", "bundle")
+end
diff --git a/bin/ci b/bin/ci
new file mode 100755
index 000000000..4137ad5bb
--- /dev/null
+++ b/bin/ci
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+require_relative "../config/boot"
+require "active_support/continuous_integration"
+
+CI = ActiveSupport::ContinuousIntegration
+require_relative "../config/ci.rb"
diff --git a/bin/dev b/bin/dev
new file mode 100755
index 000000000..5f91c2054
--- /dev/null
+++ b/bin/dev
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+exec "./bin/rails", "server", *ARGV
diff --git a/bin/setup b/bin/setup
index aaaf20ef6..0e9fbf0de 100755
--- a/bin/setup
+++ b/bin/setup
@@ -14,7 +14,6 @@ FileUtils.chdir APP_ROOT do
# Add necessary setup steps to this file.
puts "== Installing dependencies =="
- system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")
# puts "\n== Copying sample files =="
@@ -24,14 +23,14 @@ FileUtils.chdir APP_ROOT do
puts "\n== Preparing database =="
system! "bin/rails db:prepare"
+ system! "bin/rails db:reset" if ARGV.include?("--reset")
puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear"
- puts "\n== Restarting application server =="
- system! "bin/rails restart"
-
- # puts "\n== Configuring puma-dev =="
- # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
- # system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
+ unless ARGV.include?("--skip-server")
+ puts "\n== Starting development server =="
+ STDOUT.flush # flush the output before exec(2) so that it displays
+ exec "bin/dev"
+ end
end
diff --git a/config/application.rb b/config/application.rb
index d13fb9c28..877ce1f04 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -12,7 +12,6 @@
# require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
-require "sprockets/railtie"
require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
@@ -22,7 +21,7 @@
module Fablabs
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
- config.load_defaults 7.2
+ config.load_defaults 8.0
# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
@@ -60,23 +59,6 @@ class Application < Rails::Application
g.integration_specs true
end
- config.action_mailer.default_url_options = { host: 'www.fablabs.io', protocol: 'https' }
- config.action_mailer.delivery_method = :smtp
- config.action_mailer.perform_deliveries = true
- config.action_mailer.raise_delivery_errors = true
- config.action_mailer.smtp_settings = {
- authentication: ENV['EMAIL_AUTHENTICATION'],
- address: ENV['EMAIL_ADDRESS'],
- port: ENV['EMAIL_PORT'].to_i,
- domain: ENV['EMAIL_DOMAIN'],
- user_name: ENV['EMAIL_USERNAME'],
- password: ENV['EMAIL_PASSWORD']
- }
-
- config.assets.paths << Rails.root.join('vendor', 'assets')
-
- config.sass.silence_deprecations = ['import','global-builtin']
-
config.app_generators.scaffold_controller = :scaffold_controller
end
end
diff --git a/config/ci.rb b/config/ci.rb
new file mode 100644
index 000000000..1dcd62ed8
--- /dev/null
+++ b/config/ci.rb
@@ -0,0 +1,20 @@
+# Run using bin/ci
+
+CI.run do
+ step "Setup", "bin/setup --skip-server"
+
+ step "Security: Importmap vulnerability audit", "bin/importmap audit"
+ step "Tests: Rails", "bin/rails test"
+ step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant"
+
+ # Optional: Run system tests
+ # step "Tests: System", "bin/rails test:system"
+
+ # Optional: set a green GitHub commit status to unblock PR merge.
+ # Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`.
+ # if success?
+ # step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
+ # else
+ # failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again."
+ # end
+end
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 5197892f3..2556bc17e 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -5,9 +5,7 @@
config.hosts.clear
- # In the development environment your application's code is reloaded any time
- # it changes. This slows down response time but is perfect for development
- # since you don't have to restart the web server when you make code changes.
+ # Make code changes take effect immediately without server restart.
config.enable_reloading = true
# Do not eager load code on boot.
@@ -19,49 +17,46 @@
# Enable server timing.
config.server_timing = true
- # Enable/disable caching. By default caching is disabled.
- # Run rails dev:cache to toggle caching.
+ # Enable/disable Action Controller caching. By default Action Controller caching is disabled.
+ # Run rails dev:cache to toggle Action Controller caching.
if Rails.root.join("tmp/caching-dev.txt").exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
-
- config.cache_store = :memory_store
- config.public_file_server.headers = {
- "Cache-Control" => "public, max-age=#{2.days.to_i}"
- }
+ config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
else
config.action_controller.perform_caching = false
-
- config.cache_store = :null_store
end
+ # Change to :null_store to avoid any caching.
+ config.cache_store = :memory_store
+
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
- # Disable caching for Action Mailer templates even if Action Controller
- # caching is enabled.
+ # Make template changes take effect immediately.
config.action_mailer.perform_caching = false
+ # Set localhost to be used by links generated in mailer templates.
config.action_mailer.default_url_options = { host: "www.fablabs.local", port: 3000 }
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
- # Raise exceptions for disallowed deprecations.
- config.active_support.disallowed_deprecation = :raise
-
- # Tell Active Support which deprecation messages to disallow.
- config.active_support.disallowed_deprecation_warnings = []
-
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
+ # Append comments with runtime information tags to SQL queries in logs.
+ config.active_record.query_log_tags_enabled = true
+
# Highlight code that enqueued background job in logs.
config.active_job.verbose_enqueue_logs = true
+ # Highlight code that triggered redirect in logs.
+ config.action_dispatch.verbose_redirect_logs = true
+
# Suppress logger output for asset requests.
config.assets.quiet = true
@@ -69,7 +64,6 @@
# config.i18n.raise_on_missing_translations = true
# Annotate rendered view with file names.
- # config.action_view.annotate_rendered_view_with_filenames = true
config.action_view.annotate_rendered_view_with_filenames = true
# Use an evented file watcher to asynchronously detect changes in source code,
diff --git a/config/environments/production.rb b/config/environments/production.rb
index e3541a45d..d140d2a77 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -10,47 +10,26 @@
# Code is not reloaded between requests.
config.enable_reloading = false
- # Eager load code on boot. This eager loads most of Rails and
- # your application in memory, allowing both threaded web servers
- # and those relying on copy on write to perform better.
- # Rake tasks automatically ignore this option for performance.
+ # Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
config.eager_load = true
- # Full error reports are disabled and caching is turned on.
+ # Full error reports are disabled.
config.consider_all_requests_local = false
- config.action_controller.perform_caching = true
- # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
- # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
- # config.require_master_key = true
+ # Turn on fragment caching in view templates.
+ config.action_controller.perform_caching = true
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
- # Compress JavaScripts and CSS.
- config.assets.js_compressor = :uglifier
-
- # Compress CSS using a preprocessor.
- # config.assets.css_compressor = :sass
-
- # Do not fall back to assets pipeline if a precompiled asset is missed.
- config.assets.compile = false
+ # Cache assets for far-future expiry since they are all digest stamped.
+ config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" }
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = "http://assets.example.com"
- # Specifies the header that your server uses for sending files.
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
- # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
-
- # Mount Action Cable outside main process or domain.
- # config.action_cable.mount_path = nil
- # config.action_cable.url = "wss://example.com/cable"
- # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
-
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
- # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
- # config.assume_ssl = true
+ config.assume_ssl = true
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true
@@ -58,42 +37,50 @@
# Skip http-to-https redirect for the default health check endpoint.
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
- # Log to STDOUT by default
- config.logger = ActiveSupport::Logger.new(STDOUT)
- .tap { |logger| logger.formatter = ::Logger::Formatter.new }
- .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
-
- # Prepend all log lines with the following tags.
+ # Log to STDOUT with the current request id as a default log tag.
config.log_tags = [ :request_id ]
+ config.logger = ActiveSupport::TaggedLogging.logger(STDOUT)
- # "info" includes generic and useful information about system operation, but avoids logging too much
- # information to avoid inadvertent exposure of personally identifiable information (PII). If you
- # want to log everything, set the level to "debug".
+ # Change to "debug" to log everything (including potentially personally-identifiable information!).
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
- # Use a different cache store in production.
+ # Prevent health checks from clogging up the logs.
+ config.silence_healthcheck_path = "/up"
+
+ # Don't log any deprecations.
+ config.active_support.report_deprecations = false
+
+ # Replace the default in-process memory cache store with a durable alternative.
# config.cache_store = :mem_cache_store
config.cache_store = :redis_cache_store, { url: ENV["REDIS_URL"] }
- # Use a real queuing backend for Active Job (and separate queues per environment).
+ # Replace the default in-process and non-durable queuing backend for Active Job.
# config.active_job.queue_adapter = :resque
- # config.active_job.queue_name_prefix = "fablabs_production"
- # Disable caching for Action Mailer templates even if Action Controller
- # caching is enabled.
- config.action_mailer.perform_caching = false
+ config.action_mailer.delivery_method = :smtp
+ config.action_mailer.perform_deliveries = true
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
- # config.action_mailer.raise_delivery_errors = false
+ config.action_mailer.raise_delivery_errors = true
+
+ # Set host to be used by links generated in mailer templates.
+ config.action_mailer.default_url_options = { host: 'www.fablabs.io', protocol: 'https' }
+
+ # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
+ config.action_mailer.smtp_settings = {
+ authentication: ENV['EMAIL_AUTHENTICATION'],
+ address: ENV['EMAIL_ADDRESS'],
+ port: ENV['EMAIL_PORT'].to_i,
+ domain: ENV['EMAIL_DOMAIN'],
+ user_name: ENV['EMAIL_USERNAME'],
+ password: ENV['EMAIL_PASSWORD']
+ }
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
- # Don't log any deprecations.
- config.active_support.report_deprecations = false
-
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
@@ -105,6 +92,7 @@
# "example.com", # Allow requests from example.com
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
# ]
+ #
# Skip DNS rebinding protection for the default health check endpoint.
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
end
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 29779dbd2..0bb0b3e21 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -1,5 +1,3 @@
-require "active_support/core_ext/integer/time"
-
# 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
@@ -17,15 +15,11 @@
# loading is working properly before deploying your code.
config.eager_load = ENV["CI"].present?
- # Configure public file server for tests with Cache-Control for performance.
- config.public_file_server.enabled = true
- config.public_file_server.headers = {
- "Cache-Control" => "public, max-age=#{1.hour.to_i}"
- }
+ # Configure public file server for tests with cache-control for performance.
+ config.public_file_server.headers = { "cache-control" => "public, max-age=3600" }
- # Show full error reports and disable caching.
+ # Show full error reports.
config.consider_all_requests_local = true
- config.action_controller.perform_caching = false
config.cache_store = :null_store
# Render exception templates for rescuable exceptions and raise for other exceptions.
@@ -34,28 +28,17 @@
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
- # Disable caching for Action Mailer templates even if Action Controller
- # caching is enabled.
- config.action_mailer.perform_caching = 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
- # Unlike controllers, the mailer instance doesn't have any context about the
- # incoming request so you'll need to provide the :host parameter yourself.
- config.action_mailer.default_url_options = { host: "www.fablabs.io" }
+ # Set host to be used by links generated in mailer templates.
+ config.action_mailer.default_url_options = { host: "example.com" }
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
- # Raise exceptions for disallowed deprecations.
- config.active_support.disallowed_deprecation = :raise
-
- # Tell Active Support which deprecation messages to disallow.
- config.active_support.disallowed_deprecation_warnings = []
-
# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true
diff --git a/config/initializers/active_admin.rb b/config/initializers/active_admin.rb
index 402840d3b..d3c1ad953 100644
--- a/config/initializers/active_admin.rb
+++ b/config/initializers/active_admin.rb
@@ -2,21 +2,28 @@
# == Site Title
#
# Set the title that is displayed on the main layout
- # for each of the active admin pages.
+ # for each of the active admin pages. Can also be customized
+ # by extracting the _site_header partial into your project
+ # to use your own logo, styles, etc.
#
config.site_title = "Fablabs"
- # Set the link url for the title. For example, to take
- # users to your main site. Defaults to no link.
+ # == Load Paths
#
- # config.site_title_link = "/"
-
- # Set an optional image to be displayed for the header
- # instead of a string (overrides :site_title)
+ # By default Active Admin files go inside app/admin/.
+ # You can change this directory.
+ #
+ # eg:
+ # config.load_paths = [File.join(Rails.root, 'app', 'ui')]
#
- # Note: Aim for an image that's 21px high so it fits in the header.
+ # Or, you can also load more directories.
+ # Useful when setting namespaces with users that are not your main AdminUser entity.
#
- # config.site_title_image = "logo.png"
+ # eg:
+ # config.load_paths = [
+ # File.join(Rails.root, 'app', 'admin'),
+ # File.join(Rails.root, 'app', 'cashier')
+ # ]
# == Default Namespace
#
@@ -61,8 +68,10 @@
# Active Admin will automatically call an authorization
# method in a before filter of all controller actions to
# ensure that there is a user with proper rights. You can use
- # CanCanAdapter or make your own. Please refer to documentation.
+ # CanCanAdapter, PunditAdapter, or make your own. Please
+ # refer to the documentation.
# config.authorization_adapter = ActiveAdmin::CanCanAdapter
+ # config.authorization_adapter = ActiveAdmin::PunditAdapter
# In case you prefer Pundit over other solutions you can here pass
# the name of default policy class. This policy will be used in every
@@ -99,18 +108,13 @@
# settings configure the location and method used for the link.
#
# This setting changes the path where the link points to. If it's
- # a string, the strings is used as the path. If it's a Symbol, we
+ # a string, the string is used as the path. If it's a Symbol, we
# will call the method to return the path.
#
# Default:
+ # config.logout_link_path = :destroy_admin_user_session_path
config.logout_link_path = "signout"
- # This setting changes the http method used when rendering the
- # link. For example :get, :delete, :put, etc..
- #
- # Default:
- config.logout_link_method = :get
-
# == Root
#
# Set the action to call for the root path. You can set different
@@ -170,23 +174,6 @@
#
config.localize_format = :long
- # == Setting a Favicon
- #
- # config.favicon = 'favicon.ico'
-
- # == Meta Tags
- #
- # Add additional meta tags to the head element of active admin pages.
- #
- # Add tags to all pages logged in users see:
- # config.meta_tags = { author: 'My Company' }
-
- # By default, sign up/sign in/recover password pages are excluded
- # from showing up in search engine results by adding a robots meta
- # tag. You can reset the hash of meta tags included in logged out
- # pages:
- # config.meta_tags_for_logged_out_pages = {}
-
# == Removing Breadcrumbs
#
# Breadcrumbs are enabled by default. You can customize them for individual
@@ -201,21 +188,6 @@
#
# config.create_another = true
- # == Register Stylesheets & Javascripts
- #
- # We recommend using the built in Active Admin layout and loading
- # up your own stylesheets / javascripts to customize the look
- # and feel.
- #
- # To load a stylesheet:
- # config.register_stylesheet 'my_stylesheet.css'
- #
- # You can provide an options hash for more control, which is passed along to stylesheet_link_tag():
- # config.register_stylesheet 'my_print_stylesheet.css', media: :print
- #
- # To load a javascript file:
- # config.register_javascript 'my_javascript.js'
-
# == CSV options
#
# Set the CSV builder separator
@@ -228,20 +200,11 @@
#
# You can add a navigation menu to be used in your application, or configure a provided menu
#
- # To change the default utility navigation to show a link to your website & a logout btn
- #
- # config.namespace :admin do |admin|
- # admin.build_menu :utility_navigation do |menu|
- # menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
- # admin.add_logout_button_to_menu menu
- # end
- # end
- #
# If you wanted to add a static menu item to the default menu provided:
#
# config.namespace :admin do |admin|
# admin.build_menu :default do |menu|
- # menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
+ # menu.add label: "My Great Website", url: "https://mygreatwebsite.example.com", html_options: { target: "_blank" }
# end
# end
@@ -257,11 +220,10 @@
# # Disable the links entirely
# admin.download_links = false
#
- # # Only show XML & PDF options
+ # # Only show XML & PDF options. You must register the format mime type with `Mime::Type.register`.
# admin.download_links = [:xml, :pdf]
#
- # # Enable/disable the links based on block
- # # (for example, with cancan)
+ # # Enable/disable the links based on block (for example, with cancan)
# admin.download_links = proc { can?(:view_download_links) }
#
# end
@@ -303,21 +265,7 @@
# :title,
# :email,
# ]
- # config.filter_method_for_large_association = '_starts_with'
-
- # == Head
- #
- # You can add your own content to the site head like analytics. Make sure
- # you only pass content you trust.
- #
- # config.head = ''.html_safe
-
- # == Footer
- #
- # By default, the footer shows the current Active Admin version. You can
- # override the content of the footer here.
- #
- # config.footer = 'my custom footer text'
+ # config.filter_method_for_large_association = '_start'
# == Sorting
#
@@ -325,11 +273,4 @@
# You can inherit it with own class and inject it for all resources
#
# config.order_clause = MyOrderClause
-
- # == Webpacker
- #
- # By default, Active Admin uses Sprocket's asset pipeline.
- # You can switch to using Webpacker here.
- #
- # config.use_webpacker = true
end
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index d929f7800..e50a4d8fe 100644
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -5,10 +5,5 @@
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
-# Add Yarn node_modules folder to the asset load path.
-Rails.application.config.assets.paths << Rails.root.join('node_modules')
-# Precompile additional assets.
-# application.js, application.css, and all non-JS/CSS in the app/assets
-# folder are already added.
-# Rails.application.config.assets.precompile += %w[ admin.js admin.css ]
+Rails.application.config.assets.paths << Rails.root.join("app", "assets", "stylesheets", "fontawesome")
diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb
index b3076b38f..d51d71397 100644
--- a/config/initializers/content_security_policy.rb
+++ b/config/initializers/content_security_policy.rb
@@ -20,6 +20,10 @@
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
# config.content_security_policy_nonce_directives = %w(script-src style-src)
#
+# # Automatically add `nonce` to `javascript_tag`, `javascript_include_tag`, and `stylesheet_link_tag`
+# # if the corresponding directives are specified in `content_security_policy_nonce_directives`.
+# # config.content_security_policy_nonce_auto = true
+#
# # Report violations without enforcing the policy.
# # config.content_security_policy_report_only = true
# end
diff --git a/config/initializers/css_precompile_hook.rb b/config/initializers/css_precompile_hook.rb
new file mode 100644
index 000000000..44766a57f
--- /dev/null
+++ b/config/initializers/css_precompile_hook.rb
@@ -0,0 +1,6 @@
+if Rake::Task.task_defined?("assets:precompile")
+ Rake::Task["assets:precompile"].enhance do
+ puts "Building Admin CSS..."
+ system("yarn run build:css:activeadmin")
+ end
+end
diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb
index 549b05ddd..f07826f94 100644
--- a/config/initializers/doorkeeper.rb
+++ b/config/initializers/doorkeeper.rb
@@ -1,13 +1,24 @@
+# frozen_string_literal: true
+
Doorkeeper.configure do
- # Change the ORM that doorkeeper will use.
- # Currently supported options are :active_record, :mongoid2, :mongoid3, :mongo_mapper
+ # Change the ORM that doorkeeper will use (requires ORM extensions installed).
+ # Check the list of supported ORMs here: https://github.com/doorkeeper-gem/doorkeeper#orms
orm :active_record
- base_controller 'ApplicationController'
-
- # custom model class
- application_class "Doorkeeper::Application"
-
+ # Enable support for multiple database configurations with read replicas.
+ # When enabled, Doorkeeper will wrap database write operations to ensure they
+ # use the primary (writable) database when automatic role switching is enabled.
+ #
+ # For ActiveRecord (Rails 6.1+), this uses `ActiveRecord::Base.connected_to(role: :writing)`.
+ # Other ORM extensions can implement their own primary database targeting logic.
+ #
+ # enable_multiple_database_roles
+ #
+ # This prevents `ActiveRecord::ReadOnlyError` when using read replicas with Rails
+ # automatic role switching. Enable this if your application uses multiple databases
+ # with automatic role switching for read replicas.
+ #
+ # See: https://guides.rubyonrails.org/active_record_multiple_databases.html#activating-automatic-role-switching
# This block will be called to check whether the resource owner is authenticated or not.
resource_owner_authenticator do
@@ -33,56 +44,514 @@
end
end
- # Authorization Code expiration time (default 10 minutes).
+ # You can use your own model classes if you need to extend (or even override) default
+ # Doorkeeper models such as `Application`, `AccessToken` and `AccessGrant.
+ #
+ # By default Doorkeeper ActiveRecord ORM uses its own classes:
+ #
+ # access_token_class "Doorkeeper::AccessToken"
+ # access_grant_class "Doorkeeper::AccessGrant"
+ application_class "Doorkeeper::Application"
+ #
+ # Don't forget to include Doorkeeper ORM mixins into your custom models:
+ #
+ # * ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessToken - for access token
+ # * ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessGrant - for access grant
+ # * ::Doorkeeper::Orm::ActiveRecord::Mixins::Application - for application (OAuth2 clients)
+ #
+ # For example:
+ #
+ # access_token_class "MyAccessToken"
+ #
+ # class MyAccessToken < ApplicationRecord
+ # include ::Doorkeeper::Orm::ActiveRecord::Mixins::AccessToken
+ #
+ # self.table_name = "hey_i_wanna_my_name"
+ #
+ # def destroy_me!
+ # destroy
+ # end
+ # end
+
+ # Enables polymorphic Resource Owner association for Access Tokens and Access Grants.
+ # By default this option is disabled.
+ #
+ # Make sure you properly setup you database and have all the required columns (run
+ # `bundle exec rails generate doorkeeper:enable_polymorphic_resource_owner` and execute Rails
+ # migrations).
+ #
+ # If this option enabled, Doorkeeper will store not only Resource Owner primary key
+ # value, but also it's type (class name). See "Polymorphic Associations" section of
+ # Rails guides: https://guides.rubyonrails.org/association_basics.html#polymorphic-associations
+ #
+ # [NOTE] If you apply this option on already existing project don't forget to manually
+ # update `resource_owner_type` column in the database and fix migration template as it will
+ # set NOT NULL constraint for Access Grants table.
+ #
+ # use_polymorphic_resource_owner
+
+ # If you are planning to use Doorkeeper in Rails 5 API-only application, then you might
+ # want to use API mode that will skip all the views management and change the way how
+ # Doorkeeper responds to a requests.
+ #
+ # api_only
+
+ # Enforce token request content type to application/x-www-form-urlencoded.
+ # It is not enabled by default to not break prior versions of the gem.
+ #
+ # enforce_content_type
+
+ # Authorization Code expiration time (default: 10 minutes).
+ #
authorization_code_expires_in 10.minutes
- # Access token expiration time (default 2 hours).
- # If you want to disable expiration, set this to nil.
- access_token_expires_in #2.hours
+ # Access token expiration time (default: 2 hours).
+ # If you set this to `nil` Doorkeeper will not expire the token and omit expires_in in response.
+ # It is RECOMMENDED to set expiration time explicitly.
+ # Prefer access_token_expires_in 100.years or similar,
+ # which would be functionally equivalent and avoid the risk of unexpected behavior by callers.
+ #
+ access_token_expires_in 2.hours
+
+ # Assign custom TTL for access tokens. Will be used instead of access_token_expires_in
+ # option if defined. In case the block returns `nil` value Doorkeeper fallbacks to
+ # +access_token_expires_in+ configuration option value. If you really need to issue a
+ # non-expiring access token (which is not recommended) then you need to return
+ # Float::INFINITY from this block.
+ #
+ # `context` has the following properties available:
+ #
+ # * `client` - the OAuth client application (see Doorkeeper::OAuth::Client)
+ # * `grant_type` - the grant type of the request (see Doorkeeper::OAuth)
+ # * `scopes` - the requested scopes (see Doorkeeper::OAuth::Scopes)
+ # * `resource_owner` - authorized resource owner instance (if present)
+ #
+ # custom_access_token_expires_in do |context|
+ # context.client.additional_settings.implicit_oauth_expiration
+ # end
+
+ # Use a custom class for generating the access token.
+ # See https://doorkeeper.gitbook.io/guides/configuration/other-configurations#custom-access-token-generator
+ #
+ # access_token_generator '::Doorkeeper::JWT'
+ # The controller +Doorkeeper::ApplicationController+ inherits from.
+ # Defaults to +ActionController::Base+ unless +api_only+ is set, which changes the default to
+ # +ActionController::API+. The return value of this option must be a stringified class name.
+ # See https://doorkeeper.gitbook.io/guides/configuration/other-configurations#custom-controllers
+ #
+ base_controller 'ApplicationController'
+
+ # Reuse access token for the same resource owner within an application (disabled by default).
+ #
+ # This option protects your application from creating new tokens before old **valid** one becomes
+ # expired so your database doesn't bloat. Keep in mind that when this option is enabled Doorkeeper
+ # doesn't update existing token expiration time, it will create a new token instead if no active matching
+ # token found for the application, resources owner and/or set of scopes.
+ # Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/383
+ #
+ # You can not enable this option together with +hash_token_secrets+.
+ #
reuse_access_token
- # Issue access tokens with refresh token (disabled by default)
+ # In case you enabled `reuse_access_token` option Doorkeeper will try to find matching
+ # token using `matching_token_for` Access Token API that searches for valid records
+ # in batches in order not to pollute the memory with all the database records. By default
+ # Doorkeeper uses batch size of 10 000 records. You can increase or decrease this value
+ # depending on your needs and server capabilities.
+ #
+ # token_lookup_batch_size 10_000
+
+ # Set a limit for token_reuse if using reuse_access_token option
+ #
+ # This option limits token_reusability to some extent.
+ # If not set then access_token will be reused unless it expires.
+ # Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/1189
+ #
+ # This option should be a percentage(i.e. (0,100])
+ #
+ # token_reuse_limit 100
+
+ # Only allow one valid access token obtained via client credentials
+ # per client. If a new access token is obtained before the old one
+ # expired, the old one gets revoked (disabled by default)
+ #
+ # When enabling this option, make sure that you do not expect multiple processes
+ # using the same credentials at the same time (e.g. web servers spanning
+ # multiple machines and/or processes).
+ #
+ # revoke_previous_client_credentials_token
+
+ # Only allow one valid access token obtained via authorization code
+ # per client. If a new access token is obtained before the old one
+ # expired, the old one gets revoked (disabled by default)
+ #
+ # revoke_previous_authorization_code_token
+
+ # Require non-confidential clients to use PKCE when using an authorization code
+ # to obtain an access_token (disabled by default)
+ #
+ # force_pkce
+
+ # Hash access and refresh tokens before persisting them.
+ # This will disable the possibility to use +reuse_access_token+
+ # since plain values can no longer be retrieved.
+ #
+ # Note: If you are already a user of doorkeeper and have existing tokens
+ # in your installation, they will be invalid without adding 'fallback: :plain'.
+ #
+ # hash_token_secrets
+ # By default, token secrets will be hashed using the
+ # +Doorkeeper::Hashing::SHA256+ strategy.
+ #
+ # If you wish to use another hashing implementation, you can override
+ # this strategy as follows:
+ #
+ # hash_token_secrets using: '::Doorkeeper::Hashing::MyCustomHashImpl'
+ #
+ # Keep in mind that changing the hashing function will invalidate all existing
+ # secrets, if there are any.
+
+ # Hash application secrets before persisting them.
+ #
+ # hash_application_secrets
+ #
+ # By default, applications will be hashed
+ # with the +Doorkeeper::SecretStoring::SHA256+ strategy.
+ #
+ # If you wish to use bcrypt for application secret hashing, uncomment
+ # this line instead:
+ #
+ # hash_application_secrets using: '::Doorkeeper::SecretStoring::BCrypt'
+
+ # When the above option is enabled, and a hashed token or secret is not found,
+ # you can allow to fall back to another strategy. For users upgrading
+ # doorkeeper and wishing to enable hashing, you will probably want to enable
+ # the fallback to plain tokens.
+ #
+ # This will ensure that old access tokens and secrets
+ # will remain valid even if the hashing above is enabled.
+ #
+ # This can be done by adding 'fallback: plain', e.g. :
+ #
+ # hash_application_secrets using: '::Doorkeeper::SecretStoring::BCrypt', fallback: :plain
+
+ # Issue access tokens with refresh token (disabled by default), you may also
+ # pass a block which accepts `context` to customize when to give a refresh
+ # token or not. Similar to +custom_access_token_expires_in+, `context` has
+ # the following properties:
+ #
+ # `client` - the OAuth client application (see Doorkeeper::OAuth::Client)
+ # `grant_type` - the grant type of the request (see Doorkeeper::OAuth)
+ # `scopes` - the requested scopes (see Doorkeeper::OAuth::Scopes)
+ #
# use_refresh_token
# Provide support for an owner to be assigned to each registered application (disabled by default)
- # Optional parameter :confirmation => true (default false) if you want to enforce ownership of
+ # Optional parameter confirmation: true (default: false) if you want to enforce ownership of
# a registered application
- # Note: you must also run the rails g doorkeeper:application_owner generator to provide the necessary support
- enable_application_owner :confirmation => true
+ # NOTE: you must also run the rails g doorkeeper:application_owner generator
+ # to provide the necessary support
+ #
+ enable_application_owner confirmation: false
# Define access token scopes for your provider
- # For more information go to https://github.com/applicake/doorkeeper/wiki/Using-Scopes
+ # For more information go to
+ # https://doorkeeper.gitbook.io/guides/ruby-on-rails/scopes
+ #
default_scopes :public
# optional_scopes :write, :update
+ # Allows to restrict only certain scopes for grant_type.
+ # By default, all the scopes will be available for all the grant types.
+ #
+ # Keys to this hash should be the name of grant_type and
+ # values should be the array of scopes for that grant type.
+ # Note: scopes should be from configured_scopes (i.e. default or optional)
+ #
+ # scopes_by_grant_type password: [:write], client_credentials: [:update]
+
+ # Forbids creating/updating applications with arbitrary scopes that are
+ # not in configuration, i.e. +default_scopes+ or +optional_scopes+.
+ # (disabled by default)
+ #
+ # enforce_configured_scopes
+
# Change the way client credentials are retrieved from the request object.
# By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
# falls back to the `:client_id` and `:client_secret` params from the `params` object.
- # Check out the wiki for more information on customization
+ # Check out https://github.com/doorkeeper-gem/doorkeeper/wiki/Changing-how-clients-are-authenticated
+ # for more information on customization
+ #
+ # NOTE: configuring a callable extractor opts the request out of the RFC 6749
+ # §2.3 checks that reject a request authenticating the client with more than
+ # one method, or presenting more than one client identity. A callable may
+ # legitimately overlap the built-in extractors, and the extractors after the
+ # matching one are never called, so what they would have returned is unknown.
+ # Prefer the symbol extractors unless you need something they cannot express;
+ # a callable has to reject such a request itself.
+ #
# client_credentials :from_basic, :from_params
# Change the way access token is authenticated from the request object.
# By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
# falls back to the `:access_token` or `:bearer_token` params from the `params` object.
- # Check out the wiki for more information on customization
+ # Check out https://github.com/doorkeeper-gem/doorkeeper/wiki/Changing-how-clients-are-authenticated
+ # for more information on customization
+ #
# access_token_methods :from_bearer_authorization, :from_access_token_param, :from_bearer_param
- # # Change the test redirect uri for client apps
- # # When clients register with the following redirect uri, they won't be redirected to any server and the authorization code will be displayed within the provider
- # # The value can be any string. Use nil to disable this feature. When disabled, clients must provide a valid URL
- # # (Similar behaviour: https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi)
- # #
- #test_redirect_uri nil#'urn:ietf:wg:oauth:2.0:oob'
+ # Forces the usage of the HTTPS protocol in non-native redirect uris (enabled
+ # by default in non-development environments). OAuth2 delegates security in
+ # communication to the HTTPS protocol so it is wise to keep this enabled.
+ #
+ # Callable objects such as proc, lambda, block or any object that responds to
+ # #call can be used in order to allow conditional checks (to allow non-SSL
+ # redirects to localhost for example).
+ #
+ # force_ssl_in_redirect_uri !Rails.env.development?
+ #
+ # force_ssl_in_redirect_uri { |uri| uri.host != 'localhost' }
force_ssl_in_redirect_uri false
+ # Specify what redirect URI's you want to block during Application creation.
+ # Any redirect URI is allowed by default.
+ #
+ # Redirect URIs with a script scheme (`javascript`, `vbscript`, `data`) are
+ # always rejected, regardless of this option.
+ #
+ # You can use this option in order to forbid URI's of a particular host
+ # for example.
+ #
+ # forbid_redirect_uri { |uri| uri.host == 'example.com' }
- # # Under some circumstances you might want to have applications auto-approved,
- # # so that the user skips the authorization step.
- # # For example if dealing with trusted a application.
+ # Allows to set blank redirect URIs for Applications in case Doorkeeper configured
+ # to use URI-less OAuth grant flows like Client Credentials or Resource Owner
+ # Password Credentials. The option is on by default and checks configured grant
+ # types, but you **need** to manually drop `NOT NULL` constraint from `redirect_uri`
+ # column for `oauth_applications` database table.
+ #
+ # You can completely disable this feature with:
+ #
+ # allow_blank_redirect_uri false
+ #
+ # Or you can define your custom check:
+ #
+ # allow_blank_redirect_uri do |grant_flows, client|
+ # client.superapp?
+ # end
+
+ # Specify how authorization errors should be handled.
+ # By default, doorkeeper renders json errors when access token
+ # is invalid, expired, revoked or has invalid scopes.
+ #
+ # If you want to render error response yourself (i.e. rescue exceptions),
+ # set +handle_auth_errors+ to `:raise` and rescue Doorkeeper::Errors::InvalidToken
+ # or following specific errors:
+ #
+ # Doorkeeper::Errors::TokenForbidden, Doorkeeper::Errors::TokenExpired,
+ # Doorkeeper::Errors::TokenRevoked, Doorkeeper::Errors::TokenUnknown
+ #
+ # handle_auth_errors :raise
+ #
+ # If you want to redirect back to the client application in accordance with
+ # https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2.1, you can set
+ # +handle_auth_errors+ to :redirect
+ #
+ # handle_auth_errors :redirect
+
+ # Customize token introspection response.
+ # Allows to add your own fields to default one that are required by the OAuth spec
+ # for the introspection response. It could be `sub`, `aud` and so on.
+ # This configuration option can be a proc, lambda or any Ruby object responds
+ # to `.call` method and result of it's invocation must be a Hash.
+ #
+ # custom_introspection_response do |token, context|
+ # {
+ # "sub": "Z5O3upPC88QrAjx00dis",
+ # "aud": "https://protected.example.net/resource",
+ # "username": User.find(token.resource_owner_id).username
+ # }
+ # end
+ #
+ # or
+ #
+ # custom_introspection_response CustomIntrospectionResponder
+
+ # Specify what grant flows are enabled in array of Strings. The valid
+ # strings and the flows they enable are:
+ #
+ # "authorization_code" => Authorization Code Grant Flow
+ # "implicit" => Implicit Grant Flow
+ # "password" => Resource Owner Password Credentials Grant Flow
+ # "client_credentials" => Client Credentials Grant Flow
+ #
+ # If not specified, Doorkeeper enables authorization_code and
+ # client_credentials.
+ #
+ # implicit and password grant flows have risks that you should understand
+ # before enabling:
+ # https://datatracker.ietf.org/doc/html/rfc6819#section-4.4.2
+ # https://datatracker.ietf.org/doc/html/rfc6819#section-4.4.3
+ #
+ # grant_flows %w[authorization_code client_credentials]
+
+ # Allows to customize OAuth grant flows that +each+ application support.
+ # You can configure a custom block (or use a class respond to `#call`) that must
+ # return `true` in case Application instance supports requested OAuth grant flow
+ # during the authorization request to the server. This configuration +doesn't+
+ # set flows per application, it only allows to check if application supports
+ # specific grant flow.
+ #
+ # For example you can add an additional database column to `oauth_applications` table,
+ # say `t.array :grant_flows, default: []`, and store allowed grant flows that can
+ # be used with this application there. Then when authorization requested Doorkeeper
+ # will call this block to check if specific Application (passed with client_id and/or
+ # client_secret) is allowed to perform the request for the specific grant type
+ # (authorization, password, client_credentials, etc).
+ #
+ # Example of the block:
+ #
+ # ->(flow, client) { client.grant_flows.include?(flow) }
+ #
+ # In case this option invocation result is `false`, Doorkeeper server returns
+ # :unauthorized_client error and stops the request.
+ #
+ # @param allow_grant_flow_for_client [Proc] Block or any object respond to #call
+ # @return [Boolean] `true` if allow or `false` if forbid the request
+ #
+ # allow_grant_flow_for_client do |grant_flow, client|
+ # # `grant_flows` is an Array column with grant
+ # # flows that application supports
+ #
+ # client.grant_flows.include?(grant_flow)
+ # end
+
+ # If you need arbitrary Resource Owner-Client authorization you can enable this option
+ # and implement the check your need. Config option must respond to #call and return
+ # true in case resource owner authorized for the specific application or false in other
+ # cases.
+ #
+ # By default all Resource Owners are authorized to any Client (application).
+ #
+ # authorize_resource_owner_for_client do |client, resource_owner|
+ # resource_owner.admin? || client.owners_allowlist.include?(resource_owner)
+ # end
+
+ # Allows additional data fields to be sent while granting access to an application,
+ # and for this additional data to be included in subsequently generated access tokens.
+ # The 'authorizations/new' page will need to be overridden to include this additional data
+ # in the request params when granting access. The access grant and access token models
+ # will both need to respond to these additional data fields, and have a database column
+ # to store them in.
+ #
+ # Example:
+ # You have a multi-tenanted platform and want to be able to grant access to a specific
+ # tenant, rather than all the tenants a user has access to. You can use this config
+ # option to specify that a ':tenant_id' will be passed when authorizing. This tenant_id
+ # will be included in the access tokens. When a request is made with one of these access
+ # tokens, you can check that the requested data belongs to the specified tenant.
+ #
+ # Default value is an empty Array: []
+ # custom_access_token_attributes [:tenant_id]
+
+ # Hook into the strategies' request & response life-cycle in case your
+ # application needs advanced customization or logging:
+ #
+ # before_successful_strategy_response do |request|
+ # puts "BEFORE HOOK FIRED! #{request}"
+ # end
+ #
+ # after_successful_strategy_response do |request, response|
+ # puts "AFTER HOOK FIRED! #{request}, #{response}"
+ # end
+
+ # Hook into Authorization flow in order to implement Single Sign Out
+ # or add any other functionality. Inside the block you have an access
+ # to `controller` (authorizations controller instance) and `context`
+ # (Doorkeeper::OAuth::Hooks::Context instance) which provides pre auth
+ # or auth objects with issued token based on hook type (before or after).
+ #
+ # before_successful_authorization do |controller, context|
+ # Rails.logger.info(controller.request.params.inspect)
+ #
+ # Rails.logger.info(context.pre_auth.inspect)
+ # end
+ #
+ # after_successful_authorization do |controller, context|
+ # controller.session[:logout_urls] <<
+ # Doorkeeper::Application
+ # .find_by(controller.request.params.slice(:redirect_uri))
+ # .logout_uri
+ #
+ # Rails.logger.info(context.auth.inspect)
+ # Rails.logger.info(context.issued_token)
+ # end
+
+ # Under some circumstances you might want to have applications auto-approved,
+ # so that the user skips the authorization step.
+ # For example if dealing with a trusted application.
+ #
skip_authorization do |resource_owner, client|
false
- # client.superapp? or resource_owner.admin?
end
+
+ # Configure custom constraints for the Token Introspection request.
+ # By default this configuration option allows to introspect a token by another
+ # token of the same application, OR to introspect the token that belongs to
+ # authorized client (from authenticated client) OR when token doesn't
+ # belong to any client (public token). Otherwise requester has no access to the
+ # introspection and it will return response as stated in the RFC.
+ #
+ # Block arguments:
+ #
+ # @param token [Doorkeeper::AccessToken]
+ # token to be introspected
+ #
+ # @param authorized_client [Doorkeeper::Application]
+ # authorized client (if request is authorized using Basic auth with
+ # Client Credentials for example)
+ #
+ # @param authorized_token [Doorkeeper::AccessToken]
+ # Bearer token used to authorize the request
+ #
+ # In case the block returns `nil` or `false` introspection responses with 401 status code
+ # when using authorized token to introspect, or you'll get 200 with { "active": false } body
+ # when using authorized client to introspect as stated in the
+ # RFC 7662 section 2.2. Introspection Response.
+ #
+ # Using with caution:
+ # Keep in mind that these three parameters pass to block can be nil as following case:
+ # `authorized_client` is nil if and only if `authorized_token` is present, and vice versa.
+ # `token` will be nil if and only if `authorized_token` is present.
+ # So remember to use `&` or check if it is present before calling method on
+ # them to make sure you doesn't get NoMethodError exception.
+ #
+ # You can define your custom check:
+ #
+ # allow_token_introspection do |token, authorized_client, authorized_token|
+ # if authorized_token
+ # # customize: require `introspection` scope
+ # authorized_token.application == token&.application ||
+ # authorized_token.scopes.include?("introspection")
+ # elsif token.application
+ # # `protected_resource` is a new database boolean column, for example
+ # authorized_client == token.application || authorized_client.protected_resource?
+ # else
+ # # public token (when token.application is nil, token doesn't belong to any application)
+ # true
+ # end
+ # end
+ #
+ # Or you can completely disable any token introspection:
+ #
+ # allow_token_introspection false
+ #
+ # If you need to block the request at all, then configure your routes.rb or web-server
+ # like nginx to forbid the request.
+
+ # WWW-Authenticate Realm (default: "Doorkeeper").
+ #
+ # realm "Doorkeeper"
end
diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb
index 004dcef91..d79f6d6ea 100644
--- a/config/initializers/filter_parameter_logging.rb
+++ b/config/initializers/filter_parameter_logging.rb
@@ -4,7 +4,7 @@
# Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
Rails.application.config.filter_parameters += [
- :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
+ :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc
]
Rails.application.config.filter_parameters += [
diff --git a/config/initializers/new_framework_defaults_8_1.rb b/config/initializers/new_framework_defaults_8_1.rb
new file mode 100644
index 000000000..8569b5b1c
--- /dev/null
+++ b/config/initializers/new_framework_defaults_8_1.rb
@@ -0,0 +1,74 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file eases your Rails 8.1 framework defaults upgrade.
+#
+# Uncomment each configuration one by one to switch to the new default.
+# Once your application is ready to run with all new defaults, you can remove
+# this file and set the `config.load_defaults` to `8.1`.
+#
+# Read the Guide for Upgrading Ruby on Rails for more info on each option.
+# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
+
+###
+# Skips escaping HTML entities and line separators. When set to `false`, the
+# JSON renderer no longer escapes these to improve performance.
+#
+# Example:
+# class PostsController < ApplicationController
+# def index
+# render json: { key: "\u2028\u2029<>&" }
+# end
+# end
+#
+# Renders `{"key":"\u2028\u2029\u003c\u003e\u0026"}` with the previous default, but `{"key":"
<>&"}` with the config
+# set to `false`.
+#
+# Applications that want to keep the escaping behavior can set the config to `true`.
+#++
+# Rails.configuration.action_controller.escape_json_responses = false
+
+###
+# Skips escaping LINE SEPARATOR (U+2028) and PARAGRAPH SEPARATOR (U+2029) in JSON.
+#
+# Historically these characters were not valid inside JavaScript literal strings but that changed in ECMAScript 2019.
+# As such it's no longer a concern in modern browsers: https://caniuse.com/mdn-javascript_builtins_json_json_superset.
+#++
+# Rails.configuration.active_support.escape_js_separators_in_json = false
+
+###
+# Raises an error when order dependent finder methods (e.g. `#first`, `#second`) are called without `order` values
+# on the relation, and the model does not have any order columns (`implicit_order_column`, `query_constraints`, or
+# `primary_key`) to fall back on.
+#
+# The current behavior of not raising an error has been deprecated, and this configuration option will be removed in
+# Rails 8.2.
+#++
+# Rails.configuration.active_record.raise_on_missing_required_finder_order_columns = true
+
+###
+# Controls how Rails handles path relative URL redirects.
+# When set to `:raise`, Rails will raise an `ActionController::Redirecting::UnsafeRedirectError`
+# for relative URLs without a leading slash, which can help prevent open redirect vulnerabilities.
+#
+# Example:
+# redirect_to "example.com" # Raises UnsafeRedirectError
+# redirect_to "@attacker.com" # Raises UnsafeRedirectError
+# redirect_to "/safe/path" # Works correctly
+#
+# Applications that want to allow these redirects can set the config to `:log` (previous default)
+# to only log warnings, or `:notify` to send ActiveSupport notifications.
+#++
+# Rails.configuration.action_controller.action_on_path_relative_redirect = :raise
+
+###
+# Use a Ruby parser to track dependencies between Action View templates
+#++
+# Rails.configuration.action_view.render_tracker = :ruby
+
+###
+# When enabled, hidden inputs generated by `form_tag`, `token_tag`, `method_tag`, and the hidden parameter fields
+# included in `button_to` forms will omit the `autocomplete="off"` attribute.
+#
+# Applications that want to keep generating the `autocomplete` attribute for those tags can set it to `false`.
+#++
+# Rails.configuration.action_view.remove_hidden_field_autocomplete = true
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 413d48020..0524cda96 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -27,7 +27,8 @@ de:
home:
around_the_world: Weltweit
beyond_that: Und außerdem?
- fab_labs_description: Fab Labs bieten Zugang zu modernen Entwicklungsmethoden.
+ fab_labs_description: |
+ Fab Labs bieten Zugang zu modernen Entwicklungsmethoden.
Was als Projekt am Center for Bits and Atoms (CBA) des MIT begann, wurde zu
einem weltweiten Netzwerk der Zusammenarbeit. Mehr Informationen über Fab
Labs findest du auf %{fab_foundation}. Das untenstehende Foto zeigt die Ausstattung
diff --git a/config/locales/doorkeeper.en.yml b/config/locales/doorkeeper.en.yml
index 95689e954..7444d9268 100644
--- a/config/locales/doorkeeper.en.yml
+++ b/config/locales/doorkeeper.en.yml
@@ -11,9 +11,12 @@ en:
redirect_uri:
fragment_present: 'cannot contain a fragment.'
invalid_uri: 'must be a valid URI.'
+ unspecified_scheme: 'must specify a scheme.'
relative_uri: 'must be an absolute URI.'
secured_uri: 'must be an HTTPS/SSL URI.'
forbidden_uri: 'is forbidden by the server.'
+ scopes:
+ not_match_configured: "doesn't match those configured on the server."
doorkeeper:
scopes:
@@ -31,38 +34,49 @@ en:
form:
error: 'Whoops! Check your form for possible errors'
help:
+ confidential: 'Application will be used where the client secret can be kept confidential. Native mobile apps and Single Page Apps are considered non-confidential.'
redirect_uri: 'Use one line per URI'
+ blank_redirect_uri: "Leave it blank if you configured your provider to use Client Credentials, Resource Owner Password Credentials or any other grant type that doesn't require a redirect URI."
scopes: 'Separate scopes with spaces. Leave blank to use the default scopes.'
edit:
- title: 'Edit application'
+ title: 'Edit OAuth application'
index:
- title: 'Your applications'
- new: 'New Application'
+ title: 'Your OAuth applications'
+ new: 'Create OAuth Application'
name: 'Name'
callback_url: 'Callback URL'
+ confidential: 'Confidential?'
+ actions: 'Actions'
+ confidentiality:
+ 'yes': 'Yes'
+ 'no': 'No'
new:
- title: 'New Application'
+ title: 'New OAuth Application'
show:
title: 'Application: %{name}'
- application_id: 'Application Id'
- secret: 'Secret'
- scopes: 'Scopes'
- callback_urls: 'Callback urls'
+ application_id: 'UID:'
+ secret: 'Secret:'
+ secret_hashed: 'Secret hashed'
+ scopes: 'Scopes:'
+ confidential: 'Confidential:'
+ callback_urls: 'Callback URLs:'
actions: 'Actions'
+ not_defined: 'Not defined'
authorizations:
buttons:
- authorize: 'Authorize for "%{for}"'
+ authorize: 'Authorize'
deny: 'Deny'
error:
title: 'An error has occurred'
new:
title: 'Authorization required'
- prompt: 'The %{client_name} app is requesting access to your account?'
- able_to: 'This application will be able to'
- redirect_to: 'Authorizing will redirect to'
+ prompt: 'Authorize %{client_name} to use your account?'
+ able_to: 'This application will be able to:'
show:
- title: 'Authorization code'
+ title: 'Authorization code:'
+ form_post:
+ title: 'Submit this form'
authorized_applications:
confirmations:
@@ -75,27 +89,37 @@ en:
created_at: 'Created At'
date_format: '%Y-%m-%d %H:%M:%S'
+ pre_authorization:
+ status: 'Pre-authorization'
+
errors:
messages:
# Common error messages
invalid_request:
unknown: 'The request is missing a required parameter, includes an unsupported parameter value, or is otherwise malformed.'
missing_param: 'Missing required parameter: %{value}.'
- not_support_pkce: 'Invalid code_verifier parameter. Server does not support pkce.'
- request_not_authorized: 'Request need to be authorized. Required parameter for authorizing request is missing or invalid.'
- invalid_redirect_uri: "The requested redirect uri is malformed or doesn't match client redirect URI."
+ request_not_authorized: 'Request needs to be authorized. Required parameter for authorizing the request is missing or invalid.'
+ invalid_code_challenge: 'Code challenge is required.'
+ multiple_client_auth_methods: 'The request utilizes more than one mechanism for authenticating the client.'
+ invalid_redirect_uri: "The requested redirect URI is malformed or doesn't match the client redirect URI."
unauthorized_client: 'The client is not authorized to perform this request using this method.'
access_denied: 'The resource owner or authorization server denied the request.'
invalid_scope: 'The requested scope is invalid, unknown, or malformed.'
+ invalid_code_challenge_method:
+ zero: 'The authorization server does not support PKCE as there are no accepted code_challenge_method values.'
+ one: 'The code_challenge_method must be %{challenge_methods}.'
+ other: 'The code_challenge_method must be one of %{challenge_methods}.'
server_error: 'The authorization server encountered an unexpected condition which prevented it from fulfilling the request.'
temporarily_unavailable: 'The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server.'
# Configuration error messages
credential_flow_not_configured: 'Resource Owner Password Credentials flow failed due to Doorkeeper.configure.resource_owner_from_credentials being unconfigured.'
resource_owner_authenticator_not_configured: 'Resource Owner find failed due to Doorkeeper.configure.resource_owner_authenticator being unconfigured.'
+ admin_authenticator_not_configured: 'Access to admin panel is forbidden due to Doorkeeper.configure.admin_authenticator being unconfigured.'
# Access grant errors
unsupported_response_type: 'The authorization server does not support this response type.'
+ unsupported_response_mode: 'The authorization server does not support this response mode.'
# Access token errors
invalid_client: 'Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.'
@@ -106,6 +130,11 @@ en:
revoked: "The access token was revoked"
expired: "The access token expired"
unknown: "The access token is invalid"
+ revoke:
+ unauthorized: "You are not authorized to revoke this token"
+
+ forbidden_token:
+ missing_scope: 'Access to this resource requires scope "%{oauth_scopes}".'
flash:
applications:
@@ -121,8 +150,9 @@ en:
layouts:
admin:
+ title: 'Doorkeeper'
nav:
- oauth2_provider: 'Fablabs.io Developer Console'
+ oauth2_provider: 'OAuth2 Provider'
applications: 'Applications'
home: 'Home'
application:
diff --git a/config/locales/en.yml b/config/locales/en.yml
index e12288f63..34e06d2af 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -22,7 +22,8 @@ en:
add_a_lab: Add Lab
all_countries: All countries
new:
- answer-1: In order to be listed on FabLabs.io, you have to fill the form below
+ answer-1: |
+ In order to be listed on FabLabs.io, you have to fill the form below
and discuss your ne Lab with 3 Referee Labs that you can choose in the form.
Please fill the details of the form below and choose 3 of the Referee Labs
available and contact them, they will approve you after you have exchanged
@@ -32,42 +33,54 @@ en:
list. It's not important that you already know them, it's important that you
start a discussion with them. We are doing this so that the connections among
the Labs (especially for new Labs) get strengthened.
- answer-2: Referee Labs might be busy, so it depends also on their time. Please
+ answer-2: |
+ Referee Labs might be busy, so it depends also on their time. Please
do not forget that being listed on FabLabs.io is not the only thing that makes
your lab a Fab Lab, you need to interact with the global Fab Lab network continuously
and not only when creating the application.
- answer-3: For the moment the process is simple, the important thing is to get
+ answer-3: |
+ For the moment the process is simple, the important thing is to get
in contact with the 3 Referee Labs you choose.
- answer-4: You can ask for support to the administrators and the whole community
+ answer-4: |
+ You can ask for support to the administrators and the whole community
in the Fablabs.io forum section. As soon as you create the application of
a Fab Lab here, a new thread about your Lab will be created in the forum.
answer-5: If you have technical issues, you can report them on GitHub.
faq: F.A.Q
- item-1: We have recently redesigned the Fab Lab approval process to minimise
+ item-1: |
+ We have recently redesigned the Fab Lab approval process to minimise
the waiting time for Labs to get approved.
- item-2: Each new Lab need to go through the referee approval process in order
+ item-2: |
+ Each new Lab need to go through the referee approval process in order
to get approved on the platform.
- item-3: Each Lab, need to select three Referee Labs during the application process.
+ item-3: |
+ Each Lab, need to select three Referee Labs during the application process.
These are trusted Labs on our platform. Please note that you can, but you
do not have to necessarily select, labs close to you geographically.
- item-4: Referees might request more info about your Lab. In this case you will
+ item-4: |
+ Referees might request more info about your Lab. In this case you will
receive an email inviting you to add more content to some sections of the
Lab form.
- item-5: Referees can also send a Lab for admin approval. In this case, it will
+ item-5: |
+ Referees can also send a Lab for admin approval. In this case, it will
be up to the platform admins to approve or not the new Lab.
- item-6: When submitted, is first assigned the "unverified" state. If one of
+ item-6: |
+ When submitted, is first assigned the "unverified" state. If one of
the referee gives their first approval the Lab is moved into the "referee
approval" state.
- item-7: If the Referee rejects, the Lab is moved to the "might need review"
+ item-7: |
+ If the Referee rejects, the Lab is moved to the "might need review"
state. Being in one of the two states doesn't guarantee approval, nor means
that the Lab will be rejected.
item-8: The Lab will be rejected or approved depending on the vote of the Referees.
question-1: How does the registration of a new Lab work?
- question-2: What is the average/ rough time-span for an new Lab to achieve the
+ question-2: |
+ What is the average/ rough time-span for an new Lab to achieve the
status of a "Fab Lab" on the list?
question-3: Are there multiple stages to complete the registration?
question-4: What can I do if I have problems with the registration process?
- we_are_in_the_process: We are in the process of improving the list of Fab Labs
+ we_are_in_the_process: |
+ We are in the process of improving the list of Fab Labs
and the approval process, which may change in the future. Before adding a
Lab sure to read the current approval process guidelines below.
show:
@@ -127,6 +140,7 @@ en:
'yes': 'Yes'
views:
header:
+ developer_console: OAuth Applications
events: Events
jobs: Jobs
labs: Labs
@@ -134,7 +148,7 @@ en:
me: Me
organizations: Orgs
projects: Projects
- search: "\U0001F50E Search, anything"
+ search: "🔎 Search, anything"
settings: Settings
home:
around_the_world: Around the world
@@ -144,11 +158,11 @@ en:
description: In order to build a global network, a distributed laboratory
for research and invention.
title: All Fab Labs share common tools and processes.
- fab_labs_description: Fab labs provide widespread access to modern means for
+ fab_labs_description: |
+ Fab labs provide widespread access to modern means for
invention. They began as an outreach project from MIT's Center for Bits and
Atoms (CBA), and became into a collaborative and global network. You can find
- more information about Fab Labs on the
Fab
- Foundation Website. The annotated photo below illustrates the facilities
+ more information about Fab Labs on the %{fab_foundation} Website. The annotated photo below illustrates the facilities
of a typical Fab Lab.
fablabs-section:
cta: See the full list
@@ -176,7 +190,8 @@ en:
the world
subtitle: Explore
title: I’m a Person
- quote: Because all Fab Labs share common tools and processes, the program is
+ quote: |
+ Because all Fab Labs share common tools and processes, the program is
building a global network, a distributed laboratory for research and invention.
welcome: Welcome
what_can_i_do: What can I do?
diff --git a/config/locales/es.yml b/config/locales/es.yml
index a857a48a0..0857bc8e9 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -35,7 +35,8 @@ es:
home:
around_the_world: Alrededor del mundo
beyond_that: Y más alla de eso?
- fab_labs_description: Los fab labs proporcionan acceso abierto a medios modernos
+ fab_labs_description: |
+ Los fab labs proporcionan acceso abierto a medios modernos
de invención. Empezaron como un proyecto de extension del Center for Bits
and Atoms del Massachusetts Institute of Technology, y se convirtió en una
red global y colaborativa. Puedes encontrar mas informacion sobre los Fab
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 48a586ee4..12711f306 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -26,7 +26,8 @@ fr:
home:
around_the_world: Autour du monde
beyond_that: Et ensuite?
- fab_labs_description: Les Fab Labs fournissent un accès global aux moyens modernes
+ fab_labs_description: |
+ Les Fab Labs fournissent un accès global aux moyens modernes
d''invention. Ils ont commencé comme un projet de sensibilisation du MIT Center
pour Bits and Atoms (CBA) et sont devenus un réseau global et collaboratif.
Vous pourrez trouver plus d''informations sur les Fab Labs sur %{fab_foundation}.
diff --git a/config/locales/is.yml b/config/locales/is.yml
index 4ffd02963..b1b2f8d0a 100644
--- a/config/locales/is.yml
+++ b/config/locales/is.yml
@@ -1,3 +1,4 @@
+---
is:
capabilities:
circuit_production: Circuit production
@@ -21,25 +22,54 @@ is:
add_a_lab: Bæta við smiðju
all_countries: Öll lönd
new:
- answer-1: In order to be listed on FabLabs.io, you have to fill the form below and discuss your ne Lab with 3 Referee Labs that you can choose in the form. Please fill the details of the form below and choose 3 of the Referee Labs available and contact them, they will approve you after you have exchanged more information with them. The list of Referee Labs is limited to some Fab Labs with experience and a history of collaborating with the global Fab Lab Network, at the moment it is not possible to choose Referee Labs outside that list. It's not important that you already know them, it's important that you start a discussion with them. We are doing this so that the connections among the Labs (especially for new Labs) get strengthened.
- answer-2: Referee Labs might be busy, so it depends also on their time. Please do not forget that being listed on FabLabs.io is not the only thing that makes your lab a Fab Lab, you need to interact with the global Fab Lab network continuously and not only when creating the application.
- answer-3: For the moment the process is simple, the important thing is to get in contact with the 3 Referee Labs you choose.
- answer-4: You can ask for support to the administrators and the whole community in the Fablabs.io forum section. As soon as you create the application of a Fab Lab here, a new thread about your Lab will be created in the forum.
+ answer-1: In order to be listed on FabLabs.io, you have to fill the form below
+ and discuss your ne Lab with 3 Referee Labs that you can choose in the form.
+ Please fill the details of the form below and choose 3 of the Referee Labs
+ available and contact them, they will approve you after you have exchanged
+ more information with them. The list of Referee Labs is limited to some Fab
+ Labs with experience and a history of collaborating with the global Fab Lab
+ Network, at the moment it is not possible to choose Referee Labs outside that
+ list. It's not important that you already know them, it's important that you
+ start a discussion with them. We are doing this so that the connections among
+ the Labs (especially for new Labs) get strengthened.
+ answer-2: Referee Labs might be busy, so it depends also on their time. Please
+ do not forget that being listed on FabLabs.io is not the only thing that makes
+ your lab a Fab Lab, you need to interact with the global Fab Lab network continuously
+ and not only when creating the application.
+ answer-3: For the moment the process is simple, the important thing is to get
+ in contact with the 3 Referee Labs you choose.
+ answer-4: You can ask for support to the administrators and the whole community
+ in the Fablabs.io forum section. As soon as you create the application of
+ a Fab Lab here, a new thread about your Lab will be created in the forum.
answer-5: If you have technical issues, you can report them on GitHub.
faq: F.A.Q
- item-1: We have recently redesigned the Fab Lab approval process to minimise the waiting time for Labs to get approved.
- item-2: Each new Lab need to go through the referee approval process in order to get approved on the platform.
- item-3: Each Lab, need to select three Referee Labs during the application process. These are trusted Labs on our platform. Please note that you can, but you do not have to necessarily select, labs close to you geographically.
- item-4: Referees might request more info about your Lab. In this case you will receive an email inviting you to add more content to some sections of the Lab form.
- item-5: Referees can also send a Lab for admin approval. In this case, it will be up to the platform admins to approve or not the new Lab.
- item-6: When submitted, is first assigned the "unverified" state. If one of the referee gives their first approval the Lab is moved into the "referee approval" state.
- item-7: If the Referee rejects, the Lab is moved to the "might need review" state. Being in one of the two states doesn't guarantee approval, nor means that the Lab will be rejected.
+ item-1: We have recently redesigned the Fab Lab approval process to minimise
+ the waiting time for Labs to get approved.
+ item-2: Each new Lab need to go through the referee approval process in order
+ to get approved on the platform.
+ item-3: Each Lab, need to select three Referee Labs during the application process.
+ These are trusted Labs on our platform. Please note that you can, but you
+ do not have to necessarily select, labs close to you geographically.
+ item-4: Referees might request more info about your Lab. In this case you will
+ receive an email inviting you to add more content to some sections of the
+ Lab form.
+ item-5: Referees can also send a Lab for admin approval. In this case, it will
+ be up to the platform admins to approve or not the new Lab.
+ item-6: When submitted, is first assigned the "unverified" state. If one of
+ the referee gives their first approval the Lab is moved into the "referee
+ approval" state.
+ item-7: If the Referee rejects, the Lab is moved to the "might need review"
+ state. Being in one of the two states doesn't guarantee approval, nor means
+ that the Lab will be rejected.
item-8: The Lab will be rejected or approved depending on the vote of the Referees.
question-1: How does the registration of a new Lab work?
- question-2: What is the average/ rough time-span for an new Lab to achieve the status of a "Fab Lab" on the list?
+ question-2: What is the average/ rough time-span for an new Lab to achieve the
+ status of a "Fab Lab" on the list?
question-3: Are there multiple stages to complete the registration?
question-4: What can I do if I have problems with the registration process?
- we_are_in_the_process: We are in the process of improving the list of Fab Labs and the approval process, which may change in the future. Before adding a Lab sure to read the current approval process guidelines below.
+ we_are_in_the_process: We are in the process of improving the list of Fab Labs
+ and the approval process, which may change in the future. Before adding a
+ Lab sure to read the current approval process guidelines below.
show:
nearby_labs: Nálægar smiðjur
machines:
@@ -59,7 +89,8 @@ is:
signed_in: Signed in.
signed_out: Signed out!
styleguide: Styleguide
- success_sign_up: Thanks for signing up. Please check your email to complete your registration!
+ success_sign_up: Thanks for signing up. Please check your email to complete your
+ registration!
simple_form:
error_notification:
default_message: 'Please review the problems below:'
@@ -103,19 +134,25 @@ is:
me: Ég
organizations: Samtök
projects: Verkefni
- search: "Leita"
+ search: Leita
settings: Stillingar
home:
around_the_world: Umhverfis heiminn
beyond_that: Og lengra?
circles-section:
cta: Nánar
- description: In order to build a global network, a distributed laboratory for research and invention.
+ description: In order to build a global network, a distributed laboratory
+ for research and invention.
title: All Fab Labs share common tools and processes.
- fab_labs_description: Fab labs provide widespread access to modern means for invention. They began as an outreach project from MIT's Center for Bits and Atoms (CBA), and became into a collaborative and global network. You can find more information about Fab Labs on the
Fab Foundation Website. The annotated photo below illustrates the facilities of a typical Fab Lab.
+ fab_labs_description: Fab labs provide widespread access to modern means for
+ invention. They began as an outreach project from MIT's Center for Bits and
+ Atoms (CBA), and became into a collaborative and global network. You can find
+ more information about Fab Labs on the %{fab_foundation} Website. The annotated
+ photo below illustrates the facilities of a typical Fab Lab.
fablabs-section:
cta: Sjá allan listann
- description: In order to build a global network, a distributed laboratory for research and invention.
+ description: In order to build a global network, a distributed laboratory
+ for research and invention.
title: Global league of fab labs for local purposes.
features:
activity_feeds: Activity feeds
@@ -126,17 +163,20 @@ is:
opening_hours: Opnunartímar
lab_card:
cta: Skráðu smiðjuna þína
- description: Hver einasta smiðja hefur sína eigin síðu sem starfsfólk getur uppfært
+ description: Hver einasta smiðja hefur sína eigin síðu sem starfsfólk getur
+ uppfært
subtitle: Profile
title: Ég er Fablab
lab_profiles: Lab profiles
machines: Vélar
person_card:
cta: Stofna aðgang
- description: An interactive map showing the location of all the Fab Labs around the world
+ description: An interactive map showing the location of all the Fab Labs around
+ the world
subtitle: Skoða
title: Ég er persóna
- quote: Because all Fab Labs share common tools and processes, the program is building a global network, a distributed laboratory for research and invention.
+ quote: Because all Fab Labs share common tools and processes, the program is
+ building a global network, a distributed laboratory for research and invention.
welcome: Velkomin
what_can_i_do: Hvað get ég gert?
whats_a_fab_lab: I'm new here. What's a Fab Lab?
diff --git a/config/locales/it.yml b/config/locales/it.yml
index 4838f1bbe..109a85442 100644
--- a/config/locales/it.yml
+++ b/config/locales/it.yml
@@ -27,7 +27,8 @@ it:
home:
around_the_world: In tutto il mondo
beyond_that: E oltre quello?
- fab_labs_description: I Fab Lab forniscono un accesso diffuso a moderni strumenti
+ fab_labs_description: |
+ I Fab Lab forniscono un accesso diffuso a moderni strumenti
di invenzione. Sono iniziati come un progetto di estensione del Center for
Bits and Atoms (CBA) presso il MIT, e sono diventati una rete collaborativa
e globale. Puoi trovare maggior informazioni sui Fab Lab sul sito della %{fab_foundation}.
diff --git a/config/locales/nl.yml b/config/locales/nl.yml
index d7325cbf5..f791313dc 100644
--- a/config/locales/nl.yml
+++ b/config/locales/nl.yml
@@ -27,7 +27,8 @@ nl:
home:
around_the_world: 'WereldWijd '
beyond_that: En verder?
- fab_labs_description: Fablabs verlenen een wijdverspreide toegang tot moderne
+ fab_labs_description: |
+ Fablabs verlenen een wijdverspreide toegang tot moderne
technieken voor uitvindingen. Het begon als een ''outreach project'' van MIT''s
Center for Bits and Atoms en werd al snel een collaboratief globaal netwerk.
Je kan meer informatie vinden op de website van %{fab_foundation}. De onderstaande
diff --git a/config/locales/pt.yml b/config/locales/pt.yml
index f8098b5ee..8f71ffe90 100644
--- a/config/locales/pt.yml
+++ b/config/locales/pt.yml
@@ -27,10 +27,11 @@ pt:
home:
around_the_world: Ao redor do mundo
beyond_that: E além disso?
- fab_labs_description: Fab Labs fornecem um acesso amplo aos meios modernos de
+ fab_labs_description: |
+ Fab Labs fornecem um acesso amplo aos meios modernos de
invenção. Eles começaram como um projeto de extensão do Center for Bits and
Atoms (CBA) do MIT, e se tornaram uma rede colaborativa e global. Você pode
- encontrar mais informações sobre Fab Labs no site % {fab_foundation}. A foto
+ encontrar mais informações sobre Fab Labs no site %{fab_foundation}. A foto
abaixo ilustra as instalações de um Fab Lab típico.
features:
activity_feeds: Feed de Atividades
diff --git a/config/puma.rb b/config/puma.rb
index 03c166f4c..38c4b8659 100644
--- a/config/puma.rb
+++ b/config/puma.rb
@@ -1,13 +1,18 @@
# This configuration file will be evaluated by Puma. The top-level methods that
# are invoked here are part of Puma's configuration DSL. For more information
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
-
+#
# Puma starts a configurable number of processes (workers) and each process
# serves each request in a thread from an internal thread pool.
#
+# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You
+# should only set this value when you want to run 2 or more workers. The
+# default is already 1. You can set it to `auto` to automatically start a worker
+# for each available processor.
+#
# The ideal number of threads per worker depends both on how much time the
# application spends waiting for IO operations and on how much you wish to
-# to prioritize throughput over latency.
+# prioritize throughput over latency.
#
# As a rule of thumb, increasing the number of threads will increase how much
# traffic a given process can handle (throughput), but due to CRuby's
@@ -29,6 +34,9 @@
# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
+# Run the Solid Queue supervisor inside of Puma for single-server deployments.
+plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"]
+
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
# In other environments, only set the PID file if requested.
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
diff --git a/config/routes.rb b/config/routes.rb
index 3344e27ed..cf97ebb6b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -3,6 +3,10 @@
require 'sidekiq/web'
mount Sidekiq::Web, at: '/sidekiq', constraints: AdminConstraint.new
+ # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
+ # Can be used by load balancers and uptime monitors to verify that the app is live.
+ get "up" => "rails/health#show", as: :rails_health_check
+
get "discourse/sso"
get "discuss" => 'discourse#embed'
diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml
index 2c5d835fb..6053b61ef 100644
--- a/docker-compose-dev.yml
+++ b/docker-compose-dev.yml
@@ -19,16 +19,16 @@ services:
context: .
dockerfile: Dockerfile
volumes:
- - ./app:/fablabs/app
- - ./config:/fablabs/config
- - ./db:/fablabs/db
- - ./lib:/fablabs/lib
- - ./log:/fablabs/log
- - ./public:/fablabs/public
- - ./spec:/fablabs/spec
- - ./Gemfile:/fablabs/Gemfile
- - ./Gemfile.lock:/fablabs/Gemfile.lock
- # - .:/fablabs
+ # - ./app:/fablabs/app
+ # - ./config:/fablabs/config
+ # - ./db:/fablabs/db
+ # - ./lib:/fablabs/lib
+ # - ./log:/fablabs/log
+ # - ./public:/fablabs/public
+ # - ./spec:/fablabs/spec
+ # - ./Gemfile:/fablabs/Gemfile
+ # - ./Gemfile.lock:/fablabs/Gemfile.lock
+ - .:/fablabs
- app-tmp:/fablabs/tmp
- bundle_path:/usr/local/bundle
# environment:
diff --git a/package.json b/package.json
index edd498b31..20ca40beb 100644
--- a/package.json
+++ b/package.json
@@ -4,11 +4,26 @@
"main": "index.js",
"repository": "git@github.com:fablabbcn/fablabs.io.git",
"license": "MIT",
+ "scripts": {
+ "build": "esbuild app/javascript/*.js --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets",
+ "build:css:activeadmin": "npx @tailwindcss/cli -i ./app/assets/stylesheets/active_admin.css -o ./app/assets/builds/active_admin.css --minify",
+ "build:css": "sass ./app/assets/stylesheets/application.css.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules --silence-deprecation=import,global-builtin,slash-div,color-functions,legacy-js-api"
+ },
"dependencies": {
+ "@activeadmin/activeadmin": "4.0.0-beta23",
+ "@nathanvda/cocoon": "^1.2.14",
+ "@rails/ujs": "^7.1.3-4",
"bootstrap": "^4.4.1",
+ "flatpickr": "^4.6.13",
+ "geocomplete": "^1.7.0",
"jquery": "~3.7.0",
- "leaflet": "~1.0.3",
- "leaflet-spin": "~1.1.0",
+ "popper.js": "^1.16.1",
"select2": "~4.0.3"
+ },
+ "devDependencies": {
+ "@tailwindcss/cli": "^4.0.0",
+ "esbuild": "^0.28.2",
+ "sass": "^1.105.1",
+ "tailwindcss": "^4.0.0"
}
}
diff --git a/public/400.html b/public/400.html
new file mode 100644
index 000000000..640de0339
--- /dev/null
+++ b/public/400.html
@@ -0,0 +1,135 @@
+
+
+
+
+
+
+
The server cannot process the request due to a client error (400 Bad Request)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The server cannot process the request due to a client error. Please check the request and try again. If you're the application owner check the logs for more information.
+
+
+
+
+
+
diff --git a/public/404.html b/public/404.html
index 498a6ae3f..d7f0f1422 100644
--- a/public/404.html
+++ b/public/404.html
@@ -1,61 +1,135 @@
-
-
-
-
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.
-
-
If you are the application owner check the logs for more information.
-
+
+
+
+
+
+
+
The page you were looking for doesn't exist (404 Not found)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved. If you're the application owner check the logs for more information.
+
+
+
+
+
diff --git a/public/406-unsupported-browser.html b/public/406-unsupported-browser.html
new file mode 100644
index 000000000..43d2811e8
--- /dev/null
+++ b/public/406-unsupported-browser.html
@@ -0,0 +1,135 @@
+
+
+
+
+
+
+
Your browser is not supported (406 Not Acceptable)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Your browser is not supported.
Please upgrade your browser to continue.
+
+
+
+
+
+
diff --git a/public/422.html b/public/422.html
index 3b73a09ea..f12fb4aa1 100644
--- a/public/422.html
+++ b/public/422.html
@@ -1,61 +1,135 @@
-
-
-
-
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.
-
-
If you are the application owner check the logs for more information.
-
+
+
+
+
+
+
+
The change you wanted was rejected (422 Unprocessable Entity)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The change you wanted was rejected. Maybe you tried to change something you didn't have access to. If you're the application owner check the logs for more information.
+
+
+
+
+
diff --git a/public/500.html b/public/500.html
index 4ce7591a3..e4eb18a75 100644
--- a/public/500.html
+++ b/public/500.html
@@ -1,65 +1,135 @@
-
-
-
-
We're sorry, but something went wrong (500)
-
-
-
-
-
-
-

-
-
-
We're sorry, but something went wrong with the internal server.
-
-
-
Please contact a system adninistrator to report what happend and the time UTC, so we can help you along.
-
-
+
+
+
+
+
+
+
We're sorry, but something went wrong (500 Internal Server Error)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ We're sorry, but something went wrong.
If you're the application owner check the logs for more information.
+
+
+
+
+
diff --git a/spec/controllers/oauth/applications_controller_spec.rb b/spec/controllers/oauth/applications_controller_spec.rb
index 256f24619..766041023 100644
--- a/spec/controllers/oauth/applications_controller_spec.rb
+++ b/spec/controllers/oauth/applications_controller_spec.rb
@@ -40,7 +40,7 @@
status, headers, body = *response
expect(response).to be_successful
expect(response).to render_template(:index)
- expect(response.body).to include("Your applications")
+ expect(response.body).to include("Your OAuth applications")
expect(response.body).to include(app.name)
end
diff --git a/spec/i18n_spec.rb b/spec/i18n_spec.rb
new file mode 100644
index 000000000..e154082e9
--- /dev/null
+++ b/spec/i18n_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require "i18n/tasks"
+
+RSpec.describe I18n do
+ let(:i18n) { I18n::Tasks::BaseTask.new }
+ let(:missing_keys) { i18n.missing_keys }
+ let(:unused_keys) { i18n.unused_keys }
+ let(:inconsistent_interpolations) { i18n.inconsistent_interpolations }
+
+ skip it "does not have missing keys" do
+ expect(missing_keys).to be_empty,
+ "Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
+ end
+
+ skip it "does not have unused keys" do
+ expect(unused_keys).to be_empty,
+ "#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
+ end
+
+ it "files are normalized" do
+ non_normalized = i18n.non_normalized_paths
+ error_message = "The following files need to be normalized:\n" \
+ "#{non_normalized.map { |path| " #{path}" }.join("\n")}\n" \
+ "Please run `i18n-tasks normalize' to fix"
+ expect(non_normalized).to be_empty, error_message
+ end
+
+ it "does not have inconsistent interpolations" do
+ error_message = "#{inconsistent_interpolations.leaves.count} i18n keys have inconsistent interpolations.\n" \
+ "Run `i18n-tasks check-consistent-interpolations' to show them"
+ expect(inconsistent_interpolations).to be_empty, error_message
+ end
+end
diff --git a/tailwind-active_admin.config.js b/tailwind-active_admin.config.js
new file mode 100644
index 000000000..55694b7a5
--- /dev/null
+++ b/tailwind-active_admin.config.js
@@ -0,0 +1,22 @@
+import { execSync } from 'child_process';
+import activeAdminPlugin from '@activeadmin/activeadmin/plugin';
+
+// Always use the last line of output since Bundler's DEBUG env will print additional lines.
+const activeAdminPath = execSync('bundle show activeadmin', { encoding: 'utf-8' }).trim().split(/\r?\n/).pop();
+
+export default {
+ content: [
+ `${activeAdminPath}/vendor/javascript/flowbite.js`,
+ `${activeAdminPath}/plugin.js`,
+ `${activeAdminPath}/app/views/**/*.{arb,erb,html,rb}`,
+ './app/admin/**/*.{arb,erb,html,rb}',
+ './app/views/active_admin/**/*.{arb,erb,html,rb}',
+ './app/views/admin/**/*.{arb,erb,html,rb}',
+ './app/views/layouts/active_admin*.{erb,html}',
+ './app/javascript/**/*.js'
+ ],
+ darkMode: "selector",
+ plugins: [
+ activeAdminPlugin
+ ]
+}
diff --git a/vendor/assets/javascripts/Control.Loading.js b/vendor/assets/javascripts/Control.Loading.js
deleted file mode 100644
index c33ff7e17..000000000
--- a/vendor/assets/javascripts/Control.Loading.js
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * L.Control.Loading is a control that shows a loading indicator when tiles are
- * loading or when map-related AJAX requests are taking place.
- */
-L.Control.Loading = L.Control.extend({
- options: {
- position: 'topleft',
- separate: false,
- zoomControl: null
- },
-
- initialize: function(options) {
- L.setOptions(this, options);
- this._dataLoaders = {};
-
- // Try to set the zoom control this control is attached to from the
- // options
- if (this.options.zoomControl !== null) {
- this.zoomControl = this.options.zoomControl;
- }
- },
-
- onAdd: function(map) {
- this._addLayerListeners(map);
- this._addMapListeners(map);
-
- // Try to set the zoom control this control is attached to from the map
- // the control is being added to
- if (!this.options.separate && !this.zoomControl) {
- this.zoomControl = map.zoomControl;
- }
-
- // Create the loading indicator
- var classes = 'leaflet-control-loading';
- var container;
- if (this.zoomControl && !this.options.separate) {
- // If there is a zoom control, hook into the bottom of it
- container = this.zoomControl._container;
- // These classes are no longer used as of Leaflet 0.6
- classes += ' leaflet-bar-part-bottom leaflet-bar-part last';
- }
- else {
- // Otherwise, create a container for the indicator
- container = L.DomUtil.create('div', 'leaflet-control-zoom leaflet-bar');
- }
- this._indicator = L.DomUtil.create('a', classes, container);
- return container;
- },
-
- onRemove: function(map) {
- this._removeLayerListeners(map);
- this._removeMapListeners(map);
- },
-
- removeFrom: function (map) {
- if (this.zoomControl && !this.options.separate) {
- // Override Control.removeFrom() to avoid clobbering the entire
- // _container, which is the same as zoomControl's
- this._container.removeChild(this._indicator);
- this._map = null;
- this.onRemove(map);
- return this;
- }
- else {
- // If this control is separate from the zoomControl, call the
- // parent method so we don't leave behind an empty container
- return L.Control.prototype.removeFrom.call(this, map);
- }
- },
-
- addLoader: function(id) {
- this._dataLoaders[id] = true;
- this.updateIndicator();
- },
-
- removeLoader: function(id) {
- delete this._dataLoaders[id];
- this.updateIndicator();
- },
-
- updateIndicator: function() {
- if (this.isLoading()) {
- this._showIndicator();
- }
- else {
- this._hideIndicator();
- }
- },
-
- isLoading: function() {
- return this._countLoaders() > 0;
- },
-
- _countLoaders: function() {
- var size = 0, key;
- for (key in this._dataLoaders) {
- if (this._dataLoaders.hasOwnProperty(key)) size++;
- }
- return size;
- },
-
- _showIndicator: function() {
- // Show loading indicator
- L.DomUtil.addClass(this._indicator, 'is-loading');
-
- // If zoomControl exists, make the zoom-out button not last
- if (this.zoomControl && !this.options.separate) {
- L.DomUtil.removeClass(this.zoomControl._zoomOutButton, 'leaflet-bar-part-bottom');
- }
- },
-
- _hideIndicator: function() {
- // Hide loading indicator
- L.DomUtil.removeClass(this._indicator, 'is-loading');
-
- // If zoomControl exists, make the zoom-out button last
- if (this.zoomControl && !this.options.separate) {
- L.DomUtil.addClass(this.zoomControl._zoomOutButton, 'leaflet-bar-part-bottom');
- }
- },
-
- _handleLoading: function(e) {
- this.addLoader(this.getEventId(e));
- },
-
- _handleLoad: function(e) {
- this.removeLoader(this.getEventId(e));
- },
-
- getEventId: function(e) {
- if (e.id) {
- return e.id;
- }
- else if (e.layer) {
- return e.layer._leaflet_id;
- }
- return e.target._leaflet_id;
- },
-
- _layerAdd: function(e) {
- if (!e.layer || !e.layer.on) return
- e.layer.on({
- loading: this._handleLoading,
- load: this._handleLoad
- }, this);
- },
-
- _addLayerListeners: function(map) {
- // Add listeners for begin and end of load to any layers already on the
- // map
- map.eachLayer(function(layer) {
- if (!layer.on) return;
- layer.on({
- loading: this._handleLoading,
- load: this._handleLoad
- }, this);
- }, this);
-
- // When a layer is added to the map, add listeners for begin and end
- // of load
- map.on('layeradd', this._layerAdd, this);
- },
-
- _removeLayerListeners: function(map) {
- // Remove listeners for begin and end of load from all layers
- map.eachLayer(function(layer) {
- if (!layer.off) return;
- layer.off({
- loading: this._handleLoading,
- load: this._handleLoad
- }, this);
- }, this);
-
- // Remove layeradd listener from map
- map.off('layeradd', this._layerAdd, this);
- },
-
- _addMapListeners: function(map) {
- // Add listeners to the map for (custom) dataloading and dataload
- // events, eg, for AJAX calls that affect the map but will not be
- // reflected in the above layer events.
- map.on({
- dataloading: this._handleLoading,
- dataload: this._handleLoad
- }, this);
- },
-
- _removeMapListeners: function(map) {
- map.off({
- dataloading: this._handleLoading,
- dataload: this._handleLoad
- }, this);
- }
-});
-
-L.Map.addInitHook(function () {
- if (this.options.loadingControl) {
- this.loadingControl = new L.Control.Loading();
- this.addControl(this.loadingControl);
- }
-});
-
-L.Control.loading = function(options) {
- return new L.Control.Loading(options);
-};
diff --git a/vendor/assets/javascripts/intlTelInput.js b/vendor/assets/javascripts/intlTelInput.js
deleted file mode 100755
index 4f3026663..000000000
--- a/vendor/assets/javascripts/intlTelInput.js
+++ /dev/null
@@ -1,1519 +0,0 @@
-/*
-intl-tel-input
-version: 0.9.4
-description: A jQuery plugin for entering international telephone numbers
-repository: https://github.com/Bluefieldscom/intl-tel-input.git
-license: MIT
-author: Jack O'Connor (http://jackocnr.com)
-*/
-(function() {
-"use strict";
-
-(function($, window, document, undefined) {
- var pluginName = "intlTelInput", id = 1, // give each instance it's own id for namespaced event handling
- defaults = {
- preferredCountries: [ "us", "gb" ],
- // united states and united kingdom
- initialDialCode: true,
- americaMode: false,
- onlyCountries: [],
- defaultStyling: true
- };
- function Plugin(element, options) {
- this.element = element;
- this.options = $.extend({}, defaults, options);
- this._defaults = defaults;
- this.id = id++;
- this._name = pluginName;
- this.init();
- }
- Plugin.prototype = {
- init: function() {
- var that = this;
- // process onlyCountries array and update intlData.countries
- // and intlData.countryCodes accordingly
- if (this.options.onlyCountries.length > 0) {
- var newCountries = [], newCountryCodes = {};
- $.each(this.options.onlyCountries, function(i, countryCode) {
- var countryData = that._getCountryData(countryCode);
- if (countryData) {
- newCountries.push(countryData);
- var callingCode = countryData["calling-code"];
- if (newCountryCodes[callingCode]) {
- newCountryCodes[callingCode].push(countryCode);
- } else {
- newCountryCodes[callingCode] = [ countryCode ];
- }
- }
- });
- // update the global data object
- intlData.countries = newCountries;
- intlData.countryCodes = newCountryCodes;
- }
- // process preferred countries - iterate through the preferences,
- // finding the relevant data from the provided intlData.countries array
- var preferredCountries = [];
- $.each(this.options.preferredCountries, function(i, countryCode) {
- var countryData = that._getCountryData(countryCode);
- if (countryData) {
- preferredCountries.push(countryData);
- }
- });
- this.defaultCountry = preferredCountries.length ? preferredCountries[0] : intlData.countries[0];
- // telephone input
- this.telInput = $(this.element);
- // if initialDialCode is enabled (and input is not pre-populated), insert the default dial code
- // update: also check that the default country is not america, or if it is, that americaMode is false
- if (this.options.initialDialCode && this.telInput.val() === "" && (this.defaultCountry.cca2 != "us" || !this.options.americaMode)) {
- this.telInput.val("+" + this.defaultCountry["calling-code"] + " ");
- }
- // containers (mostly for positioning)
- var mainClass = "intl-tel-input";
- if (this.options.defaultStyling) {
- mainClass += " pretty";
- }
- this.telInput.wrap($("
", {
- "class": mainClass
- }));
- var flagsContainer = $("
", {
- "class": "flag-dropdown f16"
- }).insertBefore(this.telInput);
- // currently selected flag (displayed to left of input)
- var selectedFlag = $("
", {
- "class": "selected-flag"
- }).appendTo(flagsContainer);
- // here we default to the first country in the list
- var firstCountry = this.defaultCountry.cca2;
- this.selectedFlagInner = $("
", {
- "class": "flag " + firstCountry
- }).appendTo(selectedFlag);
- // CSS triangle
- $("
", {
- "class": "down-arrow"
- }).appendTo(this.selectedFlagInner);
- // country list contains: preferred countries, then divider, then all countries
- this.countryList = $("
", {
- "class": "country-list hide"
- }).appendTo(flagsContainer);
- if (preferredCountries.length) {
- this._appendListItems(preferredCountries, "preferred");
- $("- ", {
- "class": "divider"
- }).appendTo(this.countryList);
- }
- this._appendListItems(intlData.countries, "");
- this.countryListItems = this.countryList.children(".country");
- // auto select the top one
- this.countryListItems.first().addClass("active");
- // update flag on keyup
- // (by extracting the dial code from the input value)
- this.telInput.keyup(function() {
- var countryCode, alreadySelected = false;
- // try and extract valid dial code from input
- var dialCode = that._getDialCode(that.telInput.val());
- if (dialCode) {
- // check if one of the matching country's is already selected
- var countryCodes = intlData.countryCodes[dialCode];
- $.each(countryCodes, function(i, c) {
- if (that.selectedFlagInner.hasClass(c)) {
- alreadySelected = true;
- }
- });
- countryCode = countryCodes[0];
- } else {
- countryCode = that.defaultCountry.cca2;
- }
- if (!alreadySelected) {
- that._selectFlag(countryCode);
- }
- });
- // trigger it now in case there is already a number in the input
- this.telInput.keyup();
- // toggle country dropdown on click
- selectedFlag.click(function(e) {
- // toggle dropdown
- if (that.countryList.hasClass("hide")) {
- // update highlighting and scroll to active list item
- that.countryListItems.removeClass("highlight");
- var activeListItem = that.countryList.children(".active").addClass("highlight");
- // show it
- that.countryList.removeClass("hide");
- that._scrollTo(activeListItem);
- // click off to close
- // (except when this initial opening click is bubbling up)
- var isOpening = true;
- $("html").bind("click.intlTelInput" + that.id, function(e) {
- if (!isOpening) {
- that._closeDropdown();
- }
- isOpening = false;
- });
- // listen for typing
- $(document).bind("keydown.intlTelInput" + that.id, function(e) {
- // up (38) and down (40) to navigate
- if (e.which == 38 || e.which == 40) {
- var current = that.countryList.children(".highlight").first();
- var next = e.which == 38 ? current.prev() : current.next();
- if (next) {
- // skip the divider
- if (next.hasClass("divider")) {
- next = e.which == 38 ? next.prev() : next.next();
- }
- that.countryListItems.removeClass("highlight");
- next.addClass("highlight");
- that._scrollTo(next);
- }
- } else if (e.which == 13) {
- var currentCountry = that.countryList.children(".highlight").first();
- if (currentCountry.length) {
- that._selectListItem(currentCountry);
- }
- } else if (e.which == 9 || e.which == 27) {
- that._closeDropdown();
- } else if (e.which >= 97 && e.which <= 122 || e.which >= 65 && e.which <= 90) {
- var letter = String.fromCharCode(e.which);
- // filter out the countries beginning with that letter
- var countries = that.countryListItems.filter(function() {
- return $(this).text().charAt(0) == letter && !$(this).hasClass("preferred");
- });
- if (countries.length) {
- // if one is already highlighted, then we want the next one
- var highlightedCountry = countries.filter(".highlight").first();
- var listItem;
- // if the next country in the list also starts with that letter
- if (highlightedCountry && highlightedCountry.next() && highlightedCountry.next().text().charAt(0) == letter) {
- listItem = highlightedCountry.next();
- } else {
- listItem = countries.first();
- }
- // update highlighting and scroll
- that.countryListItems.removeClass("highlight");
- listItem.addClass("highlight");
- that._scrollTo(listItem);
- }
- }
- });
- }
- });
- // when mouse over a list item, remove any highlighting from any other items
- this.countryListItems.mouseover(function() {
- that.countryListItems.removeClass("highlight");
- $(this).addClass("highlight");
- });
- // listen for country selection
- this.countryListItems.click(function(e) {
- var listItem = $(e.currentTarget);
- that._selectListItem(listItem);
- });
- },
- // end of init()
- /********************
- * PRIVATE METHODS
- ********************/
- // find the country data for the given country code
- _getCountryData: function(countryCode) {
- for (var i = 0; i < intlData.countries.length; i++) {
- if (intlData.countries[i].cca2 == countryCode) {
- return intlData.countries[i];
- }
- }
- },
- // update the selected flag and the active list item
- _selectFlag: function(countryCode) {
- this.selectedFlagInner.attr("class", "flag " + countryCode);
- // and the active list item
- this.countryListItems.removeClass("active");
- var listItem = this.countryListItems.children(".flag." + countryCode).parent();
- listItem.addClass("active");
- return listItem;
- },
- // called when the user selects a list item from the dropdown
- _selectListItem: function(listItem) {
- var countryCode = listItem.attr("data-country-code");
- // update selected flag
- this.selectedFlagInner.attr("class", "flag " + countryCode);
- // update input value
- var newNumber = this._updateNumber(this.telInput.val(), listItem.attr("data-dial-code"));
- this.telInput.val(newNumber);
- // focus the input
- this.telInput.focus();
- // mark the list item as active (incase they open the dropdown again)
- this.countryListItems.removeClass("active highlight");
- listItem.addClass("active");
- },
- // close the dropdown and unbind any listeners
- _closeDropdown: function() {
- this.countryList.addClass("hide");
- $(document).unbind("keydown.intlTelInput" + this.id);
- $("html").unbind("click.intlTelInput" + this.id);
- },
- // check if an element is visible within it's container, else scroll until it is
- _scrollTo: function(element) {
- var container = this.countryList;
- var containerHeight = container.height();
- var containerTop = container.offset().top;
- var containerBottom = containerTop + containerHeight;
- var elementHeight = element.outerHeight();
- var elementTop = element.offset().top;
- var elementBottom = elementTop + elementHeight;
- var newScrollTop = elementTop - containerTop + container.scrollTop();
- if (elementTop < containerTop) {
- // scroll up
- container.scrollTop(newScrollTop);
- } else if (elementBottom > containerBottom) {
- // scroll down
- var heightDifference = containerHeight - elementHeight;
- container.scrollTop(newScrollTop - heightDifference);
- }
- },
- // replace any existing dial code with the new one
- _updateNumber: function(inputVal, dialCode) {
- var prevDialCode = "+" + this._getDialCode(inputVal);
- var newDialCode = "+" + dialCode;
- var newNumber;
- // if the previous number contained a valid dial code, replace it
- // (if more than just a plus character)
- if (prevDialCode.length > 1) {
- newNumber = inputVal.replace(prevDialCode, newDialCode);
- // if the old number was just the dial code,
- // then we will need to add the space again
- if (inputVal == prevDialCode) {
- newNumber += " ";
- }
- } else if (inputVal.length && inputVal.substr(0, 1) != "+") {
- // previous number didn't contain a dial code, so persist it
- newNumber = newDialCode + " " + inputVal.trim();
- } else {
- // previous number contained an invalid dial code, so wipe it
- newNumber = newDialCode + " ";
- }
- // if americaMode is enabled, we dont display the dial code for american numbers
- if (this.options.americaMode && newNumber.substring(0, 3) == "+1 ") {
- newNumber = newNumber.substring(3);
- }
- return newNumber;
- },
- // try and extract a valid international dial code from a full telephone number
- _getDialCode: function(inputVal) {
- var firstPart = inputVal.trim().split(" ")[0];
- // only interested in international numbers (starting with a plus)
- if (firstPart.substring(0, 1) == "+") {
- // strip out non-numeric chars (e.g. pluses, spaces, brackets)
- // and grab the first 4 numbers (max length of a dial code is 4)
- var dialCode = firstPart.replace(/\D/g, "").substring(0, 4);
- // try first 4 digits, then 3, then 2, then 1...
- for (var i = dialCode.length; i > 0; i--) {
- dialCode = dialCode.substring(0, i);
- // if we find a match (a valid dial code), then return the dial code
- if (intlData.countryCodes[dialCode]) {
- return dialCode;
- }
- }
- }
- return "";
- },
- // add a country
- to the countryList
container
- _appendListItems: function(countries, className) {
- // we create so many DOM elements, I decided it was faster to build a temp string
- // and then add everything to the DOM in one go at the end
- var tmp = "";
- // for each country
- $.each(countries, function(i, c) {
- // open the list item
- tmp += "- ";
- // add the flag
- tmp += "";
- // and the country name and dial code
- tmp += "" + c.name + "";
- tmp += "+" + c["calling-code"] + "";
- // close the list item
- tmp += "
";
- });
- this.countryList.append(tmp);
- },
- /********************
- * PUBLIC METHODS
- ********************/
- // update the selected flag, and insert the dial code
- selectCountry: function(countryCode) {
- // check if already selected
- if (!this.selectedFlagInner.hasClass(countryCode)) {
- var listItem = this._selectFlag(countryCode);
- var dialCode = listItem.attr("data-dial-code");
- this.telInput.val("+" + dialCode + " ");
- }
- },
- // get the country data object
- getCountryData: function() {
- return intlData;
- },
- // set the country data object
- setCountryData: function(obj) {
- intlData = obj;
- }
- };
- // adapted to allow public functions
- // using https://github.com/jquery-boilerplate/jquery-boilerplate/wiki/Extending-jQuery-Boilerplate
- $.fn[pluginName] = function(options) {
- var args = arguments;
- // Is the first parameter an object (options), or was omitted,
- // instantiate a new instance of the plugin.
- if (options === undefined || typeof options === "object") {
- return this.each(function() {
- if (!$.data(this, "plugin_" + pluginName)) {
- $.data(this, "plugin_" + pluginName, new Plugin(this, options));
- }
- });
- } else if (typeof options === "string" && options[0] !== "_" && options !== "init") {
- // Cache the method call to make it possible to return a value
- var returns;
- this.each(function() {
- var instance = $.data(this, "plugin_" + pluginName);
- // Tests that there's already a plugin-instance
- // and checks that the requested public method exists
- if (instance instanceof Plugin && typeof instance[options] === "function") {
- // Call the method of our plugin instance,
- // and pass it the supplied arguments.
- returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1));
- }
- });
- // If the earlier cached method gives a value back return the value,
- // otherwise return this to preserve chainability.
- return returns !== undefined ? returns : this;
- }
- };
-})(jQuery, window, document);
-
-// Tell JSHint to ignore this warning: "character may get silently deleted by one or more browsers"
-// jshint -W100
-// Namespaced to prevent clashes
-var intlData = {
- // Array of country objects for the flag dropdown.
- // Each contains a name, country code (ISO 3166-1 alpha-2) and dial code.
- // Originally from https://github.com/mledoze/countries
- // then stripped down by copying the JSON into Chrome dev tools and manipulating it
- // and then using JSON.stringify to print it out as a string again and copy it here.
- // Also commented some countries which we dont yet have flags for.
- countries: [ {
- name: "Afghanistan (افغانستان)",
- cca2: "af",
- "calling-code": "93"
- }, {
- name: "Albania (Shqipëria)",
- cca2: "al",
- "calling-code": "355"
- }, {
- name: "Algeria (الجزائر)",
- cca2: "dz",
- "calling-code": "213"
- }, {
- name: "American Samoa",
- cca2: "as",
- "calling-code": "1684"
- }, {
- name: "Andorra",
- cca2: "ad",
- "calling-code": "376"
- }, {
- name: "Angola",
- cca2: "ao",
- "calling-code": "244"
- }, {
- name: "Anguilla",
- cca2: "ai",
- "calling-code": "1264"
- }, {
- name: "Antigua and Barbuda",
- cca2: "ag",
- "calling-code": "1268"
- }, {
- name: "Argentina",
- cca2: "ar",
- "calling-code": "54"
- }, {
- name: "Armenia (Հայաստան)",
- cca2: "am",
- "calling-code": "374"
- }, {
- name: "Aruba",
- cca2: "aw",
- "calling-code": "297"
- }, {
- name: "Australia",
- cca2: "au",
- "calling-code": "61"
- }, {
- name: "Austria (Österreich)",
- cca2: "at",
- "calling-code": "43"
- }, {
- name: "Azerbaijan (Azərbaycan)",
- cca2: "az",
- "calling-code": "994"
- }, {
- name: "Bahamas",
- cca2: "bs",
- "calling-code": "1242"
- }, {
- name: "Bahrain (البحرين)",
- cca2: "bh",
- "calling-code": "973"
- }, {
- name: "Bangladesh (বাংলাদেশ)",
- cca2: "bd",
- "calling-code": "880"
- }, {
- name: "Barbados",
- cca2: "bb",
- "calling-code": "1246"
- }, {
- name: "Belarus (Беларусь)",
- cca2: "by",
- "calling-code": "375"
- }, {
- name: "Belgium (België)",
- cca2: "be",
- "calling-code": "32"
- }, {
- name: "Belize",
- cca2: "bz",
- "calling-code": "501"
- }, {
- name: "Benin (Bénin)",
- cca2: "bj",
- "calling-code": "229"
- }, {
- name: "Bermuda",
- cca2: "bm",
- "calling-code": "1441"
- }, {
- name: "Bhutan (འབྲུག)",
- cca2: "bt",
- "calling-code": "975"
- }, {
- name: "Bolivia",
- cca2: "bo",
- "calling-code": "591"
- }, {
- name: "Bosnia and Herzegovina (Босна и Херцеговина)",
- cca2: "ba",
- "calling-code": "387"
- }, {
- name: "Botswana",
- cca2: "bw",
- "calling-code": "267"
- }, {
- name: "Brazil (Brasil)",
- cca2: "br",
- "calling-code": "55"
- }, {
- name: "Brunei",
- cca2: "bn",
- "calling-code": "673"
- }, {
- name: "Bulgaria (България)",
- cca2: "bg",
- "calling-code": "359"
- }, {
- name: "Burkina Faso",
- cca2: "bf",
- "calling-code": "226"
- }, {
- name: "Burundi (Uburundi)",
- cca2: "bi",
- "calling-code": "257"
- }, {
- name: "Cambodia (កម្ពុជា)",
- cca2: "kh",
- "calling-code": "855"
- }, {
- name: "Cameroon (Cameroun)",
- cca2: "cm",
- "calling-code": "237"
- }, {
- name: "Canada",
- cca2: "ca",
- "calling-code": "1"
- }, {
- name: "Cape Verde (Kabu Verdi)",
- cca2: "cv",
- "calling-code": "238"
- }, {
- name: "Cayman Islands",
- cca2: "ky",
- "calling-code": "1345"
- }, {
- name: "Central African Republic (République centrafricaine)",
- cca2: "cf",
- "calling-code": "236"
- }, {
- name: "Chad (Tchad)",
- cca2: "td",
- "calling-code": "235"
- }, {
- name: "Chile",
- cca2: "cl",
- "calling-code": "56"
- }, {
- name: "China (中国)",
- cca2: "cn",
- "calling-code": "86"
- }, {
- name: "Colombia",
- cca2: "co",
- "calling-code": "57"
- }, {
- name: "Comoros (جزر القمر)",
- cca2: "km",
- "calling-code": "269"
- }, {
- name: "Congo [DRC] (Jamhuri ya Kidemokrasia ya Kongo)",
- cca2: "cd",
- "calling-code": "243"
- }, {
- name: "Congo [Republic] (Congo-Brazzaville)",
- cca2: "cg",
- "calling-code": "242"
- }, {
- name: "Cook Islands",
- cca2: "ck",
- "calling-code": "682"
- }, {
- name: "Costa Rica",
- cca2: "cr",
- "calling-code": "506"
- }, {
- name: "Côte d’Ivoire",
- cca2: "ci",
- "calling-code": "225"
- }, {
- name: "Croatia (Hrvatska)",
- cca2: "hr",
- "calling-code": "385"
- }, {
- name: "Cuba",
- cca2: "cu",
- "calling-code": "53"
- }, {
- name: "Cyprus (Κύπρος)",
- cca2: "cy",
- "calling-code": "357"
- }, {
- name: "Czech Republic (Česká republika)",
- cca2: "cz",
- "calling-code": "420"
- }, {
- name: "Denmark (Danmark)",
- cca2: "dk",
- "calling-code": "45"
- }, {
- name: "Djibouti",
- cca2: "dj",
- "calling-code": "253"
- }, {
- name: "Dominica",
- cca2: "dm",
- "calling-code": "1767"
- }, {
- name: "Dominican Republic (República Dominicana)",
- cca2: "do",
- "calling-code": "1809"
- }, {
- name: "Ecuador",
- cca2: "ec",
- "calling-code": "593"
- }, {
- name: "Egypt (مصر)",
- cca2: "eg",
- "calling-code": "20"
- }, {
- name: "El Salvador",
- cca2: "sv",
- "calling-code": "503"
- }, {
- name: "Equatorial Guinea (Guinea Ecuatorial)",
- cca2: "gq",
- "calling-code": "240"
- }, {
- name: "Eritrea",
- cca2: "er",
- "calling-code": "291"
- }, {
- name: "Estonia (Eesti)",
- cca2: "ee",
- "calling-code": "372"
- }, {
- name: "Ethiopia",
- cca2: "et",
- "calling-code": "251"
- }, {
- name: "Faroe Islands (Føroyar)",
- cca2: "fo",
- "calling-code": "298"
- }, {
- name: "Fiji",
- cca2: "fj",
- "calling-code": "679"
- }, {
- name: "Finland (Suomi)",
- cca2: "fi",
- "calling-code": "358"
- }, {
- name: "France",
- cca2: "fr",
- "calling-code": "33"
- }, {
- name: "French Polynesia (Polynésie française)",
- cca2: "pf",
- "calling-code": "689"
- }, {
- name: "Gabon",
- cca2: "ga",
- "calling-code": "241"
- }, {
- name: "Gambia",
- cca2: "gm",
- "calling-code": "220"
- }, {
- name: "Georgia (საქართველო)",
- cca2: "ge",
- "calling-code": "995"
- }, {
- name: "Germany (Deutschland)",
- cca2: "de",
- "calling-code": "49"
- }, {
- name: "Ghana (Gaana)",
- cca2: "gh",
- "calling-code": "233"
- }, {
- name: "Gibraltar",
- cca2: "gi",
- "calling-code": "350"
- }, {
- name: "Greece (Ελλάδα)",
- cca2: "gr",
- "calling-code": "30"
- }, {
- name: "Greenland (Kalaallit Nunaat)",
- cca2: "gl",
- "calling-code": "299"
- }, {
- name: "Grenada",
- cca2: "gd",
- "calling-code": "1473"
- }, {
- name: "Guadeloupe",
- cca2: "gp",
- "calling-code": "590"
- }, {
- name: "Guam",
- cca2: "gu",
- "calling-code": "1671"
- }, {
- name: "Guatemala",
- cca2: "gt",
- "calling-code": "502"
- }, {
- name: "Guernsey",
- cca2: "gg",
- "calling-code": "44"
- }, {
- name: "Guinea (Guinée)",
- cca2: "gn",
- "calling-code": "224"
- }, {
- name: "Guinea-Bissau (Guiné Bissau)",
- cca2: "gw",
- "calling-code": "245"
- }, {
- name: "Guyana",
- cca2: "gy",
- "calling-code": "592"
- }, {
- name: "Haiti",
- cca2: "ht",
- "calling-code": "509"
- }, {
- name: "Honduras",
- cca2: "hn",
- "calling-code": "504"
- }, {
- name: "Hong Kong (香港)",
- cca2: "hk",
- "calling-code": "852"
- }, {
- name: "Hungary (Magyarország)",
- cca2: "hu",
- "calling-code": "36"
- }, {
- name: "Iceland (Ísland)",
- cca2: "is",
- "calling-code": "354"
- }, {
- name: "India (भारत)",
- cca2: "in",
- "calling-code": "91"
- }, {
- name: "Indonesia",
- cca2: "id",
- "calling-code": "62"
- }, {
- name: "Iran (ایران)",
- cca2: "ir",
- "calling-code": "98"
- }, {
- name: "Iraq (العراق)",
- cca2: "iq",
- "calling-code": "964"
- }, {
- name: "Ireland",
- cca2: "ie",
- "calling-code": "353"
- }, {
- name: "Isle of Man",
- cca2: "im",
- "calling-code": "44"
- }, {
- name: "Israel (ישראל)",
- cca2: "il",
- "calling-code": "972"
- }, {
- name: "Italy (Italia)",
- cca2: "it",
- "calling-code": "39"
- }, {
- name: "Jamaica",
- cca2: "jm",
- "calling-code": "1876"
- }, {
- name: "Japan (日本)",
- cca2: "jp",
- "calling-code": "81"
- }, {
- name: "Jersey",
- cca2: "je",
- "calling-code": "44"
- }, {
- name: "Jordan (الأردن)",
- cca2: "jo",
- "calling-code": "962"
- }, {
- name: "Kazakhstan (Казахстан)",
- cca2: "kz",
- "calling-code": "7"
- }, {
- name: "Kenya",
- cca2: "ke",
- "calling-code": "254"
- }, {
- name: "Kiribati",
- cca2: "ki",
- "calling-code": "686"
- }, {
- name: "Kuwait (الكويت)",
- cca2: "kw",
- "calling-code": "965"
- }, {
- name: "Kyrgyzstan",
- cca2: "kg",
- "calling-code": "996"
- }, {
- name: "Laos (ສ.ປ.ປ ລາວ)",
- cca2: "la",
- "calling-code": "856"
- }, {
- name: "Latvia (Latvija)",
- cca2: "lv",
- "calling-code": "371"
- }, {
- name: "Lebanon (لبنان)",
- cca2: "lb",
- "calling-code": "961"
- }, {
- name: "Lesotho",
- cca2: "ls",
- "calling-code": "266"
- }, {
- name: "Liberia",
- cca2: "lr",
- "calling-code": "231"
- }, {
- name: "Libya (ليبيا)",
- cca2: "ly",
- "calling-code": "218"
- }, {
- name: "Liechtenstein",
- cca2: "li",
- "calling-code": "423"
- }, {
- name: "Lithuania (Lietuva)",
- cca2: "lt",
- "calling-code": "370"
- }, {
- name: "Luxembourg",
- cca2: "lu",
- "calling-code": "352"
- }, {
- name: "Macau (澳門)",
- cca2: "mo",
- "calling-code": "853"
- }, {
- name: "Macedonia [FYROM] (Македонија)",
- cca2: "mk",
- "calling-code": "389"
- }, {
- name: "Madagascar (Madagasikara)",
- cca2: "mg",
- "calling-code": "261"
- }, {
- name: "Malawi",
- cca2: "mw",
- "calling-code": "265"
- }, {
- name: "Malaysia",
- cca2: "my",
- "calling-code": "60"
- }, {
- name: "Maldives",
- cca2: "mv",
- "calling-code": "960"
- }, {
- name: "Mali",
- cca2: "ml",
- "calling-code": "223"
- }, {
- name: "Malta",
- cca2: "mt",
- "calling-code": "356"
- }, {
- name: "Marshall Islands",
- cca2: "mh",
- "calling-code": "692"
- }, {
- name: "Martinique",
- cca2: "mq",
- "calling-code": "596"
- }, {
- name: "Mauritania (موريتانيا)",
- cca2: "mr",
- "calling-code": "222"
- }, {
- name: "Mauritius (Moris)",
- cca2: "mu",
- "calling-code": "230"
- }, {
- name: "Mexico (México)",
- cca2: "mx",
- "calling-code": "52"
- }, {
- name: "Micronesia",
- cca2: "fm",
- "calling-code": "691"
- }, {
- name: "Moldova (Republica Moldova)",
- cca2: "md",
- "calling-code": "373"
- }, {
- name: "Monaco",
- cca2: "mc",
- "calling-code": "377"
- }, {
- name: "Mongolia (Монгол)",
- cca2: "mn",
- "calling-code": "976"
- }, {
- name: "Montenegro (Crna Gora)",
- cca2: "me",
- "calling-code": "382"
- }, {
- name: "Montserrat",
- cca2: "ms",
- "calling-code": "1664"
- }, {
- name: "Morocco (المغرب)",
- cca2: "ma",
- "calling-code": "212"
- }, {
- name: "Mozambique (Moçambique)",
- cca2: "mz",
- "calling-code": "258"
- }, {
- name: "Myanmar [Burma] (မြန်မာ)",
- cca2: "mm",
- "calling-code": "95"
- }, {
- name: "Namibia",
- cca2: "na",
- "calling-code": "264"
- }, {
- name: "Nauru",
- cca2: "nr",
- "calling-code": "674"
- }, {
- name: "Nepal (नेपाल)",
- cca2: "np",
- "calling-code": "977"
- }, {
- name: "Netherlands (Nederland)",
- cca2: "nl",
- "calling-code": "31"
- }, {
- name: "New Caledonia (Nouvelle-Calédonie)",
- cca2: "nc",
- "calling-code": "687"
- }, {
- name: "New Zealand",
- cca2: "nz",
- "calling-code": "64"
- }, {
- name: "Nicaragua",
- cca2: "ni",
- "calling-code": "505"
- }, {
- name: "Niger (Nijar)",
- cca2: "ne",
- "calling-code": "227"
- }, {
- name: "Nigeria",
- cca2: "ng",
- "calling-code": "234"
- }, {
- name: "North Korea (조선 민주주의 인민 공화국)",
- cca2: "kp",
- "calling-code": "850"
- }, {
- name: "Norway (Norge)",
- cca2: "no",
- "calling-code": "47"
- }, {
- name: "Oman (عُمان)",
- cca2: "om",
- "calling-code": "968"
- }, {
- name: "Pakistan (پاکستان)",
- cca2: "pk",
- "calling-code": "92"
- }, {
- name: "Palau",
- cca2: "pw",
- "calling-code": "680"
- }, {
- name: "Palestine (فلسطين)",
- cca2: "ps",
- "calling-code": "970"
- }, {
- name: "Panama (Panamá)",
- cca2: "pa",
- "calling-code": "507"
- }, {
- name: "Papua New Guinea",
- cca2: "pg",
- "calling-code": "675"
- }, {
- name: "Paraguay",
- cca2: "py",
- "calling-code": "595"
- }, {
- name: "Peru (Perú)",
- cca2: "pe",
- "calling-code": "51"
- }, {
- name: "Philippines",
- cca2: "ph",
- "calling-code": "63"
- }, {
- name: "Poland (Polska)",
- cca2: "pl",
- "calling-code": "48"
- }, {
- name: "Portugal",
- cca2: "pt",
- "calling-code": "351"
- }, {
- name: "Puerto Rico",
- cca2: "pr",
- "calling-code": "1787"
- }, {
- name: "Qatar (قطر)",
- cca2: "qa",
- "calling-code": "974"
- }, {
- name: "Réunion",
- cca2: "re",
- "calling-code": "262"
- }, {
- name: "Romania (România)",
- cca2: "ro",
- "calling-code": "40"
- }, {
- name: "Russia (Россия)",
- cca2: "ru",
- "calling-code": "7"
- }, {
- name: "Rwanda",
- cca2: "rw",
- "calling-code": "250"
- }, {
- name: "Saint Kitts and Nevis",
- cca2: "kn",
- "calling-code": "1869"
- }, {
- name: "Saint Lucia",
- cca2: "lc",
- "calling-code": "1758"
- }, {
- name: "Saint Vincent and the Grenadines",
- cca2: "vc",
- "calling-code": "1784"
- }, {
- name: "Samoa",
- cca2: "ws",
- "calling-code": "685"
- }, {
- name: "San Marino",
- cca2: "sm",
- "calling-code": "378"
- }, {
- name: "São Tomé and Príncipe (São Tomé e Príncipe)",
- cca2: "st",
- "calling-code": "239"
- }, {
- name: "Saudi Arabia (المملكة العربية السعودية)",
- cca2: "sa",
- "calling-code": "966"
- }, {
- name: "Senegal (Sénégal)",
- cca2: "sn",
- "calling-code": "221"
- }, {
- name: "Serbia (Србија)",
- cca2: "rs",
- "calling-code": "381"
- }, {
- name: "Seychelles",
- cca2: "sc",
- "calling-code": "248"
- }, {
- name: "Sierra Leone",
- cca2: "sl",
- "calling-code": "232"
- }, {
- name: "Singapore",
- cca2: "sg",
- "calling-code": "65"
- }, {
- name: "Slovakia (Slovensko)",
- cca2: "sk",
- "calling-code": "421"
- }, {
- name: "Slovenia (Slovenija)",
- cca2: "si",
- "calling-code": "386"
- }, {
- name: "Solomon Islands",
- cca2: "sb",
- "calling-code": "677"
- }, {
- name: "Somalia (Soomaaliya)",
- cca2: "so",
- "calling-code": "252"
- }, {
- name: "South Africa",
- cca2: "za",
- "calling-code": "27"
- }, {
- name: "South Korea (대한민국)",
- cca2: "kr",
- "calling-code": "82"
- }, {
- name: "Spain (España)",
- cca2: "es",
- "calling-code": "34"
- }, {
- name: "Sri Lanka (ශ්රී ලංකාව)",
- cca2: "lk",
- "calling-code": "94"
- }, {
- name: "Sudan (السودان)",
- cca2: "sd",
- "calling-code": "249"
- }, {
- name: "Suriname",
- cca2: "sr",
- "calling-code": "597"
- }, {
- name: "Swaziland",
- cca2: "sz",
- "calling-code": "268"
- }, {
- name: "Sweden (Sverige)",
- cca2: "se",
- "calling-code": "46"
- }, {
- name: "Switzerland (Schweiz)",
- cca2: "ch",
- "calling-code": "41"
- }, {
- name: "Syria (سوريا)",
- cca2: "sy",
- "calling-code": "963"
- }, {
- name: "Taiwan (台灣)",
- cca2: "tw",
- "calling-code": "886"
- }, {
- name: "Tajikistan",
- cca2: "tj",
- "calling-code": "992"
- }, {
- name: "Tanzania",
- cca2: "tz",
- "calling-code": "255"
- }, {
- name: "Thailand (ไทย)",
- cca2: "th",
- "calling-code": "66"
- }, {
- name: "Timor-Leste",
- cca2: "tl",
- "calling-code": "670"
- }, {
- name: "Togo",
- cca2: "tg",
- "calling-code": "228"
- }, {
- name: "Tonga",
- cca2: "to",
- "calling-code": "676"
- }, {
- name: "Trinidad and Tobago",
- cca2: "tt",
- "calling-code": "1868"
- }, {
- name: "Tunisia (تونس)",
- cca2: "tn",
- "calling-code": "216"
- }, {
- name: "Turkey (Türkiye)",
- cca2: "tr",
- "calling-code": "90"
- }, {
- name: "Turkmenistan",
- cca2: "tm",
- "calling-code": "993"
- }, {
- name: "Turks and Caicos Islands",
- cca2: "tc",
- "calling-code": "1649"
- }, {
- name: "Tuvalu",
- cca2: "tv",
- "calling-code": "688"
- }, {
- name: "Uganda",
- cca2: "ug",
- "calling-code": "256"
- }, {
- name: "Ukraine (Україна)",
- cca2: "ua",
- "calling-code": "380"
- }, {
- name: "United Arab Emirates (الإمارات العربية المتحدة)",
- cca2: "ae",
- "calling-code": "971"
- }, {
- name: "United Kingdom",
- cca2: "gb",
- "calling-code": "44"
- }, {
- name: "United States",
- cca2: "us",
- "calling-code": "1"
- }, {
- name: "Uruguay",
- cca2: "uy",
- "calling-code": "598"
- }, {
- name: "Uzbekistan (Ўзбекистон)",
- cca2: "uz",
- "calling-code": "998"
- }, {
- name: "Vanuatu",
- cca2: "vu",
- "calling-code": "678"
- }, {
- name: "Vatican City (Città del Vaticano)",
- cca2: "va",
- "calling-code": "379"
- }, {
- name: "Venezuela",
- cca2: "ve",
- "calling-code": "58"
- }, {
- name: "Vietnam (Việt Nam)",
- cca2: "vn",
- "calling-code": "84"
- }, {
- name: "British Virgin Islands",
- cca2: "vg",
- "calling-code": "1284"
- }, {
- name: "U.S. Virgin Islands",
- cca2: "vi",
- "calling-code": "1340"
- }, {
- name: "Western Sahara (الصحراء الغربية)",
- cca2: "eh",
- "calling-code": "212"
- }, {
- name: "Yemen (اليمن)",
- cca2: "ye",
- "calling-code": "967"
- }, {
- name: "Zambia",
- cca2: "zm",
- "calling-code": "260"
- }, {
- name: "Zimbabwe",
- cca2: "zw",
- "calling-code": "263"
- } ],
- // JavaScript object mapping dial code to country code.
- // This is used when the user enters a number,
- // to quickly look up the corresponding country code.
- // Originally from http://libphonenumber.googlecode.com/svn/trunk/javascript/i18n/phonenumbers/metadata.js
- // then I commented some weird 001 entries and added some 4-digit country-code
- // items at the end e.g. 1246 for Barbados
- countryCodes: {
- "1": [ "us", "ca" ],
- "7": [ "ru", "kz" ],
- "20": [ "eg" ],
- "27": [ "za" ],
- "30": [ "gr" ],
- "31": [ "nl" ],
- "32": [ "be" ],
- "33": [ "fr" ],
- "34": [ "es" ],
- "36": [ "hu" ],
- "39": [ "it" ],
- "40": [ "ro" ],
- "41": [ "ch" ],
- "43": [ "at" ],
- "44": [ "gb", "gg", "im", "je" ],
- "45": [ "dk" ],
- "46": [ "se" ],
- "47": [ "no", "sj" ],
- "48": [ "pl" ],
- "49": [ "de" ],
- "51": [ "pe" ],
- "52": [ "mx" ],
- "53": [ "cu" ],
- "54": [ "ar" ],
- "55": [ "br" ],
- "56": [ "cl" ],
- "57": [ "co" ],
- "58": [ "ve" ],
- "60": [ "my" ],
- "61": [ "au", "cc", "cx" ],
- "62": [ "id" ],
- "63": [ "ph" ],
- "64": [ "nz" ],
- "65": [ "sg" ],
- "66": [ "th" ],
- "81": [ "jp" ],
- "82": [ "kr" ],
- "84": [ "vn" ],
- "86": [ "cn" ],
- "90": [ "tr" ],
- "91": [ "in" ],
- "92": [ "pk" ],
- "93": [ "af" ],
- "94": [ "lk" ],
- "95": [ "mm" ],
- "98": [ "ir" ],
- "211": [ "ss" ],
- "212": [ "ma", "eh" ],
- "213": [ "dz" ],
- "216": [ "tn" ],
- "218": [ "ly" ],
- "220": [ "gm" ],
- "221": [ "sn" ],
- "222": [ "mr" ],
- "223": [ "ml" ],
- "224": [ "gn" ],
- "225": [ "ci" ],
- "226": [ "bf" ],
- "227": [ "ne" ],
- "228": [ "tg" ],
- "229": [ "bj" ],
- "230": [ "mu" ],
- "231": [ "lr" ],
- "232": [ "sl" ],
- "233": [ "gh" ],
- "234": [ "ng" ],
- "235": [ "td" ],
- "236": [ "cf" ],
- "237": [ "cm" ],
- "238": [ "cv" ],
- "239": [ "st" ],
- "240": [ "gq" ],
- "241": [ "ga" ],
- "242": [ "cg" ],
- "243": [ "cd" ],
- "244": [ "ao" ],
- "245": [ "gw" ],
- "246": [ "io" ],
- "247": [ "ac" ],
- "248": [ "sc" ],
- "249": [ "sd" ],
- "250": [ "rw" ],
- "251": [ "et" ],
- "252": [ "so" ],
- "253": [ "dj" ],
- "254": [ "ke" ],
- "255": [ "tz" ],
- "256": [ "ug" ],
- "257": [ "bi" ],
- "258": [ "mz" ],
- "260": [ "zm" ],
- "261": [ "mg" ],
- "262": [ "re", "yt" ],
- "263": [ "zw" ],
- "264": [ "na" ],
- "265": [ "mw" ],
- "266": [ "ls" ],
- "267": [ "bw" ],
- "268": [ "sz" ],
- "269": [ "km" ],
- "290": [ "sh" ],
- "291": [ "er" ],
- "297": [ "aw" ],
- "298": [ "fo" ],
- "299": [ "gl" ],
- "350": [ "gi" ],
- "351": [ "pt" ],
- "352": [ "lu" ],
- "353": [ "ie" ],
- "354": [ "is" ],
- "355": [ "al" ],
- "356": [ "mt" ],
- "357": [ "cy" ],
- "358": [ "fi", "ax" ],
- "359": [ "bg" ],
- "370": [ "lt" ],
- "371": [ "lv" ],
- "372": [ "ee" ],
- "373": [ "md" ],
- "374": [ "am" ],
- "375": [ "by" ],
- "376": [ "ad" ],
- "377": [ "mc" ],
- "378": [ "sm" ],
- "379": [ "va" ],
- "380": [ "ua" ],
- "381": [ "rs" ],
- "382": [ "me" ],
- "385": [ "hr" ],
- "386": [ "si" ],
- "387": [ "ba" ],
- "389": [ "mk" ],
- "420": [ "cz" ],
- "421": [ "sk" ],
- "423": [ "li" ],
- "500": [ "fk" ],
- "501": [ "bz" ],
- "502": [ "gt" ],
- "503": [ "sv" ],
- "504": [ "hn" ],
- "505": [ "ni" ],
- "506": [ "cr" ],
- "507": [ "pa" ],
- "508": [ "pm" ],
- "509": [ "ht" ],
- "590": [ "gp", "bl", "mf" ],
- "591": [ "bo" ],
- "592": [ "gy" ],
- "593": [ "ec" ],
- "594": [ "gf" ],
- "595": [ "py" ],
- "596": [ "mq" ],
- "597": [ "sr" ],
- "598": [ "uy" ],
- "599": [ "cw", "bq" ],
- "670": [ "tl" ],
- "672": [ "nf" ],
- "673": [ "bn" ],
- "674": [ "nr" ],
- "675": [ "pg" ],
- "676": [ "to" ],
- "677": [ "sb" ],
- "678": [ "vu" ],
- "679": [ "fj" ],
- "680": [ "pw" ],
- "681": [ "wf" ],
- "682": [ "ck" ],
- "683": [ "nu" ],
- "685": [ "ws" ],
- "686": [ "ki" ],
- "687": [ "nc" ],
- "688": [ "tv" ],
- "689": [ "pf" ],
- "690": [ "tk" ],
- "691": [ "fm" ],
- "692": [ "mh" ],
- "850": [ "kp" ],
- "852": [ "hk" ],
- "853": [ "mo" ],
- "855": [ "kh" ],
- "856": [ "la" ],
- "880": [ "bd" ],
- "886": [ "tw" ],
- "960": [ "mv" ],
- "961": [ "lb" ],
- "962": [ "jo" ],
- "963": [ "sy" ],
- "964": [ "iq" ],
- "965": [ "kw" ],
- "966": [ "sa" ],
- "967": [ "ye" ],
- "968": [ "om" ],
- "970": [ "ps" ],
- "971": [ "ae" ],
- "972": [ "il" ],
- "973": [ "bh" ],
- "974": [ "qa" ],
- "975": [ "bt" ],
- "976": [ "mn" ],
- "977": [ "np" ],
- "992": [ "tj" ],
- "993": [ "tm" ],
- "994": [ "az" ],
- "995": [ "ge" ],
- "996": [ "kg" ],
- "998": [ "uz" ],
- "1242": [ "bs" ],
- "1246": [ "bb" ],
- "1264": [ "ai" ],
- "1268": [ "ag" ],
- "1284": [ "vg" ],
- "1340": [ "vi" ],
- "1345": [ "ky" ],
- "1441": [ "bm" ],
- "1473": [ "gd" ],
- "1649": [ "tc" ],
- "1664": [ "ms" ],
- "1671": [ "gu" ],
- "1684": [ "as" ],
- "1758": [ "lc" ],
- "1767": [ "dm" ],
- "1784": [ "vc" ],
- "1787": [ "pr" ],
- "1809": [ "do" ],
- "1868": [ "tt" ],
- "1869": [ "kn" ],
- "1876": [ "jm" ]
- }
-};
-
-})();
diff --git a/vendor/assets/javascripts/jquery.autosize.js b/vendor/assets/javascripts/jquery.autosize.js
deleted file mode 100755
index 2a1f78852..000000000
--- a/vendor/assets/javascripts/jquery.autosize.js
+++ /dev/null
@@ -1,258 +0,0 @@
-/*!
- Autosize v1.18.0 - 2013-10-20
- Automatically adjust textarea height based on user input.
- (c) 2013 Jack Moore - http://www.jacklmoore.com/autosize
- license: http://www.opensource.org/licenses/mit-license.php
-*/
-(function (factory) {
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module.
- define(['jquery'], factory);
- } else {
- // Browser globals: jQuery or jQuery-like library, such as Zepto
- factory(window.jQuery || window.$);
- }
-}(function ($) {
- var
- defaults = {
- className: 'autosizejs',
- append: '',
- callback: false,
- resizeDelay: 10
- },
-
- // border:0 is unnecessary, but avoids a bug in FireFox on OSX
- copy = '',
-
- // line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
- typographyStyles = [
- 'fontFamily',
- 'fontSize',
- 'fontWeight',
- 'fontStyle',
- 'letterSpacing',
- 'textTransform',
- 'wordSpacing',
- 'textIndent'
- ],
-
- // to keep track which textarea is being mirrored when adjust() is called.
- mirrored,
-
- // the mirror element, which is used to calculate what size the mirrored element should be.
- mirror = $(copy).data('autosize', true)[0];
-
- // test that line-height can be accurately copied.
- mirror.style.lineHeight = '99px';
- if ($(mirror).css('lineHeight') === '99px') {
- typographyStyles.push('lineHeight');
- }
- mirror.style.lineHeight = '';
-
- $.fn.autosize = function (options) {
- if (!this.length) {
- return this;
- }
-
- options = $.extend({}, defaults, options || {});
-
- if (mirror.parentNode !== document.body) {
- $(document.body).append(mirror);
- }
-
- return this.each(function () {
- var
- ta = this,
- $ta = $(ta),
- maxHeight,
- minHeight,
- boxOffset = 0,
- callback = $.isFunction(options.callback),
- originalStyles = {
- height: ta.style.height,
- overflow: ta.style.overflow,
- overflowY: ta.style.overflowY,
- wordWrap: ta.style.wordWrap,
- resize: ta.style.resize
- },
- timeout,
- width = $ta.width();
-
- if ($ta.data('autosize')) {
- // exit if autosize has already been applied, or if the textarea is the mirror element.
- return;
- }
- $ta.data('autosize', true);
-
- if ($ta.css('box-sizing') === 'border-box' || $ta.css('-moz-box-sizing') === 'border-box' || $ta.css('-webkit-box-sizing') === 'border-box'){
- boxOffset = $ta.outerHeight() - $ta.height();
- }
-
- // IE8 and lower return 'auto', which parses to NaN, if no min-height is set.
- minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height());
-
- $ta.css({
- overflow: 'hidden',
- overflowY: 'hidden',
- wordWrap: 'break-word', // horizontal overflow is hidden, so break-word is necessary for handling words longer than the textarea width
- resize: ($ta.css('resize') === 'none' || $ta.css('resize') === 'vertical') ? 'none' : 'horizontal'
- });
-
- // The mirror width must exactly match the textarea width, so using getBoundingClientRect because it doesn't round the sub-pixel value.
- function setWidth() {
- var style, width;
-
- if ('getComputedStyle' in window) {
- style = window.getComputedStyle(ta, null);
- width = ta.getBoundingClientRect().width;
-
- $.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){
- width -= parseInt(style[val],10);
- });
-
- mirror.style.width = width + 'px';
- }
- else {
- // window.getComputedStyle, getBoundingClientRect returning a width are unsupported and unneeded in IE8 and lower.
- mirror.style.width = Math.max($ta.width(), 0) + 'px';
- }
- }
-
- function initMirror() {
- var styles = {};
-
- mirrored = ta;
- mirror.className = options.className;
- maxHeight = parseInt($ta.css('maxHeight'), 10);
-
- // mirror is a duplicate textarea located off-screen that
- // is automatically updated to contain the same text as the
- // original textarea. mirror always has a height of 0.
- // This gives a cross-browser supported way getting the actual
- // height of the text, through the scrollTop property.
- $.each(typographyStyles, function(i,val){
- styles[val] = $ta.css(val);
- });
- $(mirror).css(styles);
-
- setWidth();
-
- // Chrome-specific fix:
- // When the textarea y-overflow is hidden, Chrome doesn't reflow the text to account for the space
- // made available by removing the scrollbar. This workaround triggers the reflow for Chrome.
- if (window.chrome) {
- var width = ta.style.width;
- ta.style.width = '0px';
- var ignore = ta.offsetWidth;
- ta.style.width = width;
- }
- }
-
- // Using mainly bare JS in this function because it is going
- // to fire very often while typing, and needs to very efficient.
- function adjust() {
- var height, original;
-
- if (mirrored !== ta) {
- initMirror();
- } else {
- setWidth();
- }
-
- mirror.value = ta.value + options.append;
- mirror.style.overflowY = ta.style.overflowY;
- original = parseInt(ta.style.height,10);
-
- // Setting scrollTop to zero is needed in IE8 and lower for the next step to be accurately applied
- mirror.scrollTop = 0;
-
- mirror.scrollTop = 9e4;
-
- // Using scrollTop rather than scrollHeight because scrollHeight is non-standard and includes padding.
- height = mirror.scrollTop;
-
- if (maxHeight && height > maxHeight) {
- ta.style.overflowY = 'scroll';
- height = maxHeight;
- } else {
- ta.style.overflowY = 'hidden';
- if (height < minHeight) {
- height = minHeight;
- }
- }
-
- height += boxOffset;
-
- if (original !== height) {
- ta.style.height = height + 'px';
- if (callback) {
- options.callback.call(ta,ta);
- }
- }
- }
-
- function resize () {
- clearTimeout(timeout);
- timeout = setTimeout(function(){
- var newWidth = $ta.width();
-
- if (newWidth !== width) {
- width = newWidth;
- adjust();
- }
- }, parseInt(options.resizeDelay,10));
- }
-
- if ('onpropertychange' in ta) {
- if ('oninput' in ta) {
- // Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
- // so binding to onkeyup to catch most of those occasions. There is no way that I
- // know of to detect something like 'cut' in IE9.
- $ta.on('input.autosize keyup.autosize', adjust);
- } else {
- // IE7 / IE8
- $ta.on('propertychange.autosize', function(){
- if(event.propertyName === 'value'){
- adjust();
- }
- });
- }
- } else {
- // Modern Browsers
- $ta.on('input.autosize', adjust);
- }
-
- // Set options.resizeDelay to false if using fixed-width textarea elements.
- // Uses a timeout and width check to reduce the amount of times adjust needs to be called after window resize.
-
- if (options.resizeDelay !== false) {
- $(window).on('resize.autosize', resize);
- }
-
- // Event for manual triggering if needed.
- // Should only be needed when the value of the textarea is changed through JavaScript rather than user input.
- $ta.on('autosize.resize', adjust);
-
- // Event for manual triggering that also forces the styles to update as well.
- // Should only be needed if one of typography styles of the textarea change, and the textarea is already the target of the adjust method.
- $ta.on('autosize.resizeIncludeStyle', function() {
- mirrored = null;
- adjust();
- });
-
- $ta.on('autosize.destroy', function(){
- mirrored = null;
- clearTimeout(timeout);
- $(window).off('resize', resize);
- $ta
- .off('autosize')
- .off('.autosize')
- .css(originalStyles)
- .removeData('autosize');
- });
-
- // Call adjust in case the textarea already contains text.
- adjust();
- });
- };
-}));
diff --git a/vendor/assets/javascripts/jquery.geocomplete.js b/vendor/assets/javascripts/jquery.geocomplete.js
deleted file mode 100644
index a894cd8e6..000000000
--- a/vendor/assets/javascripts/jquery.geocomplete.js
+++ /dev/null
@@ -1,595 +0,0 @@
-/**
- * jQuery Geocoding and Places Autocomplete Plugin - V 1.7.0
- *
- * @author Martin Kleppe , 2016
- * @author Ubilabs http://ubilabs.net, 2016
- * @license MIT License
- */
-
-// # $.geocomplete()
-// ## jQuery Geocoding and Places Autocomplete Plugin
-//
-// * https://github.com/ubilabs/geocomplete/
-// * by Martin Kleppe
-
-(function($, window, document, undefined){
-
- // ## Options
- // The default options for this plugin.
- //
- // * `map` - Might be a selector, an jQuery object or a DOM element. Default is `false` which shows no map.
- // * `details` - The container that should be populated with data. Defaults to `false` which ignores the setting.
- // * 'detailsScope' - Allows you to scope the 'details' container and have multiple geocomplete fields on one page. Must be a parent of the input. Default is 'null'
- // * `location` - Location to initialize the map on. Might be an address `string` or an `array` with [latitude, longitude] or a `google.maps.LatLng`object. Default is `false` which shows a blank map.
- // * `bounds` - Whether to snap geocode search to map bounds. Default: `true` if false search globally. Alternatively pass a custom `LatLngBounds object.
- // * `autoselect` - Automatically selects the highlighted item or the first item from the suggestions list on Enter.
- // * `detailsAttribute` - The attribute's name to use as an indicator. Default: `"name"`
- // * `mapOptions` - Options to pass to the `google.maps.Map` constructor. See the full list [here](http://code.google.com/apis/maps/documentation/javascript/reference.html#MapOptions).
- // * `mapOptions.zoom` - The inital zoom level. Default: `14`
- // * `mapOptions.scrollwheel` - Whether to enable the scrollwheel to zoom the map. Default: `false`
- // * `mapOptions.mapTypeId` - The map type. Default: `"roadmap"`
- // * `markerOptions` - The options to pass to the `google.maps.Marker` constructor. See the full list [here](http://code.google.com/apis/maps/documentation/javascript/reference.html#MarkerOptions).
- // * `markerOptions.draggable` - If the marker is draggable. Default: `false`. Set to true to enable dragging.
- // * `markerOptions.disabled` - Do not show marker. Default: `false`. Set to true to disable marker.
- // * `maxZoom` - The maximum zoom level too zoom in after a geocoding response. Default: `16`
- // * `types` - An array containing one or more of the supported types for the places request. Default: `['geocode']` See the full list [here](http://code.google.com/apis/maps/documentation/javascript/places.html#place_search_requests).
- // * `blur` - Trigger geocode when input loses focus.
- // * `geocodeAfterResult` - If blur is set to true, choose whether to geocode if user has explicitly selected a result before blur.
- // * `restoreValueAfterBlur` - Restores the input's value upon blurring. Default is `false` which ignores the setting.
-
- var defaults = {
- bounds: true,
- strictBounds: false,
- country: null,
- map: false,
- details: false,
- detailsAttribute: "name",
- detailsScope: null,
- autoselect: true,
- location: false,
-
- mapOptions: {
- zoom: 14,
- scrollwheel: false,
- mapTypeId: "roadmap"
- },
-
- markerOptions: {
- draggable: false
- },
-
- maxZoom: 16,
- types: ['geocode'],
- blur: false,
- geocodeAfterResult: false,
- restoreValueAfterBlur: false
- };
-
- // See: [Geocoding Types](https://developers.google.com/maps/documentation/geocoding/#Types)
- // on Google Developers.
- var componentTypes = ("street_address route intersection political " +
- "country administrative_area_level_1 administrative_area_level_2 " +
- "administrative_area_level_3 colloquial_area locality sublocality " +
- "neighborhood premise subpremise postal_code natural_feature airport " +
- "park point_of_interest post_box street_number floor room " +
- "lat lng viewport location " +
- "formatted_address location_type bounds").split(" ");
-
- // See: [Places Details Responses](https://developers.google.com/maps/documentation/javascript/places#place_details_responses)
- // on Google Developers.
- var placesDetails = ("id place_id url website vicinity reference name rating " +
- "international_phone_number icon formatted_phone_number").split(" ");
-
- // The actual plugin constructor.
- function GeoComplete(input, options) {
-
- this.options = $.extend(true, {}, defaults, options);
-
- // This is a fix to allow types:[] not to be overridden by defaults
- // so search results includes everything
- if (options && options.types) {
- this.options.types = options.types;
- }
-
- this.input = input;
- this.$input = $(input);
-
- this._defaults = defaults;
- this._name = 'geocomplete';
-
- this.init();
- }
-
- // Initialize all parts of the plugin.
- $.extend(GeoComplete.prototype, {
- init: function(){
- this.initMap();
- this.initMarker();
- this.initGeocoder();
- this.initDetails();
- this.initLocation();
- },
-
- // Initialize the map but only if the option `map` was set.
- // This will create a `map` within the given container
- // using the provided `mapOptions` or link to the existing map instance.
- initMap: function(){
- if (!this.options.map){ return; }
-
- if (typeof this.options.map.setCenter == "function"){
- this.map = this.options.map;
- return;
- }
-
- this.map = new google.maps.Map(
- $(this.options.map)[0],
- this.options.mapOptions
- );
-
- // add click event listener on the map
- google.maps.event.addListener(
- this.map,
- 'click',
- $.proxy(this.mapClicked, this)
- );
-
- // add dragend even listener on the map
- google.maps.event.addListener(
- this.map,
- 'dragend',
- $.proxy(this.mapDragged, this)
- );
-
- // add idle even listener on the map
- google.maps.event.addListener(
- this.map,
- 'idle',
- $.proxy(this.mapIdle, this)
- );
-
- google.maps.event.addListener(
- this.map,
- 'zoom_changed',
- $.proxy(this.mapZoomed, this)
- );
- },
-
- // Add a marker with the provided `markerOptions` but only
- // if the option was set. Additionally it listens for the `dragend` event
- // to notify the plugin about changes.
- initMarker: function(){
- if (!this.map){ return; }
- var options = $.extend(this.options.markerOptions, { map: this.map });
-
- if (options.disabled){ return; }
-
- this.marker = new google.maps.Marker(options);
-
- google.maps.event.addListener(
- this.marker,
- 'dragend',
- $.proxy(this.markerDragged, this)
- );
- },
-
- // Associate the input with the autocompleter and create a geocoder
- // to fall back when the autocompleter does not return a value.
- initGeocoder: function(){
-
- // Indicates is user did select a result from the dropdown.
- var selected = false;
-
- var options = {
- types: this.options.types,
- bounds: this.options.bounds === true ? null : this.options.bounds,
- componentRestrictions: this.options.componentRestrictions,
- strictBounds: this.options.strictBounds
- };
-
- if (this.options.country){
- options.componentRestrictions = {country: this.options.country};
- }
-
- this.autocomplete = new google.maps.places.Autocomplete(
- this.input, options
- );
-
- this.geocoder = new google.maps.Geocoder();
-
- // Bind autocomplete to map bounds but only if there is a map
- // and `options.bindToMap` is set to true.
- if (this.map && this.options.bounds === true){
- this.autocomplete.bindTo('bounds', this.map);
- }
-
- // Watch `place_changed` events on the autocomplete input field.
- google.maps.event.addListener(
- this.autocomplete,
- 'place_changed',
- $.proxy(this.placeChanged, this)
- );
-
- // Prevent parent form from being submitted if user hit enter.
- this.$input.on('keypress.' + this._name, function(event){
- if (event.keyCode === 13){ return false; }
- });
-
- // Assume that if user types anything after having selected a result,
- // the selected location is not valid any more.
- if (this.options.geocodeAfterResult === true){
- this.$input.bind('keypress.' + this._name, $.proxy(function(){
- if (event.keyCode != 9 && this.selected === true){
- this.selected = false;
- }
- }, this));
- }
-
- // Listen for "geocode" events and trigger find action.
- this.$input.bind('geocode.' + this._name, $.proxy(function(){
- this.find();
- }, this));
-
- // Saves the previous input value
- this.$input.bind('geocode:result.' + this._name, $.proxy(function(){
- this.lastInputVal = this.$input.val();
- }, this));
-
- // Trigger find action when input element is blurred out and user has
- // not explicitly selected a result.
- // (Useful for typing partial location and tabbing to the next field
- // or clicking somewhere else.)
- if (this.options.blur === true){
- this.$input.on('blur.' + this._name, $.proxy(function(){
- if (this.options.geocodeAfterResult === true && this.selected === true) { return; }
-
- if (this.options.restoreValueAfterBlur === true && this.selected === true) {
- setTimeout($.proxy(this.restoreLastValue, this), 0);
- } else {
- this.find();
- }
- }, this));
- }
- },
-
- // Prepare a given DOM structure to be populated when we got some data.
- // This will cycle through the list of component types and map the
- // corresponding elements.
- initDetails: function(){
- if (!this.options.details){ return; }
-
- if(this.options.detailsScope) {
- var $details = $(this.input).parents(this.options.detailsScope).find(this.options.details);
- } else {
- var $details = $(this.options.details);
- }
-
- var attribute = this.options.detailsAttribute,
- details = {};
-
- function setDetail(value){
- details[value] = $details.find("[" + attribute + "=" + value + "]");
- }
-
- $.each(componentTypes, function(index, key){
- setDetail(key);
- setDetail(key + "_short");
- });
-
- $.each(placesDetails, function(index, key){
- setDetail(key);
- });
-
- this.$details = $details;
- this.details = details;
- },
-
- // Set the initial location of the plugin if the `location` options was set.
- // This method will care about converting the value into the right format.
- initLocation: function() {
-
- var location = this.options.location, latLng;
-
- if (!location) { return; }
-
- if (typeof location == 'string') {
- this.find(location);
- return;
- }
-
- if (location instanceof Array) {
- latLng = new google.maps.LatLng(location[0], location[1]);
- }
-
- if (location instanceof google.maps.LatLng){
- latLng = location;
- }
-
- if (latLng){
- if (this.map){ this.map.setCenter(latLng); }
- if (this.marker){ this.marker.setPosition(latLng); }
- }
- },
-
- destroy: function(){
- if (this.map) {
- google.maps.event.clearInstanceListeners(this.map);
- google.maps.event.clearInstanceListeners(this.marker);
- }
-
- this.autocomplete.unbindAll();
- google.maps.event.clearInstanceListeners(this.autocomplete);
- google.maps.event.clearInstanceListeners(this.input);
- this.$input.removeData();
- this.$input.off(this._name);
- this.$input.unbind('.' + this._name);
- },
-
- // Look up a given address. If no `address` was specified it uses
- // the current value of the input.
- find: function(address){
- this.geocode({
- address: address || this.$input.val()
- });
- },
-
- // Requests details about a given location.
- // Additionally it will bias the requests to the provided bounds.
- geocode: function(request){
- // Don't geocode if the requested address is empty
- if (!request.address) {
- return;
- }
- if (this.options.bounds && !request.bounds){
- if (this.options.bounds === true){
- request.bounds = this.map && this.map.getBounds();
- } else {
- request.bounds = this.options.bounds;
- }
- }
-
- if (this.options.country){
- request.region = this.options.country;
- }
-
- this.geocoder.geocode(request, $.proxy(this.handleGeocode, this));
- },
-
- // Get the selected result. If no result is selected on the list, then get
- // the first result from the list.
- selectFirstResult: function() {
- //$(".pac-container").hide();
-
- var selected = '';
- // Check if any result is selected.
- if ($(".pac-item-selected")[0]) {
- selected = '-selected';
- }
-
- // Get the first suggestion's text.
- var $span1 = $(".pac-container:visible .pac-item" + selected + ":first span:nth-child(2)").text();
- var $span2 = $(".pac-container:visible .pac-item" + selected + ":first span:nth-child(3)").text();
-
- // Adds the additional information, if available.
- var firstResult = $span1;
- if ($span2) {
- firstResult += " - " + $span2;
- }
-
- this.$input.val(firstResult);
-
- return firstResult;
- },
-
- // Restores the input value using the previous value if it exists
- restoreLastValue: function() {
- if (this.lastInputVal){ this.$input.val(this.lastInputVal); }
- },
-
- // Handles the geocode response. If more than one results was found
- // it triggers the "geocode:multiple" events. If there was an error
- // the "geocode:error" event is fired.
- handleGeocode: function(results, status){
- if (status === google.maps.GeocoderStatus.OK) {
- var result = results[0];
- this.$input.val(result.formatted_address);
- this.update(result);
-
- if (results.length > 1){
- this.trigger("geocode:multiple", results);
- }
-
- } else {
- this.trigger("geocode:error", status);
- }
- },
-
- // Triggers a given `event` with optional `arguments` on the input.
- trigger: function(event, argument){
- this.$input.trigger(event, [argument]);
- },
-
- // Set the map to a new center by passing a `geometry`.
- // If the geometry has a viewport, the map zooms out to fit the bounds.
- // Additionally it updates the marker position.
- center: function(geometry){
- if (geometry.viewport){
- this.map.fitBounds(geometry.viewport);
- if (this.map.getZoom() > this.options.maxZoom){
- this.map.setZoom(this.options.maxZoom);
- }
- } else {
- this.map.setZoom(this.options.maxZoom);
- this.map.setCenter(geometry.location);
- }
-
- if (this.marker){
- this.marker.setPosition(geometry.location);
- this.marker.setAnimation(this.options.markerOptions.animation);
- }
- },
-
- // Update the elements based on a single places or geocoding response
- // and trigger the "geocode:result" event on the input.
- update: function(result){
-
- if (this.map){
- this.center(result.geometry);
- }
-
- if (this.$details){
- this.fillDetails(result);
- }
-
- this.trigger("geocode:result", result);
- },
-
- // Populate the provided elements with new `result` data.
- // This will lookup all elements that has an attribute with the given
- // component type.
- fillDetails: function(result){
-
- var data = {},
- geometry = result.geometry,
- viewport = geometry.viewport,
- bounds = geometry.bounds;
-
- // Create a simplified version of the address components.
- $.each(result.address_components, function(index, object){
- var name = object.types[0];
-
- $.each(object.types, function(index, name){
- data[name] = object.long_name;
- data[name + "_short"] = object.short_name;
- });
- });
-
- // Add properties of the places details.
- $.each(placesDetails, function(index, key){
- data[key] = result[key];
- });
-
- // Add infos about the address and geometry.
- $.extend(data, {
- formatted_address: result.formatted_address,
- location_type: geometry.location_type || "PLACES",
- viewport: viewport,
- bounds: bounds,
- location: geometry.location,
- lat: geometry.location.lat(),
- lng: geometry.location.lng()
- });
-
- // Set the values for all details.
- $.each(this.details, $.proxy(function(key, $detail){
- var value = data[key];
- this.setDetail($detail, value);
- }, this));
-
- this.data = data;
- },
-
- // Assign a given `value` to a single `$element`.
- // If the element is an input, the value is set, otherwise it updates
- // the text content.
- setDetail: function($element, value){
-
- if (value === undefined){
- value = "";
- } else if (typeof value.toUrlValue == "function"){
- value = value.toUrlValue();
- }
-
- if ($element.is(":input")){
- $element.val(value);
- } else {
- $element.text(value);
- }
- },
-
- // Fire the "geocode:dragged" event and pass the new position.
- markerDragged: function(event){
- this.trigger("geocode:dragged", event.latLng);
- },
-
- mapClicked: function(event) {
- this.trigger("geocode:click", event.latLng);
- },
-
- // Fire the "geocode:mapdragged" event and pass the current position of the map center.
- mapDragged: function(event) {
- this.trigger("geocode:mapdragged", this.map.getCenter());
- },
-
- // Fire the "geocode:idle" event and pass the current position of the map center.
- mapIdle: function(event) {
- this.trigger("geocode:idle", this.map.getCenter());
- },
-
- mapZoomed: function(event) {
- this.trigger("geocode:zoom", this.map.getZoom());
- },
-
- // Restore the old position of the marker to the last knwon location.
- resetMarker: function(){
- this.marker.setPosition(this.data.location);
- this.setDetail(this.details.lat, this.data.location.lat());
- this.setDetail(this.details.lng, this.data.location.lng());
- },
-
- // Update the plugin after the user has selected an autocomplete entry.
- // If the place has no geometry it passes it to the geocoder.
- placeChanged: function(){
- var place = this.autocomplete.getPlace();
- this.selected = true;
-
- if (!place.geometry){
- if (this.options.autoselect) {
- // Automatically selects the highlighted item or the first item from the
- // suggestions list.
- var autoSelection = this.selectFirstResult();
- this.find(autoSelection);
- }
- } else {
- // Use the input text if it already gives geometry.
- this.update(place);
- }
- }
- });
-
- // A plugin wrapper around the constructor.
- // Pass `options` with all settings that are different from the default.
- // The attribute is used to prevent multiple instantiations of the plugin.
- $.fn.geocomplete = function(options) {
-
- var attribute = 'plugin_geocomplete';
-
- // If you call `.geocomplete()` with a string as the first parameter
- // it returns the corresponding property or calls the method with the
- // following arguments.
- if (typeof options == "string"){
-
- var instance = $(this).data(attribute) || $(this).geocomplete().data(attribute),
- prop = instance[options];
-
- if (typeof prop == "function"){
- prop.apply(instance, Array.prototype.slice.call(arguments, 1));
- return $(this);
- } else {
- if (arguments.length == 2){
- prop = arguments[1];
- }
- return prop;
- }
- } else {
- return this.each(function() {
- // Prevent against multiple instantiations.
- var instance = $.data(this, attribute);
- if (!instance) {
- instance = new GeoComplete( this, options );
- $.data(this, attribute, instance);
- }
- });
- }
- };
-
-})( jQuery, window, document );
\ No newline at end of file
diff --git a/vendor/assets/javascripts/jquery.limit-1.2.js b/vendor/assets/javascripts/jquery.limit-1.2.js
deleted file mode 100644
index 50ad8094d..000000000
--- a/vendor/assets/javascripts/jquery.limit-1.2.js
+++ /dev/null
@@ -1,31 +0,0 @@
-(function($){
- $.fn.extend({
- limit: function(limit,element) {
-
- var interval, f;
- var self = $(this);
-
- $(this).focus(function(){
- interval = window.setInterval(substring,100);
- });
-
- $(this).blur(function(){
- clearInterval(interval);
- substring();
- });
-
- substringFunction = "function substring(){ var val = $(self).val();var length = val.length;if(length > limit){$(self).val($(self).val().substring(0,limit));}";
- if(typeof element != 'undefined')
- substringFunction += "if($(element).html() != limit-length){$(element).html((limit-length<=0)?'0':limit-length);}"
-
- substringFunction += "}";
-
- eval(substringFunction);
-
-
-
- substring();
-
- }
- });
-})(jQuery);
\ No newline at end of file
diff --git a/vendor/assets/javascripts/jquery.succinct.js b/vendor/assets/javascripts/jquery.succinct.js
deleted file mode 100644
index 2a24bf370..000000000
--- a/vendor/assets/javascripts/jquery.succinct.js
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2013 Mike King (@micjamking)
- *
- * jQuery Succinct plugin
- * Version 1.0.1 (July 2013)
- *
- * Licensed under the MIT License
- */
-
- /*global jQuery*/
-(function($){
- 'use strict';
-
- $.fn.succinct = function(options){
-
- var defaults = {
- size: 240,
- omission: '...',
- ignore: true
- },
- options = $.extend(defaults, options);
-
- return this.each(function(){
-
- var textDefault,
- textTruncated,
- elements = $(this),
- regex = /[!-\/:-@\[-`{-~]$/;
-
- var truncate = function(){
-
- elements.each(function(){
- textDefault = $(this).text();
-
- if (textDefault.length > options.size) {
- textTruncated = $.trim(textDefault).
- substring(0, options.size).
- split(' ').
- slice(0, -1).
- join(' ');
-
- if (options.ignore) {
- textTruncated = textTruncated.replace( regex , '' );
- }
-
- $(this).text(textTruncated + options.omission);
- }
- });
- };
-
- var init = function() {
- truncate();
- };
-
- init();
- });
- };
-})(jQuery);
diff --git a/vendor/assets/javascripts/jquery.taggd.js b/vendor/assets/javascripts/jquery.taggd.js
deleted file mode 100644
index d7b16d2df..000000000
--- a/vendor/assets/javascripts/jquery.taggd.js
+++ /dev/null
@@ -1,163 +0,0 @@
-(function($) {
- var settings = {
- 'align': {
- 'x': 'center',
- 'y': 'center'
- },
-
- 'handlers': {},
-
- 'offset': {
- 'left': 0,
- 'top': 0
- }
- };
-
- var methods = {
- 'init': function(opt) {
- var wrapper = $('');
- var $this = this;
-
- $this.wrap(wrapper);
-
- $this.settings = {};
- $.extend(true, $this.settings, settings);
- $.extend(true, $this.settings, opt);
-
-
- $(window).resize(function() {
- methods.draw.call($this);
- });
- },
-
- 'items': function(items) {
- var $this = this;
- $this.settings = settings;
- var $wrapper = $this.parent('.taggd-wrapper');
-
- $this.css({ 'height': 'auto', 'width': 'auto' });
-
- var height = this.height;
- var width = this.width;
-
- $.each(items, function(i, v) {
- var item = $('');
-
- if(v.x > 1 && v.x % 1 === 0 && v.y > 1 && v.y % 1 === 0) {
- v.x = v.x / width;
- v.y = v.y / height;
- }
-
- item.attr('data-x', v.x);
- item.attr('data-y', v.y);
-
- $wrapper.append(item);
-
- if(typeof v.text === 'string' && v.text.length > 0) {
- var hover = $('').html(v.text);
-
- hover.attr('data-x', v.x);
- hover.attr('data-y', v.y);
-
- $wrapper.append(hover);
- }
-
- if(typeof $this.settings.handlers === 'object') {
- for(var h in $this.settings.handlers) {
- var f = $this.settings.handlers[h];
-
- if(typeof f === 'string') {
- switch(f) {
- case 'show':
- item.on(h, methods.show);
- break;
- case 'hide':
- item.on(h, methods.hide);
- break;
- case 'toggle':
- item.on(h, methods.toggle);
- break;
- }
- } else if(typeof f === 'function') {
- item.on(h, v, $this.settings.handlers[h]);
- }
- }
- }
- });
-
- $this.removeAttr('style');
- methods.draw.call($this);
- },
-
- 'show': function() {
- var $this = $(this);
- $this.addClass('active');
- $this.next().addClass('show');
- },
-
- 'hide': function() {
- var $this = $(this);
- $this.removeClass('active');
- $this.next().removeClass('show');
- },
-
- 'toggle': function() {
- var hover = $(this).next();
-
- if(hover.hasClass('show')) methods.hide.call(this);
- else methods.show.call(this);
- },
-
- 'draw': function() {
- var $this = this;
- var $parent = $this.parent('.taggd-wrapper');
- var poffset = $parent.offset();
-
- $parent.removeAttr('style').css({
- 'height': $this.height(),
- 'width': $this.width()
- });
-
- $parent.find('span').each(function(i, e) {
- var $el = $(e);
-
- var left = $el.attr('data-x') * $this.width() + poffset.left;
- var top = $el.attr('data-y') * $this.height() + poffset.top;
-
- if($el.hasClass('taggd-item')) {
- $el.css({
- 'left': left - $el.outerWidth(true) / 2,
- 'top': top - $el.outerHeight(true) / 2
- });
- } else if($el.hasClass('taggd-item-hover')) {
- if($this.settings.align.x === 'center') {
- left -= $el.outerWidth(true) / 2;
- } else if($this.settings.align.x === 'right') {
- left -= $el.outerWidth(true)
- }
-
- if($this.settings.align.y === 'center') {
- top -= $el.outerHeight(true) / 2;
- } else if($this.settings.align.y === 'bottom') {
- top -= $el.outerHeight(true)
- }
-
- $el.css({
- 'left': left + $this.settings.offset.left,
- 'top': top + $this.settings.offset.top
- });
- }
- });
- }
- };
-
- $.fn.taggd = function(opt) {
- if(methods[opt]) {
- return methods[opt].apply(this, Array.prototype.slice.call(arguments, 1));
- } else if (typeof opt === 'object' || !opt) {
- return methods.init.apply(this, arguments);
- }
-
- return this;
- };
-})(jQuery);
diff --git a/vendor/assets/javascripts/list.js b/vendor/assets/javascripts/list.js
deleted file mode 100644
index 730ca74cc..000000000
--- a/vendor/assets/javascripts/list.js
+++ /dev/null
@@ -1,1436 +0,0 @@
-;(function(){
-
-/**
- * Require the given path.
- *
- * @param {String} path
- * @return {Object} exports
- * @api public
- */
-
-function require(path, parent, orig) {
- var resolved = require.resolve(path);
-
- // lookup failed
- if (null == resolved) {
- orig = orig || path;
- parent = parent || 'root';
- var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
- err.path = orig;
- err.parent = parent;
- err.require = true;
- throw err;
- }
-
- var module = require.modules[resolved];
-
- // perform real require()
- // by invoking the module's
- // registered function
- if (!module._resolving && !module.exports) {
- var mod = {};
- mod.exports = {};
- mod.client = mod.component = true;
- module._resolving = true;
- module.call(this, mod.exports, require.relative(resolved), mod);
- delete module._resolving;
- module.exports = mod.exports;
- }
-
- return module.exports;
-}
-
-/**
- * Registered modules.
- */
-
-require.modules = {};
-
-/**
- * Registered aliases.
- */
-
-require.aliases = {};
-
-/**
- * Resolve `path`.
- *
- * Lookup:
- *
- * - PATH/index.js
- * - PATH.js
- * - PATH
- *
- * @param {String} path
- * @return {String} path or null
- * @api private
- */
-
-require.resolve = function(path) {
- if (path.charAt(0) === '/') path = path.slice(1);
-
- var paths = [
- path,
- path + '.js',
- path + '.json',
- path + '/index.js',
- path + '/index.json'
- ];
-
- for (var i = 0; i < paths.length; i++) {
- var path = paths[i];
- if (require.modules.hasOwnProperty(path)) return path;
- if (require.aliases.hasOwnProperty(path)) return require.aliases[path];
- }
-};
-
-/**
- * Normalize `path` relative to the current path.
- *
- * @param {String} curr
- * @param {String} path
- * @return {String}
- * @api private
- */
-
-require.normalize = function(curr, path) {
- var segs = [];
-
- if ('.' != path.charAt(0)) return path;
-
- curr = curr.split('/');
- path = path.split('/');
-
- for (var i = 0; i < path.length; ++i) {
- if ('..' == path[i]) {
- curr.pop();
- } else if ('.' != path[i] && '' != path[i]) {
- segs.push(path[i]);
- }
- }
-
- return curr.concat(segs).join('/');
-};
-
-/**
- * Register module at `path` with callback `definition`.
- *
- * @param {String} path
- * @param {Function} definition
- * @api private
- */
-
-require.register = function(path, definition) {
- require.modules[path] = definition;
-};
-
-/**
- * Alias a module definition.
- *
- * @param {String} from
- * @param {String} to
- * @api private
- */
-
-require.alias = function(from, to) {
- if (!require.modules.hasOwnProperty(from)) {
- throw new Error('Failed to alias "' + from + '", it does not exist');
- }
- require.aliases[to] = from;
-};
-
-/**
- * Return a require function relative to the `parent` path.
- *
- * @param {String} parent
- * @return {Function}
- * @api private
- */
-
-require.relative = function(parent) {
- var p = require.normalize(parent, '..');
-
- /**
- * lastIndexOf helper.
- */
-
- function lastIndexOf(arr, obj) {
- var i = arr.length;
- while (i--) {
- if (arr[i] === obj) return i;
- }
- return -1;
- }
-
- /**
- * The relative require() itself.
- */
-
- function localRequire(path) {
- var resolved = localRequire.resolve(path);
- return require(resolved, parent, path);
- }
-
- /**
- * Resolve relative to the parent.
- */
-
- localRequire.resolve = function(path) {
- var c = path.charAt(0);
- if ('/' == c) return path.slice(1);
- if ('.' == c) return require.normalize(p, path);
-
- // resolve deps by returning
- // the dep in the nearest "deps"
- // directory
- var segs = parent.split('/');
- var i = lastIndexOf(segs, 'deps') + 1;
- if (!i) i = 0;
- path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
- return path;
- };
-
- /**
- * Check if module is defined at `path`.
- */
-
- localRequire.exists = function(path) {
- return require.modules.hasOwnProperty(localRequire.resolve(path));
- };
-
- return localRequire;
-};
-require.register("component-classes/index.js", function(exports, require, module){
-/**
- * Module dependencies.
- */
-
-var index = require('indexof');
-
-/**
- * Whitespace regexp.
- */
-
-var re = /\s+/;
-
-/**
- * toString reference.
- */
-
-var toString = Object.prototype.toString;
-
-/**
- * Wrap `el` in a `ClassList`.
- *
- * @param {Element} el
- * @return {ClassList}
- * @api public
- */
-
-module.exports = function(el){
- return new ClassList(el);
-};
-
-/**
- * Initialize a new ClassList for `el`.
- *
- * @param {Element} el
- * @api private
- */
-
-function ClassList(el) {
- if (!el) throw new Error('A DOM element reference is required');
- this.el = el;
- this.list = el.classList;
-}
-
-/**
- * Add class `name` if not already present.
- *
- * @param {String} name
- * @return {ClassList}
- * @api public
- */
-
-ClassList.prototype.add = function(name){
- // classList
- if (this.list) {
- this.list.add(name);
- return this;
- }
-
- // fallback
- var arr = this.array();
- var i = index(arr, name);
- if (!~i) arr.push(name);
- this.el.className = arr.join(' ');
- return this;
-};
-
-/**
- * Remove class `name` when present, or
- * pass a regular expression to remove
- * any which match.
- *
- * @param {String|RegExp} name
- * @return {ClassList}
- * @api public
- */
-
-ClassList.prototype.remove = function(name){
- if ('[object RegExp]' == toString.call(name)) {
- return this.removeMatching(name);
- }
-
- // classList
- if (this.list) {
- this.list.remove(name);
- return this;
- }
-
- // fallback
- var arr = this.array();
- var i = index(arr, name);
- if (~i) arr.splice(i, 1);
- this.el.className = arr.join(' ');
- return this;
-};
-
-/**
- * Remove all classes matching `re`.
- *
- * @param {RegExp} re
- * @return {ClassList}
- * @api private
- */
-
-ClassList.prototype.removeMatching = function(re){
- var arr = this.array();
- for (var i = 0; i < arr.length; i++) {
- if (re.test(arr[i])) {
- this.remove(arr[i]);
- }
- }
- return this;
-};
-
-/**
- * Toggle class `name`.
- *
- * @param {String} name
- * @return {ClassList}
- * @api public
- */
-
-ClassList.prototype.toggle = function(name){
- // classList
- if (this.list) {
- this.list.toggle(name);
- return this;
- }
-
- // fallback
- if (this.has(name)) {
- this.remove(name);
- } else {
- this.add(name);
- }
- return this;
-};
-
-/**
- * Return an array of classes.
- *
- * @return {Array}
- * @api public
- */
-
-ClassList.prototype.array = function(){
- var str = this.el.className.replace(/^\s+|\s+$/g, '');
- var arr = str.split(re);
- if ('' === arr[0]) arr.shift();
- return arr;
-};
-
-/**
- * Check if class `name` is present.
- *
- * @param {String} name
- * @return {ClassList}
- * @api public
- */
-
-ClassList.prototype.has =
-ClassList.prototype.contains = function(name){
- return this.list
- ? this.list.contains(name)
- : !! ~index(this.array(), name);
-};
-
-});
-require.register("segmentio-extend/index.js", function(exports, require, module){
-
-module.exports = function extend (object) {
- // Takes an unlimited number of extenders.
- var args = Array.prototype.slice.call(arguments, 1);
-
- // For each extender, copy their properties on our object.
- for (var i = 0, source; source = args[i]; i++) {
- if (!source) continue;
- for (var property in source) {
- object[property] = source[property];
- }
- }
-
- return object;
-};
-});
-require.register("component-indexof/index.js", function(exports, require, module){
-module.exports = function(arr, obj){
- if (arr.indexOf) return arr.indexOf(obj);
- for (var i = 0; i < arr.length; ++i) {
- if (arr[i] === obj) return i;
- }
- return -1;
-};
-});
-require.register("component-event/index.js", function(exports, require, module){
-var bind = window.addEventListener ? 'addEventListener' : 'attachEvent',
- unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
- prefix = bind !== 'addEventListener' ? 'on' : '';
-
-/**
- * Bind `el` event `type` to `fn`.
- *
- * @param {Element} el
- * @param {String} type
- * @param {Function} fn
- * @param {Boolean} capture
- * @return {Function}
- * @api public
- */
-
-exports.bind = function(el, type, fn, capture){
- el[bind](prefix + type, fn, capture || false);
- return fn;
-};
-
-/**
- * Unbind `el` event `type`'s callback `fn`.
- *
- * @param {Element} el
- * @param {String} type
- * @param {Function} fn
- * @param {Boolean} capture
- * @return {Function}
- * @api public
- */
-
-exports.unbind = function(el, type, fn, capture){
- el[unbind](prefix + type, fn, capture || false);
- return fn;
-};
-});
-require.register("javve-is-collection/index.js", function(exports, require, module){
-var typeOf = require('type')
-
-/**
- * Evaluates _obj_ to determine if it's an array, an array-like collection, or
- * something else. This is useful when working with the function `arguments`
- * collection and `HTMLElement` collections.
- * Note: This implementation doesn't consider elements that are also
- *
- *
-
- collections, such as `