.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Wiki::Toolkit::Plugin::Categoriser 3pm" .TH Wiki::Toolkit::Plugin::Categoriser 3pm "2020-11-29" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Wiki::Toolkit::Plugin::Categoriser \- Category management for Wiki::Toolkit. .SH "DESCRIPTION" .IX Header "DESCRIPTION" Uses node metadata to build a model of how nodes are related to each other in terms of categories. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Wiki::Toolkit; \& use Wiki::Toolkit::Plugin::Categoriser; \& \& my $wiki = Wiki::Toolkit\->new( ... ); \& $wiki\->write_node( "Red Lion", "nice beer", $checksum, \& { category => [ "Pubs", "Pub Food" ] } \& ) or die "Can\*(Aqt write node"; \& $wiki\->write_node( "Holborn Station", "busy at peak times", $checksum, \& { category => "Tube Station" } \& ) or die "Can\*(Aqt write node"; \& \& my $categoriser = Wiki::Toolkit::Plugin::Categoriser\->new; \& $wiki\->register_plugin( plugin => $categoriser ); \& \& my $isa_pub = $categoriser\->in_category( category => "Pubs", \& node => "Red Lion" ); \& my @categories = $categoriser\->categories( node => "Holborn Station" ); .Ve .SH "METHODS" .IX Header "METHODS" .IP "\fBnew\fR" 4 .IX Item "new" .Vb 2 \& my $categoriser = Wiki::Toolkit::Plugin::Categoriser\->new; \& $wiki\->register_plugin( plugin => $categoriser ); .Ve .IP "\fBin_category\fR" 4 .IX Item "in_category" .Vb 2 \& my $isa_pub = $categoriser\->in_category( category => "Pubs", \& node => "Red Lion" ); .Ve .Sp Returns true if the node is in the category, and false otherwise. Note that this is \fBcase-insensitive\fR, so \f(CW\*(C`Pubs\*(C'\fR is the same category as \&\f(CW\*(C`pubs\*(C'\fR. I might do something to make it plural-insensitive at some point too. .IP "\fBsubcategories\fR" 4 .IX Item "subcategories" .Vb 5 \& $wiki\->write_node( "Category Pub Food", "mmm food", $checksum, \& { category => [ "Pubs", "Food", "Category" ] } \& ) or die "Can\*(Aqt write node"; \& my @subcats = $categoriser\->subcategories( category => "Pubs" ); \& # will return ( "Pub Food" ) \& \& # Or if you prefer CamelCase node names: \& $wiki\->write_node( "CategoryPubFood", "mmm food", $checksum, \& { category => [ "Pubs", "Food", "Category" ] } \& ) or die "Can\*(Aqt write node"; \& my @subcats = $categoriser\->subcategories( category => "Pubs" ); \& # will return ( "PubFood" ) .Ve .Sp To add a subcategory \f(CW\*(C`Foo\*(C'\fR to a given category \f(CW\*(C`Bar\*(C'\fR, write a node called any one of \f(CW\*(C`Foo\*(C'\fR, \f(CW\*(C`Category Foo\*(C'\fR, or \f(CW\*(C`CategoryFoo\*(C'\fR with metadata indicating that it's in categories \f(CW\*(C`Bar\*(C'\fR and \f(CW\*(C`Category\*(C'\fR. .Sp Yes, this pays specific attention to the Wiki convention of defining categories by prefacing the category name with \f(CW\*(C`Category\*(C'\fR and creating a node by that name. If different behaviour is required we should probably implement it using an optional argument in the constructor. .IP "\fBcategories\fR" 4 .IX Item "categories" .Vb 1 \& my @cats = $categoriser\->categories( node => "Holborn Station" ); .Ve .Sp Returns an array of category names in no particular order. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "\(bu" 4 Wiki::Toolkit .IP "\(bu" 4 Wiki::Toolkit::Plugin .SH "AUTHOR" .IX Header "AUTHOR" Kake Pugh (kake@earth.li). The Wiki::Toolkit team (http://www.wiki\-toolkit.org/) .SH "COPYRIGHT" .IX Header "COPYRIGHT" .Vb 2 \& Copyright (C) 2003\-4 Kake Pugh. All Rights Reserved. \& Copyright (C) 2006\-2009 the Wiki::Toolkit team. All Rights Reserved. .Ve .PP This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.