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..451be9a 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,13 @@ 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' + + 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($('