Gitit User’s Guide.page 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. ---
  2. format: DocBook
  3. ...
  4. <sect1 id="gitit">
  5. <title>Gitit</title>
  6. <para>
  7. Gitit is a wiki program written in Haskell. It uses
  8. <ulink url="http://happstack.com">Happstack</ulink> for the web
  9. server and
  10. <ulink url="http://johnmacfarlane.net/pandoc">pandoc</ulink> for
  11. markup processing. Pages and uploaded files are stored in a
  12. <ulink url="http://git.or.cz">git</ulink>,
  13. <ulink url="http://darcs.net">darcs</ulink>, or
  14. <ulink url="http://mercurial.selenic.com/">mercurial</ulink>
  15. repository and may be modified either by using the VCS’s
  16. command-line tools or through the wiki’s web interface. By default,
  17. pandoc’s extended version of markdown is used as a markup language,
  18. but reStructuredText, LaTeX, HTML, DocBook, or Emacs Org-mode markup
  19. can also be used. Pages can be exported in a number of different
  20. formats, including LaTeX, RTF, OpenOffice ODT, and MediaWiki markup.
  21. Gitit can be configured to display TeX math (using
  22. <ulink url="http://github.com/jgm/texmath/tree/master">texmath</ulink>)
  23. and highlighted source code (using
  24. <ulink url="http://johnmacfarlane.net/highlighting-kate/">highlighting-kate</ulink>).
  25. </para>
  26. <para>
  27. Other features include
  28. </para>
  29. <itemizedlist>
  30. <listitem>
  31. <para>
  32. plugins: dynamically loaded page transformations written in
  33. Haskell (see <quote>Network.Gitit.Interface</quote>)
  34. </para>
  35. </listitem>
  36. <listitem>
  37. <para>
  38. categories
  39. </para>
  40. </listitem>
  41. <listitem>
  42. <para>
  43. TeX math
  44. </para>
  45. </listitem>
  46. <listitem>
  47. <para>
  48. syntax highlighting of source code files and code snippets
  49. (using highlighting-kate)
  50. </para>
  51. </listitem>
  52. <listitem>
  53. <para>
  54. caching
  55. </para>
  56. </listitem>
  57. <listitem>
  58. <para>
  59. Atom feeds (site-wide and per-page)
  60. </para>
  61. </listitem>
  62. <listitem>
  63. <para>
  64. a library, <quote>Network.Gitit</quote>, that makes it simple to
  65. include a gitit wiki in any happstack application
  66. </para>
  67. </listitem>
  68. </itemizedlist>
  69. <para>
  70. You can see a running demo at
  71. <ulink url="http://gitit.johnmacfarlane.net">http://gitit.johnmacfarlane.net</ulink>.
  72. </para>
  73. </sect1>
  74. <sect1 id="getting-started">
  75. <title>Getting started</title>
  76. <sect2 id="compiling-and-installing-gitit">
  77. <title>Compiling and installing gitit</title>
  78. <para>
  79. You’ll need the
  80. <ulink url="http://www.haskell.org/ghc/">GHC</ulink> compiler and
  81. the
  82. <ulink url="http://hackage.haskell.org/trac/hackage/wiki/CabalInstall">cabal-install</ulink>
  83. tool. GHC can be downloaded
  84. <ulink url="http://www.haskell.org/ghc/">here</ulink>. Note that,
  85. starting with release 0.5, GHC 6.10 or higher is required. For
  86. <ulink url="http://hackage.haskell.org/trac/hackage/wiki/CabalInstall">cabal-install</ulink>
  87. on *nix, follow the
  88. <ulink url="http://hackage.haskell.org/trac/hackage/wiki/CabalInstall#Quick+Installation+on+Unix">quick
  89. install</ulink> instructions.
  90. </para>
  91. <para>
  92. Once you’ve got cabal-install, installing gitit is trivial:
  93. </para>
  94. <programlisting>
  95. cabal update
  96. cabal install gitit
  97. </programlisting>
  98. <para>
  99. These commands will install the latest released version of gitit.
  100. To install a version of gitit checked out from the repository,
  101. change to the gitit directory and type:
  102. </para>
  103. <programlisting>
  104. cabal install
  105. </programlisting>
  106. <para>
  107. The <literal>cabal</literal> tool will automatically install all
  108. of the required haskell libraries. If all goes well, by the end of
  109. this process, the latest release of gitit will be installed in
  110. your local <literal>.cabal</literal> directory. You can check this
  111. by trying:
  112. </para>
  113. <programlisting>
  114. gitit --version
  115. </programlisting>
  116. <para>
  117. If that doesn’t work, check to see that <literal>gitit</literal>
  118. is in your local cabal-install executable directory (usually
  119. <literal>~/.cabal/bin</literal>). And make sure
  120. <literal>~/.cabal/bin</literal> is in your system path.
  121. </para>
  122. </sect2>
  123. <sect2 id="optional-syntax-highlighting-support">
  124. <title>Optional syntax highlighting support</title>
  125. <para>
  126. If pandoc was compiled with optional syntax highlighting support,
  127. this will be available in gitit too. This feature is recommended
  128. if you plan to display source code on your wiki.
  129. </para>
  130. <para>
  131. Highlighting support requires the
  132. <ulink url="http://www.pcre.org/">pcre</ulink> library, so make
  133. sure that is installed before continuing.
  134. </para>
  135. <para>
  136. To install gitit with highlighting support, first ensure that
  137. pandoc is compiled with highlighting support, then install gitit
  138. as above:
  139. </para>
  140. <programlisting>
  141. cabal install pandoc -fhighlighting --reinstall
  142. cabal install gitit
  143. </programlisting>
  144. </sect2>
  145. <sect2 id="running-gitit">
  146. <title>Running gitit</title>
  147. <para>
  148. To run gitit, you’ll need <literal>git</literal> in your system
  149. path. (Or <literal>darcs</literal> or <literal>hg</literal>, if
  150. you’re using darcs or mercurial to store the wiki data.)
  151. </para>
  152. <para>
  153. Gitit assumes that the page files (stored in the git repository)
  154. are encoded as UTF-8. Even page names may be UTF-8 if the file
  155. system supports this. So you should make sure that you are using a
  156. UTF-8 locale when running gitit. (To check this, type
  157. <literal>locale</literal>.)
  158. </para>
  159. <para>
  160. Switch to the directory where you want to run gitit. This should
  161. be a directory where you have write access, since three
  162. directories, <literal>static</literal>,
  163. <literal>templates</literal>, and <literal>wikidata</literal>, and
  164. two files, <literal>gitit-users</literal> and
  165. <literal>gitit.log</literal>, will be created here. To start
  166. gitit, just type:
  167. </para>
  168. <programlisting>
  169. gitit
  170. </programlisting>
  171. <para>
  172. If all goes well, gitit will do the following:
  173. </para>
  174. <orderedlist numeration="arabic" spacing="compact">
  175. <listitem>
  176. <para>
  177. Create a git repository, <literal>wikidata</literal>, and add
  178. a default front page.
  179. </para>
  180. </listitem>
  181. <listitem>
  182. <para>
  183. Create a <literal>static</literal> directory containing files
  184. to be treated as static files by gitit.
  185. </para>
  186. </listitem>
  187. <listitem>
  188. <para>
  189. Create a <literal>templates</literal> directory containing
  190. HStringTemplate templates for wiki pages.
  191. </para>
  192. </listitem>
  193. <listitem>
  194. <para>
  195. Start a web server on port 5001.
  196. </para>
  197. </listitem>
  198. </orderedlist>
  199. <para>
  200. Check that it worked: open a web browser and go to
  201. <ulink url="http://localhost:5001">http://localhost:5001</ulink>.
  202. </para>
  203. <para>
  204. You can control the port that gitit runs on using the
  205. <literal>-p</literal> option: <literal>gitit -p 4000</literal>
  206. will start gitit on port 4000. Additional runtime options are
  207. described by <literal>gitit -h</literal>.
  208. </para>
  209. </sect2>
  210. </sect1>
  211. <sect1 id="using-gitit">
  212. <title>Using gitit</title>
  213. <sect2 id="wiki-links-and-formatting">
  214. <title>Wiki links and formatting</title>
  215. <para>
  216. For instructions on editing pages and creating links, see the
  217. <quote>Help</quote> page.
  218. </para>
  219. <para>
  220. Gitit interprets links with empty URLs as wikilinks. Thus, in
  221. markdown pages, <literal>[Front Page]()</literal> creates an
  222. internal wikilink to the page <literal>Front Page</literal>. In
  223. reStructuredText pages, <literal>`Front Page &lt;&gt;`_</literal>
  224. has the same effect.
  225. </para>
  226. <para>
  227. If you want to link to a directory listing for a subdirectory, use
  228. a trailing slash: <literal>[foo/bar/]()</literal> creates a link
  229. to the directory for <literal>foo/bar</literal>.
  230. </para>
  231. </sect2>
  232. <sect2 id="page-metadata">
  233. <title>Page metadata</title>
  234. <para>
  235. Pages may optionally begin with a metadata block. Here is an
  236. example:
  237. </para>
  238. <programlisting>
  239. ---
  240. format: latex+lhs
  241. categories: haskell math
  242. toc: no
  243. title: Haskell and
  244. Category Theory
  245. ...
  246. \section{Why Category Theory?}
  247. </programlisting>
  248. <para>
  249. The metadata block consists of a list of key-value pairs, each on
  250. a separate line. If needed, the value can be continued on one or
  251. more additional line, which must begin with a space. (This is
  252. illustrated by the <quote>title</quote> example above.) The
  253. metadata block must begin with a line <literal>---</literal> and
  254. end with a line <literal>...</literal> optionally followed by one
  255. or more blank lines. (The metadata block is a valid YAML document,
  256. though not all YAML documents will be valid metadata blocks.)
  257. </para>
  258. <para>
  259. Currently the following keys are supported:
  260. </para>
  261. <variablelist spacing="compact">
  262. <varlistentry>
  263. <term>
  264. format
  265. </term>
  266. <listitem>
  267. <para>
  268. Overrides the default page type as specified in the
  269. configuration file. Possible values are
  270. <literal>markdown</literal>, <literal>rst</literal>,
  271. <literal>latex</literal>, <literal>html</literal>,
  272. <literal>markdown+lhs</literal>, <literal>rst+lhs</literal>,
  273. <literal>latex+lhs</literal>. (Capitalization is ignored, so
  274. you can also use <literal>LaTeX</literal>,
  275. <literal>HTML</literal>, etc.) The <literal>+lhs</literal>
  276. variants indicate that the page is to be interpreted as
  277. literate Haskell. If this field is missing, the default page
  278. type will be used.
  279. </para>
  280. </listitem>
  281. </varlistentry>
  282. <varlistentry>
  283. <term>
  284. categories
  285. </term>
  286. <listitem>
  287. <para>
  288. A space or comma separated list of categories to which the
  289. page belongs.
  290. </para>
  291. </listitem>
  292. </varlistentry>
  293. <varlistentry>
  294. <term>
  295. toc
  296. </term>
  297. <listitem>
  298. <para>
  299. Overrides default setting for table-of-contents in the
  300. configuration file. Values can be <literal>yes</literal>,
  301. <literal>no</literal>, <literal>true</literal>, or
  302. <literal>false</literal> (capitalization is ignored).
  303. </para>
  304. </listitem>
  305. </varlistentry>
  306. <varlistentry>
  307. <term>
  308. title
  309. </term>
  310. <listitem>
  311. <para>
  312. By default the displayed page title is the page name. This
  313. metadata element overrides that default.
  314. </para>
  315. </listitem>
  316. </varlistentry>
  317. </variablelist>
  318. </sect2>
  319. <sect2 id="highlighted-source-code">
  320. <title>Highlighted source code</title>
  321. <para>
  322. If gitit was compiled against a version of pandoc that has
  323. highlighting support (see above), you can get highlighted source
  324. code by using
  325. <ulink url="http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks">delimited
  326. code blocks</ulink>:
  327. </para>
  328. <programlisting>
  329. ~~~ {.haskell .numberLines}
  330. qsort [] = []
  331. qsort (x:xs) = qsort (filter (&lt; x) xs) ++ [x] ++
  332. qsort (filter (&gt;= x) xs)
  333. ~~~
  334. </programlisting>
  335. <para>
  336. To see what languages your pandoc was compiled to highlight:
  337. </para>
  338. <programlisting>
  339. pandoc -v
  340. </programlisting>
  341. </sect2>
  342. </sect1>
  343. <sect1 id="configuring-and-customizing-gitit">
  344. <title>Configuring and customizing gitit</title>
  345. <sect2 id="configuration-options">
  346. <title>Configuration options</title>
  347. <para>
  348. Use the option <literal>-f [filename]</literal> to specify a
  349. configuration file:
  350. </para>
  351. <programlisting>
  352. gitit -f my.conf
  353. </programlisting>
  354. <para>
  355. The configuation can be splitted between several files:
  356. </para>
  357. <programlisting>
  358. gitit -f my.conf -f additional.conf
  359. </programlisting>
  360. <para>
  361. One use case is to keep sensible part of the configuration outside
  362. of a SCM (oauth client secret for example).
  363. </para>
  364. <para>
  365. If this option is not used, gitit will use a default
  366. configuration. To get a copy of the default configuration file,
  367. which you can customize, just type:
  368. </para>
  369. <programlisting>
  370. gitit --print-default-config &gt; my.conf
  371. </programlisting>
  372. <para>
  373. The default configuration file is documented with comments
  374. throughout.
  375. </para>
  376. </sect2>
  377. <sect2 id="the-static-directory">
  378. <title>The <literal>static</literal> directory</title>
  379. <para>
  380. On receiving a request, gitit always looks first in the
  381. <literal>static</literal> directory (or in whatever directory is
  382. specified for <literal>static-dir</literal> in the configuration
  383. file). If a file corresponding to the request is found there, it
  384. is served immediately. If the file is not found in
  385. <literal>static</literal>, gitit next looks in the
  386. <literal>static</literal> subdirectory of gitit’s data file
  387. (<literal>$CABALDIR/share/gitit-x.y.z/data</literal>). This is
  388. where default css, images, and javascripts are stored. If the file
  389. is not found there either, gitit treats the request as a request
  390. for a wiki page or wiki command.
  391. </para>
  392. <para>
  393. So, you can throw anything you want to be served statically (for
  394. example, a <literal>robots.txt</literal> file or
  395. <literal>favicon.ico</literal>) in the <literal>static</literal>
  396. directory. You can override any of gitit’s default css,
  397. javascript, or image files by putting a file with the same
  398. relative path in <literal>static</literal>. Note that gitit has a
  399. default <literal>robots.txt</literal> file that excludes all URLs
  400. beginning with <literal>/_</literal>.
  401. </para>
  402. <para>
  403. Note: if you set <literal>static-dir</literal> to be a
  404. subdirectory of <literal>repository-path</literal>, and then add
  405. the files in the static directory to your repository, you can
  406. ensure that others who clone your wiki repository get these files
  407. as well. It will not be possible to modify these files using the
  408. web interface, but they will be modifiable via git.
  409. </para>
  410. </sect2>
  411. <sect2 id="using-a-vcs-other-than-git">
  412. <title>Using a VCS other than git</title>
  413. <para>
  414. By default, gitit will store wiki pages in a git repository in the
  415. <literal>wikidata</literal> directory. If you’d prefer to use
  416. darcs instead of git, you need to add the following field to the
  417. configuration file:
  418. </para>
  419. <programlisting>
  420. repository-type: Darcs
  421. </programlisting>
  422. <para>
  423. If you’d prefer to use mercurial, add:
  424. </para>
  425. <programlisting>
  426. repository-type: Mercurial
  427. </programlisting>
  428. <para>
  429. This program may be called <quote>darcsit</quote> instead of
  430. <quote>gitit</quote> when a darcs backend is used.
  431. </para>
  432. <para>
  433. Note: we recommend that you use gitit/darcsit with darcs version
  434. 2.3.0 or greater. If you must use an older version of darcs, then
  435. you need to compile the filestore library without the (default)
  436. maxcount flag, before (re)installing gitit:
  437. </para>
  438. <programlisting>
  439. cabal install --reinstall filestore -f-maxcount
  440. cabal install --reinstall gitit
  441. </programlisting>
  442. <para>
  443. Otherwise you will get an error when you attempt to access your
  444. repository.
  445. </para>
  446. </sect2>
  447. <sect2 id="changing-the-theme">
  448. <title>Changing the theme</title>
  449. <para>
  450. To change the look of the wiki, you can modify
  451. <literal>custom.css</literal> in <literal>static/css</literal>.
  452. </para>
  453. <para>
  454. To change the look of printed pages, copy gitit’s default
  455. <literal>print.css</literal> to <literal>static/css</literal> and
  456. modify it.
  457. </para>
  458. <para>
  459. The logo picture can be changed by copying a new PNG file to
  460. <literal>static/img/logo.png</literal>. The default logo is
  461. 138x155 pixels.
  462. </para>
  463. <para>
  464. To change the footer, modify
  465. <literal>templates/footer.st</literal>.
  466. </para>
  467. <para>
  468. For more radical changes, you can override any of the default
  469. templates in
  470. <literal>$CABALDIR/share/gitit-x.y.z/data/templates</literal> by
  471. copying the file into <literal>templates</literal>, modifying it,
  472. and restarting gitit. The <literal>page.st</literal> template is
  473. the master template; it includes the others. Interpolated
  474. variables are surrounded by <literal>$</literal>s, so
  475. <literal>literal $</literal> must be backslash-escaped.
  476. </para>
  477. </sect2>
  478. <sect2 id="adding-support-for-math">
  479. <title>Adding support for math</title>
  480. <para>
  481. To write math on a markdown-formatted wiki page, just enclose it
  482. in dollar signs, as in LaTeX:
  483. </para>
  484. <programlisting>
  485. Here is a formula: $\frac{1}{\sqrt{c^2}}$
  486. </programlisting>
  487. <para>
  488. You can write display math by enclosing it in double dollar signs:
  489. </para>
  490. <programlisting>
  491. $$\frac{1}{\sqrt{c^2}}$$
  492. </programlisting>
  493. <para>
  494. Gitit can display TeX math in three different ways, depending on
  495. the setting of <literal>math</literal> in the configuration file:
  496. </para>
  497. <orderedlist numeration="arabic">
  498. <listitem>
  499. <para>
  500. <literal>mathml</literal> (default): Math will be converted to
  501. MathML using
  502. <ulink url="http://github.com/jgm/texmath/tree/master">texmath</ulink>.
  503. This method works with IE+mathplayer, Firefox, and Opera, but
  504. not Safari.
  505. </para>
  506. </listitem>
  507. <listitem>
  508. <para>
  509. <literal>jsMath</literal>: Math will be rendered using the
  510. <ulink url="http://www.math.union.edu/~dpvc/jsmath/">jsMath</ulink>
  511. javascript. If you want to use this method, download
  512. <literal>jsMath</literal> and
  513. <literal>jsMath Image Fonts</literal> from the
  514. <ulink url="http://sourceforge.net/project/showfiles.php?group_id=172663">jsMath
  515. download page</ulink>. You’ll have two <literal>.zip</literal>
  516. archives. Unzip them both in the <literal>static/js</literal>
  517. directory (a new subdirectory, <literal>jsMath</literal>, will
  518. be created). This works with all browsers, but is slower and
  519. not as nice looking as MathML.
  520. </para>
  521. </listitem>
  522. <listitem>
  523. <para>
  524. <literal>raw</literal>: Math will be rendered as raw LaTeX
  525. codes.
  526. </para>
  527. </listitem>
  528. </orderedlist>
  529. </sect2>
  530. <sect2 id="restricting-access">
  531. <title>Restricting access</title>
  532. <para>
  533. If you want to limit account creation on your wiki, the easiest
  534. way to do this is to provide an <literal>access-question</literal>
  535. in your configuration file. (See the commented default
  536. configuration file.) Nobody will be able to create an account
  537. without knowing the answer to the access question.
  538. </para>
  539. <para>
  540. Another approach is to use HTTP authentication. (See the config
  541. file comments on <literal>authentication-method</literal>.)
  542. </para>
  543. </sect2>
  544. <sect2 id="authentication-through-github">
  545. <title>Authentication through github</title>
  546. <para>
  547. If you want to authenticate the user from github through oauth2,
  548. you need to register your app with github to obtain a OAuth client
  549. secret and add the following section to your configuration file:
  550. </para>
  551. <programlisting>
  552. [Github]
  553. oauthclientid: 01239456789abcdef012
  554. oauthclientsecret: 01239456789abcdef01239456789abcdef012394
  555. oauthcallback: http://mysite/_githubCallback
  556. oauthoauthorizeendpoint: https://github.com/login/oauth/authorize
  557. oauthaccesstokenendpoint: https://github.com/login/oauth/access_token
  558. ## Uncomment if you are checking membership against an organization and change
  559. ## gitit-testorg to this organization:
  560. # github-org: gitit-testorg
  561. </programlisting>
  562. <para>
  563. The github authentication uses the scope
  564. <literal>user:email</literal>. This way, gitit gets the email of
  565. the user, and the commit can be assigned to the right author if
  566. the wikidata repository is pushed to github. Additionally, it uses
  567. <literal>read:org</literal> if you uses the option
  568. <literal>github-org</literal> to check membership against an
  569. organization.
  570. </para>
  571. <para>
  572. To push your repository to gitub after each commit, you can add
  573. the file <literal>post-commit</literal> with the content below in
  574. the .git/hooks directory of your wikidata repository.
  575. </para>
  576. <programlisting>
  577. #!/bin/sh
  578. git push origin master 2&gt;&gt; logit
  579. </programlisting>
  580. </sect2>
  581. </sect1>
  582. <sect1 id="plugins">
  583. <title>Plugins</title>
  584. <para>
  585. Plugins are small Haskell programs that transform a wiki page after
  586. it has been converted from Markdown or another source format. See
  587. the example plugins in the <literal>plugins</literal> directory. To
  588. enable a plugin, include the path to the plugin (or its module name)
  589. in the <literal>plugins</literal> field of the configuration file.
  590. (If the plugin name starts with
  591. <literal>Network.Gitit.Plugin.</literal>, gitit will assume that the
  592. plugin is an installed module and will not look for a source file.)
  593. </para>
  594. <para>
  595. Plugin support is enabled by default. However, plugin support makes
  596. the gitit executable considerably larger and more memory-hungry. If
  597. you don’t need plugins, you may want to compile gitit without plugin
  598. support. To do this, unset the <literal>plugins</literal> Cabal
  599. flag:
  600. </para>
  601. <programlisting>
  602. cabal install --reinstall gitit -f-plugins
  603. </programlisting>
  604. <para>
  605. Note also that if you compile gitit for executable profiling,
  606. attempts to load plugins will result in <quote>internal error: PAP
  607. object entered!</quote>
  608. </para>
  609. </sect1>
  610. <sect1 id="accessing-the-wiki-through-git">
  611. <title>Accessing the wiki through git</title>
  612. <para>
  613. All the pages and uploaded files are stored in a git repository. By
  614. default, this lives in the <literal>wikidata</literal> directory
  615. (though this can be changed through configuration options). So you
  616. can interact with the wiki using git command line tools:
  617. </para>
  618. <programlisting>
  619. git clone ssh://my.server.edu/path/of/wiki/wikidata
  620. cd wikidata
  621. vim Front\ Page.page # edit the page
  622. git commit -m &quot;Added message about wiki etiquette&quot; Front\ Page.page
  623. git push
  624. </programlisting>
  625. <para>
  626. If you now look at the Front Page on the wiki, you should see your
  627. changes reflected there. Note that the pages all have the extension
  628. <literal>.page</literal>.
  629. </para>
  630. <para>
  631. If you are using the darcs or mercurial backend, the commands will
  632. be slightly different. See the documentation for your VCS for
  633. details.
  634. </para>
  635. </sect1>
  636. <sect1 id="performance">
  637. <title>Performance</title>
  638. <sect2 id="caching">
  639. <title>Caching</title>
  640. <para>
  641. By default, gitit does not cache content. If your wiki receives a
  642. lot of traffic or contains pages that are slow to render, you may
  643. want to activate caching. To do this, set the configuration option
  644. <literal>use-cache</literal> to <literal>yes</literal>. By
  645. default, rendered pages, highlighted source files, and exported
  646. PDFs will be cached in the <literal>cache</literal> directory.
  647. (Another directory can be specified by setting the
  648. <literal>cache-dir</literal> configuration option.)
  649. </para>
  650. <para>
  651. Cached pages are updated when pages are modified using the web
  652. interface. They are not updated when pages are modified directly
  653. through git or darcs. However, the cache can be refreshed manually
  654. by pressing Ctrl-R when viewing a page, or by sending an HTTP GET
  655. or POST request to <literal>/_expire/path/to/page</literal>, where
  656. <literal>path/to/page</literal> is the name of the page to be
  657. expired.
  658. </para>
  659. <para>
  660. Users who frequently update pages using git or darcs may wish to
  661. add a hook to the repository that makes the appropriate HTTP
  662. request to expire pages when they are updated. To facilitate such
  663. hooks, the gitit cabal package includes an executable
  664. <literal>expireGititCache</literal>. Assuming you are running
  665. gitit at port 5001 on localhost, and the environment variable
  666. <literal>CHANGED_FILES</literal> contains a list of the files that
  667. have changed, you can expire their cached versions using
  668. </para>
  669. <programlisting>
  670. expireGititCache http://localhost:5001 $CHANGED_FILES
  671. </programlisting>
  672. <para>
  673. Or you can specify the files directly:
  674. </para>
  675. <programlisting>
  676. expireGititCache http://localhost:5001 &quot;Front Page.page&quot; foo/bar/baz.c
  677. </programlisting>
  678. <para>
  679. This program will return a success status (0) if the page has been
  680. successfully expired (or if it was never cached in the first
  681. place), and a failure status (&gt; 0) otherwise.
  682. </para>
  683. <para>
  684. The cache is persistent through restarts of gitit. To expire all
  685. cached pages, simply remove the <literal>cache</literal>
  686. directory.
  687. </para>
  688. </sect2>
  689. <sect2 id="idle">
  690. <title>Idle</title>
  691. <para>
  692. By default, GHC’s runtime will repeatedly attempt to collect
  693. garbage when an executable like Gitit is idle. This means that
  694. gitit will, after the first page request, never use 0% CPU time
  695. and sleep, but will use ~1%. This can be bad for battery life,
  696. among other things.
  697. </para>
  698. <para>
  699. To fix this, one can disable the idle-time GC with the runtime
  700. flag <literal>-I0</literal>:
  701. </para>
  702. <programlisting>
  703. gitit -f my.conf +RTS -I0 -RTS
  704. </programlisting>
  705. </sect2>
  706. </sect1>
  707. <sect1 id="using-gitit-with-apache">
  708. <title>Using gitit with apache</title>
  709. <para>
  710. Most users who run a public-facing gitit will want gitit to appear
  711. at a nice URL like <literal>http://wiki.mysite.com</literal> or
  712. <literal>http://mysite.com/wiki</literal> rather than
  713. <literal>http://mysite.com:5001</literal>. This can be achieved
  714. using apache’s <literal>mod_proxy</literal>.
  715. </para>
  716. <sect2 id="proxying-to-httpwiki.mysite.com">
  717. <title>Proxying to <literal>http://wiki.mysite.com</literal></title>
  718. <para>
  719. Set up your DNS so that <literal>http://wiki.mysite.com</literal>
  720. maps to your server’s IP address. Make sure that the
  721. <literal>mod_proxy</literal>, <literal>mod_proxy_http</literal>
  722. and <literal>mod_rewrite</literal> modules are loaded, and set up
  723. a virtual host with the following configuration:
  724. </para>
  725. <programlisting>
  726. &lt;VirtualHost *&gt;
  727. ServerName wiki.mysite.com
  728. DocumentRoot /var/www/
  729. RewriteEngine On
  730. ProxyPreserveHost On
  731. ProxyRequests Off
  732. &lt;Proxy *&gt;
  733. Order deny,allow
  734. Allow from all
  735. &lt;/Proxy&gt;
  736. ProxyPassReverse / http://127.0.0.1:5001
  737. RewriteRule ^(.*) http://127.0.0.1:5001$1 [P]
  738. ErrorLog /var/log/apache2/error.log
  739. LogLevel warn
  740. CustomLog /var/log/apache2/access.log combined
  741. ServerSignature On
  742. &lt;/VirtualHost&gt;
  743. </programlisting>
  744. <para>
  745. Reload your apache configuration and you should be all set.
  746. </para>
  747. </sect2>
  748. <sect2 id="using-nginx-to-achieve-the-same">
  749. <title>Using nginx to achieve the same</title>
  750. <para>
  751. Drop a file called <literal>wiki.example.com.conf</literal> into
  752. <literal>/etc/nginx/conf.d</literal> (or where ever your
  753. distribution puts it).
  754. </para>
  755. <programlisting>
  756. server {
  757. listen 80;
  758. server_name wiki.example.com
  759. location / {
  760. proxy_pass http://127.0.0.1:5001/;
  761. proxy_set_header X-Real-IP $remote_addr;
  762. proxy_redirect off;
  763. }
  764. access_log /var/log/nginx/wiki.example.com.log main;
  765. }
  766. </programlisting>
  767. <para>
  768. Reload your nginx config and you should be all set.
  769. </para>
  770. </sect2>
  771. <sect2 id="proxying-to-httpmysite.comwiki">
  772. <title>Proxying to <literal>http://mysite.com/wiki</literal></title>
  773. <para>
  774. Make sure the <literal>mod_proxy</literal>,
  775. <literal>mod_headers</literal>, <literal>mod_proxy_http</literal>,
  776. and <literal>mod_proxy_html</literal> modules are loaded.
  777. <literal>mod_proxy_html</literal> is an external module, which can
  778. be obtained <ulink url="http://www.haskell.org/ghc/">here</ulink>
  779. (http://apache.webthing.com/mod_proxy_html/). It rewrites URLs
  780. that occur in web pages. Here we will use it to rewrite gitit’s
  781. links so that they all begin with <literal>/wiki/</literal>.
  782. </para>
  783. <para>
  784. First, tell gitit not to compress pages, since
  785. <literal>mod_proxy_html</literal> needs uncompressed pages to
  786. parse. You can do this by setting the gitit configuration option
  787. </para>
  788. <programlisting>
  789. compress-responses: no
  790. </programlisting>
  791. <para>
  792. Second, modify the link in the
  793. <literal>reset-password-message</literal> in the configuration
  794. file: instead of
  795. </para>
  796. <programlisting>
  797. http://$hostname$:$port$$resetlink$
  798. </programlisting>
  799. <para>
  800. set it to
  801. </para>
  802. <programlisting>
  803. http://$hostname$/wiki$resetlink$
  804. </programlisting>
  805. <para>
  806. Restart gitit.
  807. </para>
  808. <para>
  809. Now add the following lines to the apache configuration file for
  810. the <literal>mysite.com</literal> server:
  811. </para>
  812. <programlisting>
  813. # These commands will proxy /wiki/ to port 5001
  814. ProxyRequests Off
  815. &lt;Proxy *&gt;
  816. Order deny,allow
  817. Allow from all
  818. &lt;/Proxy&gt;
  819. ProxyPass /wiki/ http://127.0.0.1:5001/
  820. &lt;Location /wiki/&gt;
  821. SetOutputFilter proxy-html
  822. ProxyPassReverse /
  823. ProxyHTMLURLMap / /wiki/
  824. ProxyHTMLDocType &quot;&lt;!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'&gt;&quot; XHTML
  825. RequestHeader unset Accept-Encoding
  826. &lt;/Location&gt;
  827. </programlisting>
  828. <para>
  829. Reload your apache configuration and you should be set.
  830. </para>
  831. <para>
  832. For further information on the use of
  833. <literal>mod_proxy_http</literal> to rewrite URLs, see the
  834. <ulink url="http://apache.webthing.com/mod_proxy_html/guide.html"><literal>mod_proxy_html</literal>
  835. guide</ulink>.
  836. </para>
  837. </sect2>
  838. </sect1>
  839. <sect1 id="using-gitit-as-a-library">
  840. <title>Using gitit as a library</title>
  841. <para>
  842. By importing the module <literal>Network.Gitit</literal>, you can
  843. include a gitit wiki (or several of them) in another happstack
  844. application. There are some simple examples in the haddock
  845. documentation for <literal>Network.Gitit</literal>.
  846. </para>
  847. </sect1>
  848. <sect1 id="reporting-bugs">
  849. <title>Reporting bugs</title>
  850. <para>
  851. Bugs may be reported (and feature requests filed) at
  852. <ulink url="http://code.google.com/p/gitit/issues/list">http://code.google.com/p/gitit/issues/list</ulink>.
  853. </para>
  854. <para>
  855. There is a mailing list for users and developers at
  856. <ulink url="http://groups.google.com/group/gitit-discuss">http://groups.google.com/group/gitit-discuss</ulink>.
  857. </para>
  858. </sect1>
  859. <sect1 id="acknowledgements">
  860. <title>Acknowledgements</title>
  861. <para>
  862. A number of people have contributed patches:
  863. </para>
  864. <itemizedlist spacing="compact">
  865. <listitem>
  866. <para>
  867. Gwern Branwen helped to optimize gitit and wrote the
  868. InterwikiPlugin. He also helped with the Feed module.
  869. </para>
  870. </listitem>
  871. <listitem>
  872. <para>
  873. Simon Michael contributed the patch adding RST support.
  874. </para>
  875. </listitem>
  876. <listitem>
  877. <para>
  878. Henry Laxen added support for password resets and helped with
  879. the apache proxy instructions.
  880. </para>
  881. </listitem>
  882. <listitem>
  883. <para>
  884. Anton van Straaten made the process of page generation more
  885. modular by adding Gitit.ContentTransformer.
  886. </para>
  887. </listitem>
  888. <listitem>
  889. <para>
  890. Robin Green helped improve the plugin API and interface, and
  891. fixed a security problem with the reset password code.
  892. </para>
  893. </listitem>
  894. <listitem>
  895. <para>
  896. Thomas Hartman helped improve the index page, making directory
  897. browsing persistent, and fixed a bug in template recompilation.
  898. </para>
  899. </listitem>
  900. <listitem>
  901. <para>
  902. Justin Bogner improved the appearance of the preview button.
  903. </para>
  904. </listitem>
  905. <listitem>
  906. <para>
  907. Kohei Ozaki contributed the ImgTexPlugin.
  908. </para>
  909. </listitem>
  910. <listitem>
  911. <para>
  912. Michael Terepeta improved validation of change descriptions.
  913. </para>
  914. </listitem>
  915. <listitem>
  916. <para>
  917. mightybyte suggested making gitit available as a library, and
  918. contributed a patch to ifLoggedIn that was needed to make gitit
  919. usable with a custom authentication scheme.
  920. </para>
  921. </listitem>
  922. </itemizedlist>
  923. <para>
  924. I am especially grateful to the darcs team for using darcsit for
  925. their public-facing wiki. This has helped immensely in identifying
  926. issues and improving performance.
  927. </para>
  928. <para>
  929. Gitit’s default visual layout is shamelessly borrowed from
  930. Wikipedia. The stylesheets are influenced by Wikipedia’s stylesheets
  931. and by the bluetrip CSS framework (see BLUETRIP-LICENSE). Some of
  932. the icons in <literal>img/icons</literal> come from bluetrip as
  933. well.
  934. </para>
  935. </sect1>