<commit_before># == Schema Information
# Schema version: 20090809211822
#
# Table name: images
#
#  id                 :integer         not null, primary key
#  image_file_name    :string(255)     
#  image_content_type :string(255)     
#  image_file_size    :integer         
#  created_at         :datetime        
#  updated_at         :datetime        
#  title              :string(255)     
#

# FIXME: Temporary location for the image styles configuration
CONFIG = {}
CONFIG[:thumbnail_size] = '60x60#'
CONFIG[:upload_images_path] = '/upload/'

class Image < ActiveRecord::Base
  default_scope :order => 'created_at DESC'
  has_attached_file :image,
                    :styles => {
                      :thumbnail => CONFIG[:thumbnail_size],
                      :icon => '80x16'
                    },
                    :path => ":rails_root/public#{CONFIG[:upload_images_path]}:attachment/:id/:style/:basename.:extension",
                    :url => "#{CONFIG[:upload_images_path]}:attachment/:id/:style/:basename.:extension"
  
  has_fulltext_search :title, :image_file_name
  acts_as_content :liquid => [:title, :image_file_name, :image]

  def self.attachment_names
    [:image]
  end
  
  # validates_presence_of :image_file_name
  validates_attachment_presence :image
  
  before_create :generate_title

  def icon_path
    image.url(:icon)
  end
  
  def url
    image.andand.url
  end

  def multiple_images=(images)
    @multiple_images ||= []
    images.each do |attributes|
      @multiple_images << Image.create(attributes) unless attributes[:image].is_a?(String)
    end
  end

  def multiple_images
    @multiple_images ||= []
  end

  def scale_to(geom='50x50')
    Paperclip::Thumbnail::new(image, :geometry => geom)
  end

  def custom_thumbnail_url(geom)
    thumb = Paperclip::Thumbnail::new(image, :geometry => geom)<commit_msg>Image#slug generation<commit_after># == Schema Information
# Schema version: 20090809211822
#
# Table name: images
#
#  id                 :integer         not null, primary key
#  image_file_name    :string(255)     
#  image_content_type :string(255)     
#  image_file_size    :integer         
#  created_at         :datetime        
#  updated_at         :datetime        
#  title              :string(255)     
#

# FIXME: Temporary location for the image styles configuration
CONFIG = {}
CONFIG[:thumbnail_size] = '60x60#'
CONFIG[:upload_images_path] = '/upload/'

class Image < ActiveRecord::Base
  default_scope :order => 'created_at DESC'
  has_attached_file :image,
                    :styles => {
                      :thumbnail => CONFIG[:thumbnail_size],
                      :icon => '80x16'
                    },
                    :path => ":rails_root/public#{CONFIG[:upload_images_path]}:attachment/:id/:style/:basename.:extension",
                    :url => "#{CONFIG[:upload_images_path]}:attachment/:id/:style/:basename.:extension"
  
  has_fulltext_search :title, :image_file_name
  acts_as_content :liquid => [:title, :image_file_name, :image, :slug]

  def self.attachment_names
    [:image]
  end
  
  # validates_presence_of :image_file_name
  validates_attachment_presence :image
  
  before_validation_on_create :generate_title


  # for slugs
  def title_from_default_locale
    image_file_name.sub(/\.[^\.]+$/, '')
  end

  def icon_path
    image.url(:icon)
  end
  
  def url
    image.andand.url
  end

  def multiple_images=(images)
    @multiple_images ||= []
    images.each do |attributes|
      @multiple_images << Image.create(attributes) unless attributes[:image].is_a?(String)
    end
  end

  def multiple_images
    @multiple_images ||= []
  end

  def scale_to(geom='50x50')
    Paperclip::Thumbnail::new(image, :geometry => geom)
  end

  def custom_thumbnail_url(geom)
    thumb = Paperclip::Thumbnail::new(image, :geometry => geom)
{'fraction_non_alphanumeric': 0.11506493506493506, 'fraction_numerical': 0.01818181818181818, 'mean_word_length': 2.753411306042885, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 21, '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': '1026090', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1197, 'n_words': 231}