Commit 9f2b8a88426d1bf45f1ab3cbaa4041285e128a4a
- Diff rendering mode:
- inline
- side by side
TODO
(0 / 2)
|   | |||
| 1 | 1 | Backend | |
| 2 | 2 | ------- | |
| 3 | - Try to parse page in history, and link to it | ||
| 4 | - Add link to retrieve a revision of a page | ||
| 5 | 3 | - Add diffs to history | |
| 6 | 4 | - Auto-link plain-text links | |
| 7 | 5 | - Wikify links |
index.php
(27 / 36)
|   | |||
| 23 | 23 | // Helpers | |
| 24 | 24 | // -------------------------------------------------------------------------- | |
| 25 | 25 | ||
| 26 | function wikify($text) { | ||
| 27 | return $text; | ||
| 28 | } | ||
| 29 | |||
| 30 | 26 | function getHistory($file = "") { | |
| 31 | 27 | $output = array(); | |
| 32 | 28 | git("log --pretty=format:'%H>%T>%an>%ae>%aD>%s' -- $file", $output); | |
| … | … | ||
| 54 | 54 | return $history; | |
| 55 | 55 | } | |
| 56 | 56 | ||
| 57 | function getThemeDir() { | ||
| 58 | global $THEME; | ||
| 59 | return "themes/$THEME"; | ||
| 60 | } | ||
| 61 | |||
| 62 | 57 | function getAuthorForUser($user) { | |
| 63 | 58 | global $AUTHORS, $DEFAULT_AUTHOR; | |
| 64 | 59 | ||
| … | … | ||
| 146 | 146 | return array("page" => $page, "type" => $type); | |
| 147 | 147 | } | |
| 148 | 148 | ||
| 149 | |||
| 149 | 150 | // -------------------------------------------------------------------------- | |
| 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 | // -------------------------------------------------------------------------- | ||
| 150 | 163 | // Utility functions (for use inside templates) | |
| 151 | 164 | // -------------------------------------------------------------------------- | |
| 152 | 165 | ||
| … | … | ||
| 220 | 220 | return getThemeDir() . "/style.css"; | |
| 221 | 221 | } | |
| 222 | 222 | ||
| 223 | function getThemeDir() { | ||
| 224 | global $THEME; | ||
| 225 | return "themes/$THEME"; | ||
| 226 | } | ||
| 227 | |||
| 223 | 228 | // -------------------------------------------------------------------------- | |
| 224 | 229 | // Initialize globals | |
| 225 | 230 | // -------------------------------------------------------------------------- | |
| … | … | ||
| 293 | 293 | $data = fread($handle, filesize($wikiFile)); | |
| 294 | 294 | fclose($handle); | |
| 295 | 295 | ||
| 296 | // Add wiki links and other transformations | ||
| 297 | $wikifiedData = wikify($data); | ||
| 298 | |||
| 299 | // Textilify | ||
| 300 | $textile = new Textile(); | ||
| 301 | $formattedData = $textile->TextileThis($wikifiedData); | ||
| 302 | |||
| 303 | 296 | // Put in template | |
| 304 | $wikiContent = $formattedData; | ||
| 297 | $wikiContent = wikify($data); | ||
| 305 | 298 | include(getThemeDir() . "/view.php"); | |
| 306 | 299 | } | |
| 307 | 300 | // Editing | |
| … | … | ||
| 308 | 308 | $wikiData = $data; | |
| 309 | 309 | include(getThemeDir() . "/edit.php"); | |
| 310 | 310 | } | |
| 311 | // History | ||
| 311 | 312 | else if ($wikiSubPage == "history") { | |
| 312 | 313 | $wikiHistory = getHistory($wikiPage); | |
| 313 | 314 | include(getThemeDir() . "/history.php"); | |
| 314 | 315 | } | |
| 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)) { | ||
| 318 | 318 | $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)) { | ||
| 333 | 320 | return; | |
| 334 | 321 | } | |
| 335 | |||
| 336 | // Fallback | ||
| 322 | $wikiContent = wikify(join("\n", $output)); | ||
| 323 | include(getThemeDir() . "/view.php"); | ||
| 324 | } | ||
| 325 | else { | ||
| 337 | 326 | print "Unknow subpage: " . $wikiSubPage; | |
| 338 | 327 | } | |
| 339 | 328 | } |

