From c7dfc8d105e24ddd5223f935bc097a3111a8e27e Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Fri, 1 Jun 2018 16:27:35 +0200 Subject: [PATCH 01/44] change paths to conform a bit more to other cloudron apps Signed-off-by: Felix Bartels --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index fcfbf1c..9a38b39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ ENV NODEJS_VERSION 6.9.5 RUN ln -s /usr/local/node-$NODEJS_VERSION/bin/node /usr/local/bin/node && \ ln -s /usr/local/node-$NODEJS_VERSION/bin/npm /usr/local/bin/npm -WORKDIR /hackmd +WORKDIR /app/code ENV HACKMD_VERSION d1d6d5810b12645ddb02275ce0c2498b2189a8a0 RUN curl -L https://github.com/hackmdio/hackmd/archive/$HACKMD_VERSION.tar.gz | tar -xz --strip-components 1 -f - @@ -20,7 +20,6 @@ RUN npm run build RUN npm prune --production # add utils -ADD CloudronManifest.json ./ ADD start.sh ./ RUN chmod +x ./start.sh @@ -30,4 +29,4 @@ RUN ln -sfn /app/data/build/constant.js ./public/build/constant.js && \ EXPOSE 3000 -CMD ["/hackmd/start.sh"] +CMD ["/app/code/start.sh"] From 239ff77fb422c3cd0c40122615f285821f95b21d Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Fri, 1 Jun 2018 16:40:26 +0200 Subject: [PATCH 02/44] update to latest hackmd release add todo list Signed-off-by: Felix Bartels --- CloudronManifest.json | 2 +- Dockerfile | 2 +- TODO.md | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 TODO.md diff --git a/CloudronManifest.json b/CloudronManifest.json index 56a51dd..695616c 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -5,7 +5,7 @@ "description": "file://DESCRIPTION.md", "changelog": "file://CHANGELOG", "tagline": "Best way to write and share your knowledge in markdown", - "version": "0.0.2", + "version": "0.0.3", "healthCheckPath": "/status", "httpPort": 3000, "addons": { diff --git a/Dockerfile b/Dockerfile index 9a38b39..015255a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN ln -s /usr/local/node-$NODEJS_VERSION/bin/node /usr/local/bin/node && \ WORKDIR /app/code -ENV HACKMD_VERSION d1d6d5810b12645ddb02275ce0c2498b2189a8a0 +ENV HACKMD_VERSION 1.1.1-ce RUN curl -L https://github.com/hackmdio/hackmd/archive/$HACKMD_VERSION.tar.gz | tar -xz --strip-components 1 -f - # npm, deps diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..db7e4fe --- /dev/null +++ b/TODO.md @@ -0,0 +1,4 @@ +# TODO list + +- inside of the app the uid is shown instead of the username +- notes seem to get lost during update From 7368296ca2e8a8018bf3eb9e168148053df6255b Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Fri, 1 Jun 2018 16:41:45 +0200 Subject: [PATCH 03/44] update changelog Signed-off-by: Felix Bartels --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index fd48cc2..878834f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +[0.0.3] +update to latest upstream release + [0.0.2] minor bugfix From d187ffb9e942f9a4db71bc00221cc3761901475b Mon Sep 17 00:00:00 2001 From: Thierry Pasquier Date: Mon, 4 Jun 2018 22:31:13 +0200 Subject: [PATCH 04/44] added partial config file to set tmp directory and ldap username --- Dockerfile | 1 + config.json | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 config.json diff --git a/Dockerfile b/Dockerfile index 015255a..0d7f828 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,7 @@ RUN npm prune --production # add utils ADD start.sh ./ RUN chmod +x ./start.sh +ADD config.json ./ # use local storage RUN ln -sfn /app/data/build/constant.js ./public/build/constant.js && \ diff --git a/config.json b/config.json new file mode 100644 index 0000000..1922ab0 --- /dev/null +++ b/config.json @@ -0,0 +1,8 @@ +{ + "production": { + "tmpPath": "../../app/data/tmp", + "ldap": { + "usernameField": "username" + } + } +} From 4b88e0a5e57417f6b28b33bab9dc87a3a91ad101 Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Tue, 5 Jun 2018 09:39:57 +0200 Subject: [PATCH 05/44] merge pr from @jeau and update changelog Signed-off-by: Felix Bartels --- CHANGELOG | 6 +++++- CloudronManifest.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 878834f..b629e7b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ +[0.0.4] +add config file to set tmp directory and ldap username +Thanks go out to @jeau for the pr! + [0.0.3] -update to latest upstream release +update to 1.1.1-ce upstream release [0.0.2] minor bugfix diff --git a/CloudronManifest.json b/CloudronManifest.json index 695616c..2f6d640 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -5,7 +5,7 @@ "description": "file://DESCRIPTION.md", "changelog": "file://CHANGELOG", "tagline": "Best way to write and share your knowledge in markdown", - "version": "0.0.3", + "version": "0.0.4", "healthCheckPath": "/status", "httpPort": 3000, "addons": { From 48f6727b0463d7b39cc797bacd6fb755944008dd Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Tue, 5 Jun 2018 09:42:14 +0200 Subject: [PATCH 06/44] update todo Signed-off-by: Felix Bartels --- TODO.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index db7e4fe..0884765 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,3 @@ # TODO list -- inside of the app the uid is shown instead of the username -- notes seem to get lost during update +- merge cloudron docker image with upstream source from https://github.com/hackmdio/docker-hackmd From caf4af5bc300d895f33054d20b9f9a43b8018b8e Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Wed, 6 Jun 2018 14:22:37 +0200 Subject: [PATCH 07/44] properly format config.json set usernamefield through env variable add comment about email env variables Signed-off-by: Felix Bartels --- config.json | 12 ++++++------ start.sh | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/config.json b/config.json index 1922ab0..11489cd 100644 --- a/config.json +++ b/config.json @@ -1,8 +1,8 @@ { - "production": { - "tmpPath": "../../app/data/tmp", - "ldap": { - "usernameField": "username" - } - } + "production": { + "tmpPath": "../../app/data/tmp", + "ldap": { + "usernameField": "username" + } + } } diff --git a/start.sh b/start.sh index 37c2e8d..1797c7f 100644 --- a/start.sh +++ b/start.sh @@ -21,9 +21,11 @@ export HMD_LDAP_BINDDN="$LDAP_BIND_DN" export HMD_LDAP_BINDCREDENTIALS="$LDAP_BIND_PASSWORD" export HMD_LDAP_SEARCHBASE="$LDAP_USERS_BASE_DN" export HMD_LDAP_SEARCHFILTER="(username={{username}})" +export HMD_LDAP_USERNAMEFIELD="username" +export HMD_IMAGE_UPLOAD_TYPE=filesystem +# the following two changes could be transferred to config.json to enable users to change this export HMD_EMAIL=false export HMD_ALLOW_EMAIL_REGISTER=false -export HMD_IMAGE_UPLOAD_TYPE=filesystem # run /usr/local/bin/gosu cloudron:cloudron node app.js From 8c49348111e51a8ce54d8910cf89be654ef0fa04 Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Wed, 6 Jun 2018 14:23:31 +0200 Subject: [PATCH 08/44] remove usernamefield from config.json (already set in start.sh) Signed-off-by: Felix Bartels --- config.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/config.json b/config.json index 11489cd..c204ba2 100644 --- a/config.json +++ b/config.json @@ -1,8 +1,5 @@ { "production": { - "tmpPath": "../../app/data/tmp", - "ldap": { - "usernameField": "username" - } + "tmpPath": "../../app/data/tmp" } } From 06b982c8ce5d97eb74a95e1d8e53351d80a4224c Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Thu, 7 Jun 2018 09:12:29 +0200 Subject: [PATCH 09/44] disable pdf export until https://github.com/hackmdio/hackmd/issues/820 is fixed Signed-off-by: Felix Bartels --- start.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/start.sh b/start.sh index 1797c7f..ae8f1d8 100644 --- a/start.sh +++ b/start.sh @@ -26,6 +26,8 @@ export HMD_IMAGE_UPLOAD_TYPE=filesystem # the following two changes could be transferred to config.json to enable users to change this export HMD_EMAIL=false export HMD_ALLOW_EMAIL_REGISTER=false +# disable pdf export until https://github.com/hackmdio/hackmd/issues/820 is fixed +export HMD_ALLOW_PDF_EXPORT=false # run /usr/local/bin/gosu cloudron:cloudron node app.js From 50263a0f2c39a015259e18b6027cf958bebea89e Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Thu, 7 Jun 2018 09:13:27 +0200 Subject: [PATCH 10/44] update changelog Signed-off-by: Felix Bartels --- CHANGELOG | 3 +++ CloudronManifest.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index b629e7b..0e8bda0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +[0.0.5] +disable pdf export until https://github.com/hackmdio/hackmd/issues/820 is fixed + [0.0.4] add config file to set tmp directory and ldap username Thanks go out to @jeau for the pr! diff --git a/CloudronManifest.json b/CloudronManifest.json index 2f6d640..953c865 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -5,7 +5,7 @@ "description": "file://DESCRIPTION.md", "changelog": "file://CHANGELOG", "tagline": "Best way to write and share your knowledge in markdown", - "version": "0.0.4", + "version": "0.0.5", "healthCheckPath": "/status", "httpPort": 3000, "addons": { From 5dce2573c426f9d9ee2543e117f46b31f0a8d74f Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Fri, 8 Jun 2018 12:11:01 +0200 Subject: [PATCH 11/44] switch default visibility to private for new notes Signed-off-by: Felix Bartels --- CHANGELOG | 3 +++ CloudronManifest.json | 2 +- start.sh | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 0e8bda0..98d280e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +[0.0.6] +switch default visibility to private for new notes + [0.0.5] disable pdf export until https://github.com/hackmdio/hackmd/issues/820 is fixed diff --git a/CloudronManifest.json b/CloudronManifest.json index 953c865..58cf52a 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -5,7 +5,7 @@ "description": "file://DESCRIPTION.md", "changelog": "file://CHANGELOG", "tagline": "Best way to write and share your knowledge in markdown", - "version": "0.0.5", + "version": "0.0.6", "healthCheckPath": "/status", "httpPort": 3000, "addons": { diff --git a/start.sh b/start.sh index ae8f1d8..5b522f7 100644 --- a/start.sh +++ b/start.sh @@ -28,6 +28,8 @@ export HMD_EMAIL=false export HMD_ALLOW_EMAIL_REGISTER=false # disable pdf export until https://github.com/hackmdio/hackmd/issues/820 is fixed export HMD_ALLOW_PDF_EXPORT=false +# respect users privacy and make notes private by default +export HMD_DEFAULT_PERMISSION=private # run /usr/local/bin/gosu cloudron:cloudron node app.js From 70e3eecc73fe888100d7e847a64925341bd0afe0 Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Sun, 10 Jun 2018 07:44:44 +0200 Subject: [PATCH 12/44] set more sharing options as suggested in https://github.com/fbartels/cloudron-hackmd/pull/3#issuecomment-395958825 Signed-off-by: Felix Bartels --- start.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/start.sh b/start.sh index 5b522f7..f7a1c5b 100644 --- a/start.sh +++ b/start.sh @@ -30,6 +30,10 @@ export HMD_ALLOW_EMAIL_REGISTER=false export HMD_ALLOW_PDF_EXPORT=false # respect users privacy and make notes private by default export HMD_DEFAULT_PERMISSION=private +# let users choose to allow guest editing +export HMD_ALLOW_ANONYMOUS_EDITS=true +# create new page, if url does not yet exist +export HMD_ALLOW_FREEURL=true # run /usr/local/bin/gosu cloudron:cloudron node app.js From 074916f79d5e5c32808c5e400666ff16a32b28df Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Sun, 10 Jun 2018 07:46:37 +0200 Subject: [PATCH 13/44] update changelog Signed-off-by: Felix Bartels --- CHANGELOG | 4 ++++ CloudronManifest.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 98d280e..516f6d7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +[0.0.7] +make it possible to set notes publicly writable +automatically create new notes if url doesnt exist + [0.0.6] switch default visibility to private for new notes diff --git a/CloudronManifest.json b/CloudronManifest.json index 58cf52a..7d2ba14 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -5,7 +5,7 @@ "description": "file://DESCRIPTION.md", "changelog": "file://CHANGELOG", "tagline": "Best way to write and share your knowledge in markdown", - "version": "0.0.6", + "version": "0.0.7", "healthCheckPath": "/status", "httpPort": 3000, "addons": { From 15e05d728242a4af25d4031f9994a2cc61b71a0a Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Sun, 10 Jun 2018 07:53:45 +0200 Subject: [PATCH 14/44] update todo Signed-off-by: Felix Bartels --- TODO.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO.md b/TODO.md index 0884765..2f04f6d 100644 --- a/TODO.md +++ b/TODO.md @@ -1,3 +1,5 @@ # TODO list - merge cloudron docker image with upstream source from https://github.com/hackmdio/docker-hackmd +- generate sessionSecret in start.sh and write it to config.json to make user session persist restarts +- move config.json into /app/data From 3915862ea5151766b1419fa2367b6101f35bd928 Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Mon, 11 Jun 2018 08:40:12 +0200 Subject: [PATCH 15/44] some path cleanups (prefer absolute over relative paths) first step to generate user session in config.json Signed-off-by: Felix Bartels --- Dockerfile | 13 ++++++++----- config.json | 2 +- start.sh | 9 ++++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0d7f828..f0c4ad1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,13 +20,16 @@ RUN npm run build RUN npm prune --production # add utils -ADD start.sh ./ -RUN chmod +x ./start.sh -ADD config.json ./ +ADD start.sh /app/code +RUN chmod +x /app/code/start.sh # use local storage -RUN ln -sfn /app/data/build/constant.js ./public/build/constant.js && \ - rm -rf ./public/uploads && ln -sf /app/data/uploads ./public/uploads +RUN ln -sfn /app/data/build/constant.js /app/code/public/build/constant.js && \ + rm -rf /app/code/public/uploads && ln -sf /app/data/uploads /app/code/public/uploads + +# add user definable config +ADD config.json /app/code/config.json-cloudron +RUN ln -sfn /app/data/config.json /app/code/config.json EXPOSE 3000 diff --git a/config.json b/config.json index c204ba2..45fe38c 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,5 @@ { "production": { - "tmpPath": "../../app/data/tmp" + "tmpPath": "/app/data/tmp" } } diff --git a/start.sh b/start.sh index f7a1c5b..af538ca 100644 --- a/start.sh +++ b/start.sh @@ -5,9 +5,12 @@ mkdir -p /app/data/build && \ mkdir -p /app/data/uploads chown -R cloudron:cloudron /app/data -if [ -f .sequelizerc ]; -then - node_modules/.bin/sequelize db:migrate +if [ ! -e /app/data/config.json ]; then + cp /app/code/config.json-cloudron /app/data/config.json +fi + +if [ -f .sequelizerc ]; then + node_modules/.bin/sequelize db:migrate fi # wait for db up From d4dad2c004ad487065d1328cf2b89de5a5208a97 Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Mon, 11 Jun 2018 08:41:15 +0200 Subject: [PATCH 16/44] update todo Signed-off-by: Felix Bartels --- TODO.md | 1 - 1 file changed, 1 deletion(-) diff --git a/TODO.md b/TODO.md index 2f04f6d..831b9d0 100644 --- a/TODO.md +++ b/TODO.md @@ -2,4 +2,3 @@ - merge cloudron docker image with upstream source from https://github.com/hackmdio/docker-hackmd - generate sessionSecret in start.sh and write it to config.json to make user session persist restarts -- move config.json into /app/data From fa2260a2c9c941ade817aebcb2bb49811fd3e25a Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Tue, 12 Jun 2018 08:27:34 +0200 Subject: [PATCH 17/44] generate a per installation unique sessionsecret (to persist sessions between app restarts) Signed-off-by: Felix Bartels --- Dockerfile | 5 +++++ config.json | 6 +++--- start.sh | 8 ++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index f0c4ad1..3bde9de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,9 @@ FROM cloudron/base:0.10.0 +# install jq and moreutils (for sponge). +# can be removed once https://git.cloudron.io/cloudron/docker-base-image/merge_requests/3 is merged and released +RUN apt update && apt -y full-upgrade && \ + apt -y install moreutils jq && \ + rm -rf /var/cache/apt /var/lib/apt/lists # setup nodejs version ENV NODEJS_VERSION 6.9.5 diff --git a/config.json b/config.json index 45fe38c..01a6fd0 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,5 @@ { - "production": { - "tmpPath": "/app/data/tmp" - } + "production": { + "tmpPath": "/app/data/tmp" + } } diff --git a/start.sh b/start.sh index af538ca..b7447ce 100644 --- a/start.sh +++ b/start.sh @@ -16,6 +16,14 @@ fi # wait for db up sleep 3 +# generate and store an unique sessionSecret for this installation +CONFIG_JSON=/app/data/config.json +if [ $(jq .sessionSecret $CONFIG_JSON) == "null" ]; then + echo "generating sessionSecret" + sessionsecret=$(pwgen -1sc 32) + jq ".sessionSecret = \"$sessionsecret\"" $CONFIG_JSON | sponge $CONFIG_JSON +fi + export NODE_ENV='production' export HMD_ALLOW_ANONYMOUS="false" export HMD_DB_URL="$POSTGRESQL_URL" From b1b86a916fa48a3a999caf029cd6c26d754e3b93 Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Tue, 12 Jun 2018 09:28:37 +0200 Subject: [PATCH 18/44] switch tmppath back to a relative one Signed-off-by: Felix Bartels --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 01a6fd0..2506a1b 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,5 @@ { "production": { - "tmpPath": "/app/data/tmp" + "tmpPath": "../../app/data/tmp" } } From b78e17053cab979fe91c91e7e15b806c40a4bc68 Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Wed, 13 Jun 2018 08:01:32 +0200 Subject: [PATCH 19/44] update changelog Signed-off-by: Felix Bartels --- CHANGELOG | 3 +++ CloudronManifest.json | 2 +- TODO.md | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 516f6d7..760c7b7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +[0.0.8] +Generate sessionSecret at initial app startup + [0.0.7] make it possible to set notes publicly writable automatically create new notes if url doesnt exist diff --git a/CloudronManifest.json b/CloudronManifest.json index 7d2ba14..43b723a 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -5,7 +5,7 @@ "description": "file://DESCRIPTION.md", "changelog": "file://CHANGELOG", "tagline": "Best way to write and share your knowledge in markdown", - "version": "0.0.7", + "version": "0.0.8", "healthCheckPath": "/status", "httpPort": 3000, "addons": { diff --git a/TODO.md b/TODO.md index 831b9d0..0884765 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,3 @@ # TODO list - merge cloudron docker image with upstream source from https://github.com/hackmdio/docker-hackmd -- generate sessionSecret in start.sh and write it to config.json to make user session persist restarts From dc6e9355d58bb52e7faf9e4783489f7e12bfb96f Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 20 Jun 2018 19:56:24 -0700 Subject: [PATCH 20/44] Set 'x' bit in the repo instead This is just a convention followed in all repos --- Dockerfile | 1 - start.sh | 0 2 files changed, 1 deletion(-) mode change 100644 => 100755 start.sh diff --git a/Dockerfile b/Dockerfile index 3bde9de..b5cf761 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,6 @@ RUN npm prune --production # add utils ADD start.sh /app/code -RUN chmod +x /app/code/start.sh # use local storage RUN ln -sfn /app/data/build/constant.js /app/code/public/build/constant.js && \ diff --git a/start.sh b/start.sh old mode 100644 new mode 100755 From ac1938ac411fb04ff87e58c3ef6428ac67915c59 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 20 Jun 2018 19:55:35 -0700 Subject: [PATCH 21/44] Update nodejs to 8.11.3 --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b5cf761..d0c3654 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,14 @@ FROM cloudron/base:0.10.0 # install jq and moreutils (for sponge). # can be removed once https://git.cloudron.io/cloudron/docker-base-image/merge_requests/3 is merged and released -RUN apt update && apt -y full-upgrade && \ +RUN apt update && \ apt -y install moreutils jq && \ rm -rf /var/cache/apt /var/lib/apt/lists # setup nodejs version -ENV NODEJS_VERSION 6.9.5 -RUN ln -s /usr/local/node-$NODEJS_VERSION/bin/node /usr/local/bin/node && \ - ln -s /usr/local/node-$NODEJS_VERSION/bin/npm /usr/local/bin/npm +RUN mkdir -p /usr/local/node-8.11.3 +RUN curl -L https://nodejs.org/download/release/v8.11.3/node-v8.11.3-linux-x64.tar.gz | tar zxf - --strip-components 1 -C /usr/local/node-8.11.3 +ENV PATH /usr/local/node-8.11.3/bin:$PATH WORKDIR /app/code From f98481d8e92c7d4114916b16faef4337e7d8ea9a Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 20 Jun 2018 20:07:37 -0700 Subject: [PATCH 22/44] Add MIT license --- LICENSE | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1d8e98b --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ +MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + From f0f7ab9b863b64c64e4e63367db1e773bdf5b304 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 20 Jun 2018 20:16:43 -0700 Subject: [PATCH 23/44] Add README --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6b31c0 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# HackMD Cloudron App + +This repository contains the Cloudron app package source for [HackMD](https://hackmd.io/). + +## Installation + +[![Install](https://cloudron.io/img/button.svg)](https://cloudron.io/button.html?app=io.hackmd.cloudronapp) + +or using the [Cloudron command line tooling](https://cloudron.io/references/cli.html) + +``` +cloudron install --appstore-id io.hackmd.cloudronapp +``` + +## Building + +The app package can be built using the [Cloudron command line tooling](https://cloudron.io/references/cli.html). + +``` +cd hackmd-app + +cloudron build +cloudron install +``` + +## Testing + +The e2e tests are located in the `test/` folder and require [nodejs](http://nodejs.org/). They are creating a fresh build, install the app on your Cloudron, backup and restore. + +``` +cd hackmd-app/test + +npm install +USERNAME= PASSWORD= mocha --bail test.js +``` + From ffdef25288797bad4b272046ddbf41d827f38101 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 20 Jun 2018 20:16:57 -0700 Subject: [PATCH 24/44] Fix id of application --- CloudronManifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CloudronManifest.json b/CloudronManifest.json index 43b723a..e3df66a 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -1,5 +1,5 @@ { - "id": "io.hackmd", + "id": "io.hackmd.cloudronapp", "title": "HackMD", "author": "HackMD authors", "description": "file://DESCRIPTION.md", From 3304cf648d68293bdd63ee6ea5b028142ec2046e Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 20 Jun 2018 20:21:20 -0700 Subject: [PATCH 25/44] Update DESCRIPTION --- DESCRIPTION.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION.md b/DESCRIPTION.md index 48ec828..604d042 100644 --- a/DESCRIPTION.md +++ b/DESCRIPTION.md @@ -1,6 +1,16 @@ -This app packages HackMD 0.5.2-snapshot (d1d6d58) +This app packages HackMD 1.1.1-ce HackMD lets you create realtime collaborative markdown notes on all -platforms. -Inspired by Hackpad, with more focus on speed and flexibility. +platforms. Inspired by Hackpad, with more focus on speed and flexibility. + +## Features + +* Documentation Collaborated +* Context Captured +* Native Markdown +* Knowledge Net +* Technical Sharing and Presentation +* Turn Notes into Slides +* Better Conference Experience +* Questions Polling From 1253af8a46bd0bcfe0d6c01e70669e38379e4718 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 20 Jun 2018 19:56:13 -0700 Subject: [PATCH 26/44] Remove multiple steps to reduce docker image size Remove the prune because it does not work with the latest node version --- Dockerfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index d0c3654..e915ed9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,13 +16,7 @@ ENV HACKMD_VERSION 1.1.1-ce RUN curl -L https://github.com/hackmdio/hackmd/archive/$HACKMD_VERSION.tar.gz | tar -xz --strip-components 1 -f - # npm, deps -RUN npm install - -# build front-end bundle -RUN npm run build - -# remove dev dependencies -RUN npm prune --production +RUN npm install && npm run build # add utils ADD start.sh /app/code From 26caf277b3d3fc262e8484233d87776c69a43bc5 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 20 Jun 2018 19:57:45 -0700 Subject: [PATCH 27/44] Fixup minor bash script issues * set -eu is good practice to catch scipting errors * db is always up in cloudron case * use exec to prevent parent shell from being around --- start.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/start.sh b/start.sh index b7447ce..51d2dc4 100755 --- a/start.sh +++ b/start.sh @@ -1,7 +1,9 @@ #!/bin/bash +set -eu + # prepare data directory -mkdir -p /app/data/build && \ +mkdir -p /app/data/build mkdir -p /app/data/uploads chown -R cloudron:cloudron /app/data @@ -13,9 +15,6 @@ if [ -f .sequelizerc ]; then node_modules/.bin/sequelize db:migrate fi -# wait for db up -sleep 3 - # generate and store an unique sessionSecret for this installation CONFIG_JSON=/app/data/config.json if [ $(jq .sessionSecret $CONFIG_JSON) == "null" ]; then @@ -47,4 +46,4 @@ export HMD_ALLOW_ANONYMOUS_EDITS=true export HMD_ALLOW_FREEURL=true # run -/usr/local/bin/gosu cloudron:cloudron node app.js +exec /usr/local/bin/gosu cloudron:cloudron node app.js From e440e1f7775bde8f534cdb4e099c9a27a9701410 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 20 Jun 2018 20:17:58 -0700 Subject: [PATCH 28/44] build should not be in data directory move it to run time directory where it is not part of the backup --- Dockerfile | 4 ++-- start.sh | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index e915ed9..640f1b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,8 +21,8 @@ RUN npm install && npm run build # add utils ADD start.sh /app/code -# use local storage -RUN ln -sfn /app/data/build/constant.js /app/code/public/build/constant.js && \ +# constant.js is generated on startup and "require"d by the code +RUN ln -sfn /run/hackmd/constant.js /app/code/public/build/constant.js && \ rm -rf /app/code/public/uploads && ln -sf /app/data/uploads /app/code/public/uploads # add user definable config diff --git a/start.sh b/start.sh index 51d2dc4..838afda 100755 --- a/start.sh +++ b/start.sh @@ -3,9 +3,8 @@ set -eu # prepare data directory -mkdir -p /app/data/build -mkdir -p /app/data/uploads -chown -R cloudron:cloudron /app/data +mkdir -p /app/data/uploads /run/hackmd +chown -R cloudron:cloudron /app/data /run/hackmd if [ ! -e /app/data/config.json ]; then cp /app/code/config.json-cloudron /app/data/config.json From 496e0009e5125164dd5d1a887a9053a622f87722 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 20 Jun 2018 20:18:43 -0700 Subject: [PATCH 29/44] Fix tmp path --- config.json | 2 +- start.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.json b/config.json index 2506a1b..686c591 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,5 @@ { "production": { - "tmpPath": "../../app/data/tmp" + "tmpPath": "/tmp/hackmd" } } diff --git a/start.sh b/start.sh index 838afda..e828b55 100755 --- a/start.sh +++ b/start.sh @@ -3,8 +3,8 @@ set -eu # prepare data directory -mkdir -p /app/data/uploads /run/hackmd -chown -R cloudron:cloudron /app/data /run/hackmd +mkdir -p /app/data/uploads /tmp/hackmd /run/hackmd +chown -R cloudron:cloudron /app/data /tmp/hackmd /run/hackmd if [ ! -e /app/data/config.json ]; then cp /app/code/config.json-cloudron /app/data/config.json From 2c59c057212905d24c36d6bf6ca2ab76196cb480 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 20 Jun 2018 21:05:33 -0700 Subject: [PATCH 30/44] Move customizable settings to config.json In addition: * run db migration after the config files is generated and setup * change ownership after the config is generated --- config.json | 9 ++++++++- start.sh | 39 +++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/config.json b/config.json index 686c591..09abb89 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,12 @@ { "production": { - "tmpPath": "/tmp/hackmd" + "allowAnonymous": false, + "allowAnonymousEdits": false, + "allowEmailRegister": false, + "allowFreeUrl": true, + "allowPdfExport": false, + "debug": false, + "defaultPermission": "private", + "email": false } } diff --git a/start.sh b/start.sh index e828b55..aaeceb3 100755 --- a/start.sh +++ b/start.sh @@ -4,26 +4,22 @@ set -eu # prepare data directory mkdir -p /app/data/uploads /tmp/hackmd /run/hackmd -chown -R cloudron:cloudron /app/data /tmp/hackmd /run/hackmd if [ ! -e /app/data/config.json ]; then + echo "Creating initial template on first run" cp /app/code/config.json-cloudron /app/data/config.json fi -if [ -f .sequelizerc ]; then - node_modules/.bin/sequelize db:migrate -fi - # generate and store an unique sessionSecret for this installation CONFIG_JSON=/app/data/config.json -if [ $(jq .sessionSecret $CONFIG_JSON) == "null" ]; then - echo "generating sessionSecret" - sessionsecret=$(pwgen -1sc 32) - jq ".sessionSecret = \"$sessionsecret\"" $CONFIG_JSON | sponge $CONFIG_JSON +if [ $(jq .production.sessionSecret $CONFIG_JSON) == "null" ]; then + echo "generating sessionSecret" + sessionsecret=$(pwgen -1sc 32) + jq ".production.sessionSecret = \"$sessionsecret\"" $CONFIG_JSON | sponge $CONFIG_JSON fi -export NODE_ENV='production' -export HMD_ALLOW_ANONYMOUS="false" +# these cannot be changed by user (https://github.com/hackmdio/hackmd/wiki/Environment-Variables) +export HMD_DOMAIN="$APP_DOMAIN" export HMD_DB_URL="$POSTGRESQL_URL" export HMD_LDAP_URL="$LDAP_URL" export HMD_LDAP_BINDDN="$LDAP_BIND_DN" @@ -31,18 +27,17 @@ export HMD_LDAP_BINDCREDENTIALS="$LDAP_BIND_PASSWORD" export HMD_LDAP_SEARCHBASE="$LDAP_USERS_BASE_DN" export HMD_LDAP_SEARCHFILTER="(username={{username}})" export HMD_LDAP_USERNAMEFIELD="username" +export HMD_PORT=3000 export HMD_IMAGE_UPLOAD_TYPE=filesystem -# the following two changes could be transferred to config.json to enable users to change this -export HMD_EMAIL=false -export HMD_ALLOW_EMAIL_REGISTER=false -# disable pdf export until https://github.com/hackmdio/hackmd/issues/820 is fixed -export HMD_ALLOW_PDF_EXPORT=false -# respect users privacy and make notes private by default -export HMD_DEFAULT_PERMISSION=private -# let users choose to allow guest editing -export HMD_ALLOW_ANONYMOUS_EDITS=true -# create new page, if url does not yet exist -export HMD_ALLOW_FREEURL=true +export HMD_TMP_PATH=/tmp/hackmd + +if [ -f .sequelizerc ]; then + node_modules/.bin/sequelize db:migrate +fi + +chown -R cloudron:cloudron /app/data /tmp/hackmd /run/hackmd # run +export NODE_ENV=production exec /usr/local/bin/gosu cloudron:cloudron node app.js + From f4c444b6413e4511ebccfa4051a9fdc9f1151d33 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 20 Jun 2018 21:08:14 -0700 Subject: [PATCH 31/44] generate sequelizerc to run db migrations https://github.com/hackmdio/hackmd/blob/82c7f9d07cfecfc110af8c8fc0e47edf070596b2/README.md#native-setup --- Dockerfile | 3 +++ start.sh | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 640f1b1..b357125 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,9 @@ RUN curl -L https://github.com/hackmdio/hackmd/archive/$HACKMD_VERSION.tar.gz | # npm, deps RUN npm install && npm run build +# generate sequelizerrc +RUN sed -e "s/'change this'/process.env.POSTGRESQL_URL/" /app/code/.sequelizerc.example > /app/code/.sequelizerc + # add utils ADD start.sh /app/code diff --git a/start.sh b/start.sh index aaeceb3..07841c9 100755 --- a/start.sh +++ b/start.sh @@ -31,9 +31,8 @@ export HMD_PORT=3000 export HMD_IMAGE_UPLOAD_TYPE=filesystem export HMD_TMP_PATH=/tmp/hackmd -if [ -f .sequelizerc ]; then - node_modules/.bin/sequelize db:migrate -fi +echo "Running db migrations" +node_modules/.bin/sequelize db:migrate chown -R cloudron:cloudron /app/data /tmp/hackmd /run/hackmd From 2e7639d39e3138825e3e45a67406bbe185d20912 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 21 Jun 2018 10:08:31 -0700 Subject: [PATCH 32/44] Set useSsl flag for resources to load correctly --- start.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/start.sh b/start.sh index 07841c9..39f539e 100755 --- a/start.sh +++ b/start.sh @@ -20,6 +20,7 @@ fi # these cannot be changed by user (https://github.com/hackmdio/hackmd/wiki/Environment-Variables) export HMD_DOMAIN="$APP_DOMAIN" +export HMD_PROTOCOL_USESSL=true export HMD_DB_URL="$POSTGRESQL_URL" export HMD_LDAP_URL="$LDAP_URL" export HMD_LDAP_BINDDN="$LDAP_BIND_DN" From 46e0fd1654b74a35c8a7134b54dfdd47880800be Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 21 Jun 2018 10:40:11 -0700 Subject: [PATCH 33/44] Add ignore files --- .dockerignore | 9 +++++++++ .gitignore | 2 ++ 2 files changed, 11 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..133695d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.git +.gitignore +.dockerignore +test +CloudronManifest.json +README.md +DESCRIPTION.md +screenshots/* + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d570088 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ + From 5e0cbe9f39b982479688174a8aa29d3473d54dd9 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 21 Jun 2018 10:29:24 -0700 Subject: [PATCH 34/44] Add tests --- test/package.json | 24 +++++ test/test.js | 220 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 244 insertions(+) create mode 100644 test/package.json create mode 100644 test/test.js diff --git a/test/package.json b/test/package.json new file mode 100644 index 0000000..d08f3cd --- /dev/null +++ b/test/package.json @@ -0,0 +1,24 @@ +{ + "name": "test", + "version": "1.0.0", + "description": "", + "main": "test.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "ejs": "^2.3.4", + "expect.js": "^0.3.1", + "mkdirp": "^0.5.1", + "mocha": "^2.3.4", + "rimraf": "^2.4.4", + "selenium-server-standalone-jar": "^2.53.0", + "selenium-webdriver": "^2.53.3", + "superagent": "^1.4.0" + }, + "dependencies": { + "chromedriver": "^2.37.0" + } +} diff --git a/test/test.js b/test/test.js new file mode 100644 index 0000000..76fd1e2 --- /dev/null +++ b/test/test.js @@ -0,0 +1,220 @@ +#!/usr/bin/env node + +/* jslint node:true */ +/* global it:false */ +/* global xit:false */ +/* global describe:false */ +/* global before:false */ +/* global after:false */ + +'use strict'; + +require('chromedriver'); + +var execSync = require('child_process').execSync, + expect = require('expect.js'), + path = require('path'), + webdriver = require('selenium-webdriver'); + +var by = webdriver.By, + until = webdriver.until; + +process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; + +if (!process.env.USERNAME || !process.env.PASSWORD || !process.env.EMAIL) { + console.log('USERNAME, PASSWORD and EMAIL env vars need to be set'); + process.exit(1); +} + +describe('Application life cycle test', function () { + this.timeout(0); + + var chrome = require('selenium-webdriver/chrome'); + var server, browser = new chrome.Driver(); + var username = process.env.USERNAME, password = process.env.PASSWORD; + // var email = process.env.EMAIL; + var noteUrl; + + function login(done) { + browser.manage().deleteAllCookies().then(function () { + return browser.get('https://' + app.fqdn); + }).then(function () { + return browser.wait(until.elementLocated(by.xpath('//button[text()="Sign In"]')), TEST_TIMEOUT); + }).then(function () { + return browser.findElement(by.xpath('//div[@class="ui-signin"]/button[text()="Sign In"]')).click(); + }).then(function () { + return browser.sleep(2000); // wait for login popup + }).then(function () { + return browser.findElement(by.xpath('//input[@name="username"]')).sendKeys(username); + }).then(function () { + return browser.findElement(by.xpath('//input[@name="password"]')).sendKeys(password); + }).then(function () { + return browser.findElement(by.xpath('//button[text()="Sign in" and contains(@formaction, "ldap")]')).click(); + }).then(function () { + return browser.wait(until.elementLocated(by.xpath('//a[contains(text(), "New note")]')), TEST_TIMEOUT); + }).then(function () { + done(); + }); + } + + function newNote(done) { + browser.get('https://' + app.fqdn + '/new').then(function () { + return browser.wait(until.elementLocated(by.xpath('//a[contains(text(), "Publish")]')), TEST_TIMEOUT); + }).then(function () { + return browser.sleep(5000); // code mirror takes a while to load + }).then(function () { + return browser.getCurrentUrl(); + }).then(function (url) { + noteUrl = url; + console.log('The note url is ' + noteUrl); + return browser.findElement(by.css('.CodeMirror textarea')).sendKeys('hello cloudron'); + }).then(function () { + return browser.sleep(2000); // give it a second to 'save' + }).then(function () { + done(); + }); + } + + function checkExistingNote(done) { + browser.get(noteUrl).then(function () { + return browser.wait(until.elementLocated(by.xpath('//p[contains(text(), "hello cloudron")]')), TEST_TIMEOUT); + }).then(function () { + done(); + }); + } + + function checkNoteIsPrivate(done) { + browser.get(noteUrl).then(function () { + return browser.wait(until.elementLocated(by.xpath('//h1[contains(text(), "403 Forbidden")]')), TEST_TIMEOUT); + }).then(function () { + done(); + }); + } + + function logout(done) { + browser.get('https://' + app.fqdn).then(function () { + return browser.findElement(by.xpath('//button[@id="profileLabel"]')).click(); + }).then(function () { + return browser.sleep(2000); // wait for menu to open + }).then(function () { + return browser.findElement(by.xpath('//a[contains(text(), "Sign Out")]')).click(); + }).then(function () { + return browser.sleep(2000); + }).then(function () { + done(); + }); + } + + before(function (done) { + var seleniumJar= require('selenium-server-standalone-jar'); + var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer; + server = new SeleniumServer(seleniumJar.path, { port: 4444 }); + server.start(); + + done(); + }); + + after(function (done) { + browser.quit(); + server.stop(); + done(); + }); + + var LOCATION = 'test'; + var TEST_TIMEOUT = 30000; + var app; + + xit('build app', function () { + execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + }); + + it('install app', function () { + execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + }); + + it('can get app information', function () { + var inspect = JSON.parse(execSync('cloudron inspect')); + + app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0]; + + expect(app).to.be.an('object'); + }); + + it('can login', login); + it('can create new note', newNote); + it('can check existing note', checkExistingNote); + it('can logout', logout); + + it('did create private note', checkNoteIsPrivate); + + it('backup app', function () { + execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + }); + + it('restore app', function () { + execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + }); + + it('can login', login); + it('can check existing note', checkExistingNote); + it('can logout', logout); + + it('did create private note', checkNoteIsPrivate); + + it('can restart app', function (done) { + execSync('cloudron restart --wait --app ' + app.id); + done(); + }); + + it('can login', login); + it('can check existing note', checkExistingNote); + it('can logout', logout); + + it('did create private note', checkNoteIsPrivate); + + it('move to different location', function (done) { + execSync('cloudron configure --wait --location ' + LOCATION + '2 --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + var inspect = JSON.parse(execSync('cloudron inspect')); + app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0]; + expect(app).to.be.an('object'); + noteUrl = noteUrl.replace(LOCATION, LOCATION + '2'); + + done(); + }); + + it('can login', login); + it('can check existing note', checkExistingNote); + it('can logout', logout); + + it('did create private note', checkNoteIsPrivate); + + it('uninstall app', function () { + execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + }); + + // test update + it('can install from appstore', function () { + execSync('cloudron install --new --wait --appstore-id io.hackmd.cloudronapp --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + var inspect = JSON.parse(execSync('cloudron inspect')); + app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0]; + expect(app).to.be.an('object'); + }); + + it('can login', login); + it('can create new note', newNote); + it('can logout', logout); + + it('can update', function () { + execSync('cloudron install --wait --app ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + }); + + it('can login', login); + it('can check existing note', checkExistingNote); + it('can logout', logout); + + it('did create private note', checkNoteIsPrivate); + + it('uninstall app', function () { + execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + }); +}); From 6c12cb1983394fbb95d00241238175c09cea7f92 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 21 Jun 2018 12:06:23 -0700 Subject: [PATCH 35/44] Allow login via email --- start.sh | 2 +- test/test.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/start.sh b/start.sh index 39f539e..5bea530 100755 --- a/start.sh +++ b/start.sh @@ -26,7 +26,7 @@ export HMD_LDAP_URL="$LDAP_URL" export HMD_LDAP_BINDDN="$LDAP_BIND_DN" export HMD_LDAP_BINDCREDENTIALS="$LDAP_BIND_PASSWORD" export HMD_LDAP_SEARCHBASE="$LDAP_USERS_BASE_DN" -export HMD_LDAP_SEARCHFILTER="(username={{username}})" +export HMD_LDAP_SEARCHFILTER="(|(username={{username}})(mail={{username}}))" export HMD_LDAP_USERNAMEFIELD="username" export HMD_PORT=3000 export HMD_IMAGE_UPLOAD_TYPE=filesystem diff --git a/test/test.js b/test/test.js index 76fd1e2..098bfa2 100644 --- a/test/test.js +++ b/test/test.js @@ -32,10 +32,10 @@ describe('Application life cycle test', function () { var chrome = require('selenium-webdriver/chrome'); var server, browser = new chrome.Driver(); var username = process.env.USERNAME, password = process.env.PASSWORD; - // var email = process.env.EMAIL; + var email = process.env.EMAIL; var noteUrl; - function login(done) { + function login(username, done) { browser.manage().deleteAllCookies().then(function () { return browser.get('https://' + app.fqdn); }).then(function () { @@ -140,7 +140,7 @@ describe('Application life cycle test', function () { expect(app).to.be.an('object'); }); - it('can login', login); + it('can login', login.bind(null, username)); it('can create new note', newNote); it('can check existing note', checkExistingNote); it('can logout', logout); @@ -155,7 +155,7 @@ describe('Application life cycle test', function () { execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); }); - it('can login', login); + it('can login', login.bind(null, username)); it('can check existing note', checkExistingNote); it('can logout', logout); @@ -166,7 +166,7 @@ describe('Application life cycle test', function () { done(); }); - it('can login', login); + it('can login', login.bind(null, email)); it('can check existing note', checkExistingNote); it('can logout', logout); @@ -182,7 +182,7 @@ describe('Application life cycle test', function () { done(); }); - it('can login', login); + it('can login', login.bind(null, username)); it('can check existing note', checkExistingNote); it('can logout', logout); @@ -200,7 +200,7 @@ describe('Application life cycle test', function () { expect(app).to.be.an('object'); }); - it('can login', login); + it('can login', login.bind(null, username)); it('can create new note', newNote); it('can logout', logout); @@ -208,7 +208,7 @@ describe('Application life cycle test', function () { execSync('cloudron install --wait --app ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); }); - it('can login', login); + it('can login', login.bind(null, email)); it('can check existing note', checkExistingNote); it('can logout', logout); From f41873c2e6538e0d246d7ad7111a4b4e8df15a5a Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 21 Jun 2018 12:11:59 -0700 Subject: [PATCH 36/44] Version 0.1.0 --- CHANGELOG | 27 +++------------------------ CloudronManifest.json | 2 +- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 760c7b7..4d7a1f1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,25 +1,4 @@ -[0.0.8] -Generate sessionSecret at initial app startup +[0.1.0] +* Initial version +* Made possible by @dictcp, @felix and @jeau -[0.0.7] -make it possible to set notes publicly writable -automatically create new notes if url doesnt exist - -[0.0.6] -switch default visibility to private for new notes - -[0.0.5] -disable pdf export until https://github.com/hackmdio/hackmd/issues/820 is fixed - -[0.0.4] -add config file to set tmp directory and ldap username -Thanks go out to @jeau for the pr! - -[0.0.3] -update to 1.1.1-ce upstream release - -[0.0.2] -minor bugfix - -[0.0.1] -initial release diff --git a/CloudronManifest.json b/CloudronManifest.json index e3df66a..5063079 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -5,7 +5,7 @@ "description": "file://DESCRIPTION.md", "changelog": "file://CHANGELOG", "tagline": "Best way to write and share your knowledge in markdown", - "version": "0.0.8", + "version": "0.1.0", "healthCheckPath": "/status", "httpPort": 3000, "addons": { From c4aa7f2e93d02d41794d6d07b4e19cdf63474227 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 21 Jun 2018 12:17:31 -0700 Subject: [PATCH 37/44] Fix screenshot link --- CloudronManifest.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CloudronManifest.json b/CloudronManifest.json index 5063079..c556fc9 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -23,6 +23,8 @@ "document", "collaboration" ], - "mediaLinks": [ "https://hackmd.io/screenshot.png" ] + "mediaLinks": [ + "https://s3.amazonaws.com/cloudron-app-screenshots/io.hackmd.cloudronapp/f41873c2e6538e0d246d7ad7111a4b4e8df15a5a/screenshot.png" + ] } From 1a94e37ed5e00eb89fa2cadecf5b8ebd1dd51e9a Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 21 Jun 2018 12:26:09 -0700 Subject: [PATCH 38/44] Add documentationUrl --- CloudronManifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CloudronManifest.json b/CloudronManifest.json index c556fc9..c8557a6 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -25,6 +25,7 @@ ], "mediaLinks": [ "https://s3.amazonaws.com/cloudron-app-screenshots/io.hackmd.cloudronapp/f41873c2e6538e0d246d7ad7111a4b4e8df15a5a/screenshot.png" - ] + ], + "documentationUrl": "https://cloudron.io/documentation/apps/hackmd/" } From c738c3f39a491964720f248a42dfa9ee91b2a4d8 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 21 Jun 2018 12:27:06 -0700 Subject: [PATCH 39/44] Version 0.2.0 --- CHANGELOG | 3 +++ CloudronManifest.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 4d7a1f1..49e0117 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,3 +2,6 @@ * Initial version * Made possible by @dictcp, @felix and @jeau +[0.2.0] +* Update screenshot and add documentation link + diff --git a/CloudronManifest.json b/CloudronManifest.json index c8557a6..77694f0 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -5,7 +5,7 @@ "description": "file://DESCRIPTION.md", "changelog": "file://CHANGELOG", "tagline": "Best way to write and share your knowledge in markdown", - "version": "0.1.0", + "version": "0.2.0", "healthCheckPath": "/status", "httpPort": 3000, "addons": { From 1dc38d6b6522e0bdbc78ab67269c846d5ac4321c Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Sun, 1 Jul 2018 12:52:12 +0200 Subject: [PATCH 40/44] update to codimd 1.2.0 and update references from hackmd to codimd Signed-off-by: Felix Bartels --- CHANGELOG | 2 ++ CloudronManifest.json | 8 ++++---- Dockerfile | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 49e0117..ccfb531 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,3 +5,5 @@ [0.2.0] * Update screenshot and add documentation link +[0.3.0] +* HackMD is now called CodiMD diff --git a/CloudronManifest.json b/CloudronManifest.json index 77694f0..006df9b 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -1,11 +1,11 @@ { "id": "io.hackmd.cloudronapp", - "title": "HackMD", - "author": "HackMD authors", + "title": "CodiMD", + "author": "CodiMD authors", "description": "file://DESCRIPTION.md", "changelog": "file://CHANGELOG", "tagline": "Best way to write and share your knowledge in markdown", - "version": "0.2.0", + "version": "0.3.0", "healthCheckPath": "/status", "httpPort": 3000, "addons": { @@ -14,7 +14,7 @@ "ldap": {} }, "manifestVersion": 1, - "website": "https://hackmd.io", + "website": "https://hackmd-ce.herokuapp.com/", "contactEmail": "support@cloudron.io", "icon": "logo.png", "tags": [ diff --git a/Dockerfile b/Dockerfile index b357125..49a00c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,8 +12,8 @@ ENV PATH /usr/local/node-8.11.3/bin:$PATH WORKDIR /app/code -ENV HACKMD_VERSION 1.1.1-ce -RUN curl -L https://github.com/hackmdio/hackmd/archive/$HACKMD_VERSION.tar.gz | tar -xz --strip-components 1 -f - +ENV HACKMD_VERSION 1.2.0 +RUN curl -L https://github.com/hackmdio/codimd/archive/$HACKMD_VERSION.tar.gz | tar -xz --strip-components 1 -f - # npm, deps RUN npm install && npm run build From 26964c18eefb4d40ef4efb1d1523c458ae9e75de Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Tue, 3 Jul 2018 15:58:45 +0200 Subject: [PATCH 41/44] allowAnonymousEdits should be set to true - this was the value previously defined in start.sh - users then still have the option to allow it on a per document base Signed-off-by: Felix Bartels --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 09abb89..8c54178 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { "production": { "allowAnonymous": false, - "allowAnonymousEdits": false, + "allowAnonymousEdits": true, "allowEmailRegister": false, "allowFreeUrl": true, "allowPdfExport": false, From 7eb9428e2b2f4424ff60a5e8b1521e958f51f61d Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Fri, 6 Jul 2018 07:46:57 +0200 Subject: [PATCH 42/44] forgot to update version in description Signed-off-by: Felix Bartels --- DESCRIPTION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION.md b/DESCRIPTION.md index 604d042..b8796b7 100644 --- a/DESCRIPTION.md +++ b/DESCRIPTION.md @@ -1,4 +1,4 @@ -This app packages HackMD 1.1.1-ce +This app packages HackMD 1.2.0 HackMD lets you create realtime collaborative markdown notes on all platforms. Inspired by Hackpad, with more focus on speed and flexibility. From d93da0d99797f2f3cae267e09e971790ac13a4a2 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Sun, 5 Aug 2018 20:18:49 -0700 Subject: [PATCH 43/44] Add notes to tags --- CloudronManifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CloudronManifest.json b/CloudronManifest.json index 006df9b..630d1cb 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -21,7 +21,8 @@ "markdown", "wiki", "document", - "collaboration" + "collaboration", + "notes" ], "mediaLinks": [ "https://s3.amazonaws.com/cloudron-app-screenshots/io.hackmd.cloudronapp/f41873c2e6538e0d246d7ad7111a4b4e8df15a5a/screenshot.png" From f91bae2613214cddff04368f8446998f840aefa3 Mon Sep 17 00:00:00 2001 From: Felix Bartels Date: Thu, 4 Oct 2018 16:37:49 +0200 Subject: [PATCH 44/44] update to 1.2.1 upstream Signed-off-by: Felix Bartels --- CHANGELOG | 3 +++ CloudronManifest.json | 2 +- DESCRIPTION.md | 4 ++-- Dockerfile | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ccfb531..694e2cd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,3 +7,6 @@ [0.3.0] * HackMD is now called CodiMD + +[0.3.1] +* Update to CodiMD 1.2.1 diff --git a/CloudronManifest.json b/CloudronManifest.json index 630d1cb..e776c10 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -5,7 +5,7 @@ "description": "file://DESCRIPTION.md", "changelog": "file://CHANGELOG", "tagline": "Best way to write and share your knowledge in markdown", - "version": "0.3.0", + "version": "0.3.1", "healthCheckPath": "/status", "httpPort": 3000, "addons": { diff --git a/DESCRIPTION.md b/DESCRIPTION.md index b8796b7..4218b38 100644 --- a/DESCRIPTION.md +++ b/DESCRIPTION.md @@ -1,6 +1,6 @@ -This app packages HackMD 1.2.0 +This app packages CodiMD 1.2.1 -HackMD lets you create realtime collaborative markdown notes on all +CodiMD lets you create realtime collaborative markdown notes on all platforms. Inspired by Hackpad, with more focus on speed and flexibility. ## Features diff --git a/Dockerfile b/Dockerfile index 49a00c6..587c4d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ENV PATH /usr/local/node-8.11.3/bin:$PATH WORKDIR /app/code -ENV HACKMD_VERSION 1.2.0 +ENV HACKMD_VERSION 1.2.1 RUN curl -L https://github.com/hackmdio/codimd/archive/$HACKMD_VERSION.tar.gz | tar -xz --strip-components 1 -f - # npm, deps