<commit_before># -*- encoding: utf-8 -*-

require 'memorack/locals'
require 'memorack/locals/app'


module MemoRack

	class BaseLocals < Locals

		def initialize(app, hash = nil, ifnone = nil)
			super ifnone

			@app = app
			merge!(hash) if hash

			self[:app] = AppLocals[]
		end

		define_key :__menu__ do |key|
			@app.render_menu
		end
	end

end<commit_msg>くずぱんリスト(breadcrumb) のために nav と subdirs をテンプレートで参照できるようにした<commit_after># -*- encoding: utf-8 -*-

require 'memorack/locals'
require 'memorack/locals/app'


module MemoRack

	class BaseLocals < Locals

		def initialize(app, hash = nil, ifnone = nil)
			super ifnone

			@app = app
			merge!(hash) if hash

			self[:app] = AppLocals[]
		end

		define_key :__menu__ do |key|
			@app.render_menu
		end

		define_key :subdirs do |key|
			unless @subdirs
				@subdirs = []

				path_info = self[:path_info]
				break unless path_info

				href = self[:site][:url].to_s

				File.dirname(path_info).split('/').each { |dir|
					next if dir == '.'
					href = File.join(href, dir)
					next if dir.empty?

					@subdirs << {name: dir, href: href}
				}
			end

			@subdirs
		end

		define_key :nav do |key|
			unless @nav
				@nav = []
				@nav << {name: self[:title], href: File.join(self[:site][:url].to_s, '')}
				@nav += self[:subdirs] if self[:subdirs]
				@nav << {name: self[:page][:name]} if self[:page][:name]
				@nav.last[:last?] = true
			end

			@nav
		end

	end

end
{'fraction_non_alphanumeric': 0.14484679665738162, 'fraction_numerical': 0.001392757660167131, 'mean_word_length': 2.9696132596685083, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '4303543', 'n_tokens_mistral': 682, 'n_tokens_neox': 560, 'n_words': 135}