seiten 0.0.4 → 0.0.5
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 -0
- data/app/helpers/seiten_helper.rb +2 -1
- data/config/routes.rb +1 -1
- data/lib/seiten/page.rb +2 -1
- data/lib/seiten/page_store.rb +40 -12
- data/lib/seiten/version.rb +1 -1
- data/test/dummy/app/views/layouts/application.html.erb +2 -0
- data/test/dummy/app/views/layouts/home.html.erb +22 -0
- data/test/dummy/app/views/layouts/products.html.erb +22 -0
- data/test/dummy/app/views/layouts/team.html.erb +22 -0
- data/test/dummy/config/navigation.yml +8 -1
- data/test/dummy/log/development.log +1012 -0
- data/test/dummy/log/test.log +2805 -0
- data/test/dummy/tmp/pids/server.pid +1 -1
- data/test/integration/layout_test.rb +26 -0
- data/test/integration/navigation_test.rb +0 -11
- data/test/integration/redirect_test.rb +15 -0
- data/test/page_test.rb +4 -0
- metadata +17 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0ff873128338069249737ba993b223217dd98a8
|
4
|
+
data.tar.gz: 940a0ebd9ce9c3edce4902f88936b3f6e2a9fb65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d776bf9d134f8d295b97f570e6429fd92e76f8e3d8bc550f9998c9ef69a3b93464a17120db62a2edc6ca2439eea8cb662ab96408f7f76d6456877dcbe6589b64
|
7
|
+
data.tar.gz: 2ab6292b960d3fae73d9cff0e1344a997b6312c35a61af06ae261cb2197fc7a5486de44d2d21d7701b04ef5211fc5a7f11bd466d2f0b78e71276a246000f2472
|
data/config/routes.rb
CHANGED
data/lib/seiten/page.rb
CHANGED
@@ -2,7 +2,7 @@ module Seiten
|
|
2
2
|
|
3
3
|
class Page
|
4
4
|
|
5
|
-
attr_accessor :id, :parent_id, :title, :children, :slug, :redirect
|
5
|
+
attr_accessor :id, :parent_id, :title, :children, :slug, :redirect, :layout
|
6
6
|
|
7
7
|
# initialize Page object with attributes
|
8
8
|
def initialize(options={})
|
@@ -11,6 +11,7 @@ module Seiten
|
|
11
11
|
@title = options[:title]
|
12
12
|
@slug = options[:slug]
|
13
13
|
@redirect = options[:redirect]
|
14
|
+
@layout = options[:layout]
|
14
15
|
end
|
15
16
|
|
16
17
|
def self.all
|
data/lib/seiten/page_store.rb
CHANGED
@@ -12,41 +12,69 @@ module Seiten
|
|
12
12
|
@storage_file ||= File.join(Rails.root, Seiten.config[:storage_file])
|
13
13
|
end
|
14
14
|
|
15
|
+
def build_link(page, prefix_url="")
|
16
|
+
slug = page["url"].nil? ? page["title"].parameterize : page["url"]
|
17
|
+
unless slug[0] == "/" || !!(slug.match(/^https?:\/\/.+/))
|
18
|
+
slug = "#{prefix_url}/#{slug}"
|
19
|
+
end
|
20
|
+
slug
|
21
|
+
end
|
22
|
+
|
15
23
|
def load_pages(options={})
|
16
24
|
|
17
|
-
pages
|
18
|
-
parent_id
|
19
|
-
|
25
|
+
pages = options[:pages]
|
26
|
+
parent_id = options[:parent_id] # || nil
|
27
|
+
layout = options[:layout]
|
28
|
+
prefix_url = options[:prefix_url] || ""
|
20
29
|
|
21
30
|
# Setting default values
|
22
31
|
if storage_type == :yaml
|
23
32
|
pages ||= YAML.load_file(storage_file)
|
24
33
|
end
|
25
|
-
|
26
|
-
url ||= ""
|
34
|
+
|
27
35
|
@id ||= 1
|
28
36
|
@navigation ||= []
|
29
37
|
|
30
38
|
pages.each_index do |i|
|
31
39
|
|
40
|
+
# Load page and set parent_id and generated page id
|
32
41
|
page = pages[i]
|
33
42
|
page["id"] = @id
|
34
43
|
page["parent_id"] = parent_id
|
44
|
+
page["layout"] ||= layout
|
45
|
+
|
46
|
+
# Increment generated id
|
35
47
|
@id += 1
|
36
48
|
|
37
49
|
# Build link
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
page["
|
50
|
+
page["slug"] = build_link(page, prefix_url)
|
51
|
+
|
52
|
+
# Set layout
|
53
|
+
if page["layout"]
|
54
|
+
if page["layout"].is_a?(String)
|
55
|
+
inherited_layout = page["layout"]
|
56
|
+
elsif page["layout"].is_a?(Hash)
|
57
|
+
if page["layout"]["inherit"]
|
58
|
+
inherited_layout = page["layout"]
|
59
|
+
else
|
60
|
+
inherited_layout = nil
|
61
|
+
end
|
62
|
+
page["layout"] = page["layout"]["name"]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Set redirect
|
67
|
+
if page["redirect"]
|
68
|
+
if page["redirect"].is_a?(TrueClass)
|
69
|
+
page["redirect"] = build_link(page["nodes"].first, page["slug"])
|
70
|
+
end
|
43
71
|
end
|
44
72
|
|
73
|
+
# Load children
|
45
74
|
if page["nodes"]
|
46
|
-
load_pages(pages: page["nodes"], parent_id: page["id"],
|
75
|
+
load_pages(pages: page["nodes"], parent_id: page["id"], prefix_url: page["slug"], layout: inherited_layout)
|
47
76
|
end
|
48
77
|
|
49
|
-
page.delete("nodes")
|
50
78
|
page_params = page.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
51
79
|
@navigation << Page.new(page_params)
|
52
80
|
end
|
data/lib/seiten/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", :media => "all" %>
|
6
|
+
<%# <%= javascript_include_tag "application" %1> %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<p>Home Layout</p>
|
12
|
+
|
13
|
+
<h1>Navigation</h1>
|
14
|
+
<%= seiten_navigation %>
|
15
|
+
|
16
|
+
<h1>Breadcrumb</h1>
|
17
|
+
<%= seiten_breadcrumb %>
|
18
|
+
|
19
|
+
<%= yield %>
|
20
|
+
|
21
|
+
</body>
|
22
|
+
</html>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", :media => "all" %>
|
6
|
+
<%# <%= javascript_include_tag "application" %1> %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<p>Products Layout</p>
|
12
|
+
|
13
|
+
<h1>Navigation</h1>
|
14
|
+
<%= seiten_navigation %>
|
15
|
+
|
16
|
+
<h1>Breadcrumb</h1>
|
17
|
+
<%= seiten_breadcrumb %>
|
18
|
+
|
19
|
+
<%= yield %>
|
20
|
+
|
21
|
+
</body>
|
22
|
+
</html>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", :media => "all" %>
|
6
|
+
<%# <%= javascript_include_tag "application" %1> %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<p>Team Layout</p>
|
12
|
+
|
13
|
+
<h1>Navigation</h1>
|
14
|
+
<%= seiten_navigation %>
|
15
|
+
|
16
|
+
<h1>Breadcrumb</h1>
|
17
|
+
<%= seiten_breadcrumb %>
|
18
|
+
|
19
|
+
<%= yield %>
|
20
|
+
|
21
|
+
</body>
|
22
|
+
</html>
|
@@ -1,17 +1,24 @@
|
|
1
1
|
- title: "Home"
|
2
2
|
url: "/"
|
3
|
+
layout: "home"
|
3
4
|
|
4
5
|
- title: "Products"
|
6
|
+
layout:
|
7
|
+
name: "products"
|
8
|
+
inherit: true
|
5
9
|
nodes:
|
6
10
|
- title: "Logo Design"
|
7
11
|
- title: "Web Development"
|
8
12
|
- title: "Hire us"
|
9
|
-
|
13
|
+
redirect: "/contact" # links to Contact page
|
10
14
|
|
11
15
|
- title: "About"
|
12
16
|
redirect: true # redirects /about to /about/our-team
|
13
17
|
nodes:
|
14
18
|
- title: "Our Team"
|
19
|
+
layout:
|
20
|
+
name: "team"
|
21
|
+
inherit: false
|
15
22
|
nodes:
|
16
23
|
- title: "Switzerland"
|
17
24
|
- title: "Italy"
|