Replace entry with artifact and add entity

This commit is contained in:
kngako committed 2022-01-05 03:04:43 +02:00
1 parent e22f85a1aa
commit 7be5200094
28 files changed
+560 -523

No files matched your search

+110 -91
View File
@@ -25,7 +25,7 @@
}
},
"../mantra-db-models": {
"version": "0.0.7",
"version": "0.0.8",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.1",
@@ -39,17 +39,17 @@
}
},
"node_modules/@babel/helper-validator-identifier": {
"version": "7.15.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz",
"integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==",
"version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz",
"integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/parser": {
"version": "7.16.6",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.6.tgz",
"integrity": "sha512-Gr86ujcNuPDnNOY8mi383Hvi8IYrJVJYuf3XcuBM/Dgd+bINn/7tHqsj+tKkoreMbmGsFLsltI/JJd8fOFWGDQ==",
"version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.7.tgz",
"integrity": "sha512-sR4eaSrnM7BV7QPzGfEX5paG/6wrZM3I0HDzfIAK06ESvo9oy3xBuVBxE3MbQaKNhvg8g/ixjMWo2CGpzpHsDA==",
"bin": {
"parser": "bin/babel-parser.js"
},
@@ -58,11 +58,11 @@
}
},
"node_modules/@babel/types": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.16.0.tgz",
"integrity": "sha512-PJgg/k3SdLsGb3hhisFvtLOw5ts113klrpLuIPtCJIU+BB24fqq6lf8RWqKJEjzqXR9AEH1rIb5XTqwBHB+kQg==",
"version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.16.7.tgz",
"integrity": "sha512-E8HuV7FO9qLpx6OtoGfUQ2cjIYnbFwvZWYBS+87EwtdMvmUPJSwykpovFB+8insbpF0uJcpr8KMUi64XZntZcg==",
"dependencies": {
"@babel/helper-validator-identifier": "^7.15.7",
"@babel/helper-validator-identifier": "^7.16.7",
"to-fast-properties": "^2.0.0"
},
"engines": {
@@ -85,9 +85,9 @@
"peer": true
},
"node_modules/@types/node": {
"version": "17.0.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.5.tgz",
"integrity": "sha512-w3mrvNXLeDYV1GKTZorGJQivK6XLCoGwpnyJFbJVK/aTBQUxOCaa/GlFAAN3OTDFcb7h5tiFG+YXCO2By+riZw==",
"version": "17.0.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.8.tgz",
"integrity": "sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==",
"peer": true
},
"node_modules/accepts": {
@@ -481,26 +481,6 @@
"node": ">4.0.0"
}
},
"node_modules/excel4node/node_modules/mime": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz",
"integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w==",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4.0.0"
}
},
"node_modules/excel4node/node_modules/uuid": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==",
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
"bin": {
"uuid": "bin/uuid"
}
},
"node_modules/express": {
"version": "4.17.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.17.2.tgz",
@@ -1112,14 +1092,14 @@
}
},
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz",
"integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w==",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
"node": ">=4.0.0"
}
},
"node_modules/mime-db": {
@@ -1548,12 +1528,16 @@
}
},
"node_modules/resolve": {
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz",
"integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==",
"version": "1.21.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.21.0.tgz",
"integrity": "sha512-3wCbTpk5WJlyE4mSOtDLhqQmGFi0/TD9VPwmiolnk8U0wRgMEktqCXd3vy5buTO3tljvalNvKrjHEfrd2WpEKA==",
"dependencies": {
"is-core-module": "^2.2.0",
"path-parse": "^1.0.6"
"is-core-module": "^2.8.0",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
},
"bin": {
"resolve": "bin/resolve"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
@@ -1627,15 +1611,26 @@
"node": ">= 0.8.0"
}
},
"node_modules/send/node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=4"
}
},
"node_modules/send/node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/sequelize": {
"version": "6.12.2",
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.12.2.tgz",
"integrity": "sha512-MjrvyROlvCs44u0XXBsjAKTKSOCI6djFyimlak4Urr6XGSpka5+PD40PlDgJSuCRwIdvyDUdAQl0cw7E68YqqQ==",
"version": "6.12.5",
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.12.5.tgz",
"integrity": "sha512-V//3SwPHMkPZi0amkCLlk2aNdS+qnLR0tTAzAYvhrxZ6t7JgMDiIO4R5+84nHZ0PwGE71RDXKOBBVhkYjABxhQ==",
"funding": [
{
"type": "opencollective",
@@ -1722,6 +1717,15 @@
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"peer": true
},
"node_modules/sequelize/node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"peer": true,
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/serve-static": {
"version": "1.14.2",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.2.tgz",
@@ -1818,6 +1822,17 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/supports-preserve-symlinks-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/to-fast-properties": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
@@ -1904,12 +1919,12 @@
}
},
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"peer": true,
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==",
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
"bin": {
"uuid": "dist/bin/uuid"
"uuid": "bin/uuid"
}
},
"node_modules/validator": {
@@ -2025,21 +2040,21 @@
},
"dependencies": {
"@babel/helper-validator-identifier": {
"version": "7.15.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz",
"integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w=="
"version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz",
"integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw=="
},
"@babel/parser": {
"version": "7.16.6",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.6.tgz",
"integrity": "sha512-Gr86ujcNuPDnNOY8mi383Hvi8IYrJVJYuf3XcuBM/Dgd+bINn/7tHqsj+tKkoreMbmGsFLsltI/JJd8fOFWGDQ=="
"version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.16.7.tgz",
"integrity": "sha512-sR4eaSrnM7BV7QPzGfEX5paG/6wrZM3I0HDzfIAK06ESvo9oy3xBuVBxE3MbQaKNhvg8g/ixjMWo2CGpzpHsDA=="
},
"@babel/types": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.16.0.tgz",
"integrity": "sha512-PJgg/k3SdLsGb3hhisFvtLOw5ts113klrpLuIPtCJIU+BB24fqq6lf8RWqKJEjzqXR9AEH1rIb5XTqwBHB+kQg==",
"version": "7.16.7",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.16.7.tgz",
"integrity": "sha512-E8HuV7FO9qLpx6OtoGfUQ2cjIYnbFwvZWYBS+87EwtdMvmUPJSwykpovFB+8insbpF0uJcpr8KMUi64XZntZcg==",
"requires": {
"@babel/helper-validator-identifier": "^7.15.7",
"@babel/helper-validator-identifier": "^7.16.7",
"to-fast-properties": "^2.0.0"
}
},
@@ -2059,9 +2074,9 @@
"peer": true
},
"@types/node": {
"version": "17.0.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.5.tgz",
"integrity": "sha512-w3mrvNXLeDYV1GKTZorGJQivK6XLCoGwpnyJFbJVK/aTBQUxOCaa/GlFAAN3OTDFcb7h5tiFG+YXCO2By+riZw==",
"version": "17.0.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.8.tgz",
"integrity": "sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==",
"peer": true
},
"accepts": {
@@ -2366,18 +2381,6 @@
"mime": "2.4.0",
"uuid": "3.3.2",
"xmlbuilder": "11.0.1"
},
"dependencies": {
"mime": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz",
"integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w=="
},
"uuid": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
}
}
},
"express": {
@@ -2835,9 +2838,9 @@
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
},
"mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-2.4.0.tgz",
"integrity": "sha512-ikBcWwyqXQSHKtciCcctu9YfPbFYZ4+gbHEmE0Q8jzcTYQg5dHCr3g2wwAZjPoJfQVXZq6KXAjpXOTf5/cjT7w=="
},
"mime-db": {
"version": "1.51.0",
@@ -3185,12 +3188,13 @@
}
},
"resolve": {
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz",
"integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==",
"version": "1.21.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.21.0.tgz",
"integrity": "sha512-3wCbTpk5WJlyE4mSOtDLhqQmGFi0/TD9VPwmiolnk8U0wRgMEktqCXd3vy5buTO3tljvalNvKrjHEfrd2WpEKA==",
"requires": {
"is-core-module": "^2.2.0",
"path-parse": "^1.0.6"
"is-core-module": "^2.8.0",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
}
},
"retry-as-promised": {
@@ -3238,6 +3242,11 @@
"statuses": "~1.5.0"
},
"dependencies": {
"mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
},
"ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@@ -3246,9 +3255,9 @@
}
},
"sequelize": {
"version": "6.12.2",
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.12.2.tgz",
"integrity": "sha512-MjrvyROlvCs44u0XXBsjAKTKSOCI6djFyimlak4Urr6XGSpka5+PD40PlDgJSuCRwIdvyDUdAQl0cw7E68YqqQ==",
"version": "6.12.5",
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.12.5.tgz",
"integrity": "sha512-V//3SwPHMkPZi0amkCLlk2aNdS+qnLR0tTAzAYvhrxZ6t7JgMDiIO4R5+84nHZ0PwGE71RDXKOBBVhkYjABxhQ==",
"peer": true,
"requires": {
"@types/debug": "^4.1.7",
@@ -3282,6 +3291,12 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"peer": true
},
"uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"peer": true
}
}
},
@@ -3369,6 +3384,11 @@
"define-properties": "^1.1.3"
}
},
"supports-preserve-symlinks-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w=="
},
"to-fast-properties": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
@@ -3434,10 +3454,9 @@
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
},
"uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"peer": true
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
},
"validator": {
"version": "13.7.0",
@@ -30,7 +30,7 @@ module.exports = function (options) {
]
}).then(user => {
if (user) {
// TODO: Check if user already created a password reset entry to save on a db transaction
// TODO: Check if user already created a password reset artifact to save on a db transaction
return Promise.all([
user.userEmails[0],
user.userPasswordReset ? user.userPasswordReset : db.UserPasswordReset.create({
@@ -84,7 +84,7 @@ module.exports = function (options) {
pageTitle: "Password Reset Initiated - Mantra"
})
} else {
next(`Failed to create a user password reset entry (user ${request.body.email} doesn't exist)`)
next(`Failed to create a user password reset artifact (user ${request.body.email} doesn't exist)`)
}
}).catch (error => {
next(error)
+33 -33
View File
@@ -6,19 +6,19 @@ module.exports = function (options) {
router.route('/t/:id')
.post(function(request, response, next) {
db.TranslationEntryVersion.findByPk(request.params.id, {
}).then(async (translationEntryVersion) => {
if (translationEntryVersion) {
db.TranslationArtifactVersion.findByPk(request.params.id, {
}).then(async (translationArtifactVersion) => {
if (translationArtifactVersion) {
// fork...
const forkedTranslationEntryVersion = await db.TranslationEntryVersion.create({
name: translationEntryVersion.name,
entryVersionId: translationEntryVersion.entryVersionId,
const forkedTranslationArtifactVersion = await db.TranslationArtifactVersion.create({
name: translationArtifactVersion.name,
artifactVersionId: translationArtifactVersion.artifactVersionId,
userId: request.user.id,
dialectId: translationEntryVersion.dialectId,
forkedFromId: translationEntryVersion.id
dialectId: translationArtifactVersion.dialectId,
forkedFromId: translationArtifactVersion.id
})
if (forkedTranslationEntryVersion) {
return response.redirect(`/v/${forkedTranslationEntryVersion.entryVersionId}/translations/${forkedTranslationEntryVersion.id}`)
if (forkedTranslationArtifactVersion) {
return response.redirect(`/v/${forkedTranslationArtifactVersion.artifactVersionId}/translations/${forkedTranslationArtifactVersion.id}`)
}
} else {
next()
@@ -30,18 +30,18 @@ module.exports = function (options) {
router.route('/e/:id')
.get(function(request, response, next) {
db.EntryVersion.findByPk(request.params.id, {
db.ArtifactVersion.findByPk(request.params.id, {
include: [
{
association: db.EntryVersion.Entry
association: db.ArtifactVersion.Artifact
}
]
}).then(entryVersion => {
if (entryVersion) {
response.display("fork-entry-version", {
}).then(artifactVersion => {
if (artifactVersion) {
response.display("fork-artifact-version", {
user: request.user,
pageTitle: "Add translation - Mantra",
entryVersion: entryVersion
artifactVersion: artifactVersion
})
} else {
next()
@@ -64,13 +64,13 @@ module.exports = function (options) {
})
if (dialect) {
const entryVersion = await db.EntryVersion.findByPk(request.params.id, {
const artifactVersion = await db.ArtifactVersion.findByPk(request.params.id, {
include: [
{
association: db.EntryVersion.Entry
association: db.ArtifactVersion.Artifact
},
{
association: db.EntryVersion.TranslationEntryVersions,
association: db.ArtifactVersion.TranslationArtifactVersions,
required: false,
where: {
dialectId: dialect.id,
@@ -79,10 +79,10 @@ module.exports = function (options) {
]
})
if (entryVersion) {
const forkedTranslationEntryVersion = await forkEntryVersion(entryVersion, dialect, request.user.id)
if (forkedTranslationEntryVersion) {
return response.redirect(`/v/${forkedTranslationEntryVersion.entryVersionId}/translations/${forkedTranslationEntryVersion.id}`)
if (artifactVersion) {
const forkedTranslationArtifactVersion = await forkArtifactVersion(artifactVersion, dialect, request.user.id)
if (forkedTranslationArtifactVersion) {
return response.redirect(`/v/${forkedTranslationArtifactVersion.artifactVersionId}/translations/${forkedTranslationArtifactVersion.id}`)
}
}
}
@@ -90,22 +90,22 @@ module.exports = function (options) {
next()
})
const forkEntryVersion = (entryVersion, dialect, userId) => {
if (entryVersion.translationEntryVersions.length == 0) {
// create a translationEntryVersion with a new dialect...
return db.TranslationEntryVersion.create({
const forkArtifactVersion = (artifactVersion, dialect, userId) => {
if (artifactVersion.translationArtifactVersions.length == 0) {
// create a translationArtifactVersion with a new dialect...
return db.TranslationArtifactVersion.create({
name: dialect.name,
entryVersionId: entryVersion.id,
artifactVersionId: artifactVersion.id,
dialectId: dialect.id,
userId: userId,
})
} else {
return db.TranslationEntryVersion.create({
name: entryVersion.translationEntryVersions[0].name,
entryVersionId: entryVersion.translationEntryVersions[0].entryVersionId,
return db.TranslationArtifactVersion.create({
name: artifactVersion.translationArtifactVersions[0].name,
artifactVersionId: artifactVersion.translationArtifactVersions[0].artifactVersionId,
userId: userId,
dialectId: entryVersion.translationEntryVersions[0].dialectId,
forkedFromId: entryVersion.translationEntryVersions[0].id
dialectId: artifactVersion.translationArtifactVersions[0].dialectId,
forkedFromId: artifactVersion.translationArtifactVersions[0].id
})
}
}
+19 -18
View File
@@ -7,7 +7,7 @@ module.exports = function (options) {
router.route('/')
.get(function(request, response, next) {
db.Entry.findAll({
db.Artifact.findAll({
}).then(entries => {
response.display("library", {
@@ -26,7 +26,7 @@ module.exports = function (options) {
response.display("library-form", {
user: request.user,
pageTitle: "Add Library - Mantra",
entry: {
artifact: {
version: "1.0"
}
})
@@ -43,20 +43,21 @@ module.exports = function (options) {
}
}).then(dialect => {
if (dialect) {
return db.Entry.create({
return db.Artifact.create({
name: request.body.name,
url: request.body.url,
dialectId: dialect.id,
licenseId: "copyright",
entryVersions: [
artifactVersions: [
{
tag: request.body.version
}
]
],
entityId: request.user.individualEntityUser.entityUser.entityId
}, {
include: [
{
association: db.Entry.EntryVersions,
association: db.Artifact.ArtifactVersions,
}
]
@@ -65,9 +66,9 @@ module.exports = function (options) {
response.redirect("/library/add") // TODO: Show error message on missing dialect...
}
}).then(entry => {
if (entry) {
response.redirect(`/library/${entry.id}`)
}).then(artifact => {
if (artifact) {
response.redirect(`/library/${artifact.id}`)
} else {
next()
}
@@ -82,24 +83,24 @@ module.exports = function (options) {
router.route('/:id')
.get(function(request, response, next) {
db.Entry.findByPk(request.params.id, {
db.Artifact.findByPk(request.params.id, {
include: [
{
association: db.Entry.EntryApproval
association: db.Artifact.ArtifactApproval
},
{
association: db.Entry.EntryVersions
association: db.Artifact.ArtifactVersions
}
]
}).then(entry => {
if (entry) {
if (entry.entryVersions.length == 1) {
response.redirect(`/v/${entry.entryVersions[0].id}`)
}).then(artifact => {
if (artifact) {
if (artifact.artifactVersions.length == 1) {
response.redirect(`/v/${artifact.artifactVersions[0].id}`)
} else {
response.display("entry", {
response.display("artifact", {
user: request.user,
pageTitle: "Library - Mantra",
entry: entry
artifact: artifact
})
}
+66 -65
View File
@@ -22,29 +22,29 @@ module.exports = function (options) {
db.Project.findByPk(request.params.id, {
include: [
{
association: db.Project.ProjectEntryVersions,
association: db.Project.ProjectArtifactVersions,
include: [
{
association: db.ProjectEntryVersion.EntryVersion,
association: db.ProjectArtifactVersion.ArtifactVersion,
include: [
{
association: db.EntryVersion.Entry
association: db.ArtifactVersion.Artifact
}
]
}
]
},
{
association: db.Project.ProjectTranslationEntryVersions,
association: db.Project.ProjectTranslationArtifactVersions,
include: [
{
association: db.ProjectTranslationEntryVersion.TranslationEntryVersion,
association: db.ProjectTranslationArtifactVersion.TranslationArtifactVersion,
include: [
{
association: db.TranslationEntryVersion.EntryVersion,
association: db.TranslationArtifactVersion.ArtifactVersion,
include: [
{
association: db.EntryVersion.Entry
association: db.ArtifactVersion.Artifact
}
]
}
@@ -81,7 +81,8 @@ module.exports = function (options) {
.post(function(request, response, next) {
db.Project.create({
name: request.body.name,
description: request.body.description
description: request.body.description,
entityId: request.user.individualEntityUser.entityUser.entityId
}).then(project => {
if (project) {
response.redirect(`/projects/${project.id}`)
@@ -93,31 +94,31 @@ module.exports = function (options) {
})
})
router.route('/:id/add-entry')
router.route('/:id/add-artifact')
.get(function(request, response, next) {
db.Project.findByPk(request.params.id, {
include: [
{
association: db.Project.ProjectEntryVersions
association: db.Project.ProjectArtifactVersions
},
{
association: db.Project.ProjectTranslationEntryVersions
association: db.Project.ProjectTranslationArtifactVersions
}
]
}).then(async (project) => {
if (project) {
const entries = await db.Entry.findAll({
const entries = await db.Artifact.findAll({
// Narrow it down to entries this user has admin ownership off...,
include: [
{
association: db.Entry.EntryVersions,
association: db.Artifact.ArtifactVersions,
limit: 1,
required: true
// TODO: Order by version...
}
]
})
response.display("project-add-entry", {
response.display("project-add-artifact", {
user: request.user,
pageTitle: "Projects - Mantra",
project: project,
@@ -134,29 +135,29 @@ module.exports = function (options) {
db.Project.findByPk(request.params.id, {
include: [
{
association: db.Project.ProjectEntryVersions,
association: db.Project.ProjectArtifactVersions,
include: [
{
association: db.ProjectEntryVersion.EntryVersion,
association: db.ProjectArtifactVersion.ArtifactVersion,
include: [
{
association: db.EntryVersion.Entry
association: db.ArtifactVersion.Artifact
}
]
}
]
},
{
association: db.Project.ProjectTranslationEntryVersions,
association: db.Project.ProjectTranslationArtifactVersions,
include: [
{
association: db.ProjectTranslationEntryVersion.TranslationEntryVersion,
association: db.ProjectTranslationArtifactVersion.TranslationArtifactVersion,
include: [
{
association: db.TranslationEntryVersion.EntryVersion,
association: db.TranslationArtifactVersion.ArtifactVersion,
include: [
{
association: db.EntryVersion.Entry
association: db.ArtifactVersion.Artifact
}
]
}
@@ -168,19 +169,19 @@ module.exports = function (options) {
}).then(async (project) => {
if (project) {
// TODO: Fi
const entryVersion = await db.EntryVersion.findByPk(request.body.entryVersionId, {
const artifactVersion = await db.ArtifactVersion.findByPk(request.body.artifactVersionId, {
// Narrow it down to entries this user has admin ownership off...,
})
if (entryVersion) {
const projectEntryVersion = db.ProjectEntryVersion.create({
if (artifactVersion) {
const projectArtifactVersion = db.ProjectArtifactVersion.create({
projectId: project.id,
entryVersionId: entryVersion.id
artifactVersionId: artifactVersion.id
})
response.redirect(`/projects/${project.id}`)
} else {
response.redirect(`/projects/${project.id}/add-entry`)
response.redirect(`/projects/${project.id}/add-artifact`)
}
@@ -197,24 +198,24 @@ module.exports = function (options) {
db.Project.findByPk(request.params.id, {
include: [
{
association: db.Project.ProjectEntryVersions
association: db.Project.ProjectArtifactVersions
},
{
association: db.Project.ProjectTranslationEntryVersions
association: db.Project.ProjectTranslationArtifactVersions
}
]
}).then(async (project) => {
if (project) {
const translationEntryVersions = await db.TranslationEntryVersion.findAll({
const translationArtifactVersions = await db.TranslationArtifactVersion.findAll({
// Narrow it down to entries this user has admin ownership off...,
include: [
{
association: db.TranslationEntryVersion.EntryVersion,
association: db.TranslationArtifactVersion.ArtifactVersion,
required: true,
// TODO: Order by version...
include: [
{
association: db.EntryVersion.Entry
association: db.ArtifactVersion.Artifact
}
]
}
@@ -224,7 +225,7 @@ module.exports = function (options) {
user: request.user,
pageTitle: "Projects - Mantra",
project: project,
translationEntryVersions: translationEntryVersions
translationArtifactVersions: translationArtifactVersions
})
} else {
next()
@@ -237,30 +238,30 @@ module.exports = function (options) {
db.Project.findByPk(request.params.id, {
include: [
{
association: db.Project.ProjectEntryVersions
association: db.Project.ProjectArtifactVersions
},
{
association: db.Project.ProjectTranslationEntryVersions
association: db.Project.ProjectTranslationArtifactVersions
}
]
}).then(async (project) => {
if (project) {
// TODO: Fi
const translationEntryVersion = await db.TranslationEntryVersion.findByPk(request.body.translationEntryVersionId, {
const translationArtifactVersion = await db.TranslationArtifactVersion.findByPk(request.body.translationArtifactVersionId, {
// Narrow it down to entries this user has admin ownership off...,
include: [
{
association: db.TranslationEntryVersion.EntryVersion,
association: db.TranslationArtifactVersion.ArtifactVersion,
required: true
// TODO: Order by version...
}
]
})
if (translationEntryVersion) {
const projectTranslationEntryVersion = db.ProjectTranslationEntryVersion.create({
if (translationArtifactVersion) {
const projectTranslationArtifactVersion = db.ProjectTranslationArtifactVersion.create({
projectId: project.id,
translationEntryVersionId: translationEntryVersion.id
translationArtifactVersionId: translationArtifactVersion.id
})
response.redirect(`/projects/${project.id}`)
@@ -285,29 +286,29 @@ module.exports = function (options) {
required: true
},
{
association: db.Project.ProjectEntryVersions,
association: db.Project.ProjectArtifactVersions,
include: [
{
association: db.ProjectEntryVersion.EntryVersion,
association: db.ProjectArtifactVersion.ArtifactVersion,
include: [
{
association: db.EntryVersion.Entry
association: db.ArtifactVersion.Artifact
}
]
}
]
},
{
association: db.Project.ProjectTranslationEntryVersions,
association: db.Project.ProjectTranslationArtifactVersions,
include: [
{
association: db.ProjectTranslationEntryVersion.TranslationEntryVersion,
association: db.ProjectTranslationArtifactVersion.TranslationArtifactVersion,
include: [
{
association: db.TranslationEntryVersion.EntryVersion,
association: db.TranslationArtifactVersion.ArtifactVersion,
include: [
{
association: db.EntryVersion.Entry
association: db.ArtifactVersion.Artifact
}
]
}
@@ -362,29 +363,29 @@ module.exports = function (options) {
}).then(async (project) => {
if (project) {
db.TranslationEntryVersion.findAll({
db.TranslationArtifactVersion.findAll({
include: [
// TODO: require translationEntryVersions in ProjectEntryVersion
// TODO: require translationArtifactVersions in ProjectArtifactVersion
{
association: db.TranslationEntryVersion.ProjectTranslationEntryVersions,
association: db.TranslationArtifactVersion.ProjectTranslationArtifactVersions,
where: {
projectId: request.params.id
},
required: true
},
{
association: db.TranslationEntryVersion.EntryVersion,
association: db.TranslationArtifactVersion.ArtifactVersion,
include: [
{
association: db.EntryVersion.Entry,
association: db.ArtifactVersion.Artifact,
include: [
{
association: db.Entry.Dialect
association: db.Artifact.Dialect
}
]
},
{
association: db.EntryVersion.Chapters,
association: db.ArtifactVersion.Chapters,
include: [
{
association: db.Chapter.Chunks,
@@ -399,22 +400,22 @@ module.exports = function (options) {
]
},
{
association: db.TranslationEntryVersion.Dialect
association: db.TranslationArtifactVersion.Dialect
}
]
}).then(translationEntryVersions => {
}).then(translationArtifactVersions => {
const workbook = new XL.Workbook();
const cellWidth = 45
const cellHeight = 25
translationEntryVersions.forEach((translationEntryVersion, index) => {
const worksheet_name = `${index+1}-${translationEntryVersion.dialect.countryId}-${translationEntryVersion.dialect.languageId} - ${translationEntryVersion.entryVersion.entry.name}`.substring(0, 30);
translationArtifactVersions.forEach((translationArtifactVersion, index) => {
const worksheet_name = `${index+1}-${translationArtifactVersion.dialect.countryId}-${translationArtifactVersion.dialect.languageId} - ${translationArtifactVersion.artifactVersion.artifact.name}`.substring(0, 30);
// Don't have [ ] * ? : / \
const worksheet = workbook.addWorksheet(worksheet_name.replace(/[`*?:'\[\]\\\/]/gi, ""))
worksheet.cell(2,2,2,3,true)
.string(translationEntryVersion.entryVersion.entry.name)
.string(translationArtifactVersion.artifactVersion.artifact.name)
.style({
font: {
bold: true,
@@ -426,7 +427,7 @@ module.exports = function (options) {
})
worksheet.cell(4,2)
.string(translationEntryVersion.entryVersion.entry.dialect.name)
.string(translationArtifactVersion.artifactVersion.artifact.dialect.name)
.style({
font: {
bold: true,
@@ -438,7 +439,7 @@ module.exports = function (options) {
})
worksheet.cell(4,3)
.string(translationEntryVersion.dialect.name)
.string(translationArtifactVersion.dialect.name)
.style({
font: {
bold: true,
@@ -448,15 +449,15 @@ module.exports = function (options) {
wrapText: true
}
})
// Meta data for the translation and entry
// Meta data for the translation and artifact
worksheet.cell(4,4)
.string(translationEntryVersion.entryVersion.id)
.string(translationArtifactVersion.artifactVersion.id)
worksheet.cell(4,5)
.string(translationEntryVersion.id)
.string(translationArtifactVersion.id)
var cellIndex = 6
for (const i in translationEntryVersion.entryVersion.chapters) {
const chapter = translationEntryVersion.entryVersion.chapters[i]
for (const i in translationArtifactVersion.artifactVersion.chapters) {
const chapter = translationArtifactVersion.artifactVersion.chapters[i]
const chunks = chapter.chunks.sort((a,b) => a.index - b.index)
for (const j in chunks) {
const chunk = chunks[j]
+60 -60
View File
@@ -7,14 +7,14 @@ module.exports = function (options) {
router.route('/:id')
.get(function(request, response, next) {
db.TranslationEntryVersion.findByPk(request.params.id, {
db.TranslationArtifactVersion.findByPk(request.params.id, {
include: [
{
association: db.TranslationEntryVersion.EntryVersion,
association: db.TranslationArtifactVersion.ArtifactVersion,
required: true,
include: [
{
association: db.EntryVersion.Chapters,
association: db.ArtifactVersion.Chapters,
required: true,
limit: 1,
// TODO: Order by chapter index
@@ -22,9 +22,9 @@ module.exports = function (options) {
]
}
]
}).then(translationEntryVersion => {
if (translationEntryVersion) {
response.redirect(`/translate/${translationEntryVersion.id}/chapter/${translationEntryVersion.entryVersion.chapters[0].id}`)
}).then(translationArtifactVersion => {
if (translationArtifactVersion) {
response.redirect(`/translate/${translationArtifactVersion.id}/chapter/${translationArtifactVersion.artifactVersion.chapters[0].id}`)
} else {
next()
}
@@ -44,21 +44,21 @@ module.exports = function (options) {
]
},
{
association: db.Chapter.EntryVersion,
association: db.Chapter.ArtifactVersion,
required: true,
include: [
{
association: db.EntryVersion.TranslationEntryVersions,
association: db.ArtifactVersion.TranslationArtifactVersions,
required: true,
where: {
id: request.params.id
}
},
{
association: db.EntryVersion.Entry,
association: db.ArtifactVersion.Artifact,
include: [
{
association: db.Entry.Dialect
association: db.Artifact.Dialect
}
]
}
@@ -104,21 +104,21 @@ module.exports = function (options) {
required: true,
include: [
{
association: db.Chapter.EntryVersion,
association: db.Chapter.ArtifactVersion,
required: true,
include: [
{
association: db.EntryVersion.TranslationEntryVersions,
association: db.ArtifactVersion.TranslationArtifactVersions,
required: true,
where: {
id: request.params.id
}
},
{
association: db.EntryVersion.Entry,
association: db.ArtifactVersion.Artifact,
include: [
{
association: db.Entry.Dialect
association: db.Artifact.Dialect
}
]
}
@@ -133,7 +133,7 @@ module.exports = function (options) {
if (chunk) {
response.display("translate-chunk", {
user: request.user,
pageTitle: `Translate ${chunk.chapter.entryVersion.entry.name}`,
pageTitle: `Translate ${chunk.chapter.artifactVersion.artifact.name}`,
chunk: chunk,
previousChunk: chunks.find(chunk => chunk.index == previousIndex),
nextChunk: chunks.find(chunk => chunk.index == nextIndex)
@@ -164,21 +164,21 @@ module.exports = function (options) {
required: true,
include: [
{
association: db.Chapter.EntryVersion,
association: db.Chapter.ArtifactVersion,
required: true,
include: [
{
association: db.EntryVersion.TranslationEntryVersions,
association: db.ArtifactVersion.TranslationArtifactVersions,
required: true,
where: {
id: request.params.id
}
},
{
association: db.EntryVersion.Entry,
association: db.ArtifactVersion.Artifact,
include: [
{
association: db.Entry.Dialect
association: db.Artifact.Dialect
}
]
}
@@ -196,7 +196,7 @@ module.exports = function (options) {
translation = await db.Translation.create({
chunkId: chunk.id,
text: request.body.translatedText,
translationEntryVersionId: request.params.id
translationArtifactVersionId: request.params.id
})
}
response.redirect(`/translate/${request.params.id}/chapter/${request.params.chapterId}/t/${Number(request.params.chunkIndex)+1}`)
@@ -210,14 +210,14 @@ module.exports = function (options) {
router.route('/:id/back')
.post(function(request, response, next) {
db.TranslationEntryVersion.findByPk(request.params.id, {
db.TranslationArtifactVersion.findByPk(request.params.id, {
include: [
{
association: db.TranslationEntryVersion.EntryVersion,
association: db.TranslationArtifactVersion.ArtifactVersion,
required: true,
include: [
{
association: db.EntryVersion.Chapters,
association: db.ArtifactVersion.Chapters,
required: true,
include: [
{
@@ -234,31 +234,31 @@ module.exports = function (options) {
]
},
{
association: db.EntryVersion.Entry,
association: db.ArtifactVersion.Artifact,
include: [
{
association: db.Entry.Dialect
association: db.Artifact.Dialect
}
]
}
]
}
]
}).then((translationEntryVersion) => {
if (translationEntryVersion) {
}).then((translationArtifactVersion) => {
if (translationArtifactVersion) {
// TODO: Create a backTranslation...
backTranslatedEntry = {}
backTranslatedArtifact = {}
return db.BackTranslation.create({
translationEntryVersionId: translationEntryVersion.id,
entry: {
name: translationEntryVersion.name + translationEntryVersion.entryVersion.entry.name,
translationArtifactVersionId: translationArtifactVersion.id,
artifact: {
name: translationArtifactVersion.name + translationArtifactVersion.artifactVersion.artifact.name,
url: `/translate/${request.params.id}`,
dialectId: translationEntryVersion.dialectId,
dialectId: translationArtifactVersion.dialectId,
licenseId: "copyright", // Should be closed because it's a back translation not meant to be published
entryVersions: [
artifactVersions: [
{
tag: translationEntryVersion.entryVersion.tag,
chapters: translationEntryVersion.entryVersion.chapters.map(chapter => {
tag: translationArtifactVersion.artifactVersion.tag,
chapters: translationArtifactVersion.artifactVersion.chapters.map(chapter => {
return {
name: chapter.chunks[0].translation.text, // TODO: This isn't important...
chunks: chapter.chunks.map(chunk => {
@@ -269,10 +269,10 @@ module.exports = function (options) {
})
}
}),
translationEntryVersions: [
translationArtifactVersions: [
{
dialectId: translationEntryVersion.entryVersion.entry.dialect.id,
name: translationEntryVersion.entryVersion.entry.dialect.name
dialectId: translationArtifactVersion.artifactVersion.artifact.dialect.id,
name: translationArtifactVersion.artifactVersion.artifact.dialect.name
}
]
}
@@ -281,13 +281,13 @@ module.exports = function (options) {
}, {
include: [
{
association: db.BackTranslation.Entry,
association: db.BackTranslation.Artifact,
include: [
{
association: db.Entry.EntryVersions,
association: db.Artifact.ArtifactVersions,
include: [
{
association: db.EntryVersion.Chapters,
association: db.ArtifactVersion.Chapters,
include: [
{
association: db.Chapter.Chunks
@@ -295,7 +295,7 @@ module.exports = function (options) {
]
},
{
association: db.EntryVersion.TranslationEntryVersions
association: db.ArtifactVersion.TranslationArtifactVersions
}
]
}
@@ -308,7 +308,7 @@ module.exports = function (options) {
}
}).then(backTranslation => {
if (backTranslation) {
response.redirect(`/library/${backTranslation.entryId}`)
response.redirect(`/library/${backTranslation.artifactId}`)
} else {
// TODO: Let user know we cannot back translate
response.redirect(`/translate/${request.params.id}`)
@@ -320,25 +320,25 @@ module.exports = function (options) {
router.route('/:id/campaign')
.get(function(request, response, next) {
db.TranslationEntryVersion.findByPk(request.params.id, {
db.TranslationArtifactVersion.findByPk(request.params.id, {
include: [
{
association: db.TranslationEntryVersion.TranslationEntryVersionCampaigns,
association: db.TranslationArtifactVersion.TranslationArtifactVersionCampaigns,
required: true,
include: [
{
association: db.TranslationEntryVersionCampaign.Campaign,
association: db.TranslationArtifactVersionCampaign.Campaign,
required: true
}
]
}
]
}).then(translationEntryVersion => {
if (translationEntryVersion) {
if (translationEntryVersion.translationEntryVersionCampaings.length == 1) {
response.redirect(`/campaigns/${translationEntryVersion.translationEntryVersionCampaings[0].campaignId}`)
}).then(translationArtifactVersion => {
if (translationArtifactVersion) {
if (translationArtifactVersion.translationArtifactVersionCampaings.length == 1) {
response.redirect(`/campaigns/${translationArtifactVersion.translationArtifactVersionCampaings[0].campaignId}`)
} else {
// TODO: Display translation entry campaign...
// TODO: Display translation artifact campaign...
next()
}
} else {
@@ -349,36 +349,36 @@ module.exports = function (options) {
router.route('/:id/campaign/create')
.get(function(request, response, next) {
db.TranslationEntryVersion.findByPk(request.params.id, {
db.TranslationArtifactVersion.findByPk(request.params.id, {
include: [
{
association: db.TranslationEntryVersion.EntryVersion,
association: db.TranslationArtifactVersion.ArtifactVersion,
include: [
{
association: db.EntryVersion.Entry
association: db.ArtifactVersion.Artifact
}
]
},
{
association: db.TranslationEntryVersion.TranslationEntryVersionCampaigns,
association: db.TranslationArtifactVersion.TranslationArtifactVersionCampaigns,
required: false,
include: [
{
association: db.TranslationEntryVersionCampaign.Campaign,
association: db.TranslationArtifactVersionCampaign.Campaign,
required: false
}
]
}
]
}).then(translationEntryVersion => {
if (translationEntryVersion) {
}).then(translationArtifactVersion => {
if (translationArtifactVersion) {
response.display("campaign-form", {
user: request.user,
pageTitle: "Campaign - Mantra",
campaign: {
name: `Campaign for ${translationEntryVersion.name} translation of ${translationEntryVersion.entryVersion.entry.name}`
name: `Campaign for ${translationArtifactVersion.name} translation of ${translationArtifactVersion.artifactVersion.artifact.name}`
},
translationEntryVersions: [translationEntryVersion]
translationArtifactVersions: [translationArtifactVersion]
})
} else {
next()
+64 -63
View File
@@ -7,29 +7,29 @@ module.exports = function (options) {
router.route('/:id')
.get(function(request, response, next) {
db.EntryVersion.findByPk(request.params.id, {
db.ArtifactVersion.findByPk(request.params.id, {
include: [
{
association: db.EntryVersion.Entry,
association: db.ArtifactVersion.Artifact,
include: [
{
association: db.Entry.EntryApproval
association: db.Artifact.ArtifactApproval
}
]
},
{
association: db.EntryVersion.Chapters
association: db.ArtifactVersion.Chapters
},
{
association: db.EntryVersion.TranslationEntryVersions
association: db.ArtifactVersion.TranslationArtifactVersions
}
]
}).then(entryVersion => {
if (entryVersion) {
response.display("entry-version", {
}).then(artifactVersion => {
if (artifactVersion) {
response.display("artifact-version", {
user: request.user,
pageTitle: "Entry - Mantra",
entryVersion: entryVersion
pageTitle: "Artifact - Mantra",
artifactVersion: artifactVersion
})
} else {
next()
@@ -41,26 +41,26 @@ module.exports = function (options) {
router.route('/:id/chapters/add')
.get(function(request, response, next) {
db.EntryVersion.findByPk(request.params.id, {
db.ArtifactVersion.findByPk(request.params.id, {
include: [
{
association: db.EntryVersion.Entry,
association: db.ArtifactVersion.Artifact,
include: [
{
association: db.Entry.EntryApproval
association: db.Artifact.ArtifactApproval
}
]
},
{
association: db.EntryVersion.Chapters
association: db.ArtifactVersion.Chapters
}
]
}).then(entryVersion => {
if (entryVersion) {
}).then(artifactVersion => {
if (artifactVersion) {
response.display("chapter-form", {
user: request.user,
pageTitle: "Library - Mantra",
entryVersion: entryVersion
artifactVersion: artifactVersion
})
} else {
next()
@@ -71,27 +71,27 @@ module.exports = function (options) {
})
})
.post(function(request, response, next) {
db.EntryVersion.findByPk(request.params.id, {
db.ArtifactVersion.findByPk(request.params.id, {
include: [
{
association: db.EntryVersion.Entry,
association: db.ArtifactVersion.Artifact,
include: [
{
association: db.Entry.EntryApproval
association: db.Artifact.ArtifactApproval
}
]
},
{
association: db.EntryVersion.Chapters
association: db.ArtifactVersion.Chapters
}
]
}).then(entryVersion => {
}).then(artifactVersion => {
const isString = typeof request.body.text === "string" || request.body.text instanceof String
if (entryVersion && isString) {
if (artifactVersion && isString) {
const chunks = request.body.text.trim().split(/\r?\n\r?\n/)
db.Chapter.create({
name: chunks[0].trim(),
entryVersionId: entryVersion.id,
artifactVersionId: artifactVersion.id,
chunks: chunks.map((chunk,index) => {
return {
text: chunk,
@@ -106,12 +106,12 @@ module.exports = function (options) {
]
}).then(chapter => {
if (chapter) {
response.redirect(`/v/${chapter.entryVersionId}/chapters/${chapter.id}`)
response.redirect(`/v/${chapter.artifactVersionId}/chapters/${chapter.id}`)
} else {
response.display("chapter-form", {
user: request.user,
pageTitle: "Library - Mantra",
entryVersion: entryVersion
artifactVersion: artifactVersion
})
}
}).catch(error => {
@@ -134,10 +134,10 @@ module.exports = function (options) {
association: db.Chapter.Chunks
},
{
association: db.Chapter.EntryVersion,
association: db.Chapter.ArtifactVersion,
include: [
{
association: db.EntryVersion.Entry
association: db.ArtifactVersion.Artifact
}
]
}
@@ -157,28 +157,28 @@ module.exports = function (options) {
})
})
router.route('/:id/translations/:translationEntryVersionId')
router.route('/:id/translations/:translationArtifactVersionId')
.get(function(request, response, next) {
db.TranslationEntryVersion.findByPk(request.params.translationEntryVersionId, {
db.TranslationArtifactVersion.findByPk(request.params.translationArtifactVersionId, {
include: [
{
association: db.TranslationEntryVersion.EntryVersion,
association: db.TranslationArtifactVersion.ArtifactVersion,
include: [
{
association: db.EntryVersion.Entry
association: db.ArtifactVersion.Artifact
}
]
},
{
association: db.TranslationEntryVersion.ForkedFrom
association: db.TranslationArtifactVersion.ForkedFrom
}
]
}).then(translationEntryVersion => {
if (translationEntryVersion) {
response.display("translation-entry-version", {
}).then(translationArtifactVersion => {
if (translationArtifactVersion) {
response.display("translation-artifact-version", {
user: request.user,
pageTitle: "Translation Entry - Mantra",
translationEntryVersion: translationEntryVersion,
pageTitle: "Translation Artifact - Mantra",
translationArtifactVersion: translationArtifactVersion,
})
} else {
next()
@@ -190,26 +190,26 @@ module.exports = function (options) {
router.route('/:id/translations/add')
.get(function(request, response, next) {
db.EntryVersion.findByPk(request.params.id, {
db.ArtifactVersion.findByPk(request.params.id, {
include: [
{
association: db.EntryVersion.Entry,
association: db.ArtifactVersion.Artifact,
include: [
{
association: db.Entry.EntryApproval
association: db.Artifact.ArtifactApproval
}
]
},
{
association: db.EntryVersion.TranslationEntryVersions
association: db.ArtifactVersion.TranslationArtifactVersions
}
]
}).then(entryVersion => {
if (entryVersion) {
}).then(artifactVersion => {
if (artifactVersion) {
response.display("translation-form", {
user: request.user,
pageTitle: "Library - Mantra",
entryVersion: entryVersion
artifactVersion: artifactVersion
})
} else {
next()
@@ -220,22 +220,22 @@ module.exports = function (options) {
})
})
.post(function(request, response, next) {
db.EntryVersion.findByPk(request.params.id, {
db.ArtifactVersion.findByPk(request.params.id, {
include: [
{
association: db.EntryVersion.Entry,
association: db.ArtifactVersion.Artifact,
include: [
{
association: db.Entry.EntryApproval
association: db.Artifact.ArtifactApproval
}
]
},
{
association: db.EntryVersion.TranslationEntryVersions
association: db.ArtifactVersion.TranslationArtifactVersions
}
]
}).then(async (entryVersion) => {
if (entryVersion) {
}).then(async (artifactVersion) => {
if (artifactVersion) {
const dialectTokens = request.body.dialect?.split(":")
if (dialectTokens?.length == 2) {
const countryId = dialectTokens[0].split("-")[0]
@@ -249,14 +249,15 @@ module.exports = function (options) {
})
if (dialect) {
const translationEntryVersion = await db.TranslationEntryVersion.create({
const translationArtifactVersion = await db.TranslationArtifactVersion.create({
name: dialect.name,
entryVersionId: entryVersion.id,
dialectId: dialect.id
artifactVersionId: artifactVersion.id,
dialectId: dialect.id,
entityId: request.user.individualEntityUser.entityUser.entityId
})
if (translationEntryVersion) {
return response.redirect(`/v/${entryVersion.id}/translations/${translationEntryVersion.id}`)
if (translationArtifactVersion) {
return response.redirect(`/v/${artifactVersion.id}/translations/${translationArtifactVersion.id}`)
}
}
}
@@ -269,24 +270,24 @@ module.exports = function (options) {
router.route('/:id/campaign/create')
.get(function(request, response, next) {
db.EntryVersion.findByPk(request.params.id, {
db.ArtifactVersion.findByPk(request.params.id, {
include: [
{
association: db.EntryVersion.Entry,
association: db.ArtifactVersion.Artifact,
},
{
association: db.EntryVersion.TranslationEntryVersions
association: db.ArtifactVersion.TranslationArtifactVersions
}
]
}).then(entryVersion => {
if (entryVersion) {
}).then(artifactVersion => {
if (artifactVersion) {
response.display("campaign-form", {
user: request.user,
pageTitle: "Campaign - Mantra",
campaign: {
name: `Campaign for ${entryVersion.translationEntryVersions.length} translations of ${entryVersion.entry.name}`
name: `Campaign for ${artifactVersion.translationArtifactVersions.length} translations of ${artifactVersion.artifact.name}`
},
translationEntryVersions: entryVersion.translationEntryVersions
translationArtifactVersions: artifactVersion.translationArtifactVersions
})
} else {
next()
+16 -1
View File
@@ -180,6 +180,19 @@ module.exports = function () {
// }
}
]
},
{
association: db.User.IndividualEntityUser,
include: [
{
association: db.IndividualEntityUser.EntityUser,
include: [
{
association: db.EntityUser.Entity
}
]
}
]
}
]
})
@@ -195,7 +208,7 @@ module.exports = function () {
sessionStore.sync();
// TODO: Create a load router module...
// TODO: check that user has an individualEntityUser....
var router = require('./router/index.js')({
app: app,
express: express,
@@ -204,6 +217,8 @@ module.exports = function () {
});
app.use('/', router);
// 404 pages...
app.use((request, response, next) => {
+39 -39
View File
@@ -1,8 +1,8 @@
/*!
* Materialize v1.0.0 (http://materializecss.com)
* Copyright 2014-2017 Materialize
* MIT License (https://raw.githubusercontent.com/Dogfalo/materialize/master/LICENSE)
*/
/*!
* Materialize v1.0.0 (http://materializecss.com)
* Copyright 2014-2017 Materialize
* MIT License (https://raw.githubusercontent.com/Dogfalo/materialize/master/LICENSE)
*/
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -4771,13 +4771,13 @@ $jscomp.polyfill = function (e, r, p, m) {
M.initializeJqueryWrapper(Tooltip, 'tooltip', 'M_Tooltip');
}
})(cash, M.anime);
; /*!
* Waves v0.6.4
* http://fian.my.id/Waves
*
* Copyright 2014 Alfiana E. Sibuea and other contributors
* Released under the MIT license
* https://github.com/fians/Waves/blob/master/LICENSE
; /*!
* Waves v0.6.4
* http://fian.my.id/Waves
*
* Copyright 2014 Alfiana E. Sibuea and other contributors
* Released under the MIT license
* https://github.com/fians/Waves/blob/master/LICENSE
*/
;(function (window) {
@@ -4987,13 +4987,13 @@ $jscomp.polyfill = function (e, r, p, m) {
}
};
/**
* Disable mousedown event for 500ms during and after touch
/**
* Disable mousedown event for 500ms during and after touch
*/
var TouchHandler = {
/* uses an integer rather than bool so there's no issues with
* needing to clear timeouts if another touch event occurred
* within the 500ms. Cannot mouseup between touchstart and
/* uses an integer rather than bool so there's no issues with
* needing to clear timeouts if another touch event occurred
* within the 500ms. Cannot mouseup between touchstart and
* touchend, nor in the 500ms after touchend. */
touches: 0,
allowEvent: function (e) {
@@ -5018,9 +5018,9 @@ $jscomp.polyfill = function (e, r, p, m) {
}
};
/**
* Delegated click handler for .waves-effect element.
* returns null when .waves-effect element not in "click tree"
/**
* Delegated click handler for .waves-effect element.
* returns null when .waves-effect element not in "click tree"
*/
function getWavesEffectElement(e) {
if (TouchHandler.allowEvent(e) === false) {
@@ -5040,8 +5040,8 @@ $jscomp.polyfill = function (e, r, p, m) {
return element;
}
/**
* Bubble the click and show effect if .waves-effect elem was found
/**
* Bubble the click and show effect if .waves-effect elem was found
*/
function showEffect(e) {
var element = getWavesEffectElement(e);
@@ -5077,11 +5077,11 @@ $jscomp.polyfill = function (e, r, p, m) {
document.body.addEventListener('mousedown', showEffect, false);
};
/**
* Attach Waves to an input element (or any element which doesn't
* bubble mouseup/mousedown events).
* Intended to be used with dynamically loaded forms/inputs, or
* where the user doesn't want a delegated click handler.
/**
* Attach Waves to an input element (or any element which doesn't
* bubble mouseup/mousedown events).
* Intended to be used with dynamically loaded forms/inputs, or
* where the user doesn't want a delegated click handler.
*/
Waves.attach = function (element) {
//FUTURE: automatically add waves classes and allow users
@@ -6789,11 +6789,11 @@ $jscomp.polyfill = function (e, r, p, m) {
break;
}
var entry = {
var artifact = {
data: data[key],
key: key
};
matchingData.push(entry);
matchingData.push(artifact);
this.count++;
}
@@ -6809,12 +6809,12 @@ $jscomp.polyfill = function (e, r, p, m) {
// Render
for (var i = 0; i < matchingData.length; i++) {
var _entry = matchingData[i];
var _artifact = matchingData[i];
var $autocompleteOption = $('<li></li>');
if (!!_entry.data) {
$autocompleteOption.append("<img src=\"" + _entry.data + "\" class=\"right circle\"><span>" + _entry.key + "</span>");
if (!!_artifact.data) {
$autocompleteOption.append("<img src=\"" + _artifact.data + "\" class=\"right circle\"><span>" + _artifact.key + "</span>");
} else {
$autocompleteOption.append('<span>' + _entry.key + '</span>');
$autocompleteOption.append('<span>' + _artifact.key + '</span>');
}
$(this.container).append($autocompleteOption);
@@ -11728,9 +11728,9 @@ $jscomp.polyfill = function (e, r, p, m) {
if (placeholderOption.length) {
placeholderOption.removeClass('selected');
placeholderOption.find('input[type="checkbox"]').prop('checked', false);
this._toggleEntryFromArray(placeholderOption[0].id);
this._toggleArtifactFromArray(placeholderOption[0].id);
}
selected = this._toggleEntryFromArray(key);
selected = this._toggleArtifactFromArray(key);
} else {
$(this.dropdownOptions).find('li').removeClass('selected');
$(option).toggleClass('selected', selected);
@@ -11931,14 +11931,14 @@ $jscomp.polyfill = function (e, r, p, m) {
}
/**
* Toggle entry from option
* Toggle artifact from option
* @param {String} key Option key
* @return {Boolean} if entry was added or removed
* @return {Boolean} if artifact was added or removed
*/
}, {
key: "_toggleEntryFromArray",
value: function _toggleEntryFromArray(key) {
key: "_toggleArtifactFromArray",
value: function _toggleArtifactFromArray(key) {
var notAdded = !this._keysSelected.hasOwnProperty(key);
var $optionLi = $(this._valueDict[key].optionEl);
+1 -1
View File
@@ -3,4 +3,4 @@
* Copyright 2014-2017 Materialize
* MIT License (https://raw.githubusercontent.com/Dogfalo/materialize/master/LICENSE)
*/
var _get=function t(e,i,n){null===e&&(e=Function.prototype);var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s)return s.value;var a=s.get;return void 0!==a?a.call(n):void 0},_createClass=function(){function n(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}}();function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}window.cash=function(){var i,o=document,a=window,t=Array.prototype,r=t.slice,n=t.filter,s=t.push,e=function(){},h=function(t){return typeof t==typeof e&&t.call},d=function(t){return"string"==typeof t},l=/^#[\w-]*$/,u=/^\.[\w-]*$/,c=/<.+>/,p=/^\w+$/;function v(t,e){e=e||o;var i=u.test(t)?e.getElementsByClassName(t.slice(1)):p.test(t)?e.getElementsByTagName(t):e.querySelectorAll(t);return i}function f(t){if(!i){var e=(i=o.implementation.createHTMLDocument(null)).createElement("base");e.href=o.location.href,i.head.appendChild(e)}return i.body.innerHTML=t,i.body.childNodes}function m(t){"loading"!==o.readyState?t():o.addEventListener("DOMContentLoaded",t)}function g(t,e){if(!t)return this;if(t.cash&&t!==a)return t;var i,n=t,s=0;if(d(t))n=l.test(t)?o.getElementById(t.slice(1)):c.test(t)?f(t):v(t,e);else if(h(t))return m(t),this;if(!n)return this;if(n.nodeType||n===a)this[0]=n,this.length=1;else for(i=this.length=n.length;s<i;s++)this[s]=n[s];return this}function _(t,e){return new g(t,e)}var y=_.fn=_.prototype=g.prototype={cash:!0,length:0,push:s,splice:t.splice,map:t.map,init:g};function k(t,e){for(var i=t.length,n=0;n<i&&!1!==e.call(t[n],t[n],n,t);n++);}function b(t,e){var i=t&&(t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector);return!!i&&i.call(t,e)}function w(e){return d(e)?b:e.cash?function(t){return e.is(t)}:function(t,e){return t===e}}function C(t){return _(r.call(t).filter(function(t,e,i){return i.indexOf(t)===e}))}Object.defineProperty(y,"constructor",{value:_}),_.parseHTML=f,_.noop=e,_.isFunction=h,_.isString=d,_.extend=y.extend=function(t){t=t||{};var e=r.call(arguments),i=e.length,n=1;for(1===e.length&&(t=this,n=0);n<i;n++)if(e[n])for(var s in e[n])e[n].hasOwnProperty(s)&&(t[s]=e[n][s]);return t},_.extend({merge:function(t,e){for(var i=+e.length,n=t.length,s=0;s<i;n++,s++)t[n]=e[s];return t.length=n,t},each:k,matches:b,unique:C,isArray:Array.isArray,isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)}});var E=_.uid="_cash"+Date.now();function M(t){return t[E]=t[E]||{}}function O(t,e,i){return M(t)[e]=i}function x(t,e){var i=M(t);return void 0===i[e]&&(i[e]=t.dataset?t.dataset[e]:_(t).attr("data-"+e)),i[e]}y.extend({data:function(e,i){if(d(e))return void 0===i?x(this[0],e):this.each(function(t){return O(t,e,i)});for(var t in e)this.data(t,e[t]);return this},removeData:function(s){return this.each(function(t){return i=s,void((n=M(e=t))?delete n[i]:e.dataset?delete e.dataset[i]:_(e).removeAttr("data-"+name));var e,i,n})}});var L=/\S+/g;function T(t){return d(t)&&t.match(L)}function $(t,e){return t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.className)}function B(t,e,i){t.classList?t.classList.add(e):i.indexOf(" "+e+" ")&&(t.className+=" "+e)}function D(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(e,"")}y.extend({addClass:function(t){var n=T(t);return n?this.each(function(e){var i=" "+e.className+" ";k(n,function(t){B(e,t,i)})}):this},attr:function(e,i){if(e){if(d(e))return void 0===i?this[0]?this[0].getAttribute?this[0].getAttribute(e):this[0][e]:void 0:this.each(function(t){t.setAttribute?t.setAttribute(e,i):t[e]=i});for(var t in e)this.attr(t,e[t]);return this}},hasClass:function(t){var e=!1,i=T(t);return i&&i.length&&this.each(function(t){return!(e=$(t,i[0]))}),e},prop:function(e,i){if(d(e))return void 0===i?this[0][e]:this.each(function(t){t[e]=i});for(var t in e)this.prop(t,e[t]);return this},removeAttr:function(e){return this.each(function(t){t.removeAttribute?t.removeAttribute(e):delete t[e]})},removeClass:function(t){if(!arguments.length)return this.attr("class","");var i=T(t);return i?this.each(function(e){k(i,function(t){D(e,t)})}):this},removeProp:function(e){return this.each(function(t){delete t[e]})},toggleClass:function(t,e){if(void 0!==e)return this[e?"addClassLine truncated
var _get=function t(e,i,n){null===e&&(e=Function.prototype);var s=Object.getOwnPropertyDescriptor(e,i);if(void 0===s){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,i,n)}if("value"in s)return s.value;var a=s.get;return void 0!==a?a.call(n):void 0},_createClass=function(){function n(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}}();function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}window.cash=function(){var i,o=document,a=window,t=Array.prototype,r=t.slice,n=t.filter,s=t.push,e=function(){},h=function(t){return typeof t==typeof e&&t.call},d=function(t){return"string"==typeof t},l=/^#[\w-]*$/,u=/^\.[\w-]*$/,c=/<.+>/,p=/^\w+$/;function v(t,e){e=e||o;var i=u.test(t)?e.getElementsByClassName(t.slice(1)):p.test(t)?e.getElementsByTagName(t):e.querySelectorAll(t);return i}function f(t){if(!i){var e=(i=o.implementation.createHTMLDocument(null)).createElement("base");e.href=o.location.href,i.head.appendChild(e)}return i.body.innerHTML=t,i.body.childNodes}function m(t){"loading"!==o.readyState?t():o.addEventListener("DOMContentLoaded",t)}function g(t,e){if(!t)return this;if(t.cash&&t!==a)return t;var i,n=t,s=0;if(d(t))n=l.test(t)?o.getElementById(t.slice(1)):c.test(t)?f(t):v(t,e);else if(h(t))return m(t),this;if(!n)return this;if(n.nodeType||n===a)this[0]=n,this.length=1;else for(i=this.length=n.length;s<i;s++)this[s]=n[s];return this}function _(t,e){return new g(t,e)}var y=_.fn=_.prototype=g.prototype={cash:!0,length:0,push:s,splice:t.splice,map:t.map,init:g};function k(t,e){for(var i=t.length,n=0;n<i&&!1!==e.call(t[n],t[n],n,t);n++);}function b(t,e){var i=t&&(t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector);return!!i&&i.call(t,e)}function w(e){return d(e)?b:e.cash?function(t){return e.is(t)}:function(t,e){return t===e}}function C(t){return _(r.call(t).filter(function(t,e,i){return i.indexOf(t)===e}))}Object.defineProperty(y,"constructor",{value:_}),_.parseHTML=f,_.noop=e,_.isFunction=h,_.isString=d,_.extend=y.extend=function(t){t=t||{};var e=r.call(arguments),i=e.length,n=1;for(1===e.length&&(t=this,n=0);n<i;n++)if(e[n])for(var s in e[n])e[n].hasOwnProperty(s)&&(t[s]=e[n][s]);return t},_.extend({merge:function(t,e){for(var i=+e.length,n=t.length,s=0;s<i;n++,s++)t[n]=e[s];return t.length=n,t},each:k,matches:b,unique:C,isArray:Array.isArray,isNumeric:function(t){return!isNaN(parseFloat(t))&&isFinite(t)}});var E=_.uid="_cash"+Date.now();function M(t){return t[E]=t[E]||{}}function O(t,e,i){return M(t)[e]=i}function x(t,e){var i=M(t);return void 0===i[e]&&(i[e]=t.dataset?t.dataset[e]:_(t).attr("data-"+e)),i[e]}y.extend({data:function(e,i){if(d(e))return void 0===i?x(this[0],e):this.each(function(t){return O(t,e,i)});for(var t in e)this.data(t,e[t]);return this},removeData:function(s){return this.each(function(t){return i=s,void((n=M(e=t))?delete n[i]:e.dataset?delete e.dataset[i]:_(e).removeAttr("data-"+name));var e,i,n})}});var L=/\S+/g;function T(t){return d(t)&&t.match(L)}function $(t,e){return t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.className)}function B(t,e,i){t.classList?t.classList.add(e):i.indexOf(" "+e+" ")&&(t.className+=" "+e)}function D(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(e,"")}y.extend({addClass:function(t){var n=T(t);return n?this.each(function(e){var i=" "+e.className+" ";k(n,function(t){B(e,t,i)})}):this},attr:function(e,i){if(e){if(d(e))return void 0===i?this[0]?this[0].getAttribute?this[0].getAttribute(e):this[0][e]:void 0:this.each(function(t){t.setAttribute?t.setAttribute(e,i):t[e]=i});for(var t in e)this.attr(t,e[t]);return this}},hasClass:function(t){var e=!1,i=T(t);return i&&i.length&&this.each(function(t){return!(e=$(t,i[0]))}),e},prop:function(e,i){if(d(e))return void 0===i?this[0][e]:this.each(function(t){t[e]=i});for(var t in e)this.prop(t,e[t]);return this},removeAttr:function(e){return this.each(function(t){t.removeAttribute?t.removeAttribute(e):delete t[e]})},removeClass:function(t){if(!arguments.length)return this.attr("class","");var i=T(t);return i?this.each(function(e){k(i,function(t){D(e,t)})}):this},removeProp:function(e){return this.each(function(t){delete t[e]})},toggleClass:function(t,e){if(void 0!==e)return this[e?"addClassLine truncated
+41
View File
@@ -0,0 +1,41 @@
extend templates/layout.pug
block content
.container
.center
h1 #{artifactVersion.artifact.name}
h2 #{artifactVersion.tag}
.row
.col.s12
a.btn.black(href=`/fork/e/${artifactVersion.id}`) fork
.row
.col.s12
a.btn.black(href=`/v/${artifactVersion.id}/campaign/create`) funding campaign
.divider
.row
a.btn.black(href=`/v/${artifactVersion.id}/chapters/add`) add chapter
if artifactVersion.chapters.length == 0
p.flow-text No chapters added
else
.row
each chapter in artifactVersion.chapters
.col.s12
a(href=`/v/${artifactVersion.id}/chapters/${chapter.id}`)
.card-panel
p.flow-text= chapter.name
.divider
.row
a.btn.black(href=`/v/${artifactVersion.id}/translations/add`) add translation
if artifactVersion.translationArtifactVersions.length == 0
p.flow-text No chapters added
else
.row
each translationArtifact in artifactVersion.translationArtifactVersions
.col.s12
a(href=`/v/${artifactVersion.id}/translations/${translationArtifact.id}`)
.card-panel
p.flow-text= translationArtifact.name
+20
View File
@@ -0,0 +1,20 @@
extend templates/layout.pug
block content
.container
.center
h1= artifact.name
.divider
.row
a.btn.black(href=`/library/${artifact.id}/version/add`) add version
if artifact.artifactVersions.length == 0
p.flow-text No available versions
else
.row
each artifactVersion in artifact.artifactVersions
.col.s12
a(href=`/library/${artifactVersion.artifactId}/v/${artifactVersion.id}`)
.card-panel
p.flow-text= artifactVersion.tag
+5 -5
View File
@@ -16,11 +16,11 @@ block content
.col.s12.input-field
input(id=project.id+"-satoshis",type="number", name="satoshis", placeholder="100000 satoshis", step=1, min=1, max=2100000000000000, required)
label(for=project.id+"-satoshis") Default satoshi's goal for the #{project.name} translations
if translationEntryVersions
each translationEntryVersion in translationEntryVersions
input(type="hidden", name="translationEntryVersions", value=translationEntryVersion.id)
if translationArtifactVersions
each translationArtifactVersion in translationArtifactVersions
input(type="hidden", name="translationArtifactVersions", value=translationArtifactVersion.id)
.col.s12.input-field
input(id=translationEntryVersion.id+"-satoshis",type="number", name="satoshis", placeholder="100000 satoshis", step=1, min=1, max=2100000000000000, required)
label(for=translationEntryVersion.id+"-satoshis") Satoshi's required for the #{translationEntryVersion.name} translation
input(id=translationArtifactVersion.id+"-satoshis",type="number", name="satoshis", placeholder="100000 satoshis", step=1, min=1, max=2100000000000000, required)
label(for=translationArtifactVersion.id+"-satoshis") Satoshi's required for the #{translationArtifactVersion.name} translation
.col.s12
button.btn.black(type="submit") create campaign
+3 -3
View File
@@ -3,16 +3,16 @@ extend templates/layout.pug
block content
.container
.center
h1 Chapter in #{entryVersion.name}
h1 Chapter in #{artifactVersion.name}
.row
.col.s12
form.row(action=`/v/${entryVersion.id}/chapters/add`, method="post")
form.row(action=`/v/${artifactVersion.id}/chapters/add`, method="post")
.col.s12.input-field
textarea#textarea.materialize-textarea(name="text")
label(for="textarea") Entire chapter text (markdown)
.col.s12.input-field
input#index(type="number", name="index", value=entryVersion.chapters.length+1)
input#index(type="number", name="index", value=artifactVersion.chapters.length+1)
label(for="index") Chapter Number
.col.s12
button.btn.black(type="submit") add chapter
+1 -1
View File
@@ -6,7 +6,7 @@ block content
//- h1= chapter.name
a.btn.black(href=`/v/${chapter.entryVersionId}`) go to entry
a.btn.black(href=`/v/${chapter.artifactVersionId}`) go to artifact
.row
each chunk in chapter.chunks
-41
View File
@@ -1,41 +0,0 @@
extend templates/layout.pug
block content
.container
.center
h1 #{entryVersion.entry.name}
h2 #{entryVersion.tag}
.row
.col.s12
a.btn.black(href=`/fork/e/${entryVersion.id}`) fork
.row
.col.s12
a.btn.black(href=`/v/${entryVersion.id}/campaign/create`) funding campaign
.divider
.row
a.btn.black(href=`/v/${entryVersion.id}/chapters/add`) add chapter
if entryVersion.chapters.length == 0
p.flow-text No chapters added
else
.row
each chapter in entryVersion.chapters
.col.s12
a(href=`/v/${entryVersion.id}/chapters/${chapter.id}`)
.card-panel
p.flow-text= chapter.name
.divider
.row
a.btn.black(href=`/v/${entryVersion.id}/translations/add`) add translation
if entryVersion.translationEntryVersions.length == 0
p.flow-text No chapters added
else
.row
each translationEntry in entryVersion.translationEntryVersions
.col.s12
a(href=`/v/${entryVersion.id}/translations/${translationEntry.id}`)
.card-panel
p.flow-text= translationEntry.name
-20
View File
@@ -1,20 +0,0 @@
extend templates/layout.pug
block content
.container
.center
h1= entry.name
.divider
.row
a.btn.black(href=`/library/${entry.id}/version/add`) add version
if entry.entryVersions.length == 0
p.flow-text No available versions
else
.row
each entryVersion in entry.entryVersions
.col.s12
a(href=`/library/${entryVersion.entryId}/v/${entryVersion.id}`)
.card-panel
p.flow-text= entryVersion.tag
@@ -3,11 +3,11 @@ extend templates/layout.pug
block content
.container
.center
h1 Fork of #{entryVersion.entry.name}
h1 Fork of #{artifactVersion.artifact.name}
.row
.col.s12
form.row(action=`/fork/e/${entryVersion.id}`, method="post")
form.row(action=`/fork/e/${artifactVersion.id}`, method="post")
.col.s12.input-field
i.material-icons.prefix record_voice_over
+7 -7
View File
@@ -9,14 +9,14 @@ block content
.col.s12
form.row(action="/library/add", method="post")
.col.s12.input-field
input#name(type="text", name="name", value=entry.name)
label(for="name") Entry Name
input#name(type="text", name="name", value=artifact.name)
label(for="name") Artifact Name
.col.s12.input-field
input#url(type="text", name="url", value=entry.url)
label(for="url") Entry Url
if entry.id == null
input#url(type="text", name="url", value=artifact.url)
label(for="url") Artifact Url
if artifact.id == null
.col.s12.input-field
input#version(type="text", name="version", value=entry.version)
input#version(type="text", name="version", value=artifact.version)
label(for="version") First Version Number
.col.s12
button.btn.black(type="submit") add entry
button.btn.black(type="submit") add artifact
+4 -4
View File
@@ -5,13 +5,13 @@ block content
.center
h1 Library
a.btn.black(href="/library/add") add entry
a.btn.black(href="/library/add") add artifact
if entries.length == 0
p.flow-text No Literature currently on the system
else
.row
each entry in entries
each artifact in entries
.col.s12
a(href=`/library/${entry.id}`)
a(href=`/library/${artifact.id}`)
.card-panel
p.flow-text= entry.name
p.flow-text= artifact.name
@@ -3,7 +3,7 @@ extend templates/layout.pug
block content
.container
.center
h1 Add Entry to Project
h1 Add Artifact to Project
table
thead
@@ -12,11 +12,11 @@ block content
th Version
th
tbody
each entry in entries
each artifact in entries
tr
td= entry.name
td= entry.entryVersions[0].tag
td= artifact.name
td= artifact.artifactVersions[0].tag
td
form(action=`/projects/${project.id}/add-entry`, method="post")
input(type="hidden", name="entryVersionId", value=entry.entryVersions[0].id)
form(action=`/projects/${project.id}/add-artifact`, method="post")
input(type="hidden", name="artifactVersionId", value=artifact.artifactVersions[0].id)
button.btn.black(type="submit") add to project
+4 -4
View File
@@ -12,11 +12,11 @@ block content
th Version
th
tbody
each translationEntryVersion in translationEntryVersions
each translationArtifactVersion in translationArtifactVersions
tr
td #{translationEntryVersion.entryVersion.entry.name} - #{translationEntryVersion.name}
td= translationEntryVersion.entryVersion.tag
td #{translationArtifactVersion.artifactVersion.artifact.name} - #{translationArtifactVersion.name}
td= translationArtifactVersion.artifactVersion.tag
td
form(action=`/projects/${project.id}/add-translation`, method="post")
input(type="hidden", name="translationEntryVersionId", value=translationEntryVersion.id)
input(type="hidden", name="translationArtifactVersionId", value=translationArtifactVersion.id)
button.btn.black(type="submit") add to project
+7 -7
View File
@@ -17,17 +17,17 @@ block content
.divider
h2 Entries
each projectEntryVersion in project.projectEntryVersions
p.flow-text= projectEntryVersion.entryVersion.entry.name
each projectArtifactVersion in project.projectArtifactVersions
p.flow-text= projectArtifactVersion.artifactVersion.artifact.name
.row
.col.s12
a.btn.black(href=`/projects/${project.id}/add-entry`) add from library
a.btn.black(href=`/projects/${project.id}/add-artifact`) add from library
.divider
h2 Translation
each projectTranslationEntryVersion in project.projectTranslationEntryVersions
p.flow-text #{projectTranslationEntryVersion.translationEntryVersion.name} - #{projectTranslationEntryVersion.translationEntryVersion.entryVersion.entry.name}
each projectTranslationArtifactVersion in project.projectTranslationArtifactVersions
p.flow-text #{projectTranslationArtifactVersion.translationArtifactVersion.name} - #{projectTranslationArtifactVersion.translationArtifactVersion.artifactVersion.artifact.name}
.row
.col.s12
a.btn.black(href=`/projects/${project.id}/add-translation`) add translation
//- TODO: Show project translation entry versions
//- TODO: Show project entry versions
//- TODO: Show project translation artifact versions
//- TODO: Show project artifact versions
+6 -6
View File
@@ -3,8 +3,8 @@ extend templates/layout.pug
block content
.container
.center
h1= chapter.entryVersion.translationEntryVersions[0].name
h2= chapter.entryVersion.entry.name
h1= chapter.artifactVersion.translationArtifactVersions[0].name
h2= chapter.artifactVersion.artifact.name
//- TODO: List chunks in the chapter
.row
@@ -12,8 +12,8 @@ block content
table
thead
tr
th #{chapter.entryVersion.entry.dialect.name}
th #{chapter.entryVersion.translationEntryVersions[0].name}
th #{chapter.artifactVersion.artifact.dialect.name}
th #{chapter.artifactVersion.translationArtifactVersions[0].name}
th
tbody
@@ -31,6 +31,6 @@ block content
if chunk.translated
span nothing
else if chunk.translation
a.btn.blue(href=`/translate/${chapter.entryVersion.translationEntryVersions[0].id}/chapter/${chapter.id}/t/${chunk.index}`) edit
a.btn.blue(href=`/translate/${chapter.artifactVersion.translationArtifactVersions[0].id}/chapter/${chapter.id}/t/${chunk.index}`) edit
else
a.btn.black(href=`/translate/${chapter.entryVersion.translationEntryVersions[0].id}/chapter/${chapter.id}/t/${chunk.index}`) translate
a.btn.black(href=`/translate/${chapter.artifactVersion.translationArtifactVersions[0].id}/chapter/${chapter.id}/t/${chunk.index}`) translate
+10 -10
View File
@@ -4,10 +4,10 @@ block content
.container
.center
h1 Translate into
a(href=`/translate/${chunk.chapter.entryVersion.translationEntryVersions[0].id}/chapter/${chunk.chapter.id}`) #{chunk.chapter.entryVersion.translationEntryVersions[0].name}
a(href=`/translate/${chunk.chapter.artifactVersion.translationArtifactVersions[0].id}/chapter/${chunk.chapter.id}`) #{chunk.chapter.artifactVersion.translationArtifactVersions[0].name}
//- TODO: Show previous...
form.row(action=`/translate/${chunk.chapter.entryVersion.translationEntryVersions[0].id}/chapter/${chunk.chapter.id}/t/${chunk.index}`, method="post")
form.row(action=`/translate/${chunk.chapter.artifactVersion.translationArtifactVersions[0].id}/chapter/${chunk.chapter.id}/t/${chunk.index}`, method="post")
.col.s12.m6.input-field
textarea#original-text.materialize-textarea(name="originalText", readonly)= chunk.text
label(for="original-text") Original Text
@@ -33,8 +33,8 @@ block content
table
//- thead
tr
th #{chunk.chapter.entry.dialect.name}
th #{chunk.chapter.entry.translationEntryVersions[0].name}
th #{chunk.chapter.artifact.dialect.name}
th #{chunk.chapter.artifact.translationArtifactVersions[0].name}
th
tbody
tr
@@ -50,17 +50,17 @@ block content
if previousChunk.translated
span nothing
else if previousChunk.translation
a.btn.blue(href=`/translate/${previousChunk.chapter.entryVersion.translationEntryVersions[0].id}/chapter/${previousChunk.chapter.id}/t/${previousChunk.index}`) edit
a.btn.blue(href=`/translate/${previousChunk.chapter.artifactVersion.translationArtifactVersions[0].id}/chapter/${previousChunk.chapter.id}/t/${previousChunk.index}`) edit
else
a.btn.black(href=`/translate/${previousChunk.chapter.entryVersion.translationEntryVersions[0].id}/chapter/${previousChunk.chapter.id}/t/${previousChunk.index}`) previous translation
a.btn.black(href=`/translate/${previousChunk.chapter.artifactVersion.translationArtifactVersions[0].id}/chapter/${previousChunk.chapter.id}/t/${previousChunk.index}`) previous translation
if nextChunk
.col.s12#next-translation
table
//- thead
tr
th #{chunk.chapter.entry.dialect.name}
th #{chunk.chapter.entry.translationEntryVersions[0].name}
th #{chunk.chapter.artifact.dialect.name}
th #{chunk.chapter.artifact.translationArtifactVersions[0].name}
th
tbody
tr
@@ -76,9 +76,9 @@ block content
if nextChunk.translated
span nothing
else if nextChunk.translation
a.btn.blue(href=`/translate/${nextChunk.chapter.entryVersion.translationEntryVersions[0].id}/chapter/${nextChunk.chapter.id}/t/${nextChunk.index}`) edit
a.btn.blue(href=`/translate/${nextChunk.chapter.artifactVersion.translationArtifactVersions[0].id}/chapter/${nextChunk.chapter.id}/t/${nextChunk.index}`) edit
else
a.btn.black(href=`/translate/${nextChunk.chapter.entryVersion.translationEntryVersions[0].id}/chapter/${nextChunk.chapter.id}/t/${nextChunk.index}`) next translation
a.btn.black(href=`/translate/${nextChunk.chapter.artifactVersion.translationArtifactVersions[0].id}/chapter/${nextChunk.chapter.id}/t/${nextChunk.index}`) next translation
block additionalScripts
@@ -0,0 +1,32 @@
extend templates/layout.pug
block content
.container
.center
h1= translationArtifactVersion.name
h2= translationArtifactVersion.artifactVersion.artifact.name
if translationArtifactVersion.forkedFrom
p.flow-text is a
a(href=`/v/${translationArtifactVersion.forkedFrom.artifactVersionId}/translations/${translationArtifactVersion.forkedFrom.id}`) fork
//- TODO: Condition to show translate button
.row
.col.s12
a.btn.black(href=`/translate/${translationArtifactVersion.id}`) Translate
//- TODO: Condition to show fork button
.row
.col.s12
form(action=`/fork/t/${translationArtifactVersion.id}`, method="post")
button.btn.black(type="submit") fork
.row
.col.s12
form(action=`/translate/${translationArtifactVersion.id}/back`, method="post")
button.btn.black(type="submit") back translate
.row
.col.s12
a.btn.black(href=`/translate/${translationArtifactVersion.id}/campaign`) funding campaign
//- TODO: Give summary of chapters...
@@ -1,32 +0,0 @@
extend templates/layout.pug
block content
.container
.center
h1= translationEntryVersion.name
h2= translationEntryVersion.entryVersion.entry.name
if translationEntryVersion.forkedFrom
p.flow-text is a
a(href=`/v/${translationEntryVersion.forkedFrom.entryVersionId}/translations/${translationEntryVersion.forkedFrom.id}`) fork
//- TODO: Condition to show translate button
.row
.col.s12
a.btn.black(href=`/translate/${translationEntryVersion.id}`) Translate
//- TODO: Condition to show fork button
.row
.col.s12
form(action=`/fork/t/${translationEntryVersion.id}`, method="post")
button.btn.black(type="submit") fork
.row
.col.s12
form(action=`/translate/${translationEntryVersion.id}/back`, method="post")
button.btn.black(type="submit") back translate
.row
.col.s12
a.btn.black(href=`/translate/${translationEntryVersion.id}/campaign`) funding campaign
//- TODO: Give summary of chapters...
+2 -2
View File
@@ -3,11 +3,11 @@ extend templates/layout.pug
block content
.container
.center
h1 Translation of #{entryVersion.name}
h1 Translation of #{artifactVersion.name}
.row
.col.s12
form.row(action=`/v/${entryVersion.id}/translations/add`, method="post")
form.row(action=`/v/${artifactVersion.id}/translations/add`, method="post")
.col.s12.input-field
i.material-icons.prefix record_voice_over