diff --git a/conf/default.php b/conf/default.php index 2016b64..398f122 100644 --- a/conf/default.php +++ b/conf/default.php @@ -8,6 +8,10 @@ $conf['sortkey'] = 'cdate'; // sort key for blog entries $conf['sortorder'] = 'descending'; // ascending or descending +$conf['showhistogram'] = 1; // show histogramm in archive +$conf['max_months'] = 100; // max months to show in the histogram +$conf['histogram_height'] = 50; // height of the histogram in pixels + $conf['excluded_pages'] = '!^blog:\d{4}(:\d{2})?$!'; // regex for pages to exclude from bloglisting // vim:ts=4:sw=4:et:enc=utf-8: diff --git a/conf/metadata.php b/conf/metadata.php index c5619a0..8452594 100644 --- a/conf/metadata.php +++ b/conf/metadata.php @@ -15,4 +15,7 @@ '_choices' => array('ascending', 'descending')); $meta['excluded_pages'] = array('string'); +$meta['showhistorgram'] = array('onoff'); +$meta['max_months'] = array('numeric'); +$meta['histogram_height'] = array('numeric'); // vim:ts=4:sw=4:et:enc=utf-8: diff --git a/lang/en/lang.php b/lang/en/lang.php index 4630502..e17ad82 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -30,4 +30,7 @@ $lang['month_11'] = 'November'; $lang['month_12'] = 'December'; +$lang['entries'] = 'entries'; +$lang['entry'] = 'entry'; +$lang['archive_title'] = 'Blog History'; //Setup VIM: ex: et ts=2 enc=utf-8 : diff --git a/lang/en/settings.php b/lang/en/settings.php index 2ef63ba..e4639a5 100644 --- a/lang/en/settings.php +++ b/lang/en/settings.php @@ -28,4 +28,8 @@ $lang['excluded_pages'] = 'exclude certain pages from blog listing (regular expression required)'; +$lang['showhistorgram'] = 'Display histogram on archive rendering'; +$lang['max_months'] = 'Max months to show in the histogram'; +$lang['histogram_height'] = 'Height of the histogram (in pixels)'; + // vim:ts=4:sw=4:et:enc=utf-8: diff --git a/style.css b/style.css index 866bac4..5c90949 100644 --- a/style.css +++ b/style.css @@ -14,22 +14,27 @@ div.dokuwiki div.draft { } div.dokuwiki div.autoarchive_selector ul { - list-style-type: none; - clear: left; - margin: 0 0.5em 0 0; + list-style-type: none; + clear: left; + margin: 0 0.5em 0 0; } div.dokuwiki div.autoarchive_selector ul div.li { - float: left; - margin: 0 1em 0 0; + float: left; + margin: 0 1em 0 0; } div.dokuwiki div.autoarchive_selector ul ul { - float: left; - clear: none; + float: left; + clear: none; } div.dokuwiki div.autoarchive_selector ul ul div.li { - margin: 0; + margin: 0; } +img.blog_archive_bar { + background-color: __border__; + width: 5px; + border: 0 none; +} diff --git a/syntax/archive.php b/syntax/archive.php index 492dc3e..88bb98a 100644 --- a/syntax/archive.php +++ b/syntax/archive.php @@ -114,26 +114,109 @@ function render($mode, &$renderer, $data) { if (!$entries) return true; // nothing to display if ($mode == 'xhtml') { + // Configuration + $archive_mode = $this->getConf('archive_mode'); + $max_months = $this->getConf('max_months'); + $histogram_height = $this->getConf('histogram_height'); + // prevent caching for current month to ensure content is always fresh if (time() < $end) $renderer->info['cache'] = false; - // let Pagelist Plugin do the work for us - if (plugin_isdisabled('pagelist') - || (!$pagelist =& plugin_load('helper', 'pagelist'))) { - msg($this->getLang('missing_pagelistplugin'), -1); - return false; - } - $pagelist->setFlags($flags); - $pagelist->startList(); - foreach ($entries as $entry) { - - // entry in the right date range? - if (($start > $entry['date']) || ($entry['date'] >= $end)) continue; - - $pagelist->addPage($entry); + if ($this->getConf('showhistogram')) { + $current_year =''; + $current_month =''; + $ul_open = false; + + $histogram = ''; + $histogram_count = array(); + $histogram_higher = 0; + $posts_count = 0; + + $list = ''; + + // Generate posts list + foreach ($entries as $entry) { + // entry in the right date range? + if (($start > $entry['date']) || ($entry['date'] >= $end)) continue; + + if ($current_year != date('o',$entry['date'])) { + if ($ul_open) { + $list.=""; + $ul_open = false; + } + $current_year = date('o',$entry['date']); + $list.='

'.$current_year."

"; + } + if ($current_month != date('m',$entry['date'])) { + if ($ul_open) { + $list.=""; + } + $current_month = date('m',$entry['date']); + $list.='

'.$this->getLang('month_'.$current_month)."

"; + + if ($posts_count > $max_posts) { + $posts_count = $max_posts; + } + // Generate histogram + $histogram_count = array_reverse($histogram_count); + $month_count = 0; + foreach ($histogram_count as $key => $month_reference) { + // Check the max_months parameter + if ($month_count >= $max_months) { + break; + } + if ($month_reference > 0) { + // Height in "px" + $current_height = $histogram_height / $histogram_higher * $month_reference; + } else { + // Height in "px" + $current_height = 1; + } + // Generate the alt attribute + $alt = $key.': '.$month_reference.' '; + if ($month_reference > 1) { + $alt .= $this->getLang('entries'); + } else { + $alt .= $this->getLang('entry'); + } + $histogram .= ''; + $histogram .= ''.$alt.'" . DOKU_LF; + $month_count += 1; + } + // Add histogram and posts list + $renderer->doc .= "

".$this->getLang('archive_title')."

".$histogram.'

'.$list.'
'; + } else { + // prevent caching for current month to ensure content is always fresh + if (time() < $end) $renderer->info['cache'] = false; + + // let Pagelist Plugin do the work for us + if (plugin_isdisabled('pagelist') + || (!$pagelist =& plugin_load('helper', 'pagelist'))) { + msg($this->getLang('missing_pagelistplugin'), -1); + return false; + } + $pagelist->setFlags($flags); + $pagelist->startList(); + foreach ($entries as $entry) { + + // entry in the right date range? + if (($start > $entry['date']) || ($entry['date'] >= $end)) continue; + + $pagelist->addPage($entry); + } + $renderer->doc .= $pagelist->finishList(); } - $renderer->doc .= $pagelist->finishList(); return true; // for metadata renderer