Skip to content

Commit

Permalink
Added config option 'index_in_browser':
Browse files Browse the repository at this point in the history
- 'hide': like today, table of contents and chapter index will not be visible in the browser view
- 'display placeholder': a placeholder will be display showing the user in the browser that a table of contents or chapter index will be inserted after export. It also reminds the user to update the index after export.
  • Loading branch information
lpaulsen93 committed Feb 9, 2016
1 parent 5db3fdf commit 143ab25
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 12 deletions.
11 changes: 6 additions & 5 deletions conf/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
$conf['disable_links'] = 'No';

// TOC settings
$conf['toc_maxlevel'] = '';
$conf['toc_leader_sign'] = '.';
$conf['toc_indents'] = '0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5';
$conf['toc_pagebreak'] = 'Yes';
$conf['toc_style'] = 'color:black;';
$conf['toc_maxlevel'] = '';
$conf['toc_leader_sign'] = '.';
$conf['toc_indents'] = '0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5';
$conf['toc_pagebreak'] = 'Yes';
$conf['toc_style'] = 'color:black;';
$conf['index_in_browser'] = 'hide';
11 changes: 6 additions & 5 deletions conf/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@

$meta['disable_links'] = array('multichoice', '_choices' => array('No', 'Yes'));

$meta['toc_maxlevel'] = array('numeric');
$meta['toc_leader_sign'] = array('string');
$meta['toc_indents'] = array('string');
$meta['toc_pagebreak'] = array('multichoice', '_choices' => array('Yes', 'No'));
$meta['toc_style'] = array('string');
$meta['toc_maxlevel'] = array('numeric');
$meta['toc_leader_sign'] = array('string');
$meta['toc_indents'] = array('string');
$meta['toc_pagebreak'] = array('multichoice', '_choices' => array('Yes', 'No'));
$meta['toc_style'] = array('string');
$meta['index_in_browser'] = array('multichoice', '_choices' => array('hide', 'display placeholder'));
9 changes: 9 additions & 0 deletions helper/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,15 @@ public function __construct() {
'hasMeta' => true,
'addMetaAtStartOnly' => false,
'refresh' => false);
// Index display in browser
$this->config ['index_in_browser'] =
array('value' => NULL,
'DWGlobalName' => NULL,
'hasGlobal' => true,
'hasURL' => true,
'hasMeta' => true,
'addMetaAtStartOnly' => false,
'refresh' => false);
}

