Compare commits
510 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6acc3f2f59
|
||
| 7987e92723 | |||
|
|
d922e7f869
|
||
|
|
89c67f3617
|
||
| 1b959b5643 | |||
|
|
4551a14362
|
||
|
|
bfc0969829
|
||
|
|
a1be338ba1
|
||
|
|
589e46bc63
|
||
|
|
34e4cec503
|
||
|
|
c48538a1c6
|
||
|
|
2cced696f5
|
||
|
|
beaafa5d7e
|
||
|
|
9cf309aaa8
|
||
|
|
e8bbe6c713
|
||
|
|
49de4007ab
|
||
|
|
bc4d9ff528
|
||
|
|
b03c6e9513
|
||
|
|
332ad757a5
|
||
|
|
07fe8dba71
|
||
|
|
aedaabc7ba
|
||
|
|
8eb5f093a4
|
||
| de45d070aa | |||
| c0b1112e49 | |||
|
|
2f90393eb6
|
||
|
|
8b87072485
|
||
|
|
82019f47be
|
||
|
|
259e72167b
|
||
|
|
7000908891
|
||
|
|
df0c13b400
|
||
|
|
387a2fa2e6
|
||
| 68eba80fd7 | |||
|
|
7e05530ab7
|
||
|
|
745a319b3d
|
||
|
|
f829bb3379
|
||
|
|
19bafe081f
|
||
| d130f2f68b | |||
|
|
e284996c1c
|
||
|
|
51489a83ab
|
||
|
|
05426e4ced
|
||
|
|
445cdfa024
|
||
|
|
f74227fedb
|
||
|
|
32d1992632
|
||
| 48be35f1b1 | |||
| 87720ef285 | |||
|
|
193a4c2edd
|
||
|
|
134c81460a
|
||
|
|
b1a693e7cf
|
||
|
|
75bd879f84
|
||
|
|
33a9e1eaa9
|
||
|
|
7b321577db
|
||
|
|
61f12c2741
|
||
|
|
c58358c66e
|
||
|
|
287adbd365
|
||
|
|
9048052318
|
||
| cddc1e86f6 | |||
|
|
ce7387a409
|
||
|
|
f1ae5667de
|
||
|
|
67a9fc02d7
|
||
|
|
34849b28b0
|
||
| 8ce5f9708f | |||
|
|
cb2197893c
|
||
| 7a50bd23d6 | |||
| 64c8c3cb06 | |||
|
|
a2100b23a9
|
||
| 27195f693a | |||
|
9e74c89a80
|
|||
|
0774c88918
|
|||
| ef2d2b6422 | |||
|
a47e4fc16b
|
|||
|
9b89101afc
|
|||
|
|
ad90fcd539
|
||
|
|
705bd63b42
|
||
|
|
83e418cdee
|
||
|
|
7a193d6647
|
||
|
|
bb82b6b462
|
||
|
|
4e2e13108c
|
||
|
|
ca7475dca2
|
||
|
|
43a43e1a2c
|
||
|
|
595bb03c5a
|
||
|
|
62cd0eb7d1
|
||
|
|
f19baaf22a
|
||
|
|
23821f9e65
|
||
|
|
a33410eeb4
|
||
|
|
a1b238e86b
|
||
|
|
334b47353e
|
||
|
|
6848bd739c
|
||
|
|
7f77ad5528
|
||
| 6f2160b479 | |||
|
|
f08bb56a7a
|
||
|
|
fe1dfd8ec8
|
||
| c1f275463e | |||
| 324809f77e | |||
|
|
f9b07bcb01
|
||
|
|
986eb5387c
|
||
| f76e2c2f14 | |||
|
|
22a7bbe6eb
|
||
| 18f4deb30f | |||
|
|
9f9bf6fd80
|
||
|
|
d2987da70a
|
||
|
|
6b7a80e23a
|
||
|
|
42b9b27561
|
||
|
|
c17c980b69
|
||
|
|
f199d5d12a
|
||
|
|
4b17afa93d
|
||
|
|
6d52af53ae
|
||
|
|
4c5ad67652
|
||
|
|
3437a756eb
|
||
| 0d9fc4aa74 | |||
| 82475161a9 | |||
|
|
fb3b9af3e5
|
||
|
|
b1a0268e6b
|
||
| e1e7d8f87d | |||
|
|
5b46f3adf5
|
||
|
|
a8a8fba14c
|
||
|
|
8a7016a30b
|
||
|
|
e2618de7c6
|
||
| 90680368fb | |||
|
|
8d90847896 | ||
|
|
8da297811b | ||
|
|
fa56d6b772 | ||
|
|
ca1221e9f3 | ||
|
|
295d486761 | ||
|
|
e00390d102 | ||
|
|
b947480190 | ||
|
|
fa07978aac | ||
|
|
e758e258a8 | ||
|
|
805733939c | ||
|
|
f050d010fd
|
||
|
|
95fac38b53
|
||
| cb80465297 | |||
|
|
c7550b4f64
|
||
| 341284aa99 | |||
|
|
b34d040ce3
|
||
| 1142a4e2d5 | |||
|
|
f2c7aa2f09
|
||
| cca44d7542 | |||
| cdad7546fb | |||
| feb7833533 | |||
|
|
dfb12b8f62
|
||
|
|
6c2a97e7e5
|
||
| c8b65de7f6 | |||
| 2861254adf | |||
| 1d2910dadb | |||
|
|
251a170f2b
|
||
|
|
cbbb4c6e47
|
||
|
|
3aad27c7bd
|
||
|
|
7cff849d79
|
||
|
|
75ffd4e2f1
|
||
| b84f9109f6 | |||
| 7fd564726f | |||
|
b2a1b8caf5
|
|||
|
52cc2a8151
|
|||
|
|
c8e405d93a
|
||
|
|
5f74212603
|
||
|
|
1c3e893b6b
|
||
|
|
eec4533fea
|
||
|
|
6d20ac9a1c
|
||
|
|
27dd4163f0
|
||
|
|
1a55e5e895
|
||
|
|
8eb487600c
|
||
|
|
678e80a25d
|
||
|
|
30fb9805e5
|
||
|
|
e675970f4c
|
||
|
|
a0727e709f
|
||
|
|
55abbcc5ad
|
||
|
|
ffed398024
|
||
|
|
1a2482434c
|
||
| b530ad2f0f | |||
|
|
3c2fe7c15d
|
||
| aa7044dea7 | |||
|
|
a3f0d0f2cf
|
||
|
|
dc63506102
|
||
|
|
b87b9c2437
|
||
|
|
e580cc9991
|
||
|
|
68ab88c481
|
||
|
|
c7fe1bc3bc
|
||
| 84337c3a7d | |||
| 654b90f9ee | |||
| aa0ba18763 | |||
|
|
7dae66959e
|
||
|
|
b67d6139ac
|
||
|
|
b9259958f4
|
||
|
|
832d1e3bd7
|
||
|
|
f3f967f9f7
|
||
|
|
9407c7a94d
|
||
|
|
df3ec9f90a
|
||
|
|
25a0723166
|
||
|
|
6e884b789a
|
||
|
|
346e36e160
|
||
|
|
b7bf957dd2
|
||
|
|
084835f06a
|
||
|
|
cd7b05e2ff
|
||
|
|
7280a4c023
|
||
|
|
164400adec
|
||
|
|
c2e0909132
|
||
|
|
c44ce61e25
|
||
|
|
e2294c4029
|
||
|
|
bdc03a7181
|
||
|
|
959449a3f4
|
||
|
|
b4c9b31ce7
|
||
|
|
43f133ebd7
|
||
|
|
d9e767298b
|
||
|
|
dd482d7f2e
|
||
|
|
09d99ce9c2
|
||
|
|
8f9e1c3e84
|
||
| 4a045bf61c | |||
| f62e49f524 | |||
|
|
b0c787bbc7
|
||
|
|
86dc44d096
|
||
|
|
a1663b9f9d
|
||
|
|
aa3c2b4fa2
|
||
|
|
4c0d8283e3
|
||
|
|
d4a3f8dadb
|
||
|
|
9e988e92d1
|
||
|
|
4232df302b
|
||
|
|
2c8b3cdacc
|
||
|
|
51952ecdc2
|
||
|
|
68e0d00f6e
|
||
|
|
99dc36f13a
|
||
|
|
ee74c4847f
|
||
|
|
15b63eee73
|
||
|
|
c756528d32
|
||
|
|
fef29b4fc0
|
||
|
|
38608e053d
|
||
|
|
5f215b8ed8
|
||
|
|
87aae35974
|
||
|
|
6ad02e69a2
|
||
|
|
94ca0f3764
|
||
|
|
0fec37e0a9
|
||
|
|
620befd7c0
|
||
|
|
aba4930696
|
||
|
|
0492b42327
|
||
|
|
445a1c80a6
|
||
|
|
cf48f76553
|
||
|
|
70fa43f5d2
|
||
|
|
b37a0c25a4
|
||
|
|
3197743a55
|
||
|
|
3f49e4a3b8
|
||
| 2e1d930e0f | |||
| d849d28f62 | |||
|
|
f2a22adf6b
|
||
|
|
e1aaa2c434
|
||
|
|
e62bf67262
|
||
|
|
6df3d5933c
|
||
|
|
a5a90c4d83
|
||
|
|
80ef75ff42
|
||
|
|
67e2e45dd8
|
||
|
|
3834e5230b
|
||
|
|
4cb7c0998f
|
||
|
|
20382f7df7
|
||
|
|
add94eee8d
|
||
|
|
067dc3b63d
|
||
|
|
1a470cf1c8
|
||
|
|
f85b7f4f62
|
||
|
|
8635413002
|
||
|
|
a3da956b48
|
||
|
|
3c40dc98ca
|
||
| 28b31e63f9 | |||
|
|
efafd38f68
|
||
|
|
537e1a4774
|
||
|
|
c3b9ff8b4a
|
||
|
|
93d56f79d5
|
||
|
|
1a30345f46
|
||
|
|
778babcc05
|
||
|
|
fa3b53d3b3
|
||
|
|
0ca85656b7
|
||
|
|
f7183f68d5
|
||
| 87027b514b | |||
|
|
16ad621365
|
||
| 33e87d6472 | |||
|
03dc6c7a9c
|
|||
|
897b5bf4ea
|
|||
|
caea2d0121
|
|||
|
e1ff5c479e
|
|||
|
9b3386de30
|
|||
|
f2287c1186
|
|||
| b29197cf4e | |||
|
5c48055ac8
|
|||
|
5ead3476b7
|
|||
| fbf163740a | |||
|
|
1fc1457e97 | ||
| 1f57bbd9c2 | |||
|
2a2793ae44
|
|||
|
8773bf5f9e
|
|||
|
d9970c126a
|
|||
|
4e0d4bf86d
|
|||
|
333bcbfe7e
|
|||
| 875af6d14c | |||
| 8f87a03060 | |||
|
7838fe5f34
|
|||
|
512798d122
|
|||
|
384c28aaaa
|
|||
|
8e5d6dabdc
|
|||
|
ade9261c2c
|
|||
|
bd2a161306
|
|||
|
78c243c985
|
|||
|
cf62bfc5c2
|
|||
|
10f179a095
|
|||
|
f7d0a0ba85
|
|||
| 83e4dfa18f | |||
|
4c70600d1f
|
|||
|
9903683536
|
|||
|
4c51b9c966
|
|||
| 6790e8383d | |||
|
ed886d8182
|
|||
|
ca940ec35d
|
|||
|
5751c0338a
|
|||
|
b9ec363f36
|
|||
|
417768a30c
|
|||
|
9824dcd2c6
|
|||
|
5a784b5fa6
|
|||
|
f36f6866a7
|
|||
|
1fecfe57de
|
|||
|
3165714957
|
|||
|
4ccf43cf4a
|
|||
|
c0e79918ea
|
|||
|
2b00eebb73
|
|||
|
86cdb1202b
|
|||
|
6a469d6a75
|
|||
|
7d66b75216
|
|||
|
8102fa1230
|
|||
|
835152c656
|
|||
|
7c5bd9aa34
|
|||
|
b329b557c4
|
|||
|
2e301c3019
|
|||
|
4f2b35ccb9
|
|||
| a2889705ed | |||
|
7cb0111449
|
|||
| 773ea24c5d | |||
|
cd3e4161b8
|
|||
|
5a658ce580
|
|||
|
6e9b38f04b
|
|||
|
a71a9dfad0
|
|||
|
1c4e444c0b
|
|||
|
565a3c3276
|
|||
|
9fdbf27a60
|
|||
|
1a9b47ceee
|
|||
|
908809bc48
|
|||
|
9636671d57
|
|||
|
51cddd94f5
|
|||
|
123e7aa2a1
|
|||
|
3596955642
|
|||
|
562b16cf89
|
|||
|
830c634f88
|
|||
|
2a793e9201
|
|||
|
e571ed9429
|
|||
|
a67f3e466b
|
|||
|
ff3013f917
|
|||
|
0fa6c1a211
|
|||
|
30b2646b85
|
|||
|
f8b86b0a22
|
|||
| b71a2fa643 | |||
|
eda1f3999f
|
|||
|
c06e58a0fb
|
|||
|
c33637003e
|
|||
|
836bd0a977
|
|||
|
8578fbdad9
|
|||
|
878eac083c
|
|||
|
05da7f5dac
|
|||
|
87e3b1a76c
|
|||
|
32f02cc18a
|
|||
|
1b17cfb396
|
|||
| e5aa5a665c | |||
| d37b68a6e5 | |||
|
56936916ff
|
|||
|
c93a460cff
|
|||
| f5ceda35c1 | |||
|
eb0439d6dc
|
|||
|
c3dde3506e
|
|||
| f22ffe373c | |||
|
bc20e89617
|
|||
| 0f0f296a5e | |||
|
78aea5d608
|
|||
|
f1d3e3d8ec
|
|||
| 2706c76890 | |||
| 17f5eb56cd | |||
| aa6b677b13 | |||
|
9abdab2274
|
|||
|
dd49d1208f
|
|||
|
db9118cb7c
|
|||
|
89913ba60b
|
|||
|
8cf631fd94
|
|||
| d0b359039b | |||
|
84cf523049
|
|||
| a7390ba00b | |||
|
67d148d117
|
|||
|
83ad6f4eef
|
|||
|
2e31268698
|
|||
|
f3b22c02ef
|
|||
| dbe65b4b5a | |||
|
2871fc0f53
|
|||
|
968689a512
|
|||
|
ab29f618f4
|
|||
| 94975a1b30 | |||
|
cd8880d9dc
|
|||
|
f59182b9c1
|
|||
|
941cb4a571
|
|||
|
f534898d8b
|
|||
| 18c7c54403 | |||
|
12a9d4674b
|
|||
|
1af8e068c5
|
|||
| 669b163814 | |||
| 46c7affd1f | |||
| 7ab107b689 | |||
| 5aee1a4100 | |||
|
1578fb9976
|
|||
| 8e64a7cf78 | |||
|
8b5bd66598
|
|||
| ac8552362c | |||
|
99c86c42c5
|
|||
|
d0267cb760
|
|||
| 25ddab9241 | |||
|
bf76ac55ee
|
|||
|
40e5c3609e
|
|||
|
1078c034ad
|
|||
|
bfa38ad7b2
|
|||
|
4f20cd0d0a
|
|||
|
e2ee33a1da
|
|||
|
8662a4c8c1
|
|||
|
dbc811b840
|
|||
|
884070a3cb
|
|||
|
3c350155de
|
|||
|
21c6ebc137
|
|||
|
0a1052fcb7
|
|||
|
f94227f9f3
|
|||
| 088961dfec | |||
|
31cf353d3a
|
|||
|
4eb40abc9c
|
|||
|
682c78c7c3
|
|||
|
f9726ad9be
|
|||
|
89188f5081
|
|||
| 6a6ff84ff2 | |||
|
b6949acc96
|
|||
|
814633034f
|
|||
| 260dedb6cf | |||
|
656c887811
|
|||
|
7e9af716ac
|
|||
|
58cc6811f9
|
|||
|
8ad85636d9
|
|||
|
35e2c8cd30
|
|||
| 4526c941b8 | |||
| 4f5ebd5330 | |||
|
d7e4c6f3ae
|
|||
|
14caefe2d1
|
|||
|
0110f27ada
|
|||
|
dc7cf107c2
|
|||
| 4fbfaadb44 | |||
|
a01cb9ae21
|
|||
|
698e4381c2
|
|||
|
8997349186
|
|||
|
92bfc33bf0
|
|||
|
c6eb21faad
|
|||
| 2d9bc90b16 | |||
|
a0c579e319
|
|||
|
f289ee9365
|
|||
| 46a7345ce9 | |||
|
e12d02a988
|
|||
| 5e8618f25a | |||
|
2bdf08a523
|
|||
|
9ddd36c414
|
|||
|
9372ea7343
|
|||
|
c62ce00184
|
|||
|
4d8cd740ba
|
|||
|
9858572a2f
|
|||
|
51edf55ae9
|
|||
| 75485ce8e9 | |||
|
fcbfcc4007
|
|||
|
cdcb7b3aef
|
|||
| bcf5172956 | |||
|
26c6c5a3b2
|
|||
|
4a65573934
|
|||
|
5e2d5c3b28
|
|||
|
2f70bae523
|
|||
|
40f3e8327a
|
|||
|
f3d6e29e4e
|
|||
| 8903ae2624 | |||
|
26e9073674
|
|||
| 73a89c2601 | |||
|
7d4dee17b7
|
|||
| 602ca6ee94 | |||
|
69fc1ca57e
|
|||
|
ee72a32c7e
|
|||
|
8a0d89ef60
|
|||
|
54af949c7d
|
|||
|
6dac732a7f
|
|||
|
e8c1a6066a
|
|||
| 44fadb12d6 | |||
|
533452469b
|
|||
| efe168b205 | |||
|
5b6d6bbd00
|
|||
|
458b585cdb
|
|||
|
f651289410
|
|||
|
7ca91cf882
|
|||
|
022094ce51
|
|||
| 2a2b0a90dc | |||
| e44535daee | |||
| c8ccb418b2 | |||
| a792d66c90 | |||
| f7e48ad3a6 | |||
|
8a7d809b92
|
|||
|
b8e75c7c4a
|
|||
|
7a58babd8e
|
|||
|
ba31ed559a
|
|||
|
9cebfd3f58
|
|||
|
7aadb5cb51
|
|||
|
69b99711e5
|
|||
|
e5fe843814
|
|||
|
d7fbda0855
|
|||
|
18df8fe449
|
32
.drone.yml
32
.drone.yml
@@ -1,3 +1,4 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: CI build
|
||||
@@ -11,16 +12,23 @@ steps:
|
||||
settings:
|
||||
restore: true
|
||||
mount:
|
||||
- vendor
|
||||
- name: rspec
|
||||
image: guildeducation/rails:2.7.1-12.19.0
|
||||
commands:
|
||||
- bundle install --jobs=3 --retry=3 --deployment
|
||||
- yarn install
|
||||
- bundle exec rspec
|
||||
- ./vendor/cache
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
- name: rspec
|
||||
image: guildeducation/rails:2.7.2-14.20.0
|
||||
environment:
|
||||
RAILS_ENV: test
|
||||
commands:
|
||||
- bundle config unset deployment
|
||||
- bundle config set cache_all 'true'
|
||||
- bundle config set cache_path 'vendor/cache'
|
||||
- bundle config set with 'development test'
|
||||
- bundle install --jobs=3 --retry=3
|
||||
- yarn install
|
||||
- rake css:build
|
||||
- bundle exec rspec
|
||||
- name: rebuild-cache
|
||||
image: drillster/drone-volume-cache
|
||||
volumes:
|
||||
@@ -29,9 +37,17 @@ steps:
|
||||
settings:
|
||||
rebuild: true
|
||||
mount:
|
||||
- vendor
|
||||
- ./vendor/cache
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
|
||||
volumes:
|
||||
- name: cache
|
||||
host:
|
||||
path: /var/lib/drone/tmp
|
||||
---
|
||||
kind: signature
|
||||
hmac: f9a8cf97f6596625721365f6238f6f298aa5a7a4de10c3fb61c57202ae9d1ee1
|
||||
|
||||
...
|
||||
|
||||
49
.env.example
49
.env.example
@@ -1,8 +1,43 @@
|
||||
LDAP_HOST=192.168.33.10
|
||||
PRIMARY_DOMAIN=kosmos.org
|
||||
AKKOUNTS_DOMAIN=accounts.example.com
|
||||
|
||||
SMTP_SERVER=smtp.example.com
|
||||
SMTP_PORT=587
|
||||
SMTP_LOGIN=accounts
|
||||
SMTP_PASSWORD=123abc
|
||||
SMTP_FROM_ADDRESS=accounts@example.com
|
||||
SMTP_DOMAIN=example.com
|
||||
SMTP_AUTH_METHOD=plain
|
||||
SMTP_ENABLE_STARTTLS=auto
|
||||
|
||||
LDAP_HOST=localhost
|
||||
LDAP_PORT=389
|
||||
#
|
||||
# Production LDAP server:
|
||||
#
|
||||
# LDAP_HOST=ldap.kosmos.org
|
||||
# LDAP_PORT=636
|
||||
# LDAP_USE_TLS=true
|
||||
LDAP_ADMIN_PASSWORD=passthebutter
|
||||
LDAP_SUFFIX='dc=kosmos,dc=org'
|
||||
|
||||
REDIS_URL='redis://localhost:6379/1'
|
||||
|
||||
WEBHOOKS_ALLOWED_IPS='10.1.1.163'
|
||||
|
||||
DISCOURSE_PUBLIC_URL='https://community.kosmos.org'
|
||||
DISCOURSE_CONNECT_SECRET='discourse_connect_ftw'
|
||||
|
||||
GITEA_PUBLIC_URL='https://gitea.kosmos.org'
|
||||
MASTODON_PUBLIC_URL='https://kosmos.social'
|
||||
MEDIAWIKI_PUBLIC_URL='https://wiki.kosmos.org'
|
||||
RS_STORAGE_URL='https://storage.kosmos.org'
|
||||
|
||||
EJABBERD_ADMIN_URL='https://xmpp.kosmos.org/admin'
|
||||
EJABBERD_API_URL='https://xmpp.kosmos.org/api'
|
||||
|
||||
BTCPAY_API_URL='http://localhost:23001/api/v1'
|
||||
|
||||
LNDHUB_API_URL='http://localhost:3023'
|
||||
LNDHUB_PUBLIC_URL='https://lndhub.kosmos.org'
|
||||
LNDHUB_PUBLIC_KEY='0123d3be18617f39cf645851e3ba63f51fc13f0bb09e3bb25e6fd4de556486d946'
|
||||
LNDHUB_ADMIN_UI=true
|
||||
LNDHUB_PG_HOST=localhost
|
||||
LNDHUB_PG_PORT=5432
|
||||
LNDHUB_PG_DATABASE=lndhub
|
||||
LNDHUB_PG_USERNAME=lndhub
|
||||
LNDHUB_PG_PASSWORD=''
|
||||
|
||||
16
.env.test
Normal file
16
.env.test
Normal file
@@ -0,0 +1,16 @@
|
||||
PRIMARY_DOMAIN=kosmos.org
|
||||
|
||||
DISCOURSE_PUBLIC_URL='http://discourse.example.com'
|
||||
DISCOURSE_CONNECT_SECRET='discourse_connect_ftw'
|
||||
|
||||
EJABBERD_API_URL='http://xmpp.example.com/api'
|
||||
|
||||
BTCPAY_API_URL='http://btcpay.example.com/api/v1'
|
||||
|
||||
LNDHUB_API_URL='http://localhost:3026'
|
||||
LNDHUB_PUBLIC_URL='https://lndhub.kosmos.org'
|
||||
LNDHUB_PUBLIC_KEY='024cd3be18617f39cf645851e3ba63f51fc13f0bb09e3bb25e6fd4de556486d946'
|
||||
|
||||
RS_STORAGE_URL='https://storage.kosmos.org'
|
||||
|
||||
WEBHOOKS_ALLOWED_IPS='10.1.1.23'
|
||||
13
.gitea/release-drafter.yml
Normal file
13
.gitea/release-drafter.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
name-template: 'v$RESOLVED_VERSION'
|
||||
tag-template: 'v$RESOLVED_VERSION'
|
||||
version-resolver:
|
||||
major:
|
||||
labels:
|
||||
- 'release/major'
|
||||
minor:
|
||||
labels:
|
||||
- 'release/minor'
|
||||
patch:
|
||||
labels:
|
||||
- 'release/patch'
|
||||
default: patch
|
||||
11
.gitea/workflows/release_drafter.yml
Normal file
11
.gitea/workflows/release_drafter.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
name: Release Drafter
|
||||
on:
|
||||
pull_request:
|
||||
types: [closed]
|
||||
jobs:
|
||||
release_drafter_job:
|
||||
name: Update release notes draft
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Release Drafter
|
||||
uses: https://github.com/raucao/gitea-release-drafter@dev
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -39,3 +39,9 @@ yarn-debug.log*
|
||||
|
||||
# Ignore local dotenv config file
|
||||
.env
|
||||
|
||||
# Ignore redis dumps from sidekiq
|
||||
dump.rdb
|
||||
|
||||
/app/assets/builds/*
|
||||
!/app/assets/builds/.keep
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.6.1
|
||||
2.7.2
|
||||
|
||||
21
Dockerfile
Normal file
21
Dockerfile
Normal file
@@ -0,0 +1,21 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM ruby:2.7.6
|
||||
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
RUN apt-get update -qq && apt-get install -y --no-install-recommends curl \
|
||||
ldap-utils tini
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
|
||||
RUN apt-get update && apt-get install -y nodejs
|
||||
|
||||
WORKDIR /akkounts
|
||||
COPY Gemfile /akkounts/Gemfile
|
||||
COPY Gemfile.lock /akkounts/Gemfile.lock
|
||||
COPY package.json /akkounts/package.json
|
||||
RUN bundle install
|
||||
RUN gem install foreman
|
||||
RUN npm install -g yarn
|
||||
RUN yarn install
|
||||
|
||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||
EXPOSE 3000
|
||||
65
Gemfile
65
Gemfile
@@ -2,15 +2,21 @@ source 'https://rubygems.org'
|
||||
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
||||
|
||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||
gem 'rails', '~> 6.0.3', '>= 6.0.3.4'
|
||||
gem 'rails', '~> 7.0.2'
|
||||
# Use Puma as the app server
|
||||
gem 'puma', '~> 4.1'
|
||||
# Use SCSS for stylesheets
|
||||
gem 'sass-rails', '>= 6'
|
||||
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
|
||||
gem 'webpacker', '~> 4.0'
|
||||
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
|
||||
gem 'turbolinks', '~> 5'
|
||||
# View components
|
||||
gem "view_component"
|
||||
# Separate dependency since Rails 7.0
|
||||
gem 'sprockets-rails'
|
||||
# Allows custom JS build tasks to integrate with the asset pipeline
|
||||
gem 'cssbundling-rails'
|
||||
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
|
||||
gem "importmap-rails"
|
||||
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
|
||||
gem "turbo-rails"
|
||||
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
|
||||
gem "stimulus-rails"
|
||||
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
||||
gem 'jbuilder', '~> 2.7'
|
||||
# Use Redis adapter to run Action Cable in production
|
||||
@@ -18,39 +24,64 @@ gem 'jbuilder', '~> 2.7'
|
||||
# Use Active Model has_secure_password
|
||||
# gem 'bcrypt', '~> 3.1.7'
|
||||
|
||||
# Reduces boot times through caching; required in config/boot.rb
|
||||
gem 'bootsnap', '>= 1.4.2', require: false
|
||||
# Configuration
|
||||
gem 'dotenv-rails'
|
||||
|
||||
gem 'dotenv-rails', groups: [:development, :test]
|
||||
# Security
|
||||
gem 'lockbox'
|
||||
|
||||
# Authentication
|
||||
gem 'warden'
|
||||
gem 'devise'
|
||||
gem 'devise', '~> 4.9.0'
|
||||
gem 'devise_ldap_authenticatable'
|
||||
gem 'net-ldap'
|
||||
|
||||
# Utilities
|
||||
gem "rqrcode", "~> 2.0"
|
||||
gem 'rails-settings-cached', '~> 2.8.3'
|
||||
gem 'pagy', '~> 6.0', '>= 6.0.2'
|
||||
gem 'flipper'
|
||||
gem 'flipper-active_record'
|
||||
gem 'flipper-ui'
|
||||
|
||||
# HTTP requests
|
||||
gem 'faraday'
|
||||
|
||||
# Background/scheduled jobs
|
||||
gem 'sidekiq', '< 7'
|
||||
gem 'sidekiq-scheduler'
|
||||
|
||||
# Monitoring
|
||||
gem "sentry-ruby"
|
||||
gem "sentry-rails"
|
||||
|
||||
# Services
|
||||
gem 'discourse_api'
|
||||
gem "lnurl"
|
||||
gem 'nostr', git: 'https://gitea.kosmos.org/kosmos/nostr-gem.git', branch: 'feature/ruby_2.7_compat'
|
||||
|
||||
group :development, :test do
|
||||
# Use sqlite3 as the database for Active Record
|
||||
gem 'sqlite3', '~> 1.4'
|
||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
||||
gem 'rspec-rails'
|
||||
gem "byebug", "~> 11.1"
|
||||
end
|
||||
|
||||
group :development do
|
||||
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
|
||||
gem 'web-console', '>= 3.3.0'
|
||||
gem 'listen', '~> 3.2'
|
||||
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
||||
gem 'spring'
|
||||
gem 'spring-watcher-listen', '~> 2.0.0'
|
||||
gem 'letter_opener'
|
||||
gem 'letter_opener_web'
|
||||
gem 'faker'
|
||||
gem 'solargraph'
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem 'rspec-rails'
|
||||
gem 'factory_bot_rails'
|
||||
gem 'capybara'
|
||||
gem 'database_cleaner'
|
||||
gem 'webmock'
|
||||
end
|
||||
|
||||
group :production do
|
||||
|
||||
560
Gemfile.lock
560
Gemfile.lock
@@ -1,81 +1,122 @@
|
||||
GIT
|
||||
remote: https://gitea.kosmos.org/kosmos/nostr-gem.git
|
||||
revision: 596529d9eb50d13b3f385245636698fccf37b442
|
||||
branch: feature/ruby_2.7_compat
|
||||
specs:
|
||||
nostr (0.4.0)
|
||||
bech32 (~> 1.3)
|
||||
bip-schnorr (~> 0.4)
|
||||
ecdsa (~> 1.2)
|
||||
event_emitter (~> 0.2)
|
||||
faye-websocket (~> 0.11)
|
||||
json (~> 2.6)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (6.0.3.4)
|
||||
actionpack (= 6.0.3.4)
|
||||
actioncable (7.0.5)
|
||||
actionpack (= 7.0.5)
|
||||
activesupport (= 7.0.5)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailbox (6.0.3.4)
|
||||
actionpack (= 6.0.3.4)
|
||||
activejob (= 6.0.3.4)
|
||||
activerecord (= 6.0.3.4)
|
||||
activestorage (= 6.0.3.4)
|
||||
activesupport (= 6.0.3.4)
|
||||
actionmailbox (7.0.5)
|
||||
actionpack (= 7.0.5)
|
||||
activejob (= 7.0.5)
|
||||
activerecord (= 7.0.5)
|
||||
activestorage (= 7.0.5)
|
||||
activesupport (= 7.0.5)
|
||||
mail (>= 2.7.1)
|
||||
actionmailer (6.0.3.4)
|
||||
actionpack (= 6.0.3.4)
|
||||
actionview (= 6.0.3.4)
|
||||
activejob (= 6.0.3.4)
|
||||
net-imap
|
||||
net-pop
|
||||
net-smtp
|
||||
actionmailer (7.0.5)
|
||||
actionpack (= 7.0.5)
|
||||
actionview (= 7.0.5)
|
||||
activejob (= 7.0.5)
|
||||
activesupport (= 7.0.5)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
net-imap
|
||||
net-pop
|
||||
net-smtp
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (6.0.3.4)
|
||||
actionview (= 6.0.3.4)
|
||||
activesupport (= 6.0.3.4)
|
||||
rack (~> 2.0, >= 2.0.8)
|
||||
actionpack (7.0.5)
|
||||
actionview (= 7.0.5)
|
||||
activesupport (= 7.0.5)
|
||||
rack (~> 2.0, >= 2.2.4)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||
actiontext (6.0.3.4)
|
||||
actionpack (= 6.0.3.4)
|
||||
activerecord (= 6.0.3.4)
|
||||
activestorage (= 6.0.3.4)
|
||||
activesupport (= 6.0.3.4)
|
||||
actiontext (7.0.5)
|
||||
actionpack (= 7.0.5)
|
||||
activerecord (= 7.0.5)
|
||||
activestorage (= 7.0.5)
|
||||
activesupport (= 7.0.5)
|
||||
globalid (>= 0.6.0)
|
||||
nokogiri (>= 1.8.5)
|
||||
actionview (6.0.3.4)
|
||||
activesupport (= 6.0.3.4)
|
||||
actionview (7.0.5)
|
||||
activesupport (= 7.0.5)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||
activejob (6.0.3.4)
|
||||
activesupport (= 6.0.3.4)
|
||||
activejob (7.0.5)
|
||||
activesupport (= 7.0.5)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (6.0.3.4)
|
||||
activesupport (= 6.0.3.4)
|
||||
activerecord (6.0.3.4)
|
||||
activemodel (= 6.0.3.4)
|
||||
activesupport (= 6.0.3.4)
|
||||
activestorage (6.0.3.4)
|
||||
actionpack (= 6.0.3.4)
|
||||
activejob (= 6.0.3.4)
|
||||
activerecord (= 6.0.3.4)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (6.0.3.4)
|
||||
activemodel (7.0.5)
|
||||
activesupport (= 7.0.5)
|
||||
activerecord (7.0.5)
|
||||
activemodel (= 7.0.5)
|
||||
activesupport (= 7.0.5)
|
||||
activestorage (7.0.5)
|
||||
actionpack (= 7.0.5)
|
||||
activejob (= 7.0.5)
|
||||
activerecord (= 7.0.5)
|
||||
activesupport (= 7.0.5)
|
||||
marcel (~> 1.0)
|
||||
mini_mime (>= 1.1.0)
|
||||
activesupport (7.0.5)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
zeitwerk (~> 2.2, >= 2.2.2)
|
||||
addressable (2.7.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
bcrypt (3.1.16)
|
||||
i18n (>= 1.6, < 2)
|
||||
minitest (>= 5.1)
|
||||
tzinfo (~> 2.0)
|
||||
addressable (2.8.4)
|
||||
public_suffix (>= 2.0.2, < 6.0)
|
||||
ast (2.4.2)
|
||||
backport (1.2.0)
|
||||
bcrypt (3.1.18)
|
||||
bech32 (1.3.0)
|
||||
thor (>= 1.1.0)
|
||||
benchmark (0.2.1)
|
||||
bindex (0.8.1)
|
||||
bootsnap (1.5.0)
|
||||
msgpack (~> 1.0)
|
||||
bip-schnorr (0.6.0)
|
||||
ecdsa_ext (~> 0.5.0)
|
||||
builder (3.2.4)
|
||||
byebug (11.1.3)
|
||||
capybara (3.33.0)
|
||||
capybara (3.39.2)
|
||||
addressable
|
||||
matrix
|
||||
mini_mime (>= 0.1.3)
|
||||
nokogiri (~> 1.8)
|
||||
rack (>= 1.6.0)
|
||||
rack-test (>= 0.6.3)
|
||||
regexp_parser (~> 1.5)
|
||||
regexp_parser (>= 1.5, < 3.0)
|
||||
xpath (~> 3.2)
|
||||
concurrent-ruby (1.1.7)
|
||||
chunky_png (1.4.0)
|
||||
concurrent-ruby (1.2.2)
|
||||
connection_pool (2.4.1)
|
||||
crack (0.4.5)
|
||||
rexml
|
||||
crass (1.0.6)
|
||||
database_cleaner (1.8.5)
|
||||
devise (4.7.3)
|
||||
cssbundling-rails (1.1.2)
|
||||
railties (>= 6.0.0)
|
||||
database_cleaner (2.0.2)
|
||||
database_cleaner-active_record (>= 2, < 3)
|
||||
database_cleaner-active_record (2.1.0)
|
||||
activerecord (>= 5.a)
|
||||
database_cleaner-core (~> 2.0.0)
|
||||
database_cleaner-core (2.0.1)
|
||||
date (3.3.3)
|
||||
devise (4.9.2)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
@@ -84,191 +125,338 @@ GEM
|
||||
devise_ldap_authenticatable (0.8.7)
|
||||
devise (>= 3.4.1)
|
||||
net-ldap (>= 0.16.0)
|
||||
diff-lcs (1.4.4)
|
||||
dotenv (2.7.2)
|
||||
dotenv-rails (2.7.2)
|
||||
dotenv (= 2.7.2)
|
||||
railties (>= 3.2, < 6.1)
|
||||
erubi (1.9.0)
|
||||
factory_bot (6.1.0)
|
||||
activesupport (>= 5.0.0)
|
||||
factory_bot_rails (6.1.0)
|
||||
factory_bot (~> 6.1.0)
|
||||
railties (>= 5.0.0)
|
||||
ffi (1.13.1)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
i18n (1.8.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jbuilder (2.10.1)
|
||||
activesupport (>= 5.0.0)
|
||||
launchy (2.4.3)
|
||||
addressable (~> 2.3)
|
||||
letter_opener (1.7.0)
|
||||
launchy (~> 2.2)
|
||||
letter_opener_web (1.3.4)
|
||||
actionmailer (>= 3.2)
|
||||
letter_opener (~> 1.0)
|
||||
diff-lcs (1.5.0)
|
||||
discourse_api (2.0.1)
|
||||
faraday (~> 2.7)
|
||||
faraday-follow_redirects
|
||||
faraday-multipart
|
||||
rack (>= 1.6)
|
||||
dotenv (2.8.1)
|
||||
dotenv-rails (2.8.1)
|
||||
dotenv (= 2.8.1)
|
||||
railties (>= 3.2)
|
||||
listen (3.2.1)
|
||||
e2mmap (0.1.0)
|
||||
ecdsa (1.2.0)
|
||||
ecdsa_ext (0.5.0)
|
||||
ecdsa (~> 1.2.0)
|
||||
erubi (1.12.0)
|
||||
et-orbi (1.2.7)
|
||||
tzinfo
|
||||
event_emitter (0.2.6)
|
||||
eventmachine (1.2.7)
|
||||
factory_bot (6.2.1)
|
||||
activesupport (>= 5.0.0)
|
||||
factory_bot_rails (6.2.0)
|
||||
factory_bot (~> 6.2.0)
|
||||
railties (>= 5.0.0)
|
||||
faker (3.2.0)
|
||||
i18n (>= 1.8.11, < 2)
|
||||
faraday (2.7.6)
|
||||
faraday-net_http (>= 2.0, < 3.1)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-follow_redirects (0.3.0)
|
||||
faraday (>= 1, < 3)
|
||||
faraday-multipart (1.0.4)
|
||||
multipart-post (~> 2)
|
||||
faraday-net_http (3.0.2)
|
||||
faye-websocket (0.11.2)
|
||||
eventmachine (>= 0.12.0)
|
||||
websocket-driver (>= 0.5.1)
|
||||
ffi (1.15.5)
|
||||
flipper (0.28.0)
|
||||
concurrent-ruby (< 2)
|
||||
flipper-active_record (0.28.0)
|
||||
activerecord (>= 4.2, < 8)
|
||||
flipper (~> 0.28.0)
|
||||
flipper-ui (0.28.0)
|
||||
erubi (>= 1.0.0, < 2.0.0)
|
||||
flipper (~> 0.28.0)
|
||||
rack (>= 1.4, < 3)
|
||||
rack-protection (>= 1.5.3, <= 4.0.0)
|
||||
sanitize (< 7)
|
||||
fugit (1.8.1)
|
||||
et-orbi (~> 1, >= 1.2.7)
|
||||
raabro (~> 1.4)
|
||||
globalid (1.1.0)
|
||||
activesupport (>= 5.0)
|
||||
hashdiff (1.0.1)
|
||||
i18n (1.14.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
importmap-rails (1.1.6)
|
||||
actionpack (>= 6.0.0)
|
||||
railties (>= 6.0.0)
|
||||
jaro_winkler (1.5.6)
|
||||
jbuilder (2.11.5)
|
||||
actionview (>= 5.0.0)
|
||||
activesupport (>= 5.0.0)
|
||||
json (2.6.3)
|
||||
kramdown (2.4.0)
|
||||
rexml
|
||||
kramdown-parser-gfm (1.1.0)
|
||||
kramdown (~> 2.0)
|
||||
launchy (2.5.2)
|
||||
addressable (~> 2.8)
|
||||
letter_opener (1.8.1)
|
||||
launchy (>= 2.2, < 3)
|
||||
letter_opener_web (2.0.0)
|
||||
actionmailer (>= 5.2)
|
||||
letter_opener (~> 1.7)
|
||||
railties (>= 5.2)
|
||||
rexml
|
||||
listen (3.8.0)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
loofah (2.7.0)
|
||||
lnurl (1.0.1)
|
||||
bech32 (~> 1.1)
|
||||
lockbox (1.2.0)
|
||||
loofah (2.21.3)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
nokogiri (>= 1.12.0)
|
||||
mail (2.8.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
net-imap
|
||||
net-pop
|
||||
net-smtp
|
||||
marcel (1.0.2)
|
||||
matrix (0.4.2)
|
||||
method_source (1.0.0)
|
||||
mimemagic (0.3.5)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.14.2)
|
||||
msgpack (1.3.3)
|
||||
net-ldap (0.16.3)
|
||||
nio4r (2.5.4)
|
||||
nokogiri (1.10.10)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
mini_mime (1.1.2)
|
||||
minitest (5.18.0)
|
||||
multipart-post (2.3.0)
|
||||
net-imap (0.3.6)
|
||||
date
|
||||
net-protocol
|
||||
net-ldap (0.18.0)
|
||||
net-pop (0.1.2)
|
||||
net-protocol
|
||||
net-protocol (0.2.1)
|
||||
timeout
|
||||
net-smtp (0.3.3)
|
||||
net-protocol
|
||||
nio4r (2.5.9)
|
||||
nokogiri (1.15.2-x86_64-linux)
|
||||
racc (~> 1.4)
|
||||
orm_adapter (0.5.0)
|
||||
pagy (6.0.4)
|
||||
parallel (1.23.0)
|
||||
parser (3.2.2.3)
|
||||
ast (~> 2.4.1)
|
||||
racc
|
||||
pg (1.2.3)
|
||||
public_suffix (4.0.6)
|
||||
puma (4.3.6)
|
||||
public_suffix (5.0.1)
|
||||
puma (4.3.12)
|
||||
nio4r (~> 2.0)
|
||||
rack (2.2.3)
|
||||
rack-proxy (0.6.5)
|
||||
raabro (1.4.0)
|
||||
racc (1.7.1)
|
||||
rack (2.2.7)
|
||||
rack-protection (3.0.6)
|
||||
rack
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (6.0.3.4)
|
||||
actioncable (= 6.0.3.4)
|
||||
actionmailbox (= 6.0.3.4)
|
||||
actionmailer (= 6.0.3.4)
|
||||
actionpack (= 6.0.3.4)
|
||||
actiontext (= 6.0.3.4)
|
||||
actionview (= 6.0.3.4)
|
||||
activejob (= 6.0.3.4)
|
||||
activemodel (= 6.0.3.4)
|
||||
activerecord (= 6.0.3.4)
|
||||
activestorage (= 6.0.3.4)
|
||||
activesupport (= 6.0.3.4)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 6.0.3.4)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rack-test (2.1.0)
|
||||
rack (>= 1.3)
|
||||
rails (7.0.5)
|
||||
actioncable (= 7.0.5)
|
||||
actionmailbox (= 7.0.5)
|
||||
actionmailer (= 7.0.5)
|
||||
actionpack (= 7.0.5)
|
||||
actiontext (= 7.0.5)
|
||||
actionview (= 7.0.5)
|
||||
activejob (= 7.0.5)
|
||||
activemodel (= 7.0.5)
|
||||
activerecord (= 7.0.5)
|
||||
activestorage (= 7.0.5)
|
||||
activesupport (= 7.0.5)
|
||||
bundler (>= 1.15.0)
|
||||
railties (= 7.0.5)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.3.0)
|
||||
loofah (~> 2.3)
|
||||
railties (6.0.3.4)
|
||||
actionpack (= 6.0.3.4)
|
||||
activesupport (= 6.0.3.4)
|
||||
rails-html-sanitizer (1.6.0)
|
||||
loofah (~> 2.21)
|
||||
nokogiri (~> 1.14)
|
||||
rails-settings-cached (2.8.3)
|
||||
activerecord (>= 5.0.0)
|
||||
railties (>= 5.0.0)
|
||||
railties (7.0.5)
|
||||
actionpack (= 7.0.5)
|
||||
activesupport (= 7.0.5)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.20.3, < 2.0)
|
||||
rake (13.0.1)
|
||||
rb-fsevent (0.10.4)
|
||||
rake (>= 12.2)
|
||||
thor (~> 1.0)
|
||||
zeitwerk (~> 2.5)
|
||||
rainbow (3.1.1)
|
||||
rake (13.0.6)
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
regexp_parser (1.8.2)
|
||||
responders (3.0.1)
|
||||
actionpack (>= 5.0)
|
||||
rbs (2.8.4)
|
||||
redis (4.8.1)
|
||||
regexp_parser (2.8.1)
|
||||
responders (3.1.0)
|
||||
actionpack (>= 5.2)
|
||||
railties (>= 5.2)
|
||||
reverse_markdown (2.1.1)
|
||||
nokogiri
|
||||
rexml (3.2.5)
|
||||
rqrcode (2.2.0)
|
||||
chunky_png (~> 1.0)
|
||||
rqrcode_core (~> 1.0)
|
||||
rqrcode_core (1.2.0)
|
||||
rspec-core (3.12.2)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-expectations (3.12.3)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-mocks (3.12.5)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-rails (6.0.3)
|
||||
actionpack (>= 6.1)
|
||||
activesupport (>= 6.1)
|
||||
railties (>= 6.1)
|
||||
rspec-core (~> 3.12)
|
||||
rspec-expectations (~> 3.12)
|
||||
rspec-mocks (~> 3.12)
|
||||
rspec-support (~> 3.12)
|
||||
rspec-support (3.12.0)
|
||||
rubocop (1.52.1)
|
||||
json (~> 2.3)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.2.2.3)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml (>= 3.2.5, < 4.0)
|
||||
rubocop-ast (>= 1.28.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 2.4.0, < 3.0)
|
||||
rubocop-ast (1.29.0)
|
||||
parser (>= 3.2.1.0)
|
||||
ruby-progressbar (1.13.0)
|
||||
ruby2_keywords (0.0.5)
|
||||
rufus-scheduler (3.9.1)
|
||||
fugit (~> 1.1, >= 1.1.6)
|
||||
sanitize (6.0.1)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.12.0)
|
||||
sentry-rails (5.9.0)
|
||||
railties (>= 5.0)
|
||||
rspec-core (3.10.0)
|
||||
rspec-support (~> 3.10.0)
|
||||
rspec-expectations (3.10.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.10.0)
|
||||
rspec-mocks (3.10.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.10.0)
|
||||
rspec-rails (4.0.1)
|
||||
actionpack (>= 4.2)
|
||||
activesupport (>= 4.2)
|
||||
railties (>= 4.2)
|
||||
rspec-core (~> 3.9)
|
||||
rspec-expectations (~> 3.9)
|
||||
rspec-mocks (~> 3.9)
|
||||
rspec-support (~> 3.9)
|
||||
rspec-support (3.10.0)
|
||||
sass-rails (6.0.0)
|
||||
sassc-rails (~> 2.1, >= 2.1.1)
|
||||
sassc (2.4.0)
|
||||
ffi (~> 1.9)
|
||||
sassc-rails (2.1.2)
|
||||
railties (>= 4.0.0)
|
||||
sassc (>= 2.0)
|
||||
sprockets (> 3.0)
|
||||
sprockets-rails
|
||||
tilt
|
||||
spring (2.1.1)
|
||||
spring-watcher-listen (2.0.1)
|
||||
listen (>= 2.7, < 4.0)
|
||||
spring (>= 1.2, < 3.0)
|
||||
sprockets (4.0.2)
|
||||
sentry-ruby (~> 5.9.0)
|
||||
sentry-ruby (5.9.0)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
sidekiq (6.5.9)
|
||||
connection_pool (>= 2.2.5, < 3)
|
||||
rack (~> 2.0)
|
||||
redis (>= 4.5.0, < 5)
|
||||
sidekiq-scheduler (5.0.3)
|
||||
rufus-scheduler (~> 3.2)
|
||||
sidekiq (>= 6, < 8)
|
||||
tilt (>= 1.4.0)
|
||||
solargraph (0.49.0)
|
||||
backport (~> 1.2)
|
||||
benchmark
|
||||
bundler (~> 2.0)
|
||||
diff-lcs (~> 1.4)
|
||||
e2mmap
|
||||
jaro_winkler (~> 1.5)
|
||||
kramdown (~> 2.3)
|
||||
kramdown-parser-gfm (~> 1.1)
|
||||
parser (~> 3.0)
|
||||
rbs (~> 2.0)
|
||||
reverse_markdown (~> 2.0)
|
||||
rubocop (~> 1.38)
|
||||
thor (~> 1.0)
|
||||
tilt (~> 2.0)
|
||||
yard (~> 0.9, >= 0.9.24)
|
||||
sprockets (4.2.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.2)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
rack (>= 2.2.4, < 4)
|
||||
sprockets-rails (3.4.2)
|
||||
actionpack (>= 5.2)
|
||||
activesupport (>= 5.2)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.4.2)
|
||||
thor (1.0.1)
|
||||
thread_safe (0.3.6)
|
||||
tilt (2.0.10)
|
||||
turbolinks (5.2.1)
|
||||
turbolinks-source (~> 5.2)
|
||||
turbolinks-source (5.2.0)
|
||||
tzinfo (1.2.7)
|
||||
thread_safe (~> 0.1)
|
||||
sqlite3 (1.6.3-x86_64-linux)
|
||||
stimulus-rails (1.2.1)
|
||||
railties (>= 6.0.0)
|
||||
thor (1.2.2)
|
||||
tilt (2.2.0)
|
||||
timeout (0.3.2)
|
||||
turbo-rails (1.4.0)
|
||||
actionpack (>= 6.0.0)
|
||||
activejob (>= 6.0.0)
|
||||
railties (>= 6.0.0)
|
||||
tzinfo (2.0.6)
|
||||
concurrent-ruby (~> 1.0)
|
||||
unicode-display_width (2.4.2)
|
||||
view_component (3.2.0)
|
||||
activesupport (>= 5.2.0, < 8.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
method_source (~> 1.0)
|
||||
warden (1.2.9)
|
||||
rack (>= 2.0.9)
|
||||
web-console (4.1.0)
|
||||
web-console (4.2.0)
|
||||
actionview (>= 6.0.0)
|
||||
activemodel (>= 6.0.0)
|
||||
bindex (>= 0.4.0)
|
||||
railties (>= 6.0.0)
|
||||
webpacker (4.3.0)
|
||||
activesupport (>= 4.2)
|
||||
rack-proxy (>= 0.6.1)
|
||||
railties (>= 4.2)
|
||||
websocket-driver (0.7.3)
|
||||
webmock (3.18.1)
|
||||
addressable (>= 2.8.0)
|
||||
crack (>= 0.3.2)
|
||||
hashdiff (>= 0.4.0, < 2.0.0)
|
||||
websocket-driver (0.7.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
xpath (3.2.0)
|
||||
nokogiri (~> 1.8)
|
||||
zeitwerk (2.4.1)
|
||||
yard (0.9.34)
|
||||
zeitwerk (2.6.8)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
bootsnap (>= 1.4.2)
|
||||
byebug
|
||||
byebug (~> 11.1)
|
||||
capybara
|
||||
cssbundling-rails
|
||||
database_cleaner
|
||||
devise
|
||||
devise (~> 4.9.0)
|
||||
devise_ldap_authenticatable
|
||||
discourse_api
|
||||
dotenv-rails
|
||||
factory_bot_rails
|
||||
faker
|
||||
faraday
|
||||
flipper
|
||||
flipper-active_record
|
||||
flipper-ui
|
||||
importmap-rails
|
||||
jbuilder (~> 2.7)
|
||||
letter_opener
|
||||
letter_opener_web
|
||||
listen (~> 3.2)
|
||||
lnurl
|
||||
lockbox
|
||||
net-ldap
|
||||
nostr!
|
||||
pagy (~> 6.0, >= 6.0.2)
|
||||
pg (~> 1.2.3)
|
||||
puma (~> 4.1)
|
||||
rails (~> 6.0.3, >= 6.0.3.4)
|
||||
rails (~> 7.0.2)
|
||||
rails-settings-cached (~> 2.8.3)
|
||||
rqrcode (~> 2.0)
|
||||
rspec-rails
|
||||
sass-rails (>= 6)
|
||||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
sentry-rails
|
||||
sentry-ruby
|
||||
sidekiq (< 7)
|
||||
sidekiq-scheduler
|
||||
solargraph
|
||||
sprockets-rails
|
||||
sqlite3 (~> 1.4)
|
||||
turbolinks (~> 5)
|
||||
stimulus-rails
|
||||
turbo-rails
|
||||
tzinfo-data
|
||||
view_component
|
||||
warden
|
||||
web-console (>= 3.3.0)
|
||||
webpacker (~> 4.0)
|
||||
webmock
|
||||
|
||||
BUNDLED WITH
|
||||
2.0.2
|
||||
2.3.7
|
||||
|
||||
2
Procfile.dev
Normal file
2
Procfile.dev
Normal file
@@ -0,0 +1,2 @@
|
||||
web: bin/rails server -b 0.0.0.0 -p 3000
|
||||
css: yarn build:css --watch
|
||||
110
README.md
110
README.md
@@ -1,27 +1,32 @@
|
||||
[](https://drone.kosmos.org/kosmos/akkounts)
|
||||
|
||||
# Akkounts
|
||||
|
||||
This app allows Kosmos/LDAP users to manage their accounts, including
|
||||
credentials, invites, donations, etc..
|
||||
|
||||
## Features
|
||||
|
||||
* [x] Log in with existing LDAP account
|
||||
* [x] Reset account password by providing both username and email address
|
||||
* [x] Reset account password when logged in, via reset email
|
||||
* [x] Log in with admin permissions
|
||||
* [x] View LDAP users as admin
|
||||
* [ ] List my donations
|
||||
* [ ] Invite new users from your account
|
||||
* [ ] Sign up for a new account via invite
|
||||
* [ ] Sign up for a new account by donating upfront
|
||||
* [ ] Sign up for a new account via proving contributions (via cryptographic signature)
|
||||
* [ ] ...
|
||||
|
||||
_Planned features are not at all a complete or static list, of course.
|
||||
Suggestions and pull requests welcome!_
|
||||
|
||||
## Development
|
||||
|
||||
### Quick Start
|
||||
|
||||
The easiest way to get a working development setup is using Docker Compose like
|
||||
so:
|
||||
|
||||
1. Make sure [Docker Compose is installed][1] and Docker is running (included in
|
||||
Docker Desktop)
|
||||
2. Uncomment the `redis`, `web`, and `sidekiq` sections in `docker-compose.yml`
|
||||
3. Run `docker compose up` and wait until 389ds announces its successful start
|
||||
in the log output
|
||||
4. `docker-compose exec ldap dsconf localhost backend create --suffix="dc=kosmos,dc=org" --be-name="dev"`
|
||||
5. `docker compose run web rails ldap:setup`
|
||||
6. `docker compose run web rails db:setup`
|
||||
|
||||
After these steps, you should have a working Rails app with a handful of test
|
||||
users running on [http://localhost:3000](http://localhost:3000).
|
||||
Log in with username "admin" and password "admin is admin". All users listed on
|
||||
[http://localhost:3000/admin/users](http://localhost:3000/admin/users)
|
||||
have the password "user is user".
|
||||
|
||||
### Rails app
|
||||
|
||||
Installing dependencies:
|
||||
@@ -34,23 +39,73 @@ Setting up local database (SQLite):
|
||||
bundle exec rails db:create
|
||||
bundle exec rails db:migrate
|
||||
|
||||
Running the dev server:
|
||||
Running the dev server and auto-building CSS files on change:
|
||||
|
||||
bundle exec rails server
|
||||
bin/dev
|
||||
|
||||
Running the background workers (requires Redis):
|
||||
|
||||
bundle exec sidekiq -C config/sidekiq.yml
|
||||
|
||||
Running all specs:
|
||||
|
||||
bundle exec rspec
|
||||
|
||||
### LDAP server
|
||||
### Docker (Compose)
|
||||
|
||||
TODO make it easy to run a local Kosmos LDAP server for development, without
|
||||
manual LDIF imports etc. (or provide a staging instance)
|
||||
There is a working Docker Compose config file, which allows you to spin up both
|
||||
an app server for Rails as well as a local 389ds (LDAP) server.
|
||||
|
||||
By default, `docker-compose up` will only start the LDAP server, listening on
|
||||
port 389 on your machine. Uncomment other services in `docker-compose.yml` if
|
||||
you want to use them.
|
||||
|
||||
#### LDAP server
|
||||
|
||||
After creating the Docker container for the first time (or after deleting it),
|
||||
you need to run the following command once, in order to create the dirsrv
|
||||
back-end:
|
||||
|
||||
docker-compose exec ldap dsconf localhost backend create --suffix="dc=kosmos,dc=org" --be-name="dev"
|
||||
|
||||
Now you can seed the back-end with data using this Rails task:
|
||||
|
||||
bundle exec rails ldap:setup
|
||||
|
||||
The setup task will first delete any existing entries in the directory tree
|
||||
("dc=kosmos,dc=org"), and then create our development entries.
|
||||
|
||||
Note that all 389ds data is stored in `tmp/389ds`. So if you want to start over
|
||||
with a fresh installation, delete both that directory as well as the container.
|
||||
|
||||
### Adding npm modules to use with Stimulus controllers
|
||||
|
||||
The following command downloads the specified npm module to `vendor/javascript`
|
||||
and adds an entry for it to `config/importmap.rb`.
|
||||
|
||||
bin/importmap pin bech32 --download
|
||||
|
||||
### Solargraph
|
||||
|
||||
[Solargraph](https://solargraph.org/) is a Ruby language server, which you may
|
||||
use with your editor to add features like auto-completion and syntax
|
||||
validation. You can add inline documentation for bundled gems with this
|
||||
command:
|
||||
|
||||
bundle exec yard gems
|
||||
|
||||
## Documentation
|
||||
|
||||
### Rails
|
||||
|
||||
* [Ruby on Rails](https://guides.rubyonrails.org/)
|
||||
* [Pagination](https://ddnexus.github.io/pagy/)
|
||||
|
||||
### Front-end
|
||||
|
||||
* [Tailwind CSS](https://tailwindcss.com/)
|
||||
* [Sass](https://sass-lang.com/documentation)
|
||||
* [Stimulus](https://stimulus.hotwired.dev/handbook/)
|
||||
|
||||
### Testing
|
||||
|
||||
@@ -62,6 +117,17 @@ manual LDIF imports etc. (or provide a staging instance)
|
||||
* [devise_ldap_authenticatable](https://github.com/cschiewek/devise_ldap_authenticatable)
|
||||
* [net/ldap](https://www.rubydoc.info/gems/net-ldap/Net/LDAP)
|
||||
|
||||
### Asynchronous jobs/workers
|
||||
|
||||
* [Sidekiq](https://github.com/mperham/sidekiq/wiki/)
|
||||
* [ActiveJob](https://github.com/mperham/sidekiq/wiki/Active-Job)
|
||||
|
||||
### Feature Flags
|
||||
|
||||
* [Flipper](https://www.flippercloud.io/docs/get-started/self-hosted)
|
||||
|
||||
## License
|
||||
|
||||
[GNU Affero General Public License v3.0](https://choosealicense.com/licenses/agpl-3.0/)
|
||||
|
||||
[1]: https://docs.docker.com/compose/install/
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
//= link_tree ../images
|
||||
//= link_directory ../stylesheets .css
|
||||
//= link_tree ../../javascript .js
|
||||
//= link_tree ../builds
|
||||
//= link_tree ../../../vendor/javascript .js
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
$breakpoints-max: (
|
||||
small: 600px,
|
||||
medium: 960px,
|
||||
large: 1280px
|
||||
);
|
||||
|
||||
$breakpoints-min: (
|
||||
small: 601px,
|
||||
medium: 961px,
|
||||
large: 1281px
|
||||
);
|
||||
|
||||
@mixin media-max($screen-size) {
|
||||
@if map-has-key($breakpoints-max, $screen-size) {
|
||||
@media (max-width: map-get($breakpoints-max, $screen-size)) {
|
||||
@content;
|
||||
}
|
||||
} @else {
|
||||
// Debugging
|
||||
@warn "'#{$screen-size}' has not been declared as a breakpoint."
|
||||
}
|
||||
}
|
||||
|
||||
@mixin media-min($screen-size) {
|
||||
@if map-has-key($breakpoints-min, $screen-size) {
|
||||
@media (min-width: map-get($breakpoints-min, $screen-size)) {
|
||||
@content;
|
||||
}
|
||||
} @else {
|
||||
// Debugging
|
||||
@warn "'#{$screen-size}' has not been declared as a breakpoint."
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
html, body, h1, h2, h3, h4, h5, h6, p, pre, a, dl, dt, dd, ol, ul, li {
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
background: transparent;
|
||||
box-sizing: border-box;
|
||||
overflow: visible;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||
* listed below.
|
||||
*
|
||||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
|
||||
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
||||
*
|
||||
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
||||
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
||||
* files in this directory. Styles in this file should be added after the last require_* statement.
|
||||
* It is generally better to create a new file per style scope.
|
||||
*
|
||||
*= require_tree .
|
||||
*= require_self
|
||||
*/
|
||||
12
app/assets/stylesheets/application.tailwind.css
Normal file
12
app/assets/stylesheets/application.tailwind.css
Normal file
@@ -0,0 +1,12 @@
|
||||
@import "tailwindcss/base";
|
||||
@import "tailwindcss/components";
|
||||
@import "tailwindcss/utilities";
|
||||
|
||||
@import "components/base";
|
||||
@import "components/buttons";
|
||||
@import "components/dashboard_services";
|
||||
@import "components/forms";
|
||||
@import "components/links";
|
||||
@import "components/notifications";
|
||||
@import "components/pagination";
|
||||
@import "components/tables";
|
||||
58
app/assets/stylesheets/components/base.css
Normal file
58
app/assets/stylesheets/components/base.css
Normal file
@@ -0,0 +1,58 @@
|
||||
@layer base {
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
body {
|
||||
@apply leading-none bg-cover bg-fixed;
|
||||
background-image: linear-gradient(35deg, rgba(255,0,255,0.2) 0, rgba(13,79,153,0.8) 100%), url('/img/bg-1.jpg');
|
||||
}
|
||||
|
||||
body#admin {
|
||||
background-image: linear-gradient(35deg, rgba(255,0,255,0.2) 0, rgba(153,12,14,0.9) 100%), url('/img/bg-1.jpg');
|
||||
}
|
||||
|
||||
h1 {
|
||||
@apply text-3xl uppercase;
|
||||
}
|
||||
|
||||
h2 {
|
||||
@apply text-2xl mb-8;
|
||||
}
|
||||
|
||||
h3 {
|
||||
@apply text-xl mb-6;
|
||||
}
|
||||
|
||||
h4 {
|
||||
@apply font-bold mb-4 leading-6;
|
||||
}
|
||||
|
||||
main section {
|
||||
@apply pt-8 sm:pt-12;
|
||||
}
|
||||
|
||||
main section:first-of-type {
|
||||
@apply pt-0;
|
||||
}
|
||||
|
||||
main p {
|
||||
@apply mb-4 leading-6;
|
||||
}
|
||||
|
||||
main p:last-child {
|
||||
@apply mb-0;
|
||||
}
|
||||
|
||||
main ul {
|
||||
@apply mb-6;
|
||||
}
|
||||
|
||||
main ul:last-child {
|
||||
@apply mb-0;
|
||||
}
|
||||
|
||||
main ul li {
|
||||
@apply leading-6;
|
||||
}
|
||||
}
|
||||
44
app/assets/stylesheets/components/buttons.css
Normal file
44
app/assets/stylesheets/components/buttons.css
Normal file
@@ -0,0 +1,44 @@
|
||||
@layer components {
|
||||
.btn {
|
||||
@apply inline-block font-semibold rounded-md leading-none cursor-pointer text-center
|
||||
transition-colors duration-75 focus:outline-none focus:ring-4;
|
||||
}
|
||||
|
||||
.btn-md {
|
||||
@apply btn;
|
||||
@apply py-3 px-6;
|
||||
}
|
||||
|
||||
.btn-sm {
|
||||
@apply btn;
|
||||
@apply py-1 px-2 text-sm;
|
||||
}
|
||||
|
||||
.btn-outline {
|
||||
@apply border-2 border-gray-100 hover:bg-gray-100;
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
@apply px-3;
|
||||
}
|
||||
|
||||
.btn-gray {
|
||||
@apply bg-gray-100 hover:bg-gray-200
|
||||
focus:ring-gray-300 focus:ring-opacity-75;
|
||||
}
|
||||
|
||||
.btn-blue {
|
||||
@apply bg-blue-500 hover:bg-blue-600 text-white
|
||||
focus:ring-blue-400 focus:ring-opacity-75;
|
||||
}
|
||||
|
||||
.btn-red {
|
||||
@apply bg-red-600 hover:bg-red-700 text-white
|
||||
focus:ring-red-500 focus:ring-opacity-75;
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
@apply bg-gray-100 hover:bg-gray-200 text-gray-400
|
||||
focus:ring-gray-300 focus:ring-opacity-75;
|
||||
}
|
||||
}
|
||||
5
app/assets/stylesheets/components/dashboard_services.css
Normal file
5
app/assets/stylesheets/components/dashboard_services.css
Normal file
@@ -0,0 +1,5 @@
|
||||
@layer components {
|
||||
.services > div > a {
|
||||
background-image: linear-gradient(110deg, rgba(255,255,255,0.99) 0, rgba(255,255,255,0.88) 100%);
|
||||
}
|
||||
}
|
||||
25
app/assets/stylesheets/components/forms.css
Normal file
25
app/assets/stylesheets/components/forms.css
Normal file
@@ -0,0 +1,25 @@
|
||||
@layer components {
|
||||
input[type=text], input[type=email], input[type=password],
|
||||
input[type=number], select, textarea {
|
||||
@apply rounded-md bg-gray-100 focus:bg-white
|
||||
border-transparent focus:border-transparent focus:ring-2
|
||||
focus:ring-blue-600 focus:ring-opacity-75;
|
||||
}
|
||||
|
||||
input[type=text]:disabled,
|
||||
input[type=email]:disabled {
|
||||
@apply text-gray-700;
|
||||
}
|
||||
|
||||
input.field_with_errors {
|
||||
@apply border-b-red-600;
|
||||
}
|
||||
|
||||
.field_with_errors {
|
||||
@apply inline-block;
|
||||
}
|
||||
|
||||
.error-msg {
|
||||
@apply text-red-700;
|
||||
}
|
||||
}
|
||||
8
app/assets/stylesheets/components/links.css
Normal file
8
app/assets/stylesheets/components/links.css
Normal file
@@ -0,0 +1,8 @@
|
||||
@layer components {
|
||||
.ks-text-link {
|
||||
@apply text-blue-600;
|
||||
&:hover { @apply underline; }
|
||||
&:visited { @apply text-indigo-600; }
|
||||
&:active { @apply text-red-600; }
|
||||
}
|
||||
}
|
||||
39
app/assets/stylesheets/components/notifications.css
Normal file
39
app/assets/stylesheets/components/notifications.css
Normal file
@@ -0,0 +1,39 @@
|
||||
@layer components {
|
||||
@keyframes notification-countdown {
|
||||
from { width: 100%; }
|
||||
to { width: 0; }
|
||||
}
|
||||
|
||||
.notification-enter {
|
||||
@apply transform ease-out duration-300 transition;
|
||||
}
|
||||
|
||||
.notification-enter-from {
|
||||
@apply translate-y-2 opacity-0;
|
||||
}
|
||||
|
||||
.notification-enter-to {
|
||||
@apply translate-y-0 opacity-100;
|
||||
}
|
||||
|
||||
@screen sm {
|
||||
.notification-enter-from {
|
||||
@apply translate-y-0 translate-x-2;
|
||||
}
|
||||
.notification-enter-to {
|
||||
@apply translate-x-0;
|
||||
}
|
||||
}
|
||||
|
||||
.notification-leave {
|
||||
@apply transition ease-in duration-100;
|
||||
}
|
||||
|
||||
.notification-leave-from {
|
||||
@apply opacity-100;
|
||||
}
|
||||
|
||||
.notification-leave-to {
|
||||
@apply opacity-0;
|
||||
}
|
||||
}
|
||||
45
app/assets/stylesheets/components/pagination.css
Normal file
45
app/assets/stylesheets/components/pagination.css
Normal file
@@ -0,0 +1,45 @@
|
||||
@layer components {
|
||||
.pagy-nav.pagination {
|
||||
@apply isolate inline-flex -space-x-px rounded-md shadow-sm;
|
||||
}
|
||||
|
||||
.pagy-nav .page:not(.prev):not(.next) {
|
||||
@apply hidden sm:inline-block;
|
||||
}
|
||||
|
||||
.pagy-nav .page.next a {
|
||||
@apply relative inline-flex items-center rounded-r-md border
|
||||
border-gray-300 bg-white px-3 py-2 text-sm font-medium
|
||||
text-gray-500 hover:bg-gray-100 focus:z-20;
|
||||
}
|
||||
|
||||
.pagy-nav .page.prev a {
|
||||
@apply relative inline-flex items-center rounded-l-md border
|
||||
border-gray-300 bg-white px-3 py-2 text-sm font-medium
|
||||
text-gray-500 hover:bg-gray-100 focus:z-20;
|
||||
}
|
||||
|
||||
.pagy-nav .page.next.disabled {
|
||||
@apply relative inline-flex items-center rounded-r-md border
|
||||
border-gray-300 bg-gray-100 px-3 py-2 text-sm font-medium
|
||||
text-gray-400 focus:z-20;
|
||||
}
|
||||
|
||||
.pagy-nav .page.prev.disabled {
|
||||
@apply relative inline-flex items-center rounded-l-md border
|
||||
border-gray-300 bg-gray-100 px-3 py-2 text-sm font-medium
|
||||
text-gray-400 focus:z-20;
|
||||
}
|
||||
|
||||
.pagy-nav .page a, .page.gap {
|
||||
@apply bg-white border-gray-300 text-gray-500 hover:bg-gray-100 relative
|
||||
inline-flex items-center border px-4 py-2 text-sm font-medium
|
||||
focus:z-20;
|
||||
}
|
||||
|
||||
.pagy-nav .page.active {
|
||||
@apply z-10 border-indigo-500 bg-indigo-50 text-indigo-600 relative
|
||||
inline-flex items-center border px-4 py-2 text-sm font-medium
|
||||
focus:z-20;
|
||||
}
|
||||
}
|
||||
36
app/assets/stylesheets/components/tables.css
Normal file
36
app/assets/stylesheets/components/tables.css
Normal file
@@ -0,0 +1,36 @@
|
||||
@layer components {
|
||||
table {
|
||||
@apply w-full;
|
||||
}
|
||||
|
||||
table thead tr {
|
||||
@apply text-left;
|
||||
}
|
||||
|
||||
table thead th {
|
||||
@apply pb-3.5 text-sm font-normal uppercase text-gray-500;
|
||||
}
|
||||
|
||||
table tbody th {
|
||||
@apply text-left font-normal text-gray-500;
|
||||
}
|
||||
|
||||
table th:not(:last-of-type),
|
||||
table td:not(:last-of-type) {
|
||||
@apply pr-2;
|
||||
}
|
||||
|
||||
table td, tbody th {
|
||||
@apply py-2;
|
||||
}
|
||||
|
||||
table.divided {
|
||||
@apply divide-y divide-gray-300;
|
||||
}
|
||||
table.divided tbody {
|
||||
@apply divide-y divide-gray-200;
|
||||
}
|
||||
table.divided td, table.divided tbody th {
|
||||
@apply py-3;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
@font-face {
|
||||
font-family: 'Raleway';
|
||||
src: url('/fonts/raleway-light.woff') format('woff2');
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Open Sans", Helvetica, Arial, sans-serif;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
font-family: Raleway, inherit;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
@import "mediaqueries";
|
||||
|
||||
$content-width: 800px;
|
||||
$content-max-width: 100%;
|
||||
|
||||
body {
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
|
||||
> header {
|
||||
margin: 0 auto;
|
||||
padding: 4rem 0;
|
||||
text-align: center;
|
||||
background: #0d4f99;
|
||||
background: linear-gradient(35deg, #8955a0 0, #0d4f99 100%);
|
||||
|
||||
@include media-max(small) {
|
||||
padding: 3rem 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.8rem;
|
||||
color: #fff;
|
||||
|
||||
span.project-name {
|
||||
display: none;
|
||||
// font-size: .5em;
|
||||
// text-transform: none;
|
||||
// vertical-align: super;
|
||||
}
|
||||
|
||||
span.beta {
|
||||
font-size: .5em;
|
||||
font-style: italic;
|
||||
text-transform: none;
|
||||
vertical-align: super;
|
||||
}
|
||||
|
||||
span.bolt {
|
||||
color: #ffd000;
|
||||
}
|
||||
}
|
||||
|
||||
p.current-user {
|
||||
margin-top: 2rem;
|
||||
color: rgba(255,255,255,0.6);
|
||||
|
||||
@include media-max(small) {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: 400;
|
||||
color: #fff;
|
||||
// color: #ffd000;
|
||||
// color: #ccff40;
|
||||
}
|
||||
}
|
||||
|
||||
a {
|
||||
color: rgba(255,255,255,0.6);
|
||||
transition: color 0.1s linear;
|
||||
|
||||
&:hover, &:active {
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.flash-msg {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
padding: 2rem 0;
|
||||
|
||||
&.notice {
|
||||
background: #efffc4;
|
||||
}
|
||||
|
||||
&.alert {
|
||||
background: #fff4c2;
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
width: $content-width;
|
||||
max-width: $content-max-width;
|
||||
margin: 4rem auto;
|
||||
text-align: left;
|
||||
|
||||
@include media-max(medium) {
|
||||
max-width: 90%;
|
||||
}
|
||||
|
||||
@include media-max(small) {
|
||||
margin: 3rem auto;
|
||||
}
|
||||
|
||||
h2, h3 {
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
p {
|
||||
line-height: 1.5rem;
|
||||
margin-bottom: 1rem;
|
||||
|
||||
&.notice {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
margin-bottom: 1.5rem;
|
||||
|
||||
li {
|
||||
line-height: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
th, td {
|
||||
line-height: 1.5rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
|
||||
section {
|
||||
border-bottom: 1px dotted #ccc;
|
||||
padding-bottom: 4rem;
|
||||
margin-bottom: 4rem;
|
||||
|
||||
@include media-max(small) {
|
||||
padding-bottom: 3rem;
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
|
||||
&.services {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
grid-row-gap: 1rem;
|
||||
grid-column-gap: 2rem;
|
||||
|
||||
@include media-max(small) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
margin-top: 3rem;
|
||||
|
||||
h3 {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.grid-item {
|
||||
p {
|
||||
color: #888;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/components/form_elements/fieldset_component.html.erb
Normal file
29
app/components/form_elements/fieldset_component.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<%= tag.public_send(@tag, class: "mb-6 last:mb-0") do %>
|
||||
<% if @positioning == :vertical %>
|
||||
<label class="block">
|
||||
<p class="font-bold <%= @descripton.present? ? "mb-1" : "mb-2" %>">
|
||||
<%= @title %>
|
||||
</p>
|
||||
<% if @descripton.present? %>
|
||||
<p class="text-gray-500">
|
||||
<%= @descripton %>
|
||||
</p>
|
||||
<% end %>
|
||||
<%= content %>
|
||||
</label>
|
||||
<% elsif @positioning == :horizontal %>
|
||||
<label class="block flex items-center justify-between">
|
||||
<div class="flex flex-col">
|
||||
<label class="font-bold mb-1"><%= @title %></label>
|
||||
<% if @descripton.present? %>
|
||||
<p class="text-gray-500"><%= @descripton %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="relative ml-4 inline-flex flex-shrink-0">
|
||||
<%= content %>
|
||||
</div>
|
||||
</label>
|
||||
<% else %>
|
||||
<p>Invalid <code>positioning<code> argument for <code>FieldsetComponent</code>.</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
12
app/components/form_elements/fieldset_component.rb
Normal file
12
app/components/form_elements/fieldset_component.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module FormElements
|
||||
class FieldsetComponent < ViewComponent::Base
|
||||
def initialize(tag: "li", positioning: :vertical, title:, description: nil)
|
||||
@tag = tag
|
||||
@positioning = positioning
|
||||
@title = title
|
||||
@descripton = description
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,33 @@
|
||||
<%= tag.public_send @tag, class: "flex items-center justify-between mb-6 last:mb-0",
|
||||
data: @form_enabled ? {
|
||||
controller: "settings--toggle",
|
||||
:'settings--toggle-switch-enabled-value' => @enabled.to_s
|
||||
} : nil do %>
|
||||
<div class="flex flex-col">
|
||||
<label class="font-bold mb-1"><%= @title %></label>
|
||||
<p class="text-gray-500"><%= @descripton %></p>
|
||||
</div>
|
||||
<div class="relative ml-4 inline-flex flex-shrink-0">
|
||||
<%= render FormElements::ToggleComponent.new(
|
||||
enabled: @enabled,
|
||||
input_enabled: @input_enabled,
|
||||
class_names: @form_enabled ? "hidden" : nil,
|
||||
data: {
|
||||
:'settings--toggle-target' => "button",
|
||||
action: "settings--toggle#toggleSwitch"
|
||||
}) %>
|
||||
<% if @form_enabled %>
|
||||
<% if @attribute.present? %>
|
||||
<%= @form.check_box @attribute, {
|
||||
checked: @enabled,
|
||||
data: { :'settings--toggle-target' => "checkbox" }
|
||||
}, "true", "false" %>
|
||||
<% else %>
|
||||
<input name="<%= @field_name %>" type="hidden" value="false" autocomplete="off">
|
||||
<%= check_box_tag @field_name, "true", @enabled, {
|
||||
data: { :'settings--toggle-target' => "checkbox" }
|
||||
} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
19
app/components/form_elements/fieldset_toggle_component.rb
Normal file
19
app/components/form_elements/fieldset_toggle_component.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module FormElements
|
||||
class FieldsetToggleComponent < ViewComponent::Base
|
||||
def initialize(tag: "li", form: nil, attribute: nil, field_name: nil,
|
||||
enabled: false, input_enabled: true, title:, description:)
|
||||
@tag = tag
|
||||
@form = form
|
||||
@attribute = attribute
|
||||
@field_name = field_name
|
||||
@form_enabled = @form.present? || @field_name.present?
|
||||
@enabled = enabled
|
||||
@input_enabled = input_enabled
|
||||
@title = title
|
||||
@descripton = description
|
||||
@button_text = @enabled ? "Switch off" : "Switch on"
|
||||
end
|
||||
end
|
||||
end
|
||||
15
app/components/form_elements/toggle_component.html.erb
Normal file
15
app/components/form_elements/toggle_component.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<%= button_tag type: "button", name: "toggle", data: @data,
|
||||
role: "switch", aria: { checked: @enabled.to_s },
|
||||
tabindex: @tabindex, disabled: !@input_enabled,
|
||||
class: "#{ @enabled ? 'bg-blue-600' : 'bg-gray-200' }
|
||||
#{ @class_names.present? ? @class_names : '' }
|
||||
relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer
|
||||
rounded-full border-2 border-transparent transition-colors
|
||||
duration-200 ease-in-out focus:outline-none focus:ring-2
|
||||
focus:ring-blue-600 focus:ring-offset-2" do %>
|
||||
<span class="sr-only"><%= @button_text %></span>
|
||||
<span aria-hidden="true" data-settings--toggle-target="switch"
|
||||
class="<%= @enabled ? 'translate-x-5' : 'translate-x-0' %>
|
||||
pointer-events-none inline-block h-5 w-5 transform rounded-full
|
||||
bg-white shadow ring-0 transition duration-200 ease-in-out"></span>
|
||||
<% end %>
|
||||
13
app/components/form_elements/toggle_component.rb
Normal file
13
app/components/form_elements/toggle_component.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module FormElements
|
||||
class ToggleComponent < ViewComponent::Base
|
||||
def initialize(enabled:, input_enabled: true, data: nil, class_names: nil, tabindex: nil)
|
||||
@enabled = !!enabled
|
||||
@input_enabled = input_enabled
|
||||
@data = data
|
||||
@class_names = class_names
|
||||
@tabindex = tabindex
|
||||
end
|
||||
end
|
||||
end
|
||||
7
app/components/header_compact_component.html.erb
Normal file
7
app/components/header_compact_component.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<header class="py-10">
|
||||
<div class="max-w-xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<h1 class="text-3xl font-bold text-white text-center">
|
||||
<%= @title %>
|
||||
</h1>
|
||||
</div>
|
||||
</header>
|
||||
7
app/components/header_compact_component.rb
Normal file
7
app/components/header_compact_component.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class HeaderCompactComponent < ViewComponent::Base
|
||||
def initialize(title:)
|
||||
@title = title
|
||||
end
|
||||
end
|
||||
7
app/components/header_component.html.erb
Normal file
7
app/components/header_component.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<header class="py-10">
|
||||
<div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<h1 class="text-3xl font-bold text-white">
|
||||
<%= @title %>
|
||||
</h1>
|
||||
</div>
|
||||
</header>
|
||||
7
app/components/header_component.rb
Normal file
7
app/components/header_component.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class HeaderComponent < ViewComponent::Base
|
||||
def initialize(title:)
|
||||
@title = title
|
||||
end
|
||||
end
|
||||
5
app/components/main_compact_component.html.erb
Normal file
5
app/components/main_compact_component.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<main class="w-full max-w-xl mx-auto pb-12 px-4 sm:px-6 lg:px-8">
|
||||
<div class="bg-white rounded-lg shadow px-6 sm:px-12 py-8 sm:py-12">
|
||||
<%= content %>
|
||||
</div>
|
||||
</main>
|
||||
5
app/components/main_compact_component.rb
Normal file
5
app/components/main_compact_component.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MainCompactComponent < ViewComponent::Base
|
||||
|
||||
end
|
||||
5
app/components/main_simple_component.html.erb
Normal file
5
app/components/main_simple_component.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<main class="w-full max-w-6xl mx-auto pb-12 px-4 md:px-6 lg:px-8">
|
||||
<div class="md:min-h-[50vh] bg-white rounded-lg shadow px-6 sm:px-12 py-8 sm:py-12">
|
||||
<%= content %>
|
||||
</div>
|
||||
</main>
|
||||
5
app/components/main_simple_component.rb
Normal file
5
app/components/main_simple_component.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MainSimpleComponent < ViewComponent::Base
|
||||
|
||||
end
|
||||
15
app/components/main_with_sidenav_component.html.erb
Normal file
15
app/components/main_with_sidenav_component.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<main class="w-full max-w-6xl mx-auto pb-12 px-4 md:px-6 lg:px-8">
|
||||
<div class="bg-white rounded-lg shadow">
|
||||
<div class="md:min-h-[50vh] divide-y divide-gray-200 lg:grid lg:grid-cols-12 lg:divide-y-0 lg:divide-x">
|
||||
<aside class="py-6 sm:py-8 lg:col-span-3">
|
||||
<nav class="space-y-1">
|
||||
<%= render partial: @sidenav_partial %>
|
||||
</nav>
|
||||
</aside>
|
||||
<div class="lg:col-span-9 px-6 sm:px-12 py-8 sm:pt-10 sm:pb-12">
|
||||
<%= content %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
7
app/components/main_with_sidenav_component.rb
Normal file
7
app/components/main_with_sidenav_component.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MainWithSidenavComponent < ViewComponent::Base
|
||||
def initialize(sidenav_partial:)
|
||||
@sidenav_partial = sidenav_partial
|
||||
end
|
||||
end
|
||||
10
app/components/main_with_tabnav_component.html.erb
Normal file
10
app/components/main_with_tabnav_component.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<main class="w-full max-w-6xl mx-auto pb-12 px-4 md:px-6 lg:px-8">
|
||||
<div class="bg-white rounded-lg shadow">
|
||||
<div class="px-6 sm:px-12 pt-2 sm:pt-4">
|
||||
<%= render partial: @tabnav_partial %>
|
||||
</div>
|
||||
<div class="px-6 sm:px-12 py-8 sm:py-12">
|
||||
<%= content %>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
7
app/components/main_with_tabnav_component.rb
Normal file
7
app/components/main_with_tabnav_component.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MainWithTabnavComponent < ViewComponent::Base
|
||||
def initialize(tabnav_partial:)
|
||||
@tabnav_partial = tabnav_partial
|
||||
end
|
||||
end
|
||||
49
app/components/notification_component.html.erb
Normal file
49
app/components/notification_component.html.erb
Normal file
@@ -0,0 +1,49 @@
|
||||
<div class="flash-msg <%= @type %> hidden max-w-sm w-full bg-white shadow-lg rounded-lg pointer-events-auto mt-4"
|
||||
data-turbo="false"
|
||||
data-notification-action-url="<%= @data.dig(:action, :url) %>"
|
||||
data-notification-action-method="<%= @data.dig(:action, :method) %>"
|
||||
data-notification-timeout="<%= @data[:timeout] %>"
|
||||
data-controller="notification">
|
||||
<div class="rounded-lg shadow-xs overflow-hidden">
|
||||
<div class="p-4">
|
||||
<div class="flex items-start">
|
||||
<div class="flex-shrink-0">
|
||||
<span class="inline-block h-6 w-6 <%= @icon_color_class %>">
|
||||
<%= render "icons/#{@icon_name}" %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="ml-3 w-0 flex-1 pt-0.5">
|
||||
<p class="text-sm leading-5 font-medium text-gray-900">
|
||||
<%= @data[:title] %>
|
||||
</p>
|
||||
<% if @data[:body].present? %>
|
||||
<p class="mt-1 text-sm leading-5 text-gray-500">
|
||||
<%= @data[:body] %>
|
||||
</p>
|
||||
<% end %>
|
||||
<% if @data[:action].present? %>
|
||||
<div class="mt-2" data-notification-target="buttons">
|
||||
<a data-turbo-frame="_top" <% if @data.dig(:action, :method) == 'get' %> href="<%= @data.dig(:action, :url) %>" <% else %> href="#" data-action="notification#run" <% end %> class="text-sm leading-5 font-medium text-indigo-600 hover:text-indigo-500 focus:outline-none focus:underline transition ease-in-out duration-150">
|
||||
<%= @data.dig(:action, :name) %>
|
||||
</a>
|
||||
<button data-action="notification#close" class="ml-6 text-sm leading-5 font-medium text-gray-700 hover:text-gray-500 focus:outline-none focus:underline transition ease-in-out duration-150">
|
||||
<%= t('.dismiss') %>
|
||||
</button>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="ml-4 flex-shrink-0 flex">
|
||||
<button class="inline-flex text-gray-400 focus:outline-none focus:text-gray-500 transition ease-in-out duration-150" data-action="notification#close">
|
||||
<!-- Heroicon name: solid/x -->
|
||||
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
||||
<path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% if @data[:countdown] %>
|
||||
<div class="bg-indigo-600 rounded-lg h-1 w-0" data-notification-target="countdown"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
54
app/components/notification_component.rb
Normal file
54
app/components/notification_component.rb
Normal file
@@ -0,0 +1,54 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# @param type [String] Classic notification type `error`, `alert` and `info` + custom `success`
|
||||
# @param data [String, Hash] `String` for backward compatibility,
|
||||
# `Hash` for the new functionality `{title: '', body: '', timeout: 5, countdown: false, action: { url: '', method: '', name: ''}}`.
|
||||
# The `title` attribute for `Hash` is mandatory.
|
||||
class NotificationComponent < ViewComponent::Base
|
||||
def initialize(type:, data:)
|
||||
@type = type
|
||||
@data = prepare_data(data)
|
||||
@icon_name = icon_name
|
||||
@icon_color_class = icon_color_class
|
||||
|
||||
@data[:timeout] ||= 5
|
||||
@data[:action][:method] ||= "get" if @data[:action]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def prepare_data(data)
|
||||
case data
|
||||
when Hash
|
||||
data
|
||||
else
|
||||
{ title: data }
|
||||
end
|
||||
end
|
||||
|
||||
def icon_name
|
||||
case @type
|
||||
when 'success'
|
||||
'check-circle'
|
||||
when 'error'
|
||||
'alert-octagon'
|
||||
when 'alert'
|
||||
'alert-octagon'
|
||||
else
|
||||
'info'
|
||||
end
|
||||
end
|
||||
|
||||
def icon_color_class
|
||||
case @type
|
||||
when 'success'
|
||||
'text-emerald-500'
|
||||
when 'error'
|
||||
'text-rose-600'
|
||||
when 'alert'
|
||||
'text-rose-600'
|
||||
else
|
||||
'text-gray-400'
|
||||
end
|
||||
end
|
||||
end
|
||||
3
app/components/quickstats_container_component.html.erb
Normal file
3
app/components/quickstats_container_component.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<dl class="grid grid-cols-2 lg:grid-cols-4 gap-6 sm:gap-12">
|
||||
<%= content %>
|
||||
</dl>
|
||||
4
app/components/quickstats_container_component.rb
Normal file
4
app/components/quickstats_container_component.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class QuickstatsContainerComponent < ViewComponent::Base
|
||||
end
|
||||
18
app/components/quickstats_item_component.html.erb
Normal file
18
app/components/quickstats_item_component.html.erb
Normal file
@@ -0,0 +1,18 @@
|
||||
<div class="">
|
||||
<dt class="mb-2 text-gray-500">
|
||||
<%= @title %>
|
||||
</dt>
|
||||
<dd>
|
||||
<% if @type == :number %>
|
||||
<span class="text-2xl"><%= number_with_delimiter @value %></span>
|
||||
<% else %>
|
||||
<span class="text-2xl"><%= @value %></span>
|
||||
<% end %>
|
||||
<% if @unit %>
|
||||
<span><%= @unit %></span>
|
||||
<% end %>
|
||||
<% if @meta %>
|
||||
<span class="text-gray-500"><%= @meta %></span>
|
||||
<% end %>
|
||||
</dd>
|
||||
</div>
|
||||
13
app/components/quickstats_item_component.rb
Normal file
13
app/components/quickstats_item_component.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class QuickstatsItemComponent < ViewComponent::Base
|
||||
def initialize(type:, title:, value:, unit: nil, meta: nil, icon_name: nil, icon_color_class: nil)
|
||||
@type = type
|
||||
@title = title
|
||||
@value = value
|
||||
@unit = unit
|
||||
@meta = meta
|
||||
@icon_name = icon_name
|
||||
@icon_color_class = icon_color_class
|
||||
end
|
||||
end
|
||||
4
app/components/sidenav_link_component.html.erb
Normal file
4
app/components/sidenav_link_component.html.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<%= link_to @path, class: @link_class, title: (@disabled ? "Coming soon" : nil) do %>
|
||||
<%= render partial: "icons/#{@icon}", locals: { custom_class: @icon_class } %>
|
||||
<span class="truncate"><%= @name %></span>
|
||||
<% end %>
|
||||
37
app/components/sidenav_link_component.rb
Normal file
37
app/components/sidenav_link_component.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SidenavLinkComponent < ViewComponent::Base
|
||||
def initialize(name:, level: 1, path:, icon:, active: false, disabled: false)
|
||||
@name = name
|
||||
@level = level
|
||||
@path = path
|
||||
@icon = icon
|
||||
@active = active
|
||||
@disabled = disabled
|
||||
@link_class = class_names_link(path)
|
||||
@icon_class = class_names_icon(path)
|
||||
end
|
||||
|
||||
def class_names_link(path)
|
||||
px = @level == 1 ? "px-4" : "pl-8 pr-4"
|
||||
base = "#{px} py-2 group border-l-4 flex items-center text-base font-medium"
|
||||
|
||||
if @active
|
||||
"#{base} bg-teal-50 border-teal-500 text-teal-700 hover:bg-teal-50 hover:text-teal-700"
|
||||
elsif @disabled
|
||||
"#{base} border-transparent text-gray-400 hover:bg-gray-50"
|
||||
else
|
||||
"#{base} border-transparent text-gray-900 hover:bg-gray-50 hover:text-gray-900"
|
||||
end
|
||||
end
|
||||
|
||||
def class_names_icon(path)
|
||||
if @active
|
||||
"text-teal-500 group-hover:text-teal-500 flex-shrink-0 -ml-1 mr-3 h-6 w-6"
|
||||
elsif @disabled
|
||||
"text-gray-300 group-hover:text-gray-300 flex-shrink-0 -ml-1 mr-3 h-6 w-6"
|
||||
else
|
||||
"text-gray-400 group-hover:text-gray-500 flex-shrink-0 -ml-1 mr-3 h-6 w-6"
|
||||
end
|
||||
end
|
||||
end
|
||||
3
app/components/tabnav_link_component.html.erb
Normal file
3
app/components/tabnav_link_component.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<%= link_to @path, class: @link_class do %>
|
||||
<%= @name %>
|
||||
<% end %>
|
||||
21
app/components/tabnav_link_component.rb
Normal file
21
app/components/tabnav_link_component.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TabnavLinkComponent < ViewComponent::Base
|
||||
def initialize(name:, path:, active: false, disabled: false)
|
||||
@name = name
|
||||
@path = path
|
||||
@active = active
|
||||
@disabled = disabled
|
||||
@link_class = class_names_link(path)
|
||||
end
|
||||
|
||||
def class_names_link(path)
|
||||
if @active
|
||||
"border-indigo-500 text-indigo-600 w-1/2 py-4 px-1 text-center border-b-2"
|
||||
elsif @disabled
|
||||
"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 w-1/2 py-4 px-1 text-center border-b-2"
|
||||
else
|
||||
"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 w-1/2 py-4 px-1 text-center border-b-2"
|
||||
end
|
||||
end
|
||||
end
|
||||
22
app/components/wallet_summary_component.html.erb
Normal file
22
app/components/wallet_summary_component.html.erb
Normal file
@@ -0,0 +1,22 @@
|
||||
<section class="w-full grid grid-cols-1 md:grid-cols-12 md:mb-0">
|
||||
<div class="md:col-span-8">
|
||||
<p>
|
||||
Send and receive sats via the Bitcoin Lightning Network.
|
||||
</p>
|
||||
</div>
|
||||
<div class="md:col-span-4 mt-4 md:mt-0">
|
||||
<p class="font-mono md:text-right mb-0 p-4 border border-gray-300 rounded-lg overflow-hidden">
|
||||
<% if @balance %>
|
||||
<span class="text-2xl"><%= number_with_delimiter @balance %></span>
|
||||
<span class="text-xl">sats</span>
|
||||
<br>
|
||||
<span class="text-sm text-gray-500">Available balance</span>
|
||||
<% else %>
|
||||
<span class="text-2xl">n/a</span>
|
||||
<span class="text-xl">sats</span>
|
||||
<br>
|
||||
<span class="text-sm text-gray-500">Balance unavailable</span>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
8
app/components/wallet_summary_component.rb
Normal file
8
app/components/wallet_summary_component.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WalletSummaryComponent < ViewComponent::Base
|
||||
def initialize(balance:)
|
||||
@balance = balance
|
||||
end
|
||||
|
||||
end
|
||||
7
app/controllers/account_controller.rb
Normal file
7
app/controllers/account_controller.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class AccountController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
def index
|
||||
@current_section = :account
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,11 @@
|
||||
class Admin::BaseController < ApplicationController
|
||||
include Pagy::Backend
|
||||
|
||||
before_action :authenticate_user!
|
||||
before_action :authorize_admin
|
||||
before_action :set_context
|
||||
|
||||
def set_context
|
||||
@context = :admin
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admin::DashboardController < Admin::BaseController
|
||||
def index
|
||||
@current_section = :dashboard
|
||||
end
|
||||
end
|
||||
|
||||
95
app/controllers/admin/donations_controller.rb
Normal file
95
app/controllers/admin/donations_controller.rb
Normal file
@@ -0,0 +1,95 @@
|
||||
class Admin::DonationsController < Admin::BaseController
|
||||
before_action :set_donation, only: [:show, :edit, :update, :destroy]
|
||||
before_action :set_current_section, only: [:index, :show, :new, :edit]
|
||||
|
||||
# GET /donations
|
||||
# GET /donations.json
|
||||
def index
|
||||
@pagy, @donations = pagy(Donation.all.order('created_at desc'))
|
||||
|
||||
@stats = {
|
||||
overall_sats: @donations.all.sum("amount_sats"),
|
||||
donor_count: Donation.distinct.count(:user_id)
|
||||
}
|
||||
end
|
||||
|
||||
# GET /donations/1
|
||||
# GET /donations/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /donations/new
|
||||
def new
|
||||
@donation = Donation.new
|
||||
end
|
||||
|
||||
# GET /donations/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /donations
|
||||
# POST /donations.json
|
||||
def create
|
||||
@donation = Donation.new(donation_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @donation.save
|
||||
format.html do
|
||||
redirect_to admin_donation_url(@donation), flash: {
|
||||
success: 'Donation was successfully created.'
|
||||
}
|
||||
end
|
||||
format.json { render :show, status: :created, location: @donation }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @donation.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /donations/1
|
||||
# PATCH/PUT /donations/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @donation.update(donation_params)
|
||||
format.html do
|
||||
redirect_to admin_donation_url(@donation), flash: {
|
||||
success: 'Donation was successfully updated.'
|
||||
}
|
||||
end
|
||||
format.json { render :show, status: :ok, location: @donation }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @donation.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /donations/1
|
||||
# DELETE /donations/1.json
|
||||
def destroy
|
||||
@donation.destroy
|
||||
respond_to do |format|
|
||||
format.html do redirect_to admin_donations_url, flash: {
|
||||
success: 'Donation was successfully destroyed.'
|
||||
}
|
||||
end
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_donation
|
||||
@donation = Donation.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def donation_params
|
||||
params.require(:donation).permit(:user_id, :amount_sats, :amount_eur, :amount_usd, :public_name, :paid_at)
|
||||
end
|
||||
|
||||
def set_current_section
|
||||
@current_section = :donations
|
||||
end
|
||||
end
|
||||
12
app/controllers/admin/invitations_controller.rb
Normal file
12
app/controllers/admin/invitations_controller.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class Admin::InvitationsController < Admin::BaseController
|
||||
def index
|
||||
@current_section = :invitations
|
||||
@pagy, @invitations_used = pagy(Invitation.used.order('used_at desc'))
|
||||
|
||||
@stats = {
|
||||
available: Invitation.unused.count,
|
||||
accepted: @invitations_used.length,
|
||||
users_with_referrals: Invitation.used.distinct.count(:user_id)
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -1,41 +0,0 @@
|
||||
class Admin::LdapUsersController < Admin::BaseController
|
||||
def index
|
||||
attributes = %w{dn cn uid mail admin}
|
||||
filter = Net::LDAP::Filter.eq("uid", "*")
|
||||
if params[:ou]
|
||||
treebase = "ou=#{params[:ou]},cn=users,dc=kosmos,dc=org"
|
||||
else
|
||||
treebase = "ou=kosmos.org,cn=users,dc=kosmos,dc=org"
|
||||
end
|
||||
|
||||
entries = ldap_client.search(base: treebase, filter: filter, attributes: attributes)
|
||||
entries.sort_by! { |e| e.cn[0] }
|
||||
|
||||
@entries = entries.collect do |e|
|
||||
{
|
||||
uid: e.uid.first,
|
||||
mail: e.try(:mail) ? e.mail.first : nil,
|
||||
admin: e.try(:admin) ? 'admin' : nil
|
||||
# password: e.userpassword.first
|
||||
}
|
||||
end
|
||||
# ldap_client.get_operation_result
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ldap_client
|
||||
ldap_client ||= Net::LDAP.new host: ldap_config['host'],
|
||||
port: ldap_config['port'],
|
||||
encryption: ldap_config['ssl'],
|
||||
auth: {
|
||||
method: :simple,
|
||||
username: ldap_config['admin_user'],
|
||||
password: ldap_config['admin_password']
|
||||
}
|
||||
end
|
||||
|
||||
def ldap_config
|
||||
ldap_config ||= YAML.load(ERB.new(File.read("#{Rails.root}/config/ldap.yml")).result)[Rails.env]
|
||||
end
|
||||
end
|
||||
21
app/controllers/admin/lightning_controller.rb
Normal file
21
app/controllers/admin/lightning_controller.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
class Admin::LightningController < Admin::BaseController
|
||||
before_action :check_feature_enabled
|
||||
|
||||
def index
|
||||
@current_section = :lightning
|
||||
|
||||
@users = User.pluck(:cn, :ou, :ln_account)
|
||||
@accounts = LndhubAccount.with_balances.order(balance: :desc).to_a
|
||||
|
||||
@ln = {}
|
||||
@ln[:current_balance] = LndhubAccount.current.joins(:ledgers).sum("account_ledgers.amount")
|
||||
@ln[:users_with_sats] = @accounts.length
|
||||
end
|
||||
|
||||
def check_feature_enabled
|
||||
if !Setting.lndhub_admin_enabled?
|
||||
flash[:alert] = "Lightning Admin UI not enabled"
|
||||
redirect_to admin_root_path and return
|
||||
end
|
||||
end
|
||||
end
|
||||
12
app/controllers/admin/settings/registrations_controller.rb
Normal file
12
app/controllers/admin/settings/registrations_controller.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class Admin::Settings::RegistrationsController < Admin::SettingsController
|
||||
def index
|
||||
end
|
||||
|
||||
def create
|
||||
update_settings
|
||||
|
||||
redirect_to admin_settings_registrations_path, flash: {
|
||||
success: "Settings saved"
|
||||
}
|
||||
end
|
||||
end
|
||||
19
app/controllers/admin/settings/services_controller.rb
Normal file
19
app/controllers/admin/settings/services_controller.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
class Admin::Settings::ServicesController < Admin::SettingsController
|
||||
def index
|
||||
@service = params[:s]
|
||||
|
||||
if @service.blank?
|
||||
redirect_to admin_settings_services_path(params: { s: "discourse" })
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
service = params.require(:service)
|
||||
|
||||
update_settings
|
||||
|
||||
redirect_to admin_settings_services_path(params: { s: service }), flash: {
|
||||
success: "Settings saved"
|
||||
}
|
||||
end
|
||||
end
|
||||
40
app/controllers/admin/settings_controller.rb
Normal file
40
app/controllers/admin/settings_controller.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
class Admin::SettingsController < Admin::BaseController
|
||||
before_action :set_current_section
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def update_settings
|
||||
@errors = ActiveModel::Errors.new(Setting.new)
|
||||
changed_keys = []
|
||||
|
||||
setting_params.keys.each do |key|
|
||||
next if setting_params[key].nil? ||
|
||||
(Setting.send(key).to_s == setting_params[key].strip)
|
||||
changed_keys.push(key)
|
||||
setting = Setting.new(var: key)
|
||||
setting.value = setting_params[key].strip
|
||||
unless setting.valid?
|
||||
@errors.merge!(setting.errors)
|
||||
end
|
||||
end
|
||||
|
||||
if @errors.any?
|
||||
render :index and return
|
||||
end
|
||||
|
||||
changed_keys.each do |key|
|
||||
Setting.send("#{key}=", setting_params[key].strip)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_current_section
|
||||
@current_section = :settings
|
||||
end
|
||||
|
||||
def setting_params
|
||||
params.require(:setting).permit(Setting.editable_keys.map(&:to_sym))
|
||||
end
|
||||
end
|
||||
35
app/controllers/admin/users_controller.rb
Normal file
35
app/controllers/admin/users_controller.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
class Admin::UsersController < Admin::BaseController
|
||||
before_action :set_user, only: [:show]
|
||||
before_action :set_current_section
|
||||
|
||||
def index
|
||||
ldap = LdapService.new
|
||||
@ou = params[:ou] || Setting.primary_domain
|
||||
@orgs = ldap.fetch_organizations
|
||||
@pagy, @users = pagy(User.where(ou: @ou).order(cn: :asc))
|
||||
|
||||
@stats = {
|
||||
users_confirmed: User.where(ou: @ou).confirmed.count,
|
||||
users_pending: User.where(ou: @ou).pending.count
|
||||
}
|
||||
end
|
||||
|
||||
def show
|
||||
if Setting.lndhub_admin_enabled?
|
||||
@lndhub_user = @user.lndhub_user
|
||||
end
|
||||
|
||||
@services_enabled = @user.services_enabled
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_user
|
||||
address = params[:address].split("@")
|
||||
@user = User.where(cn: address.first, ou: address.last).first
|
||||
end
|
||||
|
||||
def set_current_section
|
||||
@current_section = :users
|
||||
end
|
||||
end
|
||||
5
app/controllers/api/base_controller.rb
Normal file
5
app/controllers/api/base_controller.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Api::BaseController < ApplicationController
|
||||
|
||||
layout false
|
||||
|
||||
end
|
||||
13
app/controllers/api/kredits_controller.rb
Normal file
13
app/controllers/api/kredits_controller.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class Api::KreditsController < Api::BaseController
|
||||
|
||||
def onchain_btc_balance
|
||||
btcpay = BtcPay.new
|
||||
balance = btcpay.onchain_wallet_balance
|
||||
render json: balance
|
||||
rescue => error
|
||||
Rails.logger.warn "Failed to fetch kredits BTC wallet balance: #{error.message}"
|
||||
render json: { error: 'Failed to fetch wallet balance' },
|
||||
status: 500
|
||||
end
|
||||
|
||||
end
|
||||
@@ -3,12 +3,30 @@ class ApplicationController < ActionController::Base
|
||||
render :text => exception, :status => 500
|
||||
end
|
||||
|
||||
before_action :sentry_set_user
|
||||
|
||||
def sentry_set_user
|
||||
return unless Setting.sentry_enabled
|
||||
|
||||
if user_signed_in?
|
||||
Sentry.set_user(id: current_user.id, username: current_user.cn)
|
||||
else
|
||||
Sentry.set_user({})
|
||||
end
|
||||
end
|
||||
|
||||
def require_user_signed_in
|
||||
unless user_signed_in?
|
||||
redirect_to welcome_path and return
|
||||
end
|
||||
end
|
||||
|
||||
def require_user_signed_out
|
||||
if user_signed_in?
|
||||
redirect_to root_path and return
|
||||
end
|
||||
end
|
||||
|
||||
def authorize_admin
|
||||
http_status :forbidden unless current_user.is_admin?
|
||||
end
|
||||
|
||||
10
app/controllers/contributions/donations_controller.rb
Normal file
10
app/controllers/contributions/donations_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class Contributions::DonationsController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
# GET /donations
|
||||
# GET /donations.json
|
||||
def index
|
||||
@donations = current_user.donations.completed
|
||||
@current_section = :contributions
|
||||
end
|
||||
end
|
||||
8
app/controllers/contributions/projects_controller.rb
Normal file
8
app/controllers/contributions/projects_controller.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class Contributions::ProjectsController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
# GET /contributions
|
||||
def index
|
||||
@current_section = :contributions
|
||||
end
|
||||
end
|
||||
@@ -2,5 +2,6 @@ class DashboardController < ApplicationController
|
||||
before_action :require_user_signed_in
|
||||
|
||||
def index
|
||||
@current_section = :services
|
||||
end
|
||||
end
|
||||
|
||||
17
app/controllers/discourse/sso_controller.rb
Normal file
17
app/controllers/discourse/sso_controller.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class Discourse::SsoController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
|
||||
def connect
|
||||
secret = Setting.discourse_connect_secret
|
||||
sso = DiscourseApi::SingleSignOn.parse(request.query_string, secret)
|
||||
sso.external_id = current_user.id
|
||||
sso.email = current_user.email
|
||||
sso.username = current_user.cn
|
||||
sso.name = current_user.display_name
|
||||
sso.admin = current_user.is_admin?
|
||||
sso.sso_secret = secret
|
||||
|
||||
redirect_to sso.to_url("#{Setting.discourse_public_url}/session/sso_login"),
|
||||
allow_other_host: true
|
||||
end
|
||||
end
|
||||
51
app/controllers/invitations_controller.rb
Normal file
51
app/controllers/invitations_controller.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
class InvitationsController < ApplicationController
|
||||
before_action :authenticate_user!, except: ["show"]
|
||||
before_action :require_user_signed_out, only: ["show"]
|
||||
|
||||
# GET /invitations
|
||||
def index
|
||||
@invitations_unused = current_user.invitations.unused
|
||||
@invitations_used = current_user.invitations.used.order('used_at desc')
|
||||
@current_section = :invitations
|
||||
end
|
||||
|
||||
# GET /invitations/a-random-invitation-token
|
||||
def show
|
||||
token = session[:invitation_token] = params[:id]
|
||||
|
||||
if Invitation.where(token: token, used_at: nil).exists?
|
||||
redirect_to signup_path and return
|
||||
else
|
||||
flash.now[:alert] = "This invitation either doesn't exist or has already been used."
|
||||
http_status :unauthorized
|
||||
end
|
||||
end
|
||||
|
||||
# POST /invitations
|
||||
def create
|
||||
@invitation = Invitation.new(user: current_user)
|
||||
|
||||
respond_to do |format|
|
||||
if @invitation.save
|
||||
format.html do redirect_to @invitation, flash: {
|
||||
success: 'Invitation was successfully created.'
|
||||
}
|
||||
end
|
||||
format.json { render :show, status: :created, location: @invitation }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @invitation.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /invitations/1
|
||||
def destroy
|
||||
@invitation = current_user.invitations.find(params[:id])
|
||||
@invitation.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to invitations_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
||||
95
app/controllers/lnurlpay_controller.rb
Normal file
95
app/controllers/lnurlpay_controller.rb
Normal file
@@ -0,0 +1,95 @@
|
||||
class LnurlpayController < ApplicationController
|
||||
before_action :check_feature_enabled
|
||||
before_action :find_user_by_address
|
||||
|
||||
MIN_SATS = 10
|
||||
MAX_SATS = 1_000_000
|
||||
MAX_COMMENT_CHARS = 100
|
||||
|
||||
def index
|
||||
render json: {
|
||||
status: "OK",
|
||||
callback: "https://accounts.kosmos.org/lnurlpay/#{@user.address}/invoice",
|
||||
tag: "payRequest",
|
||||
maxSendable: MAX_SATS * 1000, # msat
|
||||
minSendable: MIN_SATS * 1000, # msat
|
||||
metadata: metadata(@user.address),
|
||||
commentAllowed: MAX_COMMENT_CHARS
|
||||
}
|
||||
end
|
||||
|
||||
def keysend
|
||||
http_status :not_found and return unless Setting.lndhub_keysend_enabled?
|
||||
|
||||
render json: {
|
||||
status: "OK",
|
||||
tag: "keysend",
|
||||
pubkey: Setting.lndhub_public_key,
|
||||
customData: [{
|
||||
customKey: "696969",
|
||||
customValue: @user.ln_account
|
||||
}]
|
||||
}
|
||||
end
|
||||
|
||||
def invoice
|
||||
amount = params[:amount].to_i / 1000 # msats
|
||||
address = params[:address]
|
||||
comment = params[:comment] || ""
|
||||
|
||||
if !valid_amount?(amount)
|
||||
render json: { status: "ERROR", reason: "Invalid amount" }
|
||||
return
|
||||
end
|
||||
|
||||
if !valid_comment?(comment)
|
||||
render json: { status: "ERROR", reason: "Comment too long" }
|
||||
return
|
||||
end
|
||||
|
||||
memo = "To #{address}"
|
||||
memo = "#{memo}: \"#{comment}\"" if comment.present?
|
||||
|
||||
payment_request = @user.ln_create_invoice({
|
||||
amount: amount, # we create invoices in sats
|
||||
memo: memo,
|
||||
description_hash: Digest::SHA2.hexdigest(metadata(address)),
|
||||
})
|
||||
|
||||
render json: {
|
||||
status: "OK",
|
||||
successAction: {
|
||||
tag: "message",
|
||||
message: "Sats received. Thank you!"
|
||||
},
|
||||
routes: [],
|
||||
pr: payment_request
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_user_by_address
|
||||
address = params[:address].split("@")
|
||||
@user = User.where(cn: address.first, ou: address.last).first
|
||||
http_status :not_found if @user.nil?
|
||||
end
|
||||
|
||||
def metadata(address)
|
||||
"[[\"text/identifier\", \"#{address}\"], [\"text/plain\", \"Send sats, receive thanks.\"]]"
|
||||
end
|
||||
|
||||
def valid_amount?(amount_in_sats)
|
||||
amount_in_sats <= MAX_SATS && amount_in_sats >= MIN_SATS
|
||||
end
|
||||
|
||||
def valid_comment?(comment)
|
||||
comment.length <= MAX_COMMENT_CHARS
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_feature_enabled
|
||||
http_status :not_found unless Setting.lndhub_enabled?
|
||||
end
|
||||
end
|
||||
137
app/controllers/services/lightning_controller.rb
Normal file
137
app/controllers/services/lightning_controller.rb
Normal file
@@ -0,0 +1,137 @@
|
||||
require "rqrcode"
|
||||
require "lnurl"
|
||||
|
||||
class Services::LightningController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
before_action :authenticate_with_lndhub
|
||||
before_action :set_current_section
|
||||
before_action :fetch_balance
|
||||
|
||||
def index
|
||||
@wallet_url = "lndhub://#{current_user.ln_account}:#{current_user.ln_password}@#{ENV['LNDHUB_PUBLIC_URL']}"
|
||||
initialize_lndhub_qr_code
|
||||
end
|
||||
|
||||
def transactions
|
||||
@transactions = fetch_transactions
|
||||
end
|
||||
|
||||
def qr_lnurlp
|
||||
lnurlp_url = "https://kosmos.org/.well-known/lnurlp/#{current_user.cn}"
|
||||
lnurlp_bech32 = Lnurl.new(lnurlp_url).to_bech32
|
||||
qr_code = RQRCode::QRCode.new("lightning:" + lnurlp_bech32)
|
||||
|
||||
respond_to do |format|
|
||||
format.svg do
|
||||
qr_svg = qr_code.as_svg(
|
||||
color: "000",
|
||||
shape_rendering: "crispEdges",
|
||||
module_size: 6,
|
||||
standalone: true,
|
||||
use_path: true,
|
||||
svg_attributes: {
|
||||
class: 'inline-block'
|
||||
}
|
||||
)
|
||||
send_data(
|
||||
qr_svg,
|
||||
filename: "bitcoin-lightning-#{current_user.address}.svg",
|
||||
type: "image/svg+xml"
|
||||
)
|
||||
end
|
||||
format.png do
|
||||
qr_png = qr_code.as_png(
|
||||
fill: "white",
|
||||
color: "black",
|
||||
size: 1024,
|
||||
)
|
||||
send_data(
|
||||
qr_png,
|
||||
filename: "bitcoin-lightning-#{current_user.address}.png",
|
||||
type: "image/png"
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def initialize_lndhub_qr_code
|
||||
qr_code = RQRCode::QRCode.new(@wallet_url)
|
||||
@lndhub_qr_svg = qr_code.as_svg(
|
||||
color: "000",
|
||||
shape_rendering: "crispEdges",
|
||||
module_size: 6,
|
||||
standalone: true,
|
||||
use_path: true,
|
||||
svg_attributes: {
|
||||
class: 'inline-block'
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def authenticate_with_lndhub(options={})
|
||||
if session[:ln_auth_token].present? && !options[:force_reauth]
|
||||
@ln_auth_token = session[:ln_auth_token]
|
||||
else
|
||||
lndhub = Lndhub.new
|
||||
auth_token = lndhub.authenticate(current_user)
|
||||
session[:ln_auth_token] = auth_token
|
||||
@ln_auth_token = auth_token
|
||||
end
|
||||
rescue => e
|
||||
Sentry.capture_exception(e) if Setting.sentry_enabled?
|
||||
end
|
||||
|
||||
def set_current_section
|
||||
@current_section = :services
|
||||
end
|
||||
|
||||
def fetch_balance
|
||||
lndhub = Lndhub.new
|
||||
data = lndhub.balance @ln_auth_token
|
||||
@balance = data["BTC"]["AvailableBalance"] rescue nil
|
||||
rescue AuthError
|
||||
authenticate_with_lndhub(force_reauth: true)
|
||||
raise if @fetch_balance_retried
|
||||
@fetch_balance_retried = true
|
||||
fetch_balance
|
||||
end
|
||||
|
||||
def fetch_transactions
|
||||
lndhub = Lndhub.new
|
||||
txs = lndhub.gettxs @ln_auth_token
|
||||
invoices = lndhub.getuserinvoices(@ln_auth_token).select{|i| i["ispaid"]}
|
||||
process_transactions(txs + invoices)
|
||||
rescue AuthError
|
||||
authenticate_with_lndhub(force_reauth: true)
|
||||
raise if @fetch_transactions_retried
|
||||
@fetch_transactions_retried = true
|
||||
fetch_transactions
|
||||
end
|
||||
|
||||
def process_transactions(txs)
|
||||
txs.collect do |tx|
|
||||
if tx["type"] == "bitcoind_tx"
|
||||
tx["amount_sats"] = (tx["amount"] * 100000000).to_i
|
||||
tx["datetime"] = Time.at(tx["time"].to_i)
|
||||
tx["title"] = "Received"
|
||||
tx["description"] = "On-chain topup"
|
||||
tx["received"] = true
|
||||
else
|
||||
tx["amount_sats"] = tx["value"] || tx["amt"]
|
||||
tx["fee"] = tx["type"] == "paid_invoice" ? tx["fee"] : nil
|
||||
tx["datetime"] = Time.at(tx["timestamp"].to_i)
|
||||
tx["title"] = tx["type"] == "paid_invoice" ? "Sent" : "Received"
|
||||
tx["description"] = tx["memo"] || tx["description"]
|
||||
tx["received"] = tx["type"] == "user_invoice"
|
||||
end
|
||||
end
|
||||
|
||||
# Handle an edge case where lndhub.go includes a failed payment in the
|
||||
# list, which wasn't actually booked
|
||||
txs.reject!{ |tx| tx["type"] == "paid_invoice" && tx["payment_preimage"].blank? }
|
||||
|
||||
txs.sort{ |a,b| b["datetime"] <=> a["datetime"] }
|
||||
end
|
||||
end
|
||||
30
app/controllers/services/remotestorage_controller.rb
Normal file
30
app/controllers/services/remotestorage_controller.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
class Services::RemotestorageController < ApplicationController
|
||||
before_action :require_user_signed_in
|
||||
before_action :require_service_enabled
|
||||
before_action :require_feature_enabled
|
||||
before_action :set_current_section
|
||||
|
||||
def dashboard
|
||||
# unless current_user.services_enabled.include?(:remotestorage)
|
||||
# redirect_to service_remotestorage_info_path
|
||||
# end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def require_feature_enabled
|
||||
unless Flipper.enabled?(:remotestorage, current_user)
|
||||
http_status :forbidden
|
||||
end
|
||||
end
|
||||
|
||||
def require_service_enabled
|
||||
unless Setting.remotestorage_enabled?
|
||||
http_status :not_found
|
||||
end
|
||||
end
|
||||
|
||||
def set_current_section
|
||||
@current_section = :services
|
||||
end
|
||||
end
|
||||
@@ -1,7 +1,54 @@
|
||||
require 'securerandom'
|
||||
|
||||
class SettingsController < ApplicationController
|
||||
before_action :require_user_signed_in
|
||||
before_action :authenticate_user!
|
||||
before_action :set_main_nav_section
|
||||
before_action :set_settings_section, only: [:show, :update, :update_email]
|
||||
before_action :set_user, only: [:show, :update, :update_email]
|
||||
|
||||
def index
|
||||
redirect_to setting_path(:profile)
|
||||
end
|
||||
|
||||
def show
|
||||
if @settings_section == "experiments"
|
||||
session[:shared_secret] ||= SecureRandom.base64(12)
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@user.preferences.merge!(user_params[:preferences] || {})
|
||||
@user.display_name = user_params[:display_name]
|
||||
|
||||
if @user.save
|
||||
if @user.display_name && (@user.display_name != @user.ldap_entry[:display_name])
|
||||
LdapManager::UpdateDisplayName.call(@user.dn, user_params[:display_name])
|
||||
end
|
||||
|
||||
redirect_to setting_path(@settings_section), flash: {
|
||||
success: 'Settings saved.'
|
||||
}
|
||||
else
|
||||
@validation_errors = @user.errors
|
||||
render :show, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def update_email
|
||||
if @user.valid_ldap_authentication?(email_params[:current_password])
|
||||
if @user.update email: email_params[:email]
|
||||
redirect_to setting_path(:account), flash: {
|
||||
notice: 'Please confirm your new address using the confirmation link we just sent you.'
|
||||
}
|
||||
else
|
||||
@validation_errors = @user.errors
|
||||
render :show, status: :unprocessable_entity
|
||||
end
|
||||
else
|
||||
redirect_to setting_path(:account), flash: {
|
||||
error: 'Password did not match your current password. Try again.'
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def reset_password
|
||||
@@ -10,4 +57,79 @@ class SettingsController < ApplicationController
|
||||
msg = "We have sent you an email with a link to reset your password."
|
||||
redirect_to check_your_email_path, notice: msg
|
||||
end
|
||||
|
||||
def set_nostr_pubkey
|
||||
signed_event = nostr_event_params[:signed_event].to_h.symbolize_keys
|
||||
is_valid_id = NostrManager::ValidateId.call(signed_event)
|
||||
is_valid_sig = NostrManager::VerifySignature.call(signed_event)
|
||||
is_correct_content = signed_event[:content] == "Connect my public key to #{current_user.address} (confirmation #{session[:shared_secret]})"
|
||||
|
||||
unless is_valid_id && is_valid_sig && is_correct_content
|
||||
flash[:alert] = "Public key could not be verified"
|
||||
http_status :unprocessable_entity and return
|
||||
end
|
||||
|
||||
pubkey_taken = User.all_except(current_user).where(
|
||||
ou: current_user.ou, nostr_pubkey: signed_event[:pubkey]
|
||||
).any?
|
||||
|
||||
if pubkey_taken
|
||||
flash[:alert] = "Public key already in use for a different account"
|
||||
http_status :unprocessable_entity and return
|
||||
end
|
||||
|
||||
current_user.update! nostr_pubkey: signed_event[:pubkey]
|
||||
session[:shared_secret] = nil
|
||||
|
||||
flash[:success] = "Public key verification successful"
|
||||
http_status :ok
|
||||
rescue
|
||||
flash[:alert] = "Public key could not be verified"
|
||||
http_status :unprocessable_entity and return
|
||||
end
|
||||
|
||||
# DELETE /settings/nostr_pubkey
|
||||
def remove_nostr_pubkey
|
||||
current_user.update! nostr_pubkey: nil
|
||||
|
||||
redirect_to setting_path(:experiments), flash: {
|
||||
success: 'Public key removed from account'
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_main_nav_section
|
||||
@current_section = :settings
|
||||
end
|
||||
|
||||
def set_settings_section
|
||||
@settings_section = params[:section]
|
||||
allowed_sections = [:profile, :account, :lightning, :xmpp, :experiments]
|
||||
|
||||
unless allowed_sections.include?(@settings_section.to_sym)
|
||||
redirect_to setting_path(:profile)
|
||||
end
|
||||
end
|
||||
|
||||
def set_user
|
||||
@user = current_user
|
||||
end
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:display_name, preferences: [
|
||||
:lightning_notify_sats_received,
|
||||
:xmpp_exchange_contacts_with_invitees
|
||||
])
|
||||
end
|
||||
|
||||
def email_params
|
||||
params.require(:user).permit(:email, :current_password)
|
||||
end
|
||||
|
||||
def nostr_event_params
|
||||
params.permit(signed_event: [
|
||||
:id, :pubkey, :created_at, :kind, :tags, :content, :sig
|
||||
])
|
||||
end
|
||||
end
|
||||
|
||||
111
app/controllers/signup_controller.rb
Normal file
111
app/controllers/signup_controller.rb
Normal file
@@ -0,0 +1,111 @@
|
||||
class SignupController < ApplicationController
|
||||
before_action :require_user_signed_out
|
||||
before_action :require_invitation
|
||||
before_action :set_invitation
|
||||
before_action :set_new_user, only: ["steps", "validate"]
|
||||
before_action :set_context
|
||||
|
||||
def index
|
||||
@invited_by_name = @invitation.user.address
|
||||
end
|
||||
|
||||
def steps
|
||||
@step = params[:step].to_i
|
||||
http_status :not_found unless [1,2,3].include?(@step)
|
||||
@validation_error = session[:validation_error]
|
||||
end
|
||||
|
||||
def validate
|
||||
session[:validation_error] = nil
|
||||
|
||||
case user_params.keys.first
|
||||
when "cn"
|
||||
@user.cn = user_params[:cn]
|
||||
@user.valid?
|
||||
session[:new_user] = @user
|
||||
|
||||
if @user.errors[:cn].present?
|
||||
session[:validation_error] = @user.errors[:cn].first # Store user including validation errors
|
||||
redirect_to signup_steps_path(1) and return
|
||||
else
|
||||
redirect_to signup_steps_path(2) and return
|
||||
end
|
||||
when "email"
|
||||
@user.email = user_params[:email]
|
||||
@user.valid?
|
||||
session[:new_user] = @user
|
||||
|
||||
if @user.errors[:email].present?
|
||||
session[:validation_error] = @user.errors[:email].first # Store user including validation errors
|
||||
redirect_to signup_steps_path(2) and return
|
||||
else
|
||||
redirect_to signup_steps_path(3) and return
|
||||
end
|
||||
when "password"
|
||||
@user.password = user_params[:password]
|
||||
@user.password_confirmation = user_params[:password]
|
||||
@user.valid?
|
||||
session[:new_user] = @user
|
||||
|
||||
if @user.errors[:password].present?
|
||||
session[:validation_error] = @user.errors[:password].first # Store user including validation errors
|
||||
redirect_to signup_steps_path(3) and return
|
||||
else
|
||||
complete_signup
|
||||
msg = "Almost done! We have sent you an email to confirm your address."
|
||||
redirect_to(check_your_email_path, notice: msg) and return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:cn, :email, :password)
|
||||
end
|
||||
|
||||
def require_invitation
|
||||
if session[:invitation_token].blank?
|
||||
flash.now[:alert] = "You need an invitation to sign up for an account."
|
||||
http_status :unauthorized
|
||||
elsif !valid_invitation?(session[:invitation_token])
|
||||
flash.now[:alert] = "This invitation either doesn't exist or has already been used."
|
||||
http_status :unauthorized
|
||||
end
|
||||
|
||||
@invitation = Invitation.find_by(token: session[:invitation_token])
|
||||
end
|
||||
|
||||
def valid_invitation?(token)
|
||||
Invitation.where(token: session[:invitation_token], used_at: nil).exists?
|
||||
end
|
||||
|
||||
def set_invitation
|
||||
@invitation = Invitation.find_by(token: session[:invitation_token])
|
||||
end
|
||||
|
||||
def set_new_user
|
||||
if session[:new_user].present?
|
||||
@user = User.new(session[:new_user])
|
||||
else
|
||||
@user = User.new(ou: Setting.primary_domain)
|
||||
end
|
||||
end
|
||||
|
||||
def complete_signup
|
||||
session[:new_user] = nil
|
||||
session[:validation_error] = nil
|
||||
|
||||
CreateAccount.call(
|
||||
username: @user.cn,
|
||||
domain: Setting.primary_domain,
|
||||
email: @user.email,
|
||||
password: @user.password,
|
||||
invitation: @invitation
|
||||
)
|
||||
end
|
||||
|
||||
def set_context
|
||||
@context = :signup
|
||||
end
|
||||
end
|
||||
18
app/controllers/turbo_controller.rb
Normal file
18
app/controllers/turbo_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class TurboController < ApplicationController
|
||||
class Responder < ActionController::Responder
|
||||
def to_turbo_stream
|
||||
controller.render(options.merge(formats: :html))
|
||||
rescue ActionView::MissingTemplate => error
|
||||
if get?
|
||||
raise error
|
||||
elsif has_errors? && default_action
|
||||
render rendering_options.merge(formats: :html, status: :unprocessable_entity)
|
||||
else
|
||||
redirect_to navigation_location
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self.responder = Responder
|
||||
respond_to :html, :turbo_stream
|
||||
end
|
||||
17
app/controllers/users/confirmations_controller.rb
Normal file
17
app/controllers/users/confirmations_controller.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Users::ConfirmationsController < Devise::ConfirmationsController
|
||||
# GET /resource/confirmation?confirmation_token=abcdef
|
||||
def show
|
||||
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
|
||||
yield resource if block_given?
|
||||
|
||||
if resource.errors.empty?
|
||||
set_flash_message!(:success, :confirmed)
|
||||
resource.devise_after_confirmation
|
||||
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
|
||||
else
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
|
||||
end
|
||||
end
|
||||
end
|
||||
18
app/controllers/users/devise_controller.rb
Normal file
18
app/controllers/users/devise_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class Users::DeviseController < ApplicationController
|
||||
class Responder < ActionController::Responder
|
||||
def to_turbo_stream
|
||||
controller.render(options.merge(formats: :html))
|
||||
rescue ActionView::MissingTemplate => error
|
||||
if get?
|
||||
raise error
|
||||
elsif has_errors? && default_action
|
||||
render rendering_options.merge(formats: :html, status: :unprocessable_entity)
|
||||
else
|
||||
redirect_to navigation_location
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self.responder = Responder
|
||||
respond_to :html, :turbo_stream
|
||||
end
|
||||
57
app/controllers/webfinger_controller.rb
Normal file
57
app/controllers/webfinger_controller.rb
Normal file
@@ -0,0 +1,57 @@
|
||||
class WebfingerController < ApplicationController
|
||||
before_action :allow_cross_origin_requests, only: [:show]
|
||||
|
||||
layout false
|
||||
|
||||
def show
|
||||
resource = params[:resource]
|
||||
|
||||
if resource && resource.match(/acct:\w+/)
|
||||
useraddress = resource.split(":").last
|
||||
username, org = useraddress.split("@")
|
||||
username.downcase!
|
||||
unless User.where(cn: username, ou: org).any?
|
||||
head 404 and return
|
||||
end
|
||||
|
||||
render json: webfinger(useraddress).to_json,
|
||||
content_type: "application/jrd+json"
|
||||
else
|
||||
head 422 and return
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def webfinger(useraddress)
|
||||
links = [];
|
||||
|
||||
links << remotestorage_link(useraddress) if Setting.remotestorage_enabled
|
||||
|
||||
{ "links" => links }
|
||||
end
|
||||
|
||||
def remotestorage_link(useraddress)
|
||||
# TODO use when OAuth routes are available
|
||||
# auth_url = new_rs_oauth_url(useraddress)
|
||||
auth_url = "https://example.com/rs/oauth"
|
||||
storage_url = "#{Setting.rs_storage_url}/#{useraddress}"
|
||||
|
||||
{
|
||||
"rel" => "http://tools.ietf.org/id/draft-dejong-remotestorage",
|
||||
"href" => storage_url,
|
||||
"properties" => {
|
||||
"http://remotestorage.io/spec/version" => "draft-dejong-remotestorage-13",
|
||||
"http://tools.ietf.org/html/rfc6749#section-4.2" => auth_url,
|
||||
"http://tools.ietf.org/html/rfc6750#section-2.3" => nil, # access token via a HTTP query parameter
|
||||
"http://tools.ietf.org/html/rfc7233": "GET", # content range requests
|
||||
"http://remotestorage.io/spec/web-authoring": nil
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def allow_cross_origin_requests
|
||||
headers['Access-Control-Allow-Origin'] = '*'
|
||||
headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, OPTIONS'
|
||||
end
|
||||
end
|
||||
46
app/controllers/webhooks_controller.rb
Normal file
46
app/controllers/webhooks_controller.rb
Normal file
@@ -0,0 +1,46 @@
|
||||
class WebhooksController < ApplicationController
|
||||
skip_forgery_protection
|
||||
|
||||
before_action :authorize_request
|
||||
|
||||
def lndhub
|
||||
begin
|
||||
payload = JSON.parse(request.body.read, symbolize_names: true)
|
||||
head :no_content and return unless payload[:type] == "incoming"
|
||||
rescue
|
||||
head :unprocessable_entity and return
|
||||
end
|
||||
|
||||
user = User.find_by!(ln_account: payload[:user_login])
|
||||
notify = user.preferences[:lightning_notify_sats_received]
|
||||
case notify
|
||||
when "xmpp"
|
||||
notify_xmpp(user.address, payload[:amount], payload[:memo])
|
||||
when "email"
|
||||
NotificationMailer.with(user: user, amount_sats: payload[:amount])
|
||||
.lightning_sats_received.deliver_later
|
||||
end
|
||||
|
||||
head :ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# TODO refactor into mailer-like generic class/service
|
||||
def notify_xmpp(address, amt_sats, memo)
|
||||
payload = {
|
||||
type: "normal",
|
||||
from: Setting.primary_domain,
|
||||
to: address,
|
||||
subject: "Sats received!",
|
||||
body: "#{helpers.number_with_delimiter amt_sats} sats received in your Lightning wallet:\n> #{memo}"
|
||||
}
|
||||
XmppSendMessageJob.perform_later(payload)
|
||||
end
|
||||
|
||||
def authorize_request
|
||||
if !ENV['WEBHOOKS_ALLOWED_IPS'].split(',').include?(request.remote_ip)
|
||||
head :forbidden and return
|
||||
end
|
||||
end
|
||||
end
|
||||
16
app/controllers/well_known_controller.rb
Normal file
16
app/controllers/well_known_controller.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class WellKnownController < ApplicationController
|
||||
def nostr
|
||||
http_status :unprocessable_entity and return if params[:name].blank?
|
||||
domain = request.headers["X-Forwarded-Host"].presence || Setting.primary_domain
|
||||
@user = User.where(cn: params[:name], ou: domain).first
|
||||
http_status :not_found and return if @user.nil? || @user.nostr_pubkey.blank?
|
||||
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: {
|
||||
names: { "#{@user.cn}": @user.nostr_pubkey }
|
||||
}.to_json
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
1
app/errors/auth_error.rb
Normal file
1
app/errors/auth_error.rb
Normal file
@@ -0,0 +1 @@
|
||||
class AuthError < StandardError; end
|
||||
@@ -1,2 +1,21 @@
|
||||
module ApplicationHelper
|
||||
include Pagy::Frontend
|
||||
|
||||
def sats_to_btc(sats)
|
||||
sats.to_f / 100000000
|
||||
end
|
||||
|
||||
def main_nav_class(current_section, link_to_section)
|
||||
if current_section == link_to_section
|
||||
"bg-gray-900/50 text-white px-3 py-2 rounded-md font-medium text-base md:text-sm block md:inline-block"
|
||||
else
|
||||
"text-gray-300 hover:bg-gray-900/30 hover:text-white active:bg-gray-900/30 active:text-white px-3 py-2 rounded-md font-medium text-base md:text-sm block md:inline-block"
|
||||
end
|
||||
end
|
||||
|
||||
# Colors available: gray, red, yellow, green, blue, purple, pink
|
||||
# (Add more colors by adding classes to the safelist in tailwind.config.js)
|
||||
def badge(text, color)
|
||||
tag.span text, class: "inline-flex items-center rounded-full bg-#{color}-100 px-2.5 py-0.5 text-xs font-medium text-#{color}-800"
|
||||
end
|
||||
end
|
||||
|
||||
2
app/helpers/donations_helper.rb
Normal file
2
app/helpers/donations_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module DonationsHelper
|
||||
end
|
||||
2
app/helpers/invitations_helper.rb
Normal file
2
app/helpers/invitations_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module InvitationsHelper
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
module LdapUsersHelper
|
||||
end
|
||||
2
app/helpers/lnurlpay_helper.rb
Normal file
2
app/helpers/lnurlpay_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module LnurlpayHelper
|
||||
end
|
||||
2
app/helpers/signup_helper.rb
Normal file
2
app/helpers/signup_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module SignupHelper
|
||||
end
|
||||
2
app/helpers/users_helper.rb
Normal file
2
app/helpers/users_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module UsersHelper
|
||||
end
|
||||
2
app/helpers/wallet_helper.rb
Normal file
2
app/helpers/wallet_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module WalletHelper
|
||||
end
|
||||
3
app/javascript/application.js
Normal file
3
app/javascript/application.js
Normal file
@@ -0,0 +1,3 @@
|
||||
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
|
||||
import "@hotwired/turbo-rails"
|
||||
import "controllers"
|
||||
@@ -1,6 +0,0 @@
|
||||
// Action Cable provides the framework to deal with WebSockets in Rails.
|
||||
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
||||
|
||||
import { createConsumer } from "@rails/actioncable"
|
||||
|
||||
export default createConsumer()
|
||||
@@ -1,5 +0,0 @@
|
||||
// Load all the channels within this directory and all subdirectories.
|
||||
// Channel files must be named *_channel.js.
|
||||
|
||||
const channels = require.context('.', true, /_channel\.js$/)
|
||||
channels.keys().forEach(channels)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user