muck-contents 3.1.0 → 3.1.1
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/README.rdoc +23 -3
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/app/views/contents/show.html.erb +1 -1
- data/config/locales/en.yml +1 -0
- data/db/migrate/20110226174321_add_cached_slugs.rb +10 -0
- data/lib/muck-contents.rb +1 -0
- data/lib/muck-contents/controllers/content_handler.rb +2 -2
- data/lib/muck-contents/engine.rb +5 -0
- data/lib/muck-contents/models/contentable.rb +14 -0
- data/muck-contents.gemspec +8 -7
- metadata +12 -8
data/README.rdoc
CHANGED
@@ -66,6 +66,27 @@ This method determines who can add content to any url on your website. For exam
|
|
66
66
|
http://www.example.com/a/test/page and that page does not exist, muck contents will automatically create
|
67
67
|
a page for you at that location if the logged in user has a method can_add_root_content? that returns true.
|
68
68
|
|
69
|
+
=== Attach content to a parent model
|
70
|
+
Content can be scoped to a specific model. ie
|
71
|
+
|
72
|
+
class User < ActiveRecord::Base
|
73
|
+
include MuckContents::Models::MuckContentable
|
74
|
+
end
|
75
|
+
|
76
|
+
Then the user's content can be accessed via:
|
77
|
+
|
78
|
+
@user.contents
|
79
|
+
|
80
|
+
=== Content Permissions
|
81
|
+
By default users are not allowed to add content. Add 'can_add_root_content?' to your user model to determine which users can add content to the root of the
|
82
|
+
website. A default configuration might be admins only:
|
83
|
+
|
84
|
+
class User < ActiveRecord::Base
|
85
|
+
def can_add_root_content?
|
86
|
+
admin?
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
69
90
|
=== Content models
|
70
91
|
Create the following models in your project. This let's you add any other methods that you see fit.
|
71
92
|
|
@@ -83,14 +104,13 @@ Create the following models in your project. This let's you add any other metho
|
|
83
104
|
|
84
105
|
=== Contents controller
|
85
106
|
|
86
|
-
|
87
|
-
we'd have to hard code the routes to go to muck/contents which prevent modification of the contents_controller.
|
107
|
+
Optionally create a ContentsController and inherit from Muck::ContentsController. This step is only needed if you intend to override the default contents controller functionality.
|
88
108
|
class ContentsController < Muck::ContentsController
|
89
109
|
end
|
90
110
|
|
91
111
|
Add a route for the new controller:
|
92
112
|
MyApp::Application.routes.draw do
|
93
|
-
|
113
|
+
resources :contents
|
94
114
|
end
|
95
115
|
|
96
116
|
Override the contents controller to change the the security model. For example:
|
data/Rakefile
CHANGED
@@ -64,7 +64,7 @@ begin
|
|
64
64
|
gem.add_dependency "awesome_nested_set"
|
65
65
|
gem.add_dependency "sanitize"
|
66
66
|
gem.add_dependency "acts-as-taggable-on"
|
67
|
-
gem.add_dependency "friendly_id"
|
67
|
+
gem.add_dependency "friendly_id", ">=3.2.0"
|
68
68
|
gem.add_dependency "uploader"
|
69
69
|
gem.add_dependency "tiny_mce"
|
70
70
|
gem.files.exclude 'test/**'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.1
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% content_for :head do -%>
|
2
2
|
<meta name="keywords" content="<%=@content.tags.join(',')%>" />
|
3
3
|
<% end -%>
|
4
|
-
<%= @content.locale_body(I18n.locale) %>
|
4
|
+
<%= @content.locale_body(I18n.locale).html_safe %>
|
5
5
|
<%= render :partial => 'contents/admin', :locals => { :content => @content } -%>
|
data/config/locales/en.yml
CHANGED
data/lib/muck-contents.rb
CHANGED
@@ -7,6 +7,7 @@ require 'uploader'
|
|
7
7
|
|
8
8
|
require 'muck-contents/config.rb'
|
9
9
|
require 'muck-contents/rack/rack.rb'
|
10
|
+
require 'muck-contents/models/contentable.rb'
|
10
11
|
require 'muck-contents/models/content.rb'
|
11
12
|
require 'muck-contents/models/content_permission.rb'
|
12
13
|
require 'muck-contents/models/content_translation.rb'
|
@@ -51,11 +51,11 @@ module MuckContents
|
|
51
51
|
return if @content # in case @content is setup by an overriding method
|
52
52
|
id = params[:id] || Content.id_from_uri(env["muck-contents.request_uri"])
|
53
53
|
scope = params[:scope] || Content.scope_from_uri(env["muck-contents.request_uri"])
|
54
|
-
@content = Content.find(id, :scope => scope) rescue nil
|
54
|
+
@content = Content.find(id, :include => :slugs, :conditions => {:slugs => {:scope => scope}}) rescue nil
|
55
55
|
if @content.blank?
|
56
56
|
@contentable = get_parent
|
57
57
|
if @contentable
|
58
|
-
@content =
|
58
|
+
@content = @contentable.contents.find(params[:id]) rescue nil
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
data/lib/muck-contents/engine.rb
CHANGED
@@ -22,6 +22,11 @@ module MuckContents
|
|
22
22
|
I18n.load_path += Dir[ File.join(File.dirname(__FILE__), '..', '..', 'config', 'locales', '*.{rb,yml}') ]
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
initializer 'muck-contents.add_admin_ui_links', :after => 'muck-engine.add_admin_ui_links' do
|
27
|
+
# Add admin link for contents
|
28
|
+
MuckEngine.configuration.add_muck_admin_nav_item(I18n.translate('muck.engine.admin_content'), '/admin/contents')
|
29
|
+
end
|
25
30
|
|
26
31
|
end
|
27
32
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# include MuckContents::Models::MuckContentable
|
2
|
+
module MuckContents
|
3
|
+
module Models
|
4
|
+
module MuckContentable
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
has_many :contents, :as => :contentable, :dependent => :destroy
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
data/muck-contents.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{muck-contents}
|
8
|
-
s.version = "3.1.
|
8
|
+
s.version = "3.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Ball", "Joel Duffin"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-02-26}
|
13
13
|
s.email = %q{justin@tatemae.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.rdoc"
|
@@ -91,6 +91,7 @@ Gem::Specification.new do |s|
|
|
91
91
|
"db/migrate/20090703055724_add_contents.rb",
|
92
92
|
"db/migrate/20090806230610_add_layout_to_contents.rb",
|
93
93
|
"db/migrate/20090808175401_add_contents_comment_counter_cache.rb",
|
94
|
+
"db/migrate/20110226174321_add_cached_slugs.rb",
|
94
95
|
"lib/muck-contents.rb",
|
95
96
|
"lib/muck-contents/config.rb",
|
96
97
|
"lib/muck-contents/controllers/content_handler.rb",
|
@@ -98,6 +99,7 @@ Gem::Specification.new do |s|
|
|
98
99
|
"lib/muck-contents/models/content.rb",
|
99
100
|
"lib/muck-contents/models/content_permission.rb",
|
100
101
|
"lib/muck-contents/models/content_translation.rb",
|
102
|
+
"lib/muck-contents/models/contentable.rb",
|
101
103
|
"lib/muck-contents/rack/rack.rb",
|
102
104
|
"lib/muck-contents/routes.rb",
|
103
105
|
"lib/tasks/muck_contents.rake",
|
@@ -1473,11 +1475,10 @@ Gem::Specification.new do |s|
|
|
1473
1475
|
]
|
1474
1476
|
s.homepage = %q{http://github.com/tatemae/muck-contents}
|
1475
1477
|
s.require_paths = ["lib"]
|
1476
|
-
s.rubygems_version = %q{1.
|
1478
|
+
s.rubygems_version = %q{1.5.2}
|
1477
1479
|
s.summary = %q{Add content to your muck based project}
|
1478
1480
|
|
1479
1481
|
if s.respond_to? :specification_version then
|
1480
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
1481
1482
|
s.specification_version = 3
|
1482
1483
|
|
1483
1484
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
@@ -1488,7 +1489,7 @@ Gem::Specification.new do |s|
|
|
1488
1489
|
s.add_runtime_dependency(%q<awesome_nested_set>, [">= 0"])
|
1489
1490
|
s.add_runtime_dependency(%q<sanitize>, [">= 0"])
|
1490
1491
|
s.add_runtime_dependency(%q<acts-as-taggable-on>, [">= 0"])
|
1491
|
-
s.add_runtime_dependency(%q<friendly_id>, [">= 0"])
|
1492
|
+
s.add_runtime_dependency(%q<friendly_id>, [">= 3.2.0"])
|
1492
1493
|
s.add_runtime_dependency(%q<uploader>, [">= 0"])
|
1493
1494
|
s.add_runtime_dependency(%q<tiny_mce>, [">= 0"])
|
1494
1495
|
else
|
@@ -1499,7 +1500,7 @@ Gem::Specification.new do |s|
|
|
1499
1500
|
s.add_dependency(%q<awesome_nested_set>, [">= 0"])
|
1500
1501
|
s.add_dependency(%q<sanitize>, [">= 0"])
|
1501
1502
|
s.add_dependency(%q<acts-as-taggable-on>, [">= 0"])
|
1502
|
-
s.add_dependency(%q<friendly_id>, [">= 0"])
|
1503
|
+
s.add_dependency(%q<friendly_id>, [">= 3.2.0"])
|
1503
1504
|
s.add_dependency(%q<uploader>, [">= 0"])
|
1504
1505
|
s.add_dependency(%q<tiny_mce>, [">= 0"])
|
1505
1506
|
end
|
@@ -1511,7 +1512,7 @@ Gem::Specification.new do |s|
|
|
1511
1512
|
s.add_dependency(%q<awesome_nested_set>, [">= 0"])
|
1512
1513
|
s.add_dependency(%q<sanitize>, [">= 0"])
|
1513
1514
|
s.add_dependency(%q<acts-as-taggable-on>, [">= 0"])
|
1514
|
-
s.add_dependency(%q<friendly_id>, [">= 0"])
|
1515
|
+
s.add_dependency(%q<friendly_id>, [">= 3.2.0"])
|
1515
1516
|
s.add_dependency(%q<uploader>, [">= 0"])
|
1516
1517
|
s.add_dependency(%q<tiny_mce>, [">= 0"])
|
1517
1518
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muck-contents
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 1
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 3.1.
|
9
|
+
- 1
|
10
|
+
version: 3.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Ball
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
19
|
+
date: 2011-02-26 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -125,10 +125,12 @@ dependencies:
|
|
125
125
|
requirements:
|
126
126
|
- - ">="
|
127
127
|
- !ruby/object:Gem::Version
|
128
|
-
hash:
|
128
|
+
hash: 15
|
129
129
|
segments:
|
130
|
+
- 3
|
131
|
+
- 2
|
130
132
|
- 0
|
131
|
-
version:
|
133
|
+
version: 3.2.0
|
132
134
|
type: :runtime
|
133
135
|
version_requirements: *id008
|
134
136
|
- !ruby/object:Gem::Dependency
|
@@ -244,6 +246,7 @@ files:
|
|
244
246
|
- db/migrate/20090703055724_add_contents.rb
|
245
247
|
- db/migrate/20090806230610_add_layout_to_contents.rb
|
246
248
|
- db/migrate/20090808175401_add_contents_comment_counter_cache.rb
|
249
|
+
- db/migrate/20110226174321_add_cached_slugs.rb
|
247
250
|
- lib/muck-contents.rb
|
248
251
|
- lib/muck-contents/config.rb
|
249
252
|
- lib/muck-contents/controllers/content_handler.rb
|
@@ -251,6 +254,7 @@ files:
|
|
251
254
|
- lib/muck-contents/models/content.rb
|
252
255
|
- lib/muck-contents/models/content_permission.rb
|
253
256
|
- lib/muck-contents/models/content_translation.rb
|
257
|
+
- lib/muck-contents/models/contentable.rb
|
254
258
|
- lib/muck-contents/rack/rack.rb
|
255
259
|
- lib/muck-contents/routes.rb
|
256
260
|
- lib/tasks/muck_contents.rake
|
@@ -1653,7 +1657,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1653
1657
|
requirements: []
|
1654
1658
|
|
1655
1659
|
rubyforge_project:
|
1656
|
-
rubygems_version: 1.
|
1660
|
+
rubygems_version: 1.5.2
|
1657
1661
|
signing_key:
|
1658
1662
|
specification_version: 3
|
1659
1663
|
summary: Add content to your muck based project
|