refinerycms-llama_widgets 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/decorators/models/refinery/page.rb +29 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6aa6edc07aaa952c90434403d2acdbfde43e7ec0
|
4
|
+
data.tar.gz: 85a5d013493d7e7cb13dbdf99fc42d6223bbb3db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a23f6f37aa21e1d72b7b3fd96b8f09aa14f53d98a4f74e589c2b994ab13fdbcb4102479de7cc548d6f3b711cab53f68f9fd9176195d8b04251184853a3e2dceb
|
7
|
+
data.tar.gz: b3373f1061b6a39ff9ba42b0ef172970d815642c2e816c81dc16ed0b304c267941d5b2143c3c625640df8bf53086cb0d56e3d5b6bdbda0710ba9164e438843c9
|
@@ -23,6 +23,35 @@ Refinery::Page.class_eval do
|
|
23
23
|
(::Refinery::Pages.default_parts.collect{|dp| parts.find{|p| p.title == dp } } + parts).uniq
|
24
24
|
end
|
25
25
|
|
26
|
+
def self.find_or_create_by_link_url!(link_url, options={})
|
27
|
+
page = self.find_by_link_url(link_url)
|
28
|
+
if page
|
29
|
+
return page
|
30
|
+
else
|
31
|
+
page = self.new(
|
32
|
+
title: link_url.gsub(/\W/, ' ').strip.capitalize,
|
33
|
+
link_url: link_url,
|
34
|
+
deletable: false,
|
35
|
+
menu_match: "^#{link_url}(\/|\/.+?|)$",
|
36
|
+
show_in_menu: false
|
37
|
+
)
|
38
|
+
if options[:parent].present?
|
39
|
+
parent = self.find_by_link_url(options[:parent])
|
40
|
+
if parent.nil?
|
41
|
+
parent = self.find_or_create_by_link_url(options[:parent])
|
42
|
+
end
|
43
|
+
page.parent_id = parent.id
|
44
|
+
end
|
45
|
+
page.save!
|
46
|
+
Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
|
47
|
+
page.parts.create(:title => default_page_part, :body => nil, :position => index)
|
48
|
+
end
|
49
|
+
page.template_id = ::Refinery::Widgets::Template.first.id
|
50
|
+
page.save!
|
51
|
+
page
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
26
55
|
private
|
27
56
|
|
28
57
|
def validate_widgets
|