1- import { Scheme } from "src/client/poid.js"
21import PolymorphicIdentifier from "src/client/poid.js"
3- import focalStorage from "src/external/focalStorage.js"
4- import { parseQuery , getDeepProperty } from 'utils'
5-
2+ import BibliographyScheme from "./bibliography-scheme.js" ;
63import FileIndex from "src/client/fileindex.js"
74
8- export class BibScheme extends Scheme {
5+ export class BibScheme extends BibliographyScheme {
96
107 get scheme ( ) {
118 return "bib"
129 }
1310
14- resolve ( ) {
15- return true
16- }
11+ async searchEntries ( entries , query ) {
12+ var key = query
13+ return entries . filter ( entry => entry . key == key )
14+ }
1715
18- async GET ( options ) {
19- var key = this . url . replace ( / b i b \: \/ \/ / , "" )
16+ async content ( entries , query ) {
17+ var entry = entries [ 0 ] || { }
2018
19+ var key = query
2120
22- var entries = await FileIndex . current ( ) . db . bibliography . where ( "key" ) . equals ( key ) . toArray ( )
23- var entry = entries [ 0 ] || { }
21+ var files = await FileIndex . current ( ) . db . files . where ( "bibkey" ) . equals ( key ) . toArray ( )
2422
25- var content = `<h2>[${ key } ]<br/>${ entry . authors ? entry . authors + "." : "" } ${ entry . year || "" } <br/><i> ${ entry . title || "" } </i></h2>`
23+ var content = `<h2>[${ key } ]<br/>${
24+ entry . authors ?
25+ entry . authors . map ( ea => `<a href="author://${ ea } ">${ ea } </a>` ) . join ( ", " ) + "." : ""
26+ } ${ entry . year || "" } <br/><i> ${ entry . title || "" } </i></h2>`
2627
27- if ( entry . source ) {
28- content += "<pre>" + entry . source + "</pre>"
2928
29+ if ( entry . keywords ) {
30+ content += `<div><b>Keywords:</b> ${ entry . keywords . map ( ea => `<a href="keyword://${ ea } ">${ ea } </a>` ) . join ( ", " ) } </div>`
3031 }
3132
32-
33- var files = await FileIndex . current ( ) . db . files . where ( "bibkey" ) . equals ( key ) . toArray ( )
3433
34+
35+ if ( entry . source ) {
36+ content += "<pre>" + entry . source + "</pre>"
37+ }
38+
3539 content += "<h3>Documents</h3><ul>" + files . map ( ea => {
3640 return `<li><a href="${ ea . url } ">${ ea . name } </a></li>`
3741 } ) . join ( "\n" ) + "</ul>"
3842
3943
4044 content += "<h3>Bibliographies</h3><ul>" + entries . map ( ea => {
4145 return `<li><a href="${ ea . url } ">${ ea . url } </a></li>`
42- } ) . join ( "\n" ) + "</ul>"
43-
44-
45-
46- return new Response ( content , {
47- headers : {
48- "content-type" : "text/html" ,
49- } ,
50- status : 200 ,
51- } )
52- }
53-
54-
55- async OPTIONS ( options ) {
56-
57- var content = JSON . stringify ( { } , undefined , 2 )
58-
59-
60- return new Response ( content , {
61- headers : {
62- "content-type" : "application/json" ,
63- } ,
64- status : 200 ,
65- } )
46+ } ) . join ( "\n" ) + "</ul>"
47+ return content
6648 }
67-
68-
69-
70-
7149}
7250
73-
74-
7551PolymorphicIdentifier . register ( BibScheme )
0 commit comments