From 8d192b4458f77e5c7e0f1cb484b9c236055de55b Mon Sep 17 00:00:00 2001 From: Yannick Francois Date: Wed, 2 Oct 2013 17:01:13 +0200 Subject: [PATCH] Clean account page and start config locale. Start to use standard config/locale/yml file format for I18n Clean helper with a content_for yield usage --- app/controllers/setup_controller.rb | 1 - app/helpers/accounts_helper.rb | 22 -------------------- app/models/blog.rb | 4 ++++ app/views/accounts/confirm.html.erb | 11 +++++++++- app/views/accounts/login.html.erb | 20 ++++++++++++------ app/views/accounts/recover_password.html.erb | 16 ++++++++++---- app/views/accounts/signup.html.erb | 14 +++++++++---- app/views/layouts/accounts.html.erb | 10 +++++---- app/views/shared/_confirm.html.erb | 12 ----------- config/locales/en.yml | 3 --- config/locales/fr.yml | 12 +++++++++++ lang/fr_FR.rb | 12 +++-------- spec/models/blog_spec.rb | 12 +++++++++++ 13 files changed, 83 insertions(+), 66 deletions(-) delete mode 100644 app/helpers/accounts_helper.rb delete mode 100644 app/views/shared/_confirm.html.erb create mode 100644 config/locales/fr.yml diff --git a/app/controllers/setup_controller.rb b/app/controllers/setup_controller.rb index b9bc65edb6..26127b4411 100644 --- a/app/controllers/setup_controller.rb +++ b/app/controllers/setup_controller.rb @@ -4,7 +4,6 @@ class SetupController < ApplicationController def index return if not request.post? - @accounts_links = "" this_blog.blog_name = params[:setting][:blog_name] this_blog.base_url = blog_base_url diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb deleted file mode 100644 index b02bcd8dc3..0000000000 --- a/app/helpers/accounts_helper.rb +++ /dev/null @@ -1,22 +0,0 @@ -# coding: utf-8 -module AccountsHelper - def lost_password - link_to(content_tag(:small, _("I've lost my password")), :action => 'recover_password') - end - - def create_account_link - link_to(content_tag(:small, _("Create an account")), :action => 'signup') if this_blog.allow_signup == 1 - end - - def back_to_login - link_to(content_tag(:small, _("Back to login")), :action => 'login') - end - - def back_home - link_to(content_tag(:small, _("← Back to %s", this_blog.blog_name).html_safe), this_blog.base_url) - end - - def link_to_publify - content_tag(:h1, link_to("Publify", "http://publify.co")) - end -end diff --git a/app/models/blog.rb b/app/models/blog.rb index cb40f6e7c2..cd5b40f7fb 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb @@ -254,6 +254,10 @@ def has_twitter_configured? true end + def allow_signup? + allow_signup == 1 + end + private def protocol diff --git a/app/views/accounts/confirm.html.erb b/app/views/accounts/confirm.html.erb index 640fdc61ae..0219a2e887 100644 --- a/app/views/accounts/confirm.html.erb +++ b/app/views/accounts/confirm.html.erb @@ -1 +1,10 @@ -<%= render 'shared/confirm'%> +

<%= _("You have successfully signed up") %>

+

<%= _("Login: %s", current_user.login)%>

+

<%= _("strong>Password: %s", session[:tmppass]) %>

