diff --git a/app/assets/stylesheets/base.css b/app/assets/stylesheets/base.css index 586dfc89f..bc4028201 100644 --- a/app/assets/stylesheets/base.css +++ b/app/assets/stylesheets/base.css @@ -456,6 +456,15 @@ ul.dropdown-menu li a.strong { font-weight: bolder; } +.badge-light { + background-color: #eee; +} + +.locale-badges { + padding-right: 20px; + padding-top: 10px; +} + /* === LAYOUT === */ #breadcrumbs { diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 4f02fdc1a..c0e7a9030 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -41,4 +41,19 @@ def i18n_reply select.html_safe end + def i18n_icons(object) + output = '
' + output.html_safe + end + end diff --git a/app/models/category.rb b/app/models/category.rb index 83aa59d14..bd246e1b3 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -31,11 +31,17 @@ class Category < ActiveRecord::Base scope :ranked, -> { order('rank ASC') } scope :featured, -> {where(front_page: true) } + validates_presence_of :name + validates_uniqueness_of :name + + def to_param "#{id}-#{name.gsub(/[^a-z0-9]+/i, '-')}" unless name.nil? end - validates_presence_of :name - validates_uniqueness_of :name + def read_translated_attribute(name) + globalize.stash.contains?(Globalize.locale, name) ? globalize.stash.read(Globalize.locale, name) : translation_for(Globalize.locale).send(name) + end + end diff --git a/app/models/doc.rb b/app/models/doc.rb index 3d00f36a1..a42b9b480 100644 --- a/app/models/doc.rb +++ b/app/models/doc.rb @@ -56,6 +56,10 @@ def to_param "#{id}-#{title.gsub(/[^a-z0-9]+/i, '-')}" end + def read_translated_attribute(name) + globalize.stash.contains?(Globalize.locale, name) ? globalize.stash.read(Globalize.locale, name) : translation_for(Globalize.locale).send(name) + end + def content c = RDiscount.new(self.body) return c.to_html diff --git a/app/views/admin/_cat.html.erb b/app/views/admin/_cat.html.erb index e986860b5..a598af628 100644 --- a/app/views/admin/_cat.html.erb +++ b/app/views/admin/_cat.html.erb @@ -3,7 +3,7 @@ <%= link_to cat.name, admin_articles_path(cat.id) %> <%= cat.docs.count %> - + <%= i18n_icons(cat) if I18n.available_locales.count > 1 %>
<%= link_to doc.title, edit_category_doc_path(doc.category.id, doc.id, lang: I18n.locale) %> <%= " - #{I18n.t('featured_content', default: 'Featured')}" if doc.front_page == true %> <%= " - #{I18n.t('draft_content', default: 'Draft')}" if doc.active == false %>
+ <%= i18n_icons(doc) if I18n.available_locales.count > 1 %>
<%= I18n.t('written_on', date_written: doc.created_at.strftime("%m/%d/%Y"), default: 'Written on') %> <%= doc.updated_at == doc.created_at ? "" : " | #{I18n.t("content_last_updated", date_updated: doc.updated_at.strftime("%m/%d/%Y"))}" %> |
diff --git a/app/views/categories/_form.html.erb b/app/views/categories/_form.html.erb
index c81db3ef0..6663c869f 100644
--- a/app/views/categories/_form.html.erb
+++ b/app/views/categories/_form.html.erb
@@ -1,9 +1,9 @@
- <%= f.text_field :name, :label => I18n.translate("activerecord.attributes.category.name", locale: I18n.locale) %>
+ <%= f.text_field :name, label: I18n.translate("activerecord.attributes.category.name", locale: I18n.locale), value: @category.read_translated_attribute(:name) %>
<%= f.text_field :icon, class: 'icon-picker no-translate', placeholder: t(:select_icon_helptext, default: 'Select an icon to associate with this category (optional)'), :label => I18n.translate("activerecord.attributes.category.icon", locale: I18n.locale) %>
<%#= f.text_field :section %>
- <%= f.text_field :keywords, :label => I18n.translate("activerecord.attributes.category.keywords", locale: I18n.locale) %>
- <%= f.text_field :title_tag, :label => I18n.translate("activerecord.attributes.category.title_tag", locale: I18n.locale) %>
- <%= f.text_field :meta_description, :label => I18n.translate("activerecord.attributes.category.meta_description", locale: I18n.locale) %>
+ <%= f.text_field :keywords, label: I18n.translate("activerecord.attributes.category.keywords", locale: I18n.locale), value: @category.read_translated_attribute(:keywords) %>
+ <%= f.text_field :title_tag, label: I18n.translate("activerecord.attributes.category.title_tag", locale: I18n.locale), value: @category.read_translated_attribute(:title_tag) %>
+ <%= f.text_field :meta_description, label: I18n.translate("activerecord.attributes.category.meta_description", locale: I18n.locale), value: @category.read_translated_attribute(:meta_description) %>
<% if params[:lang] == "#{I18n.locale}" %>
<%= f.check_box :front_page, class: 'no-translate', :label => I18n.translate("activerecord.attributes.category.front_page", locale: I18n.locale) %>
<%= f.check_box :active, class: 'no-translate', :label => I18n.translate("activerecord.attributes.category.active", locale: I18n.locale) %>
diff --git a/app/views/docs/_form.html.erb b/app/views/docs/_form.html.erb
index 9d0327154..da0538cb8 100644
--- a/app/views/docs/_form.html.erb
+++ b/app/views/docs/_form.html.erb
@@ -1,4 +1,4 @@
- <%= f.text_field :title, :label => I18n.translate("activerecord.attributes.doc.title", locale: I18n.locale) %>
+ <%= f.text_field :title, label: I18n.translate("activerecord.attributes.doc.title", locale: I18n.locale), value: @doc.read_translated_attribute(:title) %>
<% if params[:lang] == "#{I18n.locale}" %>
<%= f.select("category_id", Category.all.collect {|c| [ c.name, c.id ] }, { include_blank: t(:select_category, default: 'Select Category'), :label => I18n.translate("activerecord.attributes.doc.category_id", locale: I18n.locale) }, { class: 'no-translate' }) %>
<% else %>
@@ -6,21 +6,25 @@
<% end %>
<%#= render 'admin/quill_editor' #uncomment this line if you prefer to use the quill editor %>
<%#= f.hidden_field :body #uncomment this line if you prefer to use the quill editor %>
- <%= f.trix_editor :body %>
+ <%= f.trix_editor :body, value: @doc.read_translated_attribute(:body) %>
+ <% unless params[:lang] == "#{I18n.locale}" || @doc.translations.where(locale: locale).count > 0 %>
+
+ <% end %>