neuralyzer / dokuwiki-plugin-revealjs

Reval.js plugin for dokuwiki
16 stars 12 forks source link

New options slide level and push nested slide headers #14

Closed ogobrecht closed 7 years ago

ogobrecht commented 8 years ago

Hi,

after your last comment on #13 I decided to leave the feature push_headers in the pull request. Feel free to delete the functionality - it is only one line in the configuration files and 4 lines in the header function in the renderer.php and of course the README.md and one parameter in the example presentation button definition. I have currently no better solution for this and as you commented may be all other ideas for this problem are more complex to implement.

Again sorry for the forgotten quotes and the debug call. Four eyes see more than two :-)

Best regards Ottmar

Changes overview

To make the organization of slide shows more flexible we introduce two new parameters: slide_level and push_headers. For a description see settings.php (next section). An example: I often organize my slideshows with H1 horizontal slides for the main points and then H2 vertical slides for the details. With the existing implementation I am not able to have H2 vertical (nested) slides, because only H3 headers goes vertical. And H3 headers are simply too small - for the presentation and also for the wiki page - they break the logic, that after a H1 header we normally use a H2 header for the subpoints. By setting the slide level to 1 this is possible. Since all parameters are now overwritable per wiki page, we can adapt this for each presentation.

If we use slide_level 2 to have H1 and H2 header slides horizontally, then we can push all headers on vertical slide by one with the option push_headers. This can fix our problem with too small slide headers on vertical slides.

At the end we have more flexible ways to organize our slides. In the default settings nothing changes for existing slides - we are backward compatible.

lang/en/settings.php

$lang['slide_level'] = "Headers on this level or above starting a horizontal slide. Levels below starting a vertical (nested) slide";
$lang['push_headers'] = "Push headers below slide_level to the next higher one";

conf/metadata.php

$meta['slide_level'] = array('multichoice','_choices' => array(1, 2));
$meta['push_headers'] = array('onoff');

conf/default.php

$conf['slide_level'] = 2;
$conf['push_headers'] = 0;

renderer.php

    function header($text, $level, $pos) {
        $slide_level = $this->getConf('slide_level');
        if($level <= $slide_level + 1){
            if($this->slide_open){
                $this->doc .= '</section>'.DOKU_LF; //close previous slide
                if ( ($this->column_open) && ($level <= $slide_level) ) { // close nested section
                      $this->doc .= '</section>'.DOKU_LF;
                      $this->column_open = false;
                }
            }
            if ( $level <= $slide_level ) { //first slide of possibly following nested ones if level is slide_level
                 $this->create_slide_section(false); # always without background to not to have a background for a whole subsection
                 $this->column_open = true;
            }
            $this->create_slide_section(true);
            $this->slide_open = true;
        }
        $level_calculated = ($level > $slide_level && $this->getConf('push_headers') ? $level - 1 : $level);
        $this->doc .= '<h'. $level_calculated .'>';
        $this->doc .= $this->_xmlEntities($text);
        $this->doc .= '</h'. $level_calculated .'>'.DOKU_LF;
    }

example_presentation.dokuwiki

**Caution**: Only H2 sections open the vertical axis. If an H3 section follows after an H1 section it is appended horizontally.