remove unused file
[iankelling.org] / b.rb
diff --git a/b.rb b/b.rb
index 391a0ed5e97430f34223d5432d177d951bfae929..10006899d147b963817a1b36450da7af066aef9c 100644 (file)
--- a/b.rb
+++ b/b.rb
@@ -86,7 +86,7 @@ EOF
       <h3><a href="/">iankelling.org</a>#{o[:header]}</h3>
     </header>
     <div class="main-content-stripe">
-      <div class="content">
+      <div class="#{o[:prose] ? "prose" : "content"}">
         #{content}
       </div>
     </div>
@@ -95,7 +95,7 @@ EOF
     </div>
     <footer>
 #{o[:footer]}
-      <p>This site has a <a href="/git/?p=iankelling.org;a=summary">git repo</a>. Unless stated otherwise, <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img class="cc-by-sa" alt="Creative Commons License" src="/assets/cc-by-sa-4.0-80x15.png" /></a></p>
+      <p>Sources in <a href="/git/?p=iankelling.org;a=summary">git</a>. Mostly markdown files. Default is <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img class="cc-by-sa" alt="Creative Commons License" src="/assets/cc-by-sa-4.0-80x15.png" /></a></p>
       <p><address><a href="mailto:ian@iankelling.org">ian@iankelling.org</a> let me know what you think</address></p>
     </footer>
   </body>
@@ -128,7 +128,7 @@ 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)
+                                         fenced_code_blocks: true).render(comment)
     <<EOF
 <div class="comment">
   #{user_input}
@@ -137,6 +137,31 @@ EOF
 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 = "<h1>#{title}</h1><b>Contents</b>"
+    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 = ' / <a href="/technical-notes.html">technical notes</a> /'
+    fskel("/technical-notes/#{b}.html", title, page_html,
+          header: header_rel,
+          prose: true)
+
+    technotes_index_entry = "<li><a href=\"/technical-notes/#{b}.html\">#{title}</a></li>"
+    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
@@ -190,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
@@ -223,8 +250,8 @@ EOF
       <form action="/cgi/comment" method="post">
         <input class="misc-comment-input" type="text" name="url">
         <input name="goto" type="hidden" value="#{rel_path}">
-        <textarea rows="10" name="comment" placeholder="markdown" maxlength="1000"></textarea>
-        <input type="submit" value="Leave a comment">
+        <textarea rows="10" name="comment" maxlength="1000"></textarea>
+        <input type="submit" value="Add a comment (markdown works)">
       </form>
       <div id="comments">
          #{com_list}
@@ -267,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}"