From 2cdcb3af127bfa6680ddf97ae85cdf4ba87b4bfb Mon Sep 17 00:00:00 2001 From: azivner Date: Wed, 4 Apr 2018 23:04:31 -0400 Subject: [PATCH] camel casing and fixes --- bin/release.sh | 2 +- db/migrations/0085__camelCase_run_values.sql | 4 ++-- db/migrations/0086__camelCase_custom_labels.sql | 7 +++++++ src/public/javascripts/dialogs/options.js | 8 ++++---- src/routes/api/file_upload.js | 6 +++--- src/routes/api/notes.js | 5 ++++- src/services/app_info.js | 8 ++++---- src/services/build.js | 2 +- src/services/date_notes.js | 6 +++--- src/services/scheduler.js | 6 +++--- 10 files changed, 32 insertions(+), 22 deletions(-) create mode 100644 db/migrations/0086__camelCase_custom_labels.sql diff --git a/bin/release.sh b/bin/release.sh index 54feb31ee..5759da04d 100755 --- a/bin/release.sh +++ b/bin/release.sh @@ -24,7 +24,7 @@ jq '.version = "'$VERSION'"' package.json|sponge package.json git add package.json -echo 'module.exports = { build_date:"'`date --iso-8601=seconds`'", build_revision: "'`git log -1 --format="%H"`'" };' > services/build.js +echo 'module.exports = { buildDate:"'`date --iso-8601=seconds`'", buildRevision: "'`git log -1 --format="%H"`'" };' > services/build.js git add services/build.js diff --git a/db/migrations/0085__camelCase_run_values.sql b/db/migrations/0085__camelCase_run_values.sql index bfe0697e1..8754cef5d 100644 --- a/db/migrations/0085__camelCase_run_values.sql +++ b/db/migrations/0085__camelCase_run_values.sql @@ -1,2 +1,2 @@ -UPDATE labels SET name = 'frontendStartup' WHERE name = 'frontend_startup'; -UPDATE labels SET name = 'backendStartup' WHERE name = 'backend_startup'; +UPDATE labels SET value = 'frontendStartup' WHERE value = 'frontend_startup'; +UPDATE labels SET value = 'backendStartup' WHERE value = 'backend_startup'; diff --git a/db/migrations/0086__camelCase_custom_labels.sql b/db/migrations/0086__camelCase_custom_labels.sql new file mode 100644 index 000000000..a94a72e1e --- /dev/null +++ b/db/migrations/0086__camelCase_custom_labels.sql @@ -0,0 +1,7 @@ +UPDATE labels SET name = 'dateData' WHERE name = 'date_data'; +UPDATE labels SET name = 'dateNote' WHERE name = 'date_note'; +UPDATE labels SET name = 'fileSize' WHERE name = 'file_size'; +UPDATE labels SET name = 'hideInAutocomplete' WHERE name = 'hide_in_autocomplete'; +UPDATE labels SET name = 'monthNote' WHERE name = 'month_note'; +UPDATE labels SET name = 'originalFileName' WHERE name = 'original_file_name'; +UPDATE labels SET name = 'yearNote' WHERE name = 'year_note'; diff --git a/src/public/javascripts/dialogs/options.js b/src/public/javascripts/dialogs/options.js index 01a925518..92bcc3ead 100644 --- a/src/public/javascripts/dialogs/options.js +++ b/src/public/javascripts/dialogs/options.js @@ -142,11 +142,11 @@ addTabHandler((async function () { const appInfo = await server.get('app-info'); - $appVersion.html(appInfo.app_version); + $appVersion.html(appInfo.appVersion); $dbVersion.html(appInfo.dbVersion); - $buildDate.html(appInfo.build_date); - $buildRevision.html(appInfo.build_revision); - $buildRevision.attr('href', 'https://github.com/zadam/trilium/commit/' + appInfo.build_revision); + $buildDate.html(appInfo.buildDate); + $buildRevision.html(appInfo.buildRevision); + $buildRevision.attr('href', 'https://github.com/zadam/trilium/commit/' + appInfo.buildRevision); return {}; })()); diff --git a/src/routes/api/file_upload.js b/src/routes/api/file_upload.js index a3b978e09..5b4f40d8c 100644 --- a/src/routes/api/file_upload.js +++ b/src/routes/api/file_upload.js @@ -26,8 +26,8 @@ async function uploadFile(req) { mime: file.mimetype }); - await labelService.createLabel(note.noteId, "original_file_name", originalName); - await labelService.createLabel(note.noteId, "file_size", size); + await labelService.createLabel(note.noteId, "originalFileName", originalName); + await labelService.createLabel(note.noteId, "fileSize", size); return { noteId: note.noteId @@ -48,7 +48,7 @@ async function downloadFile(req, res) { } const labelMap = await note.getLabelMap(); - const fileName = labelMap.original_file_name ? labelMap.original_file_name : note.title; + const fileName = labelMap.originalFileName || note.title; res.setHeader('Content-Disposition', 'file; filename="' + fileName + '"'); res.setHeader('Content-Type', note.mime); diff --git a/src/routes/api/notes.js b/src/routes/api/notes.js index d73cc538f..099a67974 100644 --- a/src/routes/api/notes.js +++ b/src/routes/api/notes.js @@ -54,7 +54,10 @@ async function protectBranch(req) { } async function setNoteTypeMime(req) { - const [noteId, type, mime] = req.params; + // can't use [] destructuring because req.params is not iterable + const noteId = req.params[0]; + const type = req.params[1]; + const mime = req.params[2]; const note = await repository.getNote(noteId); note.type = type; diff --git a/src/services/app_info.js b/src/services/app_info.js index 294290e77..6e8298922 100644 --- a/src/services/app_info.js +++ b/src/services/app_info.js @@ -3,11 +3,11 @@ const build = require('./build'); const packageJson = require('../../package'); -const APP_DB_VERSION = 85; +const APP_DB_VERSION = 86; module.exports = { - app_version: packageJson.version, + appVersion: packageJson.version, dbVersion: APP_DB_VERSION, - build_date: build.build_date, - build_revision: build.build_revision + buildDate: build.buildDate, + buildRevision: build.buildRevision }; \ No newline at end of file diff --git a/src/services/build.js b/src/services/build.js index 0c97c844a..8ae8d02b4 100644 --- a/src/services/build.js +++ b/src/services/build.js @@ -1 +1 @@ -module.exports = { build_date:"2018-01-17T23:59:03-05:00", build_revision: "651a9fb3272c85d287c16d5a4978464fb7d2490d" }; +module.exports = { buildDate:"2018-01-17T23:59:03-05:00", buildRevision: "651a9fb3272c85d287c16d5a4978464fb7d2490d" }; diff --git a/src/services/date_notes.js b/src/services/date_notes.js index ec1ac8afc..10356f485 100644 --- a/src/services/date_notes.js +++ b/src/services/date_notes.js @@ -6,9 +6,9 @@ const labelService = require('./labels'); const dateUtils = require('./date_utils'); const CALENDAR_ROOT_LABEL = 'calendarRoot'; -const YEAR_LABEL = 'year_note'; -const MONTH_LABEL = 'month_note'; -const DATE_LABEL = 'date_note'; +const YEAR_LABEL = 'yearNote'; +const MONTH_LABEL = 'monthNote'; +const DATE_LABEL = 'dateNote'; const DAYS = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; const MONTHS = ['January','February','March','April','May','June','July','August','September','October','November','December']; diff --git a/src/services/scheduler.js b/src/services/scheduler.js index 8ba132293..c7ea04cab 100644 --- a/src/services/scheduler.js +++ b/src/services/scheduler.js @@ -19,8 +19,8 @@ async function runNotesWithLabel(runAttrValue) { } } -setTimeout(() => cls.wrap(() => runNotesWithLabel('backendStartup')), 10 * 1000); +setTimeout(cls.wrap(() => runNotesWithLabel('backendStartup')), 10 * 1000); -setInterval(() => cls.wrap(() => runNotesWithLabel('hourly')), 3600 * 1000); +setInterval(cls.wrap(() => runNotesWithLabel('hourly')), 3600 * 1000); -setInterval(() => cls.wrap(() => runNotesWithLabel('daily'), 24 * 3600 * 1000)); \ No newline at end of file +setInterval(cls.wrap(() => runNotesWithLabel('daily')), 24 * 3600 * 1000); \ No newline at end of file