Class: Burr::Site
Constant Summary
Constants inherited from Exporter
Exporter::BACKMATTER, Exporter::BODYMATTER, Exporter::FRONTMATTER
Instance Attribute Summary
Attributes inherited from Exporter
#backmatter, #bodymatter, #book, #config, #frontmatter
Instance Method Summary collapse
- #assemble_book ⇒ Object
-
#decorate_contents ⇒ Object
Decorate the contents with template.
-
#parse_contents ⇒ Object
Convert original contents into HTML.
Methods inherited from Exporter
#initialize, #load_contents, #run, #run_plugins_of_type
Constructor Details
This class inherits a constructor from Burr::Exporter
Instance Method Details
#assemble_book ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/burr/exporters/site.rb', line 37 def assemble_book [nil, *flatten_items(self.book.items), nil].each_cons(3) do |pre, item, nxt| item['toc'] = item_toc_html(item['toc']) unless pre.nil? item['pre'] = '' item['pre'] << "#{pre['label']}" unless pre['label'].blank? item['pre'] << "#{pre['title']}" item['pre_url'] = get_html_path_of(pre['element'], pre['file']) end unless nxt.nil? item['nxt'] = '' item['nxt'] << "#{nxt['label']}" unless nxt['label'].blank? item['nxt'] << "#{nxt['title']}" item['nxt_url'] = get_html_path_of(nxt['element'], nxt['file']) end File.open(get_html_path_of(item['element'], item['file'], false), 'w') do |f| f.puts self.book.render(self.book.template_for(item['element']), { 'item' => item }) end end end |
#decorate_contents ⇒ Object
Decorate the contents with template
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/burr/exporters/site.rb', line 26 def decorate_contents decorated_items = [] self.book.items.each do |item| self.book.current_item = item self.run_plugins_of_type(:before_decorate) self.run_plugins_of_type(:after_decorate) decorated_items << self.book.current_item end self.book.items = decorated_items end |
#parse_contents ⇒ Object
Convert original contents into HTML
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/burr/exporters/site.rb', line 6 def parse_contents parsed_items = [] self.book.items.each do |item| self.book.current_item = item self.run_plugins_of_type(:before_parse) unless item['skip'] item['content'] = Burr::Converter.new(self.book).convert(item['original']) end self.run_plugins_of_type(:after_parse) parsed_items << self.book.current_item end self.book.items = parsed_items end |