Facetator: Configuration
The following files are involved with Facetator:
- entries.json: the
data to be presented.
- entries.jgz: the compressed version of entries.json (optional)
- index.html:
configures a view on the data, contains the following
things to configure.
- facetator.js: the
Facetator implementation
1. Data
{ "items": [ {"key1":"value1",
"key2":"value2", ...}, ... ] }
- <key>: as
facet value. { author: "Wörner, Michael" }
- <key>_entry:
in entries. { author_entry: "Michael
Wörner" }
- <key>_sort:
for sorting facet values. { author_sort:
"woerner michael" }
- sorting entries is handled by facet.sortKeys
2. Global settings
var facet = { localFileName,
remoteFileName, sortKeys, sortFunction, definitions, pageSize }
- localFileName: the data file to use with a “file:” URL. Must be
uncompressed. Example: entries.json
- remoteFileName: the data file to use with any other URL. Can be
compressed. Example: entries.jgz
- sortKeys: how to sort entries, an array of keys, each one
prefixed with a plus (sort ascendingly) or a minus (sort descendingly)
- Example: ["-year",
"+firstAuthor", "+title"]
- sortFunction: overrides the sortKeys, a function that has two
entries as arguments and returns -1,0,+1 like in array sorting.
- definitions: the facet definitions (explained below)
- pageSize: how many entries fit on a page?
2.1. GZIP compression
- For GZIP compression to work with a browser, a file must be
served with the content type text/javascript
and the encoding gzip.
- Configuring Apache: Just use the included htaccess file in your
directory (you have to prepend a dot for it to work). Now .jgz files
are served correctly.
- "file:" URLs cannot do gzipping, which is why Facetator has
separate settings for this kind of URL.
3. Facet definitions
{ key, label, strictSummaryLabel,
values }
- key: the key of the facet inside each entry
- label: the text above the facet box
- strictSummaryLabel: if specified, there is a checkbox underneath
to choose between “strict summary” (=what is related to the current
selection, for example all co-authors) and “all alternatives”
(everything that is allowed by the other facet boxes).
- values: specify fixed values for the facet boxes, an array of
value specifications
- value specification: { display, sort, restriction,
dontAddValuesFromEntries }
- restriction: use '|' for intervals. Example: "1990|1999"
- dontAddValuesFromEntries: don't sort facet box values, don't
add value from entries, keep the value specifications in the order
given.
- a string (instead of an object) is used for display, sort,
and restriction.
- display is mandatory and used if sort or restriction are
missing.
4. Entry presentation
There is a template for the entries in index.html that is cloned and
filled in as necessary.
- <span>$__index__</span>:
a running index (1 for the 1st entry etc.)
- <span>$key</span>:
insert the value from the entry
- <span
facetLinks="true">$key</span>: displays a single value
or a list of values as links that perform a selection in the facet box.
- Attribute ifExists="key"
(in any tag): only show the tag if the entry has a value for the given
key.
- Attribute ifNotExists="key"
(in any tag): only show the tag if the entry doesn't have a value for
the given key.
- <a class="toggle"
state="collapsed">: a link toggling the visibility of the
content inside the following <div>.
- state: "collapsed"
or "expanded"
- <a href="$key">:
the link target is taken from the entry.