fullstack-cms 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -0,0 +1,18 @@
1
+ module Localized
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ field :locale
6
+ index :locale
7
+
8
+ scope :localized, lambda {| l = "#{ I18n.locale or Fullstack::Cms.config.default_locale }" |
9
+ where(:locale => l)
10
+ }
11
+
12
+ before_save do |record|
13
+ locale ||= Fullstack::Cms.config.default_locale
14
+ end
15
+
16
+ end
17
+
18
+ end
@@ -2,6 +2,13 @@ class Page < ActiveRecord::Base
2
2
  include Content
3
3
  include Nestable
4
4
 
5
+ if Fullstack::Cms.config.localize_pages
6
+
7
+ include Localized
8
+ index [:uid, :locale]
9
+
10
+ end
11
+
5
12
  validates_presence_of :uid, :name
6
13
 
7
14
  field :name
@@ -68,10 +68,19 @@ module Pageable
68
68
 
69
69
  if Page.table_exists?
70
70
 
71
- page = Page.find_or_create_by_uid(uid, :title => title, :name => name)
71
+ page = unless Fullstack::Cms.config.localize_pages
72
+ Page.find_or_create_by_uid(uid, :title => title, :name => name)
73
+ else
74
+ Page.find_or_create_by_uid_and_locale(uid, I18n.locale || Fullstack::Cms.config.default_locale, :title => title, :name => name)
75
+ end
76
+
72
77
  if parent_uid
73
- parent = Page.find_by_uid(parent_uid)
74
- #raise [parent_uid.to_s, parent].inspect
78
+ parent = unless Fullstack::Cms.config.localize_pages
79
+ Page.find_by_uid(parent_uid)
80
+ else
81
+ Page.find_by_uid_and_locale(parent_uid, I18n.locale || Fullstack::Cms.config.default_locale)
82
+ end
83
+
75
84
  page.move_to_child_of(parent) unless page.parent == parent
76
85
  end
77
86
 
@@ -1,5 +1,5 @@
1
1
  <ul class="nav">
2
- <% Page.roots.each do |root| %>
2
+ <% Page.roots.each do |root| %>
3
3
  <% Page.each_with_level(root.self_and_descendants) do |page, level| %>
4
4
  <%= nav_item page.name, edit_admin_page_path(page), :icon => (page.root? ? "home" : "file"), :style => "line-height: 36px; padding-left:#{20 * level}px" %>
5
5
  <% end %>
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fullstack-cms"
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mcasimir"]
12
- s.date = "2012-08-31"
12
+ s.date = "2012-09-01"
13
13
  s.description = "CMS system built on fullstack"
14
14
  s.email = "maurizio.cas@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -39,6 +39,7 @@ Gem::Specification.new do |s|
39
39
  "app/models/attachment.rb",
40
40
  "app/models/link.rb",
41
41
  "app/models/linkable.rb",
42
+ "app/models/localized.rb",
42
43
  "app/models/menu.rb",
43
44
  "app/models/nestable.rb",
44
45
  "app/models/page.rb",
@@ -7,6 +7,8 @@ module Fullstack
7
7
  @config ||= OpenStruct.new
8
8
  @config.resources ||= []
9
9
  @config.linkables ||= []
10
+ @config.localize_pages = @config.localize_pages.nil? ? true : @config.localize_pages
11
+ @config.default_locale ||= "#{I18n.default_locale}" || "en"
10
12
  @config
11
13
  end
12
14
  module_function :config
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fullstack-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-31 00:00:00.000000000 Z
12
+ date: 2012-09-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fullstack-admin
@@ -233,6 +233,7 @@ files:
233
233
  - app/models/attachment.rb
234
234
  - app/models/link.rb
235
235
  - app/models/linkable.rb
236
+ - app/models/localized.rb
236
237
  - app/models/menu.rb
237
238
  - app/models/nestable.rb
238
239
  - app/models/page.rb
@@ -328,7 +329,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
328
329
  version: '0'
329
330
  segments:
330
331
  - 0
331
- hash: 3828187816881413206
332
+ hash: -3826717670645353415
332
333
  required_rubygems_version: !ruby/object:Gem::Requirement
333
334
  none: false
334
335
  requirements: