<commit_before># Article type that handles uploaded files.
#
# Limitation: only file metadata are versioned. Only the latest version
# of the file itself is kept. (FIXME?)
class UploadedFile < Article

  def self.type_name
    _('File')
  end

  track_actions :upload_image, :after_create, :keep_params => ["view_url", "thumbnail_path", "parent.url", "parent.name"], :if => Proc.new { |a| a.published? && a.image? && !a.parent.nil? && a.parent.gallery? }, :custom_target => :parent

  include ShortFilename

  settings_items :title, :type => 'string'
  xss_terminate :only => [ :title ]

  def title_with_default
    title_without_default || short_filename(name, 60)
  end
  alias_method_chain :title, :default

  validates_size_of :title, :maximum => 60, :if => (lambda { |file| !file.title.blank? })

  sanitize_filename

  before_create do |uploaded_file|
    uploaded_file.is_image = true if uploaded_file.image?
  end

  def thumbnail_path
    self.image? ? self.full_filename(:display).gsub(File.join(RAILS_ROOT, 'public'), '') : nil
  end

  def display_title
    title.blank? ? name : title
  end

  def first_paragraph
    ''
  end

  def self.max_size
    UploadedFile.attachment_options[:max_size]
  end

  # FIXME need to define min/max file size
  #
  # default max_size is 1.megabyte to redefine it set options:
  #  :min_size => 2.megabytes
  #  :max_size => 5.megabytes
  has_attachment :storage => :file_system,
    :thumbnails => { :icon => [24,24], :thumb => '130x130>', :slideshow => '320x240>', :display => '640X480>' },
    :thumbnail_class => Thumbnail,
    :max_size => 5.megabytes # remember to update validate message below

  validates_attachment :size => N_("%{fn} of uploaded file was larger than the maximum size of 5.0 MB").fix_i18n

  delay_attachment_fu_thumbnails

  postgresql_attachment_fu

  def self.icon_name(article = nil)
    if article
      article.image? ? article.public_filename(:icon) : (article.mime_type ? article.mime_type.gsub(/[\/+.]/, '-') : 'upload-file')
    else
      'upload-file'
    end
  end<commit_msg>Increasing upload limit to 10mb<commit_after># Article type that handles uploaded files.
#
# Limitation: only file metadata are versioned. Only the latest version
# of the file itself is kept. (FIXME?)
class UploadedFile < Article

  def self.type_name
    _('File')
  end

  track_actions :upload_image, :after_create, :keep_params => ["view_url", "thumbnail_path", "parent.url", "parent.name"], :if => Proc.new { |a| a.published? && a.image? && !a.parent.nil? && a.parent.gallery? }, :custom_target => :parent

  include ShortFilename

  settings_items :title, :type => 'string'
  xss_terminate :only => [ :title ]

  def title_with_default
    title_without_default || short_filename(name, 60)
  end
  alias_method_chain :title, :default

  validates_size_of :title, :maximum => 60, :if => (lambda { |file| !file.title.blank? })

  sanitize_filename

  before_create do |uploaded_file|
    uploaded_file.is_image = true if uploaded_file.image?
  end

  def thumbnail_path
    self.image? ? self.full_filename(:display).gsub(File.join(RAILS_ROOT, 'public'), '') : nil
  end

  def display_title
    title.blank? ? name : title
  end

  def first_paragraph
    ''
  end

  def self.max_size
    UploadedFile.attachment_options[:max_size]
  end

  # FIXME need to define min/max file size
  #
  # default max_size is 1.megabyte to redefine it set options:
  #  :min_size => 2.megabytes
  #  :max_size => 5.megabytes
  has_attachment :storage => :file_system,
    :thumbnails => { :icon => [24,24], :thumb => '130x130>', :slideshow => '320x240>', :display => '640X480>' },
    :thumbnail_class => Thumbnail,
    :max_size => 10.megabytes # remember to update validate message below

  validates_attachment :size => N_("%{fn} of uploaded file was larger than the maximum size of 10.0 MB").fix_i18n

  delay_attachment_fu_thumbnails

  postgresql_attachment_fu

  def self.icon_name(article = nil)
    if article
      article.image? ? article.public_filename(:icon) : (article.mime_type ? article.mime_type.gsub(/[\/+.]/, '-') : 'upload-file')
    else
      'upload-file'
    end
  end
{'fraction_non_alphanumeric': 0.12729026036644167, 'fraction_numerical': 0.017357762777242044, 'mean_word_length': 3.910059171597633, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '7191270', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1378, 'n_words': 355}