From 2540c2a6855267543d63e36e39e9325909fc3d9d Mon Sep 17 00:00:00 2001 From: harshil05133 Date: Mon, 17 Feb 2025 01:39:31 -0500 Subject: [PATCH 1/5] Changed the json file to include home button --- settings.json.docker | 2 +- settings.json.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/settings.json.docker b/settings.json.docker index da1d51c13..efd5b6176 100644 --- a/settings.json.docker +++ b/settings.json.docker @@ -643,7 +643,7 @@ "right": [ ["importexport", "timeslider", "savedrevision"], ["settings", "embed"], - ["showusers"] + ["showusers", "home"] ], "timeslider": [ ["timeslider_export", "timeslider_returnToPad"] diff --git a/settings.json.template b/settings.json.template index 2d856f42e..893a904b2 100644 --- a/settings.json.template +++ b/settings.json.template @@ -642,7 +642,7 @@ "right": [ ["importexport", "timeslider", "savedrevision"], ["settings", "embed"], - ["showusers"] + ["showusers", "home"] ], "timeslider": [ ["timeslider_export", "timeslider_returnToPad"] From 1e5b302a79a7f065fcfed789ed08b118a97f7da8 Mon Sep 17 00:00:00 2001 From: harshil05133 Date: Mon, 17 Feb 2025 02:13:02 -0500 Subject: [PATCH 2/5] Added keyboard shortcut for exit button, and added the option to the settings.ts file. --- settings.json.docker | 3 ++- settings.json.template | 3 ++- src/locales/en.json | 2 ++ src/node/utils/Settings.ts | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/settings.json.docker b/settings.json.docker index efd5b6176..3d04dadf7 100644 --- a/settings.json.docker +++ b/settings.json.docker @@ -290,6 +290,7 @@ "cmdShiftC": "${PAD_SHORTCUTS_ENABLED_CMD_SHIFT_C:true}", /* clear authorship */ "cmdH": "${PAD_SHORTCUTS_ENABLED_CMD_H:true}", /* backspace */ "ctrlHome": "${PAD_SHORTCUTS_ENABLED_CTRL_HOME:true}", /* scroll to top of pad */ + "cmdEsc": "${PAD_SHORTCUTS_ENABLED_CMD_ESC:true}", /* Exit pad and go back to home */ "pageUp": "${PAD_SHORTCUTS_ENABLED_PAGE_UP:true}", "pageDown": "${PAD_SHORTCUTS_ENABLED_PAGE_DOWN:true}" }, @@ -643,7 +644,7 @@ "right": [ ["importexport", "timeslider", "savedrevision"], ["settings", "embed"], - ["showusers", "home"] + ["showusers", "gohome"] ], "timeslider": [ ["timeslider_export", "timeslider_returnToPad"] diff --git a/settings.json.template b/settings.json.template index 893a904b2..94ed5ed88 100644 --- a/settings.json.template +++ b/settings.json.template @@ -275,6 +275,7 @@ "cmdShiftC": true, /* clear authorship */ "cmdH": true, /* backspace */ "ctrlHome": true, /* scroll to top of pad */ + "cmdEsc": true, /* Exit pad and go back to home */ "pageUp": true, "pageDown": true }, @@ -642,7 +643,7 @@ "right": [ ["importexport", "timeslider", "savedrevision"], ["settings", "embed"], - ["showusers", "home"] + ["showusers", "gohome"] ], "timeslider": [ ["timeslider_export", "timeslider_returnToPad"] diff --git a/src/locales/en.json b/src/locales/en.json index 5305a7025..55074abdb 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -54,6 +54,8 @@ "pad.toolbar.settings.title": "Settings", "pad.toolbar.embed.title": "Share and Embed this pad", "pad.toolbar.showusers.title": "Show the users on this pad", + "pad.toolbar.gohome.title": "Go back to home page", + "pad.colorpicker.save": "Save", "pad.colorpicker.cancel": "Cancel", diff --git a/src/node/utils/Settings.ts b/src/node/utils/Settings.ts index 4d7b421e1..f06b101d2 100644 --- a/src/node/utils/Settings.ts +++ b/src/node/utils/Settings.ts @@ -229,6 +229,7 @@ exports.padShortcutEnabled = { cmdShiftC: true, cmdH: true, ctrlHome: true, + cmdEsc: true, pageUp: true, pageDown: true, }; @@ -246,7 +247,7 @@ exports.toolbar = { right: [ ['importexport', 'timeslider', 'savedrevision'], ['settings', 'embed'], - ['showusers'], + ['showusers', 'gohome'], ], timeslider: [ ['timeslider_export', 'timeslider_settings', 'timeslider_returnToPad'], From 60e19bc28143b9f7d26c228d37506f15cf6fb482 Mon Sep 17 00:00:00 2001 From: harshil05133 Date: Mon, 17 Feb 2025 04:27:09 -0500 Subject: [PATCH 3/5] created the home button to go back to the main page when done with current pad, also tried to make a test --- src/node/utils/toolbar.ts | 6 ++++++ src/static/css/pad.css | 1 + src/static/css/pad/home.css | 9 +++++++++ src/static/css/pad/icons.css | 3 +++ src/static/js/pad_editbar.ts | 5 +++++ src/tests/frontend-new/helper/padHelper.ts | 4 ++++ src/tests/frontend-new/specs/leavePadTests.ts | 16 ++++++++++++++++ src/tests/frontend/helper/ui.ts | 15 +++++++++++++++ src/tests/frontend/specs/leavePadTest.js | 10 ++++++++++ 9 files changed, 69 insertions(+) create mode 100644 src/static/css/pad/home.css create mode 100644 src/tests/frontend-new/specs/leavePadTests.ts create mode 100644 src/tests/frontend/specs/leavePadTest.js diff --git a/src/node/utils/toolbar.ts b/src/node/utils/toolbar.ts index f0ef45479..119181e33 100644 --- a/src/node/utils/toolbar.ts +++ b/src/node/utils/toolbar.ts @@ -241,6 +241,12 @@ module.exports = { embed: defaultButtonAttributes('embed'), showusers: defaultButtonAttributes('showusers'), + gohome:{ + command: 'gohome', + localizationId: 'pad.toolbar.gohome.title', + class: 'homeicon homeicon-exit', + }, + timeslider_export: { command: 'import_export', localizationId: 'timeslider.toolbar.exportlink.title', diff --git a/src/static/css/pad.css b/src/static/css/pad.css index 5ef192509..027877e23 100644 --- a/src/static/css/pad.css +++ b/src/static/css/pad.css @@ -12,6 +12,7 @@ @import url("pad/gritter.css"); @import url("pad/loadingbox.css"); @import url("pad/form.css"); +@import url("pad/home.css"); html { font-size: 15px; diff --git a/src/static/css/pad/home.css b/src/static/css/pad/home.css new file mode 100644 index 000000000..811a22a29 --- /dev/null +++ b/src/static/css/pad/home.css @@ -0,0 +1,9 @@ +.homeicon-exit:before { + content: "\2302"; + margin-right: 5px; +} + +.homeicon:hover{ + background-color: grey; +} + diff --git a/src/static/css/pad/icons.css b/src/static/css/pad/icons.css index eb1016dca..dd17f45eb 100644 --- a/src/static/css/pad/icons.css +++ b/src/static/css/pad/icons.css @@ -74,6 +74,9 @@ .buttonicon-showusers:before { content: "\e835"; } +.buttonicon-showusers:before { + content: "\e835"; +} .buttonicon-savedRevision:before { content: "\e856"; } diff --git a/src/static/js/pad_editbar.ts b/src/static/js/pad_editbar.ts index d98174fe5..a3097c4d7 100644 --- a/src/static/js/pad_editbar.ts +++ b/src/static/js/pad_editbar.ts @@ -387,6 +387,11 @@ exports.padeditbar = new class { $('#myusernameedit').trigger('focus'); }); + this.registerCommand('gohome', () => { + console.log('Go Home button clicked'); + window.location.href = '/'; + }); + this.registerCommand('embed', () => { this.setEmbedLinks(); this.toggleDropDown('embed'); diff --git a/src/tests/frontend-new/helper/padHelper.ts b/src/tests/frontend-new/helper/padHelper.ts index f52cd0a35..28673feed 100644 --- a/src/tests/frontend-new/helper/padHelper.ts +++ b/src/tests/frontend-new/helper/padHelper.ts @@ -20,6 +20,10 @@ export const toggleUserList = async (page: Page) => { await page.locator("button[data-l10n-id='pad.toolbar.showusers.title']").click() } +export const leavePad = async (page: Page) => { + await page.locator("button[data-l10n-id='pad.toolbar.gohome.title']").click(); +} + export const setUserName = async (page: Page, userName: string) => { await page.waitForSelector('[class="popup popup-show"]') await page.click("input[data-l10n-id='pad.userlist.entername']"); diff --git a/src/tests/frontend-new/specs/leavePadTests.ts b/src/tests/frontend-new/specs/leavePadTests.ts new file mode 100644 index 000000000..497bcdd3f --- /dev/null +++ b/src/tests/frontend-new/specs/leavePadTests.ts @@ -0,0 +1,16 @@ +import { test, expect } from '@playwright/test'; // Assuming Playwright is being used +import { leavePad } from '../helper/padHelper'; // Import the exitPad function + +test('should exit the pad and return to the homepage', async ({ page }) => { + // Open a new pad (this can use helper.newPad() if it exists) + await page.goto('http://localhost:9001/p/test-' + Date.now()); // Or use helper.newPad() + + // Ensure the page is loaded + await page.waitForLoadState('domcontentloaded'); + + // Click the exit button using the exitPad function + await leavePad(page); + + // Verify that the page has navigated to the homepage + await expect(page).toHaveURL('http://localhost:9001/'); +}); \ No newline at end of file diff --git a/src/tests/frontend/helper/ui.ts b/src/tests/frontend/helper/ui.ts index 69e6b7d40..3c35aa154 100644 --- a/src/tests/frontend/helper/ui.ts +++ b/src/tests/frontend/helper/ui.ts @@ -85,6 +85,21 @@ helper.toggleUserList = async () => { await helper.waitForPromise(() => !isVisible); }; +helper.homeButton = () => helper.padChrome$("button[data-l10n-id='pad.toolbar.gohome.title']"); + +helper.leavePad = async () => { + const button = helper.homeButton(); + button.trigger('click'); + await helper.waitForPromise(() => window.location.pathname === '/'); +}; + +helper.newPad = async (page: Page) => { + // create a new pad before each test run + const padId = "FRONTEND_TESTS"+randomUUID(); + await page.goto('http://localhost:9001/p/'+padId); + await page.waitForSelector('iframe[name="ace_outer"]'); + return padId; +} /** * Gets the user name input field * diff --git a/src/tests/frontend/specs/leavePadTest.js b/src/tests/frontend/specs/leavePadTest.js new file mode 100644 index 000000000..4d0652052 --- /dev/null +++ b/src/tests/frontend/specs/leavePadTest.js @@ -0,0 +1,10 @@ +describe("Leave Pad Functionality", function () { + beforeEach(async function () { + await helper.newPad(); // Open a new pad before each test + }); + + it("should leave the pad and go back to the homepage", async function () { + await helper.leavePad(); // Clicks the exit button + expect(window.location.pathname).toBe("/"); // Confirms we are on the homepage + }); +}); From 96234dff7bf063f6eaa0264ff6c1fb8bb8eca287 Mon Sep 17 00:00:00 2001 From: harshil05133 Date: Mon, 17 Feb 2025 19:47:25 -0500 Subject: [PATCH 4/5] Added the button to the html file and made it more like the other buttons --- src/locales/en.json | 2 +- src/node/utils/toolbar.ts | 2 +- src/static/css/pad/home.css | 5 +++-- src/static/css/pad/icons.css | 4 ++-- ui/pad.html | 5 +++++ 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 55074abdb..69de63564 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -54,7 +54,7 @@ "pad.toolbar.settings.title": "Settings", "pad.toolbar.embed.title": "Share and Embed this pad", "pad.toolbar.showusers.title": "Show the users on this pad", - "pad.toolbar.gohome.title": "Go back to home page", + "pad.toolbar.gohome.title": "Go Home", "pad.colorpicker.save": "Save", diff --git a/src/node/utils/toolbar.ts b/src/node/utils/toolbar.ts index 119181e33..74a051cf1 100644 --- a/src/node/utils/toolbar.ts +++ b/src/node/utils/toolbar.ts @@ -244,7 +244,7 @@ module.exports = { gohome:{ command: 'gohome', localizationId: 'pad.toolbar.gohome.title', - class: 'homeicon homeicon-exit', + class: 'buttonicon buttonicon-gohome', }, timeslider_export: { diff --git a/src/static/css/pad/home.css b/src/static/css/pad/home.css index 811a22a29..1c35ce02b 100644 --- a/src/static/css/pad/home.css +++ b/src/static/css/pad/home.css @@ -1,9 +1,10 @@ -.homeicon-exit:before { +/*.homeicon-exit:before { content: "\2302"; - margin-right: 5px; + margin-right: 3px; } .homeicon:hover{ background-color: grey; } +*/ \ No newline at end of file diff --git a/src/static/css/pad/icons.css b/src/static/css/pad/icons.css index dd17f45eb..ffe6b681a 100644 --- a/src/static/css/pad/icons.css +++ b/src/static/css/pad/icons.css @@ -74,8 +74,8 @@ .buttonicon-showusers:before { content: "\e835"; } -.buttonicon-showusers:before { - content: "\e835"; +.buttonicon-gohome:before { + content: "\e80b"; /* Assuming \e80b is the Unicode for the home icon */ } .buttonicon-savedRevision:before { content: "\e856"; diff --git a/ui/pad.html b/ui/pad.html index e11541943..619dca8c8 100644 --- a/ui/pad.html +++ b/ui/pad.html @@ -77,6 +77,11 @@
  • +
  • + + + +
  • From f5598fdb4ef862bbf0fc373f8b0076827738a62a Mon Sep 17 00:00:00 2001 From: harshil05133 Date: Mon, 17 Feb 2025 20:40:43 -0500 Subject: [PATCH 5/5] First attempt at making a logout feature --- settings.json.docker | 2 +- settings.json.template | 2 +- src/locales/en.json | 1 + src/node/utils/Settings.ts | 2 +- src/node/utils/toolbar.ts | 6 ++++++ src/static/css/pad/icons.css | 3 +++ src/static/js/pad_editbar.ts | 11 +++++++++++ ui/pad.html | 7 ++++++- 8 files changed, 30 insertions(+), 4 deletions(-) diff --git a/settings.json.docker b/settings.json.docker index 3d04dadf7..0cad69bf4 100644 --- a/settings.json.docker +++ b/settings.json.docker @@ -644,7 +644,7 @@ "right": [ ["importexport", "timeslider", "savedrevision"], ["settings", "embed"], - ["showusers", "gohome"] + ["showusers", "gohome", "logout"] ], "timeslider": [ ["timeslider_export", "timeslider_returnToPad"] diff --git a/settings.json.template b/settings.json.template index 94ed5ed88..b69a90137 100644 --- a/settings.json.template +++ b/settings.json.template @@ -643,7 +643,7 @@ "right": [ ["importexport", "timeslider", "savedrevision"], ["settings", "embed"], - ["showusers", "gohome"] + ["showusers", "gohome", "logout"] ], "timeslider": [ ["timeslider_export", "timeslider_returnToPad"] diff --git a/src/locales/en.json b/src/locales/en.json index 69de63564..6428f4b92 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -55,6 +55,7 @@ "pad.toolbar.embed.title": "Share and Embed this pad", "pad.toolbar.showusers.title": "Show the users on this pad", "pad.toolbar.gohome.title": "Go Home", + "pad.toolbar.logout.title": "Logout", "pad.colorpicker.save": "Save", diff --git a/src/node/utils/Settings.ts b/src/node/utils/Settings.ts index f06b101d2..c906fdf97 100644 --- a/src/node/utils/Settings.ts +++ b/src/node/utils/Settings.ts @@ -247,7 +247,7 @@ exports.toolbar = { right: [ ['importexport', 'timeslider', 'savedrevision'], ['settings', 'embed'], - ['showusers', 'gohome'], + ['showusers', 'gohome', 'logout'], ], timeslider: [ ['timeslider_export', 'timeslider_settings', 'timeslider_returnToPad'], diff --git a/src/node/utils/toolbar.ts b/src/node/utils/toolbar.ts index 74a051cf1..ea48580d3 100644 --- a/src/node/utils/toolbar.ts +++ b/src/node/utils/toolbar.ts @@ -247,6 +247,12 @@ module.exports = { class: 'buttonicon buttonicon-gohome', }, + logout:{ + command: 'logout', + localizationId: 'pad.toolbar.logout.title', + class: 'buttonicon buttonicon-logout', + }, + timeslider_export: { command: 'import_export', localizationId: 'timeslider.toolbar.exportlink.title', diff --git a/src/static/css/pad/icons.css b/src/static/css/pad/icons.css index ffe6b681a..d703d9d5c 100644 --- a/src/static/css/pad/icons.css +++ b/src/static/css/pad/icons.css @@ -77,6 +77,9 @@ .buttonicon-gohome:before { content: "\e80b"; /* Assuming \e80b is the Unicode for the home icon */ } +.buttonicon-logout:before { + content: "\e800"; /* Assuming \e800 is the Unicode for the logout icon */ +} .buttonicon-savedRevision:before { content: "\e856"; } diff --git a/src/static/js/pad_editbar.ts b/src/static/js/pad_editbar.ts index a3097c4d7..b73af9710 100644 --- a/src/static/js/pad_editbar.ts +++ b/src/static/js/pad_editbar.ts @@ -392,6 +392,17 @@ exports.padeditbar = new class { window.location.href = '/'; }); + this.registerCommand('logout', () => { + console.log('Logout button clicked'); + // Clear session or authentication token + fetch('/logout', { method: 'POST' }) + .then(response => { + if (response.ok) { + window.location.href = '/'; // Redirect to the home page + } + }); + }); + this.registerCommand('embed', () => { this.setEmbedLinks(); this.toggleDropDown('embed'); diff --git a/ui/pad.html b/ui/pad.html index 619dca8c8..baa3a0b3f 100644 --- a/ui/pad.html +++ b/ui/pad.html @@ -79,7 +79,12 @@
  • - + + +
  • +
  • + +