<commit_before>class CommunityHubPluginPublicController < PublicController

	append_view_path File.join(File.dirname(__FILE__) + '/../../views')

	layout false


  def new_message
    if logged_in?

      begin
        hub = Article.find(params[:article_id])
      rescue
        hub = nil
      end

      if hub
        message_data = {}
        message_data.merge!(params[:message]) if params[:message]

        message = Comment.new(message_data)
        message.author = user
        message.title = message_timestamp
        message.article = hub
        message.ip_address = request.remote_ip
        message.user_agent = request.user_agent
        message.referrer = request.referrer

        if message && message.save
          render :text => {'ok' => true}.to_json, :content_type => 'application/json'
          return true
        end
      end

    end
    render :text => {'ok' => false}.to_json, :content_type => 'application/json'
  end


  def new_mediation
    if logged_in?

      begin
        profile = Profile.find(params[:profile_id])
      rescue
        profile = nil
      end

      if profile
        mediation_data = {}
        mediation_data.merge!(params[:article]) if params[:article]

        mediation = CommunityHubPlugin::Mediation.new(mediation_data)
        mediation.name = CommunityHubPlugin::Mediation.timestamp
        mediation.profile = profile
        mediation.last_changed_by = user
        mediation.created_by_id = user.id
        mediation.source = 'local'

        if mediation && mediation.save
          render :text => {'ok' => true}.to_json, :content_type => 'application/json'
          return true
        end
      end

    end
    render :text => {'ok' => false}.to_json, :content_type => 'application/json'
  end


  def newer_mediation_comment
    latest_id = params[:latest_post]
    mediation = params[:mediation]
    comments = Comment.find(:all, :conditions => ["id > :id and source_id = :mediation", { :id => latest_id, :mediation => mediation }])
    render :partial => "mediation_comment", :collection => comments
  end


	def newer_comments
		latest_post = params[:latest_post]
    hub = Article.find(params[:hub])
		posts = Comment.find(:all, :order => "id desc", :conditions => ["id > :id and source_id = :hub", { :id => latest_post, :hub => hub }], :limit => 20)

		if !posts.empty?
			oldest_post = posts.last.id
			latest_post = posts.first.id
      size = posts.size
		else
			oldest_post = 0
			latest_post = 0
		end

		render :partial => "post", :collection => posts, :locals => { :latest_id => latest_post, :oldest_id => oldest_post, :hub => hub }
	end


  def older_comments
    oldest_id = params[:oldest_id]
    hub = Article.find(params[:hub])
    posts = Comment.find(:all, :order => "id desc", :conditions => ["id < :id and source_id = :hub", { :id => oldest_id, :hub => hub }], :limit => 20)

    if !posts.empty?
      oldest_id = posts.last.id
      latest_id = posts.first.id
    end

    render :partial => "post", :collection => posts, :locals => { :latest_id => latest_id, :oldest_id => oldest_id, :hub => hub }
  end


  def newer_articles
    latest_post = params[:latest_post]
    hub = Article.find(params[:hub])
    posts = CommunityHubPlugin::Mediation.find(:all, :order => "id desc", :conditions => ["id > :id and parent_id = :hub", { :id => latest_post, :hub => hub.id }])

    if !posts.empty?
      oldest_post = posts.last.id
      latest_post = posts.first.id
    else
      oldest_post = 0
      latest_post = 0
    end<commit_msg>#community dashboard - updating theme<commit_after>class CommunityHubPluginPublicController < PublicController

	append_view_path File.join(File.dirname(__FILE__) + '/../../views')

	layout false


  def new_message
    if logged_in?

      begin
        hub = Article.find(params[:article_id])
      rescue
        hub = nil
      end

      if hub
        message_data = {}
        message_data.merge!(params[:message]) if params[:message]

        message = Comment.new(message_data)
        message.author = user
        message.title = message_timestamp
        message.article = hub
        message.ip_address = request.remote_ip
        message.user_agent = request.user_agent
        message.referrer = request.referrer

        if message && message.save
          render :text => {'ok' => true}.to_json, :content_type => 'application/json'
          return true
        end
      end

    end
    render :text => {'ok' => false}.to_json, :content_type => 'application/json'
  end


  def new_mediation
    if logged_in?

      begin
        profile = Profile.find(params[:profile_id])
      rescue
        profile = nil
      end

      if profile
        mediation_data = {}
        mediation_data.merge!(params[:article]) if params[:article]

        mediation = CommunityHubPlugin::Mediation.new(mediation_data)
        mediation.name = CommunityHubPlugin::Mediation.timestamp
        mediation.profile = profile
        mediation.last_changed_by = user
        mediation.created_by_id = user.id
        mediation.source = 'local'

        if mediation && mediation.save
          render :text => {'ok' => true}.to_json, :content_type => 'application/json'
          return true
        end
      end

    end
    render :text => {'ok' => false}.to_json, :content_type => 'application/json'
  end


  def newer_mediation_comment
    latest_id = params[:latest_post]
    mediation = params[:mediation]
    comments = Comment.find(:all, :conditions => ["id > :id and source_id = :mediation", { :id => latest_id, :mediation => mediation }])
    render :partial => "mediation_comment", :collection => comments
  end


	def newer_comments
		latest_post = params[:latest_post]
    hub = Article.find(params[:hub])
		posts = Comment.find(:all, :order => "id desc", :conditions => ["id > :id and source_id = :hub", { :id => latest_post, :hub => hub }], :limit => 30)

		if !posts.empty?
			oldest_post = posts.last.id
			latest_post = posts.first.id
      size = posts.size
		else
			oldest_post = 0
			latest_post = 0
		end

		render :partial => "post", :collection => posts, :locals => { :latest_id => latest_post, :oldest_id => oldest_post, :hub => hub }
	end


  def older_comments
    oldest_id = params[:oldest_id]
    hub = Article.find(params[:hub])
    posts = Comment.find(:all, :order => "id desc", :conditions => ["id < :id and source_id = :hub", { :id => oldest_id, :hub => hub }], :limit => 30)

    if !posts.empty?
      oldest_id = posts.last.id
      latest_id = posts.first.id
    end

    render :partial => "post", :collection => posts, :locals => { :latest_id => latest_id, :oldest_id => oldest_id, :hub => hub }
  end


  def newer_articles
    latest_post = params[:latest_post]
    hub = Article.find(params[:hub])
    posts = CommunityHubPlugin::Mediation.find(:all, :order => "id desc", :conditions => ["id > :id and parent_id = :hub", { :id => latest_post, :hub => hub.id }])

    if !posts.empty?
      oldest_post = posts.last.id
      latest_post = posts.first.id
    else
      oldest_post = 0
      latest_post = 0
    end
{'fraction_non_alphanumeric': 0.1273957158962796, 'fraction_numerical': 0.002254791431792559, 'mean_word_length': 2.7470960929250263, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 95, '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': '4267666', 'n_tokens_mistral': 2240, 'n_tokens_neox': 2143, 'n_words': 522}