Chapter 15: Creating New Categories

INFOMINE currently has 10 top-level categories, which are accessible from the Public homepage, and can can be used to filter canned search queries. Some of the category data is hard-coded in the iVia source and some is stored in easily-modified configuration files.

Simple changes to existing categories are quite straightforward. The default category search and advanced search pages are generated from the template file in $HOME/iVia/data/html_templates/$THEME/search/search.html. This file can be edited as described in Chapter 14: Appearance and Web Pages.

Much of the Category data, including the keywords, featured_resources lists, libraries_and_databases lists, overview, and contact information are stored in $HOME/iVia/etc/categories.conf and can be edited directly.

The basic category definitions, including the category names, abbreviation and colors, are hard-coded into the iVia library in the file $HOME/iVia/src/libs/iVia/src/CategorySet.cc. You can change the Category names and colors by altering this file and recompiling the library.

Creating new categories

To change the categories themselves (or their abbreviations) you must update the definitions in $HOME/iVia/src/libs/iVia/include/WordInfo.h and $HOME/iVia/src/libs/iVia/src/CategorySet.cc, and then recompile the source code.

For example, suppose you want to add an "Engineering" category. First go to WordInfo.h and look in the struct WordInfo declaration where the Category Masks are defined and add a new mask similar to this one:

 static const unsigned ENGINEERING = 1u << 28u;

This defines the 28th bit of the WordInfo mask as including a record in the Engineering category. You will also need to update the CATEGORIES constant as follows:

 static const unsigned CATEGORIES = BIOAG | GOVPUB | K12 |
 UNIV | ENABLE | MAPS | PHYSCI | EJOURNAL | LIBERAL | ARTS
 | BUSECON | CULTURE | ENGINEERING ;

Next go to the CategorySet.cc file and update the CategoryData struct with the Engineering category definition, by adding the following line:

 { WordInfo::ENGINEERING, "engineering", "#0000DD",
   "Engineering", "The New Engineering Category" },

This line tells iVia that the category identified by the WordInfo::ENGINEERING bit is referred to internally as engineering, has the color 0000DD, has the short title Engineering, and the long title The New Engineering Category.

Finally, the WordInfo.cc file must be updated. A new constant declaration must be added in the block of declarations at the top of the file:

 const unsigned WordInfo::ENGINEERING;

You must then recompile the system; go to the $HOME/iVia directory and run the commands make clean and make install.

Once this is complete you will need to add an engineering section to the $HOME/iVia/etc/categories.conf file, to update the main page to include a link to /cgi-bin/search?category=engineering, and to update the search box templates to include a check box for the new category.