|
9 | 9 |
|
10 | 10 | * [`bfe`](#bfe) |
11 | 11 | * [Configuring `bfe`](#configuring-bfe) |
| 12 | +* [`bfelookup`](#bfelookup) |
12 | 13 | * [`bfestore`](#bfestore) |
13 | 14 | * [`bfelog`](#bfelog) |
14 | 15 |
|
@@ -51,76 +52,17 @@ to load and, if invoking the "full editor," the structure of the left-side menu. |
51 | 52 | Providing a `return` description is generally necessary in order to provide a |
52 | 53 | callback function for when the user hits the `save` button. |
53 | 54 |
|
| 55 | +#### `config` Properties |
54 | 56 |
|
55 | | -#### Example (Kitchen sink) |
| 57 | +Required |
56 | 58 |
|
57 | | -```javascript |
58 | | -{ |
59 | | - "baseURI": "http://example.org/", |
60 | | - "profiles": [ |
61 | | - "/static/profiles/bibframe/Agents.json", |
62 | | - "/static/profiles/bibframe/Annotations.json", |
63 | | - "/static/profiles/bibframe/Authorities.json", |
64 | | - "/static/profiles/bibframe/Entities.json", |
65 | | - "/static/profiles/bibframe/WIA.json", |
66 | | - ], |
67 | | - "startingPoints": [ |
68 | | - { |
69 | | - "menuGroup": "BIBFRAME Generic", |
70 | | - "menuItems": [ |
71 | | - { |
72 | | - label: "New HeldItem", |
73 | | - useResourceTemplates: [ "profile:bf:HeldItem" ] |
74 | | - }, |
75 | | - { |
76 | | - label: "New Instance", |
77 | | - useResourceTemplates: [ "profile:bf:Instance" ] |
78 | | - }, |
79 | | - { |
80 | | - label: "New Work", |
81 | | - useResourceTemplates: [ "profile:bf:Work" ] |
82 | | - }, |
83 | | - { |
84 | | - label: "New Work, Instance, & HeldItem", |
85 | | - useResourceTemplates: [ "profile:bf:Work", "profile:bf:Instance", "profile:bf:HeldItem" ] |
86 | | - }, |
87 | | - ] |
88 | | - } |
89 | | - ], |
90 | | - "lookups": { |
91 | | - "http://id.loc.gov/authorities/names": { |
92 | | - "name": "LCNAF", |
93 | | - "load": "src/lookups/lcnames" |
94 | | - }, |
95 | | - "http://id.loc.gov/authorities/subjects": { |
96 | | - "name": "LCSH", |
97 | | - "load": "src/lookups/lcsubjects" |
98 | | - } |
99 | | - }, |
100 | | - "load": [ |
101 | | - { |
102 | | - "templateID": "profile:bf:Work", |
103 | | - "defaulturi": "http://id.loc.gov/resources/bibs/5226", |
104 | | - "source": { |
105 | | - "location": "http://id.loc.gov/resources/bibs/5226.bibframe_raw.jsonp", |
106 | | - "requestType": "jsonp" |
107 | | - } |
108 | | - }, |
109 | | - { |
110 | | - "templateID": "profile:bf:Instance", |
111 | | - "defaulturi": "_:b105resourcesbibs5226" |
112 | | - } |
113 | | - ], |
114 | | - "return": { |
115 | | - "format": "jsonld-expanded", |
116 | | - "callback": myCB |
117 | | - } |
118 | | -} |
119 | | -``` |
| 59 | +* `url`: (String) the url for the server, which in the example config is set to |
| 60 | + rectoBase, which by default is `http://localhost:3000`, or the value of RECTOBASE |
| 61 | + which is set in env.js by env.sh. |
120 | 62 |
|
121 | | -#### `config` Properties |
| 63 | +* `baseURI`: (String) the base URI to use when minting new identifiers. Defaults |
| 64 | + to `http://example.org/`. |
122 | 65 |
|
123 | | -Required |
124 | 66 | * `profiles`: (Array) locations (URLs) of Profiles to be |
125 | 67 | loaded. Profiles should be in the form of a JSON array with one or |
126 | 68 | more objects that contain a "name" and a "json" property with the |
@@ -150,46 +92,75 @@ Required |
150 | 92 | `useResourceTemplates` expects the identifier value of a resource template (not |
151 | 93 | the identifer for a Profile). If more than one resource template identifier is |
152 | 94 | listed, then the multiple resource templates are combine into one form for |
153 | | - editing. For more about the distinction see the [BIBFRAME Profile Specification][profilespec]. |
154 | | - |
| 95 | + editing. |
| 96 | +```json |
| 97 | +"startingPoints": [ |
| 98 | + {"menuGroup": "Monograph", |
| 99 | + "menuItems": [ |
| 100 | + { |
| 101 | + label: "Instance", |
| 102 | + type: ["http://id.loc.gov/ontologies/bibframe/Instance"], |
| 103 | + useResourceTemplates: [ "profile:bf2:Monograph:Instance" ] |
| 104 | + }, |
| 105 | + { |
| 106 | + label: "Work", |
| 107 | + type: ["http://id.loc.gov/ontologies/bibframe/Work"], |
| 108 | + useResourceTemplates: [ "profile:bf2:Monograph:Work" ] |
| 109 | + } |
| 110 | + |
| 111 | + ]} |
| 112 | + ] |
| 113 | +``` |
155 | 114 |
|
156 | 115 | Optional |
157 | | -* `baseURI`: (String) the base URI to use when minting new identifiers. Defaults |
158 | | - to `http://example.org/`. |
159 | | -* `load`: (Array) Instructs which resource templates to automatically load into |
160 | | - the editor. This is essential when using the "form only" editor. Each member |
161 | | - of the `load` object contains minimally one property, `templateID`. |
162 | | - `templateID` is the resource template identifier of the resource template to |
163 | | - be loaded. Each resource template - each object - represents a resource. |
164 | | - If multiple objects are specified, the resource templates will be |
165 | | - combined and displayed as one large form, similar to identifing multiple resource |
166 | | - template identifiers of the `useResourceTemplates` property of a menu item (see |
167 | | - `startingPoints` above). Each object may also specify a `defaultURI` to use |
168 | | - for the resource being loaded/edited. In order to "edit" existing data, the |
169 | | - `source` property should be used. `source` is an object that indicates the |
170 | | - `location` of the data to be loaded for editing and the `requestType`. `location` |
171 | | - should be a full URL (content-negotation is not supported). `requestType` may |
172 | | - be either 'jsonp' or 'json'. 'json' should only be used when not attempting a |
173 | | - cross-domain request. |
| 116 | +* `basedbURI`: URI for posting triples for publication in a triplestore |
| 117 | +* `resourceURI`: Base URI for resources in the triplestore. |
174 | 118 | * `logging`: (Object) with two properties. `level` indicates the level of logging |
175 | 119 | desired. INFO and DEBUG are the two options. DEBUG is verbose. Default is |
176 | 120 | INFO. `toConsole` is a boolean value. "True" will write the output to the |
177 | | - Javascript console during runtime. Default is "True". |
178 | | -* `lookups`: (Object) an object of objects. The object's key is a scheme identifier |
179 | | - used or expected to be used with the `useValuesFrom` property constraint from |
180 | | - a property in a property template which is part of a profile's resource template. |
181 | | - For more about the `useValuesFrom` property, see the [Profile Specification][profilespec]. |
182 | | - Each object consists of two properties. `name` is a label/identifier for the lookup. |
183 | | - It is used by the typeahead library. `load` is the location of the Javascript |
184 | | - file the contains the functions required to populate the typeahead drop down |
185 | | - selection list and then to process the selected item. You can read more about [lookups |
186 | | - here][lookups-info]. |
187 | | - |
| 121 | + Javascript console during runtime. Default is "True". |
| 122 | +* lookups: (Object) an object of objects. The object's key is a scheme identifier used or |
| 123 | + expected to be used with the useValuesFrom property constraint from a property in a |
| 124 | + property template which is part of a profile's resource template. Each object consists of |
| 125 | + two properties. name is a label/identifier for the lookup. It is used by the typeahead library. |
| 126 | + load is the location of the Javascript file the contains the functions required to populate |
| 127 | + the typeahead drop down selection list and then to process the selected item. |
188 | 128 |
|
189 | 129 | <!-- section links --> |
| 130 | +---------------- |
190 | 131 |
|
191 | | -[profilespec]: http://bibframe.org/documentation/bibframe-profilespec/ |
192 | | -[lookups-info]: https://github.com/lcnetdev/bfe/blob/master/docs/bfe-lookups.md |
| 132 | +### `bfelookup` |
| 133 | + |
| 134 | +`bfe` Lookups |
| 135 | +---------------- |
| 136 | + |
| 137 | +A `bfe` lookup is a Javascript function that contains logic to fetch typeahead suggestions, |
| 138 | +format those suggestions for display, and, after a suggestion is selected, a |
| 139 | +lookup performs post-selection processing and returns the data to the editor. |
| 140 | + |
| 141 | +Each lookup must contain three exported objects: |
| 142 | + |
| 143 | +* `scheme` - (String) representing the scheme identifier. This is used to match |
| 144 | + the lookup with the appropriate declaration in the `useValuesFrom` declaration |
| 145 | + in the profile. |
| 146 | +* `source` - (Function) expects two parameters - `query, process` - and |
| 147 | + ultimately returns a list of objects each with a `uri` property and `value` |
| 148 | + property, the latter containing the humand readable text to display. |
| 149 | +* `getResource` - (Function) expects four parameters: `subjecturi, propertyuri, |
| 150 | + selected, process`. `subjecturi` is the URI for the resource being described. |
| 151 | + `propertyuri` is the property uri of the property that invoked the lookup. |
| 152 | + `selected` is the selected item, it has two properties `uri` and `value`, about |
| 153 | + which see `source` above. Finally, `process` is the callback. At the end, `process` is called with |
| 154 | + one parameter, which is an array of triples formatted according to the [`bfestore`](#bfestore). |
| 155 | + It is not necessary to include the `guid` property for each triple; that is added |
| 156 | + after the data is returned to the editor. |
| 157 | + |
| 158 | +Lookups can be created and dynamically loaded at run time. See [configuring |
| 159 | +`bfe`](#configuring-bfe). If a 'key' of a dynamically loaded lookup is the same |
| 160 | +as a pre-existing/pre-loaded lookup, the pre-loaded one is overwritten and not |
| 161 | +used. |
| 162 | + |
| 163 | +<!-- section links --> |
193 | 164 |
|
194 | 165 | ---------------- |
195 | 166 |
|
@@ -224,21 +195,27 @@ Is the store itself. The store is an array of triples of the following form. |
224 | 195 | } |
225 | 196 | ] |
226 | 197 | ``` |
| 198 | +#### bfe.bfestore.jsonld2store |
| 199 | +Expects expanded jsonld, and converts the jsonld to an array of triples. |
| 200 | + |
| 201 | +#### bfe.bfestore.rdfxml2store |
| 202 | +Using ajax uses `http://rdf-translator.appstpot.com` to convert rdfxml to jsonld, which used the helper function `jsonldcompascted2store` to expand the jsonld and normalize blanknodes and identifiers. Used with Load Marc in editor. |
227 | 203 |
|
228 | | -#### bfe.bfestore.storeDedup() |
| 204 | +#### bfe.bfestore.store2rdfxml |
229 | 205 |
|
230 | | -Returns the store after deduping. Nominally clears the store of duplicate triples. |
231 | | -It is usually not necessary to call this; the store is deduped before calling the |
232 | | -below methods. |
| 206 | +Using jsonld, converts the jsonld to nquads, which is converted to turtle by N3.js. The prefixes are set and the turtle |
| 207 | +is sent to rapper using a rest api on recto. Used in the preview pane. |
233 | 208 |
|
234 | | -#### bfe.bfestore.store2text() |
| 209 | +#### bfe.bfestore.n32store |
235 | 210 |
|
236 | | -Returns the store formatted as text. This is a throw away function designed to |
237 | | -provide quick and dirty human-readable access to the data in the store. |
| 211 | +Using N3.js, convert n3/turtle to quads, which is passed to jsonld, expanded and pushed into the bfestore. |
238 | 212 |
|
239 | | -#### bfe.bfestore.store2jsonldExpanded() |
| 213 | +#### bfe.bfestore.store2turtle() |
240 | 214 |
|
241 | | -Returns the store as JSON object formatted according to jsonld expanded syntax. |
| 215 | +Returns the store formatted as turtle, for use in the preview pane. |
| 216 | + |
| 217 | +#### bfe.bfestore.store2jsonldcompacted |
| 218 | +Returns the store formatted as compacted jsonld, for use in the preview pane. |
242 | 219 |
|
243 | 220 | ---------------- |
244 | 221 |
|
@@ -286,3 +263,4 @@ Returns the log as a JSON object. Sample: |
286 | 263 | ``` |
287 | 264 |
|
288 | 265 |
|
| 266 | + |
0 commit comments