From c8d6140ed837f4ab4c11fca2de74806b818be166 Mon Sep 17 00:00:00 2001 From: Godwin Date: Mon, 30 May 2016 18:24:07 -0700 Subject: [PATCH] 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($('