<commit_before>class Embeddable::InnerPagesController < ApplicationController
  # GET /Embeddable/inner_pages
  # GET /Embeddable/inner_pages.xml
  def index    
    @inner_pages = Embeddable::InnerPage.search(params[:search], params[:page], nil)
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @inner_pages}
    end
  end

  
  def add_page
    @inner_page = Embeddable::InnerPage.find(params['id'])
    @new_page = Page.create
    @new_page.user = current_user
    @inner_page << @new_page
    render :partial => "page", :locals => {:sub_page => @new_page, :inner_page => @inner_page}
  end
  
  def delete_page
    @inner_page = Embeddable::InnerPage.find(params['id'])
    @page = Page.find(params['page_id'])
    last_number = @page.page_number
    last_number = last_number - 1 
    @inner_page.delete_page(@page)
    last_number = last_number > 1 ? (last_number -1) : 0
    @page = @inner_page.sub_pages[last_number]
    render :partial => "page", :locals => {:sub_page => @inner_page.sub_pages[last_number], :inner_page => @inner_page}
  end

  def set_page
    @inner_page = Embeddable::InnerPage.find(params['id'])
    @page = Page.find(params['page_id'])
    render :partial => "page", :locals => {:sub_page => @page, :inner_page => @inner_page}
  end


  ##
  ## TODO: This code was copy/pasted from the pages controller.
  ## TODO: It should be DRYd up a bit.
  ## This is a remote_function (ajax) to be called with link_to_remote or similar. 
  ## We expect parameters "page_id" and "closs_name"
  ## optional parameter "container" tells us what DOM ID to add our results too...
  ##
  def add_element
    @inner_page = Embeddable::InnerPage.find(params['id'])
    @page = Page.find(params['page_id'])
    @container = params['container'] || 'elements_container'

    # dynamically instantiate the component based on its type.
    component_class = params['class_name'].constantize
    if component_class == DataCollector
      if probe_type_id = session[:last_saved_probe_type_id]
        probe_type = Probe::ProbeType.find(probe_type_id)
        @component = Embeddable::DataCollector.new
        @component.probe_type = probe_type<commit_msg>fix: one location DataCollector wasn't processed<commit_after>class Embeddable::InnerPagesController < ApplicationController
  # GET /Embeddable/inner_pages
  # GET /Embeddable/inner_pages.xml
  def index    
    @inner_pages = Embeddable::InnerPage.search(params[:search], params[:page], nil)
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @inner_pages}
    end
  end

  
  def add_page
    @inner_page = Embeddable::InnerPage.find(params['id'])
    @new_page = Page.create
    @new_page.user = current_user
    @inner_page << @new_page
    render :partial => "page", :locals => {:sub_page => @new_page, :inner_page => @inner_page}
  end
  
  def delete_page
    @inner_page = Embeddable::InnerPage.find(params['id'])
    @page = Page.find(params['page_id'])
    last_number = @page.page_number
    last_number = last_number - 1 
    @inner_page.delete_page(@page)
    last_number = last_number > 1 ? (last_number -1) : 0
    @page = @inner_page.sub_pages[last_number]
    render :partial => "page", :locals => {:sub_page => @inner_page.sub_pages[last_number], :inner_page => @inner_page}
  end

  def set_page
    @inner_page = Embeddable::InnerPage.find(params['id'])
    @page = Page.find(params['page_id'])
    render :partial => "page", :locals => {:sub_page => @page, :inner_page => @inner_page}
  end


  ##
  ## TODO: This code was copy/pasted from the pages controller.
  ## TODO: It should be DRYd up a bit.
  ## This is a remote_function (ajax) to be called with link_to_remote or similar. 
  ## We expect parameters "page_id" and "closs_name"
  ## optional parameter "container" tells us what DOM ID to add our results too...
  ##
  def add_element
    @inner_page = Embeddable::InnerPage.find(params['id'])
    @page = Page.find(params['page_id'])
    @container = params['container'] || 'elements_container'

    # dynamically instantiate the component based on its type.
    component_class = params['class_name'].constantize
    if component_class == Embeddable::DataCollector
      if probe_type_id = session[:last_saved_probe_type_id]
        probe_type = Probe::ProbeType.find(probe_type_id)
        @component = Embeddable::DataCollector.new
        @component.probe_type = probe_type
{'fraction_non_alphanumeric': 0.1250280080663231, 'fraction_numerical': 0.0017925162446784674, 'mean_word_length': 3.9162995594713657, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '6535676', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1454, 'n_words': 336}