aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-12-20 01:55:08 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-12-20 04:12:30 +0100
commit3f453c7d8f79dcf2fba94287ec286d55eceb99d1 (patch)
treee7a2531a08d7b8f514f2a1b8ec9914ca60623beb /modules/private/websites
parent8cf37c75c3c744717327344ff982a62d787c1dc7 (diff)
downloadNix-3f453c7d8f79dcf2fba94287ec286d55eceb99d1.tar.gz
Nix-3f453c7d8f79dcf2fba94287ec286d55eceb99d1.tar.zst
Nix-3f453c7d8f79dcf2fba94287ec286d55eceb99d1.zip
Add ejabberd service and website
Diffstat (limited to 'modules/private/websites')
-rw-r--r--modules/private/websites/tools/im/default.nix37
-rw-r--r--modules/private/websites/tools/im/www/converse.html57
-rw-r--r--modules/private/websites/tools/im/www/index.html46
-rw-r--r--modules/private/websites/tools/tools/default.nix5
4 files changed, 144 insertions, 1 deletions
diff --git a/modules/private/websites/tools/im/default.nix b/modules/private/websites/tools/im/default.nix
new file mode 100644
index 0000000..9744d8e
--- /dev/null
+++ b/modules/private/websites/tools/im/default.nix
@@ -0,0 +1,37 @@
1{ config, lib, ... }:
2let
3 cfg = config.myServices.websites.tools.im;
4in
5{
6 options.myServices.websites.tools.im = {
7 enable = lib.mkEnableOption "enable im website";
8 };
9
10 config = lib.mkIf cfg.enable {
11 services.websites.env.tools.vhostConfs.im = {
12 certName = "eldiron";
13 addToCerts = true;
14 hosts = ["im.immae.fr"];
15 root = ./www;
16 extraConfig = [
17 ''
18 Alias /converse ${./www}/converse.html
19 ProxyPreserveHost On
20 <Location "/bosh">
21 ProxyPass http://localhost:5280/bosh
22 ProxyPassReverse http://localhost:5280/bosh
23 </Location>
24 <Location "/ws">
25 ProxyPass ws://localhost:5280/ws
26 </Location>
27 ProxyPass /upload http://localhost:5280/upload
28 ProxyPassReverse /upload http://localhost:5280/upload
29 ProxyPass /admin http://localhost:5280/admin
30 ProxyPassReverse /admin http://localhost:5280/admin
31 ProxyPass /api http://localhost:5280/api
32 ProxyPassReverse /api http://localhost:5280/api
33 ''
34 ];
35 };
36 };
37}
diff --git a/modules/private/websites/tools/im/www/converse.html b/modules/private/websites/tools/im/www/converse.html
new file mode 100644
index 0000000..5835b6e
--- /dev/null
+++ b/modules/private/websites/tools/im/www/converse.html
@@ -0,0 +1,57 @@
1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <title>Converse</title>
5 <meta charset="utf-8">
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8 <meta name="description" content="Converse: An XMPP chat client which can be integrated into any website" />
9 <meta name="keywords" content="xmpp chat webchat converse.js Converse" />
10
11 <link type="text/css" rel="stylesheet" media="screen" href="https://cdn.conversejs.org/5.0.4/dist/converse.min.css" />
12 <style type="text/css">
13 #conversejs div.chat-msg__text pre {
14 background-color: #eee;
15 padding: 10px;
16 }
17 </style>
18 <script src="https://cdn.conversejs.org/3rdparty/libsignal-protocol.min.js"></script>
19 <script src="https://cdn.conversejs.org/5.0.4/dist/converse.min.js"></script>
20 <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
21 <script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/10.0.0/markdown-it.min.js"></script>
22 <script>
23 var md = window.markdownit({
24 html: true,
25 });
26 converse.plugins.add('markdown', {
27 //initialize () {
28 // const { _converse } = this;
29 // _converse.api.listen.on('afterMessageBodyTransformed', (view, text) => {
30 // let newtext = text.replace(/<br\/>/g, '\n').replace(/```/g, "\n```\n");
31 // newtext = md.render(newtext).replace(/^<p>/, "").replace(/<\/p>\s*$/, "");
32 // view.model.save({'message': newtext}, {'silent': true });
33 // });
34 //}
35 overrides: {
36 MessageView: {
37 transformBodyText: async function(text) {
38 let newtext = await this.__super__.transformBodyText.apply(this, arguments);
39 newtext = newtext.replace(/<br\/>/g, '\n').replace(/```/g, "\n```\n");
40 return md.render(newtext).replace(/^<p>/, "").replace(/<\/p>\s*$/, "");
41 }
42 }
43 }
44 });
45 converse.initialize({
46 //bosh_service_url: 'https://im.immae.fr/bosh',
47 websocket_url: 'wss://im.immae.fr/ws',
48 view_mode: 'fullscreen',
49 show_controlbox_by_default: true,
50 whitelisted_plugins: ['markdown'],
51 });
52 </script>
53 </head>
54 <body>
55 </body>
56</html>
57
diff --git a/modules/private/websites/tools/im/www/index.html b/modules/private/websites/tools/im/www/index.html
new file mode 100644
index 0000000..15e09f2
--- /dev/null
+++ b/modules/private/websites/tools/im/www/index.html
@@ -0,0 +1,46 @@
1<!doctype html>
2<html lang="fr">
3 <head>
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>Instant messaging configuration (Jabber/XMPP)</title>
7 <style type="text/css">
8 body {
9 padding-top: 1em;
10 padding-left: 5px;
11 padding-right: 5px;
12 text-align: left;
13 margin: auto;
14 font: 20px Helvetica, sans-serif;
15 color: #333;
16 height: 100%;
17 min-height: 100%;
18 }
19 article {
20 text-align: justify;
21 display: block;
22 max-width: 850px;
23 margin: 0 auto;
24 padding-top: 30px;
25 }
26 span.code {
27 font-family: monospace;
28 }
29 </style>
30 </head>
31 <body>
32 <p>
33 Pre-configured clients:
34 <ul>
35 <li><a href="converse">Converse client</a></li>
36 </ul>
37 </p>
38 <p>
39 Technical details:
40 <ul>
41 <li>HTTP-bind/BOSH access (XEP-0124 / XEP-0206): <span class="code">https://im.immae.fr/bosh</span></li>
42 <li>WS access (RFC 7395): <span class="code">wss://im.immae.fr/ws</span></li>
43 </ul>
44 </p>
45 </body>
46</html>
diff --git a/modules/private/websites/tools/tools/default.nix b/modules/private/websites/tools/tools/default.nix
index 5a0c196..02ff224 100644
--- a/modules/private/websites/tools/tools/default.nix
+++ b/modules/private/websites/tools/tools/default.nix
@@ -100,6 +100,7 @@ in {
100 extraConfig = [ 100 extraConfig = [
101 '' 101 ''
102 RedirectMatch 301 ^/roundcube(.*)$ https://mail.immae.eu/roundcube$1 102 RedirectMatch 301 ^/roundcube(.*)$ https://mail.immae.eu/roundcube$1
103 RedirectMatch 301 ^/jappix(.*)$ https://im.immae.fr/converse
103 104
104 <Directory "/var/lib/ftp/tools.immae.eu"> 105 <Directory "/var/lib/ftp/tools.immae.eu">
105 DirectoryIndex index.php index.htm index.html 106 DirectoryIndex index.php index.htm index.html
@@ -126,7 +127,7 @@ in {
126 services.websites.env.tools.vhostConfs.outils = { 127 services.websites.env.tools.vhostConfs.outils = {
127 certName = "eldiron"; 128 certName = "eldiron";
128 addToCerts = true; 129 addToCerts = true;
129 hosts = [ "outils.immae.eu" ]; 130 hosts = [ "outils.immae.eu" "outils.immae.fr" ];
130 root = null; 131 root = null;
131 extraConfig = [ 132 extraConfig = [
132 '' 133 ''
@@ -146,6 +147,8 @@ in {
146 147
147 RedirectMatch 301 ^/roundcube(.*)$ https://mail.immae.eu/roundcube$1 148 RedirectMatch 301 ^/roundcube(.*)$ https://mail.immae.eu/roundcube$1
148 149
150 RedirectMatch 301 ^/jappix(.*)$ https://im.immae.fr/converse
151
149 RedirectMatch 301 ^/(.*)$ https://tools.immae.eu/$1 152 RedirectMatch 301 ^/(.*)$ https://tools.immae.eu/$1
150 '' 153 ''
151 ]; 154 ];