diff --git a/Gemfile b/Gemfile index 751fab83b..0e8070313 100644 --- a/Gemfile +++ b/Gemfile @@ -36,6 +36,7 @@ gem "responders" gem 'foundation-rails' gem 'acts_as_votable' gem "recaptcha", :require => "recaptcha/rails" +gem 'ckeditor' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console diff --git a/Gemfile.lock b/Gemfile.lock index 98a7de5b4..4ef48e99c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -59,7 +59,14 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) + ckeditor (4.1.2) + cocaine + orm_adapter (~> 0.5.0) + climate_control (0.0.3) + activesupport (>= 3.0) cliver (0.3.2) + cocaine (0.5.7) + climate_control (>= 0.0.3, < 1.0) coffee-rails (4.1.0) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -216,6 +223,7 @@ DEPENDENCIES acts_as_votable byebug capybara + ckeditor coffee-rails (~> 4.1.0) database_cleaner devise @@ -236,3 +244,6 @@ DEPENDENCIES turbolinks uglifier (>= 1.3.0) web-console (~> 2.0) + +BUNDLED WITH + 1.10.5 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 92a9acf14..c73d04209 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -14,6 +14,7 @@ //= require jquery_ujs //= require foundation //= require turbolinks +//= require ckeditor/init //= require_tree . $(function(){ $(document).foundation(); }); diff --git a/app/assets/javascripts/ckeditor/config.js b/app/assets/javascripts/ckeditor/config.js new file mode 100644 index 000000000..8d6edd348 --- /dev/null +++ b/app/assets/javascripts/ckeditor/config.js @@ -0,0 +1,115 @@ +/* +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.html or http://ckeditor.com/license +*/ + +CKEDITOR.editorConfig = function( config ) +{ + // Define changes to default configuration here. For example: + // config.language = 'fr'; + // config.uiColor = '#AADC6E'; + + /* Filebrowser routes */ + // The location of an external file browser, that should be launched when "Browse Server" button is pressed. + config.filebrowserBrowseUrl = "/ckeditor/attachment_files"; + + // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog. + config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files"; + + // The location of a script that handles file uploads in the Flash dialog. + config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files"; + + // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog. + config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures"; + + // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog. + config.filebrowserImageBrowseUrl = "/ckeditor/pictures"; + + // The location of a script that handles file uploads in the Image dialog. + config.filebrowserImageUploadUrl = "/ckeditor/pictures"; + + // The location of a script that handles file uploads. + config.filebrowserUploadUrl = "/ckeditor/attachment_files"; + + config.allowedContent = true; + + // Rails CSRF token + config.filebrowserParams = function(){ + var csrf_token, csrf_param, meta, + metas = document.getElementsByTagName('meta'), + params = new Object(); + + for ( var i = 0 ; i < metas.length ; i++ ){ + meta = metas[i]; + + switch(meta.name) { + case "csrf-token": + csrf_token = meta.content; + break; + case "csrf-param": + csrf_param = meta.content; + break; + default: + continue; + } + } + + if (csrf_param !== undefined && csrf_token !== undefined) { + params[csrf_param] = csrf_token; + } + + return params; + }; + + config.addQueryString = function( url, params ){ + var queryString = []; + + if ( !params ) { + return url; + } else { + for ( var i in params ) + queryString.push( i + "=" + encodeURIComponent( params[ i ] ) ); + } + + return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" ); + }; + + // Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash) + CKEDITOR.on( 'dialogDefinition', function( ev ){ + // Take the dialog name and its definition from the event data. + var dialogName = ev.data.name; + var dialogDefinition = ev.data.definition; + var content, upload; + + if (CKEDITOR.tools.indexOf(['link', 'image', 'attachment', 'flash'], dialogName) > -1) { + content = (dialogDefinition.getContents('Upload') || dialogDefinition.getContents('upload')); + upload = (content == null ? null : content.get('upload')); + + if (upload && upload.filebrowser && upload.filebrowser['params'] === undefined) { + upload.filebrowser['params'] = config.filebrowserParams(); + upload.action = config.addQueryString(upload.action, upload.filebrowser['params']); + } + } + }); + + // Toolbar groups configuration. + config.toolbar = [ + { name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source'] }, + { name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] }, + // { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] }, + // { name: 'forms', items: [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] }, + { name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] }, + { name: 'insert', items: [ 'Image', 'Flash', 'Table', 'HorizontalRule', 'SpecialChar' ] }, + { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ] }, + '/', + { name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] }, + { name: 'colors', items: [ 'TextColor', 'BGColor' ] }, + { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] } + ]; + + config.toolbar_mini = [ + { name: 'paragraph', groups: [ 'list' ], items: [ 'NumberedList', 'BulletedList' ] }, + { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike' ] } + ]; + config.toolbar = "mini"; +}; diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 03b6caad7..5361b50fb 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -5,7 +5,7 @@ <%= f.text_area :body %> <%= f.hidden_field :commentable_type, value: parent.class %> <%= f.hidden_field :commentable_id, value: parent.id %> - - <%= f.submit comment_button_text(parent), :class => "button radius" %> + + <%= f.submit comment_button_text(parent), class: "button radius" %> <% end %> diff --git a/app/views/debates/_debate.html.erb b/app/views/debates/_debate.html.erb index 6575d6c9a..521b291b7 100644 --- a/app/views/debates/_debate.html.erb +++ b/app/views/debates/_debate.html.erb @@ -5,7 +5,7 @@

