Wiki::...oriser(3pm)

✨ NAME ✨

Wiki::Toolkit::Plugin::Categoriser β€” it's the category management plugin for Wiki::Toolkit, bestie πŸ’– (the manual page itself is filed under Wiki::...oriser(3pm), iconic name, no notes)


🌸 DESCRIPTION 🌸

Okay so here's the vibe: this plugin takes your node metadata and uses it to build a whole little model of how your nodes are related to each other β€” but, like, specifically in terms of categories. That's it. That's the whole job. And it does it slayfully πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

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't write node";
$wiki->write_node( "Holborn Station", "busy at peak times", $checksum,
                   { category => "Tube Station" }
                 ) or die "Can't 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" );

πŸ‘‘ METHODS πŸ‘‘

🌟 new

my $categoriser = Wiki::Toolkit::Plugin::Categoriser->new;
$wiki->register_plugin( plugin => $categoriser );

Make a fresh categoriser, then register it with your wiki. That's the whole step. Periodt. ✨


🌟 in_category

my $isa_pub = $categoriser->in_category( category => "Pubs",
                                         node     => "Red Lion" );

Returns true if the node is in the category, and false otherwise 🫢

Heads up bestie: this is case-insensitive, so "Pubs" is literally the same category as "pubs". And the author says β€” and I quote the vibe β€” they might do something to make it plural-insensitive at some point too. So "Pubs" vs "Pub"? Not yet, babes. Not yet. 😭

🌟 subcategories

$wiki->write_node( "Category Pub Food", "mmm food", $checksum,
                   { category => [ "Pubs", "Food", "Category" ] }
                 ) or die "Can't 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't write node";
my @subcats = $categoriser->subcategories( category => "Pubs" );
# will return ( "PubFood" )

So the way this works: to add a subcategory "Foo" to a given category "Bar", you write a node called any one of "Foo", "Category Foo", or "CategoryFoo" β€” and you give it metadata saying it's in the categories "Bar" and "Category". Three naming options, one girlboss move πŸ’…

And yes, it's paying specific attention to the Wiki convention of defining categories by prefacing the category name with "Category" and creating a node by that name. That's the rule it's living by. If you need different behaviour, the note is that we should probably implement it using an optional argument in the constructor. So like… noted πŸ“


🌟 categories

my @cats = $categoriser->categories( node => "Holborn Station" );

Returns an array of category names β€” in no particular order, so don't come for the ordering, it's not that kind of function πŸ™ˆ


πŸ¦‹ SEE ALSO πŸ¦‹

  • Wiki::Toolkit
  • Wiki::Toolkit::Plugin

πŸ’œ AUTHOR πŸ’œ

Kake Pugh (kake@earth.li). The Wiki::Toolkit team (http://www.wiki-toolkit.org/) πŸ‘‘


Copyright (C) 2003-4 Kake Pugh.  All Rights Reserved.
Copyright (C) 2006-2009 the Wiki::Toolkit team. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. So go off, but respectfully 🫢


Okay and that's the whole page bestie β€” this beauty ships as part of perl v5.32.0 and the docs were dated 2020-11-29. Catch you in the next manpage, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from