common-content 0.0.2 → 0.0.3
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/app/controllers/contents_controller.rb +1 -1
- data/app/helpers/contents_helper.rb +6 -1
- data/app/models/content.rb +20 -2
- data/app/views/contents/edit.html.erb +1 -1
- data/app/views/layouts/{application.html.erb → contents.html.erb} +0 -0
- data/lib/common-content/engine.rb +0 -1
- data/lib/common-content/version.rb +1 -1
- metadata +2 -4
- data/app/models/resource.rb +0 -10
- data/app/models/seo.rb +0 -11
@@ -17,7 +17,7 @@ class ContentsController < ApplicationController
|
|
17
17
|
|
18
18
|
def edit
|
19
19
|
@content = Content.find_by_ancestry(params[:ancestors].try(:split,'/'), params[:id])
|
20
|
-
@content.build_seo unless @content.seo
|
20
|
+
# @content.build_seo unless @content.seo
|
21
21
|
# @content.child_contents.create(slug:"#{@content.slug}-kid-#{@content.child_contents.count}", title:"#{@content.slug} Kid") if @content.child_contents.size == 0
|
22
22
|
respond_with @content
|
23
23
|
end
|
@@ -17,7 +17,12 @@ module ContentsHelper
|
|
17
17
|
# end
|
18
18
|
|
19
19
|
def link_to_add_fields(name, f, association)
|
20
|
-
|
20
|
+
begin
|
21
|
+
new_object = f.object.send(association).klass.new
|
22
|
+
rescue Exception => e
|
23
|
+
p e
|
24
|
+
end
|
25
|
+
new_object ||= ::Content.const_get(association.to_s.camelize).new
|
21
26
|
id = new_object.object_id
|
22
27
|
fields = f.fields_for(association, new_object, child_index: id) do |builder|
|
23
28
|
render(partial: association.to_s.singularize + "_fields", locals: { f: builder })
|
data/app/models/content.rb
CHANGED
@@ -11,10 +11,10 @@ class Content
|
|
11
11
|
|
12
12
|
field :body, type: Textile # optional html block of text for this content
|
13
13
|
|
14
|
-
embeds_one :seo # optional SEO fields
|
14
|
+
embeds_one :seo, class_name: 'Content::Seo' # optional SEO fields
|
15
15
|
accepts_nested_attributes_for :seo # mongoid BUG see http://stackoverflow.com/questions/9392315/mongoid-and-nested-form-for-embeds-one-document
|
16
16
|
|
17
|
-
embeds_many :resources # optional 1-n resources like images, videos, REST urls, etc
|
17
|
+
embeds_many :resources, class_name: 'Content::Resource' # optional 1-n resources like images, videos, REST urls, etc
|
18
18
|
accepts_nested_attributes_for :resources # mongoid BUG see http://stackoverflow.com/questions/9392315/mongoid-and-nested-form-for-embeds-one-document
|
19
19
|
|
20
20
|
recursively_embeds_many # optionaal 1-n embedded child Content objects, the editable field controls if user can change
|
@@ -46,4 +46,22 @@ class Content
|
|
46
46
|
parent_content ? parent_content.to_param + '/' + id : id
|
47
47
|
end
|
48
48
|
|
49
|
+
class Resource
|
50
|
+
include Mongoid::Document
|
51
|
+
embedded_in :content
|
52
|
+
|
53
|
+
field :slug, type: String
|
54
|
+
field :uri, type: String # the URI of the entity we're linking to
|
55
|
+
field :content_type, type: String # mime type if there is one
|
56
|
+
end
|
57
|
+
|
58
|
+
class Seo
|
59
|
+
include Mongoid::Document
|
60
|
+
embedded_in :content
|
61
|
+
|
62
|
+
field :description, type: String
|
63
|
+
field :keywords, type: String
|
64
|
+
field :metatitle, type: String
|
65
|
+
# validates :description, :keywords, :metatitle, presence: true
|
66
|
+
end
|
49
67
|
end
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<%= render :partial => 'fields_new', :locals => {f: f} %>
|
18
18
|
<%= render :partial => 'fields_edit', :locals => {f: f} %>
|
19
19
|
<hr/>
|
20
|
-
|
20
|
+
<%= link_to_add_fields "+ seo", f, :seo unless @content.seo %>
|
21
21
|
<%= f.fields_for :seo do |seo| %>
|
22
22
|
<%= render :partial => 'seo_fields', :locals => {f: seo} %>
|
23
23
|
<% end %>
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: common-content
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -126,8 +126,6 @@ files:
|
|
126
126
|
- app/controllers/contents_controller.rb
|
127
127
|
- app/helpers/contents_helper.rb
|
128
128
|
- app/models/content.rb
|
129
|
-
- app/models/resource.rb
|
130
|
-
- app/models/seo.rb
|
131
129
|
- app/models/textile.rb
|
132
130
|
- app/views/contents/_array_form.html.erb
|
133
131
|
- app/views/contents/_child_content_fields.html.erb
|
@@ -144,7 +142,7 @@ files:
|
|
144
142
|
- app/views/contents/new.html.erb
|
145
143
|
- app/views/contents/show.html.erb
|
146
144
|
- app/views/contents/show.xml.builder
|
147
|
-
- app/views/layouts/
|
145
|
+
- app/views/layouts/contents.html.erb
|
148
146
|
- config/routes.rb
|
149
147
|
- lib/common-content/engine.rb
|
150
148
|
- lib/common-content/version.rb
|
data/app/models/resource.rb
DELETED
data/app/models/seo.rb
DELETED