pax_global_header 0000666 0000000 0000000 00000000064 14627657067 0014536 g ustar 00root root 0000000 0000000 52 comment=3052cbe5fdf550dd1e85ed8eb7ec7a5595cd9f1d jekyll-last-modified-at-1.3.2/ 0000775 0000000 0000000 00000000000 14627657067 0016154 5 ustar 00root root 0000000 0000000 jekyll-last-modified-at-1.3.2/.github/ 0000775 0000000 0000000 00000000000 14627657067 0017514 5 ustar 00root root 0000000 0000000 jekyll-last-modified-at-1.3.2/.github/FUNDING.yml 0000664 0000000 0000000 00000001060 14627657067 0021326 0 ustar 00root root 0000000 0000000 # These are supported funding model platforms github: gjtorikian # patreon: gjtorikian # open_collective: garen-torikian #ko_fi: # Replace with a single Ko-fi username #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel #community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry #liberapay: # Replace with a single Liberapay username # issuehunt: gjtorikian #otechie: # Replace with a single Otechie username #custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] jekyll-last-modified-at-1.3.2/.github/dependabot.yml 0000664 0000000 0000000 00000001034 14627657067 0022342 0 ustar 00root root 0000000 0000000 version: 2 updates: - package-ecosystem: "github-actions" directory: "/" schedule: interval: weekly day: monday time: "09:00" timezone: "Etc/UTC" groups: github-actions: patterns: - "*" open-pull-requests-limit: 10 - package-ecosystem: bundler directory: "/" schedule: interval: weekly day: monday time: "09:00" timezone: "Etc/UTC" open-pull-requests-limit: 10 groups: bundler-dependencies: patterns: - "*" jekyll-last-modified-at-1.3.2/.github/workflows/ 0000775 0000000 0000000 00000000000 14627657067 0021551 5 ustar 00root root 0000000 0000000 jekyll-last-modified-at-1.3.2/.github/workflows/automerge.yml 0000664 0000000 0000000 00000000436 14627657067 0024267 0 ustar 00root root 0000000 0000000 name: "Bot auto-{approve,merge}" on: workflow_dispatch: pull_request_target: permissions: pull-requests: write contents: write jobs: dependabot: uses: yettoapp/actions/.github/workflows/automerge_dependabot.yml@main secrets: inherit with: automerge: true jekyll-last-modified-at-1.3.2/.github/workflows/lint.yml 0000664 0000000 0000000 00000000545 14627657067 0023246 0 ustar 00root root 0000000 0000000 name: Linting on: pull_request: paths: - "**/*.rb" permissions: contents: read jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Ruby uses: yettoapp/actions/setup-languages@main with: ruby: true - name: Rubocop run: bundle exec rake rubocop jekyll-last-modified-at-1.3.2/.github/workflows/tag_and_release.yml 0000664 0000000 0000000 00000001327 14627657067 0025374 0 ustar 00root root 0000000 0000000 name: Release on: workflow_dispatch: push: branches: - main paths: - "lib/jekyll-last-modified-at/version.rb" pull_request_target: types: - closed jobs: ruby: uses: yettoapp/actions/.github/workflows/ruby_gem_release.yml@main secrets: rubygems_api_key: ${{ secrets.RUBYGEMS_API_BOT_KEY }} gh_token: ${{ secrets.GITHUB_TOKEN }} with: gem_name: jekyll-last-modified-at version_filepath: lib/jekyll-last-modified-at/version.rb prepare: ${{ github.event_name == 'push' }} release: ${{ github.event_name == 'workflow_dispatch' || ((github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'release'))) }} jekyll-last-modified-at-1.3.2/.github/workflows/test.yml 0000664 0000000 0000000 00000001064 14627657067 0023254 0 ustar 00root root 0000000 0000000 name: CI on: pull_request: permissions: contents: read jobs: test: runs-on: ubuntu-latest steps: - if: "${{ contains(github.event.pull_request.title, '[skip test]') }}" name: Skip test shell: bash run: | echo "Skipping test workflow because commit message contains `[skip test]`" exit 0 - uses: actions/checkout@v4 - name: Set up Ruby uses: yettoapp/actions/setup-languages@main with: ruby: true - name: Run tests run: bundle exec rake test jekyll-last-modified-at-1.3.2/.gitignore 0000664 0000000 0000000 00000000253 14627657067 0020144 0 ustar 00root root 0000000 0000000 *.gem _site/ Gemfile.lock spec/fixtures/_posts/1992-09-11-last-modified-at.md spec/fixtures/.jekyll-metadata spec/fixtures/.jekyll-cache spec/dev/out.txt spec/dev/err.txt jekyll-last-modified-at-1.3.2/.rubocop.yml 0000664 0000000 0000000 00000000406 14627657067 0020426 0 ustar 00root root 0000000 0000000 inherit_gem: rubocop-standard: - config/default.yml - config/minitest.yml inherit_mode: merge: - Exclude AllCops: Exclude: - test/progit/**/* - "pkg/**/*" - "ext/**/*" - "vendor/**/*" - "tmp/**/*" - "test/progit/**/*" jekyll-last-modified-at-1.3.2/.ruby-version 0000664 0000000 0000000 00000000006 14627657067 0020615 0 ustar 00root root 0000000 0000000 3.2.1 jekyll-last-modified-at-1.3.2/.vscode/ 0000775 0000000 0000000 00000000000 14627657067 0017515 5 ustar 00root root 0000000 0000000 jekyll-last-modified-at-1.3.2/.vscode/settings.json 0000664 0000000 0000000 00000000120 14627657067 0022241 0 ustar 00root root 0000000 0000000 { "[ruby]": { "editor.defaultFormatter": "Shopify.ruby-lsp" } } jekyll-last-modified-at-1.3.2/CHANGELOG.md 0000664 0000000 0000000 00000001010 14627657067 0017755 0 ustar 00root root 0000000 0000000 # [v1.3.2] - 04-06-2024 ## What's Changed * Modernize project by @gjtorikian in https://github.com/gjtorikian/jekyll-last-modified-at/pull/99 * lint by @gjtorikian in https://github.com/gjtorikian/jekyll-last-modified-at/pull/100 * :gem: 1.3.1 by @gjtorikian in https://github.com/gjtorikian/jekyll-last-modified-at/pull/101 * :gem: 1.3.2 by @gjtorikian in https://github.com/gjtorikian/jekyll-last-modified-at/pull/102 **Full Changelog**: https://github.com/gjtorikian/jekyll-last-modified-at/compare/v1.3.0...v1.3.2 jekyll-last-modified-at-1.3.2/Gemfile 0000664 0000000 0000000 00000000204 14627657067 0017443 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true source "https://rubygems.org" gemspec gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"] jekyll-last-modified-at-1.3.2/LICENSE.txt 0000664 0000000 0000000 00000002074 14627657067 0020002 0 ustar 00root root 0000000 0000000 The MIT License (MIT) Copyright (c) 2024 Garen J. Torikian Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jekyll-last-modified-at-1.3.2/README.md 0000664 0000000 0000000 00000002722 14627657067 0017436 0 ustar 00root root 0000000 0000000 # Last Modified At Plugin A liquid tag for Jekyll to indicate the last time a file was modified. This plugin determines a page's last modified date by checking the last Git commit date of source files. In the event Git is not available, the file's `mtime` is used. ## Setting up Open your Gemfile in your Jekyll root folder and add the following: ``` ruby group :jekyll_plugins do gem "jekyll-last-modified-at" end ``` Add the following to your site's `_config.yml` file ```yml plugins: - jekyll-last-modified-at # Optional. The default date format, used if none is specified in the tag. last-modified-at: date-format: '%d-%b-%y' ``` ## Usage There are a few ways to use this gem. You can place the following tag somewhere within your layout: ``` liquid {% last_modified_at %} ``` By default, this creates a time format matching `"%d-%b-%y"` (like "04-Jan-14"). You can also choose to pass along your own time format. For example: ```liquid {% last_modified_at %Y:%B:%A:%d:%S:%R %} ``` That produces "2014:January:Saturday:04." You can also call the method directly on a Jekyll "object," like so: ``` liquid {{ page.last_modified_at }} ``` To format such a time, you'll need to rely on Liquid's `date` filter: ``` liquid {{ page.last_modified_at | date: '%Y:%B:%A:%d:%S:%R' }} ``` (It's generally [more performant to use the `page.last_modified_at` version](https://github.com/gjtorikian/jekyll-last-modified-at/issues/24#issuecomment-55431108) of this plugin.) jekyll-last-modified-at-1.3.2/Rakefile 0000775 0000000 0000000 00000001001 14627657067 0017614 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true require "bundler" Bundler::GemHelper.install_tasks require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) desc "Test the project" task :test do Rake::Task["spec"].invoke end require "rubocop/rake_task" RuboCop::RakeTask.new(:rubocop) require "bundler/gem_tasks" require "rubygems/package_task" GEMSPEC = Bundler.load_gemspec("jekyll-last-modified-at.gemspec") gem_path = Gem::PackageTask.new(GEMSPEC).define desc "Package the ruby gem" task "package" => [gem_path] jekyll-last-modified-at-1.3.2/jekyll-last-modified-at.gemspec 0000664 0000000 0000000 00000001512 14627657067 0024133 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true require File.expand_path("lib/jekyll-last-modified-at/version.rb", __dir__) Gem::Specification.new do |s| s.name = "jekyll-last-modified-at" s.version = Jekyll::LastModifiedAt::VERSION s.summary = "A liquid tag for Jekyll to indicate the last time a file was modified." s.authors = "Garen J. Torikian" s.homepage = "https://github.com/gjtorikian/jekyll-last-modified-at" s.license = "MIT" s.files = Dir["lib/**/*.rb"] s.add_dependency("jekyll", ">= 3.7", " < 5.0") s.add_development_dependency("rake") s.add_development_dependency("rspec", "~> 3.4") s.add_development_dependency("rubocop") s.add_development_dependency("rubocop-standard") s.add_development_dependency("spork") end jekyll-last-modified-at-1.3.2/lib/ 0000775 0000000 0000000 00000000000 14627657067 0016722 5 ustar 00root root 0000000 0000000 jekyll-last-modified-at-1.3.2/lib/jekyll-last-modified-at.rb 0000664 0000000 0000000 00000000666 14627657067 0023672 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true module Jekyll module LastModifiedAt require "jekyll-last-modified-at/tag" require "jekyll-last-modified-at/hook" autoload :VERSION, "jekyll-last-modified-at/version" autoload :Executor, "jekyll-last-modified-at/executor" autoload :Determinator, "jekyll-last-modified-at/determinator" autoload :Git, "jekyll-last-modified-at/git" PATH_CACHE = {} REPO_CACHE = {} end end jekyll-last-modified-at-1.3.2/lib/jekyll-last-modified-at/ 0000775 0000000 0000000 00000000000 14627657067 0023335 5 ustar 00root root 0000000 0000000 jekyll-last-modified-at-1.3.2/lib/jekyll-last-modified-at/determinator.rb 0000664 0000000 0000000 00000004320 14627657067 0026356 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true module Jekyll module LastModifiedAt class Determinator attr_reader :site_source, :page_path attr_accessor :format def initialize(site_source, page_path, format = nil) @site_source = site_source @page_path = page_path @format = format || "%d-%b-%y" end def git return REPO_CACHE[site_source] unless REPO_CACHE[site_source].nil? REPO_CACHE[site_source] = Git.new(site_source) REPO_CACHE[site_source] end def formatted_last_modified_date return PATH_CACHE[page_path] unless PATH_CACHE[page_path].nil? last_modified = last_modified_at_time.strftime(@format) PATH_CACHE[page_path] = last_modified last_modified end def last_modified_at_time raise Errno::ENOENT, "#{absolute_path_to_article} does not exist!" unless File.exist?(absolute_path_to_article) Time.at(last_modified_at_unix.to_i) end def last_modified_at_unix if git.git_repo? last_commit_date = Executor.sh( "git", "--git-dir", git.top_level_directory, "log", "-n", "1", '--format="%ct"', "--", relative_path_from_git_dir, )[/\d+/] # last_commit_date can be nil iff the file was not committed. last_commit_date.nil? || last_commit_date.empty? ? mtime(absolute_path_to_article) : last_commit_date else mtime(absolute_path_to_article) end end def to_s @to_s ||= formatted_last_modified_date end def to_liquid @to_liquid ||= last_modified_at_time end private def absolute_path_to_article @absolute_path_to_article ||= Jekyll.sanitized_path(site_source, @page_path) end def relative_path_from_git_dir return unless git.git_repo? @relative_path_from_git_dir ||= Pathname.new(absolute_path_to_article) .relative_path_from( Pathname.new(File.dirname(git.top_level_directory)), ).to_s end def mtime(file) File.mtime(file).to_i.to_s end end end end jekyll-last-modified-at-1.3.2/lib/jekyll-last-modified-at/executor.rb 0000664 0000000 0000000 00000000476 14627657067 0025527 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true require "open3" module Jekyll module LastModifiedAt module Executor class << self def sh(*args) stdout_str, stderr_str, status = Open3.capture3(*args) "#{stdout_str} #{stderr_str}".strip if status.success? end end end end end jekyll-last-modified-at-1.3.2/lib/jekyll-last-modified-at/git.rb 0000664 0000000 0000000 00000001542 14627657067 0024447 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true module Jekyll module LastModifiedAt class Git attr_reader :site_source def initialize(site_source) @site_source = site_source @is_git_repo = nil end def top_level_directory return unless git_repo? @top_level_directory ||= begin Dir.chdir(@site_source) do @top_level_directory = File.join(Executor.sh("git", "rev-parse", "--show-toplevel"), ".git") end rescue StandardError "" end end def git_repo? return @is_git_repo unless @is_git_repo.nil? @is_git_repo = begin Dir.chdir(@site_source) do Executor.sh("git", "rev-parse", "--is-inside-work-tree").eql?("true") end rescue StandardError false end end end end end jekyll-last-modified-at-1.3.2/lib/jekyll-last-modified-at/hook.rb 0000664 0000000 0000000 00000001256 14627657067 0024626 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true module Jekyll module LastModifiedAt module Hook class << self def add_determinator_proc proc { |item| format = item.site.config.dig("last-modified-at", "date-format") item.data["last_modified_at"] = Determinator.new( item.site.source, item.path, format, ) } end end Jekyll::Hooks.register(:posts, :post_init, &Hook.add_determinator_proc) Jekyll::Hooks.register(:pages, :post_init, &Hook.add_determinator_proc) Jekyll::Hooks.register(:documents, :post_init, &Hook.add_determinator_proc) end end end jekyll-last-modified-at-1.3.2/lib/jekyll-last-modified-at/tag.rb 0000664 0000000 0000000 00000001201 14627657067 0024427 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true module Jekyll module LastModifiedAt class Tag < Liquid::Tag def initialize(tag_name, format, tokens) super @format = format.empty? ? nil : format.strip end def render(context) site = context.registers[:site] format = @format || site.config.dig("last-modified-at", "date-format") article_file = context.environments.first["page"]["path"] Determinator.new(site.source, article_file, format) .formatted_last_modified_date end end end end Liquid::Template.register_tag("last_modified_at", Jekyll::LastModifiedAt::Tag) jekyll-last-modified-at-1.3.2/lib/jekyll-last-modified-at/version.rb 0000664 0000000 0000000 00000000145 14627657067 0025347 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true module Jekyll module LastModifiedAt VERSION = "1.3.2" end end jekyll-last-modified-at-1.3.2/script/ 0000775 0000000 0000000 00000000000 14627657067 0017460 5 ustar 00root root 0000000 0000000 jekyll-last-modified-at-1.3.2/script/bootstrap 0000775 0000000 0000000 00000000035 14627657067 0021421 0 ustar 00root root 0000000 0000000 #! /bin/bash bundle install jekyll-last-modified-at-1.3.2/script/cibuild 0000775 0000000 0000000 00000000106 14627657067 0021016 0 ustar 00root root 0000000 0000000 #! /bin/bash script/bootstrap > /dev/null 2>&1 bundle exec rake spec jekyll-last-modified-at-1.3.2/spec/ 0000775 0000000 0000000 00000000000 14627657067 0017106 5 ustar 00root root 0000000 0000000 jekyll-last-modified-at-1.3.2/spec/dev/ 0000775 0000000 0000000 00000000000 14627657067 0017664 5 ustar 00root root 0000000 0000000 jekyll-last-modified-at-1.3.2/spec/dev/.gitkeep 0000664 0000000 0000000 00000000000 14627657067 0021303 0 ustar 00root root 0000000 0000000 jekyll-last-modified-at-1.3.2/spec/fixtures/ 0000775 0000000 0000000 00000000000 14627657067 0020757 5 ustar 00root root 0000000 0000000 jekyll-last-modified-at-1.3.2/spec/fixtures/_config.yml 0000664 0000000 0000000 00000000051 14627657067 0023102 0 ustar 00root root 0000000 0000000 name: Your New Jekyll Site timezone: UTC jekyll-last-modified-at-1.3.2/spec/fixtures/_layouts/ 0000775 0000000 0000000 00000000000 14627657067 0022616 5 ustar 00root root 0000000 0000000 jekyll-last-modified-at-1.3.2/spec/fixtures/_layouts/last_modified_at.html 0000664 0000000 0000000 00000000305 14627657067 0026771 0 ustar 00root root 0000000 0000000