ep_button_link 0.1.15 → 1.0.3
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.
- package/.github/workflows/backend-tests.yml +20 -9
- package/.github/workflows/frontend-tests.yml +92 -0
- package/.github/workflows/npmpublish.yml +12 -8
- package/README.md +20 -2
- package/index.js +18 -11
- package/package.json +9 -8
- package/static/js/main.js +29 -21
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
# You need to change lines 38 and 46 in case the plugin's name on npmjs.com is different
|
|
2
|
-
# from the repository name
|
|
3
|
-
|
|
4
1
|
name: "Backend tests"
|
|
5
2
|
|
|
6
3
|
# any branch is useful for testing before a PR is submitted
|
|
@@ -17,6 +14,10 @@ jobs:
|
|
|
17
14
|
runs-on: ubuntu-latest
|
|
18
15
|
|
|
19
16
|
steps:
|
|
17
|
+
- uses: actions/setup-node@v2
|
|
18
|
+
with:
|
|
19
|
+
node-version: 12
|
|
20
|
+
|
|
20
21
|
- name: Install libreoffice
|
|
21
22
|
run: |
|
|
22
23
|
sudo add-apt-repository -y ppa:libreoffice/ppa
|
|
@@ -32,19 +33,29 @@ jobs:
|
|
|
32
33
|
- name: Install all dependencies and symlink for ep_etherpad-lite
|
|
33
34
|
run: src/bin/installDeps.sh
|
|
34
35
|
|
|
35
|
-
# clone this repository into node_modules/ep_plugin-name
|
|
36
36
|
- name: Checkout plugin repository
|
|
37
37
|
uses: actions/checkout@v2
|
|
38
38
|
with:
|
|
39
|
-
path: ./node_modules
|
|
39
|
+
path: ./node_modules/__tmp
|
|
40
|
+
|
|
41
|
+
- name: Determine plugin name
|
|
42
|
+
id: plugin_name
|
|
43
|
+
run: |
|
|
44
|
+
cd ./node_modules/__tmp
|
|
45
|
+
npx -c 'printf %s\\n "::set-output name=plugin_name::${npm_package_name}"'
|
|
46
|
+
|
|
47
|
+
- name: Rename plugin directory
|
|
48
|
+
run: |
|
|
49
|
+
mv ./node_modules/__tmp ./node_modules/"${PLUGIN_NAME}"
|
|
50
|
+
env:
|
|
51
|
+
PLUGIN_NAME: ${{ steps.plugin_name.outputs.plugin_name }}
|
|
40
52
|
|
|
41
53
|
- name: Install plugin dependencies
|
|
42
54
|
run: |
|
|
43
|
-
cd node_modules
|
|
55
|
+
cd ./node_modules/"${PLUGIN_NAME}"
|
|
44
56
|
npm ci
|
|
57
|
+
env:
|
|
58
|
+
PLUGIN_NAME: ${{ steps.plugin_name.outputs.plugin_name }}
|
|
45
59
|
|
|
46
60
|
- name: Run the backend tests
|
|
47
61
|
run: cd src && npm test
|
|
48
|
-
|
|
49
|
-
##ETHERPAD_NPM_V=2
|
|
50
|
-
## NPM configuration automatically created using src/bin/plugins/updateAllPluginsScript.sh
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Publicly credit Sauce Labs because they generously support open source
|
|
2
|
+
# projects.
|
|
3
|
+
name: "frontend tests powered by Sauce Labs"
|
|
4
|
+
|
|
5
|
+
on: [push]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
- name: Generate Sauce Labs strings
|
|
13
|
+
id: sauce_strings
|
|
14
|
+
run: |
|
|
15
|
+
printf %s\\n '::set-output name=name::${{github.event.repository.name}} ${{ github.workflow }} - ${{ github.job }}'
|
|
16
|
+
printf %s\\n '::set-output name=tunnel_id::${{ github.run_id }}-${{ github.run_number }}-${{ github.job }}'
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-node@v2
|
|
19
|
+
with:
|
|
20
|
+
node-version: 12
|
|
21
|
+
|
|
22
|
+
- name: Check out Etherpad core
|
|
23
|
+
uses: actions/checkout@v2
|
|
24
|
+
with:
|
|
25
|
+
repository: ether/etherpad-lite
|
|
26
|
+
|
|
27
|
+
- name: Check out the plugin
|
|
28
|
+
uses: actions/checkout@v2
|
|
29
|
+
with:
|
|
30
|
+
path: ./node_modules/__tmp
|
|
31
|
+
|
|
32
|
+
- name: export GIT_HASH to env
|
|
33
|
+
id: environment
|
|
34
|
+
run: |
|
|
35
|
+
cd ./node_modules/__tmp
|
|
36
|
+
echo "::set-output name=sha_short::$(git rev-parse --short ${{ github.sha }})"
|
|
37
|
+
|
|
38
|
+
- name: Determine plugin name
|
|
39
|
+
id: plugin_name
|
|
40
|
+
run: |
|
|
41
|
+
cd ./node_modules/__tmp
|
|
42
|
+
npx -c 'printf %s\\n "::set-output name=plugin_name::${npm_package_name}"'
|
|
43
|
+
|
|
44
|
+
- name: Rename plugin directory
|
|
45
|
+
env:
|
|
46
|
+
PLUGIN_NAME: ${{ steps.plugin_name.outputs.plugin_name }}
|
|
47
|
+
run: |
|
|
48
|
+
mv ./node_modules/__tmp ./node_modules/"${PLUGIN_NAME}"
|
|
49
|
+
|
|
50
|
+
- name: Install plugin dependencies
|
|
51
|
+
env:
|
|
52
|
+
PLUGIN_NAME: ${{ steps.plugin_name.outputs.plugin_name }}
|
|
53
|
+
run: |
|
|
54
|
+
cd ./node_modules/"${PLUGIN_NAME}"
|
|
55
|
+
npm ci
|
|
56
|
+
|
|
57
|
+
# This must be run after setting up the plugin, otherwise npm will try to
|
|
58
|
+
# hoist common dependencies by removing them from src/node_modules and
|
|
59
|
+
# installing them in the top-level node_modules. As of v6.14.10, npm's hoist
|
|
60
|
+
# logic appears to be buggy, because it sometimes removes dependencies from
|
|
61
|
+
# src/node_modules but fails to add them to the top-level node_modules. Even
|
|
62
|
+
# if npm correctly hoists the dependencies, the hoisting seems to confuse
|
|
63
|
+
# tools such as `npm outdated`, `npm update`, and some ESLint rules.
|
|
64
|
+
- name: Install Etherpad core dependencies
|
|
65
|
+
run: src/bin/installDeps.sh
|
|
66
|
+
|
|
67
|
+
- name: Create settings.json
|
|
68
|
+
run: cp settings.json.template settings.json
|
|
69
|
+
|
|
70
|
+
- name: Disable import/export rate limiting
|
|
71
|
+
run: |
|
|
72
|
+
sed -e '/^ *"importExportRateLimiting":/,/^ *\}/ s/"max":.*/"max": 0/' -i settings.json
|
|
73
|
+
|
|
74
|
+
- name: Remove standard frontend test files
|
|
75
|
+
run: rm -rf src/tests/frontend/specs
|
|
76
|
+
|
|
77
|
+
- uses: saucelabs/sauce-connect-action@v1
|
|
78
|
+
with:
|
|
79
|
+
username: ${{ secrets.SAUCE_USERNAME }}
|
|
80
|
+
accessKey: ${{ secrets.SAUCE_ACCESS_KEY }}
|
|
81
|
+
tunnelIdentifier: ${{ steps.sauce_strings.outputs.tunnel_id }}
|
|
82
|
+
|
|
83
|
+
- name: Run the frontend tests
|
|
84
|
+
shell: bash
|
|
85
|
+
env:
|
|
86
|
+
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
|
|
87
|
+
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
|
|
88
|
+
SAUCE_NAME: ${{ steps.sauce_strings.outputs.name }}
|
|
89
|
+
TRAVIS_JOB_NUMBER: ${{ steps.sauce_strings.outputs.tunnel_id }}
|
|
90
|
+
GIT_HASH: ${{ steps.environment.outputs.sha_short }}
|
|
91
|
+
run: |
|
|
92
|
+
src/tests/frontend/travis/runner.sh
|
|
@@ -56,15 +56,22 @@ jobs:
|
|
|
56
56
|
runs-on: ubuntu-latest
|
|
57
57
|
steps:
|
|
58
58
|
- uses: actions/checkout@v2
|
|
59
|
+
with:
|
|
60
|
+
fetch-depth: 0
|
|
59
61
|
- uses: actions/setup-node@v1
|
|
60
62
|
with:
|
|
61
63
|
node-version: 12
|
|
62
64
|
registry-url: https://registry.npmjs.org/
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
- name: Bump version (patch)
|
|
66
|
+
run: |
|
|
67
|
+
LATEST_TAG=$(git describe --tags --abbrev=0) || exit 1
|
|
68
|
+
NEW_COMMITS=$(git rev-list --count "${LATEST_TAG}"..) || exit 1
|
|
69
|
+
[ "${NEW_COMMITS}" -gt 0 ] || exit 0
|
|
70
|
+
git config user.name 'github-actions[bot]'
|
|
71
|
+
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
|
72
|
+
npm ci
|
|
73
|
+
npm version patch
|
|
74
|
+
git push --follow-tags
|
|
68
75
|
# `npm publish` must come after `git push` otherwise there is a race
|
|
69
76
|
# condition: If two PRs are merged back-to-back then master/main will be
|
|
70
77
|
# updated with the commits from the second PR before the first PR's
|
|
@@ -78,6 +85,3 @@ jobs:
|
|
|
78
85
|
- run: npm publish
|
|
79
86
|
env:
|
|
80
87
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
81
|
-
|
|
82
|
-
##ETHERPAD_NPM_V=2
|
|
83
|
-
## NPM configuration automatically created using bin/plugins/updateAllPluginsScript.sh
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# ep_button_link
|
|
4
4
|
|
|
5
|
-
[Etherpad](https://etherpad.org) plugin
|
|
5
|
+
[Etherpad](https://etherpad.org) plugin to add custom buttons to the toolbar.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -24,7 +24,25 @@ Example configuration in `settings.json`:
|
|
|
24
24
|
}
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
Or you can specify a list of buttons:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
"ep_button_link": {
|
|
31
|
+
"buttons": [
|
|
32
|
+
{
|
|
33
|
+
"link": "https://example.com",
|
|
34
|
+
"text": "A button"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"link": "https://example.org",
|
|
38
|
+
"text": "Another button"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Available settings per button:
|
|
45
|
+
|
|
28
46
|
* `link`: Required. URL to visit.
|
|
29
47
|
* `newWindow`: Optional, defaults to true. If true, clicking on the button opens
|
|
30
48
|
the link in a new window or tab.
|
package/index.js
CHANGED
|
@@ -14,16 +14,23 @@ exports.loadSettings = async (hookName, {settings: {ep_button_link}}) => {
|
|
|
14
14
|
settings = null;
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
const {buttons = []} = settings;
|
|
18
|
+
if (settings.link) buttons.push({...settings});
|
|
19
|
+
if (buttons.length === 0) logger.warn('No buttons defined in settings.json.');
|
|
20
|
+
settings.buttons = [];
|
|
21
|
+
for (const button of buttons) {
|
|
22
|
+
if (!button.link) {
|
|
23
|
+
logger.warn('Ignoring button due to missing link:', button);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
delete button.buttons;
|
|
27
|
+
if (button.before && button.after) {
|
|
28
|
+
logger.warn('Ignoring button .before setting because .after is set.');
|
|
29
|
+
delete button.before;
|
|
30
|
+
} else if (!button.before && !button.after) {
|
|
31
|
+
button.before = '[data-key="showTimeSlider"]';
|
|
32
|
+
}
|
|
33
|
+
if (!button.classes) button.classes = 'grouped-left';
|
|
34
|
+
settings.buttons.push(button);
|
|
27
35
|
}
|
|
28
|
-
if (!settings.classes) settings.classes = 'grouped-left';
|
|
29
36
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ep_button_link",
|
|
3
3
|
"description": "Adds a button to the toolbar that links out to a new window",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"author": "johnyma22 (John McLear) <john@mclear.co.uk>",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
8
|
+
"node": ">=12.13.0"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -13,17 +13,18 @@
|
|
|
13
13
|
},
|
|
14
14
|
"funding": {
|
|
15
15
|
"type": "individual",
|
|
16
|
-
"url": "
|
|
16
|
+
"url": "https://etherpad.org/"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"eslint": "^7.
|
|
20
|
-
"eslint-config-etherpad": "^
|
|
19
|
+
"eslint": "^7.32.0",
|
|
20
|
+
"eslint-config-etherpad": "^2.0.2",
|
|
21
21
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
22
|
-
"eslint-plugin-mocha": "^
|
|
22
|
+
"eslint-plugin-mocha": "^9.0.0",
|
|
23
23
|
"eslint-plugin-node": "^11.1.0",
|
|
24
24
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
25
|
-
"eslint-plugin-promise": "^
|
|
26
|
-
"eslint-plugin-you-dont-need-lodash-underscore": "^6.
|
|
25
|
+
"eslint-plugin-promise": "^5.1.1",
|
|
26
|
+
"eslint-plugin-you-dont-need-lodash-underscore": "^6.12.0",
|
|
27
|
+
"eslint-plugin-cypress": "^2.12.1"
|
|
27
28
|
},
|
|
28
29
|
"eslintConfig": {
|
|
29
30
|
"root": true,
|
package/static/js/main.js
CHANGED
|
@@ -2,27 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
// clientVars defaults to window.clientVars for compatibility with older versions of Etherpad.
|
|
4
4
|
exports.postAceInit = (hookName, {clientVars = window.clientVars}) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.attr(titleAttrs)
|
|
16
|
-
.append($('<button>')
|
|
17
|
-
.addClass('buttonicon')
|
|
18
|
-
.addClass('buttonicon-ep_button_link')
|
|
19
|
-
.attr(titleAttrs)
|
|
20
|
-
.html(text)));
|
|
5
|
+
if (!window.clientVars.ep_button_link) {
|
|
6
|
+
console.warn('No settings set for for ep_button_link so displaying default Pad Link button');
|
|
7
|
+
console.warn('For more help https://github.com/ether/ep_button_link');
|
|
8
|
+
}
|
|
9
|
+
const buttons = (clientVars.ep_button_link && clientVars.ep_button_link.buttons) || [{
|
|
10
|
+
text: 'Pad Link',
|
|
11
|
+
link: location.href,
|
|
12
|
+
before: '[data-key="showTimeSlider"]',
|
|
13
|
+
classes: 'grouped-left',
|
|
14
|
+
}];
|
|
21
15
|
const $editBar = $('#editbar');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
for (const button of buttons) {
|
|
17
|
+
const {link, newWindow = true, text = '', title, before, after, classes} = button;
|
|
18
|
+
const titleAttrs = title ? {title, 'aria-label': title} : {};
|
|
19
|
+
const $button = $('<li>')
|
|
20
|
+
.append($('<a>')
|
|
21
|
+
.addClass(classes)
|
|
22
|
+
.attr('href', link)
|
|
23
|
+
.attr(newWindow ? {target: '_blank', rel: 'noopener noreferrer'} : {})
|
|
24
|
+
.attr(titleAttrs)
|
|
25
|
+
.append($('<button>')
|
|
26
|
+
.addClass('buttonicon')
|
|
27
|
+
.addClass('buttonicon-ep_button_link')
|
|
28
|
+
.attr(titleAttrs)
|
|
29
|
+
.html(text)));
|
|
30
|
+
if (after) {
|
|
31
|
+
$editBar.contents().find(after).after($button);
|
|
32
|
+
} else {
|
|
33
|
+
$editBar.contents().find(before).before($button);
|
|
34
|
+
}
|
|
27
35
|
}
|
|
28
36
|
};
|