From eb784b4026e012f813fddc6c10a80b5088d537b2 Mon Sep 17 00:00:00 2001 From: Stefan Strigler Date: Fri, 27 Feb 2026 14:25:57 +0100 Subject: [PATCH] fix(invites): include js/css deps in static dir --- .github/container/Dockerfile | 12 ++------ .gitignore | 3 ++ Makefile.in | 15 +++++++-- package-lock.json | 56 ++++++++++++++++++++++++++++++++++ package.json | 15 +++++++++ priv/mod_invites/base_min.html | 6 ++-- src/mod_invites.erl | 32 +++++-------------- src/mod_invites_http.erl | 3 +- tools/dl_invites_page_deps.sh | 1 + tools/make-packages | 2 -- 10 files changed, 103 insertions(+), 42 deletions(-) create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.github/container/Dockerfile b/.github/container/Dockerfile index 69d4a1b49..740d587d8 100644 --- a/.github/container/Dockerfile +++ b/.github/container/Dockerfile @@ -19,7 +19,7 @@ RUN go install -v \ FROM docker.io/erlang:${OTP_VSN}-alpine AS ejabberd RUN apk -U add --no-cache \ - nodejs npm ca-certificates \ + ca-certificates \ autoconf \ automake \ bash \ @@ -33,6 +33,7 @@ RUN apk -U add --no-cache \ libpng-dev \ libwebp-dev \ linux-pam-dev \ + npm \ openssl-dev \ sqlite-dev \ yaml-dev \ @@ -54,15 +55,6 @@ COPY / $BUILD_DIR/ WORKDIR $BUILD_DIR -RUN npm init -y \ - && npm install --silent jquery@3.7.1 bootstrap@4.6.2 \ - && mkdir -p /rootfs/usr/share/javascript/bootstrap4/css \ - && mkdir -p /rootfs/usr/share/javascript/bootstrap4/js \ - && mkdir -p /rootfs/usr/share/javascript/jquery/ \ - && cp -r node_modules/bootstrap/dist/css/bootstrap.min* /rootfs/usr/share/javascript/bootstrap4/css \ - && cp -r node_modules/bootstrap/dist/js/bootstrap.min* /rootfs/usr/share/javascript/bootstrap4/js \ - && cp -r node_modules/jquery/dist/jquery.min* /rootfs/usr/share/javascript/jquery/ - RUN mv .github/container/ejabberdctl.template . \ && mv .github/container/ejabberd.yml.example . \ && ./autogen.sh \ diff --git a/.gitignore b/.gitignore index 0f69a0aa3..c3216c187 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,6 @@ Mnesia.nonode@nohost/ /ejabberd-*.rpm /ejabberd-*.run /ejabberd-*.tar.gz +/priv/mod_invites/static/bootstrap4/ +/priv/mod_invites/static/jquery/ +/node_modules/ diff --git a/Makefile.in b/Makefile.in index 7a678958a..cbb803746 100644 --- a/Makefile.in +++ b/Makefile.in @@ -212,7 +212,7 @@ endif all: scripts deps src -deps: $(DEPSDIR)/.got +deps: $(DEPSDIR)/.got invites-deps $(DEPSDIR)/.got: rm -rf $(DEPSDIR)/.got @@ -224,6 +224,15 @@ $(DEPSDIR)/.got: $(DEPSDIR)/.built: $(DEPSDIR)/.got $(REBAR) compile && :> $(DEPSDIR)/.built +ifeq (, $(shell which npm)) + INSTALL_INVITES_DEPS=tools/dl_invites_page_deps.sh priv/mod_invites/static +else + INSTALL_INVITES_DEPS=npm install +endif + +invites-deps: + $(INSTALL_INVITES_DEPS) + src: $(DEPSDIR)/.built $(REBAR) $(SKIPDEPS) compile $(EXPLICIT_ELIXIR_COMPILE) @@ -311,7 +320,8 @@ BINARIES=$(DEPSDIR)/epam/priv/bin/epam $(DEPSDIR)/eimp/priv/bin/eimp $(DEPSDIR)/ DEPS_FILES_FILTERED=$(filter-out $(BINARIES) $(DEPSDIR)/elixir/ebin/elixir.app,$(DEPS_FILES)) DEPS_DIRS=$(sort $(DEPSDIR)/ $(foreach DEP,$(DEPS),$(DEPSDIR)/$(DEP)/) $(dir $(DEPS_FILES))) -MAIN_FILES=$(filter-out %/configure.beam,$(call FILES_WILDCARD,$(EBINDIR)/*.beam $(EBINDIR)/*.app priv/msgs/*.msg priv/css/*.css priv/img/*.png priv/js/*.js priv/lib/* priv/mod_invites/* priv/mod_invites/static/* priv/mod_invites/static/logos/* include/*.hrl COPYING)) +MAIN_FILES=$(filter-out %/configure.beam,$(call FILES_WILDCARD,$(EBINDIR)/*.beam $(EBINDIR)/*.app priv/msgs/*.msg priv/css/*.css priv/img/*.png priv/js/*.js priv/lib/* priv/mod_invites/* priv/mod_invites/static/* priv/mod_invites/static/bootstrap4/css/bootstrap.min.css priv/mod_invites/static/bootstrap4/js/bootstrap.min.js priv/mod_invites/static/jquery/jquery.min.js \ + priv/mod_invites/static/logos/* include/*.hrl COPYING)) MAIN_DIRS=$(sort $(dir $(MAIN_FILES)) priv/bin priv/sql priv/lua priv/mod_invites) define DEP_VERSION_template @@ -553,6 +563,7 @@ clean: rm -rf test/*.beam rm -f rebar.lock rm -f ejabberdctl.example ejabberd.init ejabberd.service + rm -rf priv/mod_invites/static/{jquery,bootstrap4} $(REBAR) clean $(CLEANARG) clean-rel: diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..e39f33000 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,56 @@ +{ + "name": "ejabberd", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ejabberd", + "version": "1.0.0", + "hasInstallScript": true, + "dependencies": { + "bootstrap": "4.6.2", + "jquery": "3.7.1" + } + }, + "node_modules/bootstrap": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.6.2.tgz", + "integrity": "sha512-51Bbp/Uxr9aTuy6ca/8FbFloBUJZLHwnhTcnjIeRn2suQWsWzcuJhGjKDB5eppVte/8oCdOL3VuwxvZDUggwGQ==", + "deprecated": "This version of Bootstrap is no longer supported. Please upgrade to the latest version.", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/twbs" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/bootstrap" + } + ], + "license": "MIT", + "peerDependencies": { + "jquery": "1.9.1 - 3", + "popper.js": "^1.16.1" + } + }, + "node_modules/jquery": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.1.tgz", + "integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==", + "license": "MIT" + }, + "node_modules/popper.js": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz", + "integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==", + "deprecated": "You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1", + "license": "MIT", + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..df16460c2 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "ejabberd", + "version": "1.0.0", + "dependencies": { + "jquery": "3.7.1", + "bootstrap": "4.6.2" + }, + "scripts": { + "postinstall": "npm run -s clean && npm run -s mkdir-jquery && npm run -s cp-jquery && npm run -s cp-bootstrap", + "clean": "rm -rf priv/mod_invites/static/{jquery,bootstrap4}", + "mkdir-jquery": "mkdir -p priv/mod_invites/static/jquery", + "cp-jquery": "cp node_modules/jquery/dist/jquery.min.js priv/mod_invites/static/jquery/jquery.min.js", + "cp-bootstrap": "cp -r node_modules/bootstrap/dist priv/mod_invites/static/bootstrap4" + } +} diff --git a/priv/mod_invites/base_min.html b/priv/mod_invites/base_min.html index f736ef23c..57e7d4d3c 100644 --- a/priv/mod_invites/base_min.html +++ b/priv/mod_invites/base_min.html @@ -5,7 +5,7 @@ {% block title %}{% blocktrans %}Invite to {{ site_name }}{% endblocktrans %}{% endblock %} {% block rel_alternate %}{% endblock %} - + @@ -49,7 +49,7 @@ {% block qr_code %}{% endblock %} {% block extra_scripts %}{% endblock %} - - + + diff --git a/src/mod_invites.erl b/src/mod_invites.erl index f2b7562d5..907f32644 100644 --- a/src/mod_invites.erl +++ b/src/mod_invites.erl @@ -125,28 +125,15 @@ mod_doc() -> "then guide the recipient with setting up a client " "and creating an account if required."), "", - ?T("In order to use the included landing page feature, you have to"), + ?T("In order to use the included landing page feature, you have to" + " set `landing_page` to either `auto` or an URL template like " + "`https://{{ host }}/invites/{{ invite.token }}` " + " if your server setup includes a so called reverse proxy"), "", - ?T(" * have a copy of https://code.jquery.com/jquery-3.7.1.min.js[jQuery 3] and " - " https://github.com/twbs/bootstrap/releases/download/v4.6.2/bootstrap-4.6.2-dist.zip[Bootstrap 4] " - " in a shared directory on your system. If you're using Debian or " - " derivatives this is easiest accomplished by installing both " - " `libjs-jquery` and `libjs-bootstrap4` which will put them under " - " `/usr/share/javascript/{jquery,bootstrap4}`. Alternatively you can use " - " `tools/dl_invites_page_deps.sh `."), - ?T(" * in `ejabberd.yml` configure a listener for module `ejabberd_http` " - " with a request handler for `/share: mod_http_fileserver`"), - ?T(" * in the `modules` section configure `mod_http_fileserver` so that " - " `docroot` points to the shared directory from above " - " (e.g. `docroot: /usr/share/javascript`)"), - ?T(" * configure `mod_invites` and set `landing_page` to either `auto` " - " or an URL template like `https://{{ host }}/invites/{{ invite.token }}` " - " if your server setup includes a so called reverse proxy"), - "", - "If you'd rather want to use an external service, set `landing_page` " - "to something like " - "`http://{{ host }}:8080/easy-xmpp-invites/#{{ invite.uri|strip_protocol }}` " - "or `https://invites.joinjabber.org/#{{ invite.uri|strip_protocol }}`."], + ?T("If you'd rather want to use an external service, set `landing_page` " + "to something like " + "`http://{{ host }}:8080/easy-xmpp-invites/#{{ invite.uri|strip_protocol }}` " + "or `https://invites.joinjabber.org/#{{ invite.uri|strip_protocol }}`.")], note => "added in 26.01", opts => [{access_create_account, @@ -208,11 +195,8 @@ mod_doc() -> " module: ejabberd_http", " request_handlers:", " /invites: mod_invites", - " /share: mod_http_fileserver", "# [...]", "modules:", - " mod_http_fileserver:", - " docroot: /usr/share/javascript", " mod_invites:", " landing_page: auto"]}, {?T("To allow only admin users to create invites of 'create account' and " diff --git a/src/mod_invites_http.erl b/src/mod_invites_http.erl index b9f801399..00107d290 100644 --- a/src/mod_invites_http.erl +++ b/src/mod_invites_http.erl @@ -52,7 +52,8 @@ -define(DEFAULT_CONTENT_TYPE, <<"application/octet-stream">>). -define(CONTENT_TYPES, - [{<<".js">>, <<"application/javascript">>}, + [{<<".css">>, <<"text/css">>}, + {<<".js">>, <<"application/javascript">>}, {<<".png">>, <<"image/png">>}, {<<".svg">>, <<"image/svg+xml">>}]). diff --git a/tools/dl_invites_page_deps.sh b/tools/dl_invites_page_deps.sh index d1ff05df3..67feb2d74 100755 --- a/tools/dl_invites_page_deps.sh +++ b/tools/dl_invites_page_deps.sh @@ -25,6 +25,7 @@ bootstrap4="$(mktemp /tmp/bootstrap4.XXXXXXXXX)" curl -L -s -o $bootstrap4 https://github.com/twbs/bootstrap/releases/download/v4.6.2/bootstrap-4.6.2-dist.zip check $bootstrap4_checksum $bootstrap4 +rm -rf "$install_dir/bootstrap4" unzip -q -d "$install_dir" $bootstrap4 mv "$install_dir/bootstrap-4.6.2-dist" "$install_dir/bootstrap4" rm $bootstrap4 diff --git a/tools/make-packages b/tools/make-packages index e8d1c6ae6..430d4b8cf 100755 --- a/tools/make-packages +++ b/tools/make-packages @@ -193,8 +193,6 @@ make_package() --provides 'xmpp-server' \ --no-depends \ --no-auto-depends \ - --deb-recommends 'libjs-jquery' \ - --deb-recommends 'libjs-bootstrap4' \ --deb-maintainerscripts-force-errorchecks \ --deb-systemd-enable \ --deb-systemd-auto-start \