aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor <pashev.igor@gmail.com>2010-11-06 19:31:16 +0300
committerIgor <pashev.igor@gmail.com>2010-11-06 19:31:16 +0300
commitfbafb72df08821dc281c5f04225cd6da5452d30f (patch)
treeb71e6725a16ec60ef9e2b5b8831aaf33d7428200
parente6cb69aed00a8465525e9609b8085e999962158e (diff)
downloaddokuwiki-plugin-papers-fbafb72df08821dc281c5f04225cd6da5452d30f.tar.gz
Added: recent papers
-rw-r--r--README34
-rw-r--r--syntax.php14
2 files changed, 40 insertions, 8 deletions
diff --git a/README b/README
index 8e92f90..23f95fd 100644
--- a/README
+++ b/README
@@ -1,7 +1,5 @@
This is a syntax plugin for Dokuwiki (http://www.dokuwiki.org/).
-
-
It introduces two syntax extentions for Dokuwiki:
@@ -21,9 +19,31 @@ no empty line are allowed before </bibtex>
2. Publications selected from <bibtex> by some attributes.
-<papers>
-author = pashev
-year = 2005
-source = Публикации
-</papers>
+Examples:
+
+a) All papers by 'pashev'
+grouped by paper type (article, book, etc.)
+sorted by year descend:
+ <papers>
+ author = pashev
+ </papers>
+
+b) Five recent papers by 'pashev'
+sorted by year descend and paper type:
+ <papers>
+ author = pashev
+ recent=5
+ </papers>
+
+c) Papers of 2009 year, grouped by paper type (article, book, etc.):
+ <papers>
+ year=2009
+ </papers>
+
+d) Papers of 2009 year, grouped by paper type (article, book, etc.)
+taken from wiki page 'all_our_papers':
+ <papers>
+ year=2009
+ source=all_our_papers
+ </papers>
diff --git a/syntax.php b/syntax.php
index f98507f..11e36e3 100644
--- a/syntax.php
+++ b/syntax.php
@@ -82,7 +82,7 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin
}
$options = array('byyear' => 0);
- foreach(array('raw', 'byyear') as $o)
+ foreach(array('raw', 'byyear', 'recent') as $o)
{
if (isset($spec[$o]))
{
@@ -90,6 +90,12 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin
unset($spec[$o]);
}
}
+ if (isset($options['recent']))
+ {
+ $options['raw'] = 1;
+ $options['byyear'] = 1;
+ }
+
// end: display options, not BiBTeX fields
$bibtex = (!isset($options['byyear']) || $options['byyear']) ?
@@ -152,9 +158,15 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin
$dub = array();
$byyear = !isset($options['byyear']) || $options['byyear'];
$raw = !isset($options['raw']) || !$options['raw'];
+ $recent = isset($options['recent']) ? $options['recent'] : 9999999;
+ $count = 0;
foreach ($bibtex->SELECTION as &$entry)
{
+ $count++;
+ if ($count > $recent)
+ break;
+
if ($raw)
{
if ($byyear)