Skip to content

Commit

Permalink
Clean account page and start config locale.
Browse files Browse the repository at this point in the history
Start to use standard config/locale/yml file format for I18n
Clean helper with a content_for yield usage
  • Loading branch information
Yannick Francois committed Oct 2, 2013
1 parent fc12a91 commit 8d192b4
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 66 deletions.
1 change: 0 additions & 1 deletion app/controllers/setup_controller.rb
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions app/helpers/accounts_helper.rb

This file was deleted.

4 changes: 4 additions & 0 deletions app/models/blog.rb
Expand Up @@ -254,6 +254,10 @@ def has_twitter_configured?
true
end

def allow_signup?
allow_signup == 1
end

private

def protocol
Expand Down
11 changes: 10 additions & 1 deletion app/views/accounts/confirm.html.erb
@@ -1 +1,10 @@
<%= render 'shared/confirm'%>
<p><%= _("You have successfully signed up") %></p>
<p><%= _("<strong>Login:</strong> %s", current_user.login)%></p>
<p><%= _("strong>Password:</strong> %s", session[:tmppass]) %></p>
<div class='alert'>
<small><%= _("Don't lose the mail sent at %s or you won't be able to login anymore", current_user.email)%></small>
</div>

<%- content_for :account_links do %>
<%= _("Proceed to %s", link_to(_("admin"), controller: 'admin/dashboard')) %>
<% end %>
20 changes: 14 additions & 6 deletions 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")})%>
<div class='clearfix'>
<div class='row'>
<div class='span2'>
<label class='checkbox inline'>
<%= check_box_tag 'remember_me' %><small><%= _('Remember me')%></small>
<%= check_box_tag 'remember_me' %><small><%= t('.remember_me')%></small>
</label>
</div>
<div class='span2'>
<input type="submit" name="login" class="btn btn-info pull-right" value= "<%= _('Sign in') %>" />
<%= submit_tag t('.sign_in'), class: "btn btn-info pull-right" %>
</div>
</div>
</div>
<% end %>
<% @accounts_links = [lost_password, create_account_link, back_home].join("<br />") %>
<%- content_for :account_links do %>
<small><%= link_to(_("I've lost my password"), action: 'recover_password') %></small>
<br/>
<%- if this_blog.allow_signup? %>
<small><%= link_to(_("Create an account"), action: 'signup') %></small>
<br/>
<% end %>
<small><%= link_to(_("&larr; Back to %s", this_blog.blog_name).html_safe, this_blog.base_url) %></small>
<% end %>
16 changes: 12 additions & 4 deletions 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")})%>
<input type="submit" name="submit" class="btn btn-info pull-right" value= "<%= _('Reset my password') %>" />
<%= 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("<br />") %>
<%- content_for :account_links do %>
<small><%= link_to(_("Back to login"), action: 'login') %></small>
<br/>
<%- if this_blog.allow_signup? %>
<small><%= link_to(_("Create an account"), action: 'signup') %></small>
<br/>
<% end %>
<small><%= link_to(_("&larr; Back to %s", this_blog.blog_name).html_safe, this_blog.base_url) %></small>
<% end %>
14 changes: 10 additions & 4 deletions 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") })%>
<input type="submit" id="submit" class='btn btn-info pull-right' value="<%= _('Signup')%>" />
<% end %>
<% @accounts_links = [lost_password, back_to_login, back_home].join("<br />") %>
<%- content_for :account_links do %>
<small><%= link_to(_("I've lost my password"), action: 'recover_password') %></small>
<br/>
<small><%= link_to(_("Back to login"), action: 'login') %></small>
<br/>
<small><%= link_to(_("&larr; Back to %s", this_blog.blog_name).html_safe, this_blog.base_url) %></small>
<% end %>
10 changes: 6 additions & 4 deletions app/views/layouts/accounts.html.erb
Expand Up @@ -12,17 +12,19 @@
<div class='container'>
<div class='row'>
<div class='span4 offset4'>
<%= link_to_publify %>
<h1><%= link_to("Publify", "http://publify.co") %></h1>
</div>
</div>
<div class='row'>
<div class='span4 offset4 well'>
<div id="flash"><%= render_the_flash %></div>
<%= yield %>
</div>
<div class='span4 offset4'>
<%= @accounts_links %>
</div>
<%- if content_for?(:account_links) %>
<div class='span4 offset4'>
<%= yield :account_links %>
</div>
<%- end %>
</div>
</div>
</body>
Expand Down
12 changes: 0 additions & 12 deletions app/views/shared/_confirm.html.erb

This file was deleted.

3 changes: 0 additions & 3 deletions 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"
12 changes: 12 additions & 0 deletions 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é"
12 changes: 3 additions & 9 deletions lang/fr_FR.rb
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down
12 changes: 12 additions & 0 deletions spec/models/blog_spec.rb
Expand Up @@ -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

0 comments on commit 8d192b4

Please sign in to comment.