root/documentation/trunk/wiki/pages/wiki/development.txt @ 30224

Revision 30224, 40.7 KB (checked in by jmt12, 5 years ago)

Delvelopment notes (need to be updated for move to Detritus and TSG-managed wiki)

Line 
1====== Development ======
2
3**WARNING!** This page is currently out-of-date, and reflects the state of the wiki prior to inclusion in the University-wide system. Here there be dragons.
4
5===== Frequently Asked Questions =====
6
7==== Q. How do you enable login to wiki using Greenstone registration? ====
8
9The code changes to allow for Greenstone registration integration should already be present in the dokuwiki retrieved from Greenstone's SVN. To configure the dokuwiki for login follow these instructions:
10  - Copy ''<dokuwiki>/conf/mysql.conf.php.example'' to ''<dokuwiki>/conf/mysql.conf.php''
11  - Edit the ''mysql.conf.php'' file to have the correct details:<code>$conf['auth']['mysql']['server']   = 'localhost';
12$conf['auth']['mysql']['user']     = 'greenstonewiki';
13$conf['auth']['mysql']['password'] = '********';
14$conf['auth']['mysql']['database'] = 'gs_services';</code>
15  - While still in the conf directory, create a file ''local.protected.php'' with the content:<code><?php
16require_once('mysql.conf.php');
17?></code>
18  - Edit the file ''local.php'' and ammend/add the line:<code>...
19$conf['authtype'] = 'mysql';
20...</code>
21  - Ensure the permissions for all three files you've edited are correct as to be readble by the //nzdl// group
22  - Disable Dokuwiki's built-in register and email new password abilities by editing ''<dokuwiki>/conf/local.php'' and adding (or updating):<code>$conf['disableactions'] = 'register,resendpwd';</code>Alternatively, you can set these in the "Configuration Settings" page within the "Admin" page. **Note** a later customization step will add back in links to the global Greenstone registration system.
23
24==== Q. How do I create a page? ====
25
26The easiest way is to use the search box in the left navigation to search for a page that isn't already created. Include in the search any path/namespace as required. For instance, we (originally) created this page by searching for:<code>faq</code>but we could have included a path like so:<code>Manuals:User:Section1</code>which would create a ''Manuals'' folder, with a ''User'' folder within it, and finally the ''Section1'' page within that.
27
28When you search for a page that isn't there, the result page will helpfully suggest //"If you didn't find what you were looking for, you can create or edit the page named after your query with the appropriate button."// However, instead of a button, in this page template you'll need to click the tab at the top of the search results page labelled ''create this page''.  If it all works you should find yourself in a textarea editor entering content for the page. Click ''Preview'' to review your content for formatting etc, and ''Save'' to commit changes to the page.
29
30===== Installation =====
31
32  - Checkout the ''gsdl-docs'' package out of SVN
33  - Go to ''<gsdl-docs>/lib/dokuwiki/'' and untar the [[http://www.dokuwiki.org/dokuwiki|dokuwiki]] tarball (currently the stable version [[http://www.splitbrain.org/_media/projects/dokuwiki/dokuwiki-2011-05-25a.tgz|Ricewind]])
34  - Go back up to ''<gsdl-docs>/'' and create a symlink to the folder you just unpacked called just ''dokuwiki'':<code>ln -s ./lib/dokuwiki/dokuwiki-<version> ./dokuwiki</code>
35  - Copy all of the archive files in ''<gsdl-docs>/lib/dokuwiki/plugins/'' into ''<gsdl-docs>/dokuwiki/lib/plugins/'', then unpack
36    * **note** you may need to rename the plugin folders---you'll find Dokuwiki will complain about incorrectly named folders at startup
37  - Similarly, copy the ''monobook'' template archive from ''<gsdl-docs>/lib/dokuwiki/templates'' to ''<gsdl-docs>/dokuwiki/lib/tpl/'' and unpack
38  - Setup your webserver (as needed) so you can access this dokuwiki directory and run the PHP scripts therein
39  - Visit the dokuwiki installer page in a web browser. For example, if you're webserver is running on ''localhost'', at port ''8080'', and the path to ''<gsdl-docs>/'' //is// ''/gsdl-docs'', then visit:<code>http://localhost:8080/gsdl-docs/dokuwiki/install.php</code>
40  - Follow the setup instructions, and then follow the recommended [[http://www.dokuwiki.org/security|security settings]] for Dokuwiki, including renaming the ''install.php'' file
41  - Overwrite the default configuration by copying the file ''<gsdl-docs>/lib/dokuwiki/conf/local.php'' to ''<gsdl-docs>/dokuwiki/conf/'' overwriting the existing file
42  - Recursively copy the starting pages file into place, overwriting existing files if prompted<code>cp -r <gsdl-docs>/lib/dokuwiki/pages/ <gsdl-docs>/dokuwiki/data/pages/</code>
43    * **note** there is a copy of these instructions in the starting files, located at [[wiki:development]]
44  - Enter ''<gsdl-docs>/lib/php/''
45  - Run each of these commands in order to transform the manual's XML files into Dokuwiki pages:<code>php gs-manuals-import.php -m user
46php gs-manuals-import.php -m install
47php gs-manuals-import.php -m develop
48php gs-manuals-import.php -m paper</code>
49    * **note** these require a command line version of PHP to be available on the path
50  - Enter the wiki again, log in using the administrator account you created when installing, and then visit each manual wiki page, 'edit' it and click approve
51===== Required Plugins =====
52
53  * <del>Captcha - Use a CAPTCHA challenge to protect DokuWiki against automated spam</del>
54  * [[http://wiki.splitbrain.org/plugin:code2|Code2]] by Matthias Watermann - Enhanced code syntax highlighting with line numbering
55  * [[http://wiki.splitbrain.org/plugin:htmlcomment|HTMLComment]] by Christopher Arndt - allows HTML comments to be retained in the output
56  * [[http://wiki.splitbrain.org/plugin:ifauth|IFAuth]] by Otto Vainio - so content only for specific groups and/or users
57  * [[http://wiki.splitbrain.org/plugin:imagereference|ImageReference]] by Gerrit Uitslag - create image references like latex is doing with figures
58  * [[http://dokuwiki.org/plugin:orphanswanted|OrphansWanted]] by Doug Edmunds //et al// - provide macros to list orphan pages and wanted pages
59  * [[http://www.dokuwiki.org/plugin:publish|Publish]] by Jarrod Lowe //et al// - integrate a publishing process into DokuWiki (differentiating between draft and approved copies of pages)
60  * [[http://www.dokuwiki.org/plugin:tablewidth|TableWidth]] by Mykola Ostrovskyy - allows the width of tables and table cells to be defined
61  * [[:wiki:development#custom_plugins|SimpleTabs]] - as explained below.
62
63===== Customizations =====
64
65**Note:** The diffs regarding the main Dokuwiki code are against the stable release 2011-05-25a "Rincewind".
66==== Dokuwiki ====
67
68=== inc/common.php ===
69
70^ File  ^ Changes  ^
71^ inc/common.php  | Allow for 'no change' submissions as long as the Approve flag is ticked (see documentation for [[http://www.dokuwiki.org/plugin:publish|plugin:publish]])  |
72| <code diff u>
73--- dokuwiki-2011-05-25a/inc/common.php 2011-06-15 07:58:53.000000000 +1200
74+++ dokuwiki/inc/common.php 2012-01-17 13:53:12.860063701 +1300
75@@ -973,7 +973,8 @@
76     global $lang;
77     global $REV;
78     // ignore if no changes were made
79-    if($text == rawWiki($id,'')){
80+    // - [jmt12] unless the approved checkbox is set
81+    if(!$_POST['approved'] && $text == rawWiki($id,'')){
82         return;
83     }
84</code> ||
85
86=== inc/html.php ===
87
88^ File  ^ Changes  ^
89^ inc/html.php  | Add id attributes to the table of contents list items so we can hide the ones on currently hidden tabs. Allow for a 'reset' header to be specified by the user in order to 'break out of' the current TOC nesting (for instance, at the end of a tabbed area to prevent following headings being grouped under Tab area headings).  |
90| <code diff u>
91--- html.original.php   2014-03-13 11:16:37.000000000 +1300
92+++ html.php    2014-03-13 11:13:34.000000000 +1300
93@@ -758,9 +758,28 @@ function html_li_index($item){
94  *
95  * @author Andreas Gohr <andi@splitbrain.org>
96  */
97+// In order to alter the TOC when a user changes a tab, we
98+// need some way to uniquely identify what titles lurk in
99+// what tabs. Dokuwiki automagically labels headers with
100+// <a name=""> tags - so if I use the same information here
101+// they should match (and be unique etc)
102+// - jmt12
103+// At some stage the traditional 'link' attribute was (some-
104+// times) replaced with information in 'hid'
105+// - jmt12 2014MAR13
106 function html_li_default($item)
107 {
108-    return '<li class="level' . $item['level'] . '">';
109+  $link = $item['link'];
110+  if (isset($item['hid']) && !empty($item['hid']))
111+    {
112+      $link = $item['hid'];
113+    }
114+  $hash_pos = strpos($link, '#');
115+  if ($hash_pos !== false)
116+    {
117+      $link = substr($link, $hash_pos + 1);
118+    }
119+  return '<li id="toc_' . $link . '" class="level' . $item['level'] . '">';
120 }
121
122 /**
123@@ -784,7 +803,24 @@ function html_buildlist($data,$class,$fu
124     $ret   = '';
125 
126     foreach ($data as $item){
127-   if( $item['level'] > $level ){
128+      // A reset closes all TOC items, all the way back to the top
129+      if ($item['title'] == '#')
130+   {
131+     //close last item
132+     $ret .= "</li>\n";
133+     while( $level > 0 && $open > 0 ){
134+       //close higher lists
135+       $ret .= "</ul>\n</li>\n";
136+       $level--;
137+       $open--;
138+     }
139+     // open a dummy item list, although we don't output a list item
140+     $ret .= "<li class=\"clear\">\n<ul class=\"$class\">\n<li class=\"clear\">";
141+     $level++;
142+     $open++;
143+     // skip to next item
144+     continue;
145+   }elseif( $item['level'] > $level ){
146             //open new list
147             for($i=0; $i<($item['level'] - $level); $i++){
148                 if ($i) $ret .= "<li class=\"clear\">\n";
149</code>||
150
151
152=== inc/lang/en/login.txt ===
153
154^ File  ^ Changes  ^
155^ inc/lang/en/login.txt  | Add a link to the global Greenstone registration / password reset page (because we have disabled Dokuwiki's built-in user stuff at the top of this page).  |
156| <code diff u>
157--- dokuwiki-2011-05-25a/inc/lang/en/login.txt  2012-02-09 10:17:32.000000000 +1300
158+++ greenstone-wiki/inc/lang/en/login.txt   2013-10-24 12:12:14.000000000 +1300
159@@ -2,3 +2,4 @@
160 
161 You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.
162 
163+Don't have an account? [[http://www.greenstone.org/users?&returnto=GreenstoneWiki|Create an account or email new password]].
164</code>||
165=== inc/parserutils.php ===
166
167^ File  ^ Changes  ^
168^ inc/parserutils.php  | Add a check to an introspective call to ensure that the function called exists in the class //before// calling it - otherwise the logs fill up with warnings from classes that don't (i.e. ''Doku_Renderer_metadata'') |
169| <code diff u>
170--- /greenstone/greenstone-documentation/packages/dokuwiki-2011-05-25a/inc/parserutils.php  2012-02-01 16:03:06.000000000 +1300
171+++ parserutils.php 2013-09-19 10:46:58.000000000 +1200
172@@ -522,7 +522,12 @@ function p_render_metadata($id, $orig){
173         // loop through the instructions
174         foreach ($instructions as $instruction){
175             // execute the callback against the renderer
176-            call_user_func_array(array(&$renderer, $instruction[0]), (array) $instruction[1]);
177+       // - check we can, first, otherwise logs fill up with warnings
178+       $handler = array(&$renderer, $instruction[0]);
179+       if (is_callable($handler))
180+            {
181+              call_user_func_array($handler, (array) $instruction[1]);
182+       }
183         }
184 
185         $evt->result = array('current'=>&$renderer->meta,'persistent'=>&$renderer->persistent);
186</code>||
187=== inc/parser/handler.php ===
188
189^ File  ^ Changes  ^
190^ inc/parser/handler.php  | Hide HTML comments (namely text ids) in headings  |
191| <code diff u>
192--- dokuwiki-2011-05-25a/inc/parser/handler.php 2011-06-15 07:58:54.000000000 +1200
193+++ dokuwiki/inc/parser/handler.php 2011-12-16 11:37:45.036066485 +1300
194@@ -97,6 +97,9 @@
195         $title = trim($title,'=');
196         $title = trim($title);
197 
198+        // Hide HTML comments [jmt12]
199+        $title = preg_replace('/<\!--[^>]*-->/','',$title);
200+
201         if ($this->status['section']) $this->_addCall('section_close',array(),$pos);
202 
203         $this->_addCall('header',array($title,$level,$pos), $pos);
204</code> ||
205
206=== inc/parser/xhtml.php ===
207
208^ File  ^ Changes  ^
209^ inc/parser/xhtml.php  | Hide the reset header (whose content is simply "#"). Heavily altered //_highlight()// in order to allow the id specifying HTML comments to remain hidden. Added macro to external urls to allow for links to pages on the same host.  |
210| <code diff u>
211--- dokuwiki-2011-05-25a/inc/parser/xhtml.php   2011-06-15 07:58:54.000000000 +1200
212+++ dokuwiki/inc/parser/xhtml.php   2012-01-23 13:16:49.317187175 +1300
213@@ -170,6 +170,12 @@
214         }
215         $this->lastlevel = $level;
216 
217+   // Hide the 'reset' header
218+        if ($text == '#')
219+   {
220+     return;
221+   }
222+
223         if ($level <= $conf['maxseclevel'] &&
224             count($this->sectionedits) > 0 &&
225             $this->sectionedits[count($this->sectionedits) - 1][2] === 'section') {
226             
227@@ -449,19 +449,24 @@
228             $text = substr($text, 0, -1);
229         }
230 
231+        // - code HTML is now temporarily stored in a local string so we can
232+        //   restore specific HTML comments [jmt12]
233+        $code_text = '';
234         if ( is_null($language) ) {
235-            $this->doc .= '<pre class="'.$type.'">'.$this->_xmlEntities($text).'</pre>'.DOKU_LF;
236+          $code_text = '<pre class="'.$type.'">'.$this->_xmlEntities($text).'</pre>'.DOKU_LF; // [jmt12]
237         } else {
238             $class = 'code'; //we always need the code class to make the syntax highlighting apply
239             if($type != 'code') $class .= ' '.$type;
240 
241-            $this->doc .= "<pre class=\"$class $language\">".p_xhtml_cached_geshi($text, $language, '').'</pre>'.DOKU_LF;
242+            $code_text = "<pre class=\"$class $language\">".p_xhtml_cached_geshi($text, $language, '').'</pre>'.DOKU_LF; // [jmt12]
243         }
244+        // - restore id comments! [jmt12]
245+        $code_text = preg_replace('/\&lt\;\!\-\-\s+id\:([^\s]+)\s+\-\-\&gt\;/','<!-- id:\1 -->', $code_text);
246+        $this->doc .= $code_text; // [jmt12]
247 
248         if($filename){
249             $this->doc .= '</dd></dl>'.DOKU_LF;
250         }
251
252         $this->_codeblock++;
253     }
254 
255@@ -665,6 +670,16 @@
256             $class='media';
257         }
258 
259+        // [jmt12] Replace the macro ~~localhost~~ with the hostname (and port
260+        //         number if necessary) of the current host
261+        if (preg_match('/^http:\/\/~~baseurl~~(\/.*)$/', $url, $matches))
262+        {
263+          $host = $_SERVER['HTTP_HOST'];
264+          $path = substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/'));
265+          $url = 'http://' . $host . $path . $matches[1];
266+        }
267+        // [jmt12]
268+
269         //prepare for formating
270         $link['target'] = $conf['target']['extern'];
271         $link['style']  = '';
272</code> ||
273===== Plugins =====
274
275==== Custom Plugins ====
276
277=== SimpleTabs ===
278
279Support for simple tabbed areas (as compared to the existing complicated tabbed area plugins ala [[https://www.dokuwiki.org/plugin:tabinclude|TabInclude]]) is provided through a custom-built plugin. To reinstall:
280  * download {{:wiki:simpletabs-2014dec05.tgz|SimpleTabs}} (5.5K)
281  * extract to ''<dokuwiki>/lib/plugins/''
282The syntax looks like this:<code><TABAREA tabs="comma,separated,list">
283<TAB>content for 'comma' //including// wiki <del>magic</del> formatting</TAB>
284<TAB>content for 'separated' and a [[:playground|link]]</TAB>
285<TAB>content for 'list'</TAB>
286</TABAREA></code>
287
288Older versions: {{:wiki:simpletabs-2013sep18.tgz|2013SEP18}} (5.0K) {{:wiki:simpletabs-2013aug02.tgz|2013AUG02}} (4.3K)
289==== Code ====
290
291Diff against [[http://wiki.splitbrain.org/plugin:code2|code2]] plugin dated 2008-07-22.
292
293^ File  ^ Changes  ^
294^ syntax.php  | Restore the HTML comments containing text fragment ids to be proper hidden comments.  |
295| <code diff u>
296--- dokuwiki-2011-05-25a/lib/plugins/code/syntax.php    2012-01-23 11:16:05.033314469 +1300
297+++ dokuwiki/lib/plugins/code/syntax.php    2012-01-23 11:16:19.122156271 +1300
298@@ -226,6 +226,8 @@
299    function &_entities(&$aString) {
300        $aString = str_replace(array('&', '<', '>'),
301            array('&#38;', '&#60;', '&#62;'), $aString);
302+                // [jmt12] Restore the hidden ids to normal HTML comments
303+                $aString = preg_replace('/&#60;!-- id:(.*?) --&#62;/','<!-- id:\1 -->', $aString);
304        return $aString;
305    } // _entities()
306</code>  ||
307==== HTMLComment ====
308
309Diff against [[http://wiki.splitbrain.org/plugin:htmlcomment|htmlcomment]] plugin dated 2005-10-08.
310
311^ File  ^ Changes  ^
312^ syntax.php  | Added code to allow the use of an alternate HTML comment block (prefix %!--, suffix --%) that is automagically rendered using entities to appear verbatim in text (so appears as <!-- ... --> rather than being hidden).  |
313| <code diff u>
314--- dokuwiki-2011-05-25a/lib/plugins/htmlcomment/syntax.php 2005-10-09 11:31:47.000000000 +1300
315+++ dokuwiki/lib/plugins/htmlcomment/syntax.php 2012-01-20 14:03:27.078084422 +1300
316@@ -41,15 +41,24 @@
317     }
318 
319     function connectTo($mode) {
320-        $this->Lexer->addSpecialPattern("<\!--.*?-->", $mode,
321-          'plugin_htmlcomment');
322+        $this->Lexer->addSpecialPattern("<\!--.*?-->", $mode, 'plugin_htmlcomment');
323+        $this->Lexer->addSpecialPattern("%\!--.*?--%", $mode, 'plugin_htmlcomment');
324+        $this->Lexer->addSpecialPattern("<br/>", $mode, 'plugin_htmlcomment');
325     }
326 
327     function handle($match, $state, $pos, &$handler) {
328         if ($state == DOKU_LEXER_SPECIAL) {
329-             // strip <!-- from start and --> from end
330-            $match = substr($match,4,-3);
331-            return array($state, $match);
332+          if ($match == '<br/>')
333+          {
334+            return array('newline',$match);
335+          }
336+          if (strpos($match, '%!--') !== false)
337+          {
338+            $state = 'displaycomment';
339+          }
340+          // strip <!-- from start and --> from end
341+          $match = substr($match,4,-3);
342+          return array($state, $match);
343         }
344         return array();
345     }
346@@ -57,14 +66,31 @@
347     function render($mode, &$renderer, $data) {
348         if ($mode == 'xhtml') {
349             list($state, $match) = $data;
350-            if ($state == DOKU_LEXER_SPECIAL) {
351-                $renderer->doc .= '<!--';
352-                if (HTMLCOMMENT_SAFE) {
353-                    $renderer->doc .= $renderer->_xmlEntities($match);
354-                } else {
355-                    $renderer->doc .= $match;
356-                }
357-                $renderer->doc .= '-->';
358+            if ($state == 'newline')
359+            {
360+              $renderer->doc .= $match;
361+              return true;
362+            }
363+            if ($state == 'displaycomment')
364+            {
365+              $renderer->doc .= '&lt;!--';
366+            }
367+            else
368+            {
369+              $renderer->doc .= '<!--';
370+            }
371+            if (HTMLCOMMENT_SAFE) {
372+              $renderer->doc .= $renderer->_xmlEntities($match);
373+            } else {
374+              $renderer->doc .= $match;
375+            }
376+            if ($state == 'displaycomment')
377+            {
378+              $renderer->doc .= '--&gt;';
379+            }
380+            else
381+            {
382+              $renderer->doc .= '-->';
383             }
384             return true;
385         }
386</code> ||
387==== ImageReference ====
388
389Diff against [[http://wiki.splitbrain.org/plugin:imagereference|imagereference]] plugin dated 2008-05-30.
390
391^ File  ^ Changes  ^
392^ script.js  | More tests to prevent trying to access null objects  |
393| <code diff u>
394--- dokuwiki-2011-05-25a/lib/plugins/imagereference/script.js      2009-01-07 21:48:25.000000000 +1300
395+++ dokuwiki/lib/plugins/imagereference/script.js       2011-12-16 11:40:42.128166685 +1300
396@@ -3,7 +3,8 @@
397        var divs=document.getElementsByTagName("DIV");
398 
399       for (var i=0;i<divs.length;i++) {
400-        if (divs[i].className == "imgcaption" || divs[i].className == "imgcaptionleft" || divs[i].className == "imgcaptionright") {
401+        // adding in more checks to ensure elements exist [jmt12]
402+        if (divs[i] && divs[i].childNodes[0] && divs[i].childNodes[0].childNodes[0] && (divs[i].className == "imgcaption" || divs[i].className == "imgcaptionleft" || divs[i].className == "imgcaptionright")) {
403 
404             var children = divs[i].getElementsByTagName("IMG");
405             // check if there is a link encapsulating the image       
406@@ -13,12 +14,16 @@
407             else {
408                 // we have link and we can build the link image
409                 var innerElements = divs[i];
410-                var iLink = innerElements.childNodes[1].childNodes[2];
411-                var iSpan = iLink.childNodes[0];
412-                // set the href of the link to the image link
413-                iLink.href= innerElements.childNodes[0].href;
414-                // show the link image
415-                iSpan.style.display="inline";
416+                // adding in more checks to ensure elements exist [jmt12]
417+                if (innerElements && innerElements.childNodes[0] && innerElements.childNodes[1])
418+                {
419+                  var iLink = innerElements.childNodes[1].childNodes[2];
420+                  var iSpan = iLink.childNodes[0];
421+                  // set the href of the link to the image link
422+                  iLink.href= innerElements.childNodes[0].href;
423+                  // show the link image
424+                  iSpan.style.display="inline";
425+                }
426             }   
427             //var tmpLink = divs[i].childNodes[0];
428             divs[i].style.width=(tmpImg.width + 8)+"px";
429</code> ||
430^ style.css  | Altering colours to make caption bars fit in better with Monobook template  |
431| <code diff u>
432--- dokuwiki-2011-05-25a/lib/plugins/imagereference/style.css      2008-09-11 02:56:24.000000000 +1200
433+++ dokuwiki/lib/plugins/imagereference/style.css       2012-01-16 10:48:34.558129586 +1300
434@@ -7,15 +7,17 @@
435 
436 
437 div.imgcaption {
438-    border: 1px solid #ccc;
439+    border: 0px solid #000;
440     padding: 3px !important;
441-    background-color: #f9f9f9; 
442-    font-size: 94%;
443+    /*background-color: #113355;*/
444+    background-color: #777777;
445+    /*font-size: 94%;*/
446     text-align: center;
447     width: auto;
448     overflow: hidden;
449     margin: 1px auto;
450     float: none;
451+    font-weight: bold;
452 }
453 
454 div.imgcaptionleft {
455@@ -62,7 +64,8 @@
456 }
457 
458 div.dokuwiki .undercaption a:hover {
459-    text-decoration:none;
460+    color: #002BB8 !important;
461+    text-decoration:underline;
462 }
463 
464 div.dokuwiki .undercaption span {
465</code> ||
466^ syntax.php  | Rewrote large chunks of this code to; a) allow for table captions too, b) preserve formatting (italics) in the captions, c) allow specially formatted 'HTML comments' to be inserted but not display (to allow capture and retention of explicit text ids) and d) fix minor bugs (looks like some things were in a state of change from strings to arrays - some bits of the code were expecting the other)  |
467| <code diff u>
468--- dokuwiki-2011-05-25a/lib/plugins/imagereference/syntax.php     2008-09-11 18:29:12.000000000 +1200
469+++ dokuwiki/lib/plugins/imagereference/syntax.php      2012-01-19 11:03:52.285067251 +1300
470@@ -22,6 +22,7 @@
471       
472        var $_figure_name_array = array("");
473        var $_figure_map = array();
474+        var $_captions = array();
475       
476       
477    /**
478@@ -80,13 +81,17 @@
479     * @see render()
480     */
481     function connectTo($mode) {
482+
483       $this->Lexer->addSpecialPattern('<imgref\s[^\r\n]*?>',$mode, 'plugin_imagereference');
484-         $this->Lexer->addEntryPattern('<imgcaption\s[^\r\n\|]*?>(?=.*?</imgcaption.*?>)',$mode,'plugin_imagereference');
485-         $this->Lexer->addEntryPattern('<imgcaption\s[^\r\n\|]*?\|(?=[^\r\n]*>.*?</imgcaption.*>)',$mode,'plugin_imagereference');
486+      $this->Lexer->addSpecialPattern('<tblref\s[^\r\n]*?>',$mode, 'plugin_imagereference');
487+
488+      $this->Lexer->addEntryPattern('<imgcaption\s[^\|]+\|[^>]+(?=>.*?</imgcaption>)',$mode,'plugin_imagereference');
489+      $this->Lexer->addEntryPattern('<tblcaption\s[^\|]+\|[^>]+(?=>.*?</tblcaption>)',$mode,'plugin_imagereference');
490     }
491-
492+
493     function postConnect() {
494       $this->Lexer->addExitPattern('</imgcaption>', 'plugin_imagereference');
495+      $this->Lexer->addExitPattern('</tblcaption>', 'plugin_imagereference');
496     }
497       
498 
499@@ -120,24 +125,39 @@
500     * @static
501     */
502     function handle($match, $state, $pos, &$handler){
503-       
504         switch ($state) {
505         // =========================================================
506            case DOKU_LEXER_ENTER : {
507-               /* --------------------------------------------------- */
508-               $refLabel = trim(substr($match, 11, -1));
509+
510+             /* --------------------------------------------------- */
511+             $refLabel = ''; //trim(substr($match, 11, -1));
512+             $caption = '';
513+             if (preg_match('/<(?:img|tbl)caption\s+([^\|]+)\|([^>]+)/', $match, $matches))
514+             {
515+               $refLabel = $matches[1];
516+               $caption = $matches[2];
517+             }
518                // -----------------------------------------------------
519                $parsedInput = $this->_parseParam($refLabel);
520-               
521+
522                // ------------------------------------------------------
523                //$data = $this->_imgstart($parsedInput);
524                // store the figure name from imgcaption
525                array_push($this->_figure_name_array, $parsedInput[0]);
526-               
527-               $this->_figure_map[$parsedInput[0]] = "";
528-               
529+
530+               $this->_figure_map[$parsedInput[0]] = '';
531+
532+                $this->_captions[$parsedInput[0]] = $caption;
533+
534+                ///cho '<p>refLabel:' . $refLabel . '</p>';
535+                ///cho '<p>parsedInput:' . print_r($parsedInput, true) . '</p>';
536+                ///cho '<p>figure_name_array: ' . print_r($this->_figure_name_array, true) . '</p>';
537+                ///cho '<p>figure_map: ' . print_r($this->_figure_map, true) . '</p>';
538+                ///cho '<p>captions: ' . print_r($this->_captions, true). '</p>';
539+
540                return array('caption_open', $parsedInput);  // image anchor label
541                /* --------------------------------------------------- */
542+                //}
543            }
544         // =========================================================
545           case DOKU_LEXER_UNMATCHED : {
546@@ -191,7 +211,6 @@
547     * @see handle()
548     */
549     function render($mode, &$renderer, $indata) {
550-       
551         list($case, $data) = $indata;
552         if($mode == 'xhtml'){
553                // ---------------------------------------------
554@@ -200,8 +219,14 @@
555                        /* --------------------------------------- */
556                        $refNumber = array_search($data, $this->_figure_name_array);
557                        if ($refNumber == null || $refNumber == "")
558-                               $refNumber = "##";
559-                       $str = "<a href=\"#".$data."\">".$this->getLang('figure').$refNumber." </a>";
560+                        {
561+                          $refNumber = "##";
562+                        }
563+                        if (strpos($data,'#') === false)
564+                        {
565+                          $data = "#" . $data;
566+                        }
567+                       $str = "<a class=\"wikilink1\" href=\"".$data."\">".$this->getLang('figure').$refNumber."</a>";
568                        $renderer->doc .= $str; break;
569 //                      $renderer->_xmlEntities($str);break;
570                        /* --------------------------------------- */
571@@ -210,10 +235,26 @@
572                case 'caption_close' :  {
573                        // -------------------------------------------------------
574                                list($name, $number, $caption) = $data;
575-                               $layout = "<div class=\"undercaption\">".$this->getLang('fig').$number.":
576-                                       <a name=\"".$name."\">".$caption."</a><a href=\" \"><span></span></a>
577-                                       </div></div>";
578-                                       $renderer->doc .= $layout; break;
579+                        // - retrieve the caption separately
580+                        $caption = $this->_captions[$name];
581+                        // - special case for 'hidden' tables
582+                        $layout = '';
583+                        if ($caption != '##HIDDEN##')
584+                        {
585+                          // - manual do any formatting (as leaving it to the
586+                          //   parser (to foobar) is why we had to do this in
587+                          //   the first place
588+                          $caption = preg_replace('/\/\/%%(.+?)%%\/\//','<i>\1</i>',$caption);
589+                          $caption = preg_replace('/\/\/(.+?)\/\//','<i>\1</i>',$caption);
590+                          $caption = preg_replace('/\*\*(.+?)\*\*/','<b>\1</b>',$caption);
591+                          $caption = str_replace('%!--', '<!--', $caption);
592+                          $caption = str_replace('--%', '-->', $caption);
593+                          // - special case: nested image ref (we can't really resolve these)
594+                          $caption = preg_replace('/<imgref\s+([^>]+)><\/imgref>/','\1',$caption);
595+                          $layout = "<div class=\"undercaption\">".$this->getLang('fig').$number.": <a name=\"".$name."\"></a>".$caption."</div>";
596+                          }
597+                        $layout .= "</div>";
598+                        $renderer->doc .= $layout; break;
599                }
600                                // -------------------------------------------------------     
601                                // data is mostly empty!!!
602@@ -284,7 +325,7 @@
603     
604     function _imgstart($str) {
605        // ============================================ //
606-       if (!strlen($str)) return array();
607+      if (empty($str)) return '';
608       
609                $layout = "<div class=\"imgcaption";
610                //$layout = "<div><div class=\"imgcaption";
611@@ -304,6 +345,8 @@
612      * @return array(imagename, image number, image caption)
613      */
614     function _imgend($str) {
615+      // [jmt12] I think this function is unused!
616+
617        // ===================================================== //
618        $figureName = end($this->_figure_name_array);
619        // get the position of the figure in the array
620@@ -311,8 +354,9 @@
621               
622                return array($figureName, $refNumber, $str);
623               
624+
625                $layout = "<div class=\"undercaption\">".$this->getLang('fig').$refNumber.":
626-               <a name=\"".end($this->_figure_name_array)."\">".$str."</a></div>";
627+               <a name=\"".end($this->_figure_name_array)."\"></a>".$str."</div>";
628               
629                //$layout = "<div id=\"undercaption\">Fig. ".$refNumber.":
630                //<a name=\"".end($this->_figure_name_array)."\">".$str."</a></div></div></div>";
631</code> ||
632^ lang/en/lang.php  | Changed the strings  |
633| <code diff u>
634--- /dokuwiki-2011-05-25a/lib/plugins/imagereference/lang/en/lang.php       2008-09-11 02:56:24.000000000 +1200
635+++ dokuwiki/lib/plugins/imagereference/lang/en/lang.php        2011-12-12 11:24:57.668503137 +1300
636@@ -3,5 +3,5 @@
637  * english language file
638  */
639 
640-$lang['fig']           = 'Fig. ';
641-$lang['figure']        = 'figure';
642\ No newline at end of file
643+$lang['fig']           = 'Figure ';
644+$lang['figure']        = 'figure';
645</code> ||
646==== Publish ====
647
648Diff against [[http://www.dokuwiki.org/plugin:publish|publish]] plugin dated 2011-10-02.
649
650^ File  ^ Changes  ^
651^ action.php  | Never display "previous version" span - you can always look under old revisions anyway. In fact, try to hide the 'publish state' message unless the user is looking at a draft or if they are an editor (whereupon they may be interested in when a page was last approved etc)  |
652| <code diff u>
653--- dokuwiki-2011-05-25a/lib/plugins/publish/action.php    2011-10-16 03:55:40.000000000 +1300
654+++ dokuwiki/lib/plugins/publish/action.php     2012-01-24 10:34:18.115128733 +1300
655@@ -147,10 +147,14 @@
656         if($approver && !$most_recent_approved) { $strings[] = 'yes'; } else { $strings[] = 'no'; }
657         $strings[] = '">';
658 
659+        # [jmt12] We may not display the message at all
660+        $display_message = false;
661+
662         if($most_recent_draft) {
663             $strings[] = '<span class="approval_latest_draft">';
664             $strings[] = sprintf($this->getLang('apr_recent_draft'), wl($ID, 'force_rev=1'));
665             $strings[] = $this->difflink($ID, null, $REV) . '</span>';
666+            $display_message = true;
667         }
668 
669         if($most_recent_approved) {
670@@ -160,6 +164,7 @@
671             $strings[] = '<span class="approval_outdated">';
672             $strings[] = sprintf($this->getLang('apr_outdated'), wl($ID, 'rev=' . $userrev));
673             $strings[] = $this->difflink($ID, $userrev, $REV) . '</span>';
674+            $display_message = true;
675         }
676 
677         if(!$approver) {
678@@ -168,28 +173,27 @@
679             $strings[] = sprintf($this->getLang('apr_draft'),
680                             '<span class="approval_date">' . $longdate . '</span>');
681             $strings[] = '</span>';
682+            $display_message = true;
683         }
684 
685-        if($approver) {
686+        // [jmt12] Only display this notice to editors
687+        if($approver &&  $INFO['perm'] >= AUTH_EDIT) {
688             # Approved
689             $strings[] = '<span class="approval_approved">';
690             $strings[] = sprintf($this->getLang('apr_approved'),
691                             '<span class="approval_date">' . $longdate . '</span>',
692                             editorinfo($approver));
693             $strings[] = '</span>';
694-        }
695-
696-        if($previous_approved) {
697-            $strings[] = '<span class="approval_previous">';
698-            $strings[] = sprintf($this->getLang('apr_previous'),
699-                            wl($ID, 'rev=' . $previous_approved),
700-                            dformat($previous_approved));
701-            $strings[] = $this->difflink($ID, $previous_approved, $REV) . '</span>';
702+            $display_message = true;
703         }
704 
705         $strings[] = '</div>';
706 
707-        ptln(implode($strings));
708+        // [jmt12] if there is no message content, hide empty div
709+        if ($display_message)
710+        {
711+          ptln(implode($strings));
712+        }
713         return true;
714     }
715 
716</code> ||
717^ style.css  | Making the message bubbles at the top of pages a little smaller (it was taking up about 2 inches of vertical real-estate, which was expensive even on my wide screen---small screen users would have suffered greatly)  |
718| <code diff u>
719--- dokuwiki-2011-05-25a/lib/plugins/publish/style.css     2011-10-16 03:55:40.000000000 +1300
720+++ dokuwiki/lib/plugins/publish/style.css      2012-01-17 13:47:35.324065886 +1300
721@@ -3,7 +3,7 @@
722   margin-left: auto;
723   margin-right: auto;
724   width: 70% !important;
725-  min-height: 40px;
726+  min-height: 20px;
727   clear: both;
728   text-align: justify;
729   vertical-align: middle;
730</code> || 
731===== Templates =====
732
733==== Monobook ====
734
735Diff against [[https://www.dokuwiki.org/template:monobook|monobook]] template dated 2011-12-10.
736
737^ File  ^ Changes  ^
738^ main.php  | Removed positioning test so that the hierarchy navigation appears at both the top and bottom of pages (rather than one or the other)  |
739|  <code diff u>
740--- dokuwiki-2011-05-25a/lib/tpl/monobook/main.php  2012-01-23 13:37:25.353131918 +1300
741+++ dokuwiki/lib/tpl/monobook/main.php  2013-10-24 12:22:48.000000000 +1300
742@@ -613,8 +613,8 @@
743               $ACT !== "media" && //var comes from DokuWiki
744               (empty($conf["useacl"]) || //are there any users?
745                $loginname !== "" || //user is logged in?
746-               !tpl_getConf("monobook_closedwiki")) &&
747-              tpl_getConf("monobook_youarehere_position") === "top"){
748+               !tpl_getConf("monobook_closedwiki"))){// &&
749+                //              tpl_getConf("monobook_youarehere_position") === "top"){
750               echo "\n          <div class=\"catlinks noprint\"><p>\n            ";
751               tpl_youarehere();
752               echo "\n          </p></div>\n";
753@@ -665,8 +665,8 @@
754               $ACT !== "media" && //var comes from DokuWiki
755               (empty($conf["useacl"]) || //are there any users?
756                $loginname !== "" || //user is logged in?
757-               !tpl_getConf("monobook_closedwiki")) &&
758-              tpl_getConf("monobook_youarehere_position") === "bottom"){
759+               !tpl_getConf("monobook_closedwiki"))){ // &&
760+                //              tpl_getConf("monobook_youarehere_position") === "bottom"){
761               echo "\n          <div class=\"catlinks noprint\"><p>\n            ";
762               tpl_youarehere();
763               echo "\n          </p></div>\n";               
764@@ -698,7 +698,7 @@
765           //default
766           echo "style=\"background-image:url(".DOKU_TPL."static/3rd/dokuwiki/logo.png);\"";
767       }
768-      echo " accesskey=\"h\" title=\"[ALT+H]\"></a>\n";
769+      echo " accesskey=\"h\" title=\"Back to start [ALT+H]\"></a>\n";
770       ?>
771     </div>
772     <?php
773@@ -733,7 +733,7 @@
774                 echo "          <li id=\"pt-mytalk\">".html_wikilink(tpl_getConf("monobook_discuss_ns").ltrim(tpl_getConf("monobook_userpage_ns"), ":").$loginname, hsc($lang["monobook_tab_mytalk"]))."</li>";
775             }
776             //profile
777-            echo  "          <li id=\"pt-preferences\"><a href=\"".wl(cleanID(getId()), array("do" => "profile"))."\" rel=\"nofollow\">".hsc($lang["btn_profile"])."</a></li>\n"; //language comes from DokuWiki core
778+            echo  "          <li id=\"pt-preferences\"><a href=\"http://www.greenstone.org/users/change.php\" rel=\"nofollow\">".hsc($lang["btn_profile"])."</a></li>\n"; //language comes from DokuWiki core
779             //logout
780             echo  "          <li id=\"pt-logout\"><a href=\"".wl(cleanID(getId()), array("do" => "logout"))."\" rel=\"nofollow\">".hsc($lang["btn_logout"])."</a></li>\n"; //language comes from DokuWiki core
781         } 
782</code>  ||
783^ static/css/screen.css  | Restrict the width of code blocks - otherwise they'll push out past the 1000px limit anyway - and set them to use scrollbars for any overflow.  Making h5 different (I can't remember why). Two little fixes for the new simple tabbed area where there are extra pixels sneaking in between the tabs and the tab content areas. |
784| <code diff u>
785--- screen.css.original 2012-12-13 12:54:13.000000000 +1300
786+++ screen.css  2013-08-02 12:00:08.000000000 +1200
787@@ -535,10 +535,12 @@ div#content .dokuwiki h1 a,
788 div#content .dokuwiki h2 a,
789 div#content .dokuwiki h3 a,
790 div#content .dokuwiki h4 a,
791-div#content .dokuwiki h5 a,
792 div#content .dokuwiki h6 a {
793   color: __text__;
794 }
795+div#content .dokuwiki h5 a {
796+  color: __background__;
797+}
798 div#content .dokuwiki h1 a:hover,
799 div#content .dokuwiki h2 a:hover,
800 div#content .dokuwiki h3 a:hover,
801@@ -571,6 +573,7 @@ div#content .dokuwiki h4 {
802 }
803 div#content .dokuwiki h5 {
804   font-size: 100%;
805+  color: __background__;
806 }
807 div#content .dokuwiki h6 {
808   font-size: 80%;
809@@ -629,7 +632,7 @@ div.dokuwiki li.closed {
810 
811 div#content div.dokuwiki li {
812   margin-left: 0;
813-  margin-bottom: 1px;
814+  margin-bottom: 0;
815 }
816 
817 /* quotes */
818@@ -678,6 +678,8 @@
819   line-height: 1.2em;
820   padding: 0.5em;
821   border-style: dashed;
822+  overflow: scroll;
823+  width: 800px;
824 }
825 div#content .dokuwiki dl.file,
826 div#content .dokuwiki dl.file dd {
827@@ -1338,3 +1343,7 @@ textarea,
828   #font-weight: bold;
829   #border-left: 1px dashed __background__; /* invisible border triggers IE to render the stuff */
830 }
831+
832+div.tab {
833+ margin-top:-1px;
834+}
835</code> ||
836^ static/3rd/dokuwiki/_tabs.css  | Remove the override of foreground and background colours. |
837| <code diff u>
838--- _tabs.css.original  2013-08-02 12:07:12.000000000 +1200
839+++ _tabs.css   2013-08-02 12:07:36.000000000 +1200
840@@ -19,8 +19,6 @@
841     float: left;
842     padding: .3em .8em;
843     margin: 0 .3em 0 0;
844-    background-color: __background_neu__;
845-    color: __text__;
846     border-radius: .5em .5em 0 0;
847 }
848 .dokuwiki ul.tabs li strong {
849</code> ||
850^ static/3rd/monobook/main.css  | Reduce the text area to around 1000px by centring main div and other absolute divs (logo and top navigation).  Rename the style "preferences" to "preftitle" to prevent CSS being randomly injected where-ever you end up with an anchor tag that just happens to have the word preferences in it (happens surprisingly often in instruction manuals). I can't actually find where this style is used anyway. |
851| <code diff u>
852--- dokuwiki-2011-05-25a/lib/tpl/monobook/static/3rd/monobook/main.css  2012-01-23 13:41:54.253064506 +1300
853+++ dokuwiki/lib/tpl/monobook/static/3rd/monobook/main.css  2012-01-23 11:45:42.674067707 +1300
854@@ -27,7 +27,7 @@
855    background: white;
856    color: black;
857    border: 1px solid #aaa;
858-   border-right: none;
859+   /*border-right: none;*/
860    line-height: 1.5em;
861    position: relative;
862    z-index: 2;
863@@ -54,6 +54,8 @@
864 /* scale back up to a sane default */
865 #globalWrapper {
866    font-size: 127%;
867+   width: 1024px;
868+   margin: 0 auto;
869    padding: 0;
870 }
871 .visualClear {
872@@ -702,7 +704,7 @@
873    z-index: 3;
874    position: absolute; /*needed to use z-index */
875    top: 0;
876-   left: 0;
877+   /*left: 0;*/
878    height: 155px;
879    width: 12em;
880    overflow: visible;
881@@ -858,9 +860,10 @@
882 #p-cactions {
883    position: absolute;
884    top: 1.3em;
885-   left: 11.5em;
886+   /*left: 11.5em;*/
887    margin: 0;
888    white-space: nowrap;
889+   width: 1024px;
890    line-height: 1.1em;
891    overflow: visible;
892    background: none;
893@@ -1034,7 +1037,7 @@
894    padding-top: 2em;
895    clear: both;
896 }
897-#preferences {
898+#preftitle {
899    margin: 0;
900    border: 1px solid #aaa;
901    clear: both;
902</code> ||
Note: See TracBrowser for help on using the browser.