From a544aff6ac16bdeb16bc989fe456edefe3522ade Mon Sep 17 00:00:00 2001 From: Aleksei Gurianov Date: Fri, 13 Jul 2018 09:54:12 +0400 Subject: [PATCH] improve and document developer setup (#161) japanese commit fixes #158 --- Dockerfile | 3 +- README.md | 109 ++--- compose-dev-frontend.yml | 2 +- docker-compose.yml | 1 - start.sh | 7 +- web/app/common/constants.js | 4 +- web/app/embed.js | 4 +- web/app/last-comments.js | 1 + web/app/remark.js | 1 + web/counter.ejs | 12 +- web/dev.ejs | 44 -- web/iframe.html | 9 +- web/index.ejs | 10 +- web/last-comments.ejs | 5 +- web/package-lock.json | 802 +++++++++++++++++++++++++++--------- web/package.json | 11 +- web/webpack.config.js | 50 +-- 17 files changed, 728 insertions(+), 347 deletions(-) delete mode 100644 web/dev.ejs diff --git a/Dockerfile b/Dockerfile index efa84d9f..11911d97 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,9 +62,10 @@ FROM node:10.6-alpine as build-frontend ARG CI ARG SKIP_FRONTEND_TEST +ARG NODE_ENV=production -ADD web /srv/web COPY --from=build-frontend-deps /srv/web/node_modules /srv/web/node_modules +ADD web /srv/web RUN cd /srv/web && \ if [ -z "$SKIP_FRONTEND_TEST" ] ; then npx run-p lint test build ; \ else echo "skip frontend tests and lint" ; npm run build ; fi && \ diff --git a/README.md b/README.md index 14831503..ddaa5c59 100644 --- a/README.md +++ b/README.md @@ -195,50 +195,9 @@ Admins/moderators should be defined in `docker-compose.yml` as a list of user ID To get user id just login and click on your username or any other user you want to promote to admins. It will expand login info and show full user ID. +### Setup on your website -### Frontend - -Frontend part is building automatically along with backend if you use `docker-compose`. - -For manual building: - -* install [Node.js 8](https://nodejs.org/en/) or higher; -* install [NPM 6.1.0](https://www.npmjs.com/package/npm) or higher; -* run `npm install` inside `./web`; -* run `npm run build` there; -* result files will be saved in `./web/public`. - -For development mode use `npm start` instead of `npm run build`. -In this case `webpack` will serve files using `webpack-dev-server` on `localhost:8080`. - -URLs for development: - -* `localhost:8080` — page with embedded script from `REMARK_URL` (default: `https://demo.remark42.com`); -* `localhost:8080/dev.html` — page with embedded script from local folder; -* `localhost:8080/last-comments.html` — page with embedded script for last comments; -* `localhost:8080/counter.html` — page with embedded script for counter with examples. - -#### Testing - -Also you can use fully functional local version to develop and test both frontend & backend. - -To bring it up run: - -```bash -docker-compose -f compose-dev-frontend.yml build -docker-compose -f compose-dev-frontend.yml up -``` - -It starts Remark42 on `localhost:8080` -and adds local OAuth2 provider “Dev”. To access UI demo page go to `localhost:8080/web`. - -That `compose-dev.yml` (you can find it in the root of the project) also defines if default logged user admin or not. -By default, it will be the admin, and to switch it to regular user comment or remove `-ADMIN=dev_user` there. You can also select -any other user name from the login dialog. - -#### Usage - -##### Comments +#### Comments It's a main widget which renders list of comments. @@ -305,7 +264,7 @@ Add this snippet to the bottom of web page: ```html - - diff --git a/web/iframe.html b/web/iframe.html index 5c841c04..d65d6c24 100644 --- a/web/iframe.html +++ b/web/iframe.html @@ -1,5 +1,5 @@ - + @@ -75,6 +75,13 @@