ep_padlist2 2.1.90 → 2.1.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,7 @@ jobs:
16
16
  steps:
17
17
  -
18
18
  name: Install libreoffice
19
- uses: awalsh128/cache-apt-pkgs-action@v1.6.1
19
+ uses: awalsh128/cache-apt-pkgs-action@v1.6.3
20
20
  with:
21
21
  packages: libreoffice libreoffice-pdfimport
22
22
  version: 1.0
@@ -26,11 +26,11 @@ jobs:
26
26
  with:
27
27
  repository: ether/etherpad-lite
28
28
  path: etherpad-lite
29
- - uses: actions/setup-node@v6
29
+ - uses: actions/setup-node@v7
30
30
  name: Install Node.js
31
31
  with:
32
32
  node-version: 25
33
- - uses: pnpm/action-setup@v6
33
+ - uses: pnpm/action-setup@v6.1.0
34
34
  name: Install pnpm
35
35
  with:
36
36
  package_json_file: ./etherpad-lite/package.json
@@ -16,11 +16,11 @@ jobs:
16
16
  with:
17
17
  repository: ether/etherpad-lite
18
18
  path: etherpad-lite
19
- - uses: actions/setup-node@v6
19
+ - uses: actions/setup-node@v7
20
20
  name: Install Node.js
21
21
  with:
22
22
  node-version: 25
23
- - uses: pnpm/action-setup@v6
23
+ - uses: pnpm/action-setup@v6.1.0
24
24
  name: Install pnpm
25
25
  with:
26
26
  package_json_file: ./etherpad-lite/package.json
@@ -0,0 +1,39 @@
1
+ name: Lint
2
+
3
+ on:
4
+ workflow_call:
5
+
6
+ jobs:
7
+ lint:
8
+ name: ESLint
9
+ runs-on: ubuntu-latest
10
+ # `eslint .` executes .eslintrc.cjs and every installed ESLint plugin, so
11
+ # don't hand it the caller's contents:write / id-token:write token.
12
+ permissions:
13
+ contents: read
14
+ steps:
15
+ - name: Check out plugin repository
16
+ uses: actions/checkout@v7
17
+ - uses: actions/setup-node@v7
18
+ name: Install Node.js
19
+ with:
20
+ node-version: 25
21
+ - uses: pnpm/action-setup@v6.1.0
22
+ name: Install pnpm
23
+ with:
24
+ version: 10
25
+ run_install: false
26
+ - name: Get pnpm store directory
27
+ shell: bash
28
+ run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
29
+ - uses: actions/cache@v6
30
+ name: Setup pnpm cache
31
+ with:
32
+ path: ${{ env.STORE_PATH }}
33
+ key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
34
+ restore-keys: |
35
+ ${{ runner.os }}-pnpm-store-
36
+ - name: Install dependencies
37
+ run: pnpm install --ignore-scripts
38
+ - name: Run ESLint
39
+ run: pnpm run lint
@@ -18,20 +18,24 @@ jobs:
18
18
  contents: write # for the atomic version-bump push (branch + tag)
19
19
  id-token: write # for npm OIDC trusted publishing
20
20
  steps:
21
- - uses: actions/setup-node@v6
21
+ - uses: actions/setup-node@v7
22
22
  with:
23
- # OIDC trusted publishing needs npm >= 11.5.1, which requires
24
- # Node >= 20.17.0. setup-node's `20` resolves to the latest
25
- # 20.x, which satisfies that.
26
- node-version: 25
23
+ # OIDC trusted publishing needs npm >= 11.5.1. Node 24 is an LTS
24
+ # line that every npm 11.x and 12.x supports; Node 25 is not —
25
+ # npm 12 requires ^22.22.2 || ^24.15.0 || >=26.0.0, so on Node 25
26
+ # the upgrade step below died with EBADENGINE and no plugin could
27
+ # publish.
28
+ node-version: 24
27
29
  registry-url: https://registry.npmjs.org/
30
+ # Pinned to a range rather than @latest: the next npm major dropping
31
+ # this Node line would silently break publishing fleet-wide again.
28
32
  - name: Upgrade npm to >=11.5.1 (required for trusted publishing)
29
- run: npm install -g npm@latest
33
+ run: npm install -g npm@^11.5.1
30
34
  - name: Check out Etherpad core
31
35
  uses: actions/checkout@v7
32
36
  with:
33
37
  repository: ether/etherpad-lite
