<commit_before># Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
	#include ActsAsDynamicImage::Helper
	include VideoHelper
	
	def feed_tags(options={})
		feeds = Page.enabled_feeds(@language, options)
		output = ''
		if feeds && feeds.length > 1
			output += "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"#{PagesCore.config(:site_name)}\" href=\""+formatted_pages_url(:language => @language, :format => :rss)+"\" />\n"
		end
		output += feeds.map{ |p| "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"#{PagesCore.config(:site_name)}: #{p.name.to_s}\" href=\""+page_url( p, :only_path => false, :format => :rss )+"\" />" }.join("\n")
		output
	end

	def i18n( string )
		language = @language || Language.default
		begin
			translated = @@i18n_table[string.downcase][language]
			translated || string
		rescue
			string
		end
	end
	
	def include_stylesheet(source, options={})
		@include_stylesheets ||= []
		@include_stylesheets << [source, options]
	end

	def include_javascript(source, options={})
		@include_javascripts ||= []
		@include_javascripts << [source, options]
	end

	def head_tag(options={}, &block)
		# Evaluate the given block first
		output_block = block_given? ? capture(&block) : ''

		# Get options
		options[:language] ||= @language
		options[:charset]  ||= "utf-8"
		options[:author]   ||= "Manual design (manualdesign.no)"
		options[:doctype]  ||= :xhtml
		language_definition = Language.definition( options[:language] ).iso639_1 || "en"
		unless options.has_key?( :title )
			options[:title] = PagesCore.config(:site_name)
			if @page_title
				if options[:prepend_page_title]
					options[:title] = "#{@page_title} - #{options[:title]}"
				else
					options[:title] = "#{options[:title]} - #{@page_title}"
				end
			end
		end
		
		# Build HTML
		output  = ""
		if options[:doctype] == :xhtml
			output += "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
			output += "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"#{language_definition}\" lang=\"#{language_definition}\">\n"
			output += "<head>\n"
			output += "	<meta http-equiv=\"Content-Type\" content=\"text/html; charset=#{options[:charset]}\" />\n"
			output += "	<meta http-equiv=\"Content-Language\" content=\"#{language_definition}\" />\n"
		elsif options[:doctype] == :html5
			output += "<!DOCTYPE html>\n"
			output += "<html lang=\"#{language_definition}\">\n"
			output += "<head>\n"
			output += "	<meta charset=\"#{options[:charset]}\" />\n"
		end
		output += "	<meta name=\"author\" content=\"#{options[:author]}\" />\n"
		output += "	<title>#{options[:title]}</title>\n"
		output += indent(stylesheet_link_tag(*options[:stylesheet] ), 1) + "\n"    if options.has_key? :stylesheet

		if @include_stylesheets
			output += @include_stylesheets.map do |source, source_options| 
				ie = source_options.delete(:ie)
				source_output = stylesheet_link_tag(source, source_options)
				source_output = "<!--[if #{ie}]>#{source_output}<![endif]-->" if ie
				indent(source_output, 1)
			end.join("\n")
			output += "\n"
		end<commit_msg>head_tag html5<commit_after># Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
	#include ActsAsDynamicImage::Helper
	include VideoHelper
	
	def feed_tags(options={})
		feeds = Page.enabled_feeds(@language, options)
		output = ''
		if feeds && feeds.length > 1
			output += "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"#{PagesCore.config(:site_name)}\" href=\""+formatted_pages_url(:language => @language, :format => :rss)+"\" />\n"
		end
		output += feeds.map{ |p| "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"#{PagesCore.config(:site_name)}: #{p.name.to_s}\" href=\""+page_url( p, :only_path => false, :format => :rss )+"\" />" }.join("\n")
		output
	end

	def i18n( string )
		language = @language || Language.default
		begin
			translated = @@i18n_table[string.downcase][language]
			translated || string
		rescue
			string
		end
	end
	
	def include_stylesheet(source, options={})
		@include_stylesheets ||= []
		@include_stylesheets << [source, options]
	end

	def include_javascript(source, options={})
		@include_javascripts ||= []
		@include_javascripts << [source, options]
	end

	def head_tag(options={}, &block)
		# Evaluate the given block first
		output_block = block_given? ? capture(&block) : ''

		# Get options
		options[:language] ||= @language
		options[:charset]  ||= "utf-8"
		options[:author]   ||= "Manual design (manualdesign.no)"
		options[:doctype]  ||= :xhtml
		language_definition = Language.definition( options[:language] ).iso639_1 || "en"
		unless options.has_key?( :title )
			options[:title] = PagesCore.config(:site_name)
			if @page_title
				if options[:prepend_page_title]
					options[:title] = "#{@page_title} - #{options[:title]}"
				else
					options[:title] = "#{options[:title]} - #{@page_title}"
				end
			end
		end
		
		# Build HTML
		output  = ""
		if options[:doctype] == :xhtml
			output += "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
			output += "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"#{language_definition}\" lang=\"#{language_definition}\">\n"
			output += "<head>\n"
			output += "	<meta http-equiv=\"Content-Type\" content=\"text/html; charset=#{options[:charset]}\" />\n"
			output += "	<meta http-equiv=\"Content-Language\" content=\"#{language_definition}\" />\n"
			output += "	<meta name=\"author\" content=\"#{options[:author]}\" />\n"
		elsif options[:doctype] == :html5
			output += "<!doctype html>\n"
			output += "<html lang=\"#{language_definition}\">\n"
			output += "<head>\n"
			output += "	<meta charset=\"#{options[:charset]}\">\n"
			output += "	<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n"
			output += "	<meta name=\"author\" content=\"#{options[:author]}\">\n"
		end
		output += "	<title>#{options[:title]}</title>\n"
		output += indent(stylesheet_link_tag(*options[:stylesheet] ), 1) + "\n"    if options.has_key? :stylesheet

		if @include_stylesheets
			output += @include_stylesheets.map do |source, source_options| 
				ie = source_options.delete(:ie)
				source_output = stylesheet_link_tag(source, source_options)
				source_output = "<!--[if #{ie}]>#{source_output}<![endif]-->" if ie
				indent(source_output, 1)
			end.join("\n")
			output += "\n"
		end
{'fraction_non_alphanumeric': 0.19672882910424946, 'fraction_numerical': 0.007642922653622745, 'mean_word_length': 4.217703349282297, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 8}, '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': '5980520', 'n_tokens_mistral': 2483, 'n_tokens_neox': 2167, 'n_words': 453}