<%= link_to debate.title, debate %>

Por <%= debate.author.name %> el <%= l debate.created_at.to_date %>

-

<%= debate.description %>

+

<%= sanitize(debate.description.html_safe) %>

<%= render 'shared/tags', debate: debate %>

diff --git a/app/views/debates/_form.html.erb b/app/views/debates/_form.html.erb index 30585be00..7735c4c28 100644 --- a/app/views/debates/_form.html.erb +++ b/app/views/debates/_form.html.erb @@ -18,8 +18,7 @@

<%= t("debates.form.debate_text") %>

<%= t("debates.form.text_instructions") %>

- <%= f.text_area :description %> - + <%= f.cktext_area :description, ckeditor: { language: I18n.locale } %>
<%= f.label :tag_list, t("debates.form.tags_label") %>
<%= f.text_field :tag_list, value: @debate.tag_list.to_s %> @@ -33,7 +32,7 @@ <%= render 'shared/captcha', resource: @debate %>
- <%= f.submit %> + <%= f.submit(class: "button radius") %>

-<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb index 04d1e5354..b7aea88d1 100644 --- a/app/views/debates/show.html.erb +++ b/app/views/debates/show.html.erb @@ -6,7 +6,7 @@

<%= @debate.title %>

Por <%= @debate.author.name %> el <%= l @debate.created_at.to_date %>

-

<%= @debate.description %>

+

<%= sanitize(@debate.description.html_safe) %>

<%= render 'shared/tags', debate: @debate %>

diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb index 826672f74..065ea4383 100644 --- a/app/views/devise/confirmations/new.html.erb +++ b/app/views/devise/confirmations/new.html.erb @@ -1,15 +1,15 @@ -

Resend confirmation instructions

+

<%= t("devise_views.confirmations.title") %>

<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> <%= devise_error_messages! %>
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %> + <%= f.label :email, t("devise_views.confirmations.email_label") %>
+ <%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
- <%= f.submit "Resend confirmation instructions" %> + <%= f.submit(t("devise_views.confirmations.submit"), class: "button radius") %>
<% end %> diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb index dc55f64f6..1f504444d 100644 --- a/app/views/devise/mailer/confirmation_instructions.html.erb +++ b/app/views/devise/mailer/confirmation_instructions.html.erb @@ -1,5 +1,5 @@ -

Welcome <%= @email %>!

+

<%= t("devise_views.mailer.confirmation_instructions.welcome") %> <%= @email %>

-

You can confirm your account email through the link below:

+

<%= t("devise_views.mailer.confirmation_instructions.text") %>

-

<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>

+

<%= link_to t("devise_views.mailer.confirmation_instructions.confirm_link"), confirmation_url(@resource, confirmation_token: @token) %>

diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb index f667dc12f..78923ce92 100644 --- a/app/views/devise/mailer/reset_password_instructions.html.erb +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -1,8 +1,8 @@ -

Hello <%= @resource.email %>!

+

<%= t("devise_views.mailer.reset_password_instructions.hello") %> <%= @resource.email %>

-

Someone has requested a link to change your password. You can do this through the link below.

+

<%= t("devise_views.mailer.reset_password_instructions.text") %>

-

<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>

+

<%= link_to t("devise_views.mailer.reset_password_instructions.change_link"), edit_password_url(@resource, reset_password_token: @token) %>

-

If you didn't request this, please ignore this email.

-

Your password won't change until you access the link above and create a new one.

+

<%= t("devise_views.mailer.reset_password_instructions.ignore_text") %>

+