34
- - uses: pnpm/action-setup@v6
38
+ - uses: pnpm/action-setup@v6.1.0
35
39
  name: Install pnpm
36
40
  with:
37
41
  run_install: false
@@ -73,7 +77,7 @@ jobs:
73
77
  # `pnpm version patch` bumps package.json, makes a commit, and creates
74
78
  # a `v<new-version>` tag. Capture the new tag name from package.json
75
79
  # rather than parsing pnpm's output, which has historically varied.
76
- # Bump the patch component directly with Node. pnpm/action-setup@v6
80
+ # Bump the patch component directly with Node. pnpm/action-setup@v6.0.10
77
81
  # sometimes installs pnpm 11 pre-releases even when version: 10.x is
78
82
  # requested (pnpm/action-setup#225); those pre-releases either skip
79
83
  # the git commit/tag or reject --no-git-tag-version as unknown.
@@ -14,6 +14,9 @@ permissions:
14
14
  id-token: write
15
15
 
16
16
  jobs:
17
+ lint:
18
+ uses: ./.github/workflows/lint.yml
19
+ secrets: inherit
17
20
  backend:
18
21
  uses: ./.github/workflows/backend-tests.yml
19
22
  secrets: inherit
@@ -23,6 +26,7 @@ jobs:
23
26
  release:
24
27
  if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
25
28
  needs:
29
+ - lint
26
30
  - backend
27
31
  - frontend
28
32
  permissions:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ep_padlist2",
3
- "version": "2.1.90",
3
+ "version": "2.1.92",
4
4
  "description": "Etherpad plugin to display a list of pads.",
5
5
  "keywords": [
6
6
  "ep",
@@ -23,14 +23,14 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "eslint": "^8.57.1",
26
- "eslint-config-etherpad": "^4.0.5",
27
- "typescript": "^6.0.3"
26
+ "eslint-config-etherpad": "^5.0.0",
27
+ "typescript": "~6.0.3"
28
28
  },
29
29
  "scripts": {
30
30
  "lint": "eslint .",
31
31
  "lint:fix": "eslint --fix ."
32
32
  },
33
33
  "engines": {
34
- "node": ">=18.0.0"
34
+ "node": ">=22.0.0"
35
35
  }
36
36
  }
@@ -0,0 +1,10 @@
1
+ # js-yaml and brace-expansion arrive only as transitive dev dependencies (via
2
+ # eslint and minimatch@3), so `pnpm update` cannot move them. The selectors are
3
+ # scoped to the affected major line: an unbounded range would drag minimatch@3
4
+ # onto brace-expansion 5.x and eslint onto js-yaml 5.x.
5
+ #
6
+ # pnpm 11 no longer reads `pnpm.overrides` from package.json — these must live
7
+ # here or the lockfile and the install disagree (ERR_PNPM_LOCKFILE_CONFIG_MISMATCH).
8
+ overrides:
9
+ js-yaml@4: '^4.3.2'
10
+ brace-expansion@1: '^1.1.16'
package/static/js/main.js CHANGED
@@ -1,30 +1,121 @@
1
1
  'use strict';
2
2
 
