DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:nssearch

This is an old revision of the document!


nssearch Plugin

Compatible with DokuWiki

Angua, Rincewind, Weatherwax

plugin Limit searches to within a namespace

Last updated on
2012-12-05
Provides
Action

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to appendtoquery, selectsearch

Tagged with namespace, search

This plugin lets you limit searches to the current namespace. Configuration options let you do this for specific namespaces, for all namespaces, or for all base namespaces.

Combined with the loadskin plugin, the right edit permissions, and an empty root namespace, this plugin can make your wiki act like it's several different wikis.

Installation

Install the plugin using the Plugin Manager and the download URL above, which points to latest version of the plugin. Refer to Plugins on how to install plugins manually.

Upgrade Note

The latest version is hosted on a new server. You will not be able to use the “update” button on your plugins page.

Configuration and Settings

There is only one configuration setting, which is a semicolon-delimited list of namespaces. Any search done in these namespaces will be limited to results from the given namespace.

Example: myns;myns:sub

In this case, searches from within myns:sub or myns:sub:whatever will only return results from myns:sub and its sub-namespaces. Searches from within myns or myns:sub2 will return results from within myns.

Special value: @all

If you use this value, searches will be limited in all namespaces to the current namespace. Searches in myns will be limited to myns. Searches in myns:sub will be limited to myns:sub. Searches in myns:sub:sub2:sub3:sub4:sub5 will be limited to results from myns:sub:sub2:sub3:sub4:sub5. You get the idea.

Special value: @base

If you use this value, searches will be limited to base namespaces. Searches in myns or myns:sub or myns:sub:sub2:sub3 will all return results from myns.

Special value: @depth[n]

If you use this value, searches will be limited to a depth of [n]. For example, using @depth1, searches in myns:sub:sub2 will be limited to results from myns:sub. @depth0 is equivalent to @base.

Limitations

There's no simple way to determine which page you came from while searching, so this plugin uses the last breadcumb to make a good guess. However, if you leave a window open for a long time (several days), the breadcrumb list vanishes. If you then do a search from that old page, the namespace limitations will be ignored, and you'll get results from everywhere.

Development

Changelog

  • 2012-12-05
    • Added @depth feature, from an anonymous feature request.
  • 2011-08-18
    • Fixed bug where, if you let the breadcrumb list expire, a search would give no results.
  • 2011-08-01
    • Initial release.

Discussion

Exclude Namespaces

Would it be easy to support an option that *excludes* certain namespaces from search results?

eg: '@all;-:private' (exclude anything from the root namespace ':private') '@all;-private' (exclude anything from a namespace named 'private' under the current namespace)

2011-11-11 m [dot] mccarn [at] aicr [dot] org

Here's what I think you're asking for: Search works in the normal DokuWiki way, but no results will come back from certain namespaces. Is that right? It shouldn't be too hard to implement that. I'll think about it.
You can already do what you want to some extent with a normal DokuWiki installation – just limit access to the :private namespace to certain groups. Other groups won't see search results from that namespace. Also, if you use this plugin as designed, you can use the “@base” setting to limit searches to the current namespace. So you could only search in :private if you were currently looking at a page in :private.
Or you might be asking for this: Limit searches to within the current namespace, but if you're in :private, you won't get any search results at all.

Have a look at these variables: - restrictionNS - restrictionType

here: plugin:purplenumbers#configuration

should be standard IMO. . .


So what I think you're asking for is this: Restrict search in some namespaces, and don't restrict search in others. For example, when you're in ns1, search results only come back for ns1, but when you're in ns2, you can get results from either ns1 or ns2 (or anywhere else). I'll think about implementing that feature, but it will result in behavior that will confuse some users. Maybe this would be better (but more complicated):

  • Namespaces: ns1, ns2, ns3, ns4
  • Restrictions: @base, -ns3, -ns4
  • Search in ns1: Results are only from ns1.
  • Search in ns2: Results are only from ns2.
  • Search in ns3: Results are from ns3 and ns4, but not from ns1 or ns2.
  • Summary: In addition to only seeing results from the current namespace, you can't get results from a restricted namespace when you're in any other namespace.

Sound good?

Restrict According to Namespace Depth

Feature complete. See @depth, above. (full feature request removed to keep the page clean).

Hey Eli, I really appreciate your implementing my feature request. It works exactly as you described, but slightly different than I envisioned for our use. I was looking for a solution that returns hits from within the current [n]-level directory and deeper. If I understand correctly, your solution returns hits from within the X-level directory and deeper. The difference is the current.

Put differently, could the code start by grabbing the current directory, then limiting search results to a certain folder depth within that current directory?

Example: If I'm here

:en:cars:ford:

And I make a search for “ford”, I'd want to see results from these folders:

:en:cars:ford:
:en:cars:ford:interior:
:en:cars:ford:exterior:
:en:cars:ford:maintenance:
:en:cars:ford:maintenance:scheduled:

But not:
:en:cars:toyota:interior:
:en:cars:toyota:maintenance:scheduled:
:en:cars:
:fr:cars:ford:interior:

Big time thanks !

csutton

Restrict Search for Current Language

Feature request. I have two main namespaces for English and Italian languages each namespace contains sub-namespaces.

For example:
:en:timeline:audio
:en:main-window
:it:project-options

How to restrict search within /it or /en namespace? English readers should find only English articles when they start search from any English sub-namespace. I don't know a depth of search, because users can run search from any embedded namespace.

Thanks in advance!

Igor Kokarev

Answer

zioth: You're describing the way this plugin works. Just set the config parameter to en;it. If you do that, any user inside of en will only search English pages, and any user inside it will only search Italian pages. This works because you've decided to put the language as the first piece of the namespace. If your structure were different (main-window:en, main-window:it), this plugin wouldn't support that.

Did I understand your question correctly?

Reply

/Igor Kokarev/ Thanks for your answer! Yes, I tried to set en;it but search always works in both namespaces - English and Italian.

You can try in my Dokuwiki: docs.picturestoexe.com/en/main

For example, I run search from docs.picturestoexe.com/en/main but I see results from docs.picturestoexe.com/it/…

P.S. I also tried selectsearch plug-in and it worked correctly.

Reply

zioth: Strange. I wonder if my plugin doesn't work right with the latest dokuwiki version. Does @base work?

Reply (Igor Kokarev)

No, @base also doesn't work.
I use the latest Dokuwiki “Binky”.

Reply

zioth: Sorry. I don't have time to upgrade to Binky right now. I will eventually, and then I can post an update to this plugin.

Reply (Igor Kokarev)

I just installed a new copy of “Binky” in a new folder. Search works correctly within current namespace with nssearch. It seems that my main dokuwiki has some conflict in options.

plugin/nssearch.1395338337.txt.gz · Last modified: 2014-03-20 18:58 by Aleksandr

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki