Commit graph

2835 commits

Author SHA1 Message Date
Ray Bellis
3802073695 db/DB.js: allow a Promise return instead of callbacks in init() 2019-01-18 13:48:46 +00:00
muxator
b0846ded14 db/SessionManager.js: "authorMangager" -> "authorManager"
Extracted from Ray's work.
2019-02-09 02:19:14 +01:00
muxator
98993fe156 db/SessionManager.js: "groupMangager" -> "groupManager"
Extracted from Ray's work.
2019-02-09 02:18:36 +01:00
muxator
11453d544c prepare to async: stricter checks
This change is in preparation of the future async refactoring by Ray. It tries
to extract as many changes in boolean conditions as possible, in order to make
more evident identifying eventual logic bugs in the future work.

This proved already useful in at least one case.

BEWARE: this commit exposes an incoherency in the DB API, in which, depending
on the driver used, some functions can return null or undefined. This condition
will be externally fixed by the final commit in this series ("db/DB.js: prevent
DB layer from returning undefined"). Until that commit, the code base may have
some bugs.
2019-03-01 09:43:41 +01:00
muxator
e841798314 prepare to async: typos in error messages
This change extracts the grammar correction performed on the async branch,
anticipating them in a single commit. It cannot be folded with the previous
one, as it is not purely cosmetic.
2019-02-15 22:52:53 +01:00
muxator
9497ee734f prepare to async: trivial reformatting
This change is only cosmetic. Its aim is do make it easier to understand the
async changes that are going to be merged later on. It was extracted from the
original work from Ray Bellis.

To verify that nothing has changed, you can run the following command on each
file touched by this commit:
  npm install uglify-es
  diff --unified <(uglify-js --beautify bracketize <BEFORE.js>) <(uglify-js --beautify bracketize <AFTER.js>)



This is a complete script that does the same automatically (works from a
mercurial clone):

```bash
#!/usr/bin/env bash

set -eu

REVISION=<THIS_REVISION>

PARENT_REV=$(hg identify --rev "${REVISION}" --template '{p1rev}')
FILE_LIST=$(hg status --no-status --change ${REVISION})
UGLIFYJS="node_modules/uglify-es/bin/uglifyjs"

for FILE_NAME in ${FILE_LIST[@]}; do
  echo "Checking ${FILE_NAME}"
  diff --unified \
    <("${UGLIFYJS}" --beautify bracketize <(hg cat --rev "${PARENT_REV}" "${FILE_NAME}")) \
    <("${UGLIFYJS}" --beautify bracketize <(hg cat --rev "${REVISION}"   "${FILE_NAME}"))
done
```
2019-02-08 23:20:57 +01:00
muxator
cc23bd18a4 db/API.js: require() Changeset library at top of file
Introduced with d246a191c6 ("Added option to restore revisions #1791") on
2014-11-08.
2019-03-07 00:39:41 +01:00
muxator
06756e49ee db/API.js: reuse the already required padMessageHandler (2 of 2)
It was introduced on 2014-11-12 by commit 9d39c9591a ("update pad clients").
2019-03-07 00:14:49 +01:00
muxator
72260b86de db/API.js: reuse the already required padMessageHandler (1 of 2)
Commit 94cb743ca8 ("Fix API call appendChatMessage to send new message to all
connected clients") fixed a bug, but introduced a redundant require().
2019-03-07 00:04:08 +01:00
muxator
10172af199 db/API.js: no need to parseInt(time) here
We are already sure that time is an int
2019-03-07 00:02:24 +01:00
muxator
b34fc2de2b use Date.now() instead of new Date().getTime()
This is documented to be more performant.

The substitution was made on frontend code, too (i.e., the one in /static),
because Date.now() is supported since IE 9, and we are life supporting only
IE 11.

Commands:
  find . -name *.js | xargs sed --in-place "s/new Date().getTime()/Date.now()/g"
  find . -name *.js | xargs sed --in-place "s/(new Date()).getTime()/Date.now()/g"

Not done on jQuery.
2019-02-26 23:25:15 +01:00
muxator
90bfbeb38d PadMessageHandler.js: fixed logic error in a guard condition
The guard condition on count being non negative and < 100 used the wrong
boolean operator. In its form it was impossible.

This error was introduced in 2013, in 5592c4b0fe.
Fixes #3499
2019-02-27 00:56:41 +01:00
muxator
4b913172fe PadMessageHandler.js: renamed parameter in handleCustomMessage() to avoid name clash 2019-02-26 22:19:49 +01:00
muxator
791012bb9b PadMessageHandler.js: removed redundant return statement 2019-02-26 19:15:22 +01:00
muxator
46fdeb8dc4 ExportTxt.js: getPadTXT() does not need to be exported
This function is used only inside this module, and does not belong to its
external interface.
2019-02-22 23:32:10 +01:00
muxator
169a06793d db/API.js: almost removed optional argument handling
The HTTP API doesn't ever omit arguments, it always passes `undefined` for a
parameter that wasn't supplied in the request.

The functions that were simplified are:
  - getRevisionChangeset()
  - getText()
  - getHTML()
  - saveRevision()

The only function still supporting optional arguments is getPadSafe(), which is
only called from this module.
2019-02-19 00:15:54 +01:00
muxator
26f3f1bcd0 db/Pad.js: make "force" parameter non optional in Pad.prototype.copy()
This function was simulating two overloads:
  1. copy(destinationID, force, callback)
  2. copy(destinationID, callback), in this case "force" would be assumed false

But all the call sites always used the version with arity 3.
Thus, we can remove that optionality and always assume that the funcion will be
called with three parameters. This will simplify future work.
2019-02-13 14:01:24 +01:00
translatewiki.net
1900b00ec2 Localisation updates from https://translatewiki.net. 2019-02-25 10:41:33 +01:00
Sebastian Castro
9848a600e3 colibris: Fixes #3548 #3549 chat improvements 2019-02-22 19:48:46 +01:00
Sebastian Castro
378dbe8485 skins: Improve clientPluginNames class helper
Moving classes to html tag so it can be used to style other part of template depending on plugins like #users, #chat etc...
Rename plugin class with "plugin-" prefix, because there were conflicts with some plugins using the same .ep_font_color class to apply css rules
2019-02-22 19:48:46 +01:00
Sebastian Castro
401db8fce3 chat: Adds placeholder to input. Translate stick button 2019-02-22 19:48:08 +01:00
muxator
59a6f2e9b8 node8: get rid of node < 0.7 compatibility when deleting files.
- path.exists() is no longer part of nodejs
- fs.exists() is deprecated (as of nodejs >= 8)
- checking a file for existence before using it is open to raca condition. It is
  preferable to go ahead and use the file, and eventually handle the error
- we can afford two simple synchronous fs operations here
2019-02-19 22:01:12 +01:00
muxator
6d36bb2c53 node8: we can safely use os.tmpdir()
Since we are requiring node >= 8, we can safely use native functionalities.
2019-02-19 22:01:12 +01:00
muxator
09949c242a node8: we no longer need to use a shim for Object.values in stats.js 2019-02-19 22:01:12 +01:00
muxator
9d35d15ae3 node8: require nodejs >= 8.9.0, npm >= 6.4
Next version will be Etherpad 1.8. As planned in #3424, we are going to require
NodeJS >=8.9.0 and npm >= 6.4.

This commit implements that change and updates documentation and scripts.
Subsequent changes will get rid of old idioms, dating back to node < 0.7, that
still survive in the code.
Once migrated to NodeJS 8, we will be able to start working on migrating the
code base from callbacks to async/await, greatly simplifying legibility (see
#3540).

Closes #3557
2019-02-19 22:01:12 +01:00
muxator
9d9b7c9faf NodeVersion.js: do not use callbacks, simplify calling style in server.js 2019-02-19 00:46:37 +01:00
muxator
36addd2205 server.js: group together the loading of the stats system
No functional changes, this is intended to simplify subsequent patches.
2019-02-19 00:41:51 +01:00
translatewiki.net
b16b98f8ca Localisation updates from https://translatewiki.net. 2019-02-18 08:00:31 +01:00
muxator
d5d428c4ee windows: allow graceful shutdown on Windows, too
Until Etherpad 1.7.5, process.on('SIGTERM') and process.on('SIGINT') were not
hooked up under Windows, because old nodejs versions did not support them.
This excluded the possibility of doing a graceful shutdown of the database
connection under that platform.

According to nodejs 6.x documentation, it is now safe to do so. This allows to
gracefully close the DB connection when hitting CTRL+C under Windows, for
example.

Source: https://nodejs.org/docs/latest-v6.x/api/process.html#process_signal_events

  - SIGTERM is not supported on Windows, it can be listened on.
  - SIGINT from the terminal is supported on all platforms, and can usually be
    generated with <Ctrl>+C (though this may be configurable). It is not
    generated when terminal raw mode is enabled.
2019-02-16 00:14:39 +01:00
translatewiki.net
c333984cd8 Localisation updates from https://translatewiki.net. 2019-02-14 09:09:18 +01:00
muxator
631b23f7a2 utils/AbsolutePaths.js: do not break when running as a Windows manual install
A Windows manual install has the same directory layout of a normal Unix one
(e.g. the nice symlink node_modules/ep_etherpad-lite -> ../src).
Only when running from the pre-built Windows package the directory layout is
different (e.g. src is physically copied into node_modules/ep_etherpad-lite).
The previous version of the code wrongly assumed that all Windows installs would
be run from the pre-built pakage.

In this version the path search is the same on all platform. If it fails, and we
are on Windows, there is a fallback for the specific case of the pre-built
package.

Fixes #3550
2019-02-11 03:28:02 +01:00
muxator
78c057af31 NodeVersion.js: factor out require('semver') 2019-02-08 19:10:49 +01:00
translatewiki.net
2e4ee39cc3 Localisation updates from https://translatewiki.net. 2019-02-07 15:55:56 +01:00
muxator
4f0a2785da release: prepare for 1.7.5
Written the changelog and updated package.json.
2019-01-26 00:16:03 +01:00
muxator
d475cc3d08 package.json: "http://github.com" -> "https://github.com" 2019-01-26 00:12:16 +01:00
muxator
9f31456f84 package.json: list myself among the authors 2019-01-26 00:11:11 +01:00
Ray Bellis
c8e5d87268 api: simplify version table
This commit vastly shortens (and simplifies) the version table within
handler/APIHandler.js by building each version's entry incrementally based off
the previous version.

The resulting table has been validated by comparing the "before" and "after"
output of the following loop on both versions of the code (albeit with an
intermediate "sort" step to account for the different insertion order)

  for (let v in version) {
    let m = version[v];
    for (let [k, a] of Object.entries(m)) {
      console.log(v, k, a);
    }
  }

The patch also fixes a few typos, and removes a duplicate definition of
getChatHistory which in each applicable version was defined with two different
parameter lists, but where only the second would be used.
2019-01-22 22:51:22 +01:00
translatewiki.net
bd48497ce3 Localisation updates from https://translatewiki.net. 2019-01-17 10:50:43 +01:00
HairyFotr
fce55df2b7 Fix typos 2019-01-16 11:14:04 +01:00
translatewiki.net
02b3d42771 Localisation updates from https://translatewiki.net. 2018-12-27 10:48:05 +01:00
translatewiki.net
7275cdc915 Localisation updates from https://translatewiki.net. 2018-12-17 08:51:24 +01:00
translatewiki.net
db27582622 Localisation updates from https://translatewiki.net. 2018-12-10 08:08:01 +01:00
muxator
0ad8291ae7 hooks: restore Internet Explorer 11 compatibility.
Compatibility with IE11 regressed in 23eab79946 while working for #3488.
That commit made use of modern js syntax, not supported by IE11.

- Removed arrow functions, replaced with normal functions.
- Removed the spread operator (<...iterable>) and the "new Set()" construct,
  replaced with _.uniq()

At some point IE11 compatibility will be dropped.
Ditching it now, for such a small gain, is not wise.

Fixes #3500.
2018-11-28 20:03:39 +01:00
muxator
fe20ffa202 dependencies: update wd, 1.10.3 -> 1.11.1
This is just a dev dependency, so no real risks, but it's better not to scare
users.

Reported vulnerability before this change:

$ npm audit
                       === npm audit security report ===

# Run  npm update cryptiles --depth 4  to resolve 1 vulnerability
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High          │ Insufficient Entropy                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ cryptiles                                                    │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ wd [dev]                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ wd > request > hawk > cryptiles                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/720                       │
└───────────────┴──────────────────────────────────────────────────────────────┘
2018-11-28 18:49:12 +01:00
Sebastian Castro
fc629e49d9 skins:colibris fixes #3514 hide sidediv and "show line number" option on mobile 2018-11-28 15:01:12 +01:00
Sebastian Castro
2ce195747b skins: Fixes #3510 show/hide line numbers 2018-11-15 11:34:32 +01:00
Sebastian Castro
4c7ae65ac4 colibris: use a darker default font and do not use OpenDyslexic 2018-11-08 21:56:41 +01:00
Sebastian Castro
385ca8771b colibris: various improvements, including author_hover, cursortrace plugins 2018-11-08 21:56:40 +01:00
Sebastian Castro
39ad22f78f colibris: style timeslider page 2018-11-08 21:56:39 +01:00
Sebastian Castro
8343afde84 colibris: move ep_embedded_hyperlinks style to plugin itself 2018-11-08 21:56:38 +01:00
Sebastian Castro
948e9e4e10 colibris: responsive layout depending on plugins activated 2018-11-08 21:56:30 +01:00
Sebastian Castro
413f46b085 colibris: minor improvements 2018-11-08 21:56:29 +01:00
Sebastian Castro
e8c229cc65 colibris: add style for ep_embedded_hyperlink plugin 2018-11-08 21:56:29 +01:00
Sebastian Castro
9205b551df colibris: fix plugin ep_comments style 2018-11-08 21:56:28 +01:00
Sebastian Castro
af641c3b3d colibris: minor improvements 2018-11-08 21:56:27 +01:00
Sebastian Castro
8881a2a61f colibris: style plugin ep_tables2 2018-11-08 21:56:26 +01:00
Sebastian Castro
24b46984d4 colibris: Style ep_set_title_on_pad 2018-11-08 21:56:18 +01:00
Sebastian Castro
dad6c217ef colibris: improvements 2018-11-08 21:56:17 +01:00
Sebastian Castro
3f761121b2 colibris: improve colibris responsive 2018-11-08 21:56:15 +01:00
Sebastian Castro
6cc499bcce colibris: add new skin, initial commit
Needs further development: responsive, plugins, configuration...
2018-11-08 21:56:14 +01:00
drebs
39fbc37dd8 index.html: generate unique pad names
Etherpad-lite relies on the user's browser to generate a random pad
name, but the current solution is not safe against collisions. In order
to generate unique pad names, the following modifications are made:

* use a PRNG instead of Math.random() and ensure uniform distribution
  when selecting chars.

* choose the pad name length to achieve a specific number of bits of
  security.

Closes: #3516
2018-11-26 23:07:34 +01:00
translatewiki.net
7df26840cb Localisation updates from https://translatewiki.net. 2018-11-22 07:26:44 +01:00
translatewiki.net
c17f5e5f04 Localisation updates from https://translatewiki.net. 2018-11-19 08:38:11 +01:00
Sebastian Castro
d3d1fd21bb fonts: add pencil, link and table icon
Preparatory work for introducing colibris skin
2018-11-08 21:56:13 +01:00
Sebastian Castro
e80f9a6f59 pad.css: group togheter three very similar rules.
a) these rules:
  [class^="icon-"]:before
  [class*=" icon-"]:before

b) were the same as this one:
  [data-icon]:before

except the rules in b) had a "content: attr(data-icon)" rule, too.

