| @@ -1,5 +1,9 @@ | |||||
| #!/usr/bin/env ruby | #!/usr/bin/env ruby | ||||
| # Generate a static site | # Generate a static site | ||||
| # https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way/ | |||||
| t_start = Process.clock_gettime(Process::CLOCK_MONOTONIC) | |||||
| require 'logger' | require 'logger' | ||||
| require 'haml' | require 'haml' | ||||
| require_relative '../models' | require_relative '../models' | ||||
| @@ -13,6 +17,8 @@ LAYOUT_FN = File.join(VIEWS_DIR, 'layout.haml') | |||||
| @log.info "Build starts." | @log.info "Build starts." | ||||
| @log.info "Output directory is: #{OUTPUT_DIR}" | @log.info "Output directory is: #{OUTPUT_DIR}" | ||||
| @pages = 0 | |||||
| class String | class String | ||||
| def pluralize(num) | def pluralize(num) | ||||
| if num == 1 | if num == 1 | ||||
| @@ -77,6 +83,7 @@ def write_page(path_items, template, locals = {}) | |||||
| File.write(fn, html) | File.write(fn, html) | ||||
| @log.info fn | @log.info fn | ||||
| @pages += 1 | |||||
| # TODO - add page to sitemap.xml or sitemap.txt | # TODO - add page to sitemap.xml or sitemap.txt | ||||
| # https://support.google.com/webmasters/answer/183668?hl=en&ref_topic=4581190 | # https://support.google.com/webmasters/answer/183668?hl=en&ref_topic=4581190 | ||||
| end | end | ||||
| @@ -288,4 +295,4 @@ write_page('guides', 'guides') | |||||
| write_page(%w(guides how-the-parliament-election-works), 'parliament') | write_page(%w(guides how-the-parliament-election-works), 'parliament') | ||||
| write_page(%w(guides how-the-council-election-works), 'election') | write_page(%w(guides how-the-council-election-works), 'election') | ||||
| @log.info "Build complete." | |||||
| @log.info "Build complete. %d pages generated in %0.2f seconds." % [ @pages, Process.clock_gettime(Process::CLOCK_MONOTONIC) - t_start ] | |||||