seiten 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/seiten/pages_controller.rb +1 -5
- data/lib/seiten/page.rb +20 -0
- data/lib/seiten/page_store.rb +25 -15
- data/lib/seiten/routes_helper.rb +1 -1
- data/lib/seiten/version.rb +1 -1
- data/lib/seiten.rb +1 -0
- data/test/dummy/log/development.log +2672 -6850
- data/test/dummy/log/test.log +7161 -6927
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/pids/server.pid +1 -1
- data/test/integration/i18n_test.rb +2 -8
- data/test/page_store_test.rb +28 -0
- data/test/page_test.rb +24 -0
- data/test/seiten_test.rb +4 -2
- metadata +26 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aac1c7e2cff18662cca1155e49a8f43b13df73f7
|
4
|
+
data.tar.gz: c6e449e0518a93591b26832d3c3dfa94aacef1c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 117b93f29193643c09bdaff2e2b663c9e636907c6e18ec6f300302fbe51bfca58ac69d0f14ca05a73b0bfdf759368e14973da4a24426367887e1b0b887bd2903
|
7
|
+
data.tar.gz: dee87d889d81b4d9698dd14c1e2453f1a1a4c5dcda62798d9f8b7c3841d8e4876ab5ee8c075b222058f4ace35ef0d31b8a25148c5da4fb1154dcd0bc33c1b20f
|
@@ -13,11 +13,7 @@ module Seiten
|
|
13
13
|
filename = Seiten.config[:root_page_filename]
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
file = Seiten::PageStore.current.file_path(filename: filename, locale: I18n.locale)
|
18
|
-
else
|
19
|
-
file = Seiten::PageStore.current.file_path(filename: filename)
|
20
|
-
end
|
16
|
+
file = Seiten::PageStore.current.file_path(filename: filename)
|
21
17
|
|
22
18
|
if current_page.layout
|
23
19
|
render file: file, layout: current_page.layout
|
data/lib/seiten/page.rb
CHANGED
@@ -10,6 +10,7 @@ module Seiten
|
|
10
10
|
@parent_id = options[:parent_id]
|
11
11
|
@title = options[:title]
|
12
12
|
@slug = options[:slug]
|
13
|
+
@external = options[:external]
|
13
14
|
@redirect = options[:redirect]
|
14
15
|
@layout = options[:layout]
|
15
16
|
end
|
@@ -50,11 +51,30 @@ module Seiten
|
|
50
51
|
|
51
52
|
end
|
52
53
|
|
54
|
+
# returns true if slug starts with http:// or https://
|
55
|
+
def external?
|
56
|
+
!!(slug.match(/^https?:\/\/.+/))
|
57
|
+
end
|
58
|
+
|
53
59
|
# get parent of page
|
54
60
|
def parent
|
55
61
|
Page.find(parent_id)
|
56
62
|
end
|
57
63
|
|
64
|
+
def parent?
|
65
|
+
parent.present?
|
66
|
+
end
|
67
|
+
|
68
|
+
# TODO: Find a better name for this
|
69
|
+
# get root page of current page branch
|
70
|
+
def branch_root
|
71
|
+
if self.parent?
|
72
|
+
self.parent.branch_root
|
73
|
+
else
|
74
|
+
self
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
58
78
|
# get children of page
|
59
79
|
def children
|
60
80
|
Page.all.select { |page| page.parent_id == id }
|
data/lib/seiten/page_store.rb
CHANGED
@@ -13,15 +13,6 @@ module Seiten
|
|
13
13
|
@pages = load_pages
|
14
14
|
end
|
15
15
|
|
16
|
-
# def self.new(options={})
|
17
|
-
# page_store = super(options)
|
18
|
-
# self.storages << page_store
|
19
|
-
# # page_store_key = options[:page_store_key] || options[:storage_languagea
|
20
|
-
# # options.delete :page_store_key if options[:page_store_key]
|
21
|
-
# # new_page_store = super(options)
|
22
|
-
# # Seiten.page_store[page_store_key] = new_page_store
|
23
|
-
# end
|
24
|
-
|
25
16
|
@storages = []
|
26
17
|
|
27
18
|
class << self
|
@@ -30,20 +21,39 @@ module Seiten
|
|
30
21
|
@storages
|
31
22
|
end
|
32
23
|
|
33
|
-
def
|
34
|
-
storages
|
24
|
+
def storages=(storages)
|
25
|
+
@storages = storages
|
26
|
+
end
|
27
|
+
|
28
|
+
def current
|
29
|
+
Seiten.config[:current_page_store]
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_current_page_store(options={})
|
33
|
+
Seiten.config[:current_page_store] = find_by(options) if options
|
34
|
+
end
|
35
|
+
|
36
|
+
def find_by(options={})
|
37
|
+
tmp_storages = storages
|
38
|
+
options.each do |option|
|
39
|
+
tmp_storages = tmp_storages.select { |storage| storage.send(option[0]) == option[1] }
|
40
|
+
end
|
41
|
+
tmp_storages.first
|
35
42
|
end
|
36
|
-
alias_method :current, :find_by_locale
|
37
43
|
|
38
44
|
def initialize_page_stores
|
45
|
+
# Check if config/navigation exists?
|
46
|
+
# If true: Initialize localized navigation page stores with locale language and directory
|
47
|
+
# If false: Initialize the default storage file
|
39
48
|
if File.directory?(File.join(Rails.root, Seiten.config[:default_storage_file]))
|
40
49
|
Dir[File.join(Rails.root, Seiten.config[:default_storage_file], "*.yml")].each do |file|
|
41
50
|
locale = File.basename(file, '.yml')
|
42
|
-
Seiten::PageStore.storages << Seiten::PageStore.new(storage_language: locale)
|
51
|
+
Seiten::PageStore.storages << Seiten::PageStore.new(storage_language: locale, storage_directory: File.join(Rails.root, "app", "pages", locale))
|
43
52
|
end
|
44
53
|
else
|
45
54
|
Seiten::PageStore.storages << Seiten::PageStore.new(storage_language: I18n.default_locale)
|
46
55
|
end
|
56
|
+
set_current_page_store(storage_language: I18n.default_locale)
|
47
57
|
end
|
48
58
|
|
49
59
|
end
|
@@ -57,7 +67,7 @@ module Seiten
|
|
57
67
|
end
|
58
68
|
|
59
69
|
def file_path(options={})
|
60
|
-
File.join(storage_directory, options[:
|
70
|
+
File.join(storage_directory, options[:filename])
|
61
71
|
end
|
62
72
|
|
63
73
|
def build_link(page, prefix_url="")
|
@@ -137,7 +147,7 @@ module Seiten
|
|
137
147
|
|
138
148
|
# Load children
|
139
149
|
if page["nodes"]
|
140
|
-
load_pages(pages: page["nodes"], parent_id: page["id"], prefix_url: page["slug"], layout: inherited_layout)
|
150
|
+
load_pages(pages: page["nodes"], parent_id: page["id"], prefix_url: page["slug"], layout: inherited_layout, external: page["external"])
|
141
151
|
end
|
142
152
|
|
143
153
|
page_params = page.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
data/lib/seiten/routes_helper.rb
CHANGED
data/lib/seiten/version.rb
CHANGED