1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +02:00

feat: Version 2

Closes #627, closes #1047
This commit is contained in:
Maksim Eltyshev 2025-05-10 02:09:06 +02:00
parent ad7fb51cfa
commit 2ee1166747
1557 changed files with 76832 additions and 47042 deletions

View file

@ -11,6 +11,15 @@
const { URL } = require('url');
const sails = require('sails');
const version = require('../version');
const envToNumber = (value) => {
const number = parseInt(value, 10);
return Number.isNaN(number) ? null : number;
};
const envToArray = (value) => (value ? value.split(',') : []);
const parsedBasedUrl = new URL(process.env.BASE_URL);
module.exports.custom = {
@ -20,6 +29,8 @@ module.exports.custom = {
*
*/
version,
baseUrl: process.env.BASE_URL,
baseUrlPath: parsedBasedUrl.pathname,
baseUrlSecure: parsedBasedUrl.protocol === 'https:',
@ -30,15 +41,17 @@ module.exports.custom = {
uploadsTempPath: null,
uploadsBasePath: sails.config.appPath,
preloadedFaviconsPathSegment: 'public/preloaded-favicons',
faviconsPathSegment: 'public/favicons',
userAvatarsPathSegment: 'public/user-avatars',
projectBackgroundImagesPathSegment: 'public/project-background-images',
backgroundImagesPathSegment: 'public/background-images',
attachmentsPathSegment: 'private/attachments',
defaultAdminEmail:
process.env.DEFAULT_ADMIN_EMAIL && process.env.DEFAULT_ADMIN_EMAIL.toLowerCase(),
activeUsersLimit: envToNumber(process.env.ACTIVE_USERS_LIMIT),
showDetailedAuthErrors: process.env.SHOW_DETAILED_AUTH_ERRORS === 'true',
allowAllToCreateProjects: process.env.ALLOW_ALL_TO_CREATE_PROJECTS === 'true',
s3Endpoint: process.env.S3_ENDPOINT,
s3Region: process.env.S3_REGION,
@ -55,7 +68,9 @@ module.exports.custom = {
oidcScopes: process.env.OIDC_SCOPES || 'openid email profile',
oidcResponseMode: process.env.OIDC_RESPONSE_MODE || 'fragment',
oidcUseDefaultResponseMode: process.env.OIDC_USE_DEFAULT_RESPONSE_MODE === 'true',
oidcAdminRoles: process.env.OIDC_ADMIN_ROLES ? process.env.OIDC_ADMIN_ROLES.split(',') : [],
oidcAdminRoles: envToArray(process.env.OIDC_ADMIN_ROLES),
oidcProjectOwnerRoles: envToArray(process.env.OIDC_PROJECT_OWNER_ROLES),
oidcBoardUserRoles: envToArray(process.env.OIDC_BOARD_USER_ROLES),
oidcClaimsSource: process.env.OIDC_CLAIMS_SOURCE || 'userinfo',
oidcEmailAttribute: process.env.OIDC_EMAIL_ATTRIBUTE || 'email',
oidcNameAttribute: process.env.OIDC_NAME_ATTRIBUTE || 'name',
@ -80,13 +95,4 @@ module.exports.custom = {
smtpTlsRejectUnauthorized: process.env.SMTP_TLS_REJECT_UNAUTHORIZED !== 'false',
webhooks: JSON.parse(process.env.WEBHOOKS || '[]'), // TODO: validate structure
slackBotToken: process.env.SLACK_BOT_TOKEN,
slackChannelId: process.env.SLACK_CHANNEL_ID,
googleChatWebhookUrl: process.env.GOOGLE_CHAT_WEBHOOK_URL,
telegramBotToken: process.env.TELEGRAM_BOT_TOKEN,
telegramChatId: process.env.TELEGRAM_CHAT_ID,
telegramThreadId: process.env.TELEGRAM_THREAD_ID,
};

View file

@ -48,6 +48,5 @@ module.exports.datastores = {
adapter: 'sails-postgresql',
url: process.env.DATABASE_URL,
schemaName: process.env.DATABASE_SCHEMA,
},
};

View file

@ -293,7 +293,7 @@ module.exports = {
*
*/
trustProxy: !!process.env.TRUST_PROXY,
trustProxy: process.env.TRUST_PROXY === 'true',
},
/**

View file

@ -19,7 +19,7 @@ module.exports.i18n = {
*
*/
locales: ['en', 'es', 'fr', 'de'],
locales: ['en-GB', 'en-US', 'ru-RU'],
/**
*
@ -30,7 +30,7 @@ module.exports.i18n = {
*
*/
// defaultLocale: 'en',
defaultLocale: process.env.DEFAULT_LANGUAGE || 'en-US',
/**
*

View file

@ -1,4 +0,0 @@
{
"Welcome": "Willkommen",
"A brand new app.": "Eine neue App."
}

View file

@ -0,0 +1,12 @@
{
"Card Created": "Card Created",
"Card Moved": "Card Moved",
"New Comment": "New Comment",
"Test Title": "Test Title",
"This is a test text message!": "This is a test text message!",
"This is a *test* **markdown** `message`!": "This is a *test* **markdown** `message`!",
"This is a <i>test</i> <b>html</b> <code>message</code>": "This is a <i>test</i> <b>html</b> <code>message</code>",
"%s created %s in %s on %s": "%s created %s in %s on %s",
"%s left a new comment to %s on %s": "%s left a new comment to %s on %s",
"%s moved %s from %s to %s on %s": "%s moved %s from %s to %s on %s"
}

View file

@ -0,0 +1,12 @@
{
"Card Created": "Card Created",
"Card Moved": "Card Moved",
"New Comment": "New Comment",
"Test Title": "Test Title",
"This is a test text message!": "This is a test text message!",
"This is a *test* **markdown** `message`!": "This is a *test* **markdown** `message`!",
"This is a <i>test</i> <b>html</b> <code>message</code>": "This is a <i>test</i> <b>html</b> <code>message</code>",
"%s created %s in %s on %s": "%s created %s in %s on %s",
"%s left a new comment to %s on %s": "%s left a new comment to %s on %s",
"%s moved %s from %s to %s on %s": "%s moved %s from %s to %s on %s"
}

View file

@ -1,4 +0,0 @@
{
"Welcome": "Welcome",
"A brand new app.": "A brand new app."
}

View file

@ -1,4 +0,0 @@
{
"Welcome": "Bienvenido",
"A brand new app.": "Una nueva aplicación."
}

View file

@ -1,4 +0,0 @@
{
"Welcome": "Bienvenue",
"A brand new app.": "Une toute nouvelle application."
}

View file

@ -0,0 +1,12 @@
{
"Card Created": "Карточка создана",
"Card Moved": "Карточка перемещена",
"New Comment": "Новый комментарий",
"Test Title": "Тестовый заголовок",
"This is a test text message!": "Это тестовое сообщение!",
"This is a *test* **markdown** `message`!": "Это *тестовое* **markdown** `сообщение`!",
"This is a <i>test</i> <b>html</b> <code>message</code>": "Это <i>тестовое</i> <b>html</b> <code>сообщение</code>",
"%s created %s in %s on %s": "%s создал(а) %s в %s на %s",
"%s left a new comment to %s on %s": "%s оставил(а) новый комментарий к %s на %s",
"%s moved %s from %s to %s on %s": "%s переместил(а) %s из %s в %s на %s"
}

View file

@ -123,4 +123,6 @@ module.exports.models = {
*/
// cascadeOnDestroy: true,
archiveModelIdentity: false,
};

View file

@ -21,7 +21,9 @@ module.exports.policies = {
'users/create': ['is-authenticated', 'is-admin'],
'users/delete': ['is-authenticated', 'is-admin'],
'show-config': true,
'projects/create': ['is-authenticated', 'is-admin-or-project-owner'],
'config/show': true,
'access-tokens/create': true,
'access-tokens/exchange-using-oidc': true,
'access-tokens/exchange-with-oidc': true,
};

View file

@ -1,6 +1,16 @@
/**
* Route Mappings
* (sails.config.routes)
*
* Your routes tell Sails what to do each time it receives a request.
*
* For more information on configuring custom routes, check out:
* https://sailsjs.com/anatomy/config/routes-js
*/
const path = require('path');
const serveStatic = require('serve-static');
const sails = require('sails');
const path = require('path');
// Remove prefix from urlPath, assuming completely matches a subpath of
// urlPath. The result preserves query params and fragment if present
@ -51,21 +61,11 @@ function staticDirServer(prefix, dirFn) {
};
}
/**
* Route Mappings
* (sails.config.routes)
*
* Your routes tell Sails what to do each time it receives a request.
*
* For more information on configuring custom routes, check out:
* https://sailsjs.com/anatomy/config/routes-js
*/
module.exports.routes = {
'GET /api/config': 'show-config',
'GET /api/config': 'config/show',
'POST /api/access-tokens': 'access-tokens/create',
'POST /api/access-tokens/exchange-using-oidc': 'access-tokens/exchange-using-oidc',
'POST /api/access-tokens/exchange-with-oidc': 'access-tokens/exchange-with-oidc',
'DELETE /api/access-tokens/me': 'access-tokens/delete',
'GET /api/users': 'users/index',
@ -82,18 +82,24 @@ module.exports.routes = {
'POST /api/projects': 'projects/create',
'GET /api/projects/:id': 'projects/show',
'PATCH /api/projects/:id': 'projects/update',
'POST /api/projects/:id/background-image': 'projects/update-background-image',
'DELETE /api/projects/:id': 'projects/delete',
'POST /api/projects/:projectId/managers': 'project-managers/create',
'POST /api/projects/:projectId/project-managers': 'project-managers/create',
'DELETE /api/project-managers/:id': 'project-managers/delete',
'POST /api/projects/:projectId/background-images': 'background-images/create',
'DELETE /api/background-images/:id': 'background-images/delete',
'POST /api/projects/:projectId/base-custom-field-groups': 'base-custom-field-groups/create',
'PATCH /api/base-custom-field-groups/:id': 'base-custom-field-groups/update',
'DELETE /api/base-custom-field-groups/:id': 'base-custom-field-groups/delete',
'POST /api/projects/:projectId/boards': 'boards/create',
'GET /api/boards/:id': 'boards/show',
'PATCH /api/boards/:id': 'boards/update',
'DELETE /api/boards/:id': 'boards/delete',
'POST /api/boards/:boardId/memberships': 'board-memberships/create',
'POST /api/boards/:boardId/board-memberships': 'board-memberships/create',
'PATCH /api/board-memberships/:id': 'board-memberships/update',
'DELETE /api/board-memberships/:id': 'board-memberships/delete',
@ -102,21 +108,31 @@ module.exports.routes = {
'DELETE /api/labels/:id': 'labels/delete',
'POST /api/boards/:boardId/lists': 'lists/create',
'GET /api/lists/:id': 'lists/show',
'PATCH /api/lists/:id': 'lists/update',
'POST /api/lists/:id/sort': 'lists/sort',
'POST /api/lists/:id/move-cards': 'lists/move-cards',
'POST /api/lists/:id/clear': 'lists/clear',
'DELETE /api/lists/:id': 'lists/delete',
'GET /api/lists/:listId/cards': 'cards/index',
'POST /api/lists/:listId/cards': 'cards/create',
'GET /api/cards/:id': 'cards/show',
'PATCH /api/cards/:id': 'cards/update',
'POST /api/cards/:id/duplicate': 'cards/duplicate',
'POST /api/cards/:id/read-notifications': 'cards/read-notifications',
'DELETE /api/cards/:id': 'cards/delete',
'POST /api/cards/:cardId/memberships': 'card-memberships/create',
'DELETE /api/cards/:cardId/memberships': 'card-memberships/delete',
'POST /api/cards/:cardId/labels': 'card-labels/create',
'DELETE /api/cards/:cardId/labels/:labelId': 'card-labels/delete',
'POST /api/cards/:cardId/card-memberships': 'card-memberships/create',
'DELETE /api/cards/:cardId/card-memberships/userId::userId': 'card-memberships/delete',
'POST /api/cards/:cardId/card-labels': 'card-labels/create',
'DELETE /api/cards/:cardId/card-labels/labelId::labelId': 'card-labels/delete',
'POST /api/cards/:cardId/tasks': 'tasks/create',
'POST /api/cards/:cardId/task-lists': 'task-lists/create',
'GET /api/task-lists/:id': 'task-lists/show',
'PATCH /api/task-lists/:id': 'task-lists/update',
'DELETE /api/task-lists/:id': 'task-lists/delete',
'POST /api/task-lists/:taskListId/tasks': 'tasks/create',
'PATCH /api/tasks/:id': 'tasks/update',
'DELETE /api/tasks/:id': 'tasks/delete',
@ -124,15 +140,61 @@ module.exports.routes = {
'PATCH /api/attachments/:id': 'attachments/update',
'DELETE /api/attachments/:id': 'attachments/delete',
'GET /api/cards/:cardId/actions': 'actions/index',
'POST /api/boards/:boardId/custom-field-groups': 'custom-field-groups/create-in-board',
'POST /api/cards/:cardId/custom-field-groups': 'custom-field-groups/create-in-card',
'GET /api/custom-field-groups/:id': 'custom-field-groups/show',
'PATCH /api/custom-field-groups/:id': 'custom-field-groups/update',
'DELETE /api/custom-field-groups/:id': 'custom-field-groups/delete',
'POST /api/cards/:cardId/comment-actions': 'comment-actions/create',
'PATCH /api/comment-actions/:id': 'comment-actions/update',
'DELETE /api/comment-actions/:id': 'comment-actions/delete',
'POST /api/base-custom-field-groups/:baseCustomFieldGroupId/custom-fields':
'custom-fields/create-in-base-custom-field-group',
'POST /api/custom-field-groups/:customFieldGroupId/custom-fields':
'custom-fields/create-in-custom-field-group',
'PATCH /api/custom-fields/:id': 'custom-fields/update',
'DELETE /api/custom-fields/:id': 'custom-fields/delete',
'PATCH /api/cards/:cardId/custom-field-values/customFieldGroupId::customFieldGroupId[:]customFieldId::customFieldId':
'custom-field-values/create-or-update',
'DELETE /api/cards/:cardId/custom-field-values/customFieldGroupId::customFieldGroupId[:]customFieldId::customFieldId':
'custom-field-values/delete',
'GET /api/cards/:cardId/comments': 'comments/index',
'POST /api/cards/:cardId/comments': 'comments/create',
'PATCH /api/comments/:id': 'comments/update',
'DELETE /api/comments/:id': 'comments/delete',
'GET /api/cards/:cardId/actions': 'actions/index',
'GET /api/notifications': 'notifications/index',
'GET /api/notifications/:id': 'notifications/show',
'PATCH /api/notifications/:ids': 'notifications/update',
'PATCH /api/notifications/:id': 'notifications/update',
'POST /api/notifications/read-all': 'notifications/read-all',
'POST /api/users/:userId/notification-services': 'notification-services/create-in-user',
'POST /api/boards/:boardId/notification-services': 'notification-services/create-in-board',
'PATCH /api/notification-services/:id': 'notification-services/update',
'POST /api/notification-services/:id/test': 'notification-services/test',
'DELETE /api/notification-services/:id': 'notification-services/delete',
'GET /preloaded-favicons/*': {
fn: staticDirServer('/preloaded-favicons', () =>
path.join(
path.resolve(sails.config.custom.uploadsBasePath),
sails.config.custom.preloadedFaviconsPathSegment,
),
),
skipAssets: false,
},
'GET /favicons/*': {
fn: staticDirServer('/favicons', () =>
path.join(
path.resolve(sails.config.custom.uploadsBasePath),
sails.config.custom.faviconsPathSegment,
),
),
skipAssets: false,
},
'GET /user-avatars/*': {
fn: staticDirServer('/user-avatars', () =>
@ -144,23 +206,23 @@ module.exports.routes = {
skipAssets: false,
},
'GET /project-background-images/*': {
fn: staticDirServer('/project-background-images', () =>
'GET /background-images/*': {
fn: staticDirServer('/background-images', () =>
path.join(
path.resolve(sails.config.custom.uploadsBasePath),
sails.config.custom.projectBackgroundImagesPathSegment,
sails.config.custom.backgroundImagesPathSegment,
),
),
skipAssets: false,
},
'GET /attachments/:id/download/:filename': {
action: 'attachments/download',
action: 'file-attachments/download',
skipAssets: false,
},
'GET /attachments/:id/download/thumbnails/cover-256.:extension': {
action: 'attachments/download-thumbnail',
'GET r|^/attachments/(\\w+)/download/thumbnails/([\\w-]+).(\\w+)$|id,fileName,fileExtension': {
action: 'file-attachments/download-thumbnail',
skipAssets: false,
},

View file

@ -24,7 +24,7 @@ module.exports.views = {
*
*/
extension: 'ejs',
extension: 'html',
/**
*
@ -36,5 +36,4 @@ module.exports.views = {
*/
layout: false,
locals: { BASE_URL: process.env.BASE_URL },
};