App-Basis-ConvertText2

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

INPUT=$1
OUPUT=$2
function show_usage  {
    arg=$1
    err=$2
    if [ "$err" == "" ] ; then
        err=1
    fi
      "Create a UML diagram from an input text file
(see http://plantuml.sourceforge.net/ for reference)
    usage: $0 inputfile outputfile.png
"
    if [ "$arg" != "" ] ; then
        echo "$arg
"
    fi
    exit $err
}
if [ "$INPUT" == "-help" ] ; then
    show_usage "" 0
fi

docs/README.html  view on Meta::CPAN

        <meta name="Copyright" content="Kevin Mulholland (c) 2014" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

        <style type="text/css">
            @media print {
                @page {
                    size: A4  Portrait ;
                    margin: 60pt 30pt 40pt 30pt ;
                    @top {
                    margin: 0pt 0pt 0pt 0pt ;
                        content: url(/tmp/kmulholland/cache/ct2/501584ba8fd79327876915821268382f.png) ;
                    }
                    @bottom-right { content: counter(page) " / " counter(pages) ;}
                    @bottom-left {content: "Created with ct2";}
                    @bottom { content: "Kevin Mulholland (c) 2014";}
                }
                /* remove some header stuff from front page */
                @page:first {
                    @top {content: normal; }
                    @bottom-right { content: normal; ;}
                    @bottom { content: normal; ;}

docs/README.html  view on Meta::CPAN

            /* add the footnotes section if needed */
            section.footnotes:before {
                content: "Footnotes";
            }
        </style>

    </head>
    <body>
      <div class="frontpage">
          <div class='coverpage'>
              <img src="/tmp/kmulholland/cache/ct2/bd027b5281397f731f95ac53fc0e0544.png" width="280" height="280" alt="coverpage Logo" />
          </div>
          <table class="coverpage">
              <tr><td>Title</td><td>App::Basis::ConvertText2</td></tr>
              <tr><td>Author </td><td>Kevin Mulholland</td></tr>
              <tr><td>Last Updated</td><td>2014-05-12</td></tr>
              <tr><td>Version</td><td>5</td></tr>
          </table>

      </div>
      <div id='toc' >

docs/README.html  view on Meta::CPAN

~~~~</code></pre>
<p>If the code-block would normally produce some output that we do not want displayed at the current location then we would need to use the <strong>no_output</strong> argument.</p>
<p><strong>Example</strong></p>
<pre><code>~~~~{.sparkline title=&#39;green sparkline&#39; scheme=&#39;green&#39;
    from_buffer=&#39;spark_data&#39; to_buffer=&#39;greenspark&#39; no_output=1}
~~~~</code></pre>
<p>We can also have the content of a code-block replaced with content from a buffer by using the <strong>from_buffer</strong> argument. This is also displayed in the example above.</p>
<p>To use the contents (or output of a buffered code-block) we wrap the name of the buffer once again with percent ‘%’ symbols, once again we force upper case.</p>
<p><strong>Example</strong></p>
<pre><code>%SPARK_DATA% has content 1,4,5,20,4,5,3,1
%GREENSPARK% has a generated image <img src='/tmp/kmulholland/cache/ct2/1f38c66e765de08fb292e4e410263519.png' alt='green sparkline' height='20' width='80' /></code></pre>
<p>Buffering also allows us to add content into markdown constructs like bullets.</p>
<p><strong>Example</strong></p>
<pre><code>* %SPARK_DATA%
* %GREENSPARK%</code></pre>
<p><strong>Output</strong></p>
<ul>
<li>1,4,5,20,4,5,3,1</li>
<li><img src='/tmp/kmulholland/cache/ct2/1f38c66e765de08fb292e4e410263519.png' alt='green sparkline' height='20' width='80' /></li>
</ul>
<h2 id="sparklines"><a name='5_sparklines'>5 Sparklines</a></h2>
<p>Sparklines are simple horizontal charts to give an indication of things, sometimes they are barcharts but we have nice smooth lines.</p>
<p>The only valid contents of the code-block is a single line of comma separated numbers.</p>
<p>The full set of optional arguments is</p>
<ul>
<li>title
<ul>
<li>used as the generated images ‘alt’ argument</li>
</ul></li>

docs/README.html  view on Meta::CPAN

~~~~{.sparkline title=&#39;basic sparkline&#39; }
1,4,5,20,4,5,3,1
~~~~

or we can draw the sparkline using buffered data

~~~~{.sparkline title=&#39;blue sparkline&#39; scheme=&#39;blue&#39; from_buffer=&#39;spark_data&#39;}
~~~~</code></pre>
<p><strong>Output</strong></p>
<p>here is a standard sparkline</p>
<p><img src='/tmp/kmulholland/cache/ct2/c9a9b4c7e6f8cb1089d82d00ff3eb216.png' alt='basic sparkline' height='20' width='80' /></p>
<p>or we can draw the sparkline using buffered data</p>
<p><img src='/tmp/kmulholland/cache/ct2/fd3d73d870204418c0dd327f7477c09a.png' alt='blue sparkline' height='20' width='80' /></p>
<h2 id="charts"><a name='6_charts'>6 Charts</a></h2>
<p>Displaying charts is very important when creating reports, so we have a simple <strong>chart</strong> code-block.</p>
<p>The various arguments to the code-block are shown in the examples below, hopefully they are self explanatory.</p>
<p>We will buffer some data to start</p>
<p><strong>Example</strong></p>
<pre><code>~~~~{.buffer to=&#39;chart_data&#39;}
apples,bananas,cake,cabbage,edam,fromage,tomatoes,chips
1,2,3,5,11,22,33,55
1,2,3,5,11,22,33,55
1,2,3,5,11,22,33,55
1,2,3,5,11,22,33,55
~~~~</code></pre>
<p>The content comprises a number of lines of comma separated data items. The first line of the content is the legends, the subsequent lines are numbers relating to each of these legends.</p>
<h3 id="pie-chart"><a name='6.1_pie_chart'>6.1 Pie chart</a></h3>
<p><strong>Example</strong></p>
<pre><code>~~~~{.chart format=&#39;pie&#39; title=&#39;chart1&#39; from_buffer=&#39;chart_data&#39;
    size=&#39;400x400&#39; xaxis=&#39;things xways&#39; yaxis=&#39;Vertical things&#39;
    legends=&#39;a,b,c,d,e,f,g,h&#39; }
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/b82cab1f86108fdab6afbe84d1869d6a.png' alt='chart1' height='400' width='400' /></p>
<h3 id="bar-chart"><a name='6.2_bar_chart'>6.2 Bar chart</a></h3>
<p><strong>Example</strong></p>
<pre><code>~~~~{.chart format=&#39;bars&#39; title=&#39;chart1&#39; from_buffer=&#39;chart_data&#39;
    size=&#39;600x400&#39; xaxis=&#39;things ways&#39; yaxis=&#39;Vertical things&#39;
    legends=&#39;a,b,c,d,e,f,g,h&#39; }
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/511c5b56e040bea36912d2b0987f5d1d.png' alt='chart1' height='400' width='600' /></p>
<h3 id="mixed-chart"><a name='6.3_mixed_chart'>6.3 Mixed chart</a></h3>
<p><strong>Example</strong></p>
<pre><code>~~~~{.chart format=&#39;mixed&#39; title=&#39;chart1&#39; from_buffer=&#39;chart_data&#39;
  size=&#39;600x400&#39; xaxis=&#39;things xways&#39; axis=&#39;Vertical things&#39;
  legends=&#39;a,b,c,d,e,f,g,h&#39; types=&#39;lines linepoints lines bars&#39; }
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/a1903dfe13a20e39b9e880ff1ee06b0c.png' alt='chart1' height='400' width='600' /></p>
<h2 id="message-sequence-charts---mscgen"><a name='7_message_sequence_charts_-_mscgen'>7 Message Sequence Charts - mscgen</a></h2>
<p>Software (or process) engineers often want to be able to show the sequence in which a number of events take place. We use the <a href="http://www.mcternan.me.uk/mscgen/">msc</a> program for this. This program needs to be installed onto your system...
<p>The content for this code-block is EXACTLY the same that you would use as input to <a href="http://www.mcternan.me.uk/mscgen/">msc</a></p>
<p>There are only optional 2 arguments</p>
<ul>
<li>title
<ul>
<li>used as the generated images ‘alt’ argument</li>
</ul></li>
<li>size

docs/README.html  view on Meta::CPAN

  a&lt;&lt;=c [ label = &quot;callback()&quot;];
  ---  [ label = &quot;If more to run&quot;, ID=&quot;*&quot; ];
  a-&gt;a [ label = &quot;next()&quot;];
  a-&gt;c [ label = &quot;ac1()\nac2()&quot;];
  b&lt;-c [ label = &quot;cb(TRUE)&quot;];
  b-&gt;b [ label = &quot;stalled(...)&quot;];
  a&lt;-b [ label = &quot;ab() = FALSE&quot;];
}
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/160e2de7aa8dc2a0f02f2117a1cafd4a.png' alt='mscgen1' height='448' width='600' /></p>
<h2 id="diagrams-through-ascii-art---ditaa"><a name='8_diagrams_through_ascii_art_-_ditaa'>8 DIagrams Through Ascii Art - ditaa</a></h2>
<p>This is a special system to turn ASCII art into pretty pictures, nice to render diagrams. You do need to make sure that you are using a proper monospaced font with your editor otherwise things will go awry with spaces. See <a href="http://ditaa.so...
<p>The content for this code-block must be the same that you would use to with the <a href="http://ditaa.sourceforge.net">ditaa</a> software</p>
<ul>
<li>title
<ul>
<li>used as the generated images ‘alt’ argument</li>
</ul></li>
<li>size
<ul>

docs/README.html  view on Meta::CPAN

|        | --+ ditaa +--&gt; |       |
|  Text  |   +-------+    |diagram|
|Document|   |!magic!|    |       |
|     {d}|   |       |    |       |
+---+----+   +-------+    +-------+
    :                         ^
    |       Lots of work      |
    \-------------------------+
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/8ac235932524c7f7b6592ea295b3ad95.png' height='196' width='390' /></p>
<h2 id="uml-diagrams"><a name='9_uml_diagrams'>9 UML Diagrams</a></h2>
<p>Software engineers love to draw diagrams, <a href="http://plantuml.sourceforge.net">PlantUML</a> is a java component to make this simple.</p>
<p>You will need to have a script on your system called ‘uml’ that calls java with the component.</p>
<p>Here is mine, it is also available in the scripts directory in the</p>
<pre class="shell"><code>#!/bin/bash
# run plantuml
# moodfarm@cpan.org

# we assume that the plantuml.jar file is in the same directory as this executable
EXEC_DIR=`dirname $0`

docs/README.html  view on Meta::CPAN

INPUT=$1
OUPUT=$2
function show_usage  {
    arg=$1
    err=$2
    if [ &quot;$err&quot; == &quot;&quot; ] ; then
        err=1
    fi
      &quot;Create a UML diagram from an input text file
(see http://plantuml.sourceforge.net/ for reference)
    usage: $0 inputfile outputfile.png
&quot;
    if [ &quot;$arg&quot; != &quot;&quot; ] ; then
        echo &quot;$arg
&quot;
    fi
    exit $err
}
if [ &quot;$INPUT&quot; == &quot;-help&quot; ] ; then
    show_usage &quot;&quot; 0
fi

docs/README.html  view on Meta::CPAN

/&#39; this is a
multi-line
comment&#39;/
Alice -&gt; Bob: Authentication Request
Bob --&gt; Alice: Authentication Response

Alice -&gt; Bob: Another authentication Request
Alice &lt;-- Bob: another authentication Response
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/e476fbf3e854e012b058fae4ac3a6fdf.png' height='207' width='294' /></p>
<p><a href="http://plantuml.sourceforge.net">PlantUML</a> can also create simple application interfaces <a href="http://plantuml.sourceforge.net/salt.html">See Salt</a></p>
<p><strong>Example</strong></p>
<pre><code>~~~~{.uml }
@startuml
salt
{
  Just plain text
  [This is my button]
  ()  Unchecked radio
  (X) Checked radio

docs/README.html  view on Meta::CPAN

   ++ Europe
   +++ Italy
   +++ Germany
   ++++ Berlin
   ++ Africa
  }
}
@enduml
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/311e4ee5750d33a093ab106219647946.png' height='318' width='168' /></p>
<h2 id="graphviz"><a name='10_graphviz'>10 Graphviz</a></h2>
<p><a href="http://graphviz.org">graphviz</a> allows you to draw connected graphs using text descriptions.</p>
<p>The content for this code-block must be the same that you would use to with the <a href="http://graphviz.org">graphviz</a> software</p>
<p>The arguments allowed are</p>
<ul>
<li>title
<ul>
<li>used as the generated images ‘alt’ argument</li>
</ul></li>
<li>size

docs/README.html  view on Meta::CPAN

  b2 -&gt; a3;
  a3 -&gt; a0;
  a3 -&gt; end;
  b3 -&gt; end;

  start [shape=Mdiamond];
  end [shape=Msquare];
}
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/d25c89fc3008d30afc6dc3fd38178ab2.png' alt='graphviz1' height='600' width='306' /></p>
<h2 id="venn-diagram"><a name='11_venn_diagram'>11 Venn diagram</a></h2>
<p>Creating venn diagrams may sometimes be useful, though to be honest this implementation is not great, if I could find a better way to do this then I would!</p>
<p><strong>Example</strong></p>
<pre><code>~~~~{.venn  title=&quot;sample venn diagram&quot;
    legends=&quot;team1 team2 team3&quot; scheme=&quot;rgb&quot; explain=&#39;1&#39;}
abel edward momo albert jack julien chris
edward isabel antonio delta albert kevin jake
gerald jake kevin lucia john edward
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/9e0b98ce7e0ea5829245653fa0eade79.png' alt='sample venn diagram' height='400' width='400' /></p>
<ul>
<li>only in team1 : julien momo abel chris jack
<ul>
<li>only in team2 : delta isabel antonio</li>
<li>team1 and team2 share : albert</li>
</ul></li>
<li>only in team3 : gerald john lucia
<ul>
<li>team1 and team3 share :</li>
<li>team2 and team3 share : jake kevin</li>

docs/README.html  view on Meta::CPAN

<ul>
<li>number of pixels that is a ‘bit’ in a qrcode, defaults to ‘2’</li>
</ul></li>
</ul>
<h3 id="code39"><a name='12.1_code39'>12.1 Code39</a></h3>
<p><strong>Example</strong></p>
<pre><code>~~~~{.barcode type=&#39;code39&#39;}
123456789
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/0e7f2287c82ea14554939a0691e8aae1.png' height='50' width='144' /></p>
<h3 id="ean8"><a name='12.2_ean8'>12.2 EAN8</a></h3>
<p>Only allows 8 characters</p>
<p><strong>Example</strong></p>
<pre><code>~~~~{.barcode type=&#39;ean8&#39;}
12345678
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/3d239d23db81d6fdf1b987b40073e6d4.png' height='50' width='67' /></p>
<h3 id="ean13"><a name='12.3_ean13'>12.3 EAN13</a></h3>
<p>Only allows 13 characters</p>
<p><strong>Example</strong></p>
<pre><code>~~~~{.barcode type=&#39;EAN13&#39;}
1234567890123
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/6d0725ec5ea574ae42925b13a6611b62.png' height='50' width='102' /></p>
<h3 id="coop2of5"><a name='12.4_coop2of5'>12.4 COOP2of5</a></h3>
<p><strong>Example</strong></p>
<pre><code>~~~~{.barcode type=&#39;COOP2of5&#39;}
12345678
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/bfaae0b47182da4c5db23aeeaf6b6f9e.png' height='50' width='95' /></p>
<h3 id="iata2of5"><a name='12.5_iata2of5'>12.5 IATA2of5</a></h3>
<p><strong>Example</strong></p>
<pre><code>~~~~{.barcode type=&#39;IATA2of5&#39;}
12345678
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/b4c349edced8f61bc28705a1b82081cf.png' height='50' width='121' /></p>
<h3 id="industrial2of5"><a name='12.6_industrial2of5'>12.6 Industrial2of5</a></h3>
<p><strong>Example</strong></p>
<pre><code>~~~~{.barcode type=&#39;Industrial2of5&#39;}
12345678
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/477d9962aab1e41cd81388a1b53aa4ce.png' height='50' width='131' /></p>
<h3 id="itf"><a name='12.7_itf'>12.7 ITF</a></h3>
<p><strong>Example</strong></p>
<pre><code>~~~~{.barcode type=&#39;ITF&#39;}
12345678
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/f5b80a3d645e49a0e04361a84f309d7a.png' height='50' width='81' /></p>
<h3 id="matrix2of5"><a name='12.8_matrix2of5'>12.8 Matrix2of5</a></h3>
<p><strong>Example</strong></p>
<pre><code>~~~~{.barcode type=&#39;Matrix2of5&#39;}
12345678
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/f7be15398790609e8c8f8b58b45f0a46.png' height='50' width='95' /></p>
<h3 id="nw7"><a name='12.9_nw7'>12.9 NW7</a></h3>
<p><strong>Example</strong></p>
<pre><code>~~~~{.barcode type=&#39;NW7&#39;}
12345678
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/ed9acf0286931ddd8fe783f5b170902a.png' height='50' width='96' /></p>
<h3 id="qr-code"><a name='12.10_qr_code'>12.10 QR code</a></h3>
<p>As qrcodes are now quite so prevalent, they have their own code-block type.</p>
<p>We can do qr codes, just put in anything you like, this is a URL for bbc news</p>
<p><strong>Example</strong></p>
<pre><code>~~~~{.qrcode }
http://news.bbc.co.uk
~~~~

To change the size of the barcode

docs/README.html  view on Meta::CPAN

~~~~{.qrcode height=60 version=1}
smaller text..
~~~~

To change pixel size

~~~~{.qrcode pixels=5}
smaller text..
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/48521737e058cdceb967824b8191d7bf.png' height='66' width='66' /></p>
<p>To change the size of the barcode</p>
<p><img src='/tmp/kmulholland/cache/ct2/cbe37a7a8e523a70d94c177d093ac447.png' height='80' width='80' /></p>
<p>To use version 1</p>
<p>Version 1 only allows 15 characters</p>
<p><img src='/tmp/kmulholland/cache/ct2/506a46d9e4aa4fe5a177bf267a667290.png' height='60' width='60' /></p>
<p>To change pixel size</p>
<p><img src='/tmp/kmulholland/cache/ct2/ad6751a601e410d24d4154552d9dba0e.png' height='165' width='165' /></p>
<h2 id="yaml-convert-to-json"><a name='13_yaml_convert_to_json'>13 YAML convert to JSON</a></h2>
<p>Software engineers often use <a href="https://en.wikipedia.org/wiki/Json">JSON</a> to transfer data between systems, this often is not nice to create for documentation. <a href="https://en.wikipedia.org/wiki/Yaml">YAML</a> which is a superset of <...
<p><strong>Example</strong></p>
<pre><code>~~~~{.yamlasjson }
list:
  - array: [1,2,3,7]
    channel: BBC3
    date: 2013-10-20
    time: 20:30
  - array: [1,2,3,9]

docs/README.html  view on Meta::CPAN

      zaxis ticklen 0.1 min 0 hei 0.25
      xaxis hei 0.25 dticks 4 nolast nofirst
      yaxis hei 0.25 dticks 4
   end surface
end object

amove pagewidth()/2 0.2
draw &quot;saddle.bc&quot;
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/e555247121c65a85dc45fb78ec7da0f2.png' height='521' width='731' /></p>
<h2 id="gnuplot"><a name='19_gnuplot'>19 Gnuplot</a></h2>
<p>This is the granddaddy of charting/plotting programs, available from http://gnuplot.sourceforge.net/.</p>
<p>The full set of optional arguments is</p>
<ul>
<li>title
<ul>
<li>used as the generated images ‘alt’ argument</li>
</ul></li>
<li>size
<ul>

docs/README.html  view on Meta::CPAN

set label 1 &quot;This is the surface boundary&quot; at -10,-5,150 center
set arrow 1 from -10,-5,120 to -10,0,0 nohead
set arrow 2 from -10,-5,120 to 10,0,0 nohead
set arrow 3 from -10,-5,120 to 0,10,0 nohead
set arrow 4 from -10,-5,120 to 0,-10,0 nohead
set xrange [-10:10]
set yrange [-10:10]
splot x*y
~~~~</code></pre>
<p><strong>Output</strong></p>
<p><img src='/tmp/kmulholland/cache/ct2/4363ae9c4a5380986dcf88637132dc55.png' height='512' width='720' /></p>
<h2 id="gotchas-about-variables"><a name='20_gotchas_about_variables'>20 Gotchas about variables</a></h2>
<ul>
<li>Variables used within the content area of a code-block will be evaluated before processing that block, if a variable has not yet been defined or saved to a buffer then it will only be evaluated at the end of document processing, so output may not...
<li>Variables used in markdown tables may not do what you expect if the variable is multi-line.</li>
</ul>
<h2 id="using-ct2-script-to-process-files"><a name='21_using_ct2_script_to_process_files'>21 Using ct2 script to process files</a></h2>
<p>Included in the distribution is a script to make use of all of the above code-blocks to alter <a href="http://daringfireball.net/projects/markdown">markdown</a> into nicely formatted documents.</p>
<p>Here is the help</p>
<pre><code>$ ct2 --help

lib/App/Basis/ConvertText2/Plugin/Barcode.pm  view on Meta::CPAN

    if ( !$type ) {

        warn "$params->{type} is not a valid barcode type";

        # let the caller put the block back together
        return undef;
    }

    # we can use the cache or process everything ourselves
    my $sig = create_sig( $content, $params );
    my $filename = cachefile( $cachedir, "$sig.png" );
    if ( !-f $filename ) {
        my $gdb ;
        # sometimes it throws out some warnings, lets hide them
        my ($stdout, $stderr, @result) = capture {
            $gdb = GD::Barcode->new( $type, $content, $qrcode );
        } ;
        if ( !$gdb ) {
            warn "warning $tag $params->{type}: " .  $GD::Barcode::errStr;
            return undef;
        }
        my $gd = $gdb->plot( NoText => $params->{notext}, Height => $params->{height} );
        path($filename)->spew_raw( $gd->png );

        # my $cmd = QRCODE . " -o$filename '$content'";
        # my ( $exit, $stdout, $stderr ) = run_cmd($cmd);

        # for some reason qrcodes may need scaling
        if ( -f $filename && $type eq 'QRcode' && $params->{height}) {
            my $image = Image::Resize->new($filename);
            my $gd = $image->resize( $params->{height}, $params->{height} );

            # overwrite original file with resized version
            if ($gd) {
                path($filename)->spew_raw( $gd->png );
            }
        }
    }

    my $out;
    if ( -f $filename ) {

        # create something suitable for the HTML
        $out = create_img_src( $filename, $params->{title} ) . "\n" ;
    }

lib/App/Basis/ConvertText2/Plugin/Chart.pm  view on Meta::CPAN

    my ( @data, $chart, $format );
    my @types = ();
    $params->{size} ||= "400x300";
    my ( $x, $y ) = ( $params->{size} =~ /^\s*(\d+)\s*x\s*(\d+)\s*$/ );

    # strip any ending linefeed
    chomp $content;
    return "" if ( !$content );

    my $sig = create_sig( $content, $params );
    my $filename = cachefile( $cachedir, "$sig.png" );
    if ( !-f $filename ) {

        # open the csv file, read contents, calc max, add into data array
        @data = _split_csv_data($content);

        $format = $params->{format} || "mixed";
        $format = lc $format;

        if ( !$y ) {
            $x = 400;

lib/App/Basis/ConvertText2/Plugin/Chart.pm  view on Meta::CPAN

            $chart->set_legend_font(gdMediumBoldFont);
            $chart->set_x_label_font(gdMediumBoldFont);
            $chart->set_y_label_font(gdMediumBoldFont);
            $chart->set_x_axis_font(gdMediumBoldFont);
            $chart->set_y_axis_font(gdMediumBoldFont);
            $chart->set_values_font(gdMediumBoldFont);
        }

        my ( $stdout, $stderr, $exit ) = capture {
            my $gd = $chart->plot( \@data );
            path($filename)->spew_raw( $gd->png ) if ($$gd);
        };
    }

    my $out;
    if ( -f $filename ) {

        # create something suitable for the HTML
        $out = create_img_src( $filename, $params->{title} );
    }
    return $out;

lib/App/Basis/ConvertText2/Plugin/Ditaa.pm  view on Meta::CPAN

    my ( $tag, $content, $params, $cachedir ) = @_;
    $params->{size} ||= "";
    my ( $x, $y ) = ( $params->{size} =~ /^\s*(\d+)\s*x\s*(\d+)\s*$/ );

    # strip any ending linefeed
    chomp $content;
    return "" if ( !$content );

    # we can use the cache or process everything ourselves
    my $sig = create_sig( $content, $params );
    my $filename = cachefile( $cachedir, "$sig.png" );
    if ( !-f $filename ) {

        my $ditaafile = Path::Tiny->tempfile("ditaa.XXXX");

        path($ditaafile)->spew_utf8($content);

        my $cmd = DITAA . " -o $ditaafile $filename";
        my ( $exit, $stdout, $stderr ) = run_cmd($cmd);
        if ($exit) {
            warn "Could not run script " . DITAA . " get it from http://ditaa.sourceforge.net/";
        }

        # if we want to force the size of the graph
        if ( -f $filename && $x && $y ) {
            my $image = Image::Resize->new($filename);
            my $gd = $image->resize( $x, $y );

            # overwrite original file with resized version
            if ($gd) {
                path($filename)->spew_raw( $gd->png );
            }
        }
    }

    my $out;
    if ( -f $filename ) {

        # create something suitable for the HTML
        $out = create_img_src( $filename, $params->{title} );
    }

lib/App/Basis/ConvertText2/Plugin/Gle.pm  view on Meta::CPAN

    my ( $tag, $content, $params, $cachedir ) = @_;
    $params->{size} ||= "720x512";
    my ( $x, $y ) = ( $params->{size} =~ /^\s*(\d+)\s*x\s*(\d+)\s*$/ );

    # strip any ending linefeed
    chomp $content;
    return "" if ( !$content );

    # we can use the cache or process everything ourselves
    my $sig = create_sig( $content, $params );
    my $filename = cachefile( $cachedir, "$sig.png" );
    if ( !-f $filename ) {
        my $glefile = Path::Tiny->tempfile("gleXXXXXXXX");

        my $res = sprintf( "size %.4f %.4f", $x / RES, $y / RES) ;
        $content =~ s/size\s+(.*?)\s+(.*?)$//gsm ;
        $content = "$res\n$content" ;

        path($glefile)->spew_utf8($content);

        my $cmd = GLE . ( $params->{transparent} ? " -transparent" : "" ) . " -output $filename $glefile";

lib/App/Basis/ConvertText2/Plugin/Gnuplot.pm  view on Meta::CPAN

    my ( $tag, $content, $params, $cachedir ) = @_;
    $params->{size} ||= "720x512";
    my ( $x, $y ) = ( $params->{size} =~ /^\s*(\d+)\s*x\s*(\d+)\s*$/ );

    # strip any ending linefeed
    chomp $content;
    return "" if ( !$content );

    # we can use the cache or process everything ourselves
    my $sig = create_sig( $content, $params );
    my $filename = cachefile( $cachedir, "$sig.png" );
    if ( !-f $filename ) {
        my $gnuplotfile = Path::Tiny->tempfile("gnuplotXXXXXXXX");

        # make sure the output file is not theirs
        $content =~ s/set output.*$//gsmi ;
        # set out filename
        $content = "set output '$filename'\n$content" ;
            # we want to set the size
            # strip any size in the data
            $content =~ s/set term png size.*$//gsmi ;
            $content = "set term png size $x, $y\n$content" ;

        path($gnuplotfile)->spew_utf8($content);

        my $cmd = GNUPLOT . " $gnuplotfile";
        my ( $exit, $stdout, $stderr ) = run_cmd($cmd);
        if( $exit) {
            warn "Could not run script " . GNUPLOT . " get it from http://gnuplot.sourceforge.net/" ;
        }
        # if we want to force the size of the graph
        # if ( -f $filename && $x && $y ) {
        #     my $image = Image::Resize->new($filename);
        #     my $gd = $image->resize( $x, $y );

        #     # overwrite original file with resized version
        #     if ($gd) {
        #         path($filename)->spew_raw( $gd->png );
        #     }
        # }
    }
    my $out;
    if ( -f $filename ) {

        # create something suitable for the HTML
        $out = create_img_src( $filename, $params->{title} );
    }

lib/App/Basis/ConvertText2/Plugin/Graphviz.pm  view on Meta::CPAN

    my $size = "";
    $params->{size} ||= "";
    my ( $x, $y ) = ( $params->{size} =~ /^\s*(\d+)\s*x\s*(\d+)\s*$/ );

    # strip any ending linefeed
    chomp $content;
    return "" if ( !$content );

    # we can use the cache or process everything ourselves
    my $sig = create_sig( $content, $params );
    my $filename = cachefile( $cachedir, "$sig.png" );
    if ( !-f $filename ) {

        my $dotfile = Path::Tiny->tempfile("graphviz.XXXX");

        if ( $x && $y ) {
            $size = sprintf( "  size=\"%.5f,%.5f\";", $x / DPI, $y / DPI );

            # add calculated image size to the graph
            $content =~ s/(digraph.*?)$/$1\n$size\n/sm;
        }

        path($dotfile)->spew_utf8($content);
        my $cmd = GRAPHVIZ . " -Tpng -o$filename $dotfile";
        my ( $exit, $stdout, $stderr ) = run_cmd($cmd);
        if ($exit) {
            warn "Could not run script " . GRAPHVIZ . " get it from http://graphviz.org";
        }

        # if we want to force the size of the graph
        if ( -f $filename && $x && $y ) {
            my $image = Image::Resize->new($filename);
            my $gd = $image->resize( $x, $y );

            # overwrite original file with resized version
            if ($gd) {
                path($filename)->spew_raw( $gd->png );
            }
        }
    }

    my $out;
    if ( -f $filename ) {

        # create something suitable for the HTML
        $out = create_img_src( $filename, $params->{title} );
    }

lib/App/Basis/ConvertText2/Plugin/Mscgen.pm  view on Meta::CPAN

    $params->{size} ||= "";
    my ( $x, $y ) = ( $params->{size} =~ /^\s*(\d+)\s*x\s*(\d+)\s*$/ );
    $params->{title} ||= "";

    # strip any ending linefeed
    chomp $content;
    return "" if ( !$content );

    # we can use the cache or process everything ourselves
    my $sig = create_sig( $content, $params );
    my $filename = cachefile( $cachedir, "$sig.png" );
    if ( !-f $filename ) {
        my $mscfile = Path::Tiny->tempfile("mscgen.XXXX");
        path($mscfile)->spew_utf8($content);
        my $cmd = MSCGEN . " -Tpng -o$filename $mscfile";
        my ( $exit, $stdout, $stderr ) = run_cmd($cmd);
        if ($exit) {
            warn "Could not run script " . MSCGEN . " get it from http://www.mcternan.me.uk/mscgen/";
        }

        # if we want to force the size of the graph
        if ( -f $filename && $x && $y ) {
            my $image = Image::Resize->new($filename);
            my $gd = $image->resize( $x, $y );

            # overwrite original file with resized version
            if ($gd) {
                path($filename)->spew_raw( $gd->png );
            }
        }
    }

    my $out;
    if ( -f $filename ) {

        # create something suitable for the HTML
        $out = create_img_src( $filename, $params->{title} );
    }

lib/App/Basis/ConvertText2/Plugin/Sparkline.pm  view on Meta::CPAN

    if ( !$h ) {
        $w = 80;
        $h = 20;
    }

    die "Missing content" if ( !$content );
    die "Does not appear to be comma separated integers" if ( $content !~ /^[,\d ]+$/ );

    # we can use the cache or process everything ourselves
    my $sig = create_sig( $content, $params );
    my $filename = cachefile( $cachedir, "$sig.png" );
    if ( !-f $filename ) {
        $content =~ s/^\n*//gsm;    # remove any leading new lines
        if ( $content !~ /\n$/sm ) {    # make sure we have a trailing new line
            $content .= "\n";
        }

        if ($scheme) {
            $scheme = lc $scheme;
            if ( !$_colour_schemes{$scheme} ) {
                warn "Unknown color scheme $params->{scheme}";

lib/App/Basis/ConvertText2/Plugin/Sparkline.pm  view on Meta::CPAN

        }
        else {
            $b ||= 'transparent';
            $a = 'cccccc';
            $l = '333333';
        }

        my $args = { b => $b, a => $a, l => $l, s => $content, w => $w, h => $h };
        my $spark = GD::Sparkline->new($args);
        if ($spark) {
            my $png = $spark->draw();
            if ($png) {
                path($filename)->spew_raw($png) ;
            }
        }
    }

    my $out;
    if (-f $filename) {

        # create something suitable for the HTML
        $out = create_img_src( $filename, $params->{title} );
    }

lib/App/Basis/ConvertText2/Plugin/Uml.pm  view on Meta::CPAN

    my ( $tag, $content, $params, $cachedir ) = @_;
    $params->{size} ||= "";
    my ( $x, $y ) = ( $params->{size} =~ /^\s*(\d+)\s*x\s*(\d+)\s*$/ );

    # strip any ending linefeed
    chomp $content;
    return "" if ( !$content );

    # we can use the cache or process everything ourselves
    my $sig = create_sig( $content, $params );
    my $filename = cachefile( $cachedir, "$sig.png" );
    if ( !-f $filename ) {

        $content = "\@startuml\n$content" if ( $content !~ /\@startuml/ );
        $content .= "\n\@enduml" if ( $content !~ /\@enduml/ );

        # we are lucky that plantuml can have image sizes
        if ( $x && $y ) {
            $content =~ s/\@startuml/\@startuml\nscale $x*$y\n/;
        }
        my $umlfile = Path::Tiny->tempfile("umlXXXXXXXX");

lib/App/Basis/ConvertText2/Plugin/Venn.pm  view on Meta::CPAN

    my ( $w, $h ) = ( $params->{size} =~ /^\s*(\d+)\s*x\s*(\d+)\s*$/ );

    if ( !$h ) {
        $w = 400;
        $h = 400;
    }
    return "" if ( !$content );

    # we can use the cache or process everything ourselves
    my $sig = create_sig( $content, $params );
    my $filename = cachefile( $cachedir, "$sig.png" );

    # we will not check for the cachefile as we need to create the venn object
    # each time to get the explaination text, besides not many people will
    # use this plugin, so lets not go to the extra effort
    my $venn_chart = Venn::Chart->new( $w, $h ) or die("error : $!");

    # lose any leading spaces
    $content =~ s/^\s+//s;

    # Set a title, colors and a legend for our chart

lib/App/Basis/ConvertText2/Plugin/Venn.pm  view on Meta::CPAN

        push @newlegends, "$l : $line";
        last if ( ++$lines > 3 );
        my @a = split( /[,\s+]/, $line );
        push @data, \@a;
    }
    $venn_chart->set_legends(@newlegends);

    # Create a diagram with gd object
    my $gd_venn = $venn_chart->plot(@data);

    # Create a Venn diagram image in png format
    path($filename)->spew_raw( $gd_venn->png() );

    my $out;
    if ( -f $filename ) {

        # now explain what is in each region
        my @ref_lists = $venn_chart->get_list_regions();

        # create something suitable for the HTML
        $out = create_img_src( $filename, $params->{title} );
        $out .= "\n\n" . "* only in $legends[0] : " . join( ' ', @{ $ref_lists[0] } ) . "  

scripts/uml  view on Meta::CPAN

function show_usage  {
    arg=$1
    err=$2

    if [ "$err" == "" ] ; then
        err=1
    fi

    echo "Create a UML diagram from an input text file (see http://plantuml.sourceforge.net/ for reference)

    usage: $0 inputfile outputfile.png
"
    if [ "$arg" != "" ] ; then
        echo "$arg
"
    fi
    exit $err
}


if [ "$INPUT" == "-help" ] ; then

t/02_plugins.t  view on Meta::CPAN

';
        $obj    = App::Basis::ConvertText2::Plugin::Gle->new();
        $params = undef;
        $out    = $obj->process( 'gle', $content, $params, $TEST_DIR );
        ok( has_file($out), 'gle created a file' );

# gle
        $content = '#
# $Id: surface1.dem,v 1.11 2004/09/17 05:01:12 sfeam Exp $
#
set term png size 600, 400
set output "/tmp/saddle.png"
set samples 21
set isosample 11
set xlabel "X axis" offset -3,-2
set ylabel "Y axis" offset 3,-2
set zlabel "Z axis" offset -5
set title "3D gnuplot demo"
set label 1 "This is the surface boundary" at -10,-5,150 center
set arrow 1 from -10,-5,120 to -10,0,0 nohead
set arrow 2 from -10,-5,120 to 10,0,0 nohead
set arrow 3 from -10,-5,120 to 0,10,0 nohead



( run in 1.644 second using v1.01-cache-2.11-cpan-df04353d9ac )