<commit_before>module Jekyll
  class FridgePage < Page
    def initialize(site, base, dir, content, config)
      @site = site
      @base = base
      @dir = dir
      @name = "index.html"

      self.process(@name)
      if content.attrs.has_key?(:template)
        self.read_yaml_from_string(content.template)
      else
        self.read_yaml(File.join(base, '_layouts'), config['layout'])
      end

      self.data[config['type']] = Jekyll::Fridge::Model.new(content)
      self.data['title'] = content.title
    end

    def read_yaml_from_string(str)
      begin
        self.content = str
        if content =~ /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
          self.content = $POSTMATCH
          self.data = SafeYAML.load($1)
        end
      rescue SyntaxError => e
        Jekyll.logger.warn "YAML Exception reading custom layout: #{e.message}"
      end

      self.data ||= {}
    end
  end

  class FridgePageGenerator < Generator
    safe true
    priority :lowest

    def generate(site)
      client = site.config['fridge']
      site.config['fridge_collections'].each do |type, options|
        options = {
          'type' => type,
          'query' => "content?type=#{type}",
          'path' => type,
          'layout' => "#{type}.html"
        }.merge(options || {})

        client.get(options['query']).each do |document|
          slug = document.slug == 'index' ? '' : document.slug<commit_msg>skip generating pages if there aren't any setup<commit_after>module Jekyll
  class FridgePage < Page
    def initialize(site, base, dir, content, config)
      @site = site
      @base = base
      @dir = dir
      @name = "index.html"

      self.process(@name)
      if content.attrs.has_key?(:template)
        self.read_yaml_from_string(content.template)
      else
        self.read_yaml(File.join(base, '_layouts'), config['layout'])
      end

      self.data[config['type']] = Jekyll::Fridge::Model.new(content)
      self.data['title'] = content.title
    end

    def read_yaml_from_string(str)
      begin
        self.content = str
        if content =~ /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
          self.content = $POSTMATCH
          self.data = SafeYAML.load($1)
        end
      rescue SyntaxError => e
        Jekyll.logger.warn "YAML Exception reading custom layout: #{e.message}"
      end

      self.data ||= {}
    end
  end

  class FridgePageGenerator < Generator
    safe true
    priority :lowest

    def generate(site)
      return if site.config['fridge_collections'].nil?

      client = site.config['fridge']
      site.config['fridge_collections'].each do |type, options|
        options = {
          'type' => type,
          'query' => "content?type=#{type}",
          'path' => type,
          'layout' => "#{type}.html"
        }.merge(options || {})

        client.get(options['query']).each do |document|
          slug = document.slug == 'index' ? '' : document.slug
{'fraction_non_alphanumeric': 0.15285326086956522, 'fraction_numerical': 0.0006793478260869565, 'mean_word_length': 2.208061002178649, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '500075', 'n_tokens_mistral': 941, 'n_tokens_neox': 922, 'n_words': 193}