muck-contents 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +13 -14
- data/Rakefile +3 -28
- data/VERSION +1 -1
- data/app/controllers/muck/contents_controller.rb +1 -1
- data/lib/action_controller/acts/muck_content_handler.rb +5 -0
- data/lib/active_record/acts/muck_content.rb +4 -4
- data/muck-contents.gemspec +5 -3
- metadata +2 -3
- data/test/rails_root/db/schema.rb +0 -186
data/README.rdoc
CHANGED
@@ -8,7 +8,7 @@ Note that all gems below should be installed automatically as a muck-contents ha
|
|
8
8
|
Many of the gems are found on github so before installing do:
|
9
9
|
gem sources -a http://gems.github.com
|
10
10
|
|
11
|
-
sudo gem install
|
11
|
+
sudo gem install muck-acts_as_git # Versioning. Requires a git installation.
|
12
12
|
sudo gem install collectiveidea-awesome_nested_set # Nested pages. Used to setup navigation hierarchy (http://github.com/collectiveidea/awesome_nested_set/tree/master)
|
13
13
|
sudo gem install rgrove-sanitize # Remove harmful html. (http://github.com/rgrove/sanitize/tree/master.)
|
14
14
|
sudo gem install mbleigh-acts-as-taggable-on # Tagging. (http://github.com/mbleigh/acts-as-taggable-on/tree/master)
|
@@ -64,7 +64,16 @@ Create the following models in your project. This let's you add any other metho
|
|
64
64
|
acts_as_muck_content_permission
|
65
65
|
end
|
66
66
|
|
67
|
+
=== Application controller
|
68
|
+
Add acts_as_muck_content_handler if you want muck_contents to intercept pages that are not found and provide authorized users
|
69
|
+
and opportunity to add them.
|
70
|
+
|
71
|
+
class ApplicationController < ActionController::Base
|
72
|
+
acts_as_muck_content_handler
|
73
|
+
end
|
74
|
+
|
67
75
|
=== Contents controller
|
76
|
+
|
68
77
|
Create a ContentsController and inherit from Muck::ContentsController. Unfortunately, due to routing issues this is required or
|
69
78
|
we'd have to hard code the routes to go to muck/contents which prevent modification of the contents_controller.
|
70
79
|
class ContentsController < Muck::ContentsController
|
@@ -74,27 +83,15 @@ Add a route for the new controller:
|
|
74
83
|
ActionController::Routing::Routes.draw do |map|
|
75
84
|
map.resource :contents
|
76
85
|
end
|
77
|
-
|
78
86
|
|
79
|
-
=== Application controller
|
80
|
-
Add acts_as_muck_content_handler if you want muck_contents to intercept pages that are not found and provide authorized users
|
81
|
-
and opportunity to add them.
|
82
|
-
|
83
|
-
class ApplicationController < ActionController::Base
|
84
|
-
acts_as_muck_content_handler
|
85
|
-
end
|
86
|
-
|
87
|
-
=== Content controller
|
88
87
|
Override the contents controller to change the the security model. For example:
|
89
88
|
|
90
89
|
class ContentsController < Muck::ContentsController
|
91
90
|
|
92
|
-
before_filter :login_required # require the user to be logged in to add content
|
93
|
-
|
94
91
|
# Modify this method to change how permissions are checked to see if a user can content.
|
95
92
|
# Each model that implements 'has_muck_content' can (and should) override can_add_content? to
|
96
93
|
# change how content permissions are handled.
|
97
|
-
def has_permission_to_add_content(user, parent)
|
94
|
+
def has_permission_to_add_content(user, parent, content)
|
98
95
|
parent.can_add_content?(user)
|
99
96
|
end
|
100
97
|
|
@@ -103,6 +100,8 @@ Override the contents controller to change the the security model. For example:
|
|
103
100
|
# layout will need to exist in your 'views/layouts' directory
|
104
101
|
def setup_layouts
|
105
102
|
@content_layouts =
|
103
|
+
@content_layouts << OpenStruct.new(:name => 'A Great Layout', :value => 'great_layout')
|
104
|
+
@content_layouts << OpenStruct.new(:name => 'Default', :value => 'default')
|
106
105
|
end
|
107
106
|
|
108
107
|
end
|
data/Rakefile
CHANGED
@@ -68,34 +68,9 @@ begin
|
|
68
68
|
gemspec.add_dependency "mbleigh-acts-as-taggable-on"
|
69
69
|
gemspec.add_dependency "friendly_id"
|
70
70
|
end
|
71
|
-
|
71
|
+
Jeweler::RubyforgeTasks.new do |rubyforge|
|
72
|
+
rubyforge.doc_task = "rdoc"
|
73
|
+
end
|
72
74
|
rescue LoadError
|
73
75
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
74
76
|
end
|
75
|
-
|
76
|
-
# rubyforge tasks
|
77
|
-
begin
|
78
|
-
require 'rake/contrib/sshpublisher'
|
79
|
-
namespace :rubyforge do
|
80
|
-
|
81
|
-
desc "Release gem and RDoc documentation to RubyForge"
|
82
|
-
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
83
|
-
|
84
|
-
namespace :release do
|
85
|
-
desc "Publish RDoc to RubyForge."
|
86
|
-
task :docs => [:rdoc] do
|
87
|
-
config = YAML.load(
|
88
|
-
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
89
|
-
)
|
90
|
-
|
91
|
-
host = "#{config['username']}@rubyforge.org"
|
92
|
-
remote_dir = "/var/www/gforge-projects/muck-contents/"
|
93
|
-
local_dir = 'rdoc'
|
94
|
-
|
95
|
-
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
rescue LoadError
|
100
|
-
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
101
|
-
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
@@ -20,6 +20,11 @@ module ActionController
|
|
20
20
|
|
21
21
|
# Renders content, shows 404 or redirects to new content as appropriate
|
22
22
|
def handle_content_request
|
23
|
+
if !request.format.html?
|
24
|
+
# If the the request is html we can bail.
|
25
|
+
render :nothing => true, :status => 404
|
26
|
+
return
|
27
|
+
end
|
23
28
|
get_content
|
24
29
|
if @content.blank?
|
25
30
|
redirect_to new_content_path(:path => request.path)
|
@@ -66,7 +66,7 @@ module ActiveRecord
|
|
66
66
|
end
|
67
67
|
|
68
68
|
if options[:enable_solr]
|
69
|
-
acts_as_solr :fields => [ :search_content ]
|
69
|
+
acts_as_solr({ :fields => [ :search_content => 'string' ] }, { :multi_core => true, :default_core => 'en' })
|
70
70
|
end
|
71
71
|
|
72
72
|
class_eval <<-EOV
|
@@ -189,10 +189,10 @@ module ActiveRecord
|
|
189
189
|
self.body
|
190
190
|
end
|
191
191
|
|
192
|
-
# Provided for solr index
|
193
|
-
#
|
192
|
+
# Provided for solr index. Override this method if you wish to add
|
193
|
+
# other fields/data to the solr index.
|
194
194
|
def search_content
|
195
|
-
"#{
|
195
|
+
"#{body}"
|
196
196
|
end
|
197
197
|
|
198
198
|
# Called after 'save' if auto translate is enabled
|
data/muck-contents.gemspec
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
1
4
|
# -*- encoding: utf-8 -*-
|
2
5
|
|
3
6
|
Gem::Specification.new do |s|
|
4
7
|
s.name = %q{muck-contents}
|
5
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
6
9
|
|
7
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
11
|
s.authors = ["Justin Ball"]
|
9
|
-
s.date = %q{2009-08-
|
12
|
+
s.date = %q{2009-08-12}
|
10
13
|
s.email = %q{justinball@gmail.com}
|
11
14
|
s.extra_rdoc_files = [
|
12
15
|
"README.rdoc"
|
@@ -580,7 +583,6 @@ Gem::Specification.new do |s|
|
|
580
583
|
"test/rails_root/db/migrate/20090806230610_add_layout_to_contents.rb",
|
581
584
|
"test/rails_root/db/migrate/20090808005918_add_scope_index_to_slugs.rb",
|
582
585
|
"test/rails_root/db/migrate/20090808175401_add_contents_comment_counter_cache.rb",
|
583
|
-
"test/rails_root/db/schema.rb",
|
584
586
|
"test/rails_root/features/step_definitions/common_steps.rb",
|
585
587
|
"test/rails_root/features/step_definitions/content_steps.rb",
|
586
588
|
"test/rails_root/features/step_definitions/webrat_steps.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muck-contents
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ball
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-12 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -677,7 +677,6 @@ test_files:
|
|
677
677
|
- test/rails_root/db/migrate/20090806230610_add_layout_to_contents.rb
|
678
678
|
- test/rails_root/db/migrate/20090808005918_add_scope_index_to_slugs.rb
|
679
679
|
- test/rails_root/db/migrate/20090808175401_add_contents_comment_counter_cache.rb
|
680
|
-
- test/rails_root/db/schema.rb
|
681
680
|
- test/rails_root/features/step_definitions/common_steps.rb
|
682
681
|
- test/rails_root/features/step_definitions/content_steps.rb
|
683
682
|
- test/rails_root/features/step_definitions/webrat_steps.rb
|
@@ -1,186 +0,0 @@
|
|
1
|
-
# This file is auto-generated from the current state of the database. Instead of editing this file,
|
2
|
-
# please use the migrations feature of Active Record to incrementally modify your database, and
|
3
|
-
# then regenerate this schema definition.
|
4
|
-
#
|
5
|
-
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
|
6
|
-
# to create the application database on another system, you should be using db:schema:load, not running
|
7
|
-
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
8
|
-
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
9
|
-
#
|
10
|
-
# It's strongly recommended to check this file into your version control system.
|
11
|
-
|
12
|
-
ActiveRecord::Schema.define(:version => 20090808175401) do
|
13
|
-
|
14
|
-
create_table "activities", :force => true do |t|
|
15
|
-
t.integer "item_id"
|
16
|
-
t.string "item_type"
|
17
|
-
t.string "template"
|
18
|
-
t.integer "source_id"
|
19
|
-
t.string "source_type"
|
20
|
-
t.text "content"
|
21
|
-
t.string "title"
|
22
|
-
t.boolean "is_status_update", :default => false
|
23
|
-
t.boolean "is_public", :default => true
|
24
|
-
t.datetime "created_at"
|
25
|
-
t.datetime "updated_at"
|
26
|
-
end
|
27
|
-
|
28
|
-
add_index "activities", ["item_id", "item_type"], :name => "index_activities_on_item_id_and_item_type"
|
29
|
-
|
30
|
-
create_table "activity_feeds", :force => true do |t|
|
31
|
-
t.integer "activity_id"
|
32
|
-
t.integer "ownable_id"
|
33
|
-
t.string "ownable_type"
|
34
|
-
end
|
35
|
-
|
36
|
-
add_index "activity_feeds", ["activity_id"], :name => "index_activity_feeds_on_activity_id"
|
37
|
-
add_index "activity_feeds", ["ownable_id", "ownable_type"], :name => "index_activity_feeds_on_ownable_id_and_ownable_type"
|
38
|
-
|
39
|
-
create_table "comments", :force => true do |t|
|
40
|
-
t.integer "commentable_id", :default => 0
|
41
|
-
t.string "commentable_type", :limit => 15, :default => ""
|
42
|
-
t.text "body"
|
43
|
-
t.integer "user_id"
|
44
|
-
t.integer "parent_id"
|
45
|
-
t.integer "lft"
|
46
|
-
t.integer "rgt"
|
47
|
-
t.integer "is_denied", :default => 0, :null => false
|
48
|
-
t.boolean "is_reviewed", :default => false
|
49
|
-
t.datetime "created_at"
|
50
|
-
t.datetime "updated_at"
|
51
|
-
end
|
52
|
-
|
53
|
-
add_index "comments", ["commentable_id", "commentable_type"], :name => "index_comments_on_commentable_id_and_commentable_type"
|
54
|
-
add_index "comments", ["user_id"], :name => "index_comments_on_user_id"
|
55
|
-
|
56
|
-
create_table "content_permissions", :force => true do |t|
|
57
|
-
t.integer "content_id"
|
58
|
-
t.integer "user_id"
|
59
|
-
t.datetime "created_at"
|
60
|
-
t.datetime "updated_at"
|
61
|
-
end
|
62
|
-
|
63
|
-
add_index "content_permissions", ["content_id", "user_id"], :name => "index_content_permissions_on_content_id_and_user_id"
|
64
|
-
|
65
|
-
create_table "content_translations", :force => true do |t|
|
66
|
-
t.integer "content_id"
|
67
|
-
t.string "title"
|
68
|
-
t.text "body"
|
69
|
-
t.string "locale"
|
70
|
-
t.boolean "user_edited"
|
71
|
-
t.datetime "created_at"
|
72
|
-
t.datetime "updated_at"
|
73
|
-
end
|
74
|
-
|
75
|
-
add_index "content_translations", ["content_id"], :name => "index_content_translations_on_content_id"
|
76
|
-
add_index "content_translations", ["locale"], :name => "index_content_translations_on_locale"
|
77
|
-
|
78
|
-
create_table "contents", :force => true do |t|
|
79
|
-
t.integer "creator_id"
|
80
|
-
t.string "title"
|
81
|
-
t.text "body"
|
82
|
-
t.string "locale"
|
83
|
-
t.text "body_raw"
|
84
|
-
t.integer "contentable_id"
|
85
|
-
t.string "contentable_type"
|
86
|
-
t.integer "parent_id"
|
87
|
-
t.integer "lft"
|
88
|
-
t.integer "rgt"
|
89
|
-
t.boolean "is_public"
|
90
|
-
t.string "state"
|
91
|
-
t.datetime "created_at"
|
92
|
-
t.datetime "updated_at"
|
93
|
-
t.string "layout"
|
94
|
-
t.integer "comment_count", :default => 0
|
95
|
-
end
|
96
|
-
|
97
|
-
add_index "contents", ["creator_id"], :name => "index_contents_on_creator_id"
|
98
|
-
add_index "contents", ["parent_id"], :name => "index_contents_on_parent_id"
|
99
|
-
|
100
|
-
create_table "friends", :force => true do |t|
|
101
|
-
t.integer "inviter_id"
|
102
|
-
t.integer "invited_id"
|
103
|
-
t.integer "status", :default => 0
|
104
|
-
t.datetime "created_at"
|
105
|
-
t.datetime "updated_at"
|
106
|
-
end
|
107
|
-
|
108
|
-
add_index "friends", ["invited_id", "inviter_id"], :name => "index_friends_on_invited_id_and_inviter_id"
|
109
|
-
add_index "friends", ["inviter_id", "invited_id"], :name => "index_friends_on_inviter_id_and_invited_id"
|
110
|
-
|
111
|
-
create_table "permissions", :force => true do |t|
|
112
|
-
t.integer "role_id", :null => false
|
113
|
-
t.integer "user_id", :null => false
|
114
|
-
t.datetime "created_at"
|
115
|
-
t.datetime "updated_at"
|
116
|
-
end
|
117
|
-
|
118
|
-
create_table "roles", :force => true do |t|
|
119
|
-
t.string "rolename"
|
120
|
-
t.datetime "created_at"
|
121
|
-
t.datetime "updated_at"
|
122
|
-
end
|
123
|
-
|
124
|
-
create_table "slugs", :force => true do |t|
|
125
|
-
t.string "name"
|
126
|
-
t.integer "sluggable_id"
|
127
|
-
t.integer "sequence", :default => 1, :null => false
|
128
|
-
t.string "sluggable_type", :limit => 40
|
129
|
-
t.string "scope", :limit => 40
|
130
|
-
t.datetime "created_at"
|
131
|
-
end
|
132
|
-
|
133
|
-
add_index "slugs", ["name", "sluggable_type", "scope", "sequence"], :name => "index_slugs_on_name_and_sluggable_type_and_scope_and_sequence", :unique => true
|
134
|
-
add_index "slugs", ["scope"], :name => "index_slugs_on_scope"
|
135
|
-
add_index "slugs", ["sluggable_id"], :name => "index_slugs_on_sluggable_id"
|
136
|
-
|
137
|
-
create_table "taggings", :force => true do |t|
|
138
|
-
t.integer "tag_id"
|
139
|
-
t.integer "taggable_id"
|
140
|
-
t.integer "tagger_id"
|
141
|
-
t.string "tagger_type"
|
142
|
-
t.string "taggable_type"
|
143
|
-
t.string "context"
|
144
|
-
t.datetime "created_at"
|
145
|
-
end
|
146
|
-
|
147
|
-
add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
|
148
|
-
add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"
|
149
|
-
|
150
|
-
create_table "tags", :force => true do |t|
|
151
|
-
t.string "name"
|
152
|
-
end
|
153
|
-
|
154
|
-
create_table "users", :force => true do |t|
|
155
|
-
t.string "login"
|
156
|
-
t.string "email"
|
157
|
-
t.string "first_name"
|
158
|
-
t.string "last_name"
|
159
|
-
t.string "crypted_password"
|
160
|
-
t.string "password_salt"
|
161
|
-
t.string "persistence_token"
|
162
|
-
t.string "single_access_token"
|
163
|
-
t.string "perishable_token"
|
164
|
-
t.integer "login_count", :default => 0, :null => false
|
165
|
-
t.integer "failed_login_count", :default => 0, :null => false
|
166
|
-
t.datetime "last_request_at"
|
167
|
-
t.datetime "last_login_at"
|
168
|
-
t.datetime "current_login_at"
|
169
|
-
t.string "current_login_ip"
|
170
|
-
t.string "last_login_ip"
|
171
|
-
t.boolean "terms_of_service", :default => false, :null => false
|
172
|
-
t.string "time_zone", :default => "UTC"
|
173
|
-
t.datetime "disabled_at"
|
174
|
-
t.datetime "activated_at"
|
175
|
-
t.datetime "created_at"
|
176
|
-
t.datetime "updated_at"
|
177
|
-
end
|
178
|
-
|
179
|
-
add_index "users", ["email"], :name => "index_users_on_email"
|
180
|
-
add_index "users", ["last_request_at"], :name => "index_users_on_last_request_at"
|
181
|
-
add_index "users", ["login"], :name => "index_users_on_login"
|
182
|
-
add_index "users", ["perishable_token"], :name => "index_users_on_perishable_token"
|
183
|
-
add_index "users", ["persistence_token"], :name => "index_users_on_persistence_token"
|
184
|
-
add_index "users", ["single_access_token"], :name => "index_users_on_single_access_token"
|
185
|
-
|
186
|
-
end
|