Commit bc06008eef742e3971fdbe3859c442acdbd4d1a4

Linkifying.
Some more cleanups.
TODO
(4 / 6)
  
11Backend
22-------
3- Wikify links
4- Auto-link plain-text links
5- Auto-insert newline after h?
3- Auto-insert newline after h*. section headers
64- Add section edit links ?
75- Add diffs to history
86
9ExtJS theme
10-----------
11- Create
7Themes
8------
9Create an ExtJS theme
index.php
(28 / 6)
  
2323 // Helpers
2424 // --------------------------------------------------------------------------
2525
26 function getHistory($file = "") {
26 function getGitHistory($file = "") {
2727 $output = array();
2828 git("log --pretty=format:'%H>%T>%an>%ae>%aD>%s' -- $file", $output);
2929 $history = array();
120120 print join("\n", $output) . "\n";
121121 //print "Error code: " . $result . "\n";
122122 print "</pre>";
123 return 0;
123124 }
124125 return 1;
125126 }
157157 // --------------------------------------------------------------------------
158158
159159 function wikify($text) {
160 // FIXME: Wikify
160 global $SCRIPT_URL;
161161
162 // FIXME: Do not apply this in <pre> and <notextile> blocks.
163
164 // Linkify
165 $text = preg_replace('@[^:](https?://([-\w\.]+)+(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1">$1</a>', $text);
166
167 // WikiLinkify
168 $text = preg_replace('@\[([A-Z]\w+)\]@', '<a href="' . $SCRIPT_URL . '/$1">$1</a>', $text);
169
162170 // Textilify
163171 $textile = new Textile();
164172 return $textile->TextileThis($text);
239239 return "themes/$THEME";
240240 }
241241
242 function getFile() {
243 global $wikiFile;
244 return $wikiFile;
245 }
246
247 function getContent() {
248 global $wikiContent;
249 return $wikiContent;
250 }
251
252 function getRawData() {
253 global $wikiData;
254 return $wikiData;
255 }
256
242257 // --------------------------------------------------------------------------
243258 // Initialize globals
244259 // --------------------------------------------------------------------------
263263 $resource = parseResource($_GET['r']);
264264 $wikiPage = $resource["page"];
265265 $wikiSubPage = $resource["type"];
266
267266 $wikiFile = $DATA_DIR . "/" . $wikiPage;
268 $wikiCSS = $CSS;
269267
270268
271269 // --------------------------------------------------------------------------
304304 else {
305305 // Global history
306306 if ($wikiPage == "history") {
307 $wikiHistory = getHistory();
307 $wikiHistory = getGitHistory();
308308 $wikiPage = "";
309309 include(getThemeDir() . "/history.php");
310310 }
337337 }
338338 // History
339339 else if ($wikiSubPage == "history") {
340 $wikiHistory = getHistory($wikiPage);
340 $wikiHistory = getGitHistory($wikiPage);
341341 include(getThemeDir() . "/history.php");
342342 }
343343 // Specific version
  
1818
1919 <div id="form">
2020 <form method="post" action="<?php print getPostURL(); ?>">
21 <p><textarea name="data" cols="80" rows="20" style="width: 100%"><?php print $wikiData; ?></textarea></p>
21 <p><textarea name="data" cols="80" rows="20" style="width: 100%"><?php print getRawData(); ?></textarea></p>
2222 <p><input type="submit" value="publish" /></p>
2323 </form>
2424 </div>
  
2020 </div>
2121
2222 <div id="history">
23 <p>
2324 <table>
2425 <tr><th>Date</th><th>Author</th><th>Page</th><th>Message</th></tr>
2526 <?php
3636 }
3737 ?>
3838 </table>
39 </p>
3940 </div>
4041 </body>
4142</html>
  
115115
116116#history table {
117117 border-collapse: collapse;
118 margin-left: auto;
119 margin-right: auto;
118120}
119121
120122#history td {
  
1919 </div>
2020
2121 <div id="content">
22 <?php print $wikiContent; ?>
22 <?php print getContent(); ?>
2323 </div>
2424
2525 <div id="footer">
26 <p>Last modified on <?php print date("F d Y H:i:s", filemtime($wikiFile)); ?> </p>
26 <p>Last modified on <?php print date("F d Y H:i:s", filemtime(getFile())); ?> </p>
2727 </div>
2828 </body>
2929</html>