<commit_before>class EntriesController < ApplicationController
  before_filter :find_blog
  
  layout 'hotink'
  
  def new
    @entry = @account.entries.build 
    
    # Check to see if the last entry created for this blog exists and is blank.
    # If so, redate it and serve it up instead of a new entry, to prevent
    # the data from becoming cluttered with abandoned entries.
    #
    # If the last entry was legit, save the fresh entry so it can have relationships 
   if last_blog_entry = @blog.entries.find(:last)
     if last_blog_entry.created_at == last_blog_entry.updated_at
        @entry = last_blog_entry
         @entry.date = Time.now #Give it the current time, without saving.
     else
        @entry.save
        @blog.entries << @entry
     end
   else
      @entry.save
      @blog.entries << @entry
   end
       
      respond_to do |format|
        if @entry.save 
          flash[:notice] = "New blog entry"
          format.html { redirect_to edit_account_blog_entry_url(@account, @blog, @entry) }
          format.xml  { render :xml => @entry }
        else
          flash[:notice] = "Error saving entry"
          format.html { redirect_to account_blog_url(@account, @blog) }
        end
      end
  end
  
  def edit
    @entry = @blog.entries.find(params[:id])
  end
  
  def update
    @entry = @blog.entries.find(params[:id])<commit_msg>Added index/show methods for blog entries into the API<commit_after>class EntriesController < ApplicationController
  before_filter :find_blog
  
  layout 'hotink'
  
  def new
    @entry = @account.entries.build 
    
    # Check to see if the last entry created for this blog exists and is blank.
    # If so, redate it and serve it up instead of a new entry, to prevent
    # the data from becoming cluttered with abandoned entries.
    #
    # If the last entry was legit, save the fresh entry so it can have relationships 
   if last_blog_entry = @blog.entries.find(:last)
     if last_blog_entry.created_at == last_blog_entry.updated_at
        @entry = last_blog_entry
         @entry.date = Time.now #Give it the current time, without saving.
     else
        @entry.save
        @blog.entries << @entry
     end
   else
      @entry.save
      @blog.entries << @entry
   end
       
      respond_to do |format|
        if @entry.save 
          flash[:notice] = "New blog entry"
          format.html { redirect_to edit_account_blog_entry_url(@account, @blog, @entry) }
          format.xml  { render :xml => @entry }
        else
          flash[:notice] = "Error saving entry"
          format.html { redirect_to account_blog_url(@account, @blog) }
        end
      end
  end
  
  def edit
    @entry = @blog.entries.find(params[:id])
  end
  
  def index
    @entries = @blog.entries.find(:all)
    
    respond_to do |format|
      format.xml {
        render :xml => @entries
      }
    end
  end
  
  def show
    @entry = @blog.entries.find(params[:id])
    
    respond_to do |format|
      format.xml {
        render :xml => @entry
      }
    end    
  end
  
  def update
    @entry = @blog.entries.find(params[:id])
{'fraction_non_alphanumeric': 0.08699839486356341, 'fraction_numerical': 0.0, 'mean_word_length': 2.2662473794549265, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '2632499', 'n_tokens_mistral': 938, 'n_tokens_neox': 927, 'n_words': 293}