Commit 9f2b8a88426d1bf45f1ab3cbaa4041285e128a4a

More cleanup.
TODO
(0 / 2)
  
11Backend
22-------
3- Try to parse page in history, and link to it
4- Add link to retrieve a revision of a page
53- Add diffs to history
64- Auto-link plain-text links
75- Wikify links
index.php
(27 / 36)
  
2323 // Helpers
2424 // --------------------------------------------------------------------------
2525
26 function wikify($text) {
27 return $text;
28 }
29
3026 function getHistory($file = "") {
3127 $output = array();
3228 git("log --pretty=format:'%H>%T>%an>%ae>%aD>%s' -- $file", $output);
5454 return $history;
5555 }
5656
57 function getThemeDir() {
58 global $THEME;
59 return "themes/$THEME";
60 }
61
6257 function getAuthorForUser($user) {
6358 global $AUTHORS, $DEFAULT_AUTHOR;
6459
146146 return array("page" => $page, "type" => $type);
147147 }
148148
149
149150 // --------------------------------------------------------------------------
151 // Wikify
152 // --------------------------------------------------------------------------
153
154 function wikify($text) {
155 // FIXME: Wikify
156
157 // Textilify
158 $textile = new Textile();
159 return $textile->TextileThis($text);
160 }
161
162 // --------------------------------------------------------------------------
150163 // Utility functions (for use inside templates)
151164 // --------------------------------------------------------------------------
152165
220220 return getThemeDir() . "/style.css";
221221 }
222222
223 function getThemeDir() {
224 global $THEME;
225 return "themes/$THEME";
226 }
227
223228 // --------------------------------------------------------------------------
224229 // Initialize globals
225230 // --------------------------------------------------------------------------
293293 $data = fread($handle, filesize($wikiFile));
294294 fclose($handle);
295295
296 // Add wiki links and other transformations
297 $wikifiedData = wikify($data);
298
299 // Textilify
300 $textile = new Textile();
301 $formattedData = $textile->TextileThis($wikifiedData);
302
303296 // Put in template
304 $wikiContent = $formattedData;
297 $wikiContent = wikify($data);
305298 include(getThemeDir() . "/view.php");
306299 }
307300 // Editing
308308 $wikiData = $data;
309309 include(getThemeDir() . "/edit.php");
310310 }
311 // History
311312 else if ($wikiSubPage == "history") {
312313 $wikiHistory = getHistory($wikiPage);
313314 include(getThemeDir() . "/history.php");
314315 }
315 else {
316 // Try commit.
317 // FIXME: Try to put this in an else if
316 // Specific version
317 else if (eregi("[0-9A-F]{20,20}", $wikiSubPage)) {
318318 $output = array();
319 if (git("cat-file -p " . $wikiSubPage . ":$wikiPage", $output)) {
320 $data = join("\n", $output);
321 // FIXME Factor this out
322 // Add wiki links and other transformations
323 $wikifiedData = wikify($data);
324
325 // Textilify
326 $textile = new Textile();
327 $formattedData = $textile->TextileThis($wikifiedData);
328
329 // Put in template
330 // FIXME: Remove edit links
331 $wikiContent = $formattedData;
332 include(getThemeDir() . "/view.php");
319 if (!git("cat-file -p " . $wikiSubPage . ":$wikiPage", $output)) {
333320 return;
334321 }
335
336 // Fallback
322 $wikiContent = wikify(join("\n", $output));
323 include(getThemeDir() . "/view.php");
324 }
325 else {
337326 print "Unknow subpage: " . $wikiSubPage;
338327 }
339328 }