====== Blog Plugin ====== ---- plugin ---- description: Use DokuWiki as blogging tool. (previous authors: Esther Brunner) author : Gina Häußge, Michael Klier email : dokuwiki@chimeric.de type : syntax, action, helper lastupdate : 2008-07-18 compatible : 2008-05-05 depends : include, pagelist conflicts : similar : tags : blogging, blog, news ---- ===== Download ===== ^ Download | [[http://www.chimeric.de/_src/plugin-blog.tgz|plugin-blog.tgz]] | ^ BundleHub | Configure your own DokuWiki blogsuite install package, consisting of all mandatory plugins plus any optional features you want to include: \\ [[http://dokuwiki.foosel.org/blogsuite/index.php|BlogSuite BundleHub]] | ^ Tips | If you intend to use this plugin be sure to take a look at the [[tips:blogging|blogging tips page]] | ===== Description ===== The Blog [[plugins|Plugin]] makes blogs in your wiki easily possible. The [[#blog]] component shows the latest entries (pages) from a namespace in reverse chronological order. In this new version, the creation date is the sort key -- no longer the date of the last non-minor modification as in previous versions. The [[#archive]] component lists all entries that were written (created) in the given month. If you use this plugin for blogging you might want to join [[http://planet.dokuwiki.org/|Planet DokuWiki]]. ===== Configuration ===== The blog plugin can be configured using the DokuWiki configuration manager available in the admin menu. ^ ''namespace'' | The default namespace which is used if no namespace was given in the syntax | ^ ''formposition'' | You can choose to display the new entry form either above or below the blog entries | ^ ''dateprefix'' | A date prefix that automatically gets added to pages created with the new entry form. You can use the options from the [[phpnet>strftime]] php function, namespace separators work as well ie. ''%Y:%m%d'' | ^ ''sortkey'' | Defines how the blog entries are sorted. Available options are creation date, modification date, page name, page ID and page title (first headline) | ^ ''sortorder'' | Sort the blog entries ascending/descending | ===== Components ===== ==== Blog ==== {{blog>[namespace]?[number]&[flags]}} ^ [namespace] | namespace for the blog; subspaces will be searched as well; ''*'' is the whole wiki, ''.'' is the same namespace as the page lies in | optional; default is the blog namespace set in the configuration | ^ [number] | number of entries to show per page | optional; default is 5 | ^ [flags] | include flags delimited by ''&'', see [[include#flags]] | optional | This includes a specified number of most recent blog entries from the given namespace into the current page. Below the entries a link to the page (permalink), the author, the creation date and the number of comments are shown. Link, author, date and comments info can be hidden. At the end of the blog a link to older entries lets you navigate in the history of the blog. At the very end, if you have enough rights to create new pages, a form for new blog entries is displayed. ==== Archive ==== {{archive>[namespace]?[month]&[flags]}} ^ [namespace] | the namespace for which you want an archive list; ''*'' is the whole wiki, ''.'' is the same namespace as the page lies in | optional; default is the namespace specified in the configuration | ^ [month] | the month for the archive list in YYYY-MM format; ''*'' for all pages | required | ^ [flags] | pagelist flags delimited by ''&'', see [[pagelist#flags]] | optional | Shows a table with all pages of the given namespace that were created in the specified month. ===== Demo ===== You can try this plugin [[http://chimeric.de/_demo/plugin:blog|here]]. ===== Bugs ===== Please report bugs at the [[http://bugs.chimeric.de/index.php?project=8&switch=1&do=index|Bug tracker]]. ===== Further Resources ===== * [[http://darcs.chimeric.de/darcsweb.cgi?r=blog|Darcs Repository]] * [[http://bugs.chimeric.de/index.php?project=8&switch=1&do=index|Bug tracker]] * [[http://www.chimeric.de/_dev/codereference/nav.html?plugins/blog/index.html|Source code]] ===== Changes ===== {{rss>http://darcs.chimeric.de//darcsweb.cgi?r=blog;a=rss}} ===== FAQ ===== Please also have a look at the [[tips:blogging]] tips page! ==== My dates are shown wrong. What can I do? ==== Make sure you run the latest version of all required plugins and DokuWiki. ==== Is it possible to change the way the date is displayed? ==== Yes, the plugin uses the [[config:dformat]] option to format the date. ==== How can I alter the date of a blog post? ==== You can use the [[plugin:meta]] plugin to manually set the creation date (and modification date) in the page source, then select the modification date in the blog plugins order setting. An alternative solution would be to alter the timestamps of the created files, and remove the ''/data/index/cdate.idx'' (make backups if you intent to do that!!) ===== Discussion ===== The namespace parameter seems to be locked to the top of the site. I had thought that specifying a relative namespace (like ".:news") in the config would let people add their own news/status item lists to whatever parts of our site that they liked, but new entries were created all together in /news rather than under the namespace of the page where the "blog" tag appeared. Is this the intended behavior? It seems like the plugin would be perfect for news/status items, otherwise. We have a wiki ([[http://php.twofourfour.org/dokuwiki/start]]) with 3 blogs in separate namespaces but one of them ([[http://php.twofourfour.org/dokuwiki/ltu/lulea]]) didn't want to show up until I forced the first post. The "New blog entry" box would show up in the preview but not in the saved page. Only after I created a first post via the preview did it work. Possible bug? ==== Refinement of listed blog posts with tags ==== I have been looking for some extension which could filter listed blog posts with some tags only. I haven't found any, so I started to look into ''blog/syntax/blog.php'' source code. Here I found that it's already done, but it's not documented anywhere. You can specify tags after the namespace in similar way like in ''{{topic>+tag1 -tag2}}''. So, I suggest to change the explanation of ''[namespace]'' field in ''{{blog}}'' command [[#blog|above]] like this: ^ [namespace] | namespace for the blog; subspaces will be searched as well; ''*'' is the whole wiki, ''.'' is the same namespace as the page lies in; after the space, you can specify a list of tags to refine, e.g. ''{{blog>ns +tag1 -tag2}}'' (syntax is similar to ''{{topic>+tag1 -tag2}}'') | optional; default is the blog namespace set in the configuration | ==== Draft for an HowTo import blog posts (technical discussion) ==== > Original question was: I 'imported' some blog posts from my old wiki into my new installation by copying the files while preserving the modification date (''cp -p'' under linux). I configured the blog plugin to sort posts by their creation date. But now on the blog **overview** page all the imported posts show up with a date when I copied the file in their footer instead of the date when the file was originally created (in my old wiki). Where does this date come from? -- Robert > >I think I already found out something: Could it be that the indexer does some work here? Could it be that the indexer has a bug, when he finds a completely new pages/somepost.txt? I think then it creates meta/somepost.meta with wrong dates or no dates at all. --Robert >> This is not a //bug// of the indexer, but the desired functionality. Imagine someone edited a page outside of DokuWiki with a text editor, the indexer looks at the timestamps, if the timestamp is newer then the latest cached revisions it assumes (correctly) that the page has been modified. The only way to prevent this from happening is to make sure that the way you "import" the blog posts into the new Wiki preserves the file timestamps (Linux: ''cp -a''). --- //[[chi@chimeric.de|Michael Klier]] 2008/10/10 17:22// >>> Thank you for your quick reply. Wow I learned a lot about DokuWiki internals the last two nights :-) Ok, where I am heading to: I would be willing to write a detailed "HowTo import blog posts". But as it seems an import is only possible if you sort your posts by date **last changed**. Even ''cp -p'' (in bash) **does not preserve the date created**, since there is no such thing as date created under Linux. PHP's function ''filectime'' only asks for the time the file's inode was last changed. >>> >>> Lets dig into the details and have a look at the code. (Please correct me if anything is wrong here. All code is from the most current version of >>> DokuWiki. Don't worry I'll soon refactor all this into an easy to read HowTo.) >>> >>> You copy you blog post into you new DokuWiki: ''cp -p /data/pages/mypost.txt /data/pages/'' >>> >>> Once you actually view one of your blog posts in your browser, the indexer creates some additional files: >>> * ''data/meta/mypost.indexed'' and >>> * ''data/mega/mypost.meta'' >>> The meta index **DOES NOT** contain any date information. The ''lib/exe/indexer.php'' (lines 218) tries to extract some ''$info'' from the ''change.log''. Which of course does not exist for the newly copied page, yet. As a consequece (line 226) no date can be written to the ''mypost.meta''. >>> >>> ''lib/exe/indexer.php'': >>> >>> // gather some additional info from changelog >>> $info = io_grep($conf['changelog'], >>> '/^(\d+)\t(\d+\.\d+\.\d+\.\d+)\t'.preg_quote($ID,'/').'\t([^\t]+)\t([^\t\n]+)/', >>> 0,true); >>> >>> $meta = array(); >>> if(!empty($info)){ ... } # $info array will be empty for new files (=imported blog posts) >>> >>> >>> When you look at your blog overview page the blog plugin >>> * first tries to get the date last modified from the meta information (''plugin/blog/helper.php'' line 88) >>> * since that fails, it gets the date last modified via the PHP function filectime() >>> >>> ''plugin/blog/helper.php'': >>> >>> $date = $meta['date']['created']; >>> if (!$date) $date = filectime(wikiFN($id)); >>> >>> >>> PHP manual about filectime: >>> Note also that in some Unix texts the ctime of a file is referred to as being the creation time of the file. This is wrong. There is no creation time for Unix files in most Unix filesystems. >>> >>> To conclude: The blog plugin does the best it can to get the correct date created. But in the end this is not possible cause of limitations from the underlying filesystem. >>> >>> => Could I write a script that manually **sets** the metadata of my blog posts to a date I want. (When the metadata exists, it would be used by the blog plugin? >>> >>> => I am happy about any comments and/or corrections. As I said don't worry, I'll soon refactor all this. To all the DokuWiki developers: Keep up the good work! [[wiki@doogie.de|Robert]] >>>> I've exactly got the same problem. Currently, i'm using the blog plugin version linked at the top of this page (the 2008-07-18 version). There is more this problem ... but ... i've got an other problem with it !! In the title, there a link on the post. It's very ugly! How can I remove the link ?? --- //[[apef@no-log.org|Arnaud Fouquaut]] 2008/10/29 00:30// ==== {{blog>namespace}} does not work with namespace label in non-ascii chars ==== I fixed helper.php as follows using global function ''idfilter()''. Could you merge in next release? Index: helper.php =================================================================== @@ -60,7 +60,8 @@ $pages = array(); $unique_keys_memoize = array(); - $dir = str_replace(':', '/', $ns); + //$dir = str_replace(':', '/', $ns); + $dir = idfilter($ns); search($pages, $conf['datadir'], 'search_pagename', array('query' => '.txt'), $dir); foreach ($pages as $page) { --- //[[kumion@gmail.com|EGUCHI Takashi]] 2008-12-30// > Please use the bug tracker linked on this page. --- //[[chi@chimeric.de|Michael Klier]] 2008/12/30 14:08// ====== Help required ====== Hello I need to know where the blog plugin saves the data of the content. I have troubles restoring because in the file under the blog directory there is only the Entry ~~DISCUSSION~~ Hi, I would like to know if there's a way to limit the number of pages shown with the archive> ? [[mailto:simaobelchior@gmail.com|Simão Belchior de Castro]] 2008/12/03 15:35//