<commit_before># Title: git_mod.rb
# Author: <NAME>, @cboettig
# Licence: MIT
# Description: A custom filter to return the date that git has for the page modification time 
# 
# REQUIREMENTS: Uses `path` variable set in the base_name.rb plugin
#
# Example use: 
#
# 

require 'git'
module Jekyll
  class RawContent < Generator
    def generate(site)

      puts "Getting date modified and sha data from git"
      g = Git.open("/home/cboettig/Documents/labnotebook")

      ## Loop over posts 
      site.posts.each do |post|
        begin
          path = '_posts/' + post.name
          modified = g.log(1).object(path).first.date
          sha = g.log(1).object(path).first.sha
        rescue Exception => e 
          modified = Time.now 
          sha = "not yet committed" 
        end
        post.data['sha'] = sha
        post.data['modified'] = modified
      end
      ## Loop over pages 
      site.pages.each do |page|
        begin
          path = page.dir + page.name
          modified = g.log(1).object(path).first.date
          sha = g.log(1).object(path).first.sha
        rescue Exception => e 
          modified = Time.now 
          sha = "not yet committed" 
        end
        page.data['sha'] = sha
        page.data['modified'] = modified
      end



    end
  end
end
<commit_msg>handle modification dates and sha hashes correctly for all pages<commit_after># Title: git_mod.rb
# Author: <NAME>, @cboettig
# Licence: MIT
# Description: A custom filter to return the date that git has for the page modification time 
# 
# REQUIREMENTS: Uses `path` variable set in the base_name.rb plugin
#
# Example use: 
#
# 

require 'git'
module Jekyll
  class RawContent < Generator
    def generate(site)

      puts "Getting date modified and sha data from git"
      g = Git.open("/home/cboettig/Documents/labnotebook")

      ## Loop over posts 
      site.posts.each do |post|
        begin
          path = '_posts/' + post.name
          modified = g.log(1).object(path).first.date
          sha = g.log(1).object(path).first.sha
        rescue Exception => e 
          modified = Time.now 
          sha = "not yet committed" 
        end
        post.data['sha'] = sha
        post.data['modified'] = modified
      end
      ## Loop over pages 
      site.pages.each do |page|
        begin
          path = File.join(".", page.dir, page.name)
          puts path
          modified = g.log(1).object(path).first.date
          sha = g.log(1).object(path).first.sha
        rescue Exception => e 
          modified = Time.now 
          sha = "not yet committed" 
        end
        page.data['sha'] = sha
        page.data['modified'] = modified
      end



    end
  end
end

{'fraction_non_alphanumeric': 0.1059040590405904, 'fraction_numerical': 0.002952029520295203, 'mean_word_length': 1.9856828193832599, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '7585918', 'n_tokens_mistral': 833, 'n_tokens_neox': 799, 'n_words': 244}