From 39c2486be047ffeee4d9ac24cbdb49405a528b57 Mon Sep 17 00:00:00 2001 From: Godwin Date: Sat, 21 May 2016 13:57:09 -0700 Subject: [PATCH 1/5] Fixed deployment and added Spanish translations --- app/models/conference_registration_form_field.rb | 10 ++++------ app/views/shared/_footer.html.haml | 2 +- config/initializers/sorcery.rb | 3 --- config/locales/es.yml | 4 ++-- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/models/conference_registration_form_field.rb b/app/models/conference_registration_form_field.rb index b70a7cc..2e400f5 100644 --- a/app/models/conference_registration_form_field.rb +++ b/app/models/conference_registration_form_field.rb @@ -1,6 +1,4 @@ -class ConferenceRegistrationFormField < ActiveRecord::Base - belongs_to :conference - belongs_to :registration_form_field - - acts_as_list -end +class ConferenceRegistrationFormField < ActiveRecord::Base + belongs_to :conference + belongs_to :registration_form_field +end diff --git a/app/views/shared/_footer.html.haml b/app/views/shared/_footer.html.haml index 10261f6..13dc095 100644 --- a/app/views/shared/_footer.html.haml +++ b/app/views/shared/_footer.html.haml @@ -14,7 +14,7 @@ - if locale.to_s != I18n.locale.to_s # don't show the current locale %li - locale_translation = _("languages.#{locale}", locale: locale) - %a{href: url_for(params.merge(url_params(locale)))} + %a{href: url_for_locale(locale)} =_'translate.content.change_locale', "Read in #{locale_translation}", vars: {language: locale_translation}, locale: locale .copy =_'links.footer.help_text.contributors', 'Who contributed to building this website' do |title| diff --git a/config/initializers/sorcery.rb b/config/initializers/sorcery.rb index 28cdd99..a385746 100644 --- a/config/initializers/sorcery.rb +++ b/config/initializers/sorcery.rb @@ -203,19 +203,16 @@ Rails.application.config.sorcery.configure do |config| # use an external encryption class. # Default: `nil` # - user.custom_encryption_provider = Sorcery::CryptoProviders::DrupalPassword # encryption algorithm name. See 'encryption_algorithm=' for available options. # Default: `:bcrypt` # - user.encryption_algorithm = :custom#:sha512 # make this configuration inheritable for subclasses. Useful for ActiveRecord's STI. # Default: `false` # - user.subclasses_inherit_config = true # -- remember_me -- diff --git a/config/locales/es.yml b/config/locales/es.yml index 3a19972..6df896b 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1010,8 +1010,8 @@ es: Please_Confirm_Email: Página no encontrada '404': Page_Not_Found: Crear un taller - Policy: 'Policy' - About: 'About' + Policy: 'Política' + About: 'Acerca de' actions: workshops: create: Crear From 1bf6faf54be2bd302045720bfaf44864f05f815a Mon Sep 17 00:00:00 2001 From: Godwin Date: Sat, 21 May 2016 13:57:09 -0700 Subject: [PATCH 2/5] Fixed deployment and added Spanish translations --- app/models/conference_registration_form_field.rb | 10 ++++------ app/views/shared/_footer.html.haml | 2 +- config/initializers/sorcery.rb | 3 --- config/locales/es.yml | 4 ++-- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/models/conference_registration_form_field.rb b/app/models/conference_registration_form_field.rb index b70a7cc..2e400f5 100644 --- a/app/models/conference_registration_form_field.rb +++ b/app/models/conference_registration_form_field.rb @@ -1,6 +1,4 @@ -class ConferenceRegistrationFormField < ActiveRecord::Base - belongs_to :conference - belongs_to :registration_form_field - - acts_as_list -end +class ConferenceRegistrationFormField < ActiveRecord::Base + belongs_to :conference + belongs_to :registration_form_field +end diff --git a/app/views/shared/_footer.html.haml b/app/views/shared/_footer.html.haml index 10261f6..13dc095 100644 --- a/app/views/shared/_footer.html.haml +++ b/app/views/shared/_footer.html.haml @@ -14,7 +14,7 @@ - if locale.to_s != I18n.locale.to_s # don't show the current locale %li - locale_translation = _("languages.#{locale}", locale: locale) - %a{href: url_for(params.merge(url_params(locale)))} + %a{href: url_for_locale(locale)} =_'translate.content.change_locale', "Read in #{locale_translation}", vars: {language: locale_translation}, locale: locale .copy =_'links.footer.help_text.contributors', 'Who contributed to building this website' do |title| diff --git a/config/initializers/sorcery.rb b/config/initializers/sorcery.rb index 28cdd99..a385746 100644 --- a/config/initializers/sorcery.rb +++ b/config/initializers/sorcery.rb @@ -203,19 +203,16 @@ Rails.application.config.sorcery.configure do |config| # use an external encryption class. # Default: `nil` # - user.custom_encryption_provider = Sorcery::CryptoProviders::DrupalPassword # encryption algorithm name. See 'encryption_algorithm=' for available options. # Default: `:bcrypt` # - user.encryption_algorithm = :custom#:sha512 # make this configuration inheritable for subclasses. Useful for ActiveRecord's STI. # Default: `false` # - user.subclasses_inherit_config = true # -- remember_me -- diff --git a/config/locales/es.yml b/config/locales/es.yml index 3a19972..6df896b 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1010,8 +1010,8 @@ es: Please_Confirm_Email: Página no encontrada '404': Page_Not_Found: Crear un taller - Policy: 'Policy' - About: 'About' + Policy: 'Política' + About: 'Acerca de' actions: workshops: create: Crear From a8a498684eb2585e628b7264bbdac17188dfe8f5 Mon Sep 17 00:00:00 2001 From: Godwin Date: Sat, 21 May 2016 14:27:27 -0700 Subject: [PATCH 3/5] Fixed errors --- .../stylesheets/bumbleberry-settings.json | 11 +- app/helpers/application_helper.rb | 111 ++++-------------- 2 files changed, 32 insertions(+), 90 deletions(-) diff --git a/app/assets/stylesheets/bumbleberry-settings.json b/app/assets/stylesheets/bumbleberry-settings.json index 96ad992..407ddb7 100644 --- a/app/assets/stylesheets/bumbleberry-settings.json +++ b/app/assets/stylesheets/bumbleberry-settings.json @@ -1,5 +1,14 @@ { "stylesheets": ["application", "translations", "email-example"], + "precompile": { + "test": { + "chrome": ["50"] + }, + "development": { + "chrome": ["50"], + "ios_saf": ["8", "9"] + } + }, "background-color": "#FFFEFE", "breakpoint-unit": "px", "unresponsive-width": 1000, @@ -21,7 +30,7 @@ "reset-order": "n" }, "medium": { - "range": [564], + "range": [680], "grid": "y", "offset": "n", "reset-order": "n" diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fafef04..2cf3889 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -151,84 +151,6 @@ module ApplicationHelper content_for?(section) ? content_for(section) : default end -# def _(key, behavior = nil, behavior_size = nil, locale: nil, vars: {}, html: nil, blockData: {}, &block) -# options = vars -# options[:fallback] = true -# if behavior -# options[:behavior] = behavior -# options[:behavior_size] = behavior_size -# end -# if locale -# options[:locale] = locale.to_sym -# end -# #if vars -# # puts "\nVARS:\t#{vars}\n" -# #end -# I18n.translate(key, options) -# -# #queued_keys = nil -# #result = nil -# -# #if key.kind_of?(Hash) -# # blockData.merge!(key) -# # key = key.keys -# #end -# -# #if block_given? -# # @@keyQueue ||= Array.new -# -# # if key.kind_of?(Array) -# # @@keyQueue += key -# # else -# # @@keyQueue << key -# # end -# #end -# -# #if key.kind_of?(Array) -# # new_key = key.shift -# # if key.count > 0 -# # queued_keys = key.dup -# # end -# # key = new_key -# #end -# -# #if blockData[key] -# # behavior = blockData[key][:behavior] || nil -# # behavior_size = blockData[key][:behavior_size] || nil -# # vars = blockData[key][:vars] || {} -# #end -# -# #@@lastTranslation = nil -# #generate_control = _can_translate? -# -# #puts "\nLLOOCCAALLEE:\t#{locale.to_s}" -# #translation = _do_translate(key, vars, behavior, behavior_size, locale) -# -# #if block_given? -# # html = capture(&block) -# #end -# -# #if html -# # translation['html'] = html.gsub('%' + key + '%', translation['untranslated']) -# #end -# -# #if generate_control -# # @@lastTranslation = translation -# # @@allTranslations ||= Hash.new -# # @@allTranslations[key] = key -# -# # result = _translate_me(translation) -# #end -# -# #result ||= translation['html'] || (behavior.to_s == 'strict' ? nil : translation['untranslated']) -# -# #if queued_keys -# # return _ queued_keys, behavior, behavior_size, vars: vars, html: result, blockData: blockData -# #end -# - #return result -# end - def _translate_me(translation) @@translationsOnThisPage = true datakeys = '' @@ -263,17 +185,20 @@ module ApplicationHelper false end - #def _!() - # if @@keyQueue - # return '%' + @@keyQueue.shift + '%' - # end - #end + def url_for_locale(locale) + url_for(params + .merge({action: (params[:_original_action] || params[:action])} + .merge(url_params(locale))) + .delete(:_original_action) + ) + end - #def _?() - # if @@keyQueue - # return '%' + @@keyQueue[0] + '%' - # end - #end + def registration_steps(conference = @conference) + { + pre: [:policy, :basic_info, :workshops], + open: [:policy, :basic_info, :questions, :payment, :workshops] + }[@this_conference.registration_status] + end def sortable(objects, id = 'id', url: nil, &block) result = '
    ' @@ -640,7 +565,15 @@ module ApplicationHelper return hash.length > 1 ? _("geography.formats.#{hash.keys.join('_')}", vars: hash) : hash.values.first end - def nav_link(link, title, class_name = nil) + def nav_link(link, title = nil, class_name = nil) + if title.nil? && link.is_a?(Symbol) + title = link + link = send("#{link.to_s}_path") + end + if class_name.nil? && title.is_a?(Symbol) + class_name = title + title = _"page_titles.#{title.to_s.titlecase}" + end classes = [] classes << class_name if class_name.present? classes << 'current' if current_page?(link.gsub(/(^.*)\/$/, '\1')) From 530a3e8192f2d301a89a5b0e7316ac0a139e3b17 Mon Sep 17 00:00:00 2001 From: Godwin Date: Sat, 21 May 2016 15:28:15 -0700 Subject: [PATCH 4/5] Added capistrano to help speed up sass compilation --- Capfile | 28 +++++++++++++++++ Gemfile | 11 +++---- config/deploy.rb | 49 +++++++++++++++++++++++++++++ config/deploy/production.rb | 61 +++++++++++++++++++++++++++++++++++++ config/deploy/staging.rb | 61 +++++++++++++++++++++++++++++++++++++ 5 files changed, 203 insertions(+), 7 deletions(-) create mode 100644 Capfile create mode 100644 config/deploy.rb create mode 100644 config/deploy/production.rb create mode 100644 config/deploy/staging.rb diff --git a/Capfile b/Capfile new file mode 100644 index 0000000..f072e31 --- /dev/null +++ b/Capfile @@ -0,0 +1,28 @@ +# Load DSL and set up stages +require "capistrano/setup" + +# Include default deployment tasks +require "capistrano/deploy" + +# Include tasks from other gems included in your Gemfile +# +# For documentation on these, see for example: +# +# https://github.com/capistrano/rvm +# https://github.com/capistrano/rbenv +# https://github.com/capistrano/chruby +# https://github.com/capistrano/bundler +# https://github.com/capistrano/rails +# https://github.com/capistrano/passenger +# +# require 'capistrano/rvm' +# require 'capistrano/rbenv' +# require 'capistrano/chruby' +# require 'capistrano/bundler' +# require 'capistrano/rails/assets' +# require 'capistrano/rails/migrations' +# require 'capistrano/passenger' +require 'capistrano/faster_assets' + +# Load custom tasks from `lib/capistrano/tasks` if you have any defined +Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } diff --git a/Gemfile b/Gemfile index 883e851..4ef14eb 100644 --- a/Gemfile +++ b/Gemfile @@ -6,9 +6,6 @@ gem 'pg' gem 'rack-mini-profiler' gem 'haml' -# gem 'jquery-rails' -# gem 'jquery-ui-rails' -# gem 'coffee-rails', '~> 4.0.0' gem 'nokogiri', '~> 1.6.8.rc2' if Dir.exists?('../lingua_franca') @@ -33,8 +30,6 @@ gem 'oauth2', '~> 0.8.0' gem 'carrierwave' gem 'carrierwave-imageoptimizer' gem 'mini_magick' -# gem 'nested_form' -# gem 'acts_as_list' gem 'geocoder' gem 'paper_trail', '~> 3.0.5' gem 'sitemap_generator' @@ -55,8 +50,10 @@ group :development do gem 'better_errors' gem 'binding_of_caller' gem 'meta_request' -# gem 'haml-rails' -# gem 'awesome_print' + + gem 'capistrano', '~> 3.1' + gem 'capistrano-rails', '~> 1.1' + gem 'capistrano-faster-assets', '~> 1.0' end group :test do diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 0000000..deee801 --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,49 @@ +# config valid only for current version of Capistrano +lock '3.5.0' + +set :application, 'my_app_name' +set :repo_url, 'git@example.com:me/my_repo.git' + +# Default branch is :master +# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp + +# Default deploy_to directory is /var/www/my_app_name +# set :deploy_to, '/var/www/my_app_name' + +# Default value for :scm is :git +# set :scm, :git + +# Default value for :format is :airbrussh. +# set :format, :airbrussh + +# You can configure the Airbrussh format using :format_options. +# These are the defaults. +# set :format_options, command_output: true, log_file: 'log/capistrano.log', color: :auto, truncate: :auto + +# Default value for :pty is false +# set :pty, true + +# Default value for :linked_files is [] +# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml') + +# Default value for linked_dirs is [] +# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system') + +# Default value for default_env is {} +# set :default_env, { path: "/opt/ruby/bin:$PATH" } + +# Default value for keep_releases is 5 +# set :keep_releases, 5 + +namespace :deploy do + + after :restart, :clear_cache do + on roles(:web), in: :groups, limit: 3, wait: 10 do + # Here we can do anything such as: + # within release_path do + # execute :rake, 'cache:clear' + # end + end + end + +end diff --git a/config/deploy/production.rb b/config/deploy/production.rb new file mode 100644 index 0000000..e9e33cd --- /dev/null +++ b/config/deploy/production.rb @@ -0,0 +1,61 @@ +# server-based syntax +# ====================== +# Defines a single server with a list of roles and multiple properties. +# You can define all roles on a single server, or split them: + +# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value +# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value +# server 'db.example.com', user: 'deploy', roles: %w{db} + + + +# role-based syntax +# ================== + +# Defines a role with one or multiple servers. The primary server in each +# group is considered to be the first unless any hosts have the primary +# property set. Specify the username and a domain or IP for the server. +# Don't use `:all`, it's a meta role. + +# role :app, %w{deploy@example.com}, my_property: :my_value +# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value +# role :db, %w{deploy@example.com} + + + +# Configuration +# ============= +# You can set any configuration variable like in config/deploy.rb +# These variables are then only loaded and set in this stage. +# For available Capistrano configuration variables see the documentation page. +# http://capistranorb.com/documentation/getting-started/configuration/ +# Feel free to add new variables to customise your setup. + + + +# Custom SSH Options +# ================== +# You may pass any option but keep in mind that net/ssh understands a +# limited set of options, consult the Net::SSH documentation. +# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start +# +# Global options +# -------------- +# set :ssh_options, { +# keys: %w(/home/rlisowski/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(password) +# } +# +# The server-based syntax can be used to override options: +# ------------------------------------ +# server 'example.com', +# user: 'user_name', +# roles: %w{web app}, +# ssh_options: { +# user: 'user_name', # overrides user setting above +# keys: %w(/home/user_name/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(publickey password) +# # password: 'please use keys' +# } diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb new file mode 100644 index 0000000..e9e33cd --- /dev/null +++ b/config/deploy/staging.rb @@ -0,0 +1,61 @@ +# server-based syntax +# ====================== +# Defines a single server with a list of roles and multiple properties. +# You can define all roles on a single server, or split them: + +# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value +# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value +# server 'db.example.com', user: 'deploy', roles: %w{db} + + + +# role-based syntax +# ================== + +# Defines a role with one or multiple servers. The primary server in each +# group is considered to be the first unless any hosts have the primary +# property set. Specify the username and a domain or IP for the server. +# Don't use `:all`, it's a meta role. + +# role :app, %w{deploy@example.com}, my_property: :my_value +# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value +# role :db, %w{deploy@example.com} + + + +# Configuration +# ============= +# You can set any configuration variable like in config/deploy.rb +# These variables are then only loaded and set in this stage. +# For available Capistrano configuration variables see the documentation page. +# http://capistranorb.com/documentation/getting-started/configuration/ +# Feel free to add new variables to customise your setup. + + + +# Custom SSH Options +# ================== +# You may pass any option but keep in mind that net/ssh understands a +# limited set of options, consult the Net::SSH documentation. +# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start +# +# Global options +# -------------- +# set :ssh_options, { +# keys: %w(/home/rlisowski/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(password) +# } +# +# The server-based syntax can be used to override options: +# ------------------------------------ +# server 'example.com', +# user: 'user_name', +# roles: %w{web app}, +# ssh_options: { +# user: 'user_name', # overrides user setting above +# keys: %w(/home/user_name/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(publickey password) +# # password: 'please use keys' +# } From c8d6140ed837f4ab4c11fca2de74806b818be166 Mon Sep 17 00:00:00 2001 From: Godwin Date: Mon, 30 May 2016 18:24:07 -0700 Subject: [PATCH 5/5] Pre registration --- Gemfile | 3 + app/assets/images/edit.svg | 1 + app/assets/images/img.svg | 1 + app/assets/images/link.svg | 1 + app/assets/images/ol.svg | 1 + app/assets/images/quote.svg | 1 + app/assets/images/ul.svg | 1 + app/assets/javascripts/editor.js | 79 + app/assets/javascripts/editor.js.coffee | 37 - app/assets/javascripts/main.js | 16 + app/assets/stylesheets/_application.scss | 813 ++++++-- app/assets/stylesheets/_editor.scss | 212 +++ app/assets/stylesheets/_settings.scss | 3 + .../stylesheets/bumbleberry-settings.json | 6 +- app/assets/stylesheets/user-mailer.scss | 183 ++ app/controllers/application_controller.rb | 32 +- app/controllers/conferences_controller.rb | 574 ++++-- app/controllers/oauths_controller.rb | 39 +- app/helpers/application_helper.rb | 77 +- app/mailers/user_mailer.rb | 97 +- app/models/conference.rb | 19 +- app/models/conference_registration.rb | 16 +- app/models/user.rb | 14 +- app/models/workshop.rb | 32 +- app/views/application/404.html.haml | 3 +- app/views/application/_header.html.haml | 13 +- .../_login_confirmation_sent.html.haml | 2 +- app/views/application/home.html.haml | 26 +- .../application/permission_denied.html.haml | 8 +- .../conferences/_confirm_email.html.haml | 15 +- app/views/conferences/_contact_info.html.haml | 26 + .../conferences/_email_confirm.html.haml | 2 +- app/views/conferences/_header.html.haml | 4 +- app/views/conferences/_policy.html.haml | 19 +- app/views/conferences/_workshops.html.haml | 58 +- app/views/conferences/edit.html.haml | 30 +- app/views/conferences/register.html.haml | 18 +- app/views/layouts/application.html.haml | 26 +- app/views/layouts/user_mailer.html.haml | 70 +- app/views/shared/_donate_button.html.haml | 3 +- app/views/shared/_navbar.html.haml | 21 +- .../registration_confirmation.html.haml | 8 +- .../registration_confirmation.text.haml | 7 +- app/views/user_mailer/test_email.text.haml | 1 - ...orkshop_original_content_changed.html.haml | 15 + ...orkshop_original_content_changed.text.haml | 25 + .../user_mailer/workshop_translated.html.haml | 15 + .../user_mailer/workshop_translated.text.haml | 25 + app/views/workshops/_show.html.haml | 50 +- .../workshops/_workshop_previews.html.haml | 18 +- .../facilitate_request_sent.html.haml | 6 +- app/views/workshops/index.html.haml | 11 +- app/views/workshops/new.html.haml | 94 +- app/views/workshops/show.html.haml | 18 +- config/environments/development.rb | 12 +- config/environments/preview.rb | 1 - config/environments/production.rb | 1 - config/initializers/assets.rb | 11 + config/initializers/sorcery.rb | 27 +- config/locales/en.yml | 45 +- config/locales/es.yml | 7 +- config/routes.rb | 8 +- ..._add_registration_status_to_conferences.rb | 9 + ...ighest_step_to_conference_registrations.rb | 5 + ...s_completed_to_conference_registrations.rb | 5 + ...849_add_needs_facilitators_to_workshops.rb | 5 + .../20160529225253_add_languages_to_users.rb | 5 + ...e_format_in_dynamic_translation_records.rb | 5 + db/schema.rb | 23 +- vendor/assets/javascripts/markdown.js | 78 + vendor/assets/javascripts/pen.js | 835 ++++++++ vendor/assets/javascripts/world-110m.json | 1675 +++++++++++++++++ vendor/assets/javascripts/world-50m.json | 1675 +++++++++++++++++ vendor/assets/stylesheets/pen.css | 159 ++ 74 files changed, 6710 insertions(+), 776 deletions(-) create mode 100644 app/assets/images/edit.svg create mode 100644 app/assets/images/img.svg create mode 100644 app/assets/images/link.svg create mode 100644 app/assets/images/ol.svg create mode 100644 app/assets/images/quote.svg create mode 100644 app/assets/images/ul.svg create mode 100644 app/assets/javascripts/editor.js delete mode 100644 app/assets/javascripts/editor.js.coffee create mode 100644 app/assets/javascripts/main.js create mode 100644 app/assets/stylesheets/_editor.scss create mode 100644 app/assets/stylesheets/user-mailer.scss create mode 100644 app/views/conferences/_contact_info.html.haml delete mode 100644 app/views/user_mailer/test_email.text.haml create mode 100644 app/views/user_mailer/workshop_original_content_changed.html.haml create mode 100644 app/views/user_mailer/workshop_original_content_changed.text.haml create mode 100644 app/views/user_mailer/workshop_translated.html.haml create mode 100644 app/views/user_mailer/workshop_translated.text.haml create mode 100644 config/initializers/assets.rb create mode 100644 db/migrate/20160515210708_add_registration_status_to_conferences.rb create mode 100644 db/migrate/20160521230653_add_highest_step_to_conference_registrations.rb create mode 100644 db/migrate/20160522022034_add_steps_completed_to_conference_registrations.rb create mode 100644 db/migrate/20160526044849_add_needs_facilitators_to_workshops.rb create mode 100644 db/migrate/20160529225253_add_languages_to_users.rb create mode 100644 db/migrate/20160530175805_change_date_format_in_dynamic_translation_records.rb create mode 100644 vendor/assets/javascripts/markdown.js create mode 100644 vendor/assets/javascripts/pen.js create mode 100644 vendor/assets/javascripts/world-110m.json create mode 100644 vendor/assets/javascripts/world-50m.json create mode 100644 vendor/assets/stylesheets/pen.css diff --git a/Gemfile b/Gemfile index 4ef14eb..451be9a 100644 --- a/Gemfile +++ b/Gemfile @@ -54,6 +54,9 @@ group :development do gem 'capistrano', '~> 3.1' gem 'capistrano-rails', '~> 1.1' gem 'capistrano-faster-assets', '~> 1.0' + + gem 'eventmachine', :github => 'krzcho/eventmachine', :branch => 'master' + gem 'thin', :github => 'krzcho/thin', :branch => 'master' end group :test do diff --git a/app/assets/images/edit.svg b/app/assets/images/edit.svg new file mode 100644 index 0000000..68f41ae --- /dev/null +++ b/app/assets/images/edit.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/img.svg b/app/assets/images/img.svg new file mode 100644 index 0000000..9a3e09d --- /dev/null +++ b/app/assets/images/img.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/link.svg b/app/assets/images/link.svg new file mode 100644 index 0000000..f279380 --- /dev/null +++ b/app/assets/images/link.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/ol.svg b/app/assets/images/ol.svg new file mode 100644 index 0000000..405f9a0 --- /dev/null +++ b/app/assets/images/ol.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/quote.svg b/app/assets/images/quote.svg new file mode 100644 index 0000000..53c1304 --- /dev/null +++ b/app/assets/images/quote.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/ul.svg b/app/assets/images/ul.svg new file mode 100644 index 0000000..145e61f --- /dev/null +++ b/app/assets/images/ul.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js new file mode 100644 index 0000000..ed4c0be --- /dev/null +++ b/app/assets/javascripts/editor.js @@ -0,0 +1,79 @@ +(function() { + var pens = {}; + + Array.prototype.forEach.call(document.querySelectorAll('.textarea'), function(editor) { + startEditing(editor); + }); + + function startEditing(editor) { + var name = editor.dataset.name; + pens[name] = new Pen({ + editor: editor, + class: 'pen', + textarea: '', + list: ['p', 'h3', 'h4', 'blockquote', 'insertorderedlist', 'insertunorderedlist', 'bold', 'italic', 'underline', 'strikethrough', 'createlink', 'insertimage'], + title: { + 'p': 'Paragraph', + 'h3': 'Major Heading', + 'h4': 'Minor Heading', + 'blockquote': 'Quotation', + 'insertorderedlist': 'Ordered List', + 'insertunorderedlist': 'Unordered List', + 'bold': 'Bold', + 'italic': 'Italic', + 'underline': 'Underline', + 'strikethrough': 'Strikethrough', + 'createlink': 'Link', + 'insertimage': 'Image' + } + }); + } + + Array.prototype.forEach.call(document.querySelectorAll('form'), function(form) { + var shouldAllowAlert = false; + form.addEventListener('submit', function() { + if (shouldAllowAlert) { + return; + } + Array.prototype.forEach.call(document.querySelectorAll('.textarea'), function(editor) { + var name = editor.dataset.name; + var textarea = document.querySelector('textarea[name="' + name + '"]'); + if (!textarea) { + textarea = document.createElement('textarea'); + textarea.name = name; + textarea.style.display = 'none'; + form.appendChild(textarea); + } + textarea.value = editor.innerHTML; + pens[name].destroy(); + }); + }, false); + Array.prototype.forEach.call(form.querySelectorAll('button'), function(button) { + form.addEventListener('click', function(event) { + shouldAllowAlert = (event.target.value === 'cancel'); + }); + }); + }); + + Array.prototype.forEach.call(document.querySelectorAll('.check-box-field .other input'), function(input) { + var checkbox = document.getElementById(input.parentElement.parentElement.attributes.for.value); + input.addEventListener('keyup', function(event) { + if (event.target.value) { + checkbox.checked = true; + } + }); + input.addEventListener('click', function(event) { + checkbox.checked = true; + }); + var setRequired = function() { + if (checkbox.checked) { + input.setAttribute('required', 'required'); + } else { + input.removeAttribute('required'); + } + }; + Array.prototype.forEach.call(document.querySelectorAll('.check-box-field input'), function(_input) { + _input.addEventListener('change', function(event) { setRequired(); }); + }); + }); +})(); diff --git a/app/assets/javascripts/editor.js.coffee b/app/assets/javascripts/editor.js.coffee deleted file mode 100644 index 56ba4ef..0000000 --- a/app/assets/javascripts/editor.js.coffee +++ /dev/null @@ -1,37 +0,0 @@ -#= require froala_editor.min.js -$ -> - $('[data-editable]').editable({inlineMode: true, blockTags: ["n", "p", "h2", "blockquote", "pre"], buttons: ["formatBlock", "bold", "italic", "underline", "insertOrderedList", "insertUnorderedList", "sep", "createLink", "insertImage", "insertVideo", "html", "undo", "redo"]}) - $('[data-editor]').editable({inlineMode: false, blockTags: ["n", "p", "h2", "blockquote", "pre"], buttons: ["formatBlock", "bold", "italic", "underline", "insertOrderedList", "insertUnorderedList", "sep", "createLink", "html", "undo", "redo"]}) - $('.field.country-select-field select').change () -> - $country = $(this) - country = $country.val() - $territory = $('.field.subregion-select-field select') - if $territory.data().country == country - $territory.removeClass('can cant').addClass('can') - return - - $.post '/location/territories', {country: country}, - (json) -> - $territory.html('') - if json && Object.keys(json).length - $.each json, (code, name) -> - $territory.append($('