ep_stats 0.0.61 → 0.0.63
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/ep.json +9 -6
- package/index.js +37 -32
- package/package.json +4 -1
- package/static/css/stats.css +8 -0
- package/static/js/stats.js +26 -9
- package/templates/stats_entry.ejs +0 -4
package/ep.json
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
"parts":[
|
|
2
|
+
"parts": [
|
|
3
3
|
{
|
|
4
4
|
"name": "stats",
|
|
5
|
-
"hooks":{
|
|
5
|
+
"hooks": {
|
|
6
6
|
"expressCreateServer": "ep_stats/express",
|
|
7
|
+
"loadSettings": "ep_stats/index",
|
|
8
|
+
"clientVars": "ep_stats/index",
|
|
7
9
|
"eejsBlock_exportColumn": "ep_stats/index",
|
|
8
10
|
"eejsBlock_scripts": "ep_stats/index",
|
|
9
11
|
"eejsBlock_mySettings": "ep_stats/index",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
12
|
+
"eejsBlock_padSettings": "ep_stats/index",
|
|
13
|
+
"eejsBlock_styles": "ep_stats/index",
|
|
14
|
+
"eejsBlock_body": "ep_stats/index"
|
|
13
15
|
},
|
|
14
16
|
"client_hooks": {
|
|
15
17
|
"postAceInit": "ep_stats/static/js/stats",
|
|
16
|
-
"aceEditEvent": "ep_stats/static/js/stats"
|
|
18
|
+
"aceEditEvent": "ep_stats/static/js/stats",
|
|
19
|
+
"handleClientMessage_CLIENT_MESSAGE": "ep_stats/static/js/stats:handleClientMessage_CLIENT_MESSAGE"
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
]
|
package/index.js
CHANGED
|
@@ -1,42 +1,47 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const {template} = require('ep_plugin_helpers');
|
|
4
|
+
const {padToggle} = require('ep_plugin_helpers/pad-toggle-server');
|
|
5
|
+
|
|
6
|
+
// Parallel User Settings + Pad Wide Settings checkboxes for "Show Pad and
|
|
7
|
+
// Author stats". Helper owns markup, storage, broadcast, enforce, and i18n.
|
|
8
|
+
const statsToggle = padToggle({
|
|
9
|
+
pluginName: 'ep_stats',
|
|
10
|
+
settingId: 'stats',
|
|
11
|
+
l10nId: 'ep_stats.stats_entry.show_pad_and_author_stats',
|
|
12
|
+
defaultLabel: 'Show Pad and Author stats',
|
|
13
|
+
defaultEnabled: true,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Older settings.json used a top-level `ep_stats_default` key. Translate it
|
|
17
|
+
// to the helper's nested `ep_stats.defaultEnabled` so an admin who set it
|
|
18
|
+
// to `false` keeps a default-off pad.
|
|
19
|
+
exports.loadSettings = async (hookName, args) => {
|
|
20
|
+
const root = args && args.settings;
|
|
21
|
+
if (root) {
|
|
22
|
+
const ps = (root.ep_stats = root.ep_stats || {});
|
|
23
|
+
if (typeof ps.defaultEnabled !== 'boolean' &&
|
|
24
|
+
typeof root.ep_stats_default === 'boolean') {
|
|
25
|
+
ps.defaultEnabled = root.ep_stats_default;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return statsToggle.loadSettings(hookName, args);
|
|
9
29
|
};
|
|
10
30
|
|
|
11
|
-
exports.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
31
|
+
exports.clientVars = statsToggle.clientVars;
|
|
32
|
+
exports.eejsBlock_mySettings = statsToggle.eejsBlock_mySettings;
|
|
33
|
+
exports.eejsBlock_padSettings = statsToggle.eejsBlock_padSettings;
|
|
15
34
|
|
|
16
|
-
exports.
|
|
17
|
-
|
|
18
|
-
return cb();
|
|
19
|
-
};
|
|
35
|
+
exports.eejsBlock_exportColumn =
|
|
36
|
+
template('ep_stats/templates/exportcolumn.html');
|
|
20
37
|
|
|
21
|
-
exports.
|
|
22
|
-
|
|
23
|
-
return cb();
|
|
24
|
-
};
|
|
38
|
+
exports.eejsBlock_scripts =
|
|
39
|
+
template('ep_stats/templates/scripts.html');
|
|
25
40
|
|
|
26
|
-
exports.
|
|
27
|
-
|
|
28
|
-
if (!settings.ep_stats_default) {
|
|
29
|
-
checkedState = 'unchecked';
|
|
30
|
-
} else if (settings.ep_stats_default === true) {
|
|
31
|
-
checkedState = 'checked';
|
|
32
|
-
}
|
|
33
|
-
args.content += eejs.require('ep_stats/templates/stats_entry.ejs', {checked: checkedState});
|
|
41
|
+
exports.eejsBlock_styles = (hookName, args, cb) => {
|
|
42
|
+
args.content += '<link href="../static/plugins/ep_stats/static/css/stats.css" rel="stylesheet">';
|
|
34
43
|
return cb();
|
|
35
44
|
};
|
|
36
45
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
args.content +=
|
|
40
|
-
"<li><a href='#' onClick='$(\"#options-stats\").click();'>Pad Statistics</a></li>";
|
|
41
|
-
return cb();
|
|
42
|
-
};
|
|
46
|
+
exports.eejsBlock_body =
|
|
47
|
+
template('ep_stats/templates/stats.html');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ep_stats",
|
|
3
3
|
"description": "See pad Stats in Etherpad",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.63",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "John McLear",
|
|
7
7
|
"email": "john@mclear.co.uk",
|
|
@@ -37,5 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=18.0.0"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"ep_plugin_helpers": "^0.5.2"
|
|
40
43
|
}
|
|
41
44
|
}
|
package/static/css/stats.css
CHANGED
|
@@ -31,3 +31,11 @@
|
|
|
31
31
|
.statsAuthorColor{
|
|
32
32
|
width:4px;
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
/* Hide the stats panel in core's in-pad history mode (Etherpad #7659).
|
|
36
|
+
Stats reflect the live pad; they have no meaning when the pad is showing
|
|
37
|
+
a historical revision, and the panel's bottom-right position overlaps
|
|
38
|
+
core's history banner (the "Return to live" button in particular). The
|
|
39
|
+
class is added to <body> by core when entering history and removed when
|
|
40
|
+
the user returns to live. */
|
|
41
|
+
body.history-mode #stats { display: none !important; }
|
package/static/js/stats.js
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// Sub-path import keeps the client bundle clean — the top-level
|
|
4
|
+
// `ep_plugin_helpers` index pulls in server-only modules.
|
|
5
|
+
const {padToggle} = require('ep_plugin_helpers/pad-toggle');
|
|
6
|
+
|
|
7
|
+
// Same config as the server-side instance — must agree on pluginName,
|
|
8
|
+
// settingId, l10nId, and defaultLabel so checkbox ids and clientVars line up.
|
|
9
|
+
const statsToggle = padToggle({
|
|
10
|
+
pluginName: 'ep_stats',
|
|
11
|
+
settingId: 'stats',
|
|
12
|
+
l10nId: 'ep_stats.stats_entry.show_pad_and_author_stats',
|
|
13
|
+
defaultLabel: 'Show Pad and Author stats',
|
|
14
|
+
defaultEnabled: true,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Re-export so the helper sees pad-wide broadcasts and refreshes our state
|
|
18
|
+
// when another user toggles the pad-wide checkbox.
|
|
19
|
+
exports.handleClientMessage_CLIENT_MESSAGE = statsToggle.handleClientMessage_CLIENT_MESSAGE;
|
|
20
|
+
|
|
3
21
|
const stats = {
|
|
4
22
|
init: () => {
|
|
5
23
|
stats.update();
|
|
@@ -198,19 +216,18 @@ stats.authors = {
|
|
|
198
216
|
};
|
|
199
217
|
|
|
200
218
|
exports.postAceInit = (hook, context) => {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
} else {
|
|
207
|
-
stats.hide();
|
|
208
|
-
}
|
|
219
|
+
statsToggle.init({
|
|
220
|
+
onChange: (enabled) => {
|
|
221
|
+
if (enabled) stats.show();
|
|
222
|
+
else stats.hide();
|
|
223
|
+
},
|
|
209
224
|
});
|
|
210
225
|
};
|
|
211
226
|
|
|
212
227
|
exports.aceEditEvent = (hookName, event) => {
|
|
213
|
-
|
|
228
|
+
// The helper keeps #options-stats in sync with the live toggle state,
|
|
229
|
+
// so a DOM check is still the simplest read path on the hot path.
|
|
230
|
+
if ($('#options-stats').is(':checked')) {
|
|
214
231
|
if (event.callstack.docTextChanged && event.callstack.domClean) {
|
|
215
232
|
stats.update();
|
|
216
233
|
}
|