common-content 0.0.4 → 0.0.5

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.
Files changed (34) hide show
  1. data/MIT-LICENSE +20 -20
  2. data/README.textile +55 -55
  3. data/Rakefile +29 -29
  4. data/app/assets/javascripts/application.js +15 -15
  5. data/app/assets/javascripts/contents.js.coffee +16 -16
  6. data/app/assets/javascripts/jquery-ui-1.8.21.custom.min.js +124 -124
  7. data/app/assets/stylesheets/bootstrap_and_overrides.css.less +29 -29
  8. data/app/assets/stylesheets/contents.css.less +6 -6
  9. data/app/assets/stylesheets/scaffolds.css.less +62 -62
  10. data/app/controllers/contents_controller.rb +99 -99
  11. data/app/helpers/contents_helper.rb +27 -34
  12. data/app/models/content.rb +71 -66
  13. data/app/models/textile.rb +15 -15
  14. data/app/views/contents/_array_form.html.erb +13 -13
  15. data/app/views/contents/_child_content_fields.html.erb +8 -14
  16. data/app/views/contents/_content.xml.builder +3 -3
  17. data/app/views/contents/_fields_edit.html.erb +7 -7
  18. data/app/views/contents/_fields_new.html.erb +12 -14
  19. data/app/views/contents/_navigation.html.erb +13 -0
  20. data/app/views/contents/_resource_fields.html.erb +23 -21
  21. data/app/views/contents/_seo_fields.html.erb +21 -21
  22. data/app/views/contents/_show_children.html.erb +10 -10
  23. data/app/views/contents/edit.html.erb +51 -44
  24. data/app/views/contents/index.html.erb +33 -34
  25. data/app/views/contents/index.xml.builder +4 -4
  26. data/app/views/contents/new.html.erb +13 -13
  27. data/app/views/contents/show.html.erb +25 -25
  28. data/app/views/layouts/contents.html.erb +46 -64
  29. data/config/routes.rb +9 -9
  30. data/lib/common-content.rb +4 -4
  31. data/lib/common-content/engine.rb +7 -7
  32. data/lib/common-content/version.rb +3 -3
  33. data/lib/tasks/common-content_tasks.rake +4 -4
  34. metadata +44 -73
