Skip to content

Commit

Permalink
Merge branch 'master' into toolbar_select
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmartyrk committed Jan 6, 2021
2 parents 27e1ec3 + f737ca3 commit 833d8b2
Show file tree
Hide file tree
Showing 3,620 changed files with 518 additions and 342,602 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
51 changes: 51 additions & 0 deletions .github/workflows/backend-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# You need to change lines 38 and 46 in case the plugin's name on npmjs.com is different
# from the repository name

name: "Backend tests"

# any branch is useful for testing before a PR is submitted
on: [push, pull_request]

jobs:
withplugins:
# run on pushes to any branch
# run on PRs from external forks
if: |
(github.event_name != 'pull_request')
|| (github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id)
name: with Plugins
runs-on: ubuntu-latest

steps:
- name: Install libreoffice
run: |
sudo add-apt-repository -y ppa:libreoffice/ppa
sudo apt update
sudo apt install -y --no-install-recommends libreoffice libreoffice-pdfimport
# clone etherpad-lite
- name: Install etherpad core
uses: actions/checkout@v2
with:
repository: ether/etherpad-lite

- name: Install all dependencies and symlink for ep_etherpad-lite
run: bin/installDeps.sh

# clone this repository into node_modules/ep_plugin-name
- name: Checkout plugin repository
uses: actions/checkout@v2
with:
path: ./node_modules/${{github.event.repository.name}}

- name: Install plugin dependencies
run: |
cd node_modules/${{github.event.repository.name}}
npm ci
# configures some settings and runs npm run test
- name: Run the backend tests
run: tests/frontend/travis/runnerBackend.sh

##ETHERPAD_NPM_V=1
## NPM configuration automatically created using bin/plugins/updateAllPluginsScript.sh
39 changes: 36 additions & 3 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,55 @@
name: Node.js Package

on:
#trigger on every commit to the main branch
pull_request:
push:
branches:
- main
- master

jobs:
build:
test:
runs-on: ubuntu-latest
steps:
# Clone ether/etherpad-lite to ../etherpad-lite so that ep_etherpad-lite
# can be "installed" in this plugin's node_modules. The checkout v2 action
# doesn't support cloning outside of $GITHUB_WORKSPACE (see
# https://github.com/actions/checkout/issues/197), so the repo is first
# cloned to etherpad-lite then moved to ../etherpad-lite. To avoid
# conflicts with this plugin's clone, etherpad-lite must be cloned and
# moved out before this plugin's repo is cloned to $GITHUB_WORKSPACE.
- uses: actions/checkout@v2
with:
repository: ether/etherpad-lite
path: etherpad-lite
- run: mv etherpad-lite ..
# etherpad-lite has been moved outside of $GITHUB_WORKSPACE, so it is now
# safe to clone this plugin's repo to $GITHUB_WORKSPACE.
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
# All of ep_etherpad-lite's devDependencies are installed because the
# plugin might do `require('ep_etherpad-lite/node_modules/${devDep}')`.
# Eventually it would be nice to create an ESLint plugin that prohibits
# Etherpad plugins from piggybacking off of ep_etherpad-lite's
# devDependencies. If we had that, we could change this line to only
# install production dependencies.
- run: cd ../etherpad-lite/src && npm ci
- run: npm ci
# This runs some sanity checks and creates a symlink at
# node_modules/ep_etherpad-lite that points to ../../etherpad-lite/src.
# This step must be done after `npm ci` installs the plugin's dependencies
# because npm "helpfully" cleans up such symlinks. :( Installing
# ep_etherpad-lite in the plugin's node_modules prevents lint errors and
# unit test failures if the plugin does `require('ep_etherpad-lite/foo')`.
- run: npm install --no-save ep_etherpad-lite@file:../etherpad-lite/src
- run: npm test
- run: npm run lint

publish-npm:
needs: build
if: github.event_name == 'push'
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -38,3 +68,6 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- run: git push --follow-tags

