Skip to content

Commit 678aefa

Browse files
committed
getTools()
1 parent 108114f commit 678aefa

3 files changed

Lines changed: 85 additions & 3 deletions

File tree

classes/Project/Project.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ export default class Project {
175175
return await this.update()
176176
}
177177

178+
async getTools() {
179+
await this.#load()
180+
return this.data.tools
181+
}
182+
178183
async updateMetadata(newMetadata) {
179184
this.data.metadata = newMetadata
180185
return await this.update()

classes/Project/ProjectFactory.js

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,70 @@ export default class ProjectFactory {
2121
* @param {*} manifest : The manifest object to be processed
2222
* @returns object of project data
2323
*/
24+
25+
static tools = {
26+
"userTool": [
27+
{
28+
"name":"page",
29+
"state": false
30+
},
31+
{
32+
"name":"inspector",
33+
"state": false
34+
},
35+
{
36+
"name":"characters",
37+
"state": false
38+
},
39+
{
40+
"name":"xml",
41+
"state": false
42+
},
43+
{
44+
"name":"fullpage",
45+
"state": false
46+
},
47+
{
48+
"name":"history",
49+
"state": false
50+
},
51+
{
52+
"name":"preview",
53+
"state": false
54+
},
55+
{
56+
"name":"parsing",
57+
"state": false
58+
},
59+
{
60+
"name":"compare",
61+
"state": false
62+
}
63+
],
64+
"projectTool": [
65+
{
66+
"name": "Cappelli's Abbreviation",
67+
"url": "https://centerfordigitalhumanities.github.io/cappelli/",
68+
"state": false
69+
},
70+
{
71+
"name": "Enigma",
72+
"url": "http://ciham-digital.huma-num.fr/enigma/",
73+
"state": false
74+
},
75+
{
76+
"name": "Latin Dictionary",
77+
"url": "http://www.perseus.tufts.edu/hopper/resolveform?lang=latin",
78+
"state": false
79+
},
80+
{
81+
"name": "Latin Vulgate",
82+
"url": "http://vulsearch.sourceforge.net/cgi-bin/vulsearch",
83+
"state": false
84+
}
85+
]
86+
}
87+
2488
static async DBObjectFromManifest(manifest) {
2589
if (!manifest) {
2690
throw {
@@ -31,14 +95,15 @@ export default class ProjectFactory {
3195
const now = Date.now().toString().slice(-6)
3296
const label = ProjectFactory.getLabelAsString(manifest.label) ?? now
3397
const metadata = manifest.metadata ?? []
34-
const layer = Layer.build( database.reserveId(), `First Layer - ${label}`, manifest.items )
98+
const layer = Layer.build( database.reserveId(), `First Layer - ${label}`, manifest.items )
3599

36100
// required properties: id, label, metadata, manifest, layers
37101
return {
38102
label,
39103
metadata,
40104
manifest: [ manifest.id ],
41-
layers: [ layer.asProjectLayer() ]
105+
layers: [ layer.asProjectLayer() ],
106+
tools: this.tools
42107
}
43108
}
44109

project/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,19 @@ router.route("/:projectId/hotkeys").all((_, res) => {
11471147
})
11481148

11491149
// Adding tools to the Project
1150-
router.route("/:projectId/tools").post(async (req, res) => {
1150+
router.route("/:projectId/tools").get(async (req, res) => {
1151+
const { projectId } = req.params
1152+
1153+
try {
1154+
const project = new Project(projectId)
1155+
const tools = await project.getTools()
1156+
1157+
res.status(200).json(tools)
1158+
return
1159+
} catch (error) {
1160+
return respondWithError(res, error.status ?? 500, error.message.toString())
1161+
}
1162+
}).post(async (req, res) => {
11511163
const { projectId } = req.params
11521164
const { tools } = req.body
11531165

0 commit comments

Comments
 (0)