/**
Expand Down
8 changes: 8 additions & 0 deletions lang/de-informal/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@
$lang['export_odt_button'] = 'ODT exportieren';
$lang['tpl_not_found'] = 'FEHLER: Die ODT Vorlage "%s" konnte im Vorlagenverzeichnis "%s" nicht gefunden werden. Der Export wurde abgebrochen.';
$lang['toc_title'] = 'Inhaltsverzeichnis';
$lang['chapter_title'] = 'Kapitelinhalt';
$lang['toc_msg'] = 'Ein Inhaltsverzeichnis wird an dieser Stelle eingefügt.';
$lang['chapter_msg'] = 'Ein Kapitelverzeichnis wird an dieser Stelle eingefügt.';
$lang['update_toc_msg'] = 'Bitte vergessen Sie nicht, das Inhaltsverzeichnis nach dem Export zu aktualisieren.';
$lang['update_chapter_msg'] = 'Bitte vergessen Sie nicht, das Kapitelverzeichnis nach dem Export zu aktualisieren.';
$lang['needtitle'] = 'Bitte Titel angeben!';
$lang['needns'] = 'Bitte geben Sie einen vorhandenen Namensraum an.';
$lang['empty'] = 'Sie haben noch keine Seiten gewählt.';

5 changes: 5 additions & 0 deletions lang/de/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
$lang['export_odt_button'] = 'ODT exportieren';
$lang['tpl_not_found'] = 'FEHLER: Die ODT Vorlage "%s" konnte im Vorlagenverzeichnis "%s" nicht gefunden werden. Der Export wurde abgebrochen.';
$lang['toc_title'] = 'Inhaltsverzeichnis';
$lang['chapter_title'] = 'Kapitelinhalt';
$lang['toc_msg'] = 'Ein Inhaltsverzeichnis wird an dieser Stelle eingefügt.';
$lang['chapter_msg'] = 'Ein Kapitelverzeichnis wird an dieser Stelle eingefügt.';
$lang['update_toc_msg'] = 'Bitte vergessen Sie nicht, das Inhaltsverzeichnis nach dem Export zu aktualisieren.';
$lang['update_chapter_msg'] = 'Bitte vergessen Sie nicht, das Kapitelverzeichnis nach dem Export zu aktualisieren.';
$lang['needtitle'] = 'Bitte Titel angeben!';
$lang['needns'] = 'Bitte geben Sie einen vorhandenen Namensraum an.';
$lang['empty'] = 'Sie haben noch keine Seiten gewählt.';
9 changes: 7 additions & 2 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
// template not found in the directory
$lang['tpl_not_found'] = 'ERROR : the ODT template "%s" was not found in the templates directory "%s". The export has been aborted.';

// default TOC title
$lang['toc_title'] = 'Table of Contents';
// default TOC and chapter index title
$lang['toc_title'] = 'Table of Contents';
$lang['chapter_title'] = 'Chapter Index';
$lang['toc_msg'] = 'A Table of Contents will be inserted here.';
$lang['chapter_msg'] = 'A Chapter Index will be inserted here.';
$lang['update_toc_msg'] = 'Please remember to update the Table Of Contents after export.';
$lang['update_chapter_msg'] = 'Please remember to update the Chapter Index after export.';

$lang['needtitle'] = "Please provide a title.";
$lang['needns'] = "Please provide an existing namespace.";
Expand Down
14 changes: 14 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@
background-position: left -45px;
}

/* Style for Table of contents and chapter index preview */
p.index_preview_odt {
border: 2pt dashed gray;
background-color: whitesmoke;
padding: 10pt;
}

#text.index_preview_odt {
color: black;
}

#reminder.index_preview_odt {
color: red;
}
29 changes: 29 additions & 0 deletions syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,16 @@ public function render($format, Doku_Renderer $renderer, $data) {
} elseif($format == 'metadata') {
/** @var Doku_Renderer_metadata $renderer */
$renderer->meta['relation']['odt']['toc'] = $info_value;
} elseif($format == 'xhtml') {
$this->insert_index_preview ($renderer, 'toc');
}
break;
case 'chapter-index': // Insert chapter index in exported ODT file
if($format == 'odt') {
/** @var renderer_plugin_odt_page $renderer */
$renderer->render_index('chapter', $info_value);
} elseif($format == 'xhtml') {
$this->insert_index_preview ($renderer, 'chapter');
}
break;
case 'disablelinks': // Disable creating links and only show the text instead
Expand Down Expand Up @@ -207,4 +211,29 @@ public function render($format, Doku_Renderer $renderer, $data) {
return false;
}

/**
* Insert a browser preview for an index.
*
* @param Doku_Renderer $renderer The current renderer
* @param string $type The index type ('toc' or 'chapter)'
*/
function insert_index_preview ($renderer, $type='toc') {
if ($this->config->getParam ('index_in_browser') == 'hide') {
return;
}
switch ($type) {
case 'toc':
$msg = $this->getLang('toc_msg');
$reminder = $this->getLang('update_toc_msg');
break;
case 'chapter':
$msg = $this->getLang('chapter_msg');
$reminder = $this->getLang('update_chapter_msg');
break;
}
$renderer->doc .= '<p class="index_preview_odt">';
$renderer->doc .= '<span id="text" class="index_preview_odt">'.$msg.'</span><br>';
$renderer->doc .= '<span id="reminder" class="index_preview_odt">'.$reminder.'</span>';
$renderer->doc .= '</p>';
}
}

0 comments on commit 143ab25

Please sign in to comment.