<commit_before>class String
	# Unindent multiline string based on lowest amount of whitespace.
	def unindent
		gsub(/^#{scan(/^\s*/).min_by{|l|l.length}}/, "")
	end
end

module SiteSpawner
	# Require core library
	require "middleman-core"

	class LayoutGenerator < ::Middleman::Extension
		def initialize(app, options_hash={}, &block)
			super
			
			app.set(:layoutGen, self)
			
			require 'uglifier'
			
			stylesheets_dir = File.join(File.dirname(__FILE__), '..', 'styles')		
			Sass.load_paths << "#{stylesheets_dir}"
			
			def generateHead()
				app = @app
				stylesheets = ["stylesheet"]
				current_page = app.current_page
				title = current_page.parent ? " @ " + app.site_title : ""
				head = <<-HEAD.unindent
					<!DOCTYPE HTML>
					<html lang="en">
						<head>
							<meta charset="utf-8">
							<title>#{current_page.data.title + title if current_page.data.title}</title>
							#{app.stylesheet_link_tag "stylesheet"}
						</head>
				HEAD
				return head
			end

			def generateBefore
				app = @app
				current_page = app.current_page
				layout = ""
				layout << generateHead()

				# TODO: app.site_title needs to have all spaces replaced with &nbsp;
				# Otherwise it has to be selected to be white-space: nowrap;

				layout << <<-ERB.unindent
					<body>
						<header>
							<p>made at <a href="#{app.parent_url}">#{app.parent_title}</a></p>
							<div class="bar">
								#{app.link_to app.site_title, '/index.html'}
								#{ navigationGen() }
								<form method="get" action="http://www.google.com/search" class="search">
									<input type="search" name="q" placeholder="Search this site..." class="textfield" />
									<input type="submit" value="Search" class="button" />
									<input type="radio" name="sitesearch" value="web-polygraph.org" checked hidden class="hidden" />
								</form>
							</div>
						</header>
						<div class="content">
							#{ breadcrumbs() }
							<h1 class="contentHeader no_toc">#{current_page.data.title}</h1>
							#{ tocGen() }
				ERB
				return layout
			end
			
			def generateAfter()
				app = @app
				current_page = app.current_page
				childrenHtml = seeAlsoGen(5)
				sitemapDest = app.sitemapDest
				sitemapLink = app.link_to 'Sitemap', sitemapDest

				# XXX : For some unknown reason, find_resource_by_destination_path does not find sitemapDest
				sitemapLink = '' unless app.sitemap.find_resource_by_path(sitemapDest)
				layout = <<-ERB
							</div>
							<footer>
								<span class="see-also">
									#{"See Also:&nbsp;" + childrenHtml unless childrenHtml.empty?}
								</span>
								
								<span class="right-side">
									#{sitemapLink} &bull;
									#{app.link_to 'Help', '/support/index.html'}
									<br>
									&copy; #{Time.new.year} <a href="#{app.parent_url}">#{app.parent_title}</a>
								</span>
							</footer>
						</body><commit_msg>Changed by line to be configurable.<commit_after>class String
	# Unindent multiline string based on lowest amount of whitespace.
	def unindent
		gsub(/^#{scan(/^\s*/).min_by{|l|l.length}}/, "")
	end
end

module SiteSpawner
	# Require core library
	require "middleman-core"

	class LayoutGenerator < ::Middleman::Extension
		def initialize(app, options_hash={}, &block)
			super
			
			app.set(:layoutGen, self)
			
			require 'uglifier'
			

			stylesheets_dir = File.join(File.dirname(__FILE__), '..', 'styles')		
			Sass.load_paths << "#{stylesheets_dir}"
			
			def generateHead()
				app = @app
				stylesheets = ["stylesheet"]
				current_page = app.current_page
				title = current_page.parent ? " @ " + app.site_title : ""
				head = <<-HEAD.unindent
					<!DOCTYPE HTML>
					<html lang="en">
						<head>
							<meta charset="utf-8">
							<title>#{current_page.data.title + title if current_page.data.title}</title>
							#{app.stylesheet_link_tag "stylesheet"}
						</head>
				HEAD
				return head
			end

			def generateBefore
				app = @app
				current_page = app.current_page
				layout = ""
				layout << generateHead()

				# TODO: app.site_title needs to have all spaces replaced with &nbsp;
				# Otherwise it has to be selected to be white-space: nowrap;

				layout << <<-ERB.unindent
					<body>
						<header>
							<p>#{app.site_spawner[:byLine]}</p>
							<div class="bar">
								#{app.link_to app.site_spawner[:site_title], '/index.html'}
								#{ navigationGen() }
								<form method="get" action="http://www.google.com/search" class="search">
									<input type="search" name="q" placeholder="Search this site..." class="textfield" />
									<input type="submit" value="Search" class="button" />
									<input type="radio" name="sitesearch" value="web-polygraph.org" checked hidden class="hidden" />
								</form>
							</div>
						</header>
						<div class="content">
							#{ breadcrumbs() }
							<h1 class="contentHeader no_toc">#{current_page.data.title}</h1>
							#{ tocGen() }
				ERB
				return layout
			end
			
			def generateAfter()
				app = @app
				current_page = app.current_page
				childrenHtml = seeAlsoGen(5)
				sitemapDest = app.site_spawner[:sitemapLocation]
				sitemapLink = app.link_to 'Sitemap', sitemapDest

				# XXX : For some unknown reason, find_resource_by_destination_path does not find sitemapDest
				sitemapLink = '' unless app.sitemap.find_resource_by_path(sitemapDest)
				layout = <<-ERB
							</div>
							<footer>
								<span class="see-also">
									#{"See Also:&nbsp;" + childrenHtml unless childrenHtml.empty?}
								</span>
								
								<span class="right-side">
									#{sitemapLink} &bull;
									#{app.link_to 'Help', '/support/index.html'}
									<br>
									&copy; #{Time.new.year} <a href="#{app.site_spawner[:parent_url]}">#{app.site_spawner[:parent_title]}</a>
								</span>
							</footer>
						</body>
{'fraction_non_alphanumeric': 0.14688682490540075, 'fraction_numerical': 0.0013759889920880633, 'mean_word_length': 2.729955099422707, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1159403', 'n_tokens_mistral': 2599, 'n_tokens_neox': 1879, 'n_words': 409}