@@ -1,29 +1,29 @@
1
- @import "twitter/bootstrap/bootstrap";
2
- body { padding-top: 60px; }
3
-
4
- @import "twitter/bootstrap/responsive";
5
-
6
- // Set the correct sprite paths
7
- @iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
8
- @iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
9
-
10
- // Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
11
- @fontAwesomeEotPath: asset-path('fontawesome-webfont.eot');
12
- @fontAwesomeWoffPath: asset-path('fontawesome-webfont.woff');
13
- @fontAwesomeTtfPath: asset-path('fontawesome-webfont.ttf');
14
- @fontAwesomeSvgzPath: asset-path('fontawesome-webfont.svgz');
15
- @fontAwesomeSvgPath: asset-path('fontawesome-webfont.svg');
16
-
17
- // Font Awesome
18
- @import "fontawesome";
19
-
20
- // Your custom LESS stylesheets goes here
21
- //
22
- // Since bootstrap was imported above you have access to its mixins which
23
- // you may use and inherit here
24
- //
25
- // If you'd like to override bootstrap's own variables, you can do so here as well
26
- // See http://twitter.github.com/bootstrap/less.html for their names and documentation
27
- //
28
- // Example:
29
- // @linkColor: #ff0000;
1
+ @import "twitter/bootstrap/bootstrap";
2
+ body { padding-top: 60px; }
3
+
4
+ @import "twitter/bootstrap/responsive";
5
+
6
+ // Set the correct sprite paths
7
+ @iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
8
+ @iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
9
+
10
+ // Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
11
+ @fontAwesomeEotPath: asset-path('fontawesome-webfont.eot');
12
+ @fontAwesomeWoffPath: asset-path('fontawesome-webfont.woff');
13
+ @fontAwesomeTtfPath: asset-path('fontawesome-webfont.ttf');
14
+ @fontAwesomeSvgzPath: asset-path('fontawesome-webfont.svgz');
15
+ @fontAwesomeSvgPath: asset-path('fontawesome-webfont.svg');
16
+
17
+ // Font Awesome
18
+ @import "fontawesome";
19
+
20
+ // Your custom LESS stylesheets goes here
21
+ //
22
+ // Since bootstrap was imported above you have access to its mixins which
23
+ // you may use and inherit here
24
+ //
25
+ // If you'd like to override bootstrap's own variables, you can do so here as well
26
+ // See http://twitter.github.com/bootstrap/less.html for their names and documentation
27
+ //
28
+ // Example:
29
+ // @linkColor: #ff0000;
@@ -1,6 +1,6 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
5
- @import "bootstrap_and_overrides.css";
6
- @import "scaffolds.css";
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
5
+ @import "bootstrap_and_overrides.css";
6
+ @import "scaffolds.css";
@@ -1,62 +1,62 @@
1
- body {
2
- background-color: #fff;
3
- color: #333;
4
- }
5
- body,
6
- p,
7
- ol,
8
- ul,
9
- td {
10
- font-family: verdana, arial, helvetica, sans-serif;
11
- font-size: 13px;
12
- line-height: 18px;
13
- }
14
- pre {
15
- background-color: #eee;
16
- padding: 10px;
17
- font-size: 11px;
18
- }
19
- a {
20
- color: #000;
21
- }
22
- a:visited {
23
- color: #666;
24
- }
25
- a:hover {
26
- color: #fff;
27
- background-color: #000;
28
- }
29
- div.field,
30
- div.actions {
31
- margin-bottom: 10px;
32
- }
33
- #notice {
34
- color: green;
35
- }
36
- .field_with_errors {
37
- padding: 2px;
38
- background-color: red;
39
- display: table;
40
- }
41
- #error_explanation {
42
- width: 450px;
43
- border: 2px solid red;
44
- padding: 7px;
45
- padding-bottom: 0;
46
- margin-bottom: 20px;
47
- background-color: #f0f0f0;
48
- }
49
- #error_explanation h2 {
50
- text-align: left;
51
- font-weight: bold;
52
- padding: 5px 5px 5px 15px;
53
- font-size: 12px;
54
- margin: -7px;
55
- margin-bottom: 0px;
56
- background-color: #c00;
57
- color: #fff;
58
- }
59
- #error_explanation ul li {
60
- font-size: 12px;
61
- list-style: square;
62
- }
1
+ body {
2
+ background-color: #fff;
3
+ color: #333;
4
+ }
5
+ body,
6
+ p,
7
+ ol,
8
+ ul,
9
+ td {
10
+ font-family: verdana, arial, helvetica, sans-serif;
11
+ font-size: 13px;
12
+ line-height: 18px;
13
+ }
14
+ pre {
15
+ background-color: #eee;
16
+ padding: 10px;
17
+ font-size: 11px;
18
+ }
19
+ a {
20
+ color: #000;
21
+ }
22
+ a:visited {
23
+ color: #666;
24
+ }
25
+ a:hover {
26
+ color: #fff;
27
+ background-color: #000;
28
+ }
29
+ div.field,
30
+ div.actions {
31
+ margin-bottom: 10px;
32
+ }
33
+ #notice {
34
+ color: green;
35
+ }
36
+ .field_with_errors {
37
+ padding: 2px;
38
+ background-color: red;
39
+ display: table;
40
+ }
41
+ #error_explanation {
42
+ width: 450px;
43
+ border: 2px solid red;
44
+ padding: 7px;
45
+ padding-bottom: 0;
46
+ margin-bottom: 20px;
47
+ background-color: #f0f0f0;
48
+ }
49
+ #error_explanation h2 {
50
+ text-align: left;
51
+ font-weight: bold;
52
+ padding: 5px 5px 5px 15px;
53
+ font-size: 12px;
54
+ margin: -7px;
55
+ margin-bottom: 0px;
56
+ background-color: #c00;
57
+ color: #fff;
58
+ }
59
+ #error_explanation ul li {
60
+ font-size: 12px;
61
+ list-style: square;
62
+ }
@@ -1,99 +1,99 @@
1
- class ContentsController < ApplicationController
2
-
3
- respond_to :html, :json, :xml
4
-
5
- before_filter :customize_view_paths
6
-
7
- # helper_method :link_to_add_fields
8
-
9
- def index
10
- @contents = Content.all
11
- respond_with @contents
12
- end
13
-
14
- def new
15
- @content = Content.new
16
- end
17
-
18
- def edit
19
- @content = Content.find_by_ancestry(params[:ancestors].try(:split,'/'), params[:id])
20
- # @content.build_seo unless @content.seo
21
- # @content.child_contents.create(slug:"#{@content.slug}-kid-#{@content.child_contents.count}", title:"#{@content.slug} Kid") if @content.child_contents.size == 0
22
- respond_with @content
23
- end
24
-
25
- def define
26
- @content = Content.find(params[:id])
27
- end
28
-
29
- def show # Content.all_entries
30
- @content = Content.find_by_ancestry(params[:ancestors].try(:split,'/'), params[:id])
31
- respond_with @content
32
- end
33
-
34
-
35
- def create
36
- @content = Content.new(params[:content])
37
- if @content.save
38
- # respond_with @content
39
- redirect_to contents_path, notice: "#{@content.slug} created."
40
- else
41
- format.html { render action: "new" }
42
- format.json { render json: @content.errors, status: :unprocessable_entity }
43
- end
44
- end
45
-
46
- def update
47
- @content = Content.find_by_ancestry(params[:ancestors].try(:split,'/'), params[:id])
48
- if @content.update_attributes(params[:content])
49
- redirect_to contents_path, notice: "#{@content.title} updated."
50
- else
51
- respond_to do |format|
52
- format.html { render action: "edit" }
53
- format.json { render json: @content.errors, status: :unprocessable_entity }
54
- end
55
- end
56
- end
57
-
58
-
59
- # TODO add code here to build-up embedded objects in the edited object via ajax
60
- def modify
61
- @content = Content.find(params[:id])
62
-
63
- end
64
-
65
-
66
- # PUT /foos/1
67
- # PUT /foos/1.json
68
- def renovate
69
- @content = Content.find(params[:id])
70
- @content.renovate(params[:content][:defn])
71
- if @content.save
72
- redirect_to contents_path, notice: "#{@content.slug} definition updated."
73
- else
74
- respond_to do |format|
75
- format.html { render action: "define" }
76
- format.json { render json: @content.errors, status: :unprocessable_entity }
77
- end
78
- end
79
- end
80
-
81
- def destroy
82
- @content = Content.find_by_ancestry(params[:ancestors].try(:split,'/'), params[:id])
83
- @content.destroy
84
-
85
- respond_to do |format|
86
- format.html { redirect_to contents_url}
87
- format.json { head :no_content }
88
- end
89
-
90
- end
91
-
92
- def customize_view_paths
93
- c = Content.find_by_ancestry(params[:ancestors].try(:split, '/'), params[:id]) if params[:id]
94
- prepend_view_path "app/views/contents/#{c.slug}" if c
95
- end
96
-
97
-
98
-
99
- end
1
+ class ContentsController < ApplicationController
2
+
3
+ respond_to :html, :json, :xml
4
+
5
+ before_filter :customize_view_paths
6
+
7
+ # helper_method :link_to_add_fields
8
+
9
+ def index
10
+ @contents = Content.all
11
+ respond_with @contents
12
+ end
13
+
14
+ def new
15
+ @content = Content.new
16
+ end
17
+
18
+ def edit
19
+ @content = Content.find_by_ancestry(params[:ancestors].try(:split,'/'), params[:id])
20
+ # @content.build_seo unless @content.seo
21
+ # @content.child_contents.create(slug:"#{@content.slug}-kid-#{@content.child_contents.count}", title:"#{@content.slug} Kid") if @content.child_contents.size == 0
22
+ respond_with @content
23
+ end
24
+
25
+ def define
26
+ @content = Content.find(params[:id])
27
+ end
28
+
29
+ def show # Content.all_entries
30
+ @content = Content.find_by_ancestry(params[:ancestors].try(:split,'/'), params[:id])
31
+ respond_with @content
32
+ end
33
+
34
+
35
+ def create
36
+ @content = Content.new(params[:content])
37
+ if @content.save
38
+ # respond_with @content
39
+ redirect_to contents_path, notice: "#{@content.slug} created."
40
+ else
41
+ format.html { render action: "new" }
42
+ format.json { render json: @content.errors, status: :unprocessable_entity }
43
+ end
44
+ end
45
+
46
+ def update
47
+ @content = Content.find_by_ancestry(params[:ancestors].try(:split,'/'), params[:id])
48
+ if @content.update_attributes(params[:content])
49
+ redirect_to contents_path, notice: "#{@content.title} updated."
50
+ else
51
+ respond_to do |format|
52
+ format.html { render action: "edit" }
53
+ format.json { render json: @content.errors, status: :unprocessable_entity }
54
+ end
55
+ end
56
+ end
57
+
58
+
59
+ # TODO add code here to build-up embedded objects in the edited object via ajax
60
+ def modify
61
+ @content = Content.find(params[:id])
62
+
63
+ end
64
+
65
+
66
+ # PUT /foos/1
67
+ # PUT /foos/1.json
68
+ def renovate
69
+ @content = Content.find(params[:id])
70
+ @content.renovate(params[:content][:defn])
71
+ if @content.save
72
+ redirect_to contents_path, notice: "#{@content.slug} definition updated."
73
+ else
74
+ respond_to do |format|
75
+ format.html { render action: "define" }
76
+ format.json { render json: @content.errors, status: :unprocessable_entity }
77
+ end
78
+ end
79
+ end
80
+
81
+ def destroy
82
+ @content = Content.find_by_ancestry(params[:ancestors].try(:split,'/'), params[:id])
83
+ @content.destroy
84
+
85
+ respond_to do |format|
86
+ format.html { redirect_to contents_url}
87
+ format.json { head :no_content }
88
+ end
89
+
90
+ end
91
+
92
+ def customize_view_paths
93
+ c = Content.find_by_ancestry(params[:ancestors].try(:split, '/'), params[:id]) if params[:id]
94
+ prepend_view_path "app/views/contents/#{c.slug}" if c
95
+ end
96
+
97
+
98
+
99
+ end
@@ -1,34 +1,27 @@
1
- module ContentsHelper
2
- def hateoas_uri_options(source, entity)
3
- # open the source url
4
- # parse out the entities
5
- # look for <name> and <link rel='self'> and parse into [[link, name]]
6
- end
7
-
8
-
9
- # from http://railscasts.com/episodes/196-nested-model-form-revised?view=asciicast
10
- # def link_to_add_fields(name, f, association)
11
- # new_object = f.object.send(association).klass.new
12
- # id = new_object.object_id
13
- # fields = f.fields_for(association, new_object, child_index: id) do |builder|
14
- # render(association.to_s.singularize + "_fields", f: builder)
15
- # end
16
- # link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
17
- # end
18
-
19
- def link_to_add_fields(name, f, association)
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
26
- id = new_object.object_id
27
- fields = f.fields_for(association, new_object, child_index: id) do |builder|
28
- render(partial: association.to_s.singularize + "_fields", locals: { f: builder })
29
- end
30
- link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
31
- end
32
-
33
-
34
- end
1
+ module ContentsHelper
2
+ def hateoas_uri_options(source, entity)
3
+ # open the source url
4
+ # parse out the entities
5
+ # look for <name> and <link rel='self'> and parse into [[link, name]]
6
+ end
7
+
8
+
9
+ # from http://railscasts.com/episodes/196-nested-model-form-revised?view=asciicast
10
+
11
+ def link_to_add_fields(name, f, association, enclosing_element = nil)
12
+ begin
13
+ new_object = f.object.send(association).klass.new
14
+ rescue Exception => e
15
+ p e
16
+ end
17
+ new_object ||= ::Content.const_get(association.to_s.camelize).new
18
+ id = new_object.object_id
19
+ fields = f.fields_for(association, new_object, child_index: id) do |builder|
20
+ render(partial: association.to_s.singularize + "_fields", locals: { f: builder, child_index: id })
21
+ end
22
+ link_to(name, '#', class: "add_fields",
23
+ data: {id: id, fields: fields.gsub("\n", ""), enclosing: enclosing_element})
24
+ end
25
+
26
+
27
+ end