sethyates-content_manager 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +253 -1
- data/VERSION +1 -1
- data/content_manager.gemspec +38 -2
- data/doc/created.rid +1 -0
- data/doc/files/README_rdoc.html +487 -0
- data/doc/fr_class_index.html +26 -0
- data/doc/fr_file_index.html +27 -0
- data/doc/fr_method_index.html +26 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/generators/component_scaffold/USAGE +28 -0
- data/generators/component_scaffold/component_scaffold_generator.rb +84 -0
- data/generators/component_scaffold/templates/controller.rb +85 -0
- data/generators/component_scaffold/templates/model.rb +5 -0
- data/generators/component_scaffold/templates/style.css +1 -0
- data/generators/component_scaffold/templates/view_edit.html.erb +13 -0
- data/generators/component_scaffold/templates/view_index.html.erb +22 -0
- data/generators/component_scaffold/templates/view_new.html.erb +12 -0
- data/generators/component_scaffold/templates/view_show.html.erb +3 -0
- data/generators/content_scaffold/USAGE +28 -0
- data/generators/content_scaffold/content_scaffold_generator.rb +83 -0
- data/generators/content_scaffold/templates/controller.rb +85 -0
- data/generators/content_scaffold/templates/model.rb +8 -0
- data/generators/content_scaffold/templates/view_edit.html.erb +13 -0
- data/generators/content_scaffold/templates/view_index.html.erb +22 -0
- data/generators/content_scaffold/templates/view_new.html.erb +12 -0
- data/generators/content_scaffold/templates/view_show.html.erb +8 -0
- data/lib/component.rb +28 -0
- data/lib/content/adapters/base.rb +79 -0
- data/lib/content/adapters/cabinet_adapter.rb +62 -0
- data/lib/content/adapters/tyrant_adapter.rb +73 -0
- data/lib/content/item.rb +178 -0
- data/lib/content/item_association_class_methods.rb +148 -0
- data/lib/content/item_class_methods.rb +71 -0
- data/lib/content/item_dirty_methods.rb +171 -0
- data/lib/content/item_finder_class_methods.rb +203 -0
- data/lib/content/manager.rb +105 -0
- data/lib/content/sublayout.rb +44 -0
- data/lib/content/template.rb +24 -0
- metadata +38 -2
@@ -0,0 +1,44 @@
|
|
1
|
+
module Content
|
2
|
+
class Sublayout
|
3
|
+
attr_accessor :id, :path, :name, :containers
|
4
|
+
|
5
|
+
def self.all
|
6
|
+
index = 0
|
7
|
+
@sublayouts ||= Dir.glob("app/views/sublayouts/**/*.erb").collect {|path|
|
8
|
+
path = path.gsub("app/views/sublayouts/", "")
|
9
|
+
path unless path.match '/_' or path == "application.html.erb"
|
10
|
+
}.compact.collect {|path|
|
11
|
+
Sublayout.new(path)
|
12
|
+
}.collect {|sublayout|
|
13
|
+
if sublayout.containers.length > 0
|
14
|
+
sublayout.id = index = index + 1
|
15
|
+
sublayout
|
16
|
+
end
|
17
|
+
}.compact
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.find(index)
|
21
|
+
all[index.to_i - 1]
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.find_by_path(path)
|
25
|
+
all.reject {|item| item.path != path }.first
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(path)
|
29
|
+
@path = path
|
30
|
+
@name = @path.gsub('.html.erb', '').gsub('/', ' > ').humanize.titleize
|
31
|
+
@containers = returning [] do |tainers|
|
32
|
+
File.open("app/views/sublayouts/#{@path}", File::RDONLY) do |fd|
|
33
|
+
fd.each do |line|
|
34
|
+
tainers << ($2 || "contents").to_sym if line =~ /yield[ \t]*(\(?[ \t]*:([a-z]+)[ \t]*\)?)?%/i
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_param
|
41
|
+
id.to_s
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Content
|
2
|
+
class Template < Content::Item
|
3
|
+
field :components
|
4
|
+
field :sublayout
|
5
|
+
field :contents, :array
|
6
|
+
validates_length_of :heading, :minimum => 5
|
7
|
+
validates_presence_of :sublayout
|
8
|
+
|
9
|
+
def template
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_container(name, contents)
|
14
|
+
instance_variable_set "@#{name}_obj".to_sym, ActiveSupport::JSON.encode(contents)
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_container(name)
|
18
|
+
ivar = "@#{name}_obj".to_sym
|
19
|
+
obj = instance_variable_get(ivar) or returning ActiveSupport::JSON.decode(self[name]) do
|
20
|
+
instance_variable_set ivar, obj
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sethyates-content_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Yates
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-30 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -49,7 +49,43 @@ files:
|
|
49
49
|
- Rakefile
|
50
50
|
- VERSION
|
51
51
|
- content_manager.gemspec
|
52
|
+
- doc/created.rid
|
53
|
+
- doc/files/README_rdoc.html
|
54
|
+
- doc/fr_class_index.html
|
55
|
+
- doc/fr_file_index.html
|
56
|
+
- doc/fr_method_index.html
|
57
|
+
- doc/index.html
|
58
|
+
- doc/rdoc-style.css
|
59
|
+
- generators/component_scaffold/USAGE
|
60
|
+
- generators/component_scaffold/component_scaffold_generator.rb
|
61
|
+
- generators/component_scaffold/templates/controller.rb
|
62
|
+
- generators/component_scaffold/templates/model.rb
|
63
|
+
- generators/component_scaffold/templates/style.css
|
64
|
+
- generators/component_scaffold/templates/view_edit.html.erb
|
65
|
+
- generators/component_scaffold/templates/view_index.html.erb
|
66
|
+
- generators/component_scaffold/templates/view_new.html.erb
|
67
|
+
- generators/component_scaffold/templates/view_show.html.erb
|
68
|
+
- generators/content_scaffold/USAGE
|
69
|
+
- generators/content_scaffold/content_scaffold_generator.rb
|
70
|
+
- generators/content_scaffold/templates/controller.rb
|
71
|
+
- generators/content_scaffold/templates/model.rb
|
72
|
+
- generators/content_scaffold/templates/view_edit.html.erb
|
73
|
+
- generators/content_scaffold/templates/view_index.html.erb
|
74
|
+
- generators/content_scaffold/templates/view_new.html.erb
|
75
|
+
- generators/content_scaffold/templates/view_show.html.erb
|
52
76
|
- init.rb
|
77
|
+
- lib/component.rb
|
78
|
+
- lib/content/adapters/base.rb
|
79
|
+
- lib/content/adapters/cabinet_adapter.rb
|
80
|
+
- lib/content/adapters/tyrant_adapter.rb
|
81
|
+
- lib/content/item.rb
|
82
|
+
- lib/content/item_association_class_methods.rb
|
83
|
+
- lib/content/item_class_methods.rb
|
84
|
+
- lib/content/item_dirty_methods.rb
|
85
|
+
- lib/content/item_finder_class_methods.rb
|
86
|
+
- lib/content/manager.rb
|
87
|
+
- lib/content/sublayout.rb
|
88
|
+
- lib/content/template.rb
|
53
89
|
- lib/content_manager.rb
|
54
90
|
- test/content_manager_test.rb
|
55
91
|
- test/test_helper.rb
|