##ETHERPAD_NPM_V=1
## NPM configuration automatically created using bin/plugins/updateAllPluginsScript.sh
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.ep_initialized
node_modules/
npm-debug.log
30 changes: 14 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,52 +21,50 @@ env:

jobs:
include:
- name: "Lint test package-lock"
install:
- name: "Lint test package-lock"
install:
- "npm install lockfile-lint"
script:
script:
- npx lockfile-lint --path package-lock.json --validate-https --allowed-hosts npm
- name: "Run the Backend tests"
before_script:
- "tests/frontend/travis/sauce_tunnel.sh"
before_install:
- name: "Run the Backend tests"
before_install:
- sudo add-apt-repository -y ppa:libreoffice/ppa
- sudo apt-get update
- sudo apt-get -y install libreoffice
- sudo apt-get -y install libreoffice-pdfimport
install:
install:
- "npm install"
- "mkdir ep_font_color"
- "mv !(ep_font_color) ep_font_color"
- "git clone https://github.com/ether/etherpad-lite.git etherpad"
- "cd etherpad"
- "mkdir node_modules"
- "mkdir -p node_modules"
- "mv ../ep_font_color node_modules"
- "bin/installDeps.sh"
- "export GIT_HASH=$(git rev-parse --verify --short HEAD)"
- "cd src && npm install && cd -"
script:
script:
- "tests/frontend/travis/runnerBackend.sh"
- name: "Test the Frontend"
before_script:
- name: "Test the Frontend"
before_script:
- "tests/frontend/travis/sauce_tunnel.sh"
install:
install:
- "npm install"
- "mkdir ep_font_color"
- "mv !(ep_font_color) ep_font_color"
- "git clone https://github.com/ether/etherpad-lite.git etherpad"
- "cd etherpad"
- "mkdir node_modules"
- "mkdir -p node_modules"
- "mv ../ep_font_color node_modules"
- "bin/installDeps.sh"
- "export GIT_HASH=$(git rev-parse --verify --short HEAD)"
script:
script:
- "tests/frontend/travis/runner.sh"

notifications:
irc:
channels:
- "irc.freenode.org#etherpad-lite-dev"

