# Wikibooks Stacks/History

Here is a sketch of how the Wikibooks stacks evolved to their current form.

## Bookshelves

The first overall catalog of books was a set of pages called bookshelves, which was started within months of the founding of Wikibooks in 2003. The bookshelves were manually maintained pages containing, mostly, lists of books. The overall organization of the collection of bookshelves was originally a page called All bookshelves, moved to project space in 2005 (thus, Wikibooks:All bookshelves). In 2006, the bookshelves were grouped into departments, and the top-level page renamed to Wikibooks:Departments. As Wikibooks, like its wikimedian sisters, is a mostly-decentralized volunteer project, a manually maintained central catalog tends to be incomplete and out-of-date, problems that were being discussed by the community by 2006.

## Subjects

See also: Subject:Books by subject
The subject namespace was activated in late August 2007, and the subject hierarchy gradually supplanted the old bookshelves. Each book main page would have a {{subjects}} template call, whose arguments would be the narrowest subjects —by recommendation, usually just one or two— to which the book belonged. The subject pages themselves used dynamic page lists (DPLs), a wiki platform extension for dynamically generating lists of pages belonging to an intersection of categories, which had been developed in 2005 for Wikinews (where listing articles meeting various criteria is a ubiquitous need). This distributed the per-book maintenance burden to the individual books, making it part of each book main page where it would be noticed and undertaken by users interested in those particular books, rather than depending on an ever-increasing cadre of contributors interested in doing centralized curation; what little manual effort remained for routine maintenance of the subject hierarchy would be proportional to the number of subjects, not to the number of books.

### Allbooks

The bookshelves fell increasingly into disuse, and there was talk of deprecating them in favor of the subject pages; however, a continuing concern with the subject hierarchy was that when a book was filed under a narrow subject, it would not be listed on the subject pages of larger subjects to which the narrow subject belonged. This was fixed in late 2011 with the implementation of the "all books" categories, which were automatically populated by the {{subjects}} template calls already in place. In that arrangement, when a subject page was transcluded from outside subject space, it would respond with a list of its one or two parents, thus enabling other pages — especially, allbooks category pages and book main pages — to determine the ancestry. The {{subjects}} template on a book main page could therefore deduce, given a narrow subject to be explicitly listed at the bottom of the book main page, what all the ancestors of that subject were.
Along with the implementation of the allbooks categories, a primitive form of semi-automation was provided to help human operators maintain the system. Each of the various interlocking pages would have, contained within its standard formatting templates, integrity checks of the adjoining pages in the system, and when something didn't look right, the page would display a diagnostic message, offer one or more "buttons" to initiate various edit actions that a human operator might wish to use to fix the problem, and categorize itself in Category:Attention needed (allbooks).
Some flaws of the subject hierarchy, at that point, were that
* however useful and elegantly laid out the subject pages might be, if you went to the bottom of a book main page, the links you would be provided there by the wiki platform, though called "Subjects", would be to the associated subject categories, not to the subject pages themselves, and the subject category pages had no such useful, elegantly laid out displays of information.
* there continued to be confusion over the difference between book categories and subject categories.
* if a book was filed in a top-level subject, the book didn't get listed anywhere. The top-level subject pages used a different template, {{root subject}} rather than {{subject page}}, allowing for the fact that those subjects have no specified parents and that the number of books in those subjects is likely too large to usefully list them all. Authors were told not to list books in root subjects, but this wasn't enforced by the semi-automation, and it wasn't at all clear that it should be enforced, because sometimes it was hard to know where else to put them.
* internally, the {{subjects}} template used an awkward technique to do a deep search for ancestors of a listed subject — parents of parents of parents, etc. The wiki platform carefully rations any computational power provided to wiki markup, in order to prevent both accidents and malicious damage (including, of course, deliberate generation of server load as a denial-of-service attack). Part of this is that templates cannot call themselves; and another is that the total depth of nested template calls is limited. {{subjects}} used a series of subtemplates; /0 would find the parents and, for each parent, would call /1, which would do the same and call /2, etc; if one of these templates found that it needed to go deeper, but the next template in the series didn't exist yet, it would flag itself for human operator intervention. In reality, though, this would come up against the platform-imposed bound on depth of nested template calls.

