Skip to content
Permalink
Browse files

Initial version, should work as described (includes test cases)

  • Loading branch information...
michitux committed Feb 11, 2013
0 parents commit bcad0affe4db81a34e1ebcacd455ea19e8731a05
Showing with 137 additions and 0 deletions.
  1. +27 −0 README
  2. +32 −0 _test/indextitleonly.test.php
  3. +37 −0 action.php
  4. +8 −0 conf/default.php
  5. +10 −0 conf/metadata.php
  6. +8 −0 lang/de/settings.php
  7. +8 −0 lang/en/settings.php
  8. +7 −0 plugin.info.txt
27 README
@@ -0,0 +1,27 @@
indextitleonly Plugin for DokuWiki

Allows to specify a namespace in which only the page title is indexed

All documentation for this plugin can be found at
https://www.dokuwiki.org/plugin:indextitleonly

If you install this plugin manually, make sure it is installed in
lib/plugins/indextitleonly/ - if the folder is called different it
will not work!

Please refer to http://www.dokuwiki.org/plugins for additional info
on how to install plugins in DokuWiki.

----
Copyright (C) Michael Hamann <michael@content-space.de>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

See the COPYING file in your DokuWiki folder for details
@@ -0,0 +1,32 @@
<?php
/**
* Test the indextitleonly plugin
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Michael Hamann <michael@content-space.de>
*/
class plugin_indextitleonly_test extends DokuWikiTest {
public function setup() {
global $conf;
$this->pluginsEnabled[] = 'indextitleonly';
parent::setup();
$conf['plugin']['indextitleonly']['namespace'] = 'titleonly';
saveWikiText('titleonly:sub:test', "====== Title ====== \n content", 'created');
saveWikiText('test', "====== Title ====== \n content", 'created');
idx_addPage('titleonly:sub:test');
idx_addPage('test');
}
public function test_title_returns_both() {
$query = array('title');
$this->assertEquals(array('title' => array('test' => 1, 'titleonly:sub:test' => 1)), idx_get_indexer()->lookup($query));
}
public function test_content_doesnt_return_excluded() {
$query = array('content');
$this->assertEquals(array('content' => array('test' => 1)), idx_get_indexer()->lookup($query));
}
}
@@ -0,0 +1,37 @@
<?php
/**
* DokuWiki Plugin indextitleonly (Action Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Michael Hamann <michael@content-space.de>
*/
// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();
if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once DOKU_PLUGIN.'action.php';
class action_plugin_indextitleonly extends DokuWiki_Action_Plugin {
public function register(Doku_Event_Handler &$controller) {
$controller->register_hook('INDEXER_PAGE_ADD', 'BEFORE', $this, 'handle_indexer_page_add');
$controller->register_hook('INDEXER_VERSION_GET', 'BEFORE', $this, 'handle_indexer_version_get');
}
public function handle_indexer_page_add(Doku_Event &$event, $param) {
if (strpos(getNS($event->data['page']).':', $this->getConf('namespace')) === 0) {
$event->data['body'] = $event->data['metadata']['title'];
$event->preventDefault();
}
}
public function handle_indexer_version_get(Doku_Event &$event, $param) {
$event->data['indextitleonly'] = 1;
}
}
// vim:ts=4:sw=4:et:
@@ -0,0 +1,8 @@
<?php
/**
* Default settings for the indextitleonly plugin
*
* @author Michael Hamann <michael@content-space.de>
*/
$conf['namespace'] = '!!notset!!';
@@ -0,0 +1,10 @@
<?php
/**
* Options for the indextitleonly plugin
*
* @author Michael Hamann <michael@content-space.de>
*/
$meta['namespace'] = array('string');
@@ -0,0 +1,8 @@
<?php
/**
* English language file
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Michael Hamann <michael@content-space.de>
*/
$lang['namespace'] = 'Der Namensraum, in dem nur Titel indexiert werden sollen';
@@ -0,0 +1,8 @@
<?php
/**
* English language file
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Michael Hamann <michael@content-space.de>
*/
$lang['namespace'] = 'The namespace, in which only the title shall be indexed';
@@ -0,0 +1,7 @@
base indextitleonly
author Michael Hamann
email michael@content-space.de
date 2013-02-11
name indextitleonly plugin
desc Allows to specify a namespace in which only the page title is indexed
url https://www.dokuwiki.org/plugin:indextitleonly

0 comments on commit bcad0af

Please sign in to comment.
You can’t perform that action at this time.