X-Git-Url: https://iankelling.org/git/?p=iankelling.org;a=blobdiff_plain;f=b.rb;h=391a0ed5e97430f34223d5432d177d951bfae929;hp=511ac8d9717c4d535a0a929ca5fffab82a46d88e;hb=d0aafa5d6370307bdf0abe470be16f6a15f15162;hpb=d0a5b73d2a275bfff5957961f2360df8966bee22 diff --git a/b.rb b/b.rb index 511ac8d..391a0ed 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,15 +75,14 @@ EOF #{title} - - + #{o[:head]} -
+
@@ -90,13 +90,13 @@ EOF #{content}
-
+
#{o[:comments]}
@@ -125,15 +125,14 @@ 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 @@ -161,11 +160,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 @@ -221,8 +220,8 @@ EOF comment_html("Note: there #{text} pending approval.", NOW) end com_section = <<-EOF -
- + + @@ -243,7 +242,7 @@ EOF blog_toc_entry = "
  • #{title}
  • " com_section = < +
    #{com_section}
    EOF @@ -270,7 +269,7 @@ EOF footer: footer_extra, comments: com_section, description: description) - url="#{DURL}/#{rel_path}" + url="#{DURL}#{rel_path}" # following from https://creativecommons.org/choose,