##ETHERPAD_TRAVIS_V=7
##ETHERPAD_TRAVIS_V=9
## Travis configuration automatically created using bin/plugins/updateAllPluginsScript.sh
133 changes: 133 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Contributor Guidelines
(Please talk to people on the mailing list before you change this page, see our section on [how to get in touch](https://github.com/ether/etherpad-lite#get-in-touch))

## Pull requests

* the commit series in the PR should be _linear_ (it **should not contain merge commits**). This is necessary because we want to be able to [bisect](https://en.wikipedia.org/wiki/Bisection_(software_engineering)) bugs easily. Rewrite history/perform a rebase if necessary
* PRs should be issued against the **develop** branch: we never pull directly into **master**
* PRs **should not have conflicts** with develop. If there are, please resolve them rebasing and force-pushing
* when preparing your PR, please make sure that you have included the relevant **changes to the documentation** (preferably with usage examples)
* contain meaningful and detailed **commit messages** in the form:
```
submodule: description
longer description of the change you have made, eventually mentioning the
number of the issue that is being fixed, in the form: Fixes #someIssueNumber
```
* if the PR is a **bug fix**:
* the first commit in the series must be a test that shows the failure
* subsequent commits will fix the bug and make the test pass
* the final commit message should include the text `Fixes: #xxx` to link it to its bug report
* think about stability: code has to be backwards compatible as much as possible. Always **assume your code will be run with an older version of the DB/config file**
* if you want to remove a feature, **deprecate it instead**:
* write an issue with your deprecation plan
* output a `WARN` in the log informing that the feature is going to be removed
* remove the feature in the next version
* if you want to add a new feature, put it under a **feature flag**:
* once the new feature has reached a minimal level of stability, do a PR for it, so it can be integrated early
* expose a mechanism for enabling/disabling the feature
* the new feature should be **disabled** by default. With the feature disabled, the code path should be exactly the same as before your contribution. This is a __necessary condition__ for early integration
* think of the PR not as something that __you wrote__, but as something that __someone else is going to read__. The commit series in the PR should tell a novice developer the story of your thoughts when developing it

## How to write a bug report

* Please be polite, we all are humans and problems can occur.
* Please add as much information as possible, for example
* client os(s) and version(s)
* browser(s) and version(s), is the problem reproducible on different clients
* special environments like firewalls or antivirus
* host os and version
* npm and nodejs version
* Logfiles if available
* steps to reproduce
* what you expected to happen
* what actually happened
* Please format logfiles and code examples with markdown see github Markdown help below the issue textarea for more information.

If you send logfiles, please set the loglevel switch DEBUG in your settings.json file:

```
/* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */
"loglevel": "DEBUG",
```

The logfile location is defined in startup script or the log is directly shown in the commandline after you have started etherpad.

## General goals of Etherpad
To make sure everybody is going in the same direction:
* easy to install for admins and easy to use for people
* easy to integrate into other apps, but also usable as standalone
* lightweight and scalable
* extensible, as much functionality should be extendable with plugins so changes don't have to be done in core.
Also, keep it maintainable. We don't wanna end up as the monster Etherpad was!

## How to work with git?
* Don't work in your master branch.
* Make a new branch for every feature you're working on. (This ensures that you can work you can do lots of small, independent pull requests instead of one big one with complete different features)
* Don't use the online edit function of github (this only creates ugly and not working commits!)
* Try to make clean commits that are easy readable (including descriptive commit messages!)
* Test before you push. Sounds easy, it isn't!
* Don't check in stuff that gets generated during build or runtime
* Make small pull requests that are easy to review but make sure they do add value by themselves / individually

## Coding style
* Do write comments. (You don't have to comment every line, but if you come up with something that's a bit complex/weird, just leave a comment. Bear in mind that you will probably leave the project at some point and that other people will read your code. Undocumented huge amounts of code are worthless!)
* Never ever use tabs
* Indentation: JS/CSS: 2 spaces; HTML: 4 spaces
* Don't overengineer. Don't try to solve any possible problem in one step, but try to solve problems as easy as possible and improve the solution over time!
* Do generalize sooner or later! (if an old solution, quickly hacked together, poses more problems than it solves today, refactor it!)
* Keep it compatible. Do not introduce changes to the public API, db schema or configurations too lightly. Don't make incompatible changes without good reasons!
* If you do make changes, document them! (see below)
* Use protocol independent urls "//"

## Branching model / git workflow
see git flow http://nvie.com/posts/a-successful-git-branching-model/

### `master` branch
* the stable
* This is the branch everyone should use for production stuff

### `develop`branch
* everything that is READY to go into master at some point in time
* This stuff is tested and ready to go out

### release branches
* stuff that should go into master very soon
* only bugfixes go into these (see http://nvie.com/posts/a-successful-git-branching-model/ for why)
* we should not be blocking new features to develop, just because we feel that we should be releasing it to master soon. This is the situation that release branches solve/handle.

### hotfix branches
* fixes for bugs in master

### feature branches (in your own repos)
* these are the branches where you develop your features in
* If it's ready to go out, it will be merged into develop

Over the time we pull features from feature branches into the develop branch. Every month we pull from develop into master. Bugs in master get fixed in hotfix branches. These branches will get merged into master AND develop. There should never be commits in master that aren't in develop

## Documentation
The docs are in the `doc/` folder in the git repository, so people can easily find the suitable docs for the current git revision.

Documentation should be kept up-to-date. This means, whenever you add a new API method, add a new hook or change the database model, pack the relevant changes to the docs in the same pull request.

You can build the docs e.g. produce html, using `make docs`. At some point in the future we will provide an online documentation. The current documentation in the github wiki should always reflect the state of `master` (!), since there are no docs in master, yet.

## Testing
Front-end tests are found in the `tests/frontend/` folder in the repository. Run them by pointing your browser to `<yourdomainhere>/tests/frontend`.

Back-end tests can be run from the `src` directory, via `npm test`.

## Things you can help with
Etherpad is much more than software. So if you aren't a developer then worry not, there is still a LOT you can do! A big part of what we do is community engagement. You can help in the following ways
* Triage bugs (applying labels) and confirming their existence
* Testing fixes (simply applying them and seeing if it fixes your issue or not) - Some git experience required
* Notifying large site admins of new releases
* Writing Changelogs for releases
* Creating Windows packages
* Creating releases
* Bumping dependencies periodically and checking they don't break anything
* Write proposals for grants
* Co-Author and Publish CVEs
* Work with SFC to maintain legal side of project
* Maintain TODO page - https://github.com/ether/etherpad-lite/wiki/TODO#IMPORTANT_TODOS

18 changes: 9 additions & 9 deletions exportHTML.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const _ = require('ep_etherpad-lite/static/js/underscore');
'use strict';
const eejs = require('ep_etherpad-lite/node/eejs/');

const colors = ['black', 'red', 'green', 'blue', 'yellow', 'orange'];

// Add the props to be supported in export
exports.exportHtmlAdditionalTagsWithData = async (hookName, pad) => findAllColorUsedOn(pad).map((name) => ['color', name]);

// Iterate over pad attributes to find only the color ones
function findAllColorUsedOn(pad) {
const findAllColorUsedOn = (pad) => {
const colorsUsed = [];
pad.pool.eachAttrib((key, value) => { if (key === 'color') colorsUsed.push(value); });
return colorsUsed;
}
};

// Add the props to be supported in export
exports.exportHtmlAdditionalTagsWithData = async (hookName, pad) => findAllColorUsedOn(pad).
map((name) => ['color', name]);

// Include CSS for HTML export
exports.stylesForExport = async (hookName, padId) => eejs.require('ep_font_color/static/css/color.css');
exports.stylesForExport = async (hookName, padId) => eejs
.require('ep_font_color/static/css/color.css');

exports.getLineHTMLForExport = async (hookName, context) => {
// Replace data-color="foo" with class="color:x".
Expand Down
20 changes: 11 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
'use strict';

const eejs = require('ep_etherpad-lite/node/eejs/');
const settings = require('ep_etherpad-lite/node/utils/Settings');

exports.eejsBlock_editbarMenuLeft = function (hook_name, args, cb) {
if (JSON.stringify(settings.toolbar).indexOf('fontColor') > -1 ) {
exports.eejsBlock_editbarMenuLeft = (hook, args, cb) => {
if (JSON.stringify(settings.toolbar).indexOf('fontColor') > -1) {
return cb();
}
args.content += eejs.require('ep_font_color/templates/editbarButtons.ejs');
return cb();
};

exports.eejsBlock_dd_format = function (hook_name, args, cb) {
exports.eejsBlock_dd_format = (hook, args, cb) => {
args.content += eejs.require('ep_font_color/templates/fileMenu.ejs');
return cb();
};

exports.padInitToolbar = function (hook_name, args, cb) {
exports.padInitToolbar = (hook, args, cb) => {
const toolbar = args.toolbar;
const colors = ['black', 'red', 'green', 'blue', 'yellow', 'orange'];
const fontColor = toolbar.selectButton({
command: 'fontColor',
class: 'color-selection',
selectId: 'color-selection'
command: 'fontColor',
class: 'color-selection',
selectId: 'color-selection',
});
fontColor.addOption('dummy', 'color', {'data-l10n-id': 'ep_font_color.color'});
colors.forEach(function (color, value) {
fontColor.addOption(value, color, {'data-l10n-id': 'ep_font_color.'+color});
colors.forEach((color, value) => {
fontColor.addOption(value, color, {'data-l10n-id': `ep_font_color.${color}`});
});

toolbar.registerButton('fontColor', fontColor);
Expand Down
Loading

0 comments on commit 833d8b2

Please sign in to comment.