<commit_before>#require 'page_extender'
require_dependency 'application'

class CommentsExtension < Radiant::Extension
  version "0.0.3"
  description "Adds blog-like comments and comment functionality to pages."
  url "http://svn.artofmission.com/svn/plugins/radiant/extensions/comments/"
  
  define_routes do |map|
    map.resources :comments, :path_prefix => "/pages/:page_id", :controller => "comments" # Regular routes for comments
    map.with_options(:controller => 'admin/comments') do |comments| 
      comments.resources :comments, :path_prefix => "/admin", :name_prefix => "admin_", :member => {:approve => :get, :unapprove => :get} # Admin routes for comments
      comments.admin_page_comments 'admin/pages/:page_id/comments;:action'  # This route allows us to nicely pull up comments for a particular page
      comments.admin_page_comment 'admin/pages/:page_id/comments/:id;:action' # This route pulls up a particular comment for a particular page
    end
  end
  
  def activate
    Page.send :include, CommentTags
    Comment
    
    Page.class_eval do
      has_many :comments, :dependent => :destroy
      has_many :approved_comments, :class_name => "Comment", :conditions => "comments.approved_at IS NOT NULL"
      has_many :unapproved_comments, :class_name => "Comment", :conditions => "comments.approved_at IS NULL"
    end
    
    if admin.respond_to? :page
      admin.page.edit.add :parts_bottom, "edit_comments_enabled", :before => "edit_timestamp"
      # admin.page.index.add :sitemap_head, "index_head_view_comments"
      # admin.page.index.add :node_row, "index_view_comments"
    end
    
    admin.tabs.add "Comments", "/admin/comments?status=unapproved", :visibility => [:all]
  end
  
  def deactivate
  end
  
end<commit_msg>Fixed the bug where an extra 'comments enabled?' checkbox was being inserted every time you edit a page, on Radiant 0.6.7.<commit_after>#require 'page_extender'
require_dependency 'application'

class CommentsExtension < Radiant::Extension
  version "0.0.3"
  description "Adds blog-like comments and comment functionality to pages."
  url "http://svn.artofmission.com/svn/plugins/radiant/extensions/comments/"
  
  define_routes do |map|
    map.resources :comments, :path_prefix => "/pages/:page_id", :controller => "comments" # Regular routes for comments
    map.with_options(:controller => 'admin/comments') do |comments| 
      comments.resources :comments, :path_prefix => "/admin", :name_prefix => "admin_", :member => {:approve => :get, :unapprove => :get} # Admin routes for comments
      comments.admin_page_comments 'admin/pages/:page_id/comments;:action'  # This route allows us to nicely pull up comments for a particular page
      comments.admin_page_comment 'admin/pages/:page_id/comments/:id;:action' # This route pulls up a particular comment for a particular page
    end
  end
  
  def activate
    Page.send :include, CommentTags
    Comment
    
    Page.class_eval do
      has_many :comments, :dependent => :destroy
      has_many :approved_comments, :class_name => "Comment", :conditions => "comments.approved_at IS NOT NULL"
      has_many :unapproved_comments, :class_name => "Comment", :conditions => "comments.approved_at IS NULL"
    end
    
    if admin.respond_to? :page
      unless admin.page.edit[:parts_bottom].include?( "edit_comments_enabled" )
        admin.page.edit.add :parts_bottom, "edit_comments_enabled", :before => "edit_timestamp"
      end
      # admin.page.index.add :sitemap_head, "index_head_view_comments"
      # admin.page.index.add :node_row, "index_view_comments"
    end
    
    admin.tabs.add "Comments", "/admin/comments?status=unapproved", :visibility => [:all]
  end
  
  def deactivate
  end
  
end
{'fraction_non_alphanumeric': 0.11417850442240686, 'fraction_numerical': 0.0024122219244170464, 'mean_word_length': 4.0296495956873315, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '75570', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1109, 'n_words': 297}