+
+ <%= _("Don't lose the mail sent at %s or you won't be able to login anymore", current_user.email)%> +
+ +<%- content_for :account_links do %> + <%= _("Proceed to %s", link_to(_("admin"), controller: 'admin/dashboard')) %> +<% end %> diff --git a/app/views/accounts/login.html.erb b/app/views/accounts/login.html.erb index b0a2941704..f3ff451285 100644 --- a/app/views/accounts/login.html.erb +++ b/app/views/accounts/login.html.erb @@ -1,18 +1,26 @@ -<%= form_tag :action=> "login" do %> - <%= text_field(:user, :login, {:class => 'input-block-level', :placeholder => _("Login")})%> - <%= password_field(:user, :password, {:class => 'input-block-level', :placeholder => _("Password")})%> +<%= form_tag action: "login" do %> + <%= text_field(:user, :login, {class: 'input-block-level', placeholder: t(".login")})%> + <%= password_field(:user, :password, {class: 'input-block-level', placeholder: t(".password")})%>
- + <%= submit_tag t('.sign_in'), class: "btn btn-info pull-right" %>
<% end %> -<% @accounts_links = [lost_password, create_account_link, back_home].join("
") %> +<%- content_for :account_links do %> + <%= link_to(_("I've lost my password"), action: 'recover_password') %> +
+ <%- if this_blog.allow_signup? %> + <%= link_to(_("Create an account"), action: 'signup') %> +
+ <% end %> + <%= link_to(_("← Back to %s", this_blog.blog_name).html_safe, this_blog.base_url) %> +<% end %> diff --git a/app/views/accounts/recover_password.html.erb b/app/views/accounts/recover_password.html.erb index 78b6b674c5..698452eb63 100644 --- a/app/views/accounts/recover_password.html.erb +++ b/app/views/accounts/recover_password.html.erb @@ -1,6 +1,14 @@ -<%= form_tag :action=> "recover_password" do %> - <%= text_field(:user, :login, {:class => 'input-block-level', :placeholder => _("Username or email")})%> - +<%= form_tag action: "recover_password" do %> + <%= text_field(:user, :login, {class: 'input-block-level', placeholder: _("Username or email")})%> + <%= submit_tag _('Reset my password'), class: "btn btn-info pull-right" %> <% end %> -<% @accounts_links = [back_to_login, create_account_link, back_home].join("
") %> +<%- content_for :account_links do %> + <%= link_to(_("Back to login"), action: 'login') %> +
+ <%- if this_blog.allow_signup? %> + <%= link_to(_("Create an account"), action: 'signup') %> +
+ <% end %> + <%= link_to(_("← Back to %s", this_blog.blog_name).html_safe, this_blog.base_url) %> +<% end %> diff --git a/app/views/accounts/signup.html.erb b/app/views/accounts/signup.html.erb index 538213ea96..95c90097fe 100644 --- a/app/views/accounts/signup.html.erb +++ b/app/views/accounts/signup.html.erb @@ -1,7 +1,13 @@ -<%= form_tag :action=> "signup" do %> - <%= text_field(:user, :login, {:class => 'input-block-level', :placeholder => _("Username") })%> - <%= text_field(:user, :email, {:class => 'input-block-level', :placeholder => _("Email") })%> +<%= form_tag action: "signup" do %> + <%= text_field(:user, :login, {class: 'input-block-level', placeholder: _("Username") })%> + <%= text_field(:user, :email, {class: 'input-block-level', placeholder: _("Email") })%> <% end %> -<% @accounts_links = [lost_password, back_to_login, back_home].join("
") %> +<%- content_for :account_links do %> + <%= link_to(_("I've lost my password"), action: 'recover_password') %> +
+ <%= link_to(_("Back to login"), action: 'login') %> +
+ <%= link_to(_("← Back to %s", this_blog.blog_name).html_safe, this_blog.base_url) %> +<% end %> diff --git a/app/views/layouts/accounts.html.erb b/app/views/layouts/accounts.html.erb index 711d32283f..272c4d316a 100644 --- a/app/views/layouts/accounts.html.erb +++ b/app/views/layouts/accounts.html.erb @@ -12,7 +12,7 @@
- <%= link_to_publify %> +

<%= link_to("Publify", "http://publify.co") %>

@@ -20,9 +20,11 @@
<%= render_the_flash %>
<%= yield %>
-
- <%= @accounts_links %> -
+ <%- if content_for?(:account_links) %> +
+ <%= yield :account_links %> +
+ <%- end %>
diff --git a/app/views/shared/_confirm.html.erb b/app/views/shared/_confirm.html.erb deleted file mode 100644 index 768c385e47..0000000000 --- a/app/views/shared/_confirm.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -

<%= _("You have successfully signed up") %>

-

- <%= _("Login: %s", current_user.login)%> -

-

- <%= _("Password: %s", session[:tmppass]) %> -

-
- <%= _("Don't lose the mail sent at %s or you won't be able to login anymore", current_user.email)%> -
- -<% @accounts_links = _("Proceed to %s", link_to(_("admin"), :controller => 'admin/dashboard')) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index a747bfa698..a9f72ecc77 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +1,2 @@ -# Sample localization file for English. Add more files in this directory for other locales. -# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. - en: hello: "Hello world" diff --git a/config/locales/fr.yml b/config/locales/fr.yml new file mode 100644 index 0000000000..41fabd181b --- /dev/null +++ b/config/locales/fr.yml @@ -0,0 +1,12 @@ +fr: + admin: + cache: + index: + explanations: "Afin d'économiser des ressources, Publify génère des fichiers statiques avec votre contenu. Ces fichiers sont supprimés lors d'une nouvelle publication. Vous pouvez cependant les effacer vous même." + + accounts: + login: + login: "Identifiant" + password: "Mot de passe" + sign_in: "S'identifier" + remember_me: "Rester connecté" diff --git a/lang/fr_FR.rb b/lang/fr_FR.rb index 120e913cc2..ccd608433c 100644 --- a/lang/fr_FR.rb +++ b/lang/fr_FR.rb @@ -28,7 +28,7 @@ # app/controllers/admin/dashboard_controller.rb l.store "Error: can't generate secret token. Security is at risk. Please, change %s content", "Erreur : nous n'avons pas pu générer le jeton secret. La sécurité de votre blog est à risque. Veuillez changer le contenu du fichier %s." l.store "For security reasons, you should restart your Publify application. Enjoy your blogging experience.", "Pour des raisons de sécurité, merci de redémarrer votre blog Publify. Bonne expérience de blogging !" - l.store "You are late from at least one major version of Publify. You should upgrade immediately. Download and install %s", "Vous avez au moins une version majeure de Publify de retard. Vous devriez immédiatement vous mettre à jour. Téléchargez et installez %s" + l.store "You are late from at least one major version of Publify. You should upgrade immediately. Download and install %s", "Vous avez au moins une version majeure de Publify de retard. Vous devriez immédiatement vous mettre à jour. Téléchargez et installez %s" l.store "the latest Publify version", "la dernière version de Publify" l.store "There's a new version of Publify available which may contain important bug fixes. Why don't you upgrade to %s ?", "Une nouvelle version de Publify est disponible. Celle-ci contient probablement d'importants correctifs. Pourquoi ne téléchargeriez-vous pas %s" l.store "There's a new version of Publify available. Why don't you upgrade to %s ?", "Une nouvelle version de Publify est disponible. Pouquoi n'installeriez-vous pas %s" @@ -162,12 +162,6 @@ # app/models/post_type.rb l.store "This article type already exists", "" - # app/views/accounts/login.html.erb - l.store "Sign in", "S'identifier" - l.store "Login", "Identifiant" - l.store "Password", "Mot de passe" - l.store "Remember me", "Rester connecté" - # app/views/accounts/recover_password.html.erb l.store "Reset my password", "Me renvoyer un mot de passe" l.store "Username or email", "Identifiant ou email" @@ -308,7 +302,7 @@ # app/views/admin/dashboard/_dafts.html.erb l.store "Your drafts", "Vos brouillons" l.store "No drafts yet, why don't you start and write one", "Pas de brouillons, pourquoi ne pas en écrire un" - + # app/views/admin/dashboard/_dafts.html.erb # app/views/admin/feedback/_button.html.erb @@ -419,7 +413,7 @@ l.store "This will display", "Cela affichera" l.store "at the bottom of each post in the RSS feed", "en bas de chacun de vos articles sur le flux RSS" l.store "Here you can add anything you want to appear in your application header, such as analytics service tracking code.", "Ici, vous pouve ajouter tout ce que vous souhaitez voir apparaître dans l'en-tête de votre blog, comme le code de suivi d'un service de statistiques." - + # app/views/admin/seo/permalinks.html.erb l.store "Publify offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links.", "Les exemples ci-dessous vous aideront à démarrerPublify vous offre la possibilité de créer une structure d'URL personnalisée pour vos liens permanents et vos archives. Cela peut vous permettre d'améliorer l'esthétique, l'utilisabilité et la viralité de vos liens." l.store "Here are some examples to get you started.", "Les exemples ci-dessous vous aideront à démarrer." diff --git a/spec/models/blog_spec.rb b/spec/models/blog_spec.rb index 520340699b..ee4f34edf1 100644 --- a/spec/models/blog_spec.rb +++ b/spec/models/blog_spec.rb @@ -207,4 +207,16 @@ def set_permalink permalink it { expect(blog.per_page('rss')).to eq(4) } it { expect(blog.per_page('atom')).to eq(4) } end + + describe :allow_signup? do + context "with a blog that allow signup" do + let(:blog) { build(:blog, allow_signup: 1) } + it {expect(blog.allow_signup?).to be_true} + end + + context "with a blog that not allow signup" do + let(:blog) { build(:blog, allow_signup: 0) } + it {expect(blog.allow_signup?).to be_false} + end + end end