Skip to content

Commit 2fb9203

Browse files
committed
link to live examples
1 parent f457fc7 commit 2fb9203

File tree

3 files changed

+5
-115
lines changed

3 files changed

+5
-115
lines changed

README.md

Lines changed: 1 addition & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,8 @@
11
# Zotero-JavaScript-Search-Client
22
Example HTML, CSS, and JavaScript for searching for items within a public Zotero user or group library
33

4-
[See a live demo at RawGit](https://cdn.rawgit.com/twhiteaker/Zotero-JavaScript-Search-Client/2297dc82/zotero.html)
5-
64
## Motivation
75

86
To help users discover your publications, you can add them to an online database like Zotero and then present a search interface to that database on your website. Modules for doing so have been written for WordPress and Drupal, but I hadn't seen one for static HTML sites, so I wrote this example to test how feasible a static HTML Zotero client would be to implement.
97

10-
## Usage
11-
12-
Open the zotero.html file in your browser and enter a search term like
13-
`coastal`. Click the search button and see results as formatted by Zotero to the page.
14-
15-
You can click Search with no terms specified to show the entire catalog, which is the default behavior when you load the page.
16-
17-
Zotero limits the number of results returned in a single request, so the page supports pagination to get additional results.
18-
19-
To use this for your own project, you will need a free Zotero account into which you include your publications, and obviously you'll need to adapt the HTML, CSS, etc., for your particular website.
20-
21-
## Customization
22-
23-
The code finds elements via their HTML id attribute values, so in general you'll
24-
want to start with one of the example HTML documents and adapt it to your needs.
25-
26-
To change parameters such as how many search results to show at a time, see the
27-
`ZOTERO_CONFIG` variable in `zotero.js`. See comments in the code for a brief
28-
explanation and example values, or the text below for additional details.
29-
30-
### What To Search
31-
32-
You can search a user library, a group, or a collection within a user library or
33-
group.
34-
35-
* `zotId` - The user or group identifier. You can find your group identifier by
36-
browsing to your group page and copying the number in the URL. To find your
37-
user identifier, click **Settings**, and then click **Feeds/API**.
38-
* `zotIdType` - Indicates whether `zotId` is for a `group` or a `user`.
39-
* `collectionKey` - Supply a value for this if you want to limit search to a
40-
particular collection. Otherwise leave it as an empty string, "". You can
41-
find your collection identifier by browsing to the collection's page and copying the
42-
collection key from the URL.
43-
* `filterTags` - Use this to restrict results to items matching this tag filter,
44-
or leave the value as an emptry string, "", if no tag filtering is desired.
45-
Since the Zotero API supports several ways of writing a tag filter, the entire tag parameter including the preceeding ampersand is required for
46-
this value, as in `&tag=FeaturedArticle`. See the [API
47-
documentation](https://www.zotero.org/support/dev/web_api/v3/basics) for
48-
examples.
49-
50-
### Results Table
51-
52-
Results are displayed in a table with up to four columns: `Year`, `Citation`,
53-
`Item Type`, and a special column (we'll refer to it as `ShowTags`) showing the
54-
presence of particular tags.
55-
56-
* `resultsElementId` - The id of the HTML element to contain the results table.
57-
This element must already exist in your HTML document.
58-
* `includeCols` - Array of column names to include in the output table, other than
59-
`Citation` which is always included. The full set is `Year`, `Type`, and
60-
`ShowTags`. If you leave a column name out in this array, then it will not
61-
appear in the result table. If you leave all columns out (i.e., the array is
62-
empty), then only the citations are shown, and no column header is shown.
63-
* `showTags`: Array of tags to show, if present, for each result item. Use this
64-
to categorize your items if Zotero doesn't support the categories you need out
65-
of the box. For example, you could tag your items based on their relationship
66-
to your LTER site, indicating whether the item is a foundational paper for the
67-
site (`Fondational`), was funded by the site (`LTER-Funded`), or was written by someone outside of your site
68-
who used your site's data (`LTER-Enabled`). If an item has one of the tags
69-
you specify, the tag will be shown in the `ShowTags` column. Obviously, if you
70-
want to use this functionality, make sure the text `ShowTags` is included in
71-
`includeCols`.
72-
* `showTagColName` - The name to be used for the `ShowTags` column in the
73-
results table, since I can't predict what kind of categories your tags
74-
represent. `Relationship to LTER Site` would work for the example tags
75-
mentioned above.
76-
* `style` - The bibliography display style for the citations, e.g., apa. Leave
77-
blank for the default which is chicago-note-bibliography.
78-
79-
### Result Counts and Pagination
80-
81-
You can provide HTML id attribute values for elements that will contain result
82-
counts, pagination links, and so on. In general, if you do not want to show one
83-
of these elements, then provide an empty string, "", as the identifier. If the
84-
code does not find a matching element, it will skip it.
85-
86-
* `limit` - Max number of results to retrieve per page. A value of 10 is a good
87-
starting point. As you approach 100, Zotero gets awfully slow.
88-
* `urlElementId` - Supply this if your HTML document has an element in which
89-
you'd like to display the URL that was used to fetch results from Zotero.
90-
* `countElementId` - Element in your HTML document for showing the total number
91-
of results.
92-
* `pagesTopElementId` - Element to display result page links above results.
93-
* `pagesBotElementId` - Element to display result page links below results.
94-
* `showPages` - Max number of page links to show. The code assumes this is an
95-
odd number!
96-
97-
### Advanced Search Controls
98-
99-
The Zotero API has very limited advanced search functionality, though the
100-
developers say they are planning to add more features. Currently you
101-
can only filter by item type. Thus, `zotero.html` includes a collapsible
102-
**Advanced** section in which the user can choose to filter by item type. See
103-
the HTML if you're curious, but for now I suggest leaving the advanced section
104-
out until more advanced functionality is supported.
105-
106-
### Sorting
107-
108-
The Zotero API supports sorting results. If you want to allow the user to sort
109-
results, you must include an HTML `select` control with the identifier
110-
`visibleSort` and with options matching the allowable Zotero sort values. See
111-
the section on sorting and pagination parameters in the [Zotero API
112-
documentation](https://www.zotero.org/support/dev/web_api/v3/basics) for
113-
allowable values. See `zotero.html` for an example of what the `select` element
114-
should look like. This element should be contained within a `div` element,
115-
which is used to hide the control if no results were returned from the search.
116-
117-
If you do not want to allow the user to change the sorting option, then leave
118-
these HTML elements out of your document.
119-
120-
* `sortDiv` - Identifier of the HTML element containing the `select` control
121-
allowing interactive sort options.
8+
For usage and examples, see [the documentation](https://ble-lter.github.io/Zotero-JavaScript-Search-Client/).
File renamed without changes.

index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
Example HTML, CSS, and JavaScript for searching for items within a public Zotero
33
user or group library
44

5-
[See a live demo at RawGit](https://cdn.rawgit.com/twhiteaker/Zotero-JavaScript-Search-Client/2297dc82/zotero.html)
5+
Some live demos:
6+
7+
* [Basic example](minimal.html)
8+
* [Complete example](complete.html)
69

710
## Motivation
811

0 commit comments

Comments
 (0)