X-Git-Url: https://iankelling.org/git/?p=iankelling.org;a=blobdiff_plain;f=b.rb;h=10006899d147b963817a1b36450da7af066aef9c;hp=266ce819b6525215afdbcaff90b8cf78166925d5;hb=HEAD;hpb=3db786ddb2c63466b2108d10d57b3572c389a82f diff --git a/b.rb b/b.rb index 266ce81..1000689 100644 --- a/b.rb +++ b/b.rb @@ -58,7 +58,7 @@ module B # blog module head = < EOF - if rel_path =~ %r{^blog/.} + if rel_path =~ %r{^/blog/|^blog.html} head += < EOF @@ -75,29 +75,28 @@ EOF #{title} - - + #{o[:head]} -
+
-
+
#{content}
-
+
#{o[:comments]}
@@ -126,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 @@ -192,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 @@ -222,11 +247,11 @@ EOF comment_html("Note: there #{text} pending approval.", NOW) end com_section = <<-EOF -
    - + + - - + +
    #{com_list} @@ -244,7 +269,7 @@ EOF blog_toc_entry = "
  • #{title}
  • " com_section = < +
    #{com_section}
    EOF @@ -269,6 +294,11 @@ 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}"