Permalink
Browse files

Merge branch 'localhost_master' into i18n

Conflicts:
	README.rdoc
	app/controllers/sessions_controller.rb
	app/controllers/users_controller.rb
	app/helpers/users_helper.rb
	app/views/forums/index.html.erb
	app/views/layouts/_head.html.erb
	app/views/layouts/application.html.erb
	app/views/posts/index.html.erb
	app/views/sites/_form.html.erb
	app/views/sites/index.html.erb
	app/views/topics/show.html.erb
	app/views/users/edit.html.erb
	app/views/users/show.html.erb
	db/schema.rb
  • Loading branch information...
2 parents 1d9ef5d + da3acf6 commit 7a8990e61f1c8b0f9f2f8eeccbe11475b9779851 @courtenay courtenay committed Aug 4, 2009
Showing with 951 additions and 804 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 README.rdoc
  3. +8 −0 app/controllers/application.rb
  4. +2 −2 app/controllers/forums_controller.rb
  5. +4 −4 app/controllers/sessions_controller.rb
  6. +1 −1 app/controllers/sites_controller.rb
  7. +14 −4 app/controllers/users_controller.rb
  8. +6 −30 app/helpers/application_helper.rb
  9. +0 −8 app/helpers/forums_helper.rb
  10. +6 −3 app/helpers/users_helper.rb
  11. +4 −2 app/models/user/validation.rb
  12. +3 −3 app/views/forums/_form.html.erb
  13. +3 −3 app/views/forums/edit.html.erb
  14. +25 −24 app/views/forums/index.html.erb
  15. +3 −3 app/views/forums/new.html.erb
  16. +22 −25 app/views/forums/show.html.erb
  17. +13 −15 app/views/layouts/_head.html.erb
  18. +23 −22 app/views/layouts/application.html.erb
  19. +4 −14 app/views/posts/_edit.html.erb
  20. +9 −0 app/views/posts/_formatting.erb
  21. +4 −4 app/views/posts/edit.html.erb
  22. +6 −6 app/views/posts/index.html.erb
  23. +5 −5 app/views/sessions/new.html.erb
  24. +2 −2 app/views/sessions/new.rhtml
  25. +4 −4 app/views/sites/_form.html.erb
  26. +3 −3 app/views/sites/edit.html.erb
  27. +14 −14 app/views/sites/index.html.erb
  28. +4 −4 app/views/sites/new.html.erb
  29. +6 −2 app/views/sites/show.html.erb
  30. +5 −5 app/views/topics/_form.html.erb
  31. +2 −2 app/views/topics/edit.html.erb
  32. +4 −4 app/views/topics/new.html.erb
  33. +25 −38 app/views/topics/show.html.erb
  34. +7 −7 app/views/users/_contact_info.html.erb
  35. +9 −9 app/views/users/_settings.html.erb
  36. +8 −8 app/views/users/edit.html.erb
  37. +10 −10 app/views/users/index.html.erb
  38. +7 −5 app/views/users/new.rhtml
  39. +15 −15 app/views/users/show.html.erb
  40. +10 −0 config/environment.rb
  41. +1 −1 config/environments/development.rb
  42. +311 −0 config/locales/de.yml
  43. +143 −0 config/locales/en.rb
  44. +134 −0 config/locales/en.yml
  45. +37 −0 db/migrate/002_add_brain_buster.rb
  46. +5 −0 db/schema.rb
  47. +1 −2 public/javascripts/application.js
  48. +0 −75 public/javascripts/time.js
  49. +14 −0 public/stylesheets/captcha.css
  50. +1 −0 vendor/plugins/brain_buster
  51. +0 −18 vendor/plugins/gibberish/LICENSE
  52. +0 −113 vendor/plugins/gibberish/README
  53. +0 −3 vendor/plugins/gibberish/init.rb
  54. +0 −3 vendor/plugins/gibberish/lang/es.yml
  55. +0 −3 vendor/plugins/gibberish/lang/fr.yml
  56. +0 −8 vendor/plugins/gibberish/lib/gibberish.rb
  57. +0 −69 vendor/plugins/gibberish/lib/gibberish/localize.rb
  58. +0 −17 vendor/plugins/gibberish/lib/gibberish/string_ext.rb
  59. +0 −182 vendor/plugins/gibberish/test/gibberish_test.rb