## Stacks

In 2016, an overhaul was proposed to the Wikibooks category infrastructure, intended ultimately to allow Wikibooks to have topical categories for pages as well as for books; particularly, to provide suitable targets for incoming topical links from sister projects. As these page-inclusive topical categories would be a third major set of categories distinct from the book categories and subject categories, and even just the two kinds of categories were already a cause of some confusion, the overhaul began by renaming the subject categories by adding prefix Subject: — thus, Category:Subject:Mathematics, etc. — and renaming the book categories by adding prefix Book:. In the process, the subject pages and subject categories were also modified to allow the categories to request transclusion of the full display from the subject page; thus, when a reader would go to the bottom of a book main page and click on the link that says Subject:Mathematics, they would be immediately presented with the full display from the subject page, even though they would still be looking at the subject category.
Once the subject categories and book categories had been renamed, however, there was a terminology problem with the intended new set of page-inclusive topical categories. A prefix was evidently wanted whose meaning would be instantly clear in contrast with Book: and Subject:, but Subject: is already a rather ambiguous prefix and could apply at least as well to the new categories as to the existing ones. A first step undertaken toward resolving this terminology problem was to replace prefix Subject:, in all its contexts, with prefix Shelf:. The top-level subjects being too large to plausibly call "shelves", the prefix Department: was chosen for them, recalling the organization of bookshelves from 2006.
Grouping the new-style departments and shelves, together with all their associated machinery, into a book makes it all much easier to coordinate, as Wikibooks infrastructure has evolved particularly to facilitate managing the constellation of pages associated with a book.
Giving the top-level groupings a different prefix, Department: rather than Shelf:, makes it easy to prevent books from being filed directly in departments. Template {{shelves}}, replacing {{subjects}}, simply makes it syntactically impossible to request filing in a department: the parameters name shelves, with the prefix omitted. When a shelf has the same name as a department, it is assumed by default to be a "reserved" shelf, and lists only books filed directly under that shelf name, e.g. Shelf:Mathematics; this can be overridden by specifying, at the same-named department, that the same-named shelf isn't reserved.
Just as the subject hierarchy took advantage of a facility — DPLs — that hadn't existed yet when the original bookshelves system was set up, the Wikibooks stacks exploit template {{evalx}} and module:TScope, which were designed (at Wikinews) to nurture wiki-markup-based customization by covering large classes of corner cases. Amongst other things, these tools allow each shelf category to maintain a list of all its ancestors, so that {{shelves}} doesn't have to do a deeply nested query to try to assemble this list. Each shelf compares its own list of ancestors to the ancestor lists of its parents, thus detecting when these lists need to be updated and signalling for intervention by a human operator (a technique imagined, but not yet technically feasible, when the allbooks system was set up in 2011); a (hopefully) viable strategy since the shelving hierarchy is expected to change only very slowly over time.
More convenient semi-automation, by means of dialog, is contemplated, and could in future greatly facilitate human maintenance of the system. ({{evalx}} and TScope were designed as peripheral support for the dialog tools.)

## References

* ↑ For these dates, see Meta:Wikibooks, the revision history of Wikibooks:Departments, and Wikibooks:Bookshelves/Generation 2.
* ↑ Wikibooks:Reading room/Technical Assitance, August 31, 2007.
* ↑ Wikibooks:Reading room/Proposals/2011/December#Category closures
* ↑ The default tag, "Category"/"Categories", can be overridden at page MediaWiki:Pagecategories; this was done on October 30, 2007, and default restored on June 7, 2019.
* ↑ Wikibooks:Reading room/Proposals/2017/July#Category infrastructure (note the thread was started in June 2016).