Permalink
Browse files

added mailsend example script

  • Loading branch information...
1 parent 36fb0a8 commit 1feb6fbf8e9096acd819126fb188f9dfd6751768 @zdw committed Nov 3, 2011
View
@@ -0,0 +1,128 @@
+# rakefile for docgen related tasks (processing through pandoc)
+
+# paths
+tool_path = "~/tools"
+
+# paths to bins
+$editor_bin = ENV['EDITOR']
+$pandoc_bin = "~/.cabal/bin/pandoc"
+$markdown2pdf_bin = "~/.cabal/bin/markdown2pdf"
+
+$xsltproc_bin = "/opt/local/bin/xsltproc"
+$fop_bin = "/opt/local/bin/fop"
+$jing_bin = "~/.bin/jing"
+
+$convert_bin = "/opt/local/bin/convert"
+$pngcrush_bin = "/opt/local/bin/pngcrush"
+$advpng_bin = "/opt/local/bin/advpng"
+
+# template and other auxilliary files
+$template_tex = tool_path + "/docgen/textemplate.tex"
+$css_epub = tool_path + "/docgen/epub.css"
+
+# docbook related
+docbook_xsl_prefix = "/opt/local/share/xsl/docbook-xsl"
+$docbook_html_xsl = docbook_xsl_prefix + "/html/docbook.xsl"
+$docbook_fo_xsl = docbook_xsl_prefix + "/fo/docbook.xsl"
+
+docbook_schema_prefix = "/opt/local/share/xml/docbook/5.0"
+$docbook_rng_schema = docbook_schema_prefix + "/rng/docbook.rng"
+
+# set the target variable if it's a valid file
+$target = nil
+if !ENV["target"].nil? && File.file?(ENV["target"])
+ $target = ENV["target"];
+end
+
+# default task is to make a pdf
+task :default => :pdf
+
+desc "Create pdf, html, and epub files"
+multitask :all => [ :pdf, :html, :epub ]
+
+desc "Create a PDF using pandoc's markdown2pdf"
+task :pdf do
+ if $target
+ output_pdf = $target.pathmap("%X.pdf")
+ sh "#{$markdown2pdf_bin} --xetex -N --template=#{$template_tex} --toc #{$target} -o #{output_pdf}"
+ end
+end
+
+desc "Create a HTML file with pandoc"
+task :html do
+ if $target
+ output_html = $target.pathmap("%X.html")
+ sh "#{$pandoc_bin} -s -S --toc --css=#{$css_epub} -r markdown #{$target} -w html -o #{output_html}"
+ end
+end
+
+desc "Create an ePub file with pandoc"
+task :epub do
+ if $target
+ output_epub = $target.pathmap("%X.epub")
+ sh "#{$pandoc_bin} -S --toc --epub-stylesheet=#{$css_epub} -r markdown #{$target} -w epub -o #{output_epub}"
+ end
+end
+
+desc "Create a DocBook file with pandoc"
+task :docbook do
+ if $target
+ output_docbook = $target.pathmap("%X.docbook")
+ sh "#{$pandoc_bin} -s -S -r markdown #{$target} -w docbook -o #{output_docbook}"
+ end
+end
+
+desc "Create a html file from docbook"
+task :db_html do
+ if $target
+ output_db_html = $target.pathmap("%X_db.html")
+ sh "#{$xsltproc_bin} -o #{output_db_html} #{$docbook_html_xsl} #{$target}"
+ end
+end
+
+desc "Create a fo and pdf file from docbook"
+task :db_fo_pdf do
+ if $target
+ output_fo = $target.pathmap("%X_db.fo")
+ output_pdf = $target.pathmap("%X_db.pdf")
+ sh "#{$xsltproc_bin} -o #{output_fo} #{$docbook_fo_xsl} #{$target}"
+ sh "#{$fop_bin} #{output_fo} -pdf #{output_pdf}"
+ end
+end
+
+desc "Check docbook files against schema"
+task :db_check do
+ if $target
+ sh "#{$jing_bin} #{$docbook_rng_schema} #{$target}"
+ end
+end
+
+desc "Crush PNG files, removing everything but transparency"
+task :crush do
+ if $target && ( File.extname($target) == ".png" )
+ output_crushed = $target.pathmap("%X_crushed.png")
+ sh "#{$pngcrush_bin} -q -fix -rem alla #{$target} #{output_crushed}"
+ sh "#{$advpng_bin} -q -z --shrink-insane #{output_crushed}"
+ end
+end
+
+desc "Change dpi on image file to 150"
+task :dpi150 do
+ if $target
+ setdpi($target, 150)
+ end
+end
+
+desc "Change dpi on image file to 300"
+task :dpi300 do
+ if $target
+ setdpi($target, 300)
+ end
+end
+
+# helper functions
+#
+def setdpi(file, dpi)
+ output_file = file.pathmap("%X_#{dpi}.png")
+ sh "#{$convert_bin} -units PixelsPerInch -density #{dpi} #{file} #{output_file}"
+end
View
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+#
+# tool for running rake with docgen
+
+# if passed a variable, pass that on to rake (only passes first one)
+
+SCMPATH=~/SCM
+
+# -t will make rake trace, for debugging
+RAKECMD="rake -f ${SCMPATH}/tools/docgen/docgen.rake"
+
+# by default pass a blank for the task
+RAKETASK=""
+if [ $# -eq 1 ]
+then
+ ${RAKECMD} "${1}"
+elif [ $# -eq 2 ]
+then
+ #if there's a 2nd option, pass it as the "target" variable
+ ${RAKECMD} "${1}" target="$2"
+fi
+
View
@@ -0,0 +1,29 @@
+/* General styles */
+body { margin-left: 5%; margin-right: 5%; margin-top: 5%; margin-bottom: 5%; text-align: left; font-size: medium; font-family: Georgia, "Times New Roman", serif; }
+h1, h2, h3, h4, h5, h6 { text-align: left; }
+h1.title { }
+h2.author { }
+
+/* align figures and captions */
+.figure img {display: block; margin-left: auto; margin-right: auto;}
+.figure .caption { font-weight: italic; text-align: center;}
+
+/* source code highlighting */
+code,pre { font-family: Inconsolata, monospace; }
+table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
+ { margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none;}
+td.nums { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
+td.sourceCode { padding-left: 5px; }
+pre.sourceCode span.kw { color: #007020; font-weight: bold; }
+pre.sourceCode span.dt { color: #902000; }
+pre.sourceCode span.dv { color: #40a070; }
+pre.sourceCode span.bn { color: #40a070; }
+pre.sourceCode span.fl { color: #40a070; }
+pre.sourceCode span.ch { color: #4070a0; }
+pre.sourceCode span.st { color: #4070a0; }
+pre.sourceCode span.co { color: #60a0b0; font-style: italic; }
+pre.sourceCode span.ot { color: #007020; }
+pre.sourceCode span.al { color: red; font-weight: bold; }
+pre.sourceCode span.fu { color: #06287e; }
+pre.sourceCode span.re { }
+pre.sourceCode span.er { color: red; font-weight: bold; }
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta name="generator" content="pandoc" />
+ <meta name="author" content="Artisan Computer - Zack Williams - zdw@artisancomputer.com" />
+ <meta name="date" content="2010–09–01" />
+ <title>A Test Document</title>
+ <style type="text/css">
+/*<![CDATA[*/
+table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
+ { margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
+td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
+td.sourceCode { padding-left: 5px; }
+code.sourceCode span.kw { color: #007020; font-weight: bold; }
+code.sourceCode span.dt { color: #902000; }
+code.sourceCode span.dv { color: #40a070; }
+code.sourceCode span.bn { color: #40a070; }
+code.sourceCode span.fl { color: #40a070; }
+code.sourceCode span.ch { color: #4070a0; }
+code.sourceCode span.st { color: #4070a0; }
+code.sourceCode span.co { color: #60a0b0; font-style: italic; }
+code.sourceCode span.ot { color: #007020; }
+code.sourceCode span.al { color: red; font-weight: bold; }
+code.sourceCode span.fu { color: #06287e; }
+code.sourceCode span.re { }
+code.sourceCode span.er { color: red; font-weight: bold; }
+/*]]>*/
+ </style>
+ <link rel="stylesheet" href="/Users/zdw/SCM/tools/docgen/epub.css" type="text/css" />
+</head>
+<body>
+<div id="header">
+<h1 class="title">A Test Document</h1>
+<h3 class="author">Artisan Computer - Zack Williams - zdw@artisancomputer.com</h3>
+<h4 class="date">2010–09–01</h4>
+</div>
+<div id="TOC">
+<ul>
+<li><a href="#first-section">First Section</a><ul>
+<li><a href="#major-heading">Major Heading</a></li>
+<li><a href="#another-section">Another Section</a></li>
+<li><a href="#section-with-subheadings">Section with subheadings</a><ul>
+<li><a href="#main-topic">Main topic</a></li>
+<li><a href="#secondary-topic">Secondary topic</a></li>
+</ul></li>
+</ul></li>
+<li><a href="#a-top-level-item">A top level item</a></li>
+<li><a href="#another-top-level-item">another top level item</a></li>
+<li><a href="#still-more-top-level-items">still more top level items</a></li>
+</ul>
+</div>
+<h1 id="first-section"><a href="#TOC">First Section</a></h1>
+<p>Created in Markdown format</p>
+<h2 id="major-heading"><a href="#TOC">Major Heading</a></h2>
+<p>The first paragraph of the document. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut varius orci nec orci ultrices convallis. Morbi sit amet scelerisque felis. Quisque consequat, purus vel euismod sagittis, felis massa congue arcu, quis iaculis diam risus ut ligula. Donec lobortis lacus eget ipsum auctor imperdiet. Cras faucibus, diam condimentum tempor ultrices, urna velit posuere felis, eu auctor ligula augue at nisi. Maecenas faucibus, orci ut sodales fringilla, neque leo accumsan dui, in venenatis justo urna ut erat. Phasellus id felis ligula, sit amet imperdiet purus. Mauris quis velit neque. Aenean consequat, orci eget iaculis fermentum, leo purus lobortis magna, a hendrerit diam enim et mi. Cras in ultricies quam. Etiam eget lacus nisl. Suspendisse non gravida diam. Etiam tincidunt congue mi in dignissim. Curabitur pharetra ultricies neque vel sagittis.</p>
+<p>Praesent iaculis justo quis quam convallis dignissim. Nam vitae quam lorem. Donec lobortis lacus eget ipsum auctor imperdiet. Cras faucibus, diam condimentum tempor ultrices, urna velit posuere felis, eu auctor ligula augue at nisi. Maecenas faucibus, orci ut sodales fringilla, neque leo accumsan dui, in venenatis justo urna ut erat. Phasellus id felis ligula, sit amet imperdiet purus. Mauris quis velit neque. Aenean consequat, orci eget iaculis fermentum, leo purus lobortis magna, a hendrerit diam enim et mi. Cras in ultricies quam. Etiam eget lacus nisl. Suspendisse non gravida diam. Etiam tincidunt congue mi in dignissim. Curabitur pharetra ultricies neque vel sagittis. Praesent iaculis justo quis quam convallis dignissim. Nam vitae quam lorem.<sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup></p>
+<div class="figure">
+<img src="image.png" alt="Image" /><p class="caption">Image</p>
+</div>
+<h2 id="another-section"><a href="#TOC">Another Section</a></h2>
+<p>This is some more text, “this should be printed in fancy quotes” if supported.</p>
+<p><code>This text is monospaced, and for some reason seems to be setting the the left margin incorrectly for following text. I'm not sure why this is.</code></p>
+<p>Here is a unordered list. I think, due to the text above, the left margin is shifted slightly right for text following a monospaced section. Weird.</p>
+<ul>
+<li>Item 1</li>
+<li>Item 2</li>
+<li>Item 3
+<ul>
+<li>Subitem 1</li>
+<li>Subitem 2</li>
+</ul></li>
+</ul>
+<p>And a numbered list</p>
+<ol>
+<li>First Step</li>
+<li>Second Step</li>
+<li>Third Step</li>
+</ol>
+<p><strong>A bit of source code, numbered and highlighted in HTML variants</strong></p>
+<table class="sourceCode"><tr><td class="lineNumbers" title="Click to toggle line numbers" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre>1<br />2<br />3<br />4<br />5<br />6<br />7</pre></td><td class="sourceCode"><pre class="sourceCode"><code class="sourceCode bash"><span class="co">#!/bin/bash</span><br /><br /><span class="kw">echo</span> <span class="st">&quot;this is a test&quot;</span>;<br /><br /><span class="kw">for</span> <span class="kw">file</span> <span class="kw">in</span> *; <span class="kw">do</span><br /> <span class="kw">echo</span> <span class="ot">$file</span>;<br /><span class="kw">done</span>;</code></pre></td></tr></table>
+<h2 id="section-with-subheadings"><a href="#TOC">Section with subheadings</a></h2>
+<h3 id="main-topic"><a href="#TOC">Main topic</a></h3>
+<p>Here’s the topic for this section.</p>
+<h3 id="secondary-topic"><a href="#TOC">Secondary topic</a></h3>
+<p>More information</p>
+<h1 id="a-top-level-item"><a href="#TOC">A top level item</a></h1>
+<p>This is a discussion of something new and different. I wonder how it’ll be treated.</p>
+<h1 id="another-top-level-item"><a href="#TOC">another top level item</a></h1>
+<p>This is more text</p>
+<h1 id="still-more-top-level-items"><a href="#TOC">still more top level items</a></h1>
+<div class="footnotes">
+<hr />
+<ol>
+<li id="fn1"><p>This is a footnote on the greeked text given above <a href="#fnref1" class="footnoteBackLink">↩</a></p></li>
+</ol>
+</div>
+</body>
+</html>
@@ -0,0 +1,96 @@
+% A Test Document
+% Artisan Computer - Zack Williams - zdw@artisancomputer.com
+% 2010-09-01
+
+# First Section
+
+Created in Markdown format
+
+## Major Heading
+
+The first paragraph of the document. Lorem ipsum dolor sit amet,
+consectetur adipiscing elit. Ut varius orci nec orci ultrices
+convallis. Morbi sit amet scelerisque felis. Quisque consequat,
+purus vel euismod sagittis, felis massa congue arcu, quis iaculis
+diam risus ut ligula. Donec lobortis lacus eget ipsum auctor
+imperdiet. Cras faucibus, diam condimentum tempor ultrices, urna
+velit posuere felis, eu auctor ligula augue at nisi. Maecenas
+faucibus, orci ut sodales fringilla, neque leo accumsan dui, in
+venenatis justo urna ut erat. Phasellus id felis ligula, sit amet
+imperdiet purus. Mauris quis velit neque. Aenean consequat, orci
+eget iaculis fermentum, leo purus lobortis magna, a hendrerit diam
+enim et mi. Cras in ultricies quam. Etiam eget lacus nisl.
+Suspendisse non gravida diam. Etiam tincidunt congue mi in
+dignissim. Curabitur pharetra ultricies neque vel sagittis.
+
+
+Praesent iaculis justo quis quam convallis dignissim. Nam vitae
+quam lorem. Donec lobortis lacus eget ipsum auctor
+imperdiet. Cras faucibus, diam condimentum tempor ultrices, urna
+velit posuere felis, eu auctor ligula augue at nisi. Maecenas
+faucibus, orci ut sodales fringilla, neque leo accumsan dui, in
+venenatis justo urna ut erat. Phasellus id felis ligula, sit amet
+imperdiet purus. Mauris quis velit neque. Aenean consequat, orci
+eget iaculis fermentum, leo purus lobortis magna, a hendrerit diam
+enim et mi. Cras in ultricies quam. Etiam eget lacus nisl.
+Suspendisse non gravida diam. Etiam tincidunt congue mi in
+dignissim. Curabitur pharetra ultricies neque vel sagittis.
+Praesent iaculis justo quis quam convallis dignissim. Nam vitae
+quam lorem.^[This is a footnote on the greeked text given above]
+
+![Image](image.png)
+
+## Another Section
+
+This is some more text, "this should be printed in fancy quotes" if supported.
+
+`This text is monospaced, and for some reason seems to be setting the the left margin incorrectly for following text. I'm not sure why this is.`
+
+Here is a unordered list. I think, due to the text above, the left margin is shifted slightly right for text following a monospaced section. Weird.
+
+ - Item 1
+ - Item 2
+ - Item 3
+ - Subitem 1
+ - Subitem 2
+
+And a numbered list
+
+ #. First Step
+ #. Second Step
+ #. Third Step
+
+**A bit of source code, numbered and highlighted in HTML variants**
+
+~~~~ {.bash .numberLines}
+#!/bin/bash
+
+echo "this is a test";
+
+for file in *; do
+ echo $file;
+done;
+~~~~
+
+## Section with subheadings
+
+### Main topic
+
+Here's the topic for this section.
+
+### Secondary topic
+
+More information
+
+# A top level item
+
+This is a discussion of something new and different. I wonder how it'll be treated.
+
+# another top level item
+
+This is more text
+
+# still more top level items
+
+
+
Binary file not shown.
Oops, something went wrong.

0 comments on commit 1feb6fb

Please sign in to comment.