View
@@ -0,0 +1,3 @@
+[submodule "vendor/plugins/brain_buster"]
+ path = vendor/plugins/brain_buster
+ url = git://github.com/rsanheim/brain_buster.git
View
@@ -11,6 +11,7 @@ The popular rails-based Beast forum, rewritten from the ground up with the same
* email and atom feed support
* xml/json API (not 100% tested yet, fixing soon)
* highline based easy console installer
+* internationalization via the I18n framework
Help desired via git:
@@ -4,6 +4,7 @@ class ApplicationController < ActionController::Base
include AuthenticatedSystem
helper :all
helper_method :current_page
+ before_filter :set_language
before_filter :login_required, :only => [:new, :edit, :create, :update, :destroy]
# See ActionController::RequestForgeryProtection for details
@@ -21,4 +22,11 @@ class ApplicationController < ActionController::Base
def current_page
@page ||= params[:page].blank? ? 1 : params[:page].to_i
end
+
+ private
+
+ def set_language
+ I18n.locale = :en || I18n.default_locale
+ end
+
end
@@ -53,7 +53,7 @@ def create
respond_to do |format|
if @forum.save
- flash[:notice] = 'Forum was successfully created.'
+ flash[:notice] = I18n.t 'txt.forum_created', :default => 'Forum was successfully created.'
format.html { redirect_to(@forum) }
format.xml { render :xml => @forum, :status => :created, :location => @forum }
else
@@ -70,7 +70,7 @@ def update
respond_to do |format|
if @forum.update_attributes(params[:forum])
- flash[:notice] = 'Forum was successfully updated.'
+ flash[:notice] = I18n.t 'txt.forum_updated', :default => 'Forum was successfully updated.'
format.html { redirect_to(@forum) }
format.xml { head :ok }
else
@@ -16,18 +16,18 @@ def create
cookies[:auth_token] = { :value => current_user.remember_token , :expires => current_user.remember_token_expires_at }
end
redirect_back_or_default('/')
- flash[:notice] = "Logged in successfully"
+ flash[:notice] = I18n.t 'txt.successful_login', :default => "Logged in successfully"
else
- flash[:error] = "Invalid login"
- render :action => 'new'
+ flash[:error] = I18n.t 'txt.invalid_login', :default => "Invalid login"
+ redirect_back_or_default(login_path)
end
end
def destroy
current_user.forget_me if logged_in?
cookies.delete :auth_token
reset_session
- flash[:notice] = "You have been logged out."
+ flash[:notice] = I18n.t 'txt.logged_out', :default => "You have been logged out."
redirect_back_or_default('/')
end
end
@@ -1,5 +1,5 @@
class SitesController < ApplicationController
- before_filter :admin_required, :only => [ :destroy, :update, :edit ]
+ before_filter :admin_required
def index
@sites = Site.paginate(:all, :page => current_page, :order => 'host ASC')
@@ -2,7 +2,11 @@ class UsersController < ApplicationController
before_filter :admin_required, :only => [:suspend, :unsuspend, :destroy, :purge, :edit]
before_filter :find_user, :only => [:update, :show, :edit, :suspend, :unsuspend, :destroy, :purge]
before_filter :login_required, :only => [:settings, :update]
-
+
+ # Brainbuster Captcha
+ before_filter :create_brain_buster, :only => [:new]
+ before_filter :validate_brain_buster, :only => [:create]
+
def index
users_scope = admin? ? :all_users : :users
if params[:q]
@@ -20,17 +24,19 @@ def create
cookies.delete :auth_token
@user = current_site.users.build(params[:user])
@user.save if @user.valid?
+ @user.register! if @user.valid?
unless @user.new_record?
- @user.register!
redirect_back_or_default('/login')
- flash[:notice] = "Thanks for signing up! Please click the link in your email to activate your account"
+ flash[:notice] = I18n.t 'txt.activation_required',
+ :default => "Thanks for signing up! Please click the link in your email to activate your account"
else
render :action => 'new'
end
end
def settings
@user = current_user
+ current_site
render :action => "edit"
end
@@ -100,8 +106,12 @@ def find_user
current_site.users.find_by_permalink(params[:id])
end or raise ActiveRecord::RecordNotFound
end
-
+
def authorized?
admin? || params[:id].blank? || params[:id] == current_user.permalink
end
+
+ def render_or_redirect_for_captcha_failure
+ render :action => 'new'
+ end
end
@@ -7,22 +7,22 @@ def feed_icon_tag(title, url)
def pagination(collection)
if collection.total_entries > 1
- "<p class='pages'>" + 'Pages'[:pages_title] + ": <strong>" +
- will_paginate(collection, :inner_window => 10, :next_label => "next"[], :prev_label => "previous"[]) +
+ "<p class='pages'>" + I18n.t('txt.pages', :default => 'Pages') + ": <strong>" +
+ will_paginate(collection, :inner_window => 10, :next_label => I18n.t('txt.page_next', :default => 'next'), :prev_label => I18n.t('txt.page_prev', :default => 'previous')) +
"</strong></p>"
end
end
def next_page(collection)
unless collection.current_page == collection.total_entries or collection.total_entries == 0
- "<p style='float:right;'>" + link_to("Next page"[], { :page => collection.current_page.next }.merge(params.reject{|k,v| k=="page"})) + "</p>"
+ "<p style='float:right;'>" + link_to(I18n.t('txt.next_page', :default => 'next page'), { :page => collection.current_page.next }.merge(params.reject{|k,v| k=="page"})) + "</p>"
end
end
def search_posts_title
- returning(params[:q].blank? ? 'Recent Posts'[] : "Searching for"[] + " '#{h params[:q]}'") do |title|
- title << " "+'by {user}'[:by_user,h(@user.display_name)] if @user
- title << " "+'in {forum}'[:in_forum,h(@forum.name)] if @forum
+ returning(params[:q].blank? ? I18n.t('txt.recent_posts', :default => 'Recent Posts') : I18n.t('txt.searching_for', :default => 'Searching for') + " '#{h params[:q]}'") do |title|
+ title << " " + I18n.t('txt.by_user', :default => 'by {{user}}', :user => h(@user.display_name)) if @user
+ title << " " + I18n.t('txt.in_forum', :default => 'in {{forum}}', :forum => h(@forum.name)) if @forum
end
end
@@ -61,32 +61,8 @@ def search_path(atom = false)
atom ? send("formatted_#{prefix}_posts_path", options.update(:format => :atom)) : send("#{prefix}_posts_path", options)
end
- @@default_jstime_format = "%d %b, %Y %I:%M %p"
- def jstime(time, format = nil)
- content_tag 'span', time.strftime(format || @@default_jstime_format), :class => 'time'
- end
-
def for_moderators_of(record, &block)
moderator_of?(record) && concat(capture(&block))
end
- def main_site
- @main_site ||= Site.find(:first)
- end
-
- def main_site_name
- @main_site_name ||= main_site ? @main_site.name :
- "Altered Beast"
- end
-
- def main_site_description
- @main_site_description ||= main_site ? @main_site.description :
- "<h5>What is Beast?</h5><p>A small, light-weight forum in Rails with a scary name and a goal of around 500 lines of code when we're done.</p>"
- end
-
- def main_site_tagline
- @main_site_tagline ||= main_site ? @main_site.tagline :
- "Two's company. Three's a forum. More's a Beast."
- end
-
end
@@ -10,14 +10,6 @@ def recent_forum_activity(forum)
return false unless logged_in? && forum.recent_topic
return forum.recent_topic.last_updated_at > ((session[:forums] ||= {})[forum.id] || last_active)
end
-
- def topic_count
- pluralize current_site.topics.size, 'topic'
- end
-
- def post_count
- pluralize current_site.posts.size, 'post'
- end
def last_active
session[:last_active] ||= Time.now.utc
@@ -1,17 +1,20 @@
module UsersHelper
# todo: make this use "size" instead of "count" and maybe cache it
def user_count
- pluralize current_site.users.count, 'user'[:user]
+ count = current_site.users.count
+ I18n.t 'txt.count_users', :count => count, :num => number_with_delimiter(count)
end
# todo: cache this?
def active_user_count
- pluralize current_site.users.count(:conditions => "users.posts_count > 0"), 'active user'[:active_user]
+ count = current_site.users.count(:conditions => "posts_count > 0")
+ I18n.t 'txt.count_users_active', :count => count, :num => number_with_delimiter(count)
end
# todo: cache this?
def lurking_user_count
- pluralize current_site.users.count(:conditions => "users.posts_count < 1"), 'lurking user'[:lurking_user]
+ count = current_site.users.count(:conditions => "posts_count = 0")
+ I18n.t 'txt.count_users_lurking', :count => count, :num => number_with_delimiter(count)
end
#
@@ -3,6 +3,7 @@ class User
# Virtual attribute for the unencrypted password
attr_accessor :password
+ before_validation :normalize_login_and_email
validates_presence_of :login, :email
validates_presence_of :password, :if => :password_required?
validates_presence_of :password_confirmation, :if => :password_required?
@@ -11,7 +12,6 @@ class User
validates_length_of :login, :within => 3..40
validates_length_of :email, :within => 3..100
validates_uniqueness_of :login, :email, :scope => :site_id
- before_save :downcase_email_and_login
before_save :encrypt_password
before_create :set_first_user_as_admin
@@ -50,8 +50,10 @@ def set_first_user_as_admin
self.admin = true if site and site.users.size.zero?
end
- def downcase_email_and_login
+ def normalize_login_and_email
login.downcase!
+ login.strip!
email.downcase!
+ return true
end
end
@@ -5,17 +5,17 @@
<table border="0" cellspacing="0" cellpadding="0" class="noborder nopad wide">
<td>
- <label><%= 'Title'[:title_title] %></label><br />
+ <label><%= I18n.t 'txt.views_forums.title', :default => 'Title' %></label><br />
<%= form.text_field :name, :class => "primary" %>
</td>
<td style="text-align:right">
- <label><%= 'Position'[:position_title] %></label><br />
+ <label><%= I18n.t 'txt.views_forums.position', :default => 'Position' %></label><br />
<%= form.text_field :position, :size => 5 %>
</td>
</table>
</p>
<p id="forum_descripion">
-<label><%= 'Description'[:description_title] %></label><br />
+<label><%= I18n.t 'txt.views_forums.desc', :default => 'Description' %></label><br />
<%= form.text_area :description, :rows => 7 %></p>
@@ -1,12 +1,12 @@
<div class="crumbs">
- <%= link_to 'Forums'[:forums_title], root_path %> <span class="arrow">&rarr;</span>
+ <%= link_to I18n.t('txt.forums', :default => 'Forums'), root_path %> <span class="arrow">&rarr;</span>
</div>
-<h1><%= 'Edit Forum'[:edit_forum] %></h1>
+<h1><%= I18n.t 'txt.views_forums.edit', :default => 'Edit Forum' %></h1>
<% form_for :forum,
:url => forum_path(@forum),
:html => { :method => :put } do |f| -%>
<%= render :partial => "form", :object => f %>
-<%= submit_tag 'Save Forum'[:save_forum] %> or <%= link_to('Cancel'[:cancel], forums_path) %>
+<%= submit_tag I18n.t('txt.save', :default => 'Save Forum') %> <%= I18n.t 'txt.or', :default => 'or' %> <%= link_to(I18n.t('txt.cancel', :default => 'Cancel'), forums_path) %>
<% end -%>
@@ -1,65 +1,67 @@
<% content_for :right do %>
-<% if @current_site %>
-<%= @current_site.description %>
-<% else %>
-<%= main_site_description %>
-<% end %>
+<h5><%= I18n.t 'txt.sidebar.beast_title', :default => 'What is Beast?' %></h5>
+
+<p>
+ <%= I18n.t 'txt.sidebar.beast_desc', :default => "A small, light-weight forum in Rails with a scary name and a goal of around 500 lines of code when we're done." %>
+</p>
<% if admin? %>
-<h6><%= 'Admin'[:admin_title] %></h6>
-<p><%= link_to 'Create New Forum'[:create_new_forum], new_forum_path, :class => "utility" %></p>
+<h6><%= I18n.t 'txt.admin.title', :default => 'Admin' %></h6>
+<p><%= link_to I18n.t('txt.admin.create_new_forum', :default => 'Create New Forum'), new_forum_path, :class => "utility" %></p>
<% end %>
<% end %>
-<h1 style="margin-top:0;"><%= 'Forums'[:forums_title] %></h1>
+<h1 style="margin-top:0;"><%= I18n.t 'txt.forums', :default => 'Forums' %></h1>
<p class="subtitle">
-<%= feed_icon_tag "Recent Posts"[:recent_posts], formatted_posts_path(:format => 'atom') %>
-<%= topic_count %>, <%= post_count %> <%# OPTIMIZE ME voice_count %>
+<%= feed_icon_tag I18n.t('txt.recent_posts', :default => "Recent Posts"), formatted_posts_path(:format => 'atom') %>
+<%= I18n.t 'txt.count_topics', :count => current_site.topics.size, :num => number_with_delimiter(current_site.topics.size) %>,
+<%= I18n.t 'txt.count_posts', :count => current_site.posts.size, :num => number_with_delimiter(current_site.posts.size) %>
+<%# OPTIMIZE ME voice_count %>
+
</p>
<table border="0" cellspacing="0" cellpadding="0" class="wide forums">
<tr>
- <th class="la" width="70%" colspan="3"><%= 'Forum'[:forum_title] %></th>
- <th class="la" width="30%" colspan="1"><%= 'Last Post'[:last_post] %></th>
+ <th class="la" width="70%" colspan="3"><%= I18n.t 'txt.forum', :default => 'Forum' %></th>
+ <th class="la" width="30%" colspan="1"><%= I18n.t 'txt.latest_post', :default => 'Last Post' %></th>
</tr>
<% for forum in @forums do %>
<tr>
<td class="vat c1">
<% if recent_forum_activity(forum) %>
- <%= image_tag "clearbits/comment.gif", :class => "icon green", :title => 'Recent activity'[:recent_activity] %>
+ <%= image_tag "clearbits/comment.gif", :class => "icon green", :title => I18n.t('txt.recent_activity', :default => 'Recent activity') %>
<% else %>
- <%= image_tag "clearbits/comment.gif", :class => "icon grey", :title => 'No recent activity'[:no_recent_activity] %>
+ <%= image_tag "clearbits/comment.gif", :class => "icon grey", :title => I18n.t('txt.no_recent_activity', :default => 'No recent activity') %>
<% end %>
</td>
<td class="c2 vat">
<%= link_to h(forum.name), forum_path(forum), :class => "title" %>
<div class="posts">
- <%= '{count} topics'[(count=forum.topics.size)==1 ? :topic_count : :topics_count, number_with_delimiter(count)] %>,
- <%= '{count} posts'[(count=forum.posts.size)==1 ? :post_count : :posts_count, number_with_delimiter(count)] %>
+ <%= I18n.t 'txt.count_topics', :count => forum.topics.size, :num => number_with_delimiter(forum.topics.size) %>,
+ <%= I18n.t 'txt.count_posts', :count => forum.posts.size, :num => number_with_delimiter(forum.posts.size) %>
</div>
- <p class="desc"><%= forum.description_html %>
- </p>
+ <p class="desc"><%= forum.description_html %></p>
</td>
<td class="c3">
- <%= link_to 'Edit'[:edit_title], edit_forum_path(forum), :class => "tiny", :rel => "directory", :style => "float:right" if admin? %>
+ <%= link_to I18n.t('txt.edit', :default => 'Edit'), edit_forum_path(forum), :class => "tiny", :rel => "directory", :style => "float:right" if admin? %>
</td>
<td class="inv lp">
<% if forum.recent_post -%>
- <%= jstime forum.recent_post.created_at %><br />
- <%= 'by {user}'[:by_user,"<strong>#{h(forum.recent_post.user.display_name)}</strong>"] %>
- <span>(<%= link_to 'view'[], forum_topic_path(forum, forum.recent_post.topic, :page => forum.recent_post.topic.last_page, :anchor => dom_id(forum.recent_post)) %>)</span>
+ <%= I18n.t 'txt.post_age', :when => time_ago_in_words(forum.recent_post.created_at), :default => "posted {{when}} ago" %><br />
+ <strong><%= I18n.t 'txt.by_user', :default => 'by {{user}}', :user => "#{h(forum.recent_post.user.display_name)}" %></strong>
+ <span>(<%= link_to I18n.t('txt.view', :default => 'view'), forum_topic_path(forum, forum.recent_post.topic, :page => forum.recent_post.topic.last_page, :anchor => dom_id(forum.recent_post)) %>)</span>
<% end -%>
</td>
</tr>
<% end %>
</table>
<p>
- <%= link_to 'Recent posts'[:recent_posts], posts_path %>
+ <%= link_to I18n.t('txt.show_recent_posts', :default => 'Show recent posts'), posts_path %>
</p>
<%# TODO: online_users = User.currently_online -%>
@@ -72,4 +74,3 @@
</div>
</div>
<% end %>
-
Oops, something went wrong.

0 comments on commit 7a8990e

Please sign in to comment.