X-Git-Url: https://iankelling.org/git/?p=iankelling.org;a=blobdiff_plain;f=b.rb;h=10006899d147b963817a1b36450da7af066aef9c;hp=511ac8d9717c4d535a0a929ca5fffab82a46d88e;hb=HEAD;hpb=d0a5b73d2a275bfff5957961f2360df8966bee22 diff --git a/b.rb b/b.rb index 511ac8d..1000689 100644 --- a/b.rb +++ b/b.rb @@ -49,6 +49,7 @@ module B # blog module 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 @@ -57,7 +58,7 @@ module B # blog module head = < EOF - if rel_path =~ %r{^blog/.} + if rel_path =~ %r{^/blog/|^blog.html} head += < EOF @@ -74,29 +75,28 @@ EOF #{title} - - + #{o[:head]} -
+
-
+
#{content}
-
+
#{o[:comments]}
#{o[:footer]} -

This site has a git repo. Code is gpl, content is Creative Commons License unless otherwise noted

-

ian@iankelling.org let me know what you think

+

Sources in git. Mostly markdown files. Default is Creative Commons License

+

ian@iankelling.org let me know what you think

@@ -125,19 +125,43 @@ EOF end def comment_html(comment, date) - inner = Redcarpet::Markdown.new(Redcarpet::Render::HTML, fenced_code_blocks: true).render(<#{Time.at(date).strftime("%b %-d '%y")} -EOF # I tried putting the time, %I:%M %p UTC, but it looks kinda # clunky, going against my simple theme. + user_input = Redcarpet::Markdown.new(Redcarpet::Render::Safe, + fenced_code_blocks: true).render(comment) < - #{inner} + #{user_input} +

#{Time.at(date).strftime("%b %-d '%y")}

EOF end + + def techpost(file) + + b = File.basename(file,'.md') + # double dash for one dash, single dash for space + title = b.gsub(/--|-/, '--' => '-', '-' => ' ') + + md = File.read(file) + page_html = "

#{title}

Contents" + renderer = Redcarpet::Render::HTML_TOC.new(nesting_level: 2) + page_html += Redcarpet::Markdown.new(renderer, fenced_code_blocks: true).render(md) + + renderer = HTMLwithPygments.new(with_toc_data: true) + page_html += Redcarpet::Markdown.new(renderer, fenced_code_blocks: true).render(md) + + header_rel = ' / technical notes /' + fskel("/technical-notes/#{b}.html", title, page_html, + header: header_rel, + prose: true) + + technotes_index_entry = "
  • #{title}
  • " + return technotes_index_entry + + end + def post(file, build_time=false) content = File.read(file) content =~ %r{\A(---\s*\n.*?\n?)^((---)\s*$\n?)}m # yaml front matter @@ -161,11 +185,11 @@ EOF b = File.basename(file,'.md') # date is in the format: YYYY-MM-DD- date = Time.parse(b[0..DATE_LEN]) - rel_path = "blog/#{b[(DATE_LEN + 1)..-1]}.html" + rel_path = "/blog/#{b[(DATE_LEN + 1)..-1]}.html" comments = $db.execute <<-SQL, [WAIT_DATE] select comment, date from c where page = '#{rel_path}' and ( - state = 'picked' or state = 'known' + state = 'picked' or state = 'known' or state = 'timed' or (state = 'waiting' and date < ?)) SQL # get earliest comment. earlier ones stored in git will also be @@ -191,7 +215,9 @@ SQL # Small enough that it won't happen at my site's scale. File.write(File.join(comment_file_dir, c_date.to_s), c) end - # https://piwik.org/docs/privacy/ says keep logs for 3-6 months + # Im slow at updating this site, it gets low traffic, + # https://piwik.org/docs/privacy/ suggests 3-6 months, so + # this cant be too bad. $db.execute("delete from c where date < #{NOW - DAY*180}") end comments = old_comments + comments @@ -221,11 +247,11 @@ EOF comment_html("Note: there #{text} pending approval.", NOW) end com_section = <<-EOF -
    - + + - - + +
    #{com_list} @@ -243,7 +269,7 @@ EOF blog_toc_entry = "
  • #{title}
  • " com_section = < +
    #{com_section}
    EOF @@ -268,9 +294,14 @@ EOF fskel(rel_path, title, page_html, header: header_rel, footer: footer_extra, + # We call the main content prose because it can contain + # code, so we want to left justify it, so we dont have + # to cram all the code into the middle and can use + # a wider area. + prose: true, comments: com_section, description: description) - url="#{DURL}/#{rel_path}" + url="#{DURL}#{rel_path}" # following from https://creativecommons.org/choose,