D 2009-11-06T04:11:31
L Cookbook
P 9b5352480c0ddce1367485a938291ee30fc8f84d
U anonymous
W 42847
<h1>Fossil Cookbook</h1>
The <cite>Fossil</cite> Cookbook is a collection of task-oriented instructions for intermediate users who wish to do more than basic operations with their <cite>Fossil</cite> repositories. The [Tutorial|tutorial] is a more suitable place for newcomers trying to learn the basic concepts to go first before tackling these recipes.
<h2>Index</h2>
<ul>
<li> Server recipes:
<ul>
<li> <a href="#CGI">Using <cite>Fossil</cite>'s Built-In CGI</a>
</ul>
<li> <a href="#env">Using Environment variables</a>
<li> <a href="#css">Example CSS</a>
<li> <a href="#source-hilight">Source highlighting</a>
<li> <a href="#win32dev">Fossil Win32 Development Machine setup</a>
<li> <a href="#wysiwig">Javascript HTML WYSIWYG editor control</a>
<ul>
<li> <a href="#tinymce">TinyMCE</a>
<li> <a href="#markitup">markitup!</a>
</ul>
</ul>
<h2><a name="CGI">Using <cite>Fossil</cite>'s Built-In CGI</a></h2>
<h3>Motivation</h3>
* You want to share a repository through your existing web infrastructure.
* You want to share more than one repository at the same time.
<h3>Problem</h3>
Unlike some other distributed SCMs, <cite>Fossil</cite> can only clone, push, pull and and otherwise interact through repositories over HTTP. This can be simply and easily managed through use of the <code>fossil server</code> and/or <code>fossil ui</code> commands, of course, but this is really only adequate for ad-hoc repository sharing. Consider, for example, sharing ten repositories. Using the built-in server would require you to open ten ports in your firewall to permit access. Any serious sharing will require something more robust and permanent, and solutions for doing so are described below.
<h3>Solution</h3>
<cite>Fossil</cite> supports three different ways to share repositories. For ad-hoc sharing <code>fossil server/ui</code> is more than adequate. For more robust solutions, however, the use of <cite>(x)inetd</cite> or CGI support is indicated.
Setting up fossil for CGI support is simple. (Setting up your web server for CGI support may or may not be simple, but it is out of scope of this recipe. Consult your web server/service provider's documentation for this.)
<h4>UNIX</h4>
1. Find your CGI scripts directory (if applicable). This is commonly something like <base>/cgi-bin/, but does not have to be.
2. Inside that directory build a script file which looks like this:<br><code><pre> #! /usr/bin/env fossil<br> repository: /full/path/to/repository/file.fsl</pre></code>
3. Ensure that the script file so generated is set executable for the CGI user account.
4. Ensure that every directory in the path leading to the repository is browseable (chmod +x) to the CGI user account.
5. Ensure that the repository file is readable <em>and</em> writable to the CGI user account.
The following <cite>bash</cite> script can be run from within the directory containing the <cite>Fossil</cite> repositories to be shared (and, of course, altered for your setup) to set some of the constraints above up automatically:
<nowiki><font face="monospace">
<font color="#a52a2a"> 1 </font><font color="#0000ff">#! /usr/bin/env bash</font><br>
<font color="#a52a2a"> 2 </font><font color="#008b8b">CGI_ROOT</font>=/usr/lib/fossil<br>
<font color="#a52a2a"> 3 </font><font color="#008b8b">REPOSITORY_OWNER</font>=michael<br>
<font color="#a52a2a"> 4 </font><font color="#008b8b">CGI_GROUP</font>=www-data<br>
<font color="#a52a2a"> 5 </font><font color="#a52a2a"><b>if</b></font> <font color="#a52a2a"><b>[</b></font> <font color="#6a5acd">`whoami`</font> <font color="#a52a2a"><b>=</b></font> <font color="#ff00ff">'root'</font> <font color="#a52a2a"><b>]</b></font><br>
<font color="#a52a2a"> 6 </font><font color="#a52a2a"><b>then</b></font><br>
<font color="#a52a2a"> 7 </font> <font color="#a52a2a"><b>for</b></font> repository <font color="#a52a2a"><b>in</b></font> *.fsl<br>
<font color="#a52a2a"> 8 </font> <font color="#a52a2a"><b>do</b></font><br>
<font color="#a52a2a"> 9 </font> <font color="#008b8b">SOURCE</font>=<font color="#6a5acd">`</font><font color="#a52a2a"><b>pwd</b></font><font color="#6a5acd">`</font>/<font color="#a020f0">$repository</font><br>
<font color="#a52a2a">10 </font> <font color="#008b8b">DESTINATION</font>=<font color="#a020f0">$CGI_ROOT</font>/<font color="#a020f0">${</font><font color="#a020f0">repository</font><font color="#a52a2a"><b>%</b></font>.fsl<font color="#a020f0">}</font><br>
<font color="#a52a2a">11 </font> <font color="#a52a2a"><b>echo</b></font><font color="#ff00ff"> </font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff">#! /usr/bin/env fossil</font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff"> </font><font color="#a52a2a"><b>></b></font> <font color="#a020f0">$DESTINATION</font><br>
<font color="#a52a2a">12 </font> <font color="#a52a2a"><b>echo</b></font><font color="#ff00ff"> </font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff">repository: </font><font color="#a020f0">$SOURCE</font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff"> </font><font color="#a52a2a"><b>>></b></font> <font color="#a020f0">$DESTINATION</font><br>
<font color="#a52a2a">13 </font> chown <font color="#a020f0">$REPOSITORY_OWNER</font>:<font color="#a020f0">$CGI_GROUP</font> <font color="#a020f0">$SOURCE</font><br>
<font color="#a52a2a">14 </font> <font color="#a52a2a"><b>chmod</b></font> <font color="#ff00ff">664</font> <font color="#a020f0">$SOURCE</font><br>
<font color="#a52a2a">15 </font> chown root:root <font color="#a020f0">$DESTINATION</font><br>
<font color="#a52a2a">16 </font> <font color="#a52a2a"><b>chmod</b></font> <font color="#ff00ff">755</font> <font color="#a020f0">$DESTINATION</font><br>
<font color="#a52a2a">17 </font> <font color="#a52a2a"><b>done</b></font><br>
<font color="#a52a2a">18 </font><font color="#a52a2a"><b>else</b></font><br>
<font color="#a52a2a">19 </font> sudo <font color="#a020f0">$0</font> <font color="#a020f0">$*</font><br>
<font color="#a52a2a">20 </font><font color="#a52a2a"><b>fi</b></font><br>
</font></nowiki>
Here is a little perl script to put in your cgi-bin to list all the fossils you are publishing:
<nowiki>
<pre>
<font color="#a52a2a"> 1 </font> #!/usr/bin/perl -w
<font color="#a52a2a"> 2 </font> <font color="#8B008B"><b>my</b></font> <font color="#00688B">$CGI_BIN</font> = <font color="#CD5555">'/Library/WebServer/CGI-Executables'</font><font color="#000000">;</font>
<font color="#a52a2a"> 3 </font> <font color="#8B008B"><b>my</b></font> <font color="#00688B">@files</font> = <font color="#CD5555">`grep -l repository: $CGI_BIN/* `</font><font color="#000000">;</font>
<font color="#a52a2a"> 4 </font> <font color="#8B008B"><b>print</b></font> <font color="#CD5555"><b><<EOM</b></font><font color="#000000">;</font>
<font color="#a52a2a"> 5 </font> <font color="#CD5555"><i>Content-Type: text/html</i></font>
<font color="#a52a2a"> 6 </font>
<font color="#a52a2a"> 7 </font> <font color="#CD5555"><i>Fossils for this server</i></font>
<font color="#a52a2a"> 8 </font> <font color="#CD5555"><i><ul></i></font>
<font color="#a52a2a"> 9 </font> <font color="#CD5555"><b>EOM</b></font>
<font color="#a52a2a"> 10 </font>0
<font color="#a52a2a"> 11 </font>1 <font color="#8B008B"><b>for</b></font> <font color="#000000">(</font><font color="#00688B">@files</font><font color="#000000">)</font> <font color="#000000">{</font>
<font color="#a52a2a"> 12 </font>2 <font color="#CD5555">s{.*/}{}</font><font color="#000000">;</font>
<font color="#a52a2a"> 13 </font>3 <font color="#8B008B"><b>next</b></font> <font color="#8B008B"><b>if</b></font> <font color="#CD5555">/~$/</font><font color="#000000">;</font>
<font color="#a52a2a"> 14 </font>4 <font color="#8B008B"><b>print</b></font> <font color="#CD5555">"<li><a href='$_'>$_</a></li>\n"</font><font color="#000000">;</font>
<font color="#a52a2a"> 15 </font>5 <font color="#000000">}</font>
<font color="#a52a2a"> 16 </font>6 <font color="#8B008B"><b>print</b></font> <font color="#CD5555">"</ul>\n"</font><font color="#000000">;</font>
</pre>
<pre>
#!/usr/bin/perl -w
my $CGI_BIN = '/Library/WebServer/CGI-Executables';
my @files = `grep -l repository: $CGI_BIN/* `;
print <<EOM;
Content-Type: text/html
Fossils for this server
<ul>
EOM
for (@files) {
s{.*/}{};
next if /~$/;
print "<li><a href='$_'>$_</a></li>\n";
}
print "</ul>\n";</pre>
</nowiki>
The following <cite>apache2</cite> configuration can be used to run the root of a web site with fossil, but still allow other services / documents to be reached via specific URLs. Replace "code.autonomo.us" with your site's name and "dclark@pobox.com" with your email.
<verbatim>
NameVirtualHost *:80
<VirtualHost *:80>
ServerName code.autonomo.us
ServerAdmin dclark@pobox.com
ErrorLog /var/log/apache2/code.autonomo.us-error.log
LogLevel warn
CustomLog /var/log/apache2/code.autonomo.us-access.log combined
ServerSignature On
DocumentRoot /var/www/
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
# Fossil SCM at root of web site (http://example.com) configuration...
RewriteEngine On
# RewriteCond - One for every URL we don't want Fossil SCM to serve. In the
# example, requests that go to the /var/www/tmp directory and
# the /usr/lib/cgi-bin directoty are ignored by Fossil SCM.
RewriteCond %{REQUEST_URI} !^/tmp/.*$
RewriteCond %{REQUEST_URI} !^/cgi-bin/.*$
RewriteRule ^(.*)$ /usr/lib/cgi-bin/code.autonomo.us/$1 [T=application/x-httpd-cgi]
</VirtualHost>
</verbatim>
/usr/lib/cgi-bin/code.autonomo.us is just a standard fossil CGI file; it looks like this:
<verbatim>
#!/usr/bin/fossil
repository: /srv/fossil-scm/code.autonomo.us.fossil-scm
</verbatim>
<h3>Another solution to <i>automatically</i> serve multiple repositories</h3>
With the following CGI script (I have named it <samp>p</samp> simply) it is possible to define a location where all the your repositories should be located (in this example: <samp>/home/repos/fossil</samp>). All the repositories are named according the scheme <samp><project name>.fsl</samp> for sake of this example.
If this script is called alone (like e.g.: <samp>http://your.server.here/cgi-bin/p</samp>), it will list all repositories located under <samp>$REPOSROOT</samp>, <b>if</b> there <b>does not</b> exist a corresponding file <samp>.<project name></samp> (that mechanism is used to <i>hide</i> some repository in the listing).
If the script is called like e.g. <samp>http://your.server.here/cgi-bin/p/<project name></samp>, then the corresponding repository will be selected to work with.
The lines 5 - 8 in the script below allow configuration for you needs. You have to chose, what fossil binary to use, what extension your repository databases have and where all your databases are located.
<nowiki>
<font face="monospace">
<font color="#a52a2a"> 1 </font><font color="#0000ff">#!/bin/sh</font><br>
<font color="#a52a2a"> 2 </font><br>
<font color="#a52a2a"> 3 </font><font color="#0000ff">### Configuration section ###</font><br>
<font color="#a52a2a"> 4 </font><br>
<font color="#a52a2a"> 5 </font><font color="#008b8b">TITLE</font>=<font color="#a52a2a"><b>"</b></font><font color="#ff00ff"><h2>Fossil repositories</h2></font><font color="#a52a2a"><b>"</b></font><br>
<font color="#a52a2a"> 6 </font><font color="#008b8b">FOSSIL</font>=/usr/local/bin/fossil<br>
<font color="#a52a2a"> 7 </font><font color="#008b8b">REPOSROOT</font>=/home/repos/fossil<br>
<font color="#a52a2a"> 8 </font><font color="#008b8b">REPOSEXT</font>=<font color="#a52a2a"><b>"</b></font><font color="#ff00ff">.fsl</font><font color="#a52a2a"><b>"</b></font><br>
<font color="#a52a2a"> 9 </font><br>
<font color="#a52a2a">10 </font><font color="#0000ff">### Processing section -- nothing to configure here! ###</font><br>
<font color="#a52a2a">11 </font><br>
<font color="#a52a2a">12 </font><font color="#a52a2a"><b>set</b></font><font color="#008b8b"> </font><font color="#6a5acd">-f</font><font color="#008b8b"> </font>; <font color="#0000ff"># disable filename globbing</font><br>
<font color="#a52a2a">13 </font><br>
<font color="#a52a2a">14 </font><font color="#0000ff">## Some helper functions</font><br>
<font color="#a52a2a">15 </font><br>
<font color="#a52a2a">16 </font><font color="#008b8b">HeaderText () {</font><br>
<font color="#a52a2a">17 </font> <font color="#a52a2a"><b>if </b></font><font color="#a52a2a"><b>[</b></font> <font color="#a52a2a"><b>-z</b></font> <font color="#a52a2a"><b>"</b></font><font color="#a020f0">$headerWritten</font><font color="#a52a2a"><b>"</b></font> <font color="#a52a2a"><b>]</b></font><font color="#a52a2a"><b>;</b></font> <font color="#a52a2a"><b>then</b></font><br>
<font color="#a52a2a">18 </font> <font color="#a52a2a"><b>echo</b></font><font color="#ff00ff"> </font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff">Content-type: text/plain; charset=iso-8859-1</font><font color="#a52a2a"><b>"</b></font><br>
<font color="#a52a2a">19 </font> <font color="#a52a2a"><b>echo</b></font><br>
<font color="#a52a2a">20 </font> <font color="#008b8b">headerWritten</font>=<font color="#ff00ff">1</font><br>
<font color="#a52a2a">21 </font> <font color="#a52a2a"><b>fi</b></font><br>
<font color="#a52a2a">22 </font><font color="#008b8b">}</font><br>
<font color="#a52a2a">23 </font><br>
<font color="#a52a2a">24 </font><font color="#008b8b">HeaderHTML () {</font><br>
<font color="#a52a2a">25 </font> <font color="#a52a2a"><b>if </b></font><font color="#a52a2a"><b>[</b></font> <font color="#a52a2a"><b>-z</b></font> <font color="#a52a2a"><b>"</b></font><font color="#a020f0">$headerWritten</font><font color="#a52a2a"><b>"</b></font> <font color="#a52a2a"><b>]</b></font><font color="#a52a2a"><b>;</b></font> <font color="#a52a2a"><b>then</b></font><br>
<font color="#a52a2a">26 </font> <font color="#a52a2a"><b>echo</b></font><font color="#ff00ff"> </font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff">Content-type: text/html; charset=iso-8859-1</font><font color="#a52a2a"><b>"</b></font><br>
<font color="#a52a2a">27 </font> <font color="#a52a2a"><b>echo</b></font><br>
<font color="#a52a2a">28 </font> <font color="#008b8b">headerWritten</font>=<font color="#ff00ff">1</font><br>
<font color="#a52a2a">29 </font> <font color="#a52a2a"><b>fi</b></font><br>
<font color="#a52a2a">30 </font><font color="#008b8b">}</font><br>
<font color="#a52a2a">31 </font><br>
<font color="#a52a2a">32 </font><font color="#008b8b">Error () {</font><br>
<font color="#a52a2a">33 </font> HeaderHTML<br>
<font color="#a52a2a">34 </font> <font color="#a52a2a"><b>echo</b></font><font color="#ff00ff"> </font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff"><p><font color=</font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff">red</font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff">>ERROR: </font><font color="#a020f0">$1</font><font color="#ff00ff"></font></p></font><font color="#a52a2a"><b>"</b></font><br>
<font color="#a52a2a">35 </font> <font color="#a52a2a"><b>exit</b></font> <font color="#ff00ff">1</font><br>
<font color="#a52a2a">36 </font><font color="#008b8b">}</font><br>
<font color="#a52a2a">37 </font><br>
<font color="#a52a2a">38 </font><font color="#008b8b">P () {</font><br>
<font color="#a52a2a">39 </font> HeaderText<br>
<font color="#a52a2a">40 </font> <font color="#a52a2a"><b>for </b></font>var <font color="#a52a2a"><b>in</b></font> <font color="#a020f0">$*</font><font color="#a52a2a"><b>;</b></font> <font color="#a52a2a"><b>do</b></font><br>
<font color="#a52a2a">41 </font> <font color="#a52a2a"><b>eval</b></font> <font color="#a52a2a"><b>echo</b></font><font color="#ff00ff"> </font><font color="#a020f0">$var</font><font color="#ff00ff"> = </font><font color="#a52a2a"><b>"</b></font><font color="#6a5acd">\$</font><font color="#a020f0">$var</font><font color="#a52a2a"><b>"</b></font><br>
<font color="#a52a2a">42 </font> <font color="#a52a2a"><b>done</b></font><br>
<font color="#a52a2a">43 </font><font color="#008b8b">}</font><br>
<font color="#a52a2a">44 </font><br>
<font color="#a52a2a">45 </font><font color="#0000ff">## Do the real work here ...</font><br>
<font color="#a52a2a">46 </font><br>
<font color="#a52a2a">47 </font><font color="#008b8b">project</font>=<font color="#6a5acd">`echo </font><font color="#a020f0">$PATH_INFO</font><font color="#6a5acd"> </font><font color="#a52a2a"><b>|</b></font><font color="#6a5acd"> sed -e </font><font color="#a52a2a"><b>'</b></font><font color="#ff00ff">s!/</font><font color="#6a5acd">\(</font><font color="#ff00ff">[^/]*</font><font color="#6a5acd">\)</font><font color="#ff00ff">.*!\1!</font><font color="#a52a2a"><b>'|</b></font><font color="#6a5acd"> tr </font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff">[A-Z]</font><font color="#a52a2a"><b>"</b></font><font color="#6a5acd"> </font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff">[a-z]</font><font color="#a52a2a"><b>"</b></font><font color="#6a5acd">`</font><br>
<font color="#a52a2a">48 </font><font color="#008b8b">repos</font>=<font color="#a52a2a"><b>"</b></font><font color="#a020f0">$REPOSROOT</font><font color="#ff00ff">/</font><font color="#a020f0">$project$REPOSEXT</font><font color="#a52a2a"><b>"</b></font><br>
<font color="#a52a2a">49 </font><br>
<font color="#a52a2a">50 </font><font color="#a52a2a"><b>if </b></font><font color="#a52a2a"><b>[</b></font> <font color="#a52a2a"><b>-r</b></font> <font color="#a52a2a"><b>"</b></font><font color="#a020f0">$repos</font><font color="#a52a2a"><b>"</b></font> <font color="#a52a2a"><b>]</b></font><font color="#a52a2a"><b>;</b></font> <font color="#a52a2a"><b>then</b></font><br>
<font color="#a52a2a">51 </font> <font color="#008b8b">PATH_INFO</font>=<font color="#6a5acd">`echo </font><font color="#a020f0">$REQUEST_URI</font><font color="#6a5acd"> </font><font color="#a52a2a"><b>|</b></font><font color="#6a5acd"> sed -e </font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff">s!^</font><font color="#a020f0">$SCRIPT_NAME</font><font color="#ff00ff">/</font><font color="#a020f0">$project</font><font color="#6a5acd">\\</font><font color="#ff00ff">([^?]*</font><font color="#6a5acd">\\</font><font color="#ff00ff">).*!</font><font color="#6a5acd">\\</font><font color="#ff00ff">1!</font><font color="#a52a2a"><b>"</b></font><font color="#6a5acd">`</font><br>
<font color="#a52a2a">52 </font><font color="#a52a2a"><b> :</b></font> <font color="#a020f0">${</font><font color="#a020f0">PATH_INFO</font><font color="#a52a2a"><b>:=</b></font><font color="#ff00ff">/</font><font color="#a020f0">}</font><br>
<font color="#a52a2a">53 </font> <font color="#008b8b">SCRIPT_NAME</font>=<font color="#a020f0">$SCRIPT_NAME</font>/<font color="#a020f0">$project</font><br>
<font color="#a52a2a">54 </font> <font color="#008b8b">TEMPFILE</font>=<font color="#6a5acd">`mktemp /tmp/fossil-</font><font color="#a020f0">$project</font><font color="#6a5acd">.XXXXXX`</font> <font color="#a52a2a"><b>||</b></font> Error <font color="#a52a2a"><b>"</b></font><font color="#ff00ff">Couldn't create tempfile</font><font color="#a52a2a"><b>"</b></font><br>
<font color="#a52a2a">55 </font> <font color="#a52a2a"><b>trap</b></font> <font color="#a52a2a"><b>"</b></font><font color="#ff00ff">rm -f </font><font color="#a020f0">$TEMPFILE</font><font color="#a52a2a"><b>"</b></font> EXIT QUIT INT TERM<br>
<font color="#a52a2a">56 </font> <font color="#a52a2a"><b>echo</b></font><font color="#ff00ff"> repository: </font><font color="#a020f0">$repos</font><font color="#ff00ff"> </font><font color="#a52a2a"><b>></b></font> <font color="#a020f0">$TEMPFILE</font><br>
<font color="#a52a2a">57 </font> <font color="#a020f0">$FOSSIL</font> cgi <font color="#a020f0">$TEMPFILE</font><br>
<font color="#a52a2a">58 </font><font color="#a52a2a"><b>elif</b></font> <font color="#a52a2a"><b>[</b></font> <font color="#a52a2a"><b>-z</b></font> <font color="#a52a2a"><b>"</b></font><font color="#a020f0">$project</font><font color="#a52a2a"><b>"</b></font> <font color="#a52a2a"><b>]</b></font><font color="#a52a2a"><b>;</b></font> <font color="#a52a2a"><b>then</b></font><br>
<font color="#a52a2a">59 </font> HeaderHTML<br>
<font color="#a52a2a">60 </font> <font color="#a52a2a"><b>echo</b></font><font color="#ff00ff"> </font><font color="#a52a2a"><b>"</b></font><font color="#a020f0">$TITLE</font><font color="#a52a2a"><b>"</b></font><br>
<font color="#a52a2a">61 </font> <font color="#a52a2a"><b>echo</b></font><font color="#ff00ff"> </font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff"><ul></font><font color="#a52a2a"><b>"</b></font><br>
<font color="#a52a2a">62 </font> find <font color="#a020f0">$REPOSROOT</font> -name <font color="#a52a2a"><b>"</b></font><font color="#ff00ff">*</font><font color="#a020f0">$REPOSEXT</font><font color="#a52a2a"><b>"</b></font> <font color="#a52a2a"><b>|</b></font> \<br>
<font color="#a52a2a">63 </font> while <font color="#a52a2a"><b>read</b></font> repos<font color="#a52a2a"><b>;</b></font> <font color="#a52a2a"><b>do</b></font><br>
<font color="#a52a2a">64 </font> <font color="#008b8b">project</font>=<font color="#6a5acd">`basename </font><font color="#a020f0">$repos</font><font color="#6a5acd"> </font><font color="#a020f0">$REPOSEXT</font><font color="#6a5acd">`</font><br>
<font color="#a52a2a">65 </font> <font color="#a52a2a"><b>if </b></font><font color="#a52a2a"><b>[</b></font> <font color="#a52a2a"><b>-f</b></font> <font color="#a020f0">$repos</font> <font color="#a52a2a"><b>-a</b></font> <font color="#a52a2a"><b>!</b></font> <font color="#a52a2a"><b>-e</b></font> <font color="#a020f0">$REPOSROOT</font>/.<font color="#a020f0">$project</font> <font color="#a52a2a"><b>]</b></font><font color="#a52a2a"><b>;</b></font> <font color="#a52a2a"><b>then</b></font><br>
<font color="#a52a2a">66 </font> <font color="#a52a2a"><b>echo</b></font><font color="#ff00ff"> </font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff"><li><a href='</font><font color="#a020f0">${</font><font color="#a020f0">REQUEST_URI</font><font color="#a020f0">}</font><font color="#ff00ff">/</font><font color="#a020f0">$project</font><font color="#ff00ff">'></font><font color="#a020f0">$project</font><font color="#ff00ff"></a></li></font><font color="#a52a2a"><b>"</b></font><br>
<font color="#a52a2a">67 </font> <font color="#a52a2a"><b>fi</b></font><br>
<font color="#a52a2a">68 </font> <font color="#a52a2a"><b>done</b></font><br>
<font color="#a52a2a">69 </font> <font color="#a52a2a"><b>echo</b></font><font color="#ff00ff"> </font><font color="#a52a2a"><b>"</b></font><font color="#ff00ff"></ul></font><font color="#a52a2a"><b>"</b></font><br>
<font color="#a52a2a">70 </font><font color="#a52a2a"><b>else</b></font><br>
<font color="#a52a2a">71 </font> Error <font color="#a52a2a"><b>"</b></font><font color="#ff00ff">No such project: </font><font color="#a020f0">$project</font><font color="#a52a2a"><b>"</b></font><br>
<font color="#a52a2a">72 </font><font color="#a52a2a"><b>fi</b></font><br>
<font color="#a52a2a">73 </font><br>
<font color="#a52a2a">74 </font><font color="#a52a2a"><b>exit</b></font> <font color="#ff00ff">0</font><br>
</font>
</nowiki>
<h4>Windows</h4>
<p>While it is far from a perfect set of instructions.. here are some quick notes that should help windows users along the way...</p>
<ul>
<li>you need fossil.exe accessible by your web server or on your path.. easiest is to just chuck it in \%SYSTEM_ROOT%\ (usually c:\windows\) </li>
<li>assuming you are running apache, you need to either add the ExecCGI to the options on your DocumentRoot, or make sure the ScriptAlias directive is set and put your .cgi files in that folder..</li>
<li>the contents of your cgi file needs to essentially the same as above.. however paths needs to be windows friendly.. i have made sure that all folders on my test box are free of spaces, and as such this file works for me (obviously your paths may differ)
<pre>
#! fossil.exe
repository: c:/wamp/www/dev/accounts.fossil
</pre>
I suppose you could put fossil.exe somewhere more specific and set the path to it as well, but since you are probably using the same executable for cmdline and cgi it kind of just makes sense to put it somewhere more accessible</li>
<li>As with most Windows based web instructions, permission are not as important, however at the least, you need to make sure that your repository is not flagged read-only, as you will encounter database errors if it is.</li>
</ul>
<h3>Discussion</h3>
Using the CGI server is the best solution combining an existing web infrastructure and the sharing of many <cite>Fossil</cite> repositories. Unlike the ad-hoc solution which requires, in effect, a separate port for each simultaneously-shared repository, and which requires several instances of fossil running -- one for each shared repository -- the CGI approach uses URLs to distinguish between repositories and only (briefly) runs a copy of fossil when the repository is actually accessed.
Sharing repositories with CGI is really only worth the effort if more than one repository is being shared, however. With only one being shared, <code>fossil server</code> is likely more than adequate or the use of (x)inetd may be indicated. If, however, there is already an existing web infrastructure in place, CGI still may be preferred if only for consistency and maintainability of the system as a whole.
<h2><a name="env">Using Environment variables</a></h2>
<h3>Motivation</h3>
* Want to use a different editor for checkins (Unix/Windows)
* Use a proxy if you are behind a firewall
<h3>Solution</h3>
Environment variables are used to customize some programme behaviour. On Linux/Unix they can be set in you ~/.bashrc or even on command line. On Windows they can be set in the system settings.
<cite>Fossil</cite> checks the following environment variables:
* VISUAL/EDITOR
* http_proxy
* TMP_DIR
* GATEWAY_INTERFACE
* SQLITE_FORCE_PROXY_LOCKING
* USER
* USERNAME
<b>VISUAL/EDITOR</b> contain the editor of your choice that is used to write the commit file.
<b>TMP_DIR</b> specifies the directory for temporary files.
<b>GATEWAY_INTERFACE</b> ???
<b>SQLITE_FORCE_PROXY_LOCKING</b> ???
<b>USER</b>
<b>USERNAME</b>
<h2><a name="css">Example CSS</a></h2>
<h3>Motivation</h3>
The default UI may not be stylish in everyones eyes.
It is up to you to change it. See the CSS code below from this site [http://fossil.wanderinghorse.net/index.cgi/index|Wandering Horse]
<nowiki>
<pre>
/* General settings for the entire page */
body {
margin: 0ex 1ex;
padding: 0px;
background-color: white;
font-family: "sans serif";
}
/* Make the links in the footer less ugly... */
a { color: #000f6a; }
a:link { color: #000f6a; }
a:visited { color: #000f6a; }
a:hover { background-color: #e3e3e3; }
hr {
height: 3px;
border-top: none; /*1px dashed #005;*/
border-bottom: 1px dashed #005;
border-left: none;
border-right: none;
}
/* The project logo in the upper left-hand corner of each page */
div.logo {
display: table-cell;
text-align: center;
vertical-align: bottom;
color: #000f6a;
}
/* The page title centered at the top of each page */
div.title {
display: table-cell;
font-size: 2em;
font-weight: bold;
text-align: center;
color: #000f6a;
vertical-align: bottom;
width: 100%;
}
/* The login status message in the top right-hand corner */
div.status {
display: table-cell;
text-align: right;
vertical-align: bottom;
color: #000f6a;
font-size: 0.8em;
}
/* The header across the top of the page */
div.header {
display: table;
width: 100%;
text-align: center;
}
/* The main menu bar that appears at the top of the page beneath
** the header */
div.mainmenu {
padding: 2px 5px 2px 5px;
font-size: 0.9em;
text-align: center;
letter-spacing: 1px;
background-color: #e3e3e3;
color: #000f6a;
border: 1px inset black;
}
/* The submenu bar that *sometimes* appears below the main menu */
div.submenu {
padding: 2px 5px 2px 5px;
font-size: 0.9em;
text-align: center;
background-color: #e3e3e3;
color: #000f6a;
}
div.mainmenu a, div.mainmenu a:visited, div.submenu a, div.submenu a:visited {
padding: 2px 10px 2px 10px;
color: #000f6a;
background-color: #e3e3e3;
text-decoration: none;
}
div.mainmenu a:hover, div.submenu a:hover {
color: #e3e3e3;
background-color: #000f6a;
}
/* All page content from the bottom of the menu or submenu down to
** the footer */
div.content {
padding: 0ex 1ex 0ex 2ex;
}
/* Some pages have section dividers */
div.section {
margin-bottom: 0px;
margin-top: 1em;
padding: 1px 1px 1px 1px;
font-size: 1.2em;
font-weight: bold;
background-color: #e3e3e3;
color: #000f6a;
}
/* The "Date" that occurs on the left hand side of timelines */
div.divider {
background-color: #e3e3e3;
color: #000f6a;
border: 1px #bbbbff solid;
font-size: 1em; font-weight: normal;
padding: .25em;
margin: .2em 0 .2em 0;
float: left;
clear: left;
}
/* The footer at the very bottom of the page */
div.footer {
font-size: 0.8em;
padding: 2px 5px 2px 5px;
text-align: center;
letter-spacing: 1px;
background-color: #e3e3e3;
color: #000f6a;
border: 1px inset black;
}
/* Make the links in the footer less ugly... */
div.footer a { color: #000f6a; }
div.footer a:link { color: #000f6a; }
div.footer a:visited { color: #000f6a; }
div.footer a:hover { background-color: #000f6a; color: #e3e3e3; }
/* verbatim blocks */
pre.verbatim {
background-color: #f5f5f5;
padding: 0.5em;
}
/* The label/value pairs on (for example) the vinfo page */
table.label-value th {
vertical-align: top;
text-align: right;
padding: 0.2ex 2ex;
}
/* For marking important UI elements which shouldn't be
lightly dismissed. I mainly use it to mark "not yet
implemented" parts of a page. Whether or not to have
a 'border' attribute set is arguable. */
.achtung {
color: #ff0000;
background: #ffff00;
border: 1px solid #ff0000;
}
table.fossil_db_generic_query_view {
border-spacing: 0px;
border: 1px solid black;
}
table.fossil_db_generic_query_view td {
padding: 2px 1em 2px 1em;
}
table.fossil_db_generic_query_view tr {
}
table.fossil_db_generic_query_view tr.even {
background: #ffffff;
}
table.fossil_db_generic_query_view tr.odd {
background: #e5e5e5;
}
table.fossil_db_generic_query_view tr.header {
background: #558195;
font-size: 1.5em;
color: #ffffff;
}
</pre>
</nowiki>
<h2><a name="source-hilight">Source highlighting</a></h2>
<h3>Motivation</h3>
* You want to have source code highlighting for the files in your repository
<h3>Problem</h3>
The main purpose of Fossil is to do versioning the source code. Although it provides a standalone server and lets you navigate through the repository files additional features like source code highlighting from my perspective (I am not a developer of Fossil) is out of scope for an SCM. Just keep the Unix principle: small little programs that do their task and do it well.
However to have a source code highlighting in the presented web pages would still be desirable.
<h3>Solution</h3>
There are two scenarios how to implement such a feature:
* Fossil pipes the source code through a filter before sending it to the browser. The filter could be defined as a configuration option to Fossil. One solution for this might be the <a href="http://www.gnu.org/software/src-highlite">GNU Source code Highlighting</a> program.
* Use a Javascript library that renders the code within your browser. One solution for this might be <a href="http://code.google.com/p/syntaxhighlighter">Google Syntax Highlighter</a>
I estimate that the <i>pipe</i> solution needs some more work/ code changes. Thus I am solely looking at the Javascript solution.
The SyntaxHighlighter is a library of some Javascript files, a little Flash application and a CSS file. The Flash application is for copying to clipboard, print and view source. You have the option to include all the files into your repository or use the files hosted at Google. The latter may only be an option if you are connected to internet all the time.
For syntax highlighting to work the Header and Footer templates need to be modified and a little code change has to be applied to the Fossil sources.
The examples below assume you have added the syntax highlighting library to your repository into a directory www/scripts.
<p>
<b>Header</b>
<pre>
<html>
<head>
<title>$<project_name>: $<title></title>
<link rel="alternate" type="application/rss+xml" title="RSS Feed"
href="$baseurl/timeline.rss">
<link rel="stylesheet" href="$baseurl/style.css" type="text/css"
media="screen">
<link rel="stylesheet" href="$baseurl/doc/tip/www/SyntaxHighlighter.css" type="text/css"
media="screen">
</head>
. . .
</pre>
</p><p>
<b>Footer</b>
<pre>
</div>
<div class="footer">
Fossil version $manifest_version $manifest_date
</div>
<script language="javascript" src="$baseurl/doc/tip/www/scripts/shCore.js"></script>
<script language="javascript" src="$baseurl/doc/tip/www/scripts/shBrushCpp.js"></script>
<script language="javascript">
dp.SyntaxHighlighter.ClipboardSwf = '$baseurl/doc/tip/www/scripts/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>
</body></html>
</pre>
</p><p>
<b>Fossil/src/info.c</b> function artifact_page
<pre>
if( zMime==0 ){
@ <pre name="code" class="c">
@ %h(blob_str(&content))
@ </pre>
</pre>
</p>
<h3>Discussion</h3>
The Javascript solution requires a minimum to be fully supported by Fossil. Of course my litte change only applies for C/C++ files. But only little more work needs to be done to get the extension of the file a guess the file type.
The pipe solution would also be nice but would probably need some more work than this little patch.
<h3> <a name="win32dev">How to prepare your Windows XP Fossil development Environment</h3>
<h4>MinGW+NSIS/WiX</h4>
<h5>Setup TCL</h5>
<h5>Setup MinGW</h5>
<h5>Getting NSIS Windows packaging tool </h5>
<h5>Getting Fossil source code</h5>
<h5>Build the code with Makefile.win32 </h5>
<h4>Visual Studio Express 2008+WiX</h4>
<h5>Setup TCL</h5>
<h5>Setup VS2008</h5>
<h5>Getting WiX Windows MSI tool </h5>
<h5>Getting Fossil source code</h5>
<h5>Build the code with Makefile.win32</h5>
<a name="wysiwig"><h2>Javascript HTML WYSIWYG editor control</h2></a>
<h3>Motivation</h3>
* You want to edit the wiki pages with a nice editor component, instead of using plain HTML.
<h3>Problem</h3>
Fossil by itself doesn't support it.
<h3>Solution</h3>
There are pure javascript editor components that can be used for this task.
The source for the editor component is added to the repository. The html header or footer is prepared to include a javascript file and/or a CSS.
<br>
These two tips are from the mailing list:
Rene de Zwart 30. Oct. 2009
<a name="tinymce"><h4>TinyMCE</h4></a>
<p>
Source: <a href="http://tinymce.moxiecode.com/"> TinyMCE </a>
</p>
<h5> Example</h5>
<pre class="verbatim">
mkdir tiny
mkdir tiny/javascript
fossil new tinymce.fsl
fossil ui tinymce.fsl {configure the project)
download tinymce
unzip in tiny/javascript
cd tiny
fossil open ../tinymce.fsl
fossil add javascript
fossil commit -m "added timymce to the project"
fossil ui
</pre>
Select admin/headers add after the </link>
<pre class="verbatim">
<script type="text/javascript"
src="/doc/tip/javascript/tinymce/jscripts/tiny_mce/tiny_mce.js">
</script>
</pre>
and save
select admin/footer add above the first line
<pre class="verbatim">
<script type='text/javascript'>
var m = document.getElementsByTagName('textarea')
var l = m.length
var n
for(var i=0 ;i < l;i++){
<nowiki>n = m[i].name</nowiki>
if( 'comment' == n || 'cmappnd' == n || "w" == n){
tinyMCE.init({ mode : 'exact' , elements : n, theme: 'advanced'
,width : '90%' } );
}
}
</script>
</pre>
<a name="markitup"><h3>markitup!</h3></a>
<p>
Source: <a href="http://markitup.jaysalvat.com/home/"> Markitup </a>
</p>
<h5> Example</h5>
<pre class="verbatim">
mkdir markitup
mkdir markitup/javascript
fossil new markitup.fsl
fossil ui markitup.fsl {configure the project)
download markitup and jquery
unzip in markitup/javascript, cd latest, mv * .., rmdir latest
copy jquery-....js to javascript/jquery.js
cd markitup
fossil open ../markitup.fsl
fossil add javascript
fossil commit -m "added markitup an jquery to the project"
fossil ui
</pre>
select admin/headers add after the </link> put
<pre class="verbatim">
<link rel="stylesheet" type="text/css" href="/doc/tip/javascript/markitup/skins/markitup/style.css" />
<link rel="stylesheet" type="text/css" href="/doc/tip/javascript/markitup/sets/default/style.css" />
<script type="text/javascript" src="/doc/tip/javascript/jquery.js">
</script>
<script type="text/javascript" src="/doc/tip/javascript/markitup/jquery.markitup.js">
</script>
</pre>
and save
select admin/footer add above the first line
<pre class="verbatim">
<script type='text/javascript'>
var m = document.getElementsByTagName('textarea')
var l = m.length
var n
<nowiki>var mySettings = {
nameSpace: "html", // Useful to prevent multi-instances CSS conflict
onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
onCtrlEnter: {keepDefault:false, openWith:'\n<p>', closeWith:'</p>\n'},
onTab: {keepDefault:false, openWith:' '},
markupSet: [
{name:'Heading 1', key:'1', openWith:'<h1(!( class="[![Class]!]")!)>', closeWith:'</h1>', placeHolder:'Your title here...' },
{name:'Heading 2', key:'2', openWith:'<h2(!( class="[![Class]!]")!)>', closeWith:'</h2>', placeHolder:'Your title here...' },
{name:'Heading 3', key:'3', openWith:'<h3(!( class="[![Class]!]")!)>', closeWith:'</h3>', placeHolder:'Your title here...' },
{name:'Heading 4', key:'4', openWith:'<h4(!( class="[![Class]!]")!)>', closeWith:'</h4>', placeHolder:'Your title here...' },
{name:'Heading 5', key:'5', openWith:'<h5(!( class="[![Class]!]")!)>', closeWith:'</h5>', placeHolder:'Your title here...' },
{name:'Heading 6', key:'6', openWith:'<h6(!( class="[![Class]!]")!)>', closeWith:'</h6>', placeHolder:'Your title here...' },
{name:'Paragraph', openWith:'<p(!( class="[![Class]!]")!)>', closeWith:'</p>' },
{separator:'---------------' },
{name:'Bold', key:'B', openWith:'<strong>', closeWith:'</strong>' },
{name:'Italic', key:'I', openWith:'<em>', closeWith:'</em>' },
{name:'Stroke through', key:'S', openWith:'<del>', closeWith:'</del>' },
{separator:'---------------' },
{name:'Ul', openWith:'<ul>\n', closeWith:'</ul>\n' },
{name:'Ol', openWith:'<ol>\n', closeWith:'</ol>\n' },
{name:'Li', openWith:'<li>', closeWith:'</li>' },
{separator:'---------------' },
{name:'Picture', key:'P', replaceWith:'<img src="[![Source:!:http://]!]" alt="[![Alternative text]!]" />' },
{name:'Link', key:'L', openWith:'<a href="[![Link:!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
{separator:'---------------' },
{name:'Clean', replaceWith:function(h) { return h.selection.replace(/<(.*?)>/g, "") } },
{name:'Preview', call:'preview', className:'preview' }
]
}
for(var i=0 ;i < l;i++){
n = m[i].name
if( 'comment' == n || 'cmappnd' == n || "w" == n){
m[i].id = n</nowiki>
$(document).ready(function() {
$("#" + n).markItUp(mySettings);
});
}
}
</script>
</pre>
Z d99eb6ac370c9c98e5acfe3072b58e8f