<%= t("devise_views.mailer.reset_password_instructions.info_text") %>

diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb index 41e148bf2..12f4d2b62 100644 --- a/app/views/devise/mailer/unlock_instructions.html.erb +++ b/app/views/devise/mailer/unlock_instructions.html.erb @@ -1,7 +1,7 @@ -

Hello <%= @resource.email %>!

+

<%= t("devise_views.mailer.unlock_instructions.hello") %> <%= @resource.email %>

-

Your account has been locked due to an excessive number of unsuccessful sign in attempts.

+

<%= t("devise_views.mailer.unlock_instructions.info_text") %>

-

Click the link below to unlock your account:

+

<%= t("devise_views.mailer.unlock_instructions.instructions_text") %>

-

<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>

+

<%= link_to t("devise_views.mailer.unlock_instructions.unlock_link"), unlock_url(@resource, unlock_token: @token) %>

diff --git a/app/views/devise/menu/_login_items.html.erb b/app/views/devise/menu/_login_items.html.erb index 22ffa4b0e..c075d23aa 100644 --- a/app/views/devise/menu/_login_items.html.erb +++ b/app/views/devise/menu/_login_items.html.erb @@ -1,14 +1,14 @@ \ No newline at end of file diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb index 0ee12dd27..cd0cf81ec 100644 --- a/app/views/devise/passwords/edit.html.erb +++ b/app/views/devise/passwords/edit.html.erb @@ -1,24 +1,24 @@ -

Change your password

+

<%= t("devise_views.passwords.edit.title") %>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> <%= devise_error_messages! %> <%= f.hidden_field :reset_password_token %>
- <%= f.label :password, "New password" %>
+ <%= f.label :password, t("devise_views.passwords.edit.password_label") %>
<% if @minimum_password_length %> - (<%= @minimum_password_length %> characters minimum) + <%= t("devise_views.passwords.edit.min_length", min: @minimum_password_length) %> <% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
- <%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.label :password_confirmation, t("devise_views.passwords.edit.password_confirmation_label") %>
<%= f.password_field :password_confirmation, autocomplete: "off" %>
- <%= f.submit "Change my password" %> + <%= f.submit t("devise_views.passwords.edit.change_submit") %>
<% end %> diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb index 3d6d11aae..1e3baccc8 100644 --- a/app/views/devise/passwords/new.html.erb +++ b/app/views/devise/passwords/new.html.erb @@ -1,15 +1,15 @@ -

Forgot your password?

+

<%= t("devise_views.passwords.new.title") %>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> <%= devise_error_messages! %>
- <%= f.label :email %>
+ <%= f.label :email, t("devise_views.passwords.new.email_label") %>
<%= f.email_field :email, autofocus: true %>
- <%= f.submit "Send me reset password instructions" %> + <%= f.submit t("devise_views.passwords.new.send_submit") %>
<% end %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 3ea40f014..d359cf5cd 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,39 +1,39 @@ -

Edit <%= resource_name.to_s.humanize %>

+

<%= t("devise_views.registrations.edit.edit") %> <%= resource_name.to_s.humanize %>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> <%= devise_error_messages! %>
- <%= f.label :email %>
+ <%= f.label :email, t("devise_views.registrations.edit.email_label") %>
<%= f.email_field :email, autofocus: true %>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> -
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
+
<%= t("devise_views.registrations.edit.waiting_for") %> <%= resource.unconfirmed_email %>
<% end %>
- <%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.label :password, t("devise_views.registrations.edit.password_label") %> <%= t("devise_views.registrations.edit.leave_blank") %>
<%= f.password_field :password, autocomplete: "off" %>
- <%= f.label :password_confirmation %>
+ <%= f.label :password_confirmation, t("devise_views.registrations.edit.password_confirmation_label") %>
<%= f.password_field :password_confirmation, autocomplete: "off" %>
- <%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.label :current_password, t("devise_views.registrations.edit.current_password_label") %> <%= t("devise_views.registrations.edit.need_current") %>
<%= f.password_field :current_password, autocomplete: "off" %>
- <%= f.submit "Update" %> + <%= f.submit t("devise_views.registrations.edit.update_submit") %>
<% end %> -

Cancel my account

+

<%= t("devise_views.registrations.edit.cancel_title") %>

-

Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>

+

<%= t("devise_views.registrations.edit.cancel_text") %> <%= button_to t("devise_views.registrations.edit.cancel_link"), registration_path(resource_name), data: { confirm: t("devise_views.registrations.edit.cancel_confirm") }, method: :delete %>

