-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,064 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,32 @@ | ||
// import { fetchPublicationByDoi, CrossrefClient } from 'ts-etl' | ||
// import * as D from 'docmaps-sdk' | ||
// import { either } from 'fp-ts/lib/Either' | ||
// | ||
// export async function fetchData() { | ||
// // Create a CrossrefClient instance | ||
// const client = new CrossrefClient(); | ||
// | ||
// // Create a DocmapPublisherT instance (replace with appropriate values) | ||
// const publisher = new D.DocmapPublisherT(/*...publisher values...*/); | ||
// | ||
// const result: ErrorOrDocmap = await fetchPublicationByDoi( | ||
// client, | ||
// publisher, | ||
// inputUrl | ||
// ); | ||
// | ||
// either.fold( | ||
// (error) => { | ||
// // Handle the error case (e.g., display an error message) | ||
// console.error('Error:', error); | ||
// }, | ||
// (docmap: D.DocmapT[]) => { | ||
// // Handle the success case | ||
// const resultArea = document.getElementById('resultArea'); | ||
// const renderRev = document.createElement('render-rev'); | ||
// renderRev.setAttribute('source', JSON.stringify(docmap)); | ||
// resultArea.appendChild(renderRev); | ||
// } | ||
// )(result); | ||
// } | ||
import { ItemCmd, Client as CrossrefClient } from '@docmaps/etl' | ||
import util from 'util' | ||
import {isLeft} from 'fp-ts/lib/Either' | ||
|
||
export function configureForDoiString(rev, str) { | ||
export async function configureForDoiString(rev, str) { | ||
|
||
let config = { | ||
display: { | ||
publisherName: name => name.toUpperCase(), | ||
} | ||
} | ||
|
||
try { | ||
const url = new URL(str); | ||
config["docmapsUrl"] = (_) => str; | ||
} catch (e) { | ||
config["doi"] = str; | ||
} | ||
console.log('running with', rev, str) | ||
const result = await ItemCmd( | ||
[str], | ||
{ | ||
source: { | ||
preset: 'crossref-api', | ||
client: CrossrefClient, | ||
}, | ||
publisher: {}, | ||
} | ||
); | ||
|
||
rev.configure({ | ||
...config, | ||
}); | ||
if (isLeft(result)) { | ||
console.log(util.inspect(result.left, {depth: 7})) | ||
} else { | ||
rev.configure({ | ||
...config, | ||
docmaps: result.right, | ||
}); | ||
} | ||
} |
Oops, something went wrong.