Changes To Cookbook
Not logged in

Changes to "Cookbook" between 2009-12-31 04:13:53 and 2010-01-04 23:21:38

    15     15     <li><a href="#wysiwig">Javascript HTML WYSIWYG editor control</a>
    16     16       <ul>
    17     17         <li><a href="#tinymce">TinyMCE</a></li>
    18     18         <li><a href="#markitup">markitup!</a></li>
    19     19       </ul>
    20     20     </li>
    21     21     <li><a href="#ticket-checkin-links">Link tickets to checkins</a></li>
           22  +  <li><a href="#th1-usage">Fossil and Th1</a></li>
    22     23   </ul>
    23     24   
    24     25   <h2><a name="CGI">Using <cite>Fossil</cite>'s Built-In CGI</a></h2>
    25     26   <h3>Motivation</h3>
    26     27     *  You want to share a repository through your existing web infrastructure.
    27     28     *  You want to share more than one repository at the same time.
    28     29   
................................................................................
   692    693   Now, continuing, on the same View Page add a link to view associated tickets: 
   693    694   
   694    695   <verbatim>
   695    696   <a href="/timeline?y=ci&s=$<shortUuid>">associated tickets</a>
   696    697   </verbatim>
   697    698   
   698    699   What this does is searches all checkin's for the tickets uuid, thus, you can now see all checkin's that are linked with the given ticket.
          700  +
          701  +<div>
          702  +  <h2><a name="th1-usage">Fossil Th1</a></h2>
          703  +
          704  +  <h3>Purpose of Th1</h3>
          705  +
          706  +  <p>Th1 is used as a <strong>template system</strong> for
          707  +  generating HTML header and footer. It is a TCL like
          708  +  language. If you know TCL you know TH1.</p>
          709  +
          710  +  <p>It is invoked by opening a &lt;th1&gt; tag. The first time it
          711  +  starts an interpreter. The state of this interpreter is valid
          712  +  during the page generation.</p>
          713  +
          714  +  <p>For example when you</p>
          715  +
          716  +  <ul compact='compact'>
          717  +    <li>
          718  +      do in the header &lt;th1&gt; set version beta &lt;/th1&gt;
          719  +    </li>
          720  +    <li>
          721  +      then in the footer &lt;th1&gt;puts "Version set in header
          722  +      is $version"&lt;/th1&gt; results in 'Version set in header is
          723  +      beta'
          724  +    </li>
          725  +  </ul>
          726  +
          727  +  <p>Because it is used as a template system it exports some
          728  +  details of fossil through</p>
          729  +
          730  +  <ol>
          731  +    <li>variables</li>
          732  +    <li>functions</li>
          733  +  </ol>
          734  +
          735  +  <p>These are defined in
          736  + [590e073746121befe65565ee6d73007c37ade12c|src/th_main.c])</p>
          737  +
          738  +  <h3>Variables</h3>
          739  +
          740  +  <p>These variable are global and available outside &lt;th1&gt;
          741  +  tags. They can be referenced either as</p>
          742  +
          743  +  <ul compact='compact'>
          744  +    <li>$var. e.g. $title.</li>
          745  +    <li>$&lt;var&gt; e.g. $&lt;title&gt;</li>
          746  +  </ul>
          747  +
          748  +  <p>The following are defined:</p>
          749  +
          750  +  <ul compact='compact'>
          751  +    <li>$base_url. The first part of the url. For example
          752  +    <strong>http://localhost:8080</strong></li>
          753  +    <li>$current_page. The page requested. For example editing a
          754  +    wikipage is done by $baseurl/wikiedit $current_page is
          755  +    <strong>wikiedit</strong></li>
          756  +    <li>$index_page<strong>.</strong> Mostly the value is
          757  +    <strong>/home</strong> setable in Admin/Configuration</li>
          758  +    <li>$title. The title of the $current_page</li>
          759  +    <li>$login. The name of user if a login has occurred. if you
          760  +    use this variable always check if it exists via
          761  +    <strong><code>info exists login</code></strong></li>
          762  +    <li>$manifest_version. The fossil version</li>
          763  +    <li>$manifest_date. The date that fossil version was
          764  +    compiled</li>
          765  +  </ul>
          766  +
          767  +  <h3>Functions</h3>
          768  +  <p>
          769  +     These are only avaible between 
          770  +  &lt;th1&gt; and &lt;/th1&gt;
          771  +  </p>
          772  +  <ul compact='compact'>
          773  +    <li>combobox name text-list numlines. Generates a select box
          774  +    with name="name" and a cgi-parameter of "name"</li>
          775  +    <li>enable_output boolean</li>
          776  +    <li>linecount string max min. Counts the numer of newlines in
          777  +    string but not more then max and not less then min</li>
          778  +    <li>hascap string. return true if user has all
          779  +    capabilities in string</li>
          780  +    <li>htmlize string. excapes all chars in string which have
          781  +    special meaning in HTML</li>
          782  +    <li>date returns the sqlite value of datetime('now')</li>
          783  +    <li>html string output html</li>
          784  +    <li>puts string prints the string</li>
          785  +    <li>wiki string. The string is in wiki format. translate it to
          786  +    HTML</li>
          787  +  </ul>
          788  +<nowiki>
          789  +  <h3>Example from admin/header</h3>
          790  +  <pre>
          791  +&lt;html&gt;
          792  +&lt;head&gt;
          793  +&lt;title&gt;<strong>$&lt;project_name&gt;</strong>: <strong>$&lt;title&gt;</strong>&lt;/title&gt;
          794  +&lt;link rel="alternate" type="application/rss+xml" title="RSS Feed"
          795  +      href="<strong>$baseurl</strong>/timeline.rss"&gt;
          796  +&lt;link rel="stylesheet" href="$baseurl/style.css" type="text/css"
          797  +      media="screen"&gt;
          798  +&lt;/head&gt;
          799  +&lt;body&gt;
          800  +&lt;div class="header"&gt;
          801  +  &lt;div class="logo"&gt;
          802  +    &lt;img src="<strong>$baseurl</strong>/logo" alt="logo"&gt;
          803  +    &lt;br&gt;&lt;nobr&gt;<strong>$&lt;project_name&gt;</strong>&lt;/nobr&gt;
          804  +  &lt;/div&gt;
          805  +  &lt;div class="title"&gt;<strong>$&lt;title&gt;</strong>&lt;/div&gt;
          806  +  &lt;div class="status"&gt;&lt;nobr&gt;<strong>&lt;th1&gt;</strong>
          807  +     if {<strong>[info exists login]</strong>} {
          808  +       puts "Logged in as <strong>$login</strong>"
          809  +     } else {
          810  +       puts "Not logged in"
          811  +     }
          812  +  &lt;/th1&gt;&lt;/nobr&gt;&lt;/div&gt;
          813  +&lt;/div&gt;
          814  +&lt;div class="mainmenu"&gt;&lt;th1&gt;
          815  +html "&lt;a href='<strong>$baseurl$index_page</strong>'&gt;Home&lt;/a&gt; "
          816  +if {<strong>[hascap h]</strong>]} {
          817  +  html "&lt;a href='$baseurl/dir'&gt;Files&lt;/a&gt; "
          818  +}
          819  +</pre>
          820  +
          821  +  <h3>Caveats</h3>
          822  +
          823  +  <ul compact='compact'>
          824  +    <li>puts "[hello hello]" doesn't work because [ triggers the
          825  +    interpeter, use puts "&amp;#91hello hello]'</li>
          826  +  </ul>
          827  +</nowiki>
          828  +</div>
          829  +