3
- $(() => {
3
+ // This page used to pull in jQuery and core's html10n via
4
+ // <script src="static/js/jquery.js">, "static/js/html10n.js" and
5
+ // "static/js/l10n.js". Etherpad stopped serving all three (html10n is bundled
6
+ // into the Vite entry points, l10n.js and the standalone jQuery build are
7
+ // gone), so every one of those requests 404s and the resulting
8
+ // `$ is not defined` killed this file before it could bind the search box.
9
+ // Everything below is therefore dependency-free DOM code.
10
+
11
+ // Same set html10n accepts as a "<key>.<attribute>" suffix.
12
+ const ATTRIBUTE_KEYS = ['title', 'innerHTML', 'alt', 'textContent', 'value', 'placeholder'];
13
+
14
+ const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
15
+
16
+ const translateNode = (node, strings) => {
17
+ const id = node.getAttribute('data-l10n-id');
18
+ if (!id) return;
19
+ const str = strings[id];
20
+ if (str == null) return;
21
+ const dot = id.lastIndexOf('.');
22
+ const suffix = dot > 0 ? id.slice(dot + 1) : '';
23
+ const prop = ATTRIBUTE_KEYS.indexOf(suffix) !== -1 ? suffix : 'textContent';
24
+ node[prop] = str;
25
+ // Give form controls a localized accessible name, like html10n does.
26
+ if (prop !== 'textContent' && prop !== 'innerHTML') node.setAttribute('aria-label', str);
27
+ };
28
+
29
+ // The languages to try, most specific first: 'de-AT' also tries 'de', and
30
+ // English is always the final fallback. Browsers report canonical casing
31
+ // ('pt-BR', 'zh-Hans') while the locale index is keyed in lower case, so
32
+ // normalize before looking anything up.
33
+ const preferredLangs = () => {
34
+ const langs = [];
35
+ for (const tag of (navigator.languages || [navigator.language])) {
36
+ if (!tag) continue;
37
+ const lang = tag.toLowerCase();
38
+ langs.push(lang);
39
+ if (lang.indexOf('-') > 0) langs.push(lang.split('-')[0]);
40
+ }
41
+ langs.push('en');
42
+ return langs;
43
+ };
44
+
45
+ const fetchJson = async (url) => {
46
+ const res = await fetch(url);
47
+ if (!res.ok) throw new Error(`${res.status} ${res.statusText} for ${url}`);
48
+ return await res.json();
49
+ };
50
+
51
+ const loadTranslations = async () => {
52
+ const link = document.querySelector('link[rel="localizations"]');
53
+ const indexUrl =
54
+ new URL(link ? link.getAttribute('href') : 'locales.json', window.location.href).href;
55
+ const index = await fetchJson(indexUrl);
56
+ const lang = preferredLangs().find((l) => index[l] != null);
57
+ if (!lang) return {};
58
+ // Entries are usually a path to the locale file, but Etherpad inlines the
59
+ // translations themselves for the language it falls back to (English).
60
+ const entry = index[lang];
61
+ const data = typeof entry === 'string' ? await fetchJson(new URL(entry, indexUrl).href) : entry;
62
+ // Locale files are {"<lang>": {"<key>": "<string>"}}; inlined maps are flat.
63
+ return data[lang] || data;
64
+ };
65
+
66
+ const localize = async () => {
67
+ let strings;
68
+ try {
69
+ strings = await loadTranslations();
70
+ } catch (err) {
71
+ // Leave the English fallbacks that are already in the template.
72
+ console.warn('ep_padlist2: unable to load translations', err);
73
+ return;
74
+ }
75
+ for (const node of document.querySelectorAll('[data-l10n-id]')) translateNode(node, strings);
76
+ };
77
+
78
+ const initSearch = () => {
79
+ const list = document.querySelector('ul');
80
+ const searchBox = document.querySelector('input[type="search"]');
81
+ if (!list || !searchBox) return;
82
+ const items = Array.from(list.querySelectorAll('li'));
83
+
4
84
  const filter = (query) => {
5
- const list = $('ul');
6
- if (!query.length) {
7
- list.removeClass('filtering');
8
- } else {
9
- list.addClass('filtering');
10
- const words = query.split(/\s+/);
11
- const regex = new RegExp(`(?=.*${words.join(')(?=.*')})`, 'i');
12
- list.find('li').each(function () {
13
- const item = $(this);
14
- const padId = item.find('a').text();
15
- item.toggleClass('visible', regex.test(padId));
16
- });
85
+ const words = (query || '').split(/\s+/).filter((w) => w.length).map(escapeRegExp);
86
+ if (!words.length) {
87
+ list.classList.remove('filtering');
88
+ return;
89
+ }
90
+ list.classList.add('filtering');
91
+ // Every word has to appear somewhere in the pad id, in any order.
92
+ const regex = new RegExp(`(?=.*${words.join(')(?=.*')})`, 'i');
93
+ for (const item of items) {
94
+ const link = item.querySelector('a');
95
+ item.classList.toggle('visible', regex.test(link ? link.textContent : ''));
17
96
  }
18
97
  };
98
+
19
99
  const queryParams = new URLSearchParams(window.location.search);
20
- const searchBox = $('input');
21
- const q = queryParams.has('q') ? queryParams.get('q') : searchBox.val();
100
+ const q = queryParams.has('q') ? queryParams.get('q') : searchBox.value;
101
+ searchBox.value = q;
22
102
  filter(q);
23
- searchBox.val(q);
24
- searchBox.on('input', () => {
25
- const val = searchBox.val();
103
+
104
+ searchBox.addEventListener('input', () => {
105
+ const val = searchBox.value;
26
106
  queryParams.set('q', val);
27
107
  history.replaceState(null, '', `${window.location.pathname}?${queryParams.toString()}`);
28
108
  filter(val);
29
109
  });
30
- });
110
+ };
111
+
112
+ const init = () => {
113
+ initSearch();
114
+ localize();
115
+ };
116
+
117
+ if (document.readyState === 'loading') {
118
+ document.addEventListener('DOMContentLoaded', init);
119
+ } else {
120
+ init();
121
+ }
@@ -0,0 +1,67 @@
1
+ import {expect, test} from '@playwright/test';
2
+ import {goToNewPad} from 'ep_etherpad-lite/tests/frontend-new/helper/padHelper';
3
+
4
+ const LIST_URL = 'http://localhost:9001/list';
5
+
6
+ test.describe('ep_padlist2 /list', () => {
7
+ test('lists the pad and filters it with the search box', async ({page}) => {
8
+ // Regression guard for ether/ether-plugins#79: the page used to load
9
+ // jQuery/html10n from paths core no longer serves, so main.js died with
10
+ // "$ is not defined" and typing in the search box did nothing.
11
+ const pageErrors: string[] = [];
12
+ page.on('pageerror', (err) => pageErrors.push(err.message));
13
+
14
+ const padId = await goToNewPad(page);
15
+
16
+ // The pad may not have been flushed to the database yet.
17
+ await expect(async () => {
18
+ await page.goto(LIST_URL);
19
+ await expect(page.locator('li a', {hasText: padId})).toBeVisible({timeout: 2000});
20
+ }).toPass({timeout: 30000});
21
+
22
+ const padLink = page.locator('li a', {hasText: padId});
23
+ const searchBox = page.locator('input[type="search"]');
24
+
25
+ // A query that matches hides nothing relevant...
26
+ await searchBox.fill(padId.slice(-12));
27
+ await expect(padLink).toBeVisible();
28
+
29
+ // ...and one that doesn't match hides the pad.
30
+ await searchBox.fill('zzz-no-such-pad-zzz');
31
+ await expect(padLink).toBeHidden();
32
+
33
+ // Regex metacharacters must not blow up the filter.
34
+ await searchBox.fill('((');
35
+ await expect(padLink).toBeHidden();
36
+
37
+ // Clearing the box shows everything again.
38
+ await searchBox.fill('');
39
+ await expect(padLink).toBeVisible();
40
+
41
+ expect(pageErrors).toEqual([]);
42
+ });
43
+
44
+ test('localizes the page from the plugin locales', async ({page}) => {
45
+ await page.goto(LIST_URL);
46
+ // Loaded from locales/en.json via data-l10n-id, not from the template's
47
+ // hardcoded fallback text.
48
+ await expect(page.locator('input[type="search"]'))
49
+ .toHaveAttribute('placeholder', 'Search pads');
50
+ await expect(page.locator('input[type="search"]'))
51
+ .toHaveAttribute('aria-label', 'Search pads');
52
+ await expect(page.locator('h1')).toHaveText('Pads');
53
+ });
54
+ });
55
+
56
+ test.describe('ep_padlist2 /list in pt-BR', () => {
57
+ test.use({locale: 'pt-BR'});
58
+
59
+ test('uses the regional locale, not the base language', async ({page}) => {
60
+ // The browser reports "pt-BR" but the locale index is keyed "pt-br", so a
61
+ // case-sensitive lookup would silently fall back to "pt".
62
+ await page.goto(LIST_URL);
63
+ await expect(page.locator('input[type="search"]'))
64
+ .toHaveAttribute('placeholder', 'Pesquisar notas');
65
+ await expect(page.locator('h1')).toHaveText('Notas');
66
+ });
67
+ });
@@ -4,11 +4,8 @@
4
4
  <meta name="description" content="All Pads">
5
5
  <meta name="viewport" content="width=device-width">
6
6
  <link rel="stylesheet" href="static/plugins/ep_padlist2/static/css/main.css">
7
- <script src="static/js/jquery.js" ></script>
8
- <script src="static/plugins/ep_padlist2/static/js/main.js"></script>
9
7
  <link rel="localizations" type="application/l10n+json" href="locales.json" />
10
- <script src="static/js/html10n.js"></script>
11
- <script src="static/js/l10n.js"></script>
8
+ <script src="static/plugins/ep_padlist2/static/js/main.js" defer></script>
12
9
  </head>
13
10
  <body>
14
11
  <div class="head">