# encoding: utf-8
# Copyright (C) 2016 Ian Kelling
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
All JavaScript has LibreJS support.
" DAY = 60*60*24 DN = 'iankelling' FQDN = DN + '.org' DURL = 'https://' + FQDN DESCRIPTION = "Ian Kelling's personal site and blog on software" DATE_LEN = 'YYYY-MM-DD'.length NOW = Time.now.to_f WAIT_DATE = NOW - 60*60*24*1 def db_init SQLite3::Database.new('../proposed-comments/comments.sqlite') end # from the redcarpet readme, then a bunch of googling to figure # out what to do on exception. class HTMLwithPygments < Redcarpet::Render::HTML def block_code(code, language) begin Pygments.highlight(code, lexer: language) rescue MentosError # when language detection fails Pygments.highlight(code, lexer: 'text') end end end def fwrite(output_path, string) output_path = File.join('./', output_path) FileUtils.mkdir_p(File.dirname(output_path)) File.write(output_path, string) end def fskel(rel_path, title, content, o={}) head = <#{Time.at(date).strftime("%b %-d '%y")}
EOF end def post(file, build_time=false) content = File.read(file) content =~ %r{\A(---\s*\n.*?\n?)^((---)\s*$\n?)}m # yaml front matter # stuff after last match. jekyll uses $POSTMATCH, # but it's nil for me, I don't know what magic they are using., # but only $' is listed here http://ruby-doc.org/core-2.3.1/doc/globals_rdoc.html, content = $' front = SafeYAML.load(Regexp.last_match(1)) title = front['title'] $page_title = "#{title} | #{DN}" header_rel = ' / blog /' footer_extra = <<-EOF EOF footer_extra += JS_INFO if content =~ /