governor_comments 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +21 -0
- data/Gemfile.lock +126 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +59 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/app/controllers/governor/comments_controller.rb +93 -0
- data/app/helpers/governor_comments_helper.rb +7 -0
- data/app/views/governor/articles/_comment_link.html.erb +2 -0
- data/app/views/governor/articles/_comments.html.erb +17 -0
- data/app/views/governor/comments/_comment.html.erb +27 -0
- data/app/views/governor/comments/new.html.erb +7 -0
- data/config/locales/en.yml +6 -0
- data/governor_comments.gemspec +196 -0
- data/lib/generators/governor/create_comments_generator.rb +25 -0
- data/lib/generators/governor/templates/migrations/create_comments.rb +23 -0
- data/lib/generators/governor/templates/models/comment.rb +3 -0
- data/lib/generators/governor/templates/models/guest.rb +14 -0
- data/lib/governor_comments.rb +15 -0
- data/lib/governor_comments/comment.rb +31 -0
- data/lib/governor_comments/rails.rb +5 -0
- data/log/development.log +0 -0
- data/script/rails +6 -0
- data/spec/controllers/governor/comments_controller_spec.rb +38 -0
- data/spec/governor_comments_spec.rb +16 -0
- data/spec/rails_app/.gitignore +4 -0
- data/spec/rails_app/Gemfile +40 -0
- data/spec/rails_app/Gemfile.lock +96 -0
- data/spec/rails_app/README +256 -0
- data/spec/rails_app/Rakefile +7 -0
- data/spec/rails_app/app/controllers/application_controller.rb +3 -0
- data/spec/rails_app/app/controllers/home_controller.rb +2 -0
- data/spec/rails_app/app/helpers/application_helper.rb +2 -0
- data/spec/rails_app/app/helpers/home_helper.rb +2 -0
- data/spec/rails_app/app/models/article.rb +5 -0
- data/spec/rails_app/app/models/comment.rb +3 -0
- data/spec/rails_app/app/models/guest.rb +14 -0
- data/spec/rails_app/app/models/user.rb +9 -0
- data/spec/rails_app/app/views/home/index.html.erb +0 -0
- data/spec/rails_app/app/views/layouts/application.html.erb +22 -0
- data/spec/rails_app/config.ru +4 -0
- data/spec/rails_app/config/application.rb +42 -0
- data/spec/rails_app/config/boot.rb +14 -0
- data/spec/rails_app/config/database.yml +19 -0
- data/spec/rails_app/config/environment.rb +5 -0
- data/spec/rails_app/config/environments/development.rb +26 -0
- data/spec/rails_app/config/environments/production.rb +49 -0
- data/spec/rails_app/config/environments/test.rb +35 -0
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_app/config/initializers/devise.rb +142 -0
- data/spec/rails_app/config/initializers/governor.rb +36 -0
- data/spec/rails_app/config/initializers/inflections.rb +10 -0
- data/spec/rails_app/config/initializers/mime_types.rb +5 -0
- data/spec/rails_app/config/initializers/rakismet.rb +6 -0
- data/spec/rails_app/config/initializers/secret_token.rb +7 -0
- data/spec/rails_app/config/initializers/session_store.rb +8 -0
- data/spec/rails_app/config/locales/devise.en.yml +39 -0
- data/spec/rails_app/config/locales/en.yml +5 -0
- data/spec/rails_app/config/routes.rb +64 -0
- data/spec/rails_app/db/migrate/20110329032256_devise_create_users.rb +28 -0
- data/spec/rails_app/db/migrate/20110330020108_governor_create_articles.rb +15 -0
- data/spec/rails_app/db/migrate/20110405030324_governor_create_comments.rb +23 -0
- data/spec/rails_app/db/schema.rb +66 -0
- data/spec/rails_app/db/seeds.rb +7 -0
- data/spec/rails_app/lib/tasks/.gitkeep +0 -0
- data/spec/rails_app/public/404.html +26 -0
- data/spec/rails_app/public/422.html +26 -0
- data/spec/rails_app/public/500.html +26 -0
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/public/images/rails.png +0 -0
- data/spec/rails_app/public/javascripts/application.js +2 -0
- data/spec/rails_app/public/javascripts/controls.js +965 -0
- data/spec/rails_app/public/javascripts/dragdrop.js +974 -0
- data/spec/rails_app/public/javascripts/effects.js +1123 -0
- data/spec/rails_app/public/javascripts/prototype.js +6001 -0
- data/spec/rails_app/public/javascripts/rails.js +191 -0
- data/spec/rails_app/public/robots.txt +5 -0
- data/spec/rails_app/public/stylesheets/.gitkeep +0 -0
- data/spec/rails_app/script/rails +6 -0
- data/spec/rails_app/spec/factories.rb +16 -0
- data/spec/rails_app/vendor/plugins/.gitkeep +0 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/views/governor/articles/show.html.erb_spec.rb +30 -0
- metadata +376 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '~> 3.0.5'
|
4
|
+
|
5
|
+
gem 'governor', '>= 0.2.0'
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem 'jeweler', '~> 1.5.2'
|
9
|
+
gem 'sqlite3'
|
10
|
+
gem 'rspec-rails'
|
11
|
+
gem 'mocha'
|
12
|
+
gem 'factory_girl', '~> 2.0.0.beta'
|
13
|
+
gem 'factory_girl_rails', '~> 1.1.beta'
|
14
|
+
gem 'activerecord-nulldb-adapter'
|
15
|
+
|
16
|
+
gem 'governor_comments', :path => './'
|
17
|
+
|
18
|
+
gem 'devise'
|
19
|
+
gem 'dynamic_form'
|
20
|
+
gem 'rakismet'
|
21
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ./
|
3
|
+
specs:
|
4
|
+
governor_comments (0.0.0)
|
5
|
+
rails (~> 3.0.5)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
abstract (1.0.0)
|
11
|
+
actionmailer (3.0.5)
|
12
|
+
actionpack (= 3.0.5)
|
13
|
+
mail (~> 2.2.15)
|
14
|
+
actionpack (3.0.5)
|
15
|
+
activemodel (= 3.0.5)
|
16
|
+
activesupport (= 3.0.5)
|
17
|
+
builder (~> 2.1.2)
|
18
|
+
erubis (~> 2.6.6)
|
19
|
+
i18n (~> 0.4)
|
20
|
+
rack (~> 1.2.1)
|
21
|
+
rack-mount (~> 0.6.13)
|
22
|
+
rack-test (~> 0.5.7)
|
23
|
+
tzinfo (~> 0.3.23)
|
24
|
+
activemodel (3.0.5)
|
25
|
+
activesupport (= 3.0.5)
|
26
|
+
builder (~> 2.1.2)
|
27
|
+
i18n (~> 0.4)
|
28
|
+
activerecord (3.0.5)
|
29
|
+
activemodel (= 3.0.5)
|
30
|
+
activesupport (= 3.0.5)
|
31
|
+
arel (~> 2.0.2)
|
32
|
+
tzinfo (~> 0.3.23)
|
33
|
+
activerecord-nulldb-adapter (0.2.1)
|
34
|
+
activerecord (>= 2.0.0, < 3.1)
|
35
|
+
activeresource (3.0.5)
|
36
|
+
activemodel (= 3.0.5)
|
37
|
+
activesupport (= 3.0.5)
|
38
|
+
activesupport (3.0.5)
|
39
|
+
arel (2.0.9)
|
40
|
+
bcrypt-ruby (2.1.4)
|
41
|
+
builder (2.1.2)
|
42
|
+
devise (1.1.7)
|
43
|
+
bcrypt-ruby (~> 2.1.2)
|
44
|
+
warden (~> 1.0.2)
|
45
|
+
diff-lcs (1.1.2)
|
46
|
+
dynamic_form (1.1.3)
|
47
|
+
erubis (2.6.6)
|
48
|
+
abstract (>= 1.0.0)
|
49
|
+
factory_girl (2.0.0.beta2)
|
50
|
+
factory_girl_rails (1.1.beta1)
|
51
|
+
factory_girl (~> 2.0.0.beta)
|
52
|
+
rails (>= 3.0.0)
|
53
|
+
git (1.2.5)
|
54
|
+
governor (0.2.0)
|
55
|
+
rails (~> 3.0.5)
|
56
|
+
i18n (0.5.0)
|
57
|
+
jeweler (1.5.2)
|
58
|
+
bundler (~> 1.0.0)
|
59
|
+
git (>= 1.2.5)
|
60
|
+
rake
|
61
|
+
mail (2.2.15)
|
62
|
+
activesupport (>= 2.3.6)
|
63
|
+
i18n (>= 0.4.0)
|
64
|
+
mime-types (~> 1.16)
|
65
|
+
treetop (~> 1.4.8)
|
66
|
+
mime-types (1.16)
|
67
|
+
mocha (0.9.12)
|
68
|
+
polyglot (0.3.1)
|
69
|
+
rack (1.2.1)
|
70
|
+
rack-mount (0.6.13)
|
71
|
+
rack (>= 1.0.0)
|
72
|
+
rack-test (0.5.7)
|
73
|
+
rack (>= 1.0)
|
74
|
+
rails (3.0.5)
|
75
|
+
actionmailer (= 3.0.5)
|
76
|
+
actionpack (= 3.0.5)
|
77
|
+
activerecord (= 3.0.5)
|
78
|
+
activeresource (= 3.0.5)
|
79
|
+
activesupport (= 3.0.5)
|
80
|
+
bundler (~> 1.0)
|
81
|
+
railties (= 3.0.5)
|
82
|
+
railties (3.0.5)
|
83
|
+
actionpack (= 3.0.5)
|
84
|
+
activesupport (= 3.0.5)
|
85
|
+
rake (>= 0.8.7)
|
86
|
+
thor (~> 0.14.4)
|
87
|
+
rake (0.8.7)
|
88
|
+
rakismet (1.0.1)
|
89
|
+
rspec (2.5.0)
|
90
|
+
rspec-core (~> 2.5.0)
|
91
|
+
rspec-expectations (~> 2.5.0)
|
92
|
+
rspec-mocks (~> 2.5.0)
|
93
|
+
rspec-core (2.5.1)
|
94
|
+
rspec-expectations (2.5.0)
|
95
|
+
diff-lcs (~> 1.1.2)
|
96
|
+
rspec-mocks (2.5.0)
|
97
|
+
rspec-rails (2.5.0)
|
98
|
+
actionpack (~> 3.0)
|
99
|
+
activesupport (~> 3.0)
|
100
|
+
railties (~> 3.0)
|
101
|
+
rspec (~> 2.5.0)
|
102
|
+
sqlite3 (1.3.3)
|
103
|
+
thor (0.14.6)
|
104
|
+
treetop (1.4.9)
|
105
|
+
polyglot (>= 0.3.1)
|
106
|
+
tzinfo (0.3.24)
|
107
|
+
warden (1.0.3)
|
108
|
+
rack (>= 1.0.0)
|
109
|
+
|
110
|
+
PLATFORMS
|
111
|
+
ruby
|
112
|
+
|
113
|
+
DEPENDENCIES
|
114
|
+
activerecord-nulldb-adapter
|
115
|
+
devise
|
116
|
+
dynamic_form
|
117
|
+
factory_girl (~> 2.0.0.beta)
|
118
|
+
factory_girl_rails (~> 1.1.beta)
|
119
|
+
governor (>= 0.2.0)
|
120
|
+
governor_comments!
|
121
|
+
jeweler (~> 1.5.2)
|
122
|
+
mocha
|
123
|
+
rails (~> 3.0.5)
|
124
|
+
rakismet
|
125
|
+
rspec-rails
|
126
|
+
sqlite3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Liam Morley
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
governor_comments
|
2
|
+
=================
|
3
|
+
|
4
|
+
**[Governor](http://carpeliam.github.com/governor/)** (named after Rod
|
5
|
+
Blagojevich) is the pluggable blogging platform for Rails, built for people
|
6
|
+
who want to build their blog into their website, not build their website into
|
7
|
+
their blog.
|
8
|
+
|
9
|
+
**governor_comments** is a plugin for Governor, allowing users and guests to
|
10
|
+
comment on your blog.
|
11
|
+
|
12
|
+
Dependencies
|
13
|
+
------------
|
14
|
+
|
15
|
+
* Governor, version 0.2.0 or higher. In addition, it requires that your User
|
16
|
+
class (or whatever classes can be associated with an article) have `name`,
|
17
|
+
`email`, and `website` fields.
|
18
|
+
* ActiveRecord
|
19
|
+
* Optional: [Rakismet](https://github.com/joshfrench/rakismet/) to integrate
|
20
|
+
Akismet spam filtering.
|
21
|
+
|
22
|
+
Setting Up
|
23
|
+
----------
|
24
|
+
|
25
|
+
First, install [Governor](http://carpeliam.github.com/governor/). Then, in
|
26
|
+
your Gemfile, add the following:
|
27
|
+
|
28
|
+
gem 'governor_comments'
|
29
|
+
|
30
|
+
Once you've installed the gem into your app, you need to run the generator:
|
31
|
+
|
32
|
+
rails generate governor:create_comments
|
33
|
+
|
34
|
+
This will create a Comment class and associated migration. Make sure to add
|
35
|
+
the `name`, `email`, and `website` fields to your User model if they don't
|
36
|
+
exist already.
|
37
|
+
|
38
|
+
Usage
|
39
|
+
-----
|
40
|
+
|
41
|
+
Now, when you browse to an article, you'll see places to add comments right in
|
42
|
+
the page. You really don't have to do anything special at this point.
|
43
|
+
|
44
|
+
Contributing to governor_comments
|
45
|
+
---------------------------------
|
46
|
+
|
47
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
48
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
49
|
+
* Fork the project
|
50
|
+
* Start a feature/bugfix branch
|
51
|
+
* Commit and push until you are happy with your contribution
|
52
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
53
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
54
|
+
|
55
|
+
Copyright
|
56
|
+
---------
|
57
|
+
|
58
|
+
Copyright © 2011 Liam Morley. See LICENSE.txt for further details.
|
59
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "governor_comments"
|
16
|
+
gem.homepage = "http://carpeliam.github.com/governor"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Comments plugin for the Rails 3-based Governor blogging system.}
|
19
|
+
gem.description = %Q{Comments plugin for the Rails 3-based Governor blogging system.}
|
20
|
+
gem.email = "liam@carpeliam.com"
|
21
|
+
gem.authors = ["Liam Morley"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "governor_comments #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Governor
|
2
|
+
class CommentsController < ApplicationController
|
3
|
+
include Governor::Controllers::Helpers
|
4
|
+
|
5
|
+
before_filter :init_resource
|
6
|
+
before_filter :authorize_commenter!, :except => [:new, :create]
|
7
|
+
before_filter :get_comment, :only => [:edit, :update, :destroy, :mark_spam, :not_spam]
|
8
|
+
|
9
|
+
helper :governor
|
10
|
+
helper Governor::Controllers::Helpers
|
11
|
+
|
12
|
+
def create
|
13
|
+
params[:comment][:commenter] = governor_logged_in? ? the_governor : Guest.new(params[:commenter])
|
14
|
+
|
15
|
+
@comment = resource.comments.new(params[:comment])
|
16
|
+
|
17
|
+
respond_to do |format|
|
18
|
+
if @comment.save
|
19
|
+
@comment.update_attribute(:hidden, true) if @comment.respond_to?(:spam) and @comment.spam?
|
20
|
+
flash[:notice] = 'Your comment was successfully added.'
|
21
|
+
format.html { redirect_to resource }
|
22
|
+
format.xml { render :xml => @comment, :status => :created, :location => @comment }
|
23
|
+
else
|
24
|
+
flash[:error] = 'There was a problem with your submission.'
|
25
|
+
format.html { render :action => "new" }
|
26
|
+
format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def edit
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
respond_to do |format|
|
36
|
+
if @comment.update_attributes(params[:comment])
|
37
|
+
flash[:notice] = 'Comment was successfully updated.'
|
38
|
+
format.html { redirect_to resource }
|
39
|
+
format.xml { head :ok }
|
40
|
+
else
|
41
|
+
format.html { render :action => "edit" }
|
42
|
+
format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def destroy
|
48
|
+
@comment.destroy
|
49
|
+
|
50
|
+
flash[:notice] = 'Comment successfully deleted.'
|
51
|
+
|
52
|
+
respond_to do |format|
|
53
|
+
format.html { redirect_to resource }
|
54
|
+
format.xml { head :ok }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def mark_spam
|
59
|
+
@comment.update_attribute(:hidden, true)
|
60
|
+
if @comment.respond_to?(:spam!)
|
61
|
+
@comment.spam!
|
62
|
+
flash[:notice] = 'That comment has been marked as spam, and will no longer be visible to other viewers. To remove it completely, you can delete it.'
|
63
|
+
else
|
64
|
+
flash[:warning] = 'Spam protection has not been installed. Please install and configure rakismet before continuing.'
|
65
|
+
end
|
66
|
+
redirect_to resource
|
67
|
+
end
|
68
|
+
|
69
|
+
def not_spam
|
70
|
+
@comment.update_attribute(:hidden, false)
|
71
|
+
if @comment.respond_to?(:ham!)
|
72
|
+
@comment.ham!
|
73
|
+
flash[:notice] = 'That comment has been marked as not spam, and will now be visible to other viewers.'
|
74
|
+
else
|
75
|
+
flash[:warning] = 'Spam protection has not been installed. Please install and configure rakismet before continuing.'
|
76
|
+
end
|
77
|
+
redirect_to resource
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_comment
|
81
|
+
@comment = resource.comments.find(params[:id])
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
def authorize_commenter!
|
86
|
+
if %(edit update destroy).include? action_name
|
87
|
+
authorize_governor!
|
88
|
+
else
|
89
|
+
redirect_to root_path unless governor_authorized?(:edit, resource)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div id="comments">
|
2
|
+
<p><%= link_to 'add a comment', '#new_comment' %></p>
|
3
|
+
<% unless resource.comments.empty? %><ul><%= render resource.comments %></ul><% end %>
|
4
|
+
<p><%= form_for [resource, resource.comments.new] do |f| %>
|
5
|
+
<%= f.error_messages %>
|
6
|
+
<% unless governor_logged_in? %>
|
7
|
+
<%= fields_for :commenter, Guest.new do |gf| %>
|
8
|
+
<%= gf.text_field :name %> <%= gf.label :name, 'Name (required)' %><br/>
|
9
|
+
<%= gf.text_field :email %> <%= gf.label :email, 'E-Mail (required, will not be published)' %><br/>
|
10
|
+
<%= gf.text_field :website %> <%= gf.label :website %><br/>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
<%= f.text_field :title %> <%= f.label :title %><br/>
|
14
|
+
<%= f.text_area :content, :size => '50x7' %>
|
15
|
+
<p><%= f.submit 'New Comment' %></p>
|
16
|
+
<% end %></p>
|
17
|
+
</div>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<% if !comment.hidden? or governor_authorized?(:edit, resource) %>
|
2
|
+
<%= content_tag_for(:li, comment, :class => cycle('odd', 'even')) do %>
|
3
|
+
<% unless comment.title.blank? %><div class="comment_title"><%= comment.title %></div><% end %>
|
4
|
+
<div class='comment_gravatar'>
|
5
|
+
<%= image_tag comment.gravatar_url, :size => '48x48', :alt => comment.commenter.name %>
|
6
|
+
</div>
|
7
|
+
<div class='comment_body'>
|
8
|
+
<%= comment.content %>
|
9
|
+
<div class='comment_footer'>
|
10
|
+
posted <%= show_time_ago comment.updated_at %> by
|
11
|
+
<%= link_to_if comment.commenter.website.present?, comment.commenter.name, comment.commenter.website %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
<% if comment.respond_to?(:spam?) and governor_authorized?(:edit, resource) %>
|
15
|
+
<div class="spam_check">
|
16
|
+
<% if comment.hidden? %>
|
17
|
+
<span class="spam_warning">This comment has been marked as spam.</span>
|
18
|
+
<%= link_to 'Not spam?', polymorphic_path([resource, comment], :action => :not_spam), :method => :put, :class => 'not_spam' %>
|
19
|
+
<%= link_to 'Delete', [resource, comment], :method => :delete, :confirm => 'Are you sure you want to remove this comment?', :class => 'delete' %>
|
20
|
+
<% else %>
|
21
|
+
<%= link_to 'Mark as spam', polymorphic_path([resource, comment], :action => :mark_spam), :method => :put, :class => 'mark_spam', :confirm => 'Are you sure this is spam?' %>
|
22
|
+
<%= link_to 'Delete', [resource, comment], :method => :delete, :confirm => 'Are you sure you want to remove this comment? It has not been marked as spam.', :class => 'delete' %>
|
23
|
+
<% end %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|