This commit groups all of them together, and gets rid of the "attr(data-icon)".

The commit that introduced these rules in the first place, and that are now
partially reverted, was 9aea689438 (move tiny bit
of font awesome we actually use into pad.css) from 2014-11-19.

Preparatory work for introducing colibris skin
2018-11-08 21:56:11 +01:00
Sebastian Castro
63ec2d8cc2 font picker: improve the font picker (closes #3451)
Preparatory work for introducing colibris skin
2018-11-08 21:56:10 +01:00
Sebastian Castro
c5a07e6827 pad.html: add css purpose classes
Preparatory work for introducing colibris skin
2018-11-08 21:56:09 +01:00
Sebastian Castro
5c683da435 timeslider.html: import pad.css so the pad will look the same
Preparatory work for introducing colibris skin
2018-11-08 21:56:08 +01:00
Sebastian Castro
23eb1701ed ace2_inner: fix first line number position
Preparatory work for introducing colibris skin
2018-11-08 21:55:58 +01:00
Sebastian Castro
4115f792e4 ace.js: prioritize the skin style over the plugin style
Preparatory work for introducing colibris skin
2018-11-08 21:55:34 +01:00
Sebastian Castro
8a6eae26d7 ace.js: also add plugins names to #outerdocbody (refs #3488)
This commit is an integration to aa8204e5dfe4
2018-11-08 21:55:07 +01:00
translatewiki.net
b0210c1b55 Localisation updates from https://translatewiki.net. 2018-11-12 08:37:52 +01:00
translatewiki.net
1aeff40be3 Localisation updates from https://translatewiki.net. 2018-11-08 09:56:07 +01:00
translatewiki.net
74b2bd1a4f Localisation updates from https://translatewiki.net. 2018-11-05 08:42:25 +01:00
translatewiki.net
0443de4dc9 Localisation updates from https://translatewiki.net. 2018-11-01 08:08:05 +01:00
muxator
5b88882e34 LibreOffice: add debugging log statements 2018-11-01 00:22:27 +01:00
muxator
4b8a0ff4ac LibreOffice: rename variables (conversion is generic and not PDF-specific) 2018-11-01 00:18:26 +01:00
muxator
73d09f1c6c LibreOffice: rephrase comments (conversion is generic and not PDF-specific) 2018-10-31 22:34:11 +01:00
muxator
df5618b274 ImportHandler: flattened code
Removed redundant else, no functional changes
2018-10-31 23:34:15 +01:00
muxator
fcd88de900 ImportHandler: flattened code
Removed redundant else, no functional changes
2018-10-31 23:31:23 +01:00
muxator
49a7572cee ImportHandler: early return by condition inversion
No functional changes
2018-10-31 23:28:52 +01:00
muxator
df15daac0e ImportHandler: early return by condition inversion
No functional changes
2018-10-31 23:27:22 +01:00
muxator
12bb97dc2d ImportHandler: early return by condition inversion
No functional changes
2018-10-31 23:24:56 +01:00
muxator
2b8e45e2bd ImportHandler: anticipated the error checking
No functional changes.
2018-10-31 23:22:50 +01:00
muxator
4c2ad68b69 ImportHandler: early return via DeMorgan's law
Inverted a boolean condition, no functional changes.
2018-10-31 23:20:55 +01:00
muxator
f652ba8c52 ImportHandler: flattened code
Removed redundant else, no functional changes
2018-10-31 23:16:20 +01:00
muxator
fb552b2dbb ImportHandler: early return via DeMorgan's law
Inverted a boolean condition, no functional changes.
2018-10-31 23:15:01 +01:00
muxator
9d104cc4b0 ImportHandler: early return via DeMorgan's law
Inverted a boolean condition, no functional changes.
2018-10-31 23:09:27 +01:00
muxator
395db73eb1 ImportHandler: early return by condition inversion
No functional changes
2018-10-31 23:00:45 +01:00
muxator
6727a77073 ImportHandler: flatten code
No functional changes
2018-10-31 22:55:58 +01:00
Luc Didry
e8558e3497 Allow to import files using soffice
Currently, you have to use Abiword to convert odt, pdf and doc files to be able to import those files.
This add soffice as convertor too.
2018-10-31 22:21:48 +01:00
muxator
f6cef9dfd2 skins: fix timeslider support
Found by Sebastian Castro <90scastro@gmail.com>
This was really meant to be part of 9c990ab08a
2018-10-29 21:46:19 +01:00
translatewiki.net
20be994d9b Localisation updates from https://translatewiki.net. 2018-10-18 08:18:00 +02:00
muxator
9774518525 dependencies: update graceful-fs, 4.1.3 -> 4.1.11 2018-10-17 00:37:35 +02:00
muxator
e68edcd23d dependencies: update cookie-parser, 1.3.4 -> 1.4.3 2018-10-17 00:34:28 +02:00
muxator
f67fc3ad38 dependencies: update ejs, 2.5.7 -> 2.6.1 2018-10-17 00:31:55 +02:00
muxator
a585487802 dependencies: update semver, 5.1.0 -> 5.6.0 2018-10-17 00:28:21 +02:00
muxator
50b245d260 dependencies: update request, 2.83.0 -> 2.88.0 2018-10-17 00:27:51 +02:00
muxator
c69c0053b6 dependencies: update npm, 6.4.0 -> 6.4.1 2018-10-17 00:27:25 +02:00
muxator
5734eea10b dependencies: update express, 4.16.3 -> 4.16.4 2018-10-17 00:26:51 +02:00