summaryrefslogtreecommitdiff
path: root/lib/siteutil.rb
blob: 0c0bb6992d2ad88a4611d9708a180c10934ef6dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# coding: utf-8
require 'config'
require 'sitegen'

module Sitegen
	def self.html_escape(html)
		html
			.gsub('&', '&')
			.gsub('>', '>')
			.gsub('<', '&lt;')
	end

	def self.breadcrumbs(url)
		path = url.path
		path = "/" if path == ""
		bc = []
		while true
			a = 'out'+path
			b = ('out'+path+'/index.html').gsub('//', '/')
			page = @local[a] || @local[b]
			bc.unshift("<a href=\"#{url.route_to(page.url)}\">#{page.atom_title}</a>")
			break if path == "/"
			path = File::dirname(path)
		end
		return bc.join(' » ')
	end
end