Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mpatric/badass
base: ec1776b948
...
head fork: mpatric/badass
compare: abab5fc0fd
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 11 files changed
  • 0 commit comments
  • 1 contributor
View
2  app/controllers/admin/posts_controller.rb
@@ -56,7 +56,7 @@ def update
old_tags = @post.tags.collect(&:id).sort
@post.attributes = params[:post].merge({:tags => parse_tag_ids(params[:tag_ids])})
new_tags = @post.tags.collect(&:id).sort
- did_change = @post.changed?
+ did_change = @post.change_to_bump_version?
@post.version_draft += 1 if did_change
updates = []
updates << 'post' if did_change
View
8 app/controllers/home_controller.rb
@@ -26,8 +26,12 @@ def post
@all_posts = Post.published.by_last_published.select{ |p| !(p.tags & @post.tags).empty? }.reject{ |p| p == @post }
if !params[:comment]
@comment = Comment.new
- elsif APP_CONFIG.comments_disabled
- render_404
+ elsif APP_CONFIG.comments_disabled or !@post.comments_open?
+ if @post.published?
+ redirect_to(@post.permalink_url)
+ else
+ render_404
+ end
return
else
# create comment
View
6 app/models/post.rb
@@ -76,7 +76,11 @@ def publish!(quiet=false)
true
end
- private
+ def change_to_bump_version?
+ self.changed? and (self.content_draft_changed? or self.title_draft_changed?)
+ end
+
+ private
def generate_permalink
return unless self.permalink.blank?
return if self.date.blank? or self.title_draft.blank?
View
4 app/views/admin/posts/_form.html.erb
@@ -28,6 +28,10 @@
<%= form.text_field :permalink %>
</div>
<div>
+ <%= form.label :comments_open, 'Comments' %>
+ <%= form.check_box :comments_open %> Open
+</div>
+<div>
<%= form.label :content_draft, 'Content' %>
<%= form.text_area :content_draft, :id => 'markItUp' %>
</div>
View
2  app/views/admin/posts/index.html.erb
@@ -19,6 +19,7 @@
<th>Title</th>
<th>Tags</th>
<th>Posted by</th>
+ <th>Comments open</th>
<th>Comments</th>
</tr>
<% @posts.each do |post| %>
@@ -45,6 +46,7 @@
<% end %>
</td>
<td><%= post.user.name %></td>
+ <td><%= post.comments_open? ? 'Yes' : 'No' %></td>
<td><%= comment_count_link(post) %></td>
</tr>
<% end %>
View
3  app/views/admin/posts/show.html.erb
@@ -36,6 +36,9 @@
<label>Version:</label><%= @post.version_draft %>
</span>
<span>
+ <label>Comments open:</label><%= @post.comments_open? ? 'Yes' : 'No' %>
+ </span>
+ <span>
<label>Comments:</label><%= comment_count_link(@post) %>
</span>
<span>
View
4 app/views/home/post.html.erb
@@ -40,8 +40,8 @@
</ul>
</div>
<% end %>
-<% if comments_disabled? %>
- <p>Posting comments currently disabled.</p>
+<% if comments_disabled? or !@post.comments_open? %>
+ <p class='closed-for-comments'>Post closed for comments</p>
<% else %>
<% if flash[:notice] %>
<p class='notice'><%= flash[:notice] %></p>
View
2  badass.gemspec
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.add_runtime_dependency(%q<rails>, ["3.0.9"])
+ s.add_runtime_dependency(%q<rails>, ["3.0.11"])
s.add_runtime_dependency(%q<mysql2>, ["0.2.11"])
s.add_runtime_dependency(%q<rake>, ["0.8.7"])
s.add_runtime_dependency(%q<authlogic>, ["3.0.3"])
View
1  lib/generators/badass/migrations_generator.rb
@@ -14,6 +14,7 @@ def generate_migrations
generate_migration('create_assets')
generate_migration('create_tags')
generate_migration('create_posts_tags')
+ generate_migration('add_comments_open_to_posts')
end
private
View
9 lib/generators/badass/templates/migrations/add_comments_open_to_posts.rb
@@ -0,0 +1,9 @@
+class AddCommentsOpenToPosts < ActiveRecord::Migration
+ def self.up
+ add_column :posts, :comments_open, :boolean, :default => true
+ end
+
+ def self.down
+ remove_column :posts, :comments_open
+ end
+end
View
3  public/stylesheets/sass/_badass-site.sass
@@ -177,3 +177,6 @@ div.titlebar
:height 38px
:line-height 15px
:text-indent 16px
+
+p.closed-for-comments
+ :color $myblue

No commit comments for this range

Something went wrong with that request. Please try again.