aboutsummaryrefslogtreecommitdiffstats
path: root/app/views
diff options
context:
space:
mode:
authorAdrien Coquio <adrien.coquio@gmail.com>2012-06-03 21:37:41 +0200
committerPhilip Arndt <parndt@gmail.com>2012-06-09 11:19:38 +1200
commitd0c249af2a2e630ac993eb23a691ef996613b55f (patch)
tree6992cf3816a6f5b1e022637a6780a7d24f1753cf /app/views
parent7743fab73a5c60d9f5f0cf2ce65a3f0914b1376f (diff)
downloadrefinerycms-blog-d0c249af2a2e630ac993eb23a691ef996613b55f.tar.gz
refinerycms-blog-d0c249af2a2e630ac993eb23a691ef996613b55f.tar.bz2
refinerycms-blog-d0c249af2a2e630ac993eb23a691ef996613b55f.zip
Added i18n support to models through globalize3.
* Added Post translation * Added Category translation * Use friendly_id globalize with category * Added migrate_data option on migrations for translations * Use Refinery locale instead of I18n * Refactored duplicate locale_picker partial * Removed useless .all call * Use presence instead if / blank? * Added with_globalize scopes when loading posts of one category * Use Globalize when creating post factory * Fix failing specs by creating blog posts/categories using needed locale.
Diffstat (limited to 'app/views')
-rw-r--r--app/views/refinery/blog/admin/categories/_category.html.erb12
-rw-r--r--app/views/refinery/blog/admin/categories/_form.html.erb3
-rw-r--r--app/views/refinery/blog/admin/posts/_form.html.erb3
-rw-r--r--app/views/refinery/blog/admin/posts/_post.html.erb11
-rw-r--r--app/views/refinery/blog/admin/shared/_locale_picker.html.erb11
-rw-r--r--app/views/refinery/blog/shared/_post.html.erb2
6 files changed, 38 insertions, 4 deletions
diff --git a/app/views/refinery/blog/admin/categories/_category.html.erb b/app/views/refinery/blog/admin/categories/_category.html.erb
index b7d352f..d31e4e6 100644
--- a/app/views/refinery/blog/admin/categories/_category.html.erb
+++ b/app/views/refinery/blog/admin/categories/_category.html.erb
@@ -1,7 +1,15 @@
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(category) -%>">
<span class='title'>
- <%= category.title %>
- <span class="preview">&nbsp;</span>
+ <%= category.title.presence || category.translations.detect {|t| t.title.present?}.title %>
+ <span class="preview">
+ <% category.translations.each do |translation| %>
+ <% if translation.title.present? %>
+ <%= link_to refinery_icon_tag("flags/#{translation.locale}.png", :size => '16x11'),
+ refinery.edit_blog_admin_category_path(category, :switch_locale => translation.locale),
+ :class => 'locale' %>
+ <% end %>
+ <% end %>
+ </span>
</span>
<span class='actions'>
<%= link_to refinery_icon_tag("application_edit.png"),
diff --git a/app/views/refinery/blog/admin/categories/_form.html.erb b/app/views/refinery/blog/admin/categories/_form.html.erb
index b1cf16c..6b4e20d 100644
--- a/app/views/refinery/blog/admin/categories/_form.html.erb
+++ b/app/views/refinery/blog/admin/categories/_form.html.erb
@@ -5,6 +5,9 @@
:include_object_name => true
} %>
+ <%= render "/refinery/blog/admin/shared/locale_picker",
+ :current_locale => Thread.current[:globalize_locale] if Refinery.i18n_enabled? %>
+
<div class='field'>
<%= f.label :title -%>
<%= f.text_field :title, :class => 'larger widest' -%>
diff --git a/app/views/refinery/blog/admin/posts/_form.html.erb b/app/views/refinery/blog/admin/posts/_form.html.erb
index a977754..b6fc535 100644
--- a/app/views/refinery/blog/admin/posts/_form.html.erb
+++ b/app/views/refinery/blog/admin/posts/_form.html.erb
@@ -5,6 +5,9 @@
:include_object_name => true
} %>
+ <%= render "/refinery/blog/admin/shared/locale_picker",
+ :current_locale => Thread.current[:globalize_locale] if Refinery.i18n_enabled? %>
+
<div class='field'>
<%= f.label :title -%>
<%= f.text_field :title, :class => 'larger widest' -%>
diff --git a/app/views/refinery/blog/admin/posts/_post.html.erb b/app/views/refinery/blog/admin/posts/_post.html.erb
index fea3eb8..781595a 100644
--- a/app/views/refinery/blog/admin/posts/_post.html.erb
+++ b/app/views/refinery/blog/admin/posts/_post.html.erb
@@ -1,7 +1,16 @@
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(post) -%>">
<span class='title'>
- <%= post.title %>
+ <%= post.title.presence || post.translations.detect {|t| t.title.present?}.title %>
<span class="preview">
+ <% post.translations.each do |translation| %>
+ <% if translation.title.present? %>
+ <%= link_to refinery_icon_tag("flags/#{translation.locale}.png", :size => '16x11'),
+ refinery.edit_blog_admin_post_path(post, :switch_locale => translation.locale),
+ :class => 'locale' %>
+ <% end %>
+ <% end %>
+
+ <%= post.published_at.try(:strftime, '%b %d, %Y') || 'draft' %>
<%= " by #{post.author.username}" if post.author.present? %>
<% if post.draft? %>
<span class="label notice"><%= t('refinery.blog.admin.posts.post.draft') %></span>
diff --git a/app/views/refinery/blog/admin/shared/_locale_picker.html.erb b/app/views/refinery/blog/admin/shared/_locale_picker.html.erb
new file mode 100644
index 0000000..e162364
--- /dev/null
+++ b/app/views/refinery/blog/admin/shared/_locale_picker.html.erb
@@ -0,0 +1,11 @@
+<input type='hidden' name='switch_locale' id='switch_locale' value='<%= local_assigns[:current_locale] %>' />
+<% if (locales ||= Refinery::I18n.frontend_locales).present? and locales.many? %>
+ <ul id='switch_locale_picker' class='clearfix'>
+ <% locales.each do |locale| %>
+ <li<%= " class='selected'" if locale.to_s == local_assigns[:current_locale].to_s %>>
+ <%= link_to refinery_icon_tag("flags/#{locale}.png", :size => "32x22"),
+ refinery.url_for(:switch_locale => locale) %>
+ </li>
+ <% end %>
+ </ul>
+<% end %>
diff --git a/app/views/refinery/blog/shared/_post.html.erb b/app/views/refinery/blog/shared/_post.html.erb
index 5b90c8e..40ae70b 100644
--- a/app/views/refinery/blog/shared/_post.html.erb
+++ b/app/views/refinery/blog/shared/_post.html.erb
@@ -7,7 +7,7 @@
<%= t('created_at', :scope => 'refinery.blog.shared.posts', :when => l(post.published_at.to_date, :format => :short)) %>
</time>
<%= "#{t('by', :scope => 'refinery.blog.posts.show')} #{post.author.username}" if post.author.present? %>.
- <% if (categories = post.categories).any? %>
+ <% if (categories = post.categories.translated).any? %>
<aside class='filed_in'>
<%= t('filed_in', :scope => 'refinery.blog.posts.show') %>
<%=raw categories.collect { |category| link_to category.title, refinery.blog_category_path(category) }.to_sentence %>