-<%= link_to "Back", :back %> +<%= link_to t("devise_views.registrations.edit.back_link"), :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 9ea13093c..d7203d549 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,41 +1,41 @@ -

Sign up

+

<%= t("devise_views.registrations.new.title") %>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> <%= devise_error_messages! %>
- <%= f.label :first_name %>
+ <%= f.label :first_name, t("devise_views.registrations.new.first_name_label") %>
<%= f.text_field :first_name, autofocus: true %>
- <%= f.label :last_name %>
+ <%= f.label :last_name, t("devise_views.registrations.new.last_name_label") %>
<%= f.text_field :last_name %>
- <%= f.label :email %>
+ <%= f.label :email, t("devise_views.registrations.new.email_label") %>
<%= f.email_field :email %>
- <%= f.label :password %> + <%= f.label :password, t("devise_views.registrations.new.password_label") %> <% if @minimum_password_length %> - (<%= @minimum_password_length %> characters minimum) + <%= t("devise_views.registrations.new.min_length", min: @minimum_password_length) %> <% end %>
<%= f.password_field :password, autocomplete: "off" %>
- <%= f.label :password_confirmation %>
+ <%= f.label :password_confirmation, t("devise_views.registrations.new.password_confirmation_label") %>
<%= f.password_field :password_confirmation, autocomplete: "off" %>
<%= render 'shared/captcha', resource: resource %>
- <%= f.submit "Registrarse", class: 'button radius' %> + <%= f.submit t("devise_views.registrations.new.submit"), class: 'button radius' %>
<% end %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index ba96a7ecd..e4e706cc6 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,25 +1,25 @@ -

Log in

+

<%= t("devise_views.sessions.new.title") %>

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
- <%= f.label :email %>
+ <%= f.label :email, t("devise_views.sessions.new.email_label") %>
<%= f.email_field :email, autofocus: true %>
- <%= f.label :password %>
+ <%= f.label :password, t("devise_views.sessions.new.password_label") %>
<%= f.password_field :password, autocomplete: "off" %>
<% if devise_mapping.rememberable? -%>
<%= f.check_box :remember_me %> - <%= f.label :remember_me %> + <%= f.label :remember_me, t("devise_views.sessions.new.remember_me") %>
<% end -%>
- <%= f.submit "Entrar" %> + <%= f.submit(t("devise_views.sessions.new.submit"), class: "button radius") %>
<% end %> diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb index cd795adb6..d7db78921 100644 --- a/app/views/devise/shared/_links.html.erb +++ b/app/views/devise/shared/_links.html.erb @@ -1,25 +1,25 @@ <%- if controller_name != 'sessions' %> - <%= link_to "Log in", new_session_path(resource_name) %>
+ <%= link_to t("devise_views.shared.links.login"), new_session_path(resource_name) %>
<% end -%> <%- if devise_mapping.registerable? && controller_name != 'registrations' %> - <%= link_to "Sign up", new_registration_path(resource_name) %>
+ <%= link_to t("devise_views.shared.links.signup"), new_registration_path(resource_name) %>
<% end -%> <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> - <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+ <%= link_to t("devise_views.shared.links.new_password"), new_password_path(resource_name) %>
<% end -%> <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> - <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+ <%= link_to t("devise_views.shared.links.new_confirmation"), new_confirmation_path(resource_name) %>
<% end -%> <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> - <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
+ <%= link_to t("devise_views.shared.links.new_unlock"), new_unlock_path(resource_name) %>
<% end -%> <%- if devise_mapping.omniauthable? %> <%- resource_class.omniauth_providers.each do |provider| %> - <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
+ <%= link_to t("devise_views.shared.links.signin_with_provider", provider: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider) %>
<% end -%> <% end -%> diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb index 16586bc7a..a92662664 100644 --- a/app/views/devise/unlocks/new.html.erb +++ b/app/views/devise/unlocks/new.html.erb @@ -1,15 +1,15 @@ -

Resend unlock instructions

+

<%= t("devise_views.unlocks.new.title") %>

<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> <%= devise_error_messages! %>
- <%= f.label :email %>
+ <%= f.label :email, t("devise_views.unlocks.new.email_label") %>
<%= f.email_field :email, autofocus: true %>
- <%= f.submit "Resend unlock instructions" %> + <%= f.submit t("devise_views.unlocks.new.submit") %>
<% end %> diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 890954e80..5098996ae 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -3,7 +3,7 @@
@@ -12,13 +12,13 @@