<commit_before># Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class Admin::RegistryController < AdminController
  
  def index
    
  end
  
  def viewport
    @root = Registry.root
    render :layout => false
  end
  
  def delete_folder
    node = Registry.find_by_id(params[:node]) unless params[:node].index("xnode")
    node.destroy if node
    render :text => "done"
  end
  
  def folders
    folders = []
    node = Registry.root if params[:node] == Registry::ROOT_KEY
    node = Registry.find_by_id(params[:node]) unless node
    node.folders.each do |child|
      folders << child.to_folder_hash
    end
    render :text => folders.to_json
  end
  
  def folder
    results = {:success => true, :total => 1, :folders => []}
    if request.post?
      if params[:folder_id].blank? or params[:folder_id].index('xnode')
        parent = Registry.find_by_id(params[:parent_id])
        parent = Registry.root unless parent
        fld = Registry.create(params[:folder].merge(:folder => true, :parent => parent))
      else
        fld = Registry.find(params[:folder_id])
        fld.update_attributes(params[:folder].merge(:folder => true))
        fld.regenerate_properties_keys!
      end
    else
      fld = Registry.find_by_id(params[:folder_id]) unless params[:folder_id].blank?
      fld = Registry.new(:label => "New Folder") unless fld
    end
 
    results[:folders] << fld.to_folder_hash
    render :text => results.to_json
  end  
  
  def property
    results = {:success => true, :total => 1, :properties => []}
    
    if request.post?
      if params[:prop_id].blank?
        parent = Registry.find_by_id(params[:parent_id])
        parent = Registry.root unless parent
        prop = Registry.create(params[:property].merge(:parent => parent))
      else
        prop = Registry.find(params[:prop_id])
        prop.update_attributes(params[:property])
      end
      prop.generate_key!
    else
      prop = Registry.find_by_id(params[:prop_id]) unless params[:prop_id].blank?
      prop = Registry.new unless prop
    end
 
    results[:properties] << prop.to_property_hash(false)
    render :text => results.to_json
  end
  
  def properties
    results = {:success => true, :total => 0, :properties => []}
  
    if request.get?
      node = Registry.find_by_id(params[:node]) unless (params[:node] and params[:node] == 'root')
      node = Registry.root unless node
      node.properties.each do |item|
        results[:properties] << item.to_property_hash
      end
      results[:total] = node.children.size
      
    elsif request.put?
      item = Registry.find_by_id(params[:properties][:id])
      item.update_attributes("#{Rails.env}_value" => params[:properties][:value])
      results[:properties] << item.to_property_hash
      results[:total] = 1
      
    elsif request.delete?
      node = Registry.find_by_id(params[:properties])
      node.destroy if node
    end
    
    render :text => results.to_json
  end
  
  def export
    Registry.export!("config/registry.yml")
    send_file("config/registry.yml", :type=>"text/yml", :filename => "registry.yml")    
  end

  def import
    Registry.import!("config/registry.yml")
    redirect_to :action => :viewport
  end
  
  def reset_defaults
    Registry.reset(Rails.env)
    redirect_to :action => :viewport
  end
  
private

  def selected_root_key
    return Registry.find_by_id(params[:key_id]) if params[:key_id]
    Registry.root
  end

  
end
<commit_msg>removed default names<commit_after># Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class Admin::RegistryController < AdminController
  
  def index
    
  end
  
  def viewport
    @root = Registry.root
    render :layout => false
  end
  
  def delete_folder
    node = Registry.find_by_id(params[:node]) unless params[:node].index("xnode")
    node.destroy if node
    render :text => "done"
  end
  
  def folders
    folders = []
    node = Registry.root if params[:node] == Registry::ROOT_KEY
    node = Registry.find_by_id(params[:node]) unless node
    node.folders.each do |child|
      folders << child.to_folder_hash
    end
    render :text => folders.to_json
  end
  
  def folder
    results = {:success => true, :total => 1, :folders => []}
    if request.post?
      if params[:folder_id].blank? or params[:folder_id].index('xnode')
        parent = Registry.find_by_id(params[:parent_id])
        parent = Registry.root unless parent
        fld = Registry.create(params[:folder].merge(:folder => true, :parent => parent))
      else
        fld = Registry.find(params[:folder_id])
        fld.update_attributes(params[:folder].merge(:folder => true))
        fld.regenerate_properties_keys!
      end
    else
      fld = Registry.find_by_id(params[:folder_id]) unless params[:folder_id].blank?
      fld = Registry.new(:key => "", :label => "") unless fld
    end
 
    results[:folders] << fld.to_folder_hash
    render :text => results.to_json
  end  
  
  def property
    results = {:success => true, :total => 1, :properties => []}
    
    if request.post?
      if params[:prop_id].blank?
        parent = Registry.find_by_id(params[:parent_id])
        parent = Registry.root unless parent
        prop = Registry.create(params[:property].merge(:parent => parent))
      else
        prop = Registry.find(params[:prop_id])
        prop.update_attributes(params[:property])
      end
      prop.generate_key!
    else
      prop = Registry.find_by_id(params[:prop_id]) unless params[:prop_id].blank?
      prop = Registry.new unless prop
    end
 
    results[:properties] << prop.to_property_hash(false)
    render :text => results.to_json
  end
  
  def properties
    results = {:success => true, :total => 0, :properties => []}
  
    if request.get?
      node = Registry.find_by_id(params[:node]) unless (params[:node] and params[:node] == 'root')
      node = Registry.root unless node
      node.properties.each do |item|
        results[:properties] << item.to_property_hash
      end
      results[:total] = node.children.size
      
    elsif request.put?
      item = Registry.find_by_id(params[:properties][:id])
      item.update_attributes("#{Rails.env}_value" => params[:properties][:value])
      results[:properties] << item.to_property_hash
      results[:total] = 1
      
    elsif request.delete?
      node = Registry.find_by_id(params[:properties])
      node.destroy if node
    end
    
    render :text => results.to_json
  end
  
  def export
    Registry.export!("config/registry.yml")
    send_file("config/registry.yml", :type=>"text/yml", :filename => "registry.yml")    
  end

  def import
    Registry.import!("config/registry.yml")
    redirect_to :action => :viewport
  end
  
  def reset_defaults
    Registry.reset(Rails.env)
    redirect_to :action => :viewport
  end
  
private

  def selected_root_key
    return Registry.find_by_id(params[:key_id]) if params[:key_id]
    Registry.root
  end

  
end

{'fraction_non_alphanumeric': 0.12104230876996358, 'fraction_numerical': 0.0011207621182404036, 'mean_word_length': 2.999439775910364, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 54, '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': '6261301', 'n_tokens_mistral': 2255, 'n_tokens_neox': 2157, 'n_words': 499}