Compare commits
1724 commits
Author | SHA1 | Date | |
---|---|---|---|
8eaca85fe0 | |||
fe48864f39 | |||
83d10e1a70 | |||
23c275945a | |||
70f90dd456 | |||
cd5c97afd3 | |||
97f3848b66 | |||
540bd17792 | |||
1fe9a42d8d | |||
cf978cd749 | |||
126bb29ae2 | |||
7a58287b34 | |||
328c9badb4 | |||
1dfa17abca | |||
f2025b801b | |||
4e7b911fe9 | |||
cf6e65cc03 | |||
70e5b9bec7 | |||
84383ecd31 | |||
1d59d57c2e | |||
43447ac47b | |||
d7da42b626 | |||
d80e8164c8 | |||
37a8e4bba8 | |||
9abe4a6110 | |||
d77f2302ba | |||
dd04921e6e | |||
|
71393add2f | ||
85aae94496 | |||
|
4ca14542d7 | ||
65ca2d3d6c | |||
|
3a47f3b33c | ||
a93219f4bb | |||
|
f384e16ef1 | ||
520892f789 | |||
|
290445a4e1 | ||
e1f6c9b1e3 | |||
|
8a7f320b3a | ||
9ade631b82 | |||
|
43e9fa3530 | ||
370f33fcbf | |||
|
4250b946f4 | ||
e2b8b3ba1a | |||
|
ed8903050b | ||
6c9ee8bb7d | |||
|
207ff9fda3 | ||
c5e826a3e2 | |||
|
ea2fca89ed | ||
17a6f15175 | |||
|
3dd44d23cc | ||
bfaec2f3a5 | |||
|
2d04d68484 | ||
fe9ae25a60 | |||
|
bd09e5a65f | ||
9a883e05bb | |||
|
01713b7d79 | ||
d6a0b1dcf6 | |||
bcf61bb6a0 | |||
baee7ade4f | |||
55afa8f01d | |||
8e077045d2 | |||
1475ecdde5 | |||
a2c0fb2298 | |||
7b93692ba5 | |||
|
51c3ba8ecf | ||
19f2803590 | |||
|
be95bd6468 | ||
96f340ddec | |||
|
8792bee249 | ||
d628edf213 | |||
|
05769c410c | ||
024cc73c9d | |||
|
c25c1672f1 | ||
47b8208bea | |||
|
ed8d232ce4 | ||
1fa4d71714 | |||
|
8baac038de | ||
49078156f1 | |||
|
929f26fe76 | ||
e0f82643e0 | |||
|
f8063d1bca | ||
afee38c04b | |||
3cf11b0d72 | |||
06c5d811be | |||
|
411dc19c5a | ||
179938d97c | |||
|
0e68fffc16 | ||
6a575f9058 | |||
|
0eea92930b | ||
e8a9edc2bb | |||
|
74db2cf3e1 | ||
0fee4eedfa | |||
|
5481bab429 | ||
55a1444ba8 | |||
|
145c388b65 | ||
cabc9fef84 | |||
1521130f55 | |||
de3661ab77 | |||
5d8929ac29 | |||
1cd4e54b44 | |||
3e980b9a6a | |||
427a63af0f | |||
|
466378433b | ||
bf94de46ab | |||
|
92d66f733e | ||
cb32b30663 | |||
|
a49ee852ee | ||
84940844b0 | |||
|
0991c53dd6 | ||
f7c9c044e0 | |||
|
9348b7b0ce | ||
527bfb31d6 | |||
|
f7f47a22f0 | ||
0066311bde | |||
|
a015ba2775 | ||
f456199c48 | |||
|
78712aef2f | ||
bb980eec47 | |||
|
4749b166bf | ||
f51e2610f4 | |||
|
ae0a8290f7 | ||
6afa01b58d | |||
|
0ae30c18f0 | ||
0b864a3286 | |||
|
5a6db7dee4 | ||
0e76d42743 | |||
|
39770f6f7c | ||
df0a388da6 | |||
|
6943197ec5 | ||
9855c5ce04 | |||
8432934643 | |||
5a52fda97d | |||
|
ba13e3e4ca | ||
ca6eefd0a9 | |||
|
9496648221 | ||
c40bbf3a53 | |||
|
548f156ad0 | ||
42f69bd168 | |||
|
333412c810 | ||
699096c008 | |||
|
6de8f25a31 | ||
255ff5227f | |||
|
e84d1018cc | ||
72b0a4f133 | |||
|
4a8e2dd0fc | ||
a440533a76 | |||
d98a66f42b | |||
58b31bb4c1 | |||
7f70f75d05 | |||
5b2bfd5270 | |||
7ad5d56f1b | |||
|
7f95842308 | ||
25fceca2ff | |||
|
dd862be3a9 | ||
1b08703cd9 | |||
|
1475e8f859 | ||
e72d9ca231 | |||
|
1db7cde639 | ||
76061e10e3 | |||
|
936acc6196 | ||
13e2f8ade1 | |||
|
7d47ba6edf | ||
71f35e6c2e | |||
|
8d053195d1 | ||
5c420584c0 | |||
|
4840120971 | ||
c26e528d9f | |||
|
9a2364563a | ||
5749bf2e69 | |||
|
32ad6d7d88 | ||
a200c9d43e | |||
1f9a8fee99 | |||
cbbe87e23c | |||
5d6d611707 | |||
|
16ce12b5df | ||
d172a1ace8 | |||
|
b0ce4efbd8 | ||
8143f7a1a6 | |||
|
db670de2f0 | ||
1429563b74 | |||
|
38480ddaad | ||
3bb33cdec7 | |||
7f8553127d | |||
8726fc329c | |||
ed2b3c99da | |||
db8f885092 | |||
174cd4db33 | |||
e95186e1fd | |||
03b8c1677c | |||
cf62d756af | |||
dfe74e7538 | |||
47b39edaeb | |||
21e2b5217e | |||
d877061077 | |||
1cb1eac8fe | |||
12d3da5fdb | |||
8b276938e9 | |||
|
5cd3b63b73 | ||
a910a52f83 | |||
|
fdcd159bec | ||
b7b4082ca3 | |||
|
3d48d54834 | ||
d61dc7d784 | |||
|
2d0c01d399 | ||
f6d87fe745 | |||
be06fd66f8 | |||
7660b1c731 | |||
c78aea2581 | |||
|
d6e35856d1 | ||
1e7a588157 | |||
|
9666daf068 | ||
5c7557b2d3 | |||
|
af7f2fb800 | ||
965c69748f | |||
|
508f92dd17 | ||
80184002b7 | |||
|
ec04fefbb0 | ||
a3f1016709 | |||
|
6ce729633c | ||
908cc66c99 | |||
|
d040160681 | ||
b16232b258 | |||
|
e4eb18a5fc | ||
be34e5fb57 | |||
|
a677d870c4 | ||
196b3eb426 | |||
|
997ad535b0 | ||
b5b900090a | |||
|
88ab482e53 | ||
f15f4c0a00 | |||
5dd3f70519 | |||
|
4312ef0e2d | ||
4b8adf3e03 | |||
16fe8c5366 | |||
|
f7b53250d5 | ||
|
679d9fcac7 | ||
3aaf48acf4 | |||
|
59274bab3e | ||
33e5855140 | |||
659bc57e24 | |||
acbb58c294 | |||
|
f629929162 | ||
68a06e0ec0 | |||
|
7d2eed3ef7 | ||
9a469c27eb | |||
|
744c983c86 | ||
01943ce478 | |||
|
68b6cb5c0e | ||
2e26924808 | |||
|
2e9ad7d2e5 | ||
88e986c883 | |||
|
1b036b1a73 | ||
0bf81d307a | |||
41ea09cf5d | |||
396b0dccf1 | |||
f770235e86 | |||
7efb474fb8 | |||
811f968fb9 | |||
7e6a047bc8 | |||
8875662434 | |||
|
19172a8ab3 | ||
22d8e6407e | |||
|
78db64f1dc | ||
433ed909c1 | |||
|
4ef0a4f6f1 | ||
0b02f156ea | |||
|
253561701d | ||
66de08f0bc | |||
|
816e9a984b | ||
978fa84acf | |||
|
8b9566e540 | ||
c5b7dbf829 | |||
4f5f4132d6 | |||
3d74174bab | |||
1874bc6f94 | |||
5fa788b362 | |||
35c54d05c1 | |||
|
caaaae0265 | ||
615c88c7cb | |||
|
be28421eb2 | ||
a8f9324414 | |||
|
e1b8d96636 | ||
07cd2a9eee | |||
|
6e48893e5b | ||
45846bec5d | |||
|
564f477352 | ||
2a4f50ae7d | |||
|
0c13bf8b91 | ||
b78f0343d4 | |||
|
0c92c1ff8e | ||
71990a0a6e | |||
|
eb89271001 | ||
eff5ad6cbb | |||
|
46c5702e5e | ||
100885cea4 | |||
|
32b2c84106 | ||
00a7d23925 | |||
|
fa2d75f53e | ||
ae2c960e05 | |||
|
9940c62a07 | ||
e5184a4695 | |||
|
c673cd6399 | ||
146ec9f50e | |||
|
d70df0a435 | ||
05ddf27b8c | |||
|
6944f7f330 | ||
6e3b702ed5 | |||
|
40745c7713 | ||
ff3ed3102d | |||
|
f1758a4d00 | ||
b305062d46 | |||
|
a548a91291 | ||
a3c8257f60 | |||
|
78128af30e | ||
9be807d02a | |||
|
a54dd4ac06 | ||
d7ed220ee7 | |||
|
7eb2687d6d | ||
d4f06349ef | |||
|
37bdd29a89 | ||
83f122171a | |||
|
116a336cb1 | ||
5c0300a5c9 | |||
|
68cbc72671 | ||
b7f8a71da5 | |||
|
34f4dba696 | ||
95d727f14f | |||
|
34bd2bbf97 | ||
b46fc7b65d | |||
|
5c21934c39 | ||
78b3913249 | |||
|
e9dbf346e4 | ||
a8ec0df6fb | |||
|
ad4d1d7c4d | ||
76ebc1b4f7 | |||
|
409c1ae983 | ||
5ae455487a | |||
|
7b8625f1f9 | ||
5751c54809 | |||
|
ea35e57d22 | ||
5852c52c7a | |||
|
df5d10b42a | ||
cfe442983a | |||
|
c23c05a0fc | ||
6a50d4e719 | |||
|
a2f1fd5d71 | ||
777d70499a | |||
|
b9416fcde8 | ||
0367603d42 | |||
|
9984f38474 | ||
e6687e9263 | |||
|
6ba0849efb | ||
1dc64ca8f2 | |||
|
4861e6b162 | ||
9c99a05577 | |||
|
81b31cf619 | ||
ca0287ad8b | |||
|
0a760f4500 | ||
73fb3a2189 | |||
|
fa75a462ff | ||
ed529fdf8a | |||
|
cf90ae6f77 | ||
2428bf217a | |||
|
fea5319e8e | ||
1b0f323f1e | |||
|
823f539a9d | ||
d3c2a05a33 | |||
|
1590314afc | ||
64a8d0a53a | |||
|
962eae31f0 | ||
a0645144f5 | |||
|
13176ec88d | ||
055a715181 | |||
|
132c48a9dc | ||
1b56b0fb31 | |||
|
78dd40297e | ||
8c3d6d0053 | |||
|
bb01fac0f4 | ||
dd0079edb4 | |||
|
8486725212 | ||
424300ec12 | |||
|
f95738b7d1 | ||
f160538c13 | |||
|
74c175e80d | ||
bc854d5522 | |||
|
2481c05e44 | ||
e42e432bd5 | |||
|
c78d563b63 | ||
2e74adcb1d | |||
|
fa65db433c | ||
7a8162821b | |||
|
660b436e00 | ||
c404c218c1 | |||
|
a46263285e | ||
8e811b331f | |||
|
4fadc3cc7f | ||
4ec28451aa | |||
|
82ec2f59fc | ||
f7e7b65173 | |||
|
dffd55ffbc | ||
51655e980b | |||
|
715c18107a | ||
08bea213b3 | |||
|
cc083bc09b | ||
7e6bdf1ac4 | |||
|
fd41486418 | ||
2c4dba225e | |||
|
6999978779 | ||
ca0ae1a387 | |||
|
8e29e3c498 | ||
7f168d16d2 | |||
|
e7c85e9456 | ||
a216c194d4 | |||
ec17f65107 | |||
1671323012 | |||
|
3d4585df5d | ||
306d19781e | |||
|
e4137d8718 | ||
f32b0068c6 | |||
f51c37103c | |||
2aa60db548 | |||
24ca9f86d2 | |||
ba9330cdf1 | |||
d264b8bdc3 | |||
|
49c407aade | ||
0cbc1d3b7b | |||
|
9bcec3df7c | ||
133abd2935 | |||
|
aaf5a2aed2 | ||
30d58e9e15 | |||
|
24f4571a3d | ||
e9f9f527a5 | |||
|
2faa92b642 | ||
53f744515d | |||
442c2061e8 | |||
4123e73ee0 | |||
65a70a5440 | |||
d56a656d0a | |||
6d5b298837 | |||
58a03ef931 | |||
21521f8944 | |||
d348879e1c | |||
|
74f9af7533 | ||
ab43db716c | |||
|
6ed4898a60 | ||
baf890d69c | |||
8f1cb65937 | |||
75565c9d90 | |||
|
92545ce1f5 | ||
0a45e2bcaf | |||
|
e4a1ca1481 | ||
4aca33446a | |||
|
93f23561cf | ||
ec495a2311 | |||
|
102d73f38b | ||
670e12c7e5 | |||
|
90ca01489b | ||
a4ad6ab583 | |||
|
47d32b2ea4 | ||
09508fd3a8 | |||
|
76010ae254 | ||
1e55467fd9 | |||
|
2425387322 | ||
c8059793f8 | |||
3c0c375fbb | |||
58c179bef2 | |||
|
13f9980d9e | ||
3972d9aa35 | |||
|
0ab605533d | ||
c608e3236f | |||
|
08b3e0d858 | ||
3b73acc1b1 | |||
|
311d90c4f0 | ||
7b5c73547b | |||
|
31b83fff97 | ||
ec3dc7ee06 | |||
fab6bd0cc2 | |||
23dedaa44b | |||
639064eb9e | |||
3b6225abf8 | |||
|
86589c720f | ||
0393470dd3 | |||
|
966aaa9c92 | ||
4778b26ffb | |||
|
89ff2fd2f2 | ||
a49873feb6 | |||
|
6f950a74c8 | ||
44c8621ad4 | |||
|
84642ebb19 | ||
62dcb7b32a | |||
|
037573b1b0 | ||
758c044898 | |||
|
2f8f6a1bf7 | ||
11e51d2286 | |||
10b51c654d | |||
302d4e6fdb | |||
8dd8fe3eb4 | |||
4dbcba401c | |||
6ee4222d80 | |||
608c6224b9 | |||
81e19fec1d | |||
92098a793e | |||
0f2554832d | |||
|
c0d85277fe | ||
f91b524072 | |||
|
98334f555b | ||
0e1289c428 | |||
|
6c1bd4b1e2 | ||
98b4753d32 | |||
|
2a22d65d9a | ||
4ae554d19f | |||
|
8d6a0bba4e | ||
5a5c96cee8 | |||
|
eb26bbc2eb | ||
6fd3cae8f3 | |||
|
c445ce517c | ||
14ccd1fec1 | |||
|
51bc747501 | ||
3b8efd0145 | |||
|
ebc425ad94 | ||
5bc03f36d2 | |||
05c63b241d | |||
3817545cf3 | |||
|
e9c014d768 | ||
a11b64036d | |||
|
3e058367e6 | ||
1084846193 | |||
|
c58f481b0f | ||
cdde265d48 | |||
|
a8e86da79e | ||
03685e5bac | |||
|
5f2105071e | ||
48b44552be | |||
|
9bfbd48989 | ||
6cf4c26327 | |||
189433ca3e | |||
ff7978f9b0 | |||
9124ac21ae | |||
7969003524 | |||
|
2d2616e883 | ||
757412a301 | |||
|
c3f1152592 | ||
972be6f934 | |||
|
88efeb8aad | ||
1a5693bfeb | |||
|
d2c5100043 | ||
463f7fa300 | |||
|
2f9bdaf576 | ||
def92e2a4e | |||
|
d475f27785 | ||
18b9046177 | |||
|
42914e5e3a | ||
eb139ba01c | |||
|
c981982afd | ||
e0493c4d1b | |||
|
5904635533 | ||
e64a3fd662 | |||
|
6e7da1304f | ||
d043128c4b | |||
|
36b459cc76 | ||
12bb9929ec | |||
|
e28670085b | ||
766137071d | |||
|
f1a1dccfe6 | ||
8b8c90e478 | |||
|
8debf9cfa7 | ||
65a4a5b0fd | |||
b49ffd2e9d | |||
1e28b394b6 | |||
483b3016ba | |||
4253764f39 | |||
03c8f20a8c | |||
eaeb727147 | |||
|
2d4cd801e2 | ||
a56cfed936 | |||
|
eda6241e98 | ||
38571a30f5 | |||
|
2f5e759904 | ||
4d54facc85 | |||
|
cd580b79cb | ||
b776447d6a | |||
|
b1af74ad58 | ||
658f2048b3 | |||
|
1899a41edc | ||
668cf8eb8b | |||
|
823fd12c37 | ||
79efc206e4 | |||
|
7fa7837d9b | ||
6f0d5c0ab4 | |||
|
f6faad9fa6 | ||
cd4811c084 | |||
|
4501659368 | ||
735fa41e92 | |||
|
3453e9f77c | ||
9c194feb43 | |||
|
4c11cac2ec | ||
2a755ac037 | |||
|
c94787809f | ||
1063313824 | |||
|
ba4d55da62 | ||
67ae8d81d2 | |||
|
09c36946bf | ||
5d8f7ff0d4 | |||
|
6a7845f83e | ||
9feff4a839 | |||
|
5dcad91d7d | ||
e012d03af2 | |||
|
84fd30b954 | ||
844dfae016 | |||
|
605cc7b0fa | ||
2357dd42aa | |||
|
79127fe4e7 | ||
ec242a4e4b | |||
|
b7991ea7ab | ||
c65ed29abe | |||
|
920dda52c2 | ||
8039dca8be | |||
|
c795bc875f | ||
470ff23eb6 | |||
|
e437481d08 | ||
b17c3d8bce | |||
|
2970a09508 | ||
2fb8339d91 | |||
a380b6252b | |||
|
c454f340d0 | ||
895912a23b | |||
|
c4f53bc44b | ||
9e8dafa5b1 | |||
|
e82d2b9172 | ||
f6fdf31d2d | |||
|
202dc9b2c4 | ||
cd7b537bb6 | |||
|
fe23c52d7b | ||
2a98eed64e | |||
|
46e2d24096 | ||
b593329a62 | |||
|
612a0c06ec | ||
024ee5a4e6 | |||
|
bec10ff609 | ||
3cb5d6424e | |||
|
bb9fc0fd3f | ||
778a44b1d1 | |||
|
cdacb9a649 | ||
982b53b328 | |||
|
1cb8e49c57 | ||
5349123b13 | |||
|
9891ab8cd7 | ||
eb7ce5f86e | |||
|
8a7151d087 | ||
0292f19781 | |||
|
153aac458d | ||
3f3b5ebcf9 | |||
|
bc5c9aec72 | ||
1498e2812c | |||
|
733fabcb0f | ||
6daff9e25b | |||
|
89f0756be4 | ||
4cf79308c7 | |||
|
3f637332ce | ||
7ae20b4fd8 | |||
|
d129d0d05d | ||
e2b9c61e6a | |||
|
dc510e75a2 | ||
91095d1ab2 | |||
|
576745f2bb | ||
7617aaada4 | |||
|
e120a866a8 | ||
f2ebc5c748 | |||
|
1870b58b0d | ||
febb38d9b8 | |||
|
000529dfff | ||
4dcbade0b2 | |||
|
70b9d313b7 | ||
7b5c5c7cc8 | |||
|
867f0e0407 | ||
fe66536b49 | |||
|
8b8e9f68ee | ||
05e457440b | |||
|
3d0c8d8562 | ||
600c4e4496 | |||
|
cdaa6737fb | ||
8ca717044b | |||
|
fb3430469b | ||
0320ceefb3 | |||
|
c9881affc3 | ||
67591f8d1b | |||
|
5439de37e6 | ||
65438d53b3 | |||
|
38679e3f9d | ||
fe47a9d945 | |||
|
3a5e109f08 | ||
e4fd672503 | |||
|
a179c51488 | ||
6a8bc1ed89 | |||
|
81d4fb1ed3 | ||
bdc9519234 | |||
|
90dae99fc0 | ||
7b48f4bbe9 | |||
|
954c9b1aa1 | ||
8d7c76d8ab | |||
|
a28903f199 | ||
57bb3f1ce6 | |||
|
374fec9d7a | ||
5eec3af59d | |||
|
0f3f356470 | ||
37d5169e23 | |||
|
0376e35a19 | ||
76578ae520 | |||
|
8824f78dc5 | ||
d3b8f76787 | |||
|
1c2bb38f46 | ||
13b3dfd502 | |||
|
59d980c540 | ||
717f1f95d9 | |||
|
4b600688be | ||
e8ec941af3 | |||
|
e268e4eb82 | ||
9a7aec7ed7 | |||
|
6b04efc009 | ||
cadd58187a | |||
c7f5190885 | |||
|
26390520b4 | ||
fc86628ae2 | |||
|
f813e5fad6 | ||
cf00a0e744 | |||
|
6e20a55675 | ||
34123d146c | |||
|
f12a2571ac | ||
a3dbae01ac | |||
|
63c0af7317 | ||
479fc975f1 | |||
|
0aa0302421 | ||
61fbf40059 | |||
|
a3d0fc5098 | ||
8a1638fe4f | |||
|
15d08f4b4c | ||
42d5b58258 | |||
|
b00584b0ef | ||
b63b84a87b | |||
|
7477e7d771 | ||
8699978b2a | |||
|
f826e3d328 | ||
02443ff511 | |||
|
571ad21999 | ||
a091317c1f | |||
|
3b7838f6fd | ||
a3e6ee0aaa | |||
|
709a26f771 | ||
8873ff8f10 | |||
|
fbb695a743 | ||
f4179fbf1b | |||
|
6fcf56136b | ||
63605fb093 | |||
|
457254b607 | ||
a90ece5049 | |||
|
a2dafd4c9e | ||
683916c24a | |||
|
fc9806b34a | ||
01f0006e23 | |||
|
b758d06311 | ||
0b0b081fe1 | |||
|
83c4c4ecd6 | ||
c6ca8992c9 | |||
|
b70fbd7e40 | ||
9f4a25dc48 | |||
|
23e60c9d5f | ||
e9563279d8 | |||
|
7ea4586f0e | ||
0694e097e6 | |||
|
91784d8e3e | ||
bfbbbb6d4d | |||
|
45d52a94b0 | ||
cc18c52d9c | |||
2e6b4fd607 | |||
|
88b5c447b7 | ||
|
1205105cd7 | ||
235521589f | |||
630ec46186 | |||
39a197ae7b | |||
cd9fed3a68 | |||
f45ad6fbed | |||
b1407af945 | |||
87e04b063f | |||
|
1dbed1c42c | ||
7cea12bcfa | |||
|
04106ce87f | ||
651e03633c | |||
|
cee96b242e | ||
3bade5d7d1 | |||
|
14123d9ce3 | ||
5abde1d8e1 | |||
|
91f6d63c87 | ||
867474d560 | |||
|
e4b0004d75 | ||
126c642cbd | |||
|
4966396a4d | ||
0bf23ef5c7 | |||
|
daf2c507ed | ||
1f9399519b | |||
|
f6654c0acc | ||
cbb61e2230 | |||
|
1aac669930 | ||
77dcb63104 | |||
|
e5cc1a0c9b | ||
3d28451e46 | |||
|
b01a903bd8 | ||
63fc46c833 | |||
|
7e92576bfc | ||
485ac49712 | |||
|
feaddfa0b2 | ||
0cf1e008ce | |||
|
37b592b714 | ||
207d114a5d | |||
|
ad4e9b6df4 | ||
c017c872ea | |||
|
372722187f | ||
c1bf1fb924 | |||
|
61cd2be7f7 | ||
24bae1de55 | |||
|
af30567b85 | ||
69456e848e | |||
|
d7c6a08b69 | ||
5c30b0614a | |||
|
23c2f502f1 | ||
6f96f0c7d4 | |||
|
9855924829 | ||
4eccd04a81 | |||
|
dc4a44548d | ||
743a6bed74 | |||
|
99be138cfa | ||
07c313a24b | |||
|
f581ae77e9 | ||
b357bff1cb | |||
|
b93f3bca54 | ||
d1dc39ef5e | |||
|
8367f56a62 | ||
068aefb87f | |||
|
52465bbe50 | ||
1aaba1d9e6 | |||
|
144a1d25dd | ||
ab469ff526 | |||
|
911006ad3f | ||
31d4e4258b | |||
|
eca92f6706 | ||
4db4793026 | |||
|
8f4cc4129d | ||
b75ab36c01 | |||
|
7fb5e00772 | ||
ba952d82f9 | |||
|
055b73e756 | ||
78eccae8ac | |||
|
fad1291880 | ||
1225212c42 | |||
|
dddbf4251c | ||
883150de44 | |||
|
165d2564b8 | ||
8a572c320a | |||
|
99f8f8445a | ||
758930bbf7 | |||
|
b977c26cfe | ||
94c80c48f5 | |||
|
abef7049cb | ||
99c658c695 | |||
|
937a6e5bf2 | ||
5cab50c6f3 | |||
|
b222eea3fc | ||
8715a4e9c5 | |||
|
3c515caae3 | ||
c30bc85120 | |||
|
06da1b76bf | ||
dfe9907744 | |||
|
03d68001ed | ||
49ecef45d0 | |||
|
743fdf4304 | ||
1970c3774a | |||
|
73843a7bb8 | ||
a2f2dae140 | |||
3a681c0a44 | |||
1ac8e27157 | |||
|
9a9900eb92 | ||
d3edd501cc | |||
|
c23bcd277d | ||
db385bf977 | |||
|
7dfcbeadc7 | ||
1d7394e5ec | |||
051f6a4b03 | |||
e8f1b532fa | |||
|
87aea1faf6 | ||
f3a27b45d7 | |||
|
89c0a2ca84 | ||
af230eedaa | |||
|
0d3862208b | ||
167c5474ea | |||
|
e2375ca5f8 | ||
0589b32aa6 | |||
a06d00210b | |||
8e2535206e | |||
dabd03f556 | |||
58ee36c932 | |||
d9e2467ba5 | |||
66ed0f5c51 | |||
|
f353e4205a | ||
c93b8a3801 | |||
|
d67a8ff62c | ||
2142e7eafa | |||
|
06360bf06c | ||
6aa88055d3 | |||
|
0eafb74578 | ||
dcdd35729f | |||
|
99aa2438ef | ||
e8fd4fc6ee | |||
|
edd8877cbf | ||
e9d1568021 | |||
|
f79baeb1e1 | ||
865598ec7f | |||
462c710295 | |||
7edac37e16 | |||
795c25c19c | |||
71cb15d007 | |||
d47c8c00f3 | |||
3d336d5693 | |||
bebbfec510 | |||
3f78d5118a | |||
79b9013707 | |||
4d9989b37b | |||
|
019dfb2977 | ||
5833a55c7f | |||
|
033cabffbe | ||
1f9a829980 | |||
|
d8e2c6d2e4 | ||
b98becfdf5 | |||
|
9ca6bf94f5 | ||
ab558fe339 | |||
|
9a55b56b7a | ||
91cfcd5324 | |||
|
852eb53874 | ||
918dab4039 | |||
|
557c7dd035 | ||
1bfe053be4 | |||
|
5ced88983a | ||
93307c77f2 | |||
|
e043073b9d | ||
9697f99b51 | |||
|
8cc934b9d9 | ||
2c8be468c9 | |||
|
5b7c26e2ad | ||
ec9aa65ad2 | |||
|
0980d40c3b | ||
cf13dbcc8e | |||
|
4f075494fa | ||
cee300fa74 | |||
|
8477c79b0a | ||
29f9adbf46 | |||
|
9667baf531 | ||
4868017d9b | |||
|
ecdf3f9ca6 | ||
cb03b20e48 | |||
|
a3f09c40fc | ||
8d25b8e789 | |||
|
33b14f83d6 | ||
b801c9e194 | |||
|
7abf8609d3 | ||
bc92424d45 | |||
|
5cb1003bc1 | ||
b74c156298 | |||
16c945b3a6 | |||
e62f68f514 | |||
447e72b16e | |||
cbfae0ae34 | |||
|
145fb478bc | ||
168922ce53 | |||
|
ba454f5b96 | ||
851aa4818e | |||
|
1835452a5b | ||
3aab2608d0 | |||
|
dbbed5757c | ||
78449eca84 | |||
|
72f4164793 | ||
deb23b4a50 | |||
eb82ff4ca5 | |||
9220981db3 | |||
f5b037265b | |||
6dc3803f51 | |||
9c62a5daff | |||
8397a81218 | |||
e2f81ac7d0 | |||
5a3aa824cd | |||
|
7a462124f6 | ||
5b0595e19d | |||
|
90e83d621e | ||
326c7a868f | |||
|
c192b3b7af | ||
e6e2c5d5e4 | |||
|
f75fcef77b | ||
a17101b751 | |||
|
f8f8dce9f9 | ||
c351da2508 | |||
|
e01d49a6b3 | ||
6618a819fe | |||
|
98815decbb | ||
15ec1b26ce | |||
|
fb804f585e | ||
3248c0479d | |||
|
3197ebebec | ||
fc0b2713a8 | |||
|
713c71be98 | ||
ce37a9d99c | |||
|
0e2e305496 | ||
e9845d27c3 | |||
e1731d2ed3 | |||
0700fb0cd2 | |||
|
e97f89b8d4 | ||
d44e606be4 | |||
|
cc5a843638 | ||
b1e0b467b1 | |||
|
11f15ad6b3 | ||
24d84fec10 | |||
|
71ee35cadd | ||
a80d7efd36 | |||
|
b26513ed98 | ||
92cc44ec75 | |||
|
1a3a7683e4 | ||
e4f8af0d1d | |||
|
aa20875389 | ||
d7258d0ee3 | |||
f2ad3a6626 | |||
86ac67698e | |||
e105887e3f | |||
|
ad4c2f542e | ||
eba9e4a53e | |||
|
3b107c6749 | ||
e208b7d86e | |||
|
59047d3f7e | ||
5fe01b7f10 | |||
|
84a1e4a391 | ||
d6bf66c3a5 | |||
|
a9ca46e179 | ||
421b58ab45 | |||
|
4073ca7679 | ||
eb9557baee | |||
|
b753e9fa5b | ||
19ee734b7c | |||
|
8f3ec493b4 | ||
ea6839d4d3 | |||
|
8eb852d497 | ||
21ce72720e | |||
|
061fad50f4 | ||
a7d0bdc32a | |||
|
06fb152c62 | ||
14c4f6908c | |||
57bd41febf | |||
8a56827b13 | |||
|
ffc6530588 | ||
98cf0582d0 | |||
|
ee0d7004b1 | ||
60251d6468 | |||
5f54517aa6 | |||
2ce58ace34 | |||
|
6ba8aff2ac | ||
483085e7be | |||
|
cf846d543e | ||
7431b701ca | |||
|
86ab27a456 | ||
3ed23353b9 | |||
|
1cb5ef6b6e | ||
63ab840c64 | |||
|
4cc86eac5e | ||
a8155e262c | |||
|
602d773758 | ||
bd1908587f | |||
|
3dc38022c7 | ||
57510e623e | |||
|
3d2a318b37 | ||
b938a13aeb | |||
|
aed8c30f17 | ||
ace1cd44bb | |||
|
231ddccc1d | ||
8b62387e90 | |||
|
0df1dfa856 | ||
7581a441ac | |||
|
df5c50204e | ||
0722e12ca5 | |||
|
c7e9bec046 | ||
55c81f5abe | |||
|
56335ed7f5 | ||
6698df6986 | |||
|
6caa34191c | ||
a69df7fff3 | |||
|
549288cc1f | ||
c277854bb5 | |||
|
45caf07cc4 | ||
ee27bdc006 | |||
|
d3b7abcf53 | ||
76ef558536 | |||
|
4fcd9e434e | ||
552c8c27a7 | |||
|
36bb5c0c7d | ||
54037c4514 | |||
7ee5bb00ba | |||
8d93a5ac7a | |||
|
65b246472b | ||
fcc14cef62 | |||
|
796f217370 | ||
f16e7bd6d7 | |||
|
aa68961849 | ||
b27e7c05bf | |||
|
a48afca310 | ||
3f1d1b2662 | |||
|
078520d484 | ||
d6345eb3e6 | |||
|
54ae83d281 | ||
54de5d84b5 | |||
|
ad26e55b02 | ||
32c4862b0c | |||
|
6fc2959369 | ||
40cd2f4a6e | |||
|
376e87ecd2 | ||
8566fda66b | |||
|
c546d57eaa | ||
f636e92db8 | |||
|
f074b4f120 | ||
2b2d720bcf | |||
|
0655cd9f62 | ||
b5a999ca32 | |||
|
67bd886d10 | ||
b2da0da3fe | |||
|
33aa86af08 | ||
7915c21a4c | |||
|
b8c5eca060 | ||
d0aafb94a9 | |||
58c5a7d443 | |||
92c0a517c2 | |||
5f285d8449 | |||
728147052d | |||
bdb69df52d | |||
f51a740858 | |||
|
5917eaaf88 | ||
0a0131e92e | |||
|
bfb5c5451b | ||
b2ee1e1516 | |||
|
2ef2d9458a | ||
1c2e6c5788 | |||
|
7da4dbcc95 | ||
5fb8a9153f | |||
2a3d3b8044 | |||
b862186a4f | |||
88e1246f8b | |||
52b1220068 | |||
ebfa7f7bf7 | |||
a13fe9d772 | |||
bcabf94741 | |||
8cfded9232 | |||
aedbb4b327 | |||
2b1090130f | |||
a0db33067c | |||
15719f74da | |||
|
409f589bf4 | ||
059f9795af | |||
|
e2a6326461 | ||
ab588d115a | |||
|
2b2c754ff8 | ||
e09fb364b9 | |||
|
5e48bfebb2 | ||
69214eb3b2 | |||
|
b37baa4e2b | ||
9e681111b7 | |||
|
d127a351dd | ||
7a0ecab3cc | |||
|
ee386c6ac5 | ||
5486a18c28 | |||
|
dde063113b | ||
ddb1d3df99 | |||
|
1c2cb89fef | ||
c6599ebfac | |||
|
8e866cef09 | ||
f403c4b118 | |||
|
2d51c7558a | ||
e59cfed48e | |||
|
84b3b6cc07 | ||
fd370d3b5e | |||
|
89219010bc | ||
aa082f8bb1 | |||
|
f96d7d679e | ||
b17ff5c7b8 | |||
|
2c17a19f06 | ||
906671353d | |||
|
11b900480c | ||
58f83590ce | |||
|
374c453595 | ||
3752aa0025 | |||
|
81391b86e7 | ||
0de0252795 | |||
|
e0dc3a966c | ||
6b64fe4942 | |||
|
0bbc38f36a | ||
5969b73d58 | |||
|
253765205e | ||
e6a7605d3b | |||
|
c2e4c2654f | ||
ea10992849 | |||
|
2390a3f67a | ||
852ab78095 | |||
|
7ba102ec82 | ||
703892b232 | |||
|
18f9254b70 | ||
75f064b204 | |||
|
60d37d5378 | ||
f6ac97af21 | |||
|
3e2301af2c | ||
0c9d284da1 | |||
|
9fe10bb614 | ||
9c9caf1041 | |||
|
cbe967e2cc | ||
0269fad741 | |||
|
b6a6b4ad77 | ||
a7a6655153 | |||
|
c932223c55 | ||
a10f86e736 | |||
|
63c1322ab6 | ||
5c2498a887 | |||
|
949516ef57 | ||
7fe641b775 | |||
|
c1850e3037 | ||
ff83b3ce05 | |||
|
3ce396c322 | ||
ea911386fa | |||
|
e45f45a7a1 | ||
2c5678834c | |||
|
c46c9af7b4 | ||
ca0a16457a | |||
|
0ef94ddc44 | ||
0e30926742 | |||
|
5eb9ab1d85 | ||
a6d996b74b | |||
|
0914ea9a56 | ||
e6592946f3 | |||
|
c90a922535 | ||
edb29af115 | |||
|
d286344c51 | ||
09ea77c5a3 | |||
|
fd18dfabb3 | ||
c1b931bf97 | |||
|
682640d8f6 | ||
2a89a44a40 | |||
0658c25927 | |||
ac1d7cb607 | |||
|
f56157e8df | ||
1e4bad4134 | |||
|
1e04187c7b | ||
224f418bcf | |||
|
b07458f40f | ||
59dd62b33a | |||
|
d3f3081947 | ||
c88628d360 | |||
|
8791e714a5 | ||
2626cae6dc | |||
|
cf57d95ccf | ||
28ecee6485 | |||
|
69d5e663b1 | ||
413a919f92 | |||
|
cb8ea52d04 | ||
a7b7f43fe3 | |||
|
0bda2f4c13 | ||
8dc70c1345 | |||
|
afd09d40b0 | ||
58a2fbf8dc | |||
|
64f6f4954e | ||
026ee5dca7 | |||
|
099a5badb5 | ||
8b3ffa754b | |||
|
834fc88e4f | ||
07f76db555 | |||
|
cc8530c698 | ||
457722af40 | |||
|
f89223eb21 | ||
270f758a5e | |||
|
2dba925abe | ||
383c28c741 | |||
|
e4ae3368b8 | ||
bfec12b570 | |||
|
ae00199d99 | ||
27463b1727 | |||
|
4c1475b6e5 | ||
ae806be7d7 | |||
9743ba8eed | |||
16b120bc73 | |||
c4d7dc31d5 | |||
cee9d77b50 | |||
9256aae89d | |||
af20594968 | |||
8444634fc7 | |||
0ef99c53d2 | |||
6d6e719f52 | |||
672e724784 | |||
c64f1720be | |||
86051dddc0 | |||
1338ce8714 | |||
cd254b47fd | |||
|
cd5fe1af1f | ||
|
a4acfd0352 | ||
|
d42d07c6ac | ||
7bc3854246 | |||
|
1ad0859007 | ||
184b5a18fb | |||
|
d873e15572 | ||
90edd9a270 | |||
|
1cc9e2e92b | ||
5a4fc79b0c | |||
|
4c701e405e | ||
3f53a7cfe7 | |||
|
ffab2260c2 | ||
fe6b5c1c3f | |||
|
82c92810ea | ||
b22580a068 | |||
|
9c51c66576 | ||
38a752d9c8 | |||
|
78eed45412 | ||
3791920f41 | |||
|
f33609e01e | ||
eee9c63cd3 | |||
|
7ffd23d344 | ||
3d5cd5ad81 | |||
|
219fc29080 | ||
6dec78728c | |||
|
ac2f219f6f | ||
7a8807e1c2 | |||
556802c6e7 | |||
b59cea9a5e | |||
4cb246aad2 | |||
0794c8a754 | |||
|
aa86718f15 | ||
c080700cee | |||
|
5e8e60314e | ||
a8a0147fa7 | |||
|
a7e50bd069 | ||
47d86b2cb9 | |||
|
467d1a5bd1 | ||
52e8c5dd91 | |||
|
2cd838a820 | ||
a39745525d | |||
|
6a4423a90b | ||
948c09d636 | |||
|
8de20a1807 | ||
e057feaec2 | |||
|
7332eaffe6 | ||
a1e7fe1662 | |||
447268b417 | |||
f2c8f04c2f | |||
bdbcaa55ea | |||
f38235561f | |||
c410e344a0 | |||
45c71bbb47 | |||
0d393bd172 | |||
|
d9b4fe834d | ||
ceb63bb78d | |||
|
61f6b02978 | ||
6c0cbf6afd | |||
|
9a2ae85058 | ||
81b2282d25 | |||
|
aeb8501c0c | ||
3b8cc29f65 | |||
|
1bce889285 | ||
723a2ec7f7 | |||
|
2c08426edc | ||
cb2a25be9a | |||
a8b3dffddb | |||
1d2d1abf0f | |||
|
4c2aea21ee | ||
a7cb1896f9 | |||
|
3b00d230a1 | ||
d642298b13 | |||
|
b8969e4e78 | ||
e97c4c88f2 | |||
|
d9ccf86c46 | ||
22d7bd5360 | |||
|
e0eb79df88 | ||
fda41bbc02 | |||
|
d788d4c5aa | ||
2236864200 | |||
|
5815c0b05a | ||
9346e812e7 | |||
|
cce1813122 | ||
5a9b3b93c2 | |||
|
401794177d | ||
ed36809d1b | |||
|
945fee8c8a | ||
a1776a5da8 | |||
|
10040984e4 | ||
3ab764c2e3 | |||
|
5fb94666cb | ||
4e4bb4b012 | |||
|
69ff7e55de | ||
a2397293de | |||
|
8a25e8c474 | ||
71cb729cb8 | |||
|
48f8f25f04 | ||
c5d9193cc3 | |||
|
2533cb2cef | ||
cf58e974a8 | |||
|
9379ed8a13 | ||
18a7575f06 | |||
|
550025e642 | ||
bd36e7d92d | |||
6c43363c78 | |||
4bea97df0c | |||
44518e6e51 | |||
|
c4830c7e10 | ||
e5732fe460 | |||
33acf33be9 | |||
16d711b874 | |||
|
db95ab31d7 | ||
159c6f8b37 | |||
|
7af6573d2c | ||
62a91056c9 | |||
|
e6746cb052 | ||
28f8112d68 | |||
|
17d13e8b41 | ||
0d0deb5114 | |||
|
b49fa778ee | ||
7c7e0a0981 | |||
47e847d100 | |||
f060f52520 | |||
|
4088d20f9e | ||
28a975fdde | |||
|
6ed51cf68e | ||
a7689865ba | |||
ca6205d2a6 | |||
5eed665801 | |||
cfca6a1de5 | |||
a8de52077f | |||
|
2451220a8a | ||
495fa00082 | |||
8a83d9b565 | |||
3f4634710c | |||
5f82c82818 | |||
|
31643a64ea | ||
74e04a604c | |||
|
99dea2e735 | ||
c0c05c102b | |||
953f98a389 | |||
41df88bdde | |||
0ea6149c70 | |||
12d02454bc | |||
1fc2844b04 | |||
|
d671f502ef | ||
e8d14992d9 | |||
42f0fa2238 | |||
84efc8a3da | |||
|
30c1bb5385 | ||
49418f6c71 | |||
|
7e4598445b | ||
7780b0391f | |||
|
e52a472526 | ||
dd3e9a2818 | |||
6c28f75678 | |||
027eccfad8 | |||
07cf1afc1c | |||
d058a1db2a | |||
096b4db322 | |||
a4fa8ca433 | |||
|
059c4432f7 | ||
fb9a45b14d | |||
|
ccd04c24d1 | ||
6e5c8fd615 | |||
|
f2c7d897af | ||
ea9b30791c | |||
|
6f2b978839 | ||
64b61acc87 | |||
|
54fb2254bd | ||
3270bfed7f | |||
ec264a9d4e | |||
4f4f7769da | |||
9fcd16ec16 | |||
8ad225c8f6 | |||
|
07b0b26e98 | ||
ad4a605620 | |||
|
dec9fb3bad | ||
74b02127c5 | |||
|
9d5376f6ff | ||
4733776ccd | |||
|
b57df386ff | ||
b65dba2490 | |||
|
c52adff965 | ||
1df65dc542 | |||
|
c52875bcce | ||
c4bb1e92ea | |||
|
2316af7820 | ||
13afa36105 | |||
6f6abae258 | |||
206586462d | |||
|
3e774ad091 | ||
62118570c7 | |||
|
6d386023ba | ||
0c604bdc24 | |||
|
cb09a9eb76 | ||
e86d163542 | |||
|
72a6d2710d | ||
5da8568ca4 | |||
|
86cde5012d | ||
accf4d6a49 | |||
|
89defd2591 | ||
768dd47cc5 | |||
|
29241f4751 | ||
ff9b96677e | |||
|
64608e3b8b | ||
0018200596 | |||
|
119019b4b1 | ||
76e49e9b77 | |||
faeceea995 | |||
72cb4fd7eb | |||
ffe90b9399 | |||
|
fcc289358b | ||
e2c6d6b8ec | |||
|
f74c6ca28e | ||
26ec5ac98d | |||
|
022b96bcbc | ||
12ffc227a5 | |||
c95d7ed58d | |||
d801e6f3db | |||
c9106b5b8b | |||
def69f4038 | |||
|
2f0d381ee2 | ||
1bf0667f08 | |||
|
718b43b3e5 | ||
70d7765889 | |||
ffb4aa5c1e | |||
271d50db53 | |||
|
342bbaf6e0 | ||
66257e7e9b | |||
976929e9b9 | |||
1d85c4c8cf | |||
0ddec78d09 | |||
ea8395a651 | |||
7cd9956b92 | |||
|
0cca0e78e1 | ||
64c4448baa | |||
|
8dd94033d8 | ||
8f85a80fd4 | |||
|
b52c470cfc | ||
54e003e816 | |||
|
caf439db92 | ||
aa11a827e4 | |||
|
851234c0c5 | ||
35802600d8 | |||
|
181c41a5e4 | ||
862643de5f | |||
|
ab6435c5a7 | ||
9ceee89c32 | |||
|
cca7201302 | ||
aa652d2e06 | |||
e9fd898469 | |||
91b7baa8d6 | |||
4a0bc6005a | |||
8d781b7009 | |||
|
d275c9c42e | ||
589ae03db5 | |||
|
9d512195fc | ||
d14666dac5 | |||
|
705669fcaa | ||
f73c920087 | |||
|
c5da06f4bf | ||
3c8997a0bd | |||
|
260b43cee2 | ||
592237483b | |||
|
11292da6da | ||
a370d65ab1 | |||
|
14a4f974b2 | ||
e996f5f59b | |||
|
9df1620c94 | ||
7215869d0b | |||
|
90614d0202 | ||
746b33b7e8 | |||
|
4a9b6268c6 | ||
7fce642951 | |||
|
58bf8e4abd | ||
c3f9df0fe7 | |||
|
81da306ef7 | ||
bda8c72011 | |||
|
26acce62ba | ||
66666fe732 | |||
|
aa29a3849e | ||
dcab593b98 | |||
|
aea4b9cc7c | ||
ebf69d8dc1 | |||
|
2838d520ac | ||
7438cad46c | |||
|
e197d2b000 | ||
64f82c42aa | |||
|
65926c20de | ||
4e55b4541d | |||
|
01fb8bbf7d | ||
bdb3470251 | |||
|
a936b3d595 | ||
dfd8bceca3 | |||
|
e620bb32b0 | ||
5abad0d64c | |||
|
e439c89cd5 | ||
54a3591e57 | |||
|
b5dd81a254 | ||
ba6d74b401 | |||
c3c395c659 | |||
b8608a3f57 | |||
ff6d8ae3eb | |||
e456f688a3 | |||
b93a8587a3 | |||
|
0bf3f5f0f9 | ||
d85d1f4754 | |||
|
3d65186084 | ||
b2635b5066 | |||
|
6826c6037c | ||
cb8f40b6da | |||
|
7383ca9f27 | ||
393dda2fcc | |||
|
bcadad04d3 | ||
622f57c0a0 | |||
|
ce27826e20 | ||
99fd129e76 | |||
|
15d2e05d7c | ||
67eb4e76fc | |||
|
682d515aee | ||
8b6cf4a2da | |||
|
c20e594c16 | ||
478b8bd24b | |||
|
5df314d5e3 | ||
ed64efc8ed | |||
|
839492e843 | ||
db547e4b2d | |||
|
8a1468017a | ||
b8c72e7904 | |||
|
446902a37e | ||
0de3bdd2f0 | |||
|
7bb0f4dbc2 | ||
98f9cd0464 | |||
|
826a6591ef | ||
828f682ba5 | |||
|
e355b0e087 | ||
3baefc0054 | |||
|
e5e7db252e | ||
d2bb2c5dde | |||
7affa43ea8 | |||
18fb386082 | |||
87aca4864c | |||
bb01d22562 | |||
|
6d337f9983 | ||
3ab5018a89 | |||
|
6089082605 | ||
b0601ee814 | |||
|
cc1c039831 | ||
1ee79b4ca5 | |||
|
ff6ad5b4cb | ||
d7eb5b599a | |||
|
09ba5f8c4b | ||
96db82925e | |||
|
ad2d2029c3 | ||
2804fe4de3 | |||
|
5354e94037 | ||
818064cbe8 | |||
|
58c4fd79fd | ||
5c8a7c529d | |||
|
14e588d353 | ||
f1124d8260 | |||
|
720a00cfbb | ||
1f552a2f0e | |||
|
79b155bab5 | ||
10c459208e | |||
|
e3e72edbcc | ||
b9294deb93 | |||
|
29584be256 | ||
8c0e412148 | |||
|
cc29af0c86 | ||
b4d55228f4 | |||
|
b24e5bce19 | ||
74af62106e | |||
|
b1744e77f0 | ||
c1ab00d4eb | |||
|
39bf05537c | ||
1dae5ae8b5 | |||
|
0c9144af7f | ||
2d69b6925a | |||
|
ae411c4c8b | ||
674acce23e | |||
ca6be34a66 | |||
|
422aa33189 | ||
|
7c8ae13575 | ||
a9c5ba7f78 | |||
|
e722ac3202 | ||
508fb5d65b | |||
|
13727b2f36 | ||
6c85e12afa | |||
c4c7514316 | |||
903ebf56eb | |||
|
6e6b853112 | ||
226e81bf53 | |||
|
7a72f73494 | ||
c11038bace | |||
|
c5c502d9a9 | ||
4258cefeb1 | |||
|
ebc34f1419 | ||
15b41846f0 | |||
|
93b35fae6d | ||
3b6e62b35e | |||
289d64a60d | |||
56961bce2f | |||
349bf27d7a | |||
1af4c1c201 | |||
d504cb0e90 | |||
3ec6f9abf1 | |||
80c07b37a9 | |||
5ff91965ad | |||
|
2e29e5950d | ||
8cfaabd7ec | |||
|
72d6ec6f04 | ||
1727532d85 | |||
|
3e9904fb40 | ||
8961134966 | |||
|
ad17d364f4 | ||
cfe129cd11 | |||
|
504a22bd47 | ||
cc290aa7a5 | |||
|
88cd7635f7 | ||
04064f3a2b | |||
26cd021a25 | |||
0edf1a0421 | |||
a0954bc936 |
410 changed files with 15475 additions and 24572 deletions
|
@ -1,21 +1,21 @@
|
|||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
# Tab indentation
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
tab_width = 4
|
||||
|
||||
[yml]
|
||||
[*.{js,css}]
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
APP_ENV=testing
|
||||
APP_DEBUG=true
|
||||
APP_KEY=base64:6DJhvZLVjE6dD4Cqrteh+6Z5vZlG+v/soCKcDHLOAH0=
|
||||
APP_URL=http://localhost:8000
|
||||
APP_LONGURL=localhost
|
||||
APP_SHORTURL=local
|
||||
|
||||
DB_CONNECTION=travis
|
||||
|
||||
CACHE_DRIVER=array
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
SCOUT_DRIVER=pgsql
|
102
.env.example
102
.env.example
|
@ -1,68 +1,90 @@
|
|||
APP_NAME=Laravel
|
||||
APP_ENV=production
|
||||
APP_KEY=SomeRandomString # Leave this
|
||||
APP_DEBUG=false
|
||||
APP_LOG_LEVEL=warning
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_TIMEZONE=UTC
|
||||
APP_URL=https://example.com
|
||||
|
||||
DB_CONNECTION=pgsql
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=5432
|
||||
DB_DATABASE=
|
||||
DB_USERNAME=
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=laravel
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
SESSION_DOMAIN=null
|
||||
|
||||
BROADCAST_CONNECTION=log
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_CLIENT=phpredis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=smtp.mailtrap.io
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
AWS_S3_KEY=your-key
|
||||
AWS_S3_SECRET=your-secret
|
||||
AWS_S3_REGION=region
|
||||
AWS_S3_BUCKET=your-bucket
|
||||
AWS_S3_URL=https://xxxxxxx.s3-region.amazonaws.com
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
|
||||
APP_URL=https://example.com # This one is necessary
|
||||
APP_LONGURL=example.com
|
||||
APP_SHORTURL=examp.le
|
||||
|
||||
ADMIN_USER=admin # pick something better, this is used for `/admin`
|
||||
ADMIN_USER=admin# pick something better, this is used for `/admin`
|
||||
ADMIN_PASS=password
|
||||
DISPLAY_NAME='Joe Bloggs' # This is used for example in the header and titles
|
||||
DISPLAY_NAME='Joe Bloggs'# This is used for example in the header and titles
|
||||
|
||||
TWITTER_CONSUMER_KEY=
|
||||
TWITTER_CONSUMER_SECRET=
|
||||
TWITTER_ACCESS_TOKEN=
|
||||
TWITTER_ACCESS_TOKEN_SECRET=
|
||||
|
||||
SCOUT_DRIVER=pgsql
|
||||
SCOUT_DRIVER=database
|
||||
SCOUT_QUEUE=false
|
||||
|
||||
PIWIK=false
|
||||
PIWIK_ID=1
|
||||
PIWIK_URL=https://analytics.jmb.lv/piwik.php
|
||||
|
||||
FATHOM_ID=
|
||||
|
||||
APP_TIMEZONE=UTC
|
||||
APP_LANG=en
|
||||
APP_LOG=daily
|
||||
SECURE_SESSION_COOKIE=true
|
||||
SESSION_SECURE_COOKIE=true
|
||||
SESSION_SAME_SITE=strict
|
||||
|
||||
LOG_SLACK_WEBHOOK_URL=
|
||||
|
||||
FONT_LINK=
|
||||
FLARE_KEY=
|
||||
|
||||
IGNITION_OPEN_AI_KEY=
|
||||
|
||||
BRIDGY_MASTODON_TOKEN=
|
||||
|
|
66
.env.github
66
.env.github
|
@ -1,66 +0,0 @@
|
|||
APP_NAME=Laravel
|
||||
APP_ENV=testing
|
||||
APP_KEY=SomeRandomString # Leave this
|
||||
APP_DEBUG=false
|
||||
APP_LOG_LEVEL=warning
|
||||
|
||||
DB_CONNECTION=pgsql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=5432
|
||||
DB_DATABASE=jbukdev_testing
|
||||
DB_USERNAME=postgres
|
||||
DB_PASSWORD=postgres
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=smtp.mailtrap.io
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
|
||||
AWS_S3_KEY=your-key
|
||||
AWS_S3_SECRET=your-secret
|
||||
AWS_S3_REGION=region
|
||||
AWS_S3_BUCKET=your-bucket
|
||||
AWS_S3_URL=https://xxxxxxx.s3-region.amazonaws.com
|
||||
|
||||
APP_URL=https://example.com # This one is necessary
|
||||
APP_LONGURL=example.com
|
||||
APP_SHORTURL=examp.le
|
||||
|
||||
ADMIN_USER=admin # pick something better, this is used for `/admin`
|
||||
ADMIN_PASS=password
|
||||
DISPLAY_NAME="Joe Bloggs" # This is used for example in the header and titles
|
||||
|
||||
TWITTER_CONSUMER_KEY=
|
||||
TWITTER_CONSUMER_SECRET=
|
||||
TWITTER_ACCESS_TOKEN=
|
||||
TWITTER_ACCESS_TOKEN_SECRET=
|
||||
|
||||
SCOUT_DRIVER=pgsql
|
||||
|
||||
PIWIK=false
|
||||
|
||||
FATHOM_ID=
|
||||
|
||||
APP_TIMEZONE=UTC
|
||||
APP_LANG=en
|
||||
APP_LOG=daily
|
||||
SECURE_SESSION_COOKIE=true
|
||||
|
||||
LOG_SLACK_WEBHOOK_URL=
|
||||
|
||||
FONT_LINK=
|
|
@ -1,24 +0,0 @@
|
|||
parserOptions:
|
||||
sourceType: 'module'
|
||||
extends: 'eslint:recommended'
|
||||
env:
|
||||
browser: true
|
||||
es6: true
|
||||
rules:
|
||||
indent:
|
||||
- error
|
||||
- 4
|
||||
linebreak-style:
|
||||
- error
|
||||
- unix
|
||||
quotes:
|
||||
- error
|
||||
- single
|
||||
semi:
|
||||
- error
|
||||
- always
|
||||
no-console:
|
||||
- error
|
||||
- allow:
|
||||
- warn
|
||||
- error
|
12
.gitattributes
vendored
12
.gitattributes
vendored
|
@ -1,5 +1,7 @@
|
|||
* text=auto
|
||||
*.css linguist-vendored
|
||||
*.scss linguist-vendored
|
||||
*.js linguist-vendored
|
||||
CHANGELOG.md export-ignore
|
||||
* text=auto eol=lf
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
|
12
.github/dependabot.yml
vendored
12
.github/dependabot.yml
vendored
|
@ -1,12 +0,0 @@
|
|||
version: 2
|
||||
|
||||
updates:
|
||||
- package-ecosystem: "composer"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
142
.github/workflows/deploy.yml
vendored
142
.github/workflows/deploy.yml
vendored
|
@ -1,142 +0,0 @@
|
|||
name: Deploy
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy
|
||||
runs-on: ubuntu-latest
|
||||
environment: Hetzner
|
||||
env:
|
||||
repository: 'jonnybarnes/jonnybarnes.uk'
|
||||
newReleaseName: '${{ github.run_id }}'
|
||||
|
||||
steps:
|
||||
- name: 🌍 Set Environment Variables
|
||||
run: |
|
||||
echo "releasesDir=${{ secrets.DEPLOYMENT_BASE_DIR }}/releases" >> $GITHUB_ENV
|
||||
echo "persistentDir=${{ secrets.DEPLOYMENT_BASE_DIR }}/persistent" >> $GITHUB_ENV
|
||||
echo "currentDir=${{ secrets.DEPLOYMENT_BASE_DIR }}/current" >> $GITHUB_ENV
|
||||
- name: 🌎 Set Environment Variables Part 2
|
||||
run: |
|
||||
echo "newReleaseDir=${{ env.releasesDir }}/${{ env.newReleaseName }}" >> $GITHUB_ENV
|
||||
- name: 🔄 Clone Repository
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.DEPLOYMENT_HOST }}
|
||||
port: ${{ secrets.DEPLOYMENT_PORT }}
|
||||
username: ${{ secrets.DEPLOYMENT_USER }}
|
||||
key: ${{ secrets.DEPLOYMENT_KEY }}
|
||||
script: |
|
||||
[ -d ${{ env.releasesDir }} ] || mkdir ${{ env.releasesDir }}
|
||||
[ -d ${{ env.persistentDir }} ] || mkdir ${{ env.persistentDir }}
|
||||
[ -d ${{ env.persistentDir }}/storage ] || mkdir ${{ env.persistentDir }}/storage
|
||||
|
||||
cd ${{ env.releasesDir }}
|
||||
|
||||
# Create new release directory
|
||||
mkdir ${{ env.newReleaseDir }}
|
||||
|
||||
# Clone app
|
||||
git clone --depth 1 --branch ${{ github.ref_name }} https://github.com/${{ env.repository }} ${{ env.newReleaseName }}
|
||||
|
||||
# Mark release
|
||||
cd ${{ env.newReleaseDir }}
|
||||
echo "${{ env.newReleaseName }}" > public/release-name.txt
|
||||
|
||||
# Fix cache directory permissions
|
||||
sudo chown -R ${{ secrets.HTTP_USER }}:${{ secrets.HTTP_USER }} bootstrap/cache
|
||||
|
||||
- name: 🎵 Run Composer
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.DEPLOYMENT_HOST }}
|
||||
port: ${{ secrets.DEPLOYMENT_PORT }}
|
||||
username: ${{ secrets.DEPLOYMENT_USER }}
|
||||
key: ${{ secrets.DEPLOYMENT_KEY }}
|
||||
script: |
|
||||
cd ${{ env.newReleaseDir }}
|
||||
composer install --prefer-dist --no-scripts --no-dev --no-progress --optimize-autoloader --quiet --no-interaction
|
||||
|
||||
- name: 🔗 Update Symlinks
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.DEPLOYMENT_HOST }}
|
||||
port: ${{ secrets.DEPLOYMENT_PORT }}
|
||||
username: ${{ secrets.DEPLOYMENT_USER }}
|
||||
key: ${{ secrets.DEPLOYMENT_KEY }}
|
||||
script: |
|
||||
# Import the environment config
|
||||
cd ${{ env.newReleaseDir }};
|
||||
ln -nfs ${{ secrets.DEPLOYMENT_BASE_DIR }}/.env .env;
|
||||
|
||||
# Remove the storage directory and replace with persistent data
|
||||
rm -rf ${{ env.newReleaseDir }}/storage;
|
||||
cd ${{ env.newReleaseDir }};
|
||||
ln -nfs ${{ secrets.DEPLOYMENT_BASE_DIR }}/persistent/storage storage;
|
||||
|
||||
# Remove the public/profile-images directory and replace with persistent data
|
||||
rm -rf ${{ env.newReleaseDir }}/public/assets/profile-images;
|
||||
cd ${{ env.newReleaseDir }};
|
||||
ln -nfs ${{ secrets.DEPLOYMENT_BASE_DIR }}/persistent/profile-images public/assets/profile-images;
|
||||
|
||||
# Add the persistent files data
|
||||
cd ${{ env.newReleaseDir }};
|
||||
ln -nfs ${{ secrets.DEPLOYMENT_BASE_DIR }}/persistent/files public/files;
|
||||
|
||||
# Add the persistent fonts data
|
||||
cd ${{ env.newReleaseDir }};
|
||||
ln -nfs ${{ secrets.DEPLOYMENT_BASE_DIR }}/persistent/fonts public/fonts;
|
||||
|
||||
- name: ✨ Optimize Installation
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.DEPLOYMENT_HOST }}
|
||||
port: ${{ secrets.DEPLOYMENT_PORT }}
|
||||
username: ${{ secrets.DEPLOYMENT_USER }}
|
||||
key: ${{ secrets.DEPLOYMENT_KEY }}
|
||||
script: |
|
||||
cd ${{ env.newReleaseDir }};
|
||||
sudo runuser -u ${{ secrets.HTTP_USER }} -- php artisan clear-compiled;
|
||||
|
||||
- name: 🙈 Migrate database
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.DEPLOYMENT_HOST }}
|
||||
port: ${{ secrets.DEPLOYMENT_PORT }}
|
||||
username: ${{ secrets.DEPLOYMENT_USER }}
|
||||
key: ${{ secrets.DEPLOYMENT_KEY }}
|
||||
script: |
|
||||
cd ${{ env.newReleaseDir }}
|
||||
sudo runuser -u ${{ secrets.HTTP_USER }} -- php artisan migrate --force
|
||||
|
||||
- name: 🙏 Bless release
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.DEPLOYMENT_HOST }}
|
||||
port: ${{ secrets.DEPLOYMENT_PORT }}
|
||||
username: ${{ secrets.DEPLOYMENT_USER }}
|
||||
key: ${{ secrets.DEPLOYMENT_KEY }}
|
||||
script: |
|
||||
ln -nfs ${{ env.newReleaseDir }} ${{ env.currentDir }};
|
||||
cd ${{ env.newReleaseDir }}
|
||||
sudo runuser -u ${{ secrets.HTTP_USER }} -- php artisan horizon:terminate
|
||||
sudo runuser -u ${{ secrets.HTTP_USER }} -- php artisan config:cache
|
||||
sudo runuser -u ${{ secrets.HTTP_USER }} -- php artisan event:cache
|
||||
sudo runuser -u ${{ secrets.HTTP_USER }} -- php artisan route:cache
|
||||
sudo runuser -u ${{ secrets.HTTP_USER }} -- php artisan view:cache
|
||||
|
||||
sudo systemctl restart php-fpm.service
|
||||
sudo systemctl restart jbuk-horizon.service
|
||||
|
||||
- name: 🚾 Clean up old releases
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: ${{ secrets.DEPLOYMENT_HOST }}
|
||||
port: ${{ secrets.DEPLOYMENT_PORT }}
|
||||
username: ${{ secrets.DEPLOYMENT_USER }}
|
||||
key: ${{ secrets.DEPLOYMENT_KEY }}
|
||||
script: |
|
||||
fd '.+' ${{ env.releasesDir }} -d 1 | head -n -3 | xargs -d "\n" -I'{}' sudo chown -R ${{ secrets.DEPLOYMENT_USER }}:${{ secrets.DEPLOYMENT_USER }} {}/bootstrap/cache;
|
||||
fd '.+' ${{ env.releasesDir }} -d 1 | head -n -3 | xargs -d "\n" -I'{}' rm -rf {};
|
68
.github/workflows/phpunit.yml
vendored
68
.github/workflows/phpunit.yml
vendored
|
@ -1,68 +0,0 @@
|
|||
name: PHP Unit
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
phpunit:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: PHPUnit test suite
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:latest
|
||||
env:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: jbukdev_testing
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Node and dependencies
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
|
||||
- name: Setup PHP with pecl extensions
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.1'
|
||||
extensions: phpredis,imagick
|
||||
|
||||
- name: Copy .env
|
||||
run: php -r "file_exists('.env') || copy('.env.github', '.env');"
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
id: composer-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-composer-
|
||||
|
||||
- name: Install Composer Dependencies
|
||||
run: composer install --quiet --no-ansi --no-interaction --no-progress
|
||||
|
||||
- name: Generate Key
|
||||
run: php artisan key:generate
|
||||
|
||||
- name: Setup Directory Permissions
|
||||
run: chmod -R 777 storage bootstrap/cache
|
||||
|
||||
- name: Setup Database
|
||||
run: php artisan migrate
|
||||
|
||||
- name: Execute PHPUnit Tests
|
||||
run: vendor/bin/phpunit
|
38
.github/workflows/pint.yml
vendored
38
.github/workflows/pint.yml
vendored
|
@ -1,38 +0,0 @@
|
|||
name: Laravel Pint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
pint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: Laravel Pint
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup PHP with pecl extensions
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.1'
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
id: composer-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-composer-
|
||||
|
||||
- name: Install Composer Dependencies
|
||||
run: composer install --quiet --no-ansi --no-interaction --no-progress
|
||||
|
||||
- name: Check Files with Laravel Pint
|
||||
run: vendor/bin/pint --test
|
25
.gitignore
vendored
25
.gitignore
vendored
|
@ -1,21 +1,24 @@
|
|||
/.phpunit.cache
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/coverage
|
||||
/public/hot
|
||||
/public/files
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/vendor
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpunit.result.cache
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
auth.json
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
/.fleet
|
||||
/.idea
|
||||
/lsp
|
||||
.phpstorm.meta.php
|
||||
_ide_helper.php
|
||||
# Custom paths in /public
|
||||
/public/coverage
|
||||
/public/hot
|
||||
/public/storage
|
||||
/public/fonts
|
||||
/public/files
|
||||
/public/keybase.txt
|
||||
/public/assets/*.map
|
||||
/.vscode
|
||||
ray.php
|
||||
/public/gpg.key
|
||||
/public/assets/img/favicon.png
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
preset: laravel
|
||||
|
||||
disabled:
|
||||
- concat_without_spaces
|
||||
- single_import_per_statement
|
||||
|
||||
finder:
|
||||
path: app/
|
|
@ -1,6 +1,3 @@
|
|||
{
|
||||
"extends": ["stylelint-config-standard"],
|
||||
"rules": {
|
||||
"indentation": 4
|
||||
}
|
||||
"extends": ["stylelint-config-standard"]
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use League\CommonMark\Extension\Mention\Generator\MentionGeneratorInterface;
|
|||
use League\CommonMark\Extension\Mention\Mention;
|
||||
use League\CommonMark\Node\Inline\AbstractInline;
|
||||
|
||||
class ContactMentionGenerator implements MentionGeneratorInterface
|
||||
class MentionGenerator implements MentionGeneratorInterface
|
||||
{
|
||||
public function generateMention(Mention $mention): ?AbstractInline
|
||||
{
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\CommonMark\Renderers;
|
||||
|
||||
use App\Models\Contact;
|
||||
use League\CommonMark\Node\Node;
|
||||
use League\CommonMark\Renderer\ChildNodeRendererInterface;
|
||||
use League\CommonMark\Renderer\NodeRendererInterface;
|
||||
|
||||
class ContactMentionRenderer implements NodeRendererInterface
|
||||
{
|
||||
public function render(Node $node, ChildNodeRendererInterface $childRenderer): string
|
||||
{
|
||||
$contact = Contact::where('nick', $node->getIdentifier())->first();
|
||||
|
||||
if ($contact === null) {
|
||||
return '<a href="https://twitter.com/' . $node->getIdentifier() . '">@' . $node->getIdentifier() . '</a>';
|
||||
}
|
||||
|
||||
return trim(view('templates.mini-hcard', ['contact' => $contact])->render());
|
||||
}
|
||||
}
|
37
app/CommonMark/Renderers/MentionRenderer.php
Normal file
37
app/CommonMark/Renderers/MentionRenderer.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\CommonMark\Renderers;
|
||||
|
||||
use App\Models\Contact;
|
||||
use League\CommonMark\Node\Node;
|
||||
use League\CommonMark\Renderer\ChildNodeRendererInterface;
|
||||
use League\CommonMark\Renderer\NodeRendererInterface;
|
||||
use League\CommonMark\Util\HtmlElement;
|
||||
|
||||
class MentionRenderer implements NodeRendererInterface
|
||||
{
|
||||
public function render(Node $node, ChildNodeRendererInterface $childRenderer): HtmlElement|string
|
||||
{
|
||||
$contact = Contact::where('nick', $node->getIdentifier())->first();
|
||||
|
||||
// If we have a contact, render a mini-hcard
|
||||
if ($contact) {
|
||||
// rendering a blade template to a string, so can’t be an HtmlElement
|
||||
return trim(view('templates.mini-hcard', ['contact' => $contact])->render());
|
||||
}
|
||||
|
||||
// Otherwise, check the link is to the Mastodon profile
|
||||
$mentionText = $node->getIdentifier();
|
||||
$parts = explode('@', $mentionText);
|
||||
|
||||
// This is not [@]handle@instance, so return a Twitter link
|
||||
if (count($parts) === 1) {
|
||||
return new HtmlElement('a', ['href' => 'https://twitter.com/' . $parts[0]], '@' . $mentionText);
|
||||
}
|
||||
|
||||
// Render the Mastodon profile link
|
||||
return new HtmlElement('a', ['href' => 'https://' . $parts[1] . '/@' . $parts[0]], '@' . $mentionText);
|
||||
}
|
||||
}
|
69
app/Console/Commands/CopyMediaToLocal.php
Normal file
69
app/Console/Commands/CopyMediaToLocal.php
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Media;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class CopyMediaToLocal extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:copy-media-to-local';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Copy any historic media saved to S3 to the local filesystem';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// Load all the Media records
|
||||
$media = Media::all();
|
||||
|
||||
// Loop through each media record and copy the file from S3 to the local filesystem
|
||||
foreach ($media as $mediaItem) {
|
||||
$filename = $mediaItem->path;
|
||||
|
||||
$this->info('Processing: ' . $filename);
|
||||
|
||||
// If the file is already saved locally skip to next one
|
||||
if (Storage::disk('local')->exists('public/' . $filename)) {
|
||||
$this->info('File already exists locally, skipping');
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Copy the file from S3 to the local filesystem
|
||||
if (! Storage::disk('s3')->exists($filename)) {
|
||||
$this->error('File does not exist on S3');
|
||||
|
||||
continue;
|
||||
}
|
||||
$contents = Storage::disk('s3')->get($filename);
|
||||
Storage::disk('local')->put('public/' . $filename, $contents);
|
||||
|
||||
// Copy -medium and -small versions if they exist
|
||||
$filenameParts = explode('.', $filename);
|
||||
$extension = array_pop($filenameParts);
|
||||
$basename = trim(implode('.', $filenameParts), '.');
|
||||
$mediumFilename = $basename . '-medium.' . $extension;
|
||||
$smallFilename = $basename . '-small.' . $extension;
|
||||
if (Storage::disk('s3')->exists($mediumFilename)) {
|
||||
Storage::disk('local')->put('public/' . $mediumFilename, Storage::disk('s3')->get($mediumFilename));
|
||||
}
|
||||
if (Storage::disk('s3')->exists($smallFilename)) {
|
||||
Storage::disk('local')->put('public/' . $smallFilename, Storage::disk('s3')->get($smallFilename));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,22 +25,10 @@ class MigratePlaceDataFromPostgis extends Command
|
|||
*/
|
||||
protected $description = 'Copy Postgis data to normal latitude longitude fields';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
$locationColumn = DB::selectOne(DB::raw("
|
||||
SELECT EXISTS (
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace App\Console\Commands;
|
|||
|
||||
use App\Models\WebMention;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Illuminate\FileSystem\FileSystem;
|
||||
|
||||
class ParseCachedWebMentions extends Command
|
||||
|
@ -27,13 +28,13 @@ class ParseCachedWebMentions extends Command
|
|||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public function handle(FileSystem $filesystem)
|
||||
public function handle(FileSystem $filesystem): void
|
||||
{
|
||||
$htmlFiles = $filesystem->allFiles(storage_path() . '/HTML');
|
||||
foreach ($htmlFiles as $file) {
|
||||
if ($file->getExtension() !== 'backup') { //we don’t want to parse `.backup` files
|
||||
if ($file->getExtension() !== 'backup') { // we don’t want to parse `.backup` files
|
||||
$filepath = $file->getPathname();
|
||||
$this->info('Loading HTML from: ' . $filepath);
|
||||
$html = $filesystem->get($filepath);
|
||||
|
@ -49,9 +50,6 @@ class ParseCachedWebMentions extends Command
|
|||
|
||||
/**
|
||||
* Determine the source URL from a filename.
|
||||
*
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
private function urlFromFilename(string $filepath): string
|
||||
{
|
||||
|
|
|
@ -24,22 +24,10 @@ class ReDownloadWebMentions extends Command
|
|||
*/
|
||||
protected $description = 'Redownload the HTML content of webmentions';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
$webmentions = WebMention::all();
|
||||
foreach ($webmentions as $webmention) {
|
||||
|
|
36
app/Console/Commands/UpdateWebmentionsRelationship.php
Normal file
36
app/Console/Commands/UpdateWebmentionsRelationship.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Note;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UpdateWebmentionsRelationship extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'webmentions:update-model-relationship';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Update webmentions to relate to the correct note model class';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
DB::table('webmentions')
|
||||
->where('commentable_type', '=', 'App\Model\Note')
|
||||
->update(['commentable_type' => Note::class]);
|
||||
|
||||
$this->info('All webmentions updated to relate to the correct note model class');
|
||||
}
|
||||
}
|
|
@ -7,36 +7,21 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
Commands\ParseCachedWebMentions::class,
|
||||
Commands\ReDownloadWebMentions::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
protected function schedule(Schedule $schedule): void
|
||||
{
|
||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||
$schedule->command('cache:prune-stale-tags')->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
protected function commands(): void
|
||||
{
|
||||
$this->load(__DIR__ . '/Commands');
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
|
|
|
@ -2,104 +2,18 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
* Register the exception handling callbacks for the application.
|
||||
*/
|
||||
protected $dontReport = [
|
||||
NotFoundHttpException::class,
|
||||
ModelNotFoundException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param Throwable $throwable
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function report(Throwable $throwable)
|
||||
public function register(): void
|
||||
{
|
||||
parent::report($throwable);
|
||||
|
||||
if ($this->shouldReport($throwable)) {
|
||||
$guzzle = new Client([
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
$exceptionName = get_class($throwable) ?? 'Unknown Exception';
|
||||
$title = $exceptionName . ': ' . $throwable->getMessage();
|
||||
|
||||
$guzzle->post(
|
||||
config('logging.slack'),
|
||||
[
|
||||
'body' => json_encode([
|
||||
'attachments' => [[
|
||||
'fallback' => 'There was an exception.',
|
||||
'pretext' => 'There was an exception.',
|
||||
'color' => '#d00000',
|
||||
'author_name' => app()->environment(),
|
||||
'author_link' => config('app.url'),
|
||||
'fields' => [[
|
||||
'title' => $title,
|
||||
'value' => request()->method() . ' ' . request()->fullUrl(),
|
||||
]],
|
||||
'ts' => time(),
|
||||
]],
|
||||
]),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Throwable $throwable
|
||||
* @return Response
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function render($request, Throwable $throwable)
|
||||
{
|
||||
if ($throwable instanceof TokenMismatchException) {
|
||||
Route::getRoutes()->match($request);
|
||||
}
|
||||
|
||||
return parent::render($request, $throwable);
|
||||
$this->reportable(function (Throwable $_e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,4 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
class InternetArchiveException extends \Exception
|
||||
{
|
||||
}
|
||||
class InternetArchiveException extends \Exception {}
|
||||
|
|
7
app/Exceptions/InvalidTokenScopeException.php
Normal file
7
app/Exceptions/InvalidTokenScopeException.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
class InvalidTokenScopeException extends \Exception {}
|
7
app/Exceptions/MicropubHandlerException.php
Normal file
7
app/Exceptions/MicropubHandlerException.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
class MicropubHandlerException extends \Exception {}
|
|
@ -6,5 +6,5 @@ use Exception;
|
|||
|
||||
class RemoteContentNotFoundException extends Exception
|
||||
{
|
||||
//used when guzzle can’t find the remote content
|
||||
// used when guzzle can’t find the remote content
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
class TwitterContentException extends \Exception
|
||||
{
|
||||
}
|
|
@ -27,7 +27,7 @@ class ArticlesController extends Controller
|
|||
|
||||
public function store(): RedirectResponse
|
||||
{
|
||||
//if a `.md` is attached use that for the main content.
|
||||
// if a `.md` is attached use that for the main content.
|
||||
if (request()->hasFile('article')) {
|
||||
$file = request()->file('article')->openFile();
|
||||
$content = $file->fread($file->getSize());
|
||||
|
|
32
app/Http/Controllers/Admin/BioController.php
Normal file
32
app/Http/Controllers/Admin/BioController.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Bio;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class BioController extends Controller
|
||||
{
|
||||
public function show(): View
|
||||
{
|
||||
$bio = Bio::first();
|
||||
|
||||
return view('admin.bio.show', [
|
||||
'bioEntry' => $bio,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request): RedirectResponse
|
||||
{
|
||||
$bio = Bio::firstOrNew();
|
||||
$bio->content = $request->input('content');
|
||||
$bio->save();
|
||||
|
||||
return redirect()->route('admin.bio.show');
|
||||
}
|
||||
}
|
|
@ -7,15 +7,12 @@ namespace App\Http\Controllers\Admin;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Models\MicropubClient;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class ClientsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show a list of known clients.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -26,8 +23,6 @@ class ClientsController extends Controller
|
|||
|
||||
/**
|
||||
* Show form to add a client name.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
|
@ -36,8 +31,6 @@ class ClientsController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to adda new client name.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(): RedirectResponse
|
||||
{
|
||||
|
@ -51,9 +44,6 @@ class ClientsController extends Controller
|
|||
|
||||
/**
|
||||
* Show a form to edit a client name.
|
||||
*
|
||||
* @param int $clientId
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(int $clientId): View
|
||||
{
|
||||
|
@ -68,9 +58,6 @@ class ClientsController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to edit a client name.
|
||||
*
|
||||
* @param int $clientId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(int $clientId): RedirectResponse
|
||||
{
|
||||
|
@ -84,9 +71,6 @@ class ClientsController extends Controller
|
|||
|
||||
/**
|
||||
* Process a request to delete a client.
|
||||
*
|
||||
* @param int $clientId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(int $clientId): RedirectResponse
|
||||
{
|
||||
|
|
|
@ -9,7 +9,6 @@ use App\Models\Contact;
|
|||
use GuzzleHttp\Client;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\View\View;
|
||||
|
||||
|
@ -17,8 +16,6 @@ class ContactsController extends Controller
|
|||
{
|
||||
/**
|
||||
* List the currect contacts that can be edited.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -29,8 +26,6 @@ class ContactsController extends Controller
|
|||
|
||||
/**
|
||||
* Display the form to add a new contact.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
|
@ -39,12 +34,10 @@ class ContactsController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to add a new contact.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(): RedirectResponse
|
||||
{
|
||||
$contact = new Contact();
|
||||
$contact = new Contact;
|
||||
$contact->name = request()->input('name');
|
||||
$contact->nick = request()->input('nick');
|
||||
$contact->homepage = request()->input('homepage');
|
||||
|
@ -57,9 +50,6 @@ class ContactsController extends Controller
|
|||
|
||||
/**
|
||||
* Show the form to edit an existing contact.
|
||||
*
|
||||
* @param int $contactId
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(int $contactId): View
|
||||
{
|
||||
|
@ -72,9 +62,6 @@ class ContactsController extends Controller
|
|||
* Process the request to edit a contact.
|
||||
*
|
||||
* @todo Allow saving profile pictures for people without homepages
|
||||
*
|
||||
* @param int $contactId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(int $contactId): RedirectResponse
|
||||
{
|
||||
|
@ -89,7 +76,7 @@ class ContactsController extends Controller
|
|||
if (request()->hasFile('avatar') && (request()->input('homepage') != '')) {
|
||||
$dir = parse_url(request()->input('homepage'), PHP_URL_HOST);
|
||||
$destination = public_path() . '/assets/profile-images/' . $dir;
|
||||
$filesystem = new Filesystem();
|
||||
$filesystem = new Filesystem;
|
||||
if ($filesystem->isDirectory($destination) === false) {
|
||||
$filesystem->makeDirectory($destination);
|
||||
}
|
||||
|
@ -101,9 +88,6 @@ class ContactsController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to delete a contact.
|
||||
*
|
||||
* @param int $contactId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(int $contactId): RedirectResponse
|
||||
{
|
||||
|
@ -119,7 +103,6 @@ class ContactsController extends Controller
|
|||
* This method attempts to find the microformat marked-up profile image
|
||||
* from a given homepage and save it accordingly
|
||||
*
|
||||
* @param int $contactId
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
*/
|
||||
public function getAvatar(int $contactId)
|
||||
|
@ -153,7 +136,7 @@ class ContactsController extends Controller
|
|||
}
|
||||
if ($avatar !== null) {
|
||||
$directory = public_path() . '/assets/profile-images/' . parse_url($contact->homepage, PHP_URL_HOST);
|
||||
$filesystem = new Filesystem();
|
||||
$filesystem = new Filesystem;
|
||||
if ($filesystem->isDirectory($directory) === false) {
|
||||
$filesystem->makeDirectory($directory);
|
||||
}
|
||||
|
|
|
@ -11,8 +11,6 @@ class HomeController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show the homepage of the admin CP.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function welcome(): View
|
||||
{
|
||||
|
|
|
@ -14,8 +14,6 @@ class LikesController extends Controller
|
|||
{
|
||||
/**
|
||||
* List the likes that can be edited.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -26,8 +24,6 @@ class LikesController extends Controller
|
|||
|
||||
/**
|
||||
* Show the form to make a new like.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
|
@ -36,8 +32,6 @@ class LikesController extends Controller
|
|||
|
||||
/**
|
||||
* Process a request to make a new like.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(): RedirectResponse
|
||||
{
|
||||
|
@ -51,9 +45,6 @@ class LikesController extends Controller
|
|||
|
||||
/**
|
||||
* Display the form to edit a specific like.
|
||||
*
|
||||
* @param int $likeId
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(int $likeId): View
|
||||
{
|
||||
|
@ -67,9 +58,6 @@ class LikesController extends Controller
|
|||
|
||||
/**
|
||||
* Process a request to edit a like.
|
||||
*
|
||||
* @param int $likeId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(int $likeId): RedirectResponse
|
||||
{
|
||||
|
@ -83,9 +71,6 @@ class LikesController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to delete a like.
|
||||
*
|
||||
* @param int $likeId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(int $likeId): RedirectResponse
|
||||
{
|
||||
|
|
|
@ -15,8 +15,6 @@ class NotesController extends Controller
|
|||
{
|
||||
/**
|
||||
* List the notes that can be edited.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -30,8 +28,6 @@ class NotesController extends Controller
|
|||
|
||||
/**
|
||||
* Show the form to make a new note.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
|
@ -40,14 +36,12 @@ class NotesController extends Controller
|
|||
|
||||
/**
|
||||
* Process a request to make a new note.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(): RedirectResponse
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
Note::create([
|
||||
'in-reply-to' => request()->input('in-reply-to'),
|
||||
'note' => request()->input('content'),
|
||||
'in_reply_to' => $request->input('in-reply-to'),
|
||||
'note' => $request->input('content'),
|
||||
]);
|
||||
|
||||
return redirect('/admin/notes');
|
||||
|
@ -55,9 +49,6 @@ class NotesController extends Controller
|
|||
|
||||
/**
|
||||
* Display the form to edit a specific note.
|
||||
*
|
||||
* @param int $noteId
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(int $noteId): View
|
||||
{
|
||||
|
@ -70,13 +61,10 @@ class NotesController extends Controller
|
|||
/**
|
||||
* Process a request to edit a note. Easy since this can only be done
|
||||
* from the admin CP.
|
||||
*
|
||||
* @param int $noteId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(int $noteId): RedirectResponse
|
||||
{
|
||||
//update note data
|
||||
// update note data
|
||||
$note = Note::findOrFail($noteId);
|
||||
$note->note = request()->input('content');
|
||||
$note->in_reply_to = request()->input('in-reply-to');
|
||||
|
@ -91,9 +79,6 @@ class NotesController extends Controller
|
|||
|
||||
/**
|
||||
* Delete the note.
|
||||
*
|
||||
* @param int $noteId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(int $noteId): RedirectResponse
|
||||
{
|
||||
|
|
326
app/Http/Controllers/Admin/PasskeysController.php
Normal file
326
app/Http/Controllers/Admin/PasskeysController.php
Normal file
|
@ -0,0 +1,326 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Passkey;
|
||||
use App\Models\User;
|
||||
use Cose\Algorithm\Manager;
|
||||
use Cose\Algorithm\Signature\ECDSA\ES256;
|
||||
use Cose\Algorithm\Signature\EdDSA\Ed25519;
|
||||
use Cose\Algorithm\Signature\RSA\RS256;
|
||||
use Cose\Algorithms;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\View\View;
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
use Random\RandomException;
|
||||
use Throwable;
|
||||
use Webauthn\AttestationStatement\AttestationStatementSupportManager;
|
||||
use Webauthn\AttestationStatement\NoneAttestationStatementSupport;
|
||||
use Webauthn\AuthenticationExtensions\ExtensionOutputCheckerHandler;
|
||||
use Webauthn\AuthenticatorAssertionResponse;
|
||||
use Webauthn\AuthenticatorAssertionResponseValidator;
|
||||
use Webauthn\AuthenticatorAttestationResponse;
|
||||
use Webauthn\AuthenticatorAttestationResponseValidator;
|
||||
use Webauthn\AuthenticatorSelectionCriteria;
|
||||
use Webauthn\CeremonyStep\CeremonyStepManagerFactory;
|
||||
use Webauthn\Denormalizer\WebauthnSerializerFactory;
|
||||
use Webauthn\Exception\WebauthnException;
|
||||
use Webauthn\PublicKeyCredential;
|
||||
use Webauthn\PublicKeyCredentialCreationOptions;
|
||||
use Webauthn\PublicKeyCredentialParameters;
|
||||
use Webauthn\PublicKeyCredentialRequestOptions;
|
||||
use Webauthn\PublicKeyCredentialRpEntity;
|
||||
use Webauthn\PublicKeyCredentialSource;
|
||||
use Webauthn\PublicKeyCredentialUserEntity;
|
||||
|
||||
class PasskeysController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$passkeys = $user->passkey;
|
||||
|
||||
return view('admin.passkeys.index', compact('passkeys'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RandomException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function getCreateOptions(Request $request): JsonResponse
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
// RP Entity i.e. the application
|
||||
$rpEntity = PublicKeyCredentialRpEntity::create(
|
||||
name: config('app.name'),
|
||||
id: config('app.url'),
|
||||
);
|
||||
|
||||
// User Entity
|
||||
$userEntity = PublicKeyCredentialUserEntity::create(
|
||||
name: $user->name,
|
||||
id: (string) $user->id,
|
||||
displayName: $user->name,
|
||||
);
|
||||
|
||||
// Challenge
|
||||
$challenge = random_bytes(16);
|
||||
|
||||
// List of supported public key parameters
|
||||
$pubKeyCredParams = collect([
|
||||
Algorithms::COSE_ALGORITHM_EDDSA,
|
||||
Algorithms::COSE_ALGORITHM_ES256,
|
||||
Algorithms::COSE_ALGORITHM_RS256,
|
||||
])->map(
|
||||
fn ($algorithm) => PublicKeyCredentialParameters::create('public-key', $algorithm)
|
||||
)->toArray();
|
||||
|
||||
$authenticatorSelectionCriteria = AuthenticatorSelectionCriteria::create(
|
||||
userVerification: AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_REQUIRED,
|
||||
residentKey: AuthenticatorSelectionCriteria::RESIDENT_KEY_REQUIREMENT_REQUIRED,
|
||||
);
|
||||
|
||||
$publicKeyCredentialCreationOptions = PublicKeyCredentialCreationOptions::create(
|
||||
rp: $rpEntity,
|
||||
user: $userEntity,
|
||||
challenge: $challenge,
|
||||
pubKeyCredParams: $pubKeyCredParams,
|
||||
authenticatorSelection: $authenticatorSelectionCriteria,
|
||||
attestation: PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE
|
||||
);
|
||||
|
||||
$attestationStatementSupportManager = new AttestationStatementSupportManager;
|
||||
$attestationStatementSupportManager->add(new NoneAttestationStatementSupport);
|
||||
$webauthnSerializerFactory = new WebauthnSerializerFactory(
|
||||
attestationStatementSupportManager: $attestationStatementSupportManager
|
||||
);
|
||||
$webauthnSerializer = $webauthnSerializerFactory->create();
|
||||
$publicKeyCredentialCreationOptions = $webauthnSerializer->serialize(
|
||||
data: $publicKeyCredentialCreationOptions,
|
||||
format: 'json'
|
||||
);
|
||||
|
||||
$request->session()->put('create_options', $publicKeyCredentialCreationOptions);
|
||||
|
||||
return JsonResponse::fromJsonString($publicKeyCredentialCreationOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
* @throws WebauthnException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function create(Request $request): JsonResponse
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$publicKeyCredentialCreationOptionsData = session('create_options');
|
||||
// Unset session data to mitigate replay attacks
|
||||
$request->session()->forget('create_options');
|
||||
if (empty($publicKeyCredentialCreationOptionsData)) {
|
||||
throw new WebAuthnException('No public key credential request options found');
|
||||
}
|
||||
|
||||
$attestationStatementSupportManager = new AttestationStatementSupportManager;
|
||||
$attestationStatementSupportManager->add(new NoneAttestationStatementSupport);
|
||||
$webauthnSerializerFactory = new WebauthnSerializerFactory(
|
||||
attestationStatementSupportManager: $attestationStatementSupportManager
|
||||
);
|
||||
$webauthnSerializer = $webauthnSerializerFactory->create();
|
||||
|
||||
$publicKeyCredential = $webauthnSerializer->deserialize(
|
||||
json_encode($request->all(), JSON_THROW_ON_ERROR),
|
||||
PublicKeyCredential::class,
|
||||
'json'
|
||||
);
|
||||
|
||||
if (! $publicKeyCredential->response instanceof AuthenticatorAttestationResponse) {
|
||||
throw new WebAuthnException('Invalid response type');
|
||||
}
|
||||
|
||||
$algorithmManager = new Manager;
|
||||
$algorithmManager->add(new Ed25519);
|
||||
$algorithmManager->add(new ES256);
|
||||
$algorithmManager->add(new RS256);
|
||||
|
||||
$ceremonyStepManagerFactory = new CeremonyStepManagerFactory;
|
||||
$ceremonyStepManagerFactory->setAlgorithmManager($algorithmManager);
|
||||
$ceremonyStepManagerFactory->setAttestationStatementSupportManager(
|
||||
$attestationStatementSupportManager
|
||||
);
|
||||
$ceremonyStepManagerFactory->setExtensionOutputCheckerHandler(
|
||||
ExtensionOutputCheckerHandler::create()
|
||||
);
|
||||
$allowedOrigins = [];
|
||||
if (App::environment('local', 'development')) {
|
||||
$allowedOrigins = [config('app.url')];
|
||||
}
|
||||
$ceremonyStepManagerFactory->setAllowedOrigins($allowedOrigins);
|
||||
|
||||
$authenticatorAttestationResponseValidator = AuthenticatorAttestationResponseValidator::create(
|
||||
ceremonyStepManager: $ceremonyStepManagerFactory->creationCeremony()
|
||||
);
|
||||
|
||||
$publicKeyCredentialCreationOptions = $webauthnSerializer->deserialize(
|
||||
$publicKeyCredentialCreationOptionsData,
|
||||
PublicKeyCredentialCreationOptions::class,
|
||||
'json'
|
||||
);
|
||||
|
||||
$publicKeyCredentialSource = $authenticatorAttestationResponseValidator->check(
|
||||
authenticatorAttestationResponse: $publicKeyCredential->response,
|
||||
publicKeyCredentialCreationOptions: $publicKeyCredentialCreationOptions,
|
||||
host: config('app.url')
|
||||
);
|
||||
|
||||
$user->passkey()->create([
|
||||
'passkey_id' => Base64UrlSafe::encodeUnpadded($publicKeyCredentialSource->publicKeyCredentialId),
|
||||
'passkey' => json_encode($publicKeyCredentialSource, JSON_THROW_ON_ERROR),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Passkey created successfully',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RandomException
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function getRequestOptions(Request $request): JsonResponse
|
||||
{
|
||||
$publicKeyCredentialRequestOptions = PublicKeyCredentialRequestOptions::create(
|
||||
challenge: random_bytes(16),
|
||||
userVerification: PublicKeyCredentialRequestOptions::USER_VERIFICATION_REQUIREMENT_REQUIRED
|
||||
);
|
||||
|
||||
$attestationStatementSupportManager = AttestationStatementSupportManager::create();
|
||||
$attestationStatementSupportManager->add(NoneAttestationStatementSupport::create());
|
||||
$factory = new WebauthnSerializerFactory(
|
||||
attestationStatementSupportManager: $attestationStatementSupportManager
|
||||
);
|
||||
$serializer = $factory->create();
|
||||
$publicKeyCredentialRequestOptions = $serializer->serialize(data: $publicKeyCredentialRequestOptions, format: 'json');
|
||||
|
||||
$request->session()->put('request_options', $publicKeyCredentialRequestOptions);
|
||||
|
||||
return JsonResponse::fromJsonString($publicKeyCredentialRequestOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \JsonException
|
||||
*/
|
||||
public function login(Request $request): JsonResponse
|
||||
{
|
||||
$requestOptions = session('request_options');
|
||||
$request->session()->forget('request_options');
|
||||
|
||||
if (empty($requestOptions)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'No request options found',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$attestationStatementSupportManager = new AttestationStatementSupportManager;
|
||||
$attestationStatementSupportManager->add(new NoneAttestationStatementSupport);
|
||||
|
||||
$webauthnSerializerFactory = new WebauthnSerializerFactory(
|
||||
attestationStatementSupportManager: $attestationStatementSupportManager
|
||||
);
|
||||
$webauthnSerializer = $webauthnSerializerFactory->create();
|
||||
|
||||
$publicKeyCredential = $webauthnSerializer->deserialize(
|
||||
json_encode($request->all(), JSON_THROW_ON_ERROR),
|
||||
PublicKeyCredential::class,
|
||||
'json'
|
||||
);
|
||||
|
||||
if (! $publicKeyCredential->response instanceof AuthenticatorAssertionResponse) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Invalid response type',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$passkey = Passkey::firstWhere('passkey_id', $publicKeyCredential->id);
|
||||
if (! $passkey) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Passkey not found',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$publicKeyCredentialSource = $webauthnSerializer->deserialize(
|
||||
$passkey->passkey,
|
||||
PublicKeyCredentialSource::class,
|
||||
'json'
|
||||
);
|
||||
|
||||
$algorithmManager = new Manager;
|
||||
$algorithmManager->add(new Ed25519);
|
||||
$algorithmManager->add(new ES256);
|
||||
$algorithmManager->add(new RS256);
|
||||
|
||||
$attestationStatementSupportManager = new AttestationStatementSupportManager;
|
||||
$attestationStatementSupportManager->add(new NoneAttestationStatementSupport);
|
||||
|
||||
$ceremonyStepManagerFactory = new CeremonyStepManagerFactory;
|
||||
$ceremonyStepManagerFactory->setAlgorithmManager($algorithmManager);
|
||||
$ceremonyStepManagerFactory->setAttestationStatementSupportManager(
|
||||
$attestationStatementSupportManager
|
||||
);
|
||||
$ceremonyStepManagerFactory->setExtensionOutputCheckerHandler(
|
||||
ExtensionOutputCheckerHandler::create()
|
||||
);
|
||||
$allowedOrigins = [];
|
||||
if (App::environment('local', 'development')) {
|
||||
$allowedOrigins = [config('app.url')];
|
||||
}
|
||||
$ceremonyStepManagerFactory->setAllowedOrigins($allowedOrigins);
|
||||
|
||||
$authenticatorAssertionResponseValidator = AuthenticatorAssertionResponseValidator::create(
|
||||
ceremonyStepManager: $ceremonyStepManagerFactory->requestCeremony()
|
||||
);
|
||||
|
||||
$publicKeyCredentialRequestOptions = $webauthnSerializer->deserialize(
|
||||
$requestOptions,
|
||||
PublicKeyCredentialRequestOptions::class,
|
||||
'json'
|
||||
);
|
||||
|
||||
try {
|
||||
$authenticatorAssertionResponseValidator->check(
|
||||
publicKeyCredentialSource: $publicKeyCredentialSource,
|
||||
authenticatorAssertionResponse: $publicKeyCredential->response,
|
||||
publicKeyCredentialRequestOptions: $publicKeyCredentialRequestOptions,
|
||||
host: config('app.url'),
|
||||
userHandle: null,
|
||||
);
|
||||
} catch (Throwable) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Passkey could not be verified',
|
||||
], 500);
|
||||
}
|
||||
|
||||
$user = User::find($passkey->user_id);
|
||||
Auth::login($user);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Passkey verified successfully',
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -21,8 +21,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* List the places that can be edited.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -33,8 +31,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Show the form to make a new place.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
|
@ -43,8 +39,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Process a request to make a new place.
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function store(): RedirectResponse
|
||||
{
|
||||
|
@ -62,9 +56,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Display the form to edit a specific place.
|
||||
*
|
||||
* @param int $placeId
|
||||
* @return View
|
||||
*/
|
||||
public function edit(int $placeId): View
|
||||
{
|
||||
|
@ -75,9 +66,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Process a request to edit a place.
|
||||
*
|
||||
* @param int $placeId
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function update(int $placeId): RedirectResponse
|
||||
{
|
||||
|
@ -94,9 +82,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* List the places we can merge with the current place.
|
||||
*
|
||||
* @param int $placeId
|
||||
* @return View
|
||||
*/
|
||||
public function mergeIndex(int $placeId): View
|
||||
{
|
||||
|
@ -114,10 +99,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Show a form for merging two specific places.
|
||||
*
|
||||
* @param int $placeId1
|
||||
* @param int $placeId2
|
||||
* @return View
|
||||
*/
|
||||
public function mergeEdit(int $placeId1, int $placeId2): View
|
||||
{
|
||||
|
@ -129,8 +110,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to merge two places.
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function mergeStore(): RedirectResponse
|
||||
{
|
||||
|
|
94
app/Http/Controllers/Admin/SyndicationTargetsController.php
Normal file
94
app/Http/Controllers/Admin/SyndicationTargetsController.php
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\SyndicationTarget;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class SyndicationTargetsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show a list of known syndication targets.
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
$targets = SyndicationTarget::all();
|
||||
|
||||
return view('admin.syndication.index', compact('targets'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show form to add a syndication target.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('admin.syndication.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the request to adda new syndication target.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'uid' => 'required|string',
|
||||
'name' => 'required|string',
|
||||
'service_name' => 'nullable|string',
|
||||
'service_url' => 'nullable|string',
|
||||
'service_photo' => 'nullable|string',
|
||||
'user_name' => 'nullable|string',
|
||||
'user_url' => 'nullable|string',
|
||||
'user_photo' => 'nullable|string',
|
||||
]);
|
||||
|
||||
SyndicationTarget::create($validated);
|
||||
|
||||
return redirect('/admin/syndication');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a form to edit a syndication target.
|
||||
*/
|
||||
public function edit(SyndicationTarget $syndicationTarget): View
|
||||
{
|
||||
return view('admin.syndication.edit', [
|
||||
'syndication_target' => $syndicationTarget,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the request to edit a client name.
|
||||
*/
|
||||
public function update(Request $request, SyndicationTarget $syndicationTarget): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'uid' => 'required|string',
|
||||
'name' => 'required|string',
|
||||
'service_name' => 'nullable|string',
|
||||
'service_url' => 'nullable|string',
|
||||
'service_photo' => 'nullable|string',
|
||||
'user_name' => 'nullable|string',
|
||||
'user_url' => 'nullable|string',
|
||||
'user_photo' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$syndicationTarget->update($validated);
|
||||
|
||||
return redirect('/admin/syndication');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a request to delete a client.
|
||||
*/
|
||||
public function destroy(SyndicationTarget $syndicationTarget): RedirectResponse
|
||||
{
|
||||
$syndicationTarget->delete();
|
||||
|
||||
return redirect('/admin/syndication');
|
||||
}
|
||||
}
|
|
@ -14,30 +14,21 @@ class ArticlesController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show all articles (with pagination).
|
||||
*
|
||||
* @param int|null $year
|
||||
* @param int|null $month
|
||||
* @return View
|
||||
*/
|
||||
public function index(int $year = null, int $month = null): View
|
||||
public function index(?int $year = null, ?int $month = null): View
|
||||
{
|
||||
$articles = Article::where('published', '1')
|
||||
->date($year, $month)
|
||||
->orderBy('updated_at', 'desc')
|
||||
->simplePaginate(5);
|
||||
->date($year, $month)
|
||||
->orderBy('updated_at', 'desc')
|
||||
->simplePaginate(5);
|
||||
|
||||
return view('articles.index', compact('articles'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a single article.
|
||||
*
|
||||
* @param int $year
|
||||
* @param int $month
|
||||
* @param string $slug
|
||||
* @return RedirectResponse|View
|
||||
*/
|
||||
public function show(int $year, int $month, string $slug)
|
||||
public function show(int $year, int $month, string $slug): RedirectResponse|View
|
||||
{
|
||||
try {
|
||||
$article = Article::where('titleurl', $slug)->firstOrFail();
|
||||
|
@ -56,11 +47,7 @@ class ArticlesController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* We only have the ID, work out post title, year and month
|
||||
* and redirect to it.
|
||||
*
|
||||
* @param string $idFromUrl
|
||||
* @return RedirectResponse
|
||||
* We only have the ID, work out post title, year and month and redirect to it.
|
||||
*/
|
||||
public function onlyIdInUrl(string $idFromUrl): RedirectResponse
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\View\View;
|
||||
|
||||
|
@ -12,10 +13,8 @@ class AuthController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show the login form.
|
||||
*
|
||||
* @return View|RedirectResponse
|
||||
*/
|
||||
public function showLogin()
|
||||
public function showLogin(): View|RedirectResponse
|
||||
{
|
||||
if (Auth::check()) {
|
||||
return redirect('/');
|
||||
|
@ -25,28 +24,23 @@ class AuthController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Log in a user, set a session variable, check credentials against
|
||||
* the .env file.
|
||||
*
|
||||
* @return RedirectResponse
|
||||
* Log in a user, set a session variable, check credentials against the `.env` file.
|
||||
*/
|
||||
public function login(): RedirectResponse
|
||||
public function login(Request $request): RedirectResponse
|
||||
{
|
||||
$credentials = request()->only('name', 'password');
|
||||
$credentials = $request->only('name', 'password');
|
||||
|
||||
if (Auth::attempt($credentials, true)) {
|
||||
return redirect()->intended('/');
|
||||
return redirect()->intended('/admin');
|
||||
}
|
||||
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form to logout a user.
|
||||
*
|
||||
* @return View|RedirectResponse
|
||||
* Show the form to allow a user to log-out.
|
||||
*/
|
||||
public function showLogout()
|
||||
public function showLogout(): View|RedirectResponse
|
||||
{
|
||||
if (Auth::check() === false) {
|
||||
// The user is not logged in, just redirect them home
|
||||
|
@ -58,8 +52,6 @@ class AuthController extends Controller
|
|||
|
||||
/**
|
||||
* Log the user out from their current session.
|
||||
*
|
||||
* @return RedirectResponse;
|
||||
*/
|
||||
public function logout(): RedirectResponse
|
||||
{
|
||||
|
|
|
@ -11,8 +11,6 @@ class BookmarksController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show the most recent bookmarks.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -23,9 +21,6 @@ class BookmarksController extends Controller
|
|||
|
||||
/**
|
||||
* Show a single bookmark.
|
||||
*
|
||||
* @param Bookmark $bookmark
|
||||
* @return View
|
||||
*/
|
||||
public function show(Bookmark $bookmark): View
|
||||
{
|
||||
|
@ -33,4 +28,16 @@ class BookmarksController extends Controller
|
|||
|
||||
return view('bookmarks.show', compact('bookmark'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show bookmarks tagged with a specific tag.
|
||||
*/
|
||||
public function tagged(string $tag): View
|
||||
{
|
||||
$bookmarks = Bookmark::whereHas('tags', function ($query) use ($tag) {
|
||||
$query->where('tag', $tag);
|
||||
})->latest()->with('tags')->withCount('tags')->paginate(10);
|
||||
|
||||
return view('bookmarks.tagged', compact('bookmarks', 'tag'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,12 +12,10 @@ class ContactsController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show all the contacts.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
$filesystem = new Filesystem();
|
||||
$filesystem = new Filesystem;
|
||||
$contacts = Contact::all();
|
||||
foreach ($contacts as $contact) {
|
||||
$contact->homepageHost = parse_url($contact->homepage, PHP_URL_HOST);
|
||||
|
@ -33,16 +31,13 @@ class ContactsController extends Controller
|
|||
|
||||
/**
|
||||
* Show a single contact.
|
||||
*
|
||||
* @param Contact $contact
|
||||
* @return View
|
||||
*/
|
||||
public function show(Contact $contact): View
|
||||
{
|
||||
$contact->homepageHost = parse_url($contact->homepage, PHP_URL_HOST);
|
||||
$file = public_path() . '/assets/profile-images/' . $contact->homepageHost . '/image';
|
||||
|
||||
$filesystem = new Filesystem();
|
||||
$filesystem = new Filesystem;
|
||||
$image = ($filesystem->exists($file)) ?
|
||||
'/assets/profile-images/' . $contact->homepageHost . '/image'
|
||||
:
|
||||
|
|
|
@ -2,14 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
abstract class Controller
|
||||
{
|
||||
use AuthorizesRequests;
|
||||
use DispatchesJobs;
|
||||
use ValidatesRequests;
|
||||
//
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ class FeedsController extends Controller
|
|||
{
|
||||
/**
|
||||
* Returns the blog RSS feed.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function blogRss(): Response
|
||||
{
|
||||
|
@ -22,28 +20,24 @@ class FeedsController extends Controller
|
|||
$buildDate = $articles->first()->updated_at->toRssString();
|
||||
|
||||
return response()
|
||||
->view('articles.rss', compact('articles', 'buildDate'))
|
||||
->header('Content-Type', 'application/rss+xml; charset=utf-8');
|
||||
->view('articles.rss', compact('articles', 'buildDate'))
|
||||
->header('Content-Type', 'application/rss+xml; charset=utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the blog Atom feed.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function blogAtom(): Response
|
||||
{
|
||||
$articles = Article::where('published', '1')->latest('updated_at')->take(20)->get();
|
||||
|
||||
return response()
|
||||
->view('articles.atom', compact('articles'))
|
||||
->header('Content-Type', 'application/atom+xml; charset=utf-8');
|
||||
->view('articles.atom', compact('articles'))
|
||||
->header('Content-Type', 'application/atom+xml; charset=utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the notes RSS feed.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function notesRss(): Response
|
||||
{
|
||||
|
@ -51,39 +45,41 @@ class FeedsController extends Controller
|
|||
$buildDate = $notes->first()->updated_at->toRssString();
|
||||
|
||||
return response()
|
||||
->view('notes.rss', compact('notes', 'buildDate'))
|
||||
->header('Content-Type', 'application/rss+xml; charset=utf-8');
|
||||
->view('notes.rss', compact('notes', 'buildDate'))
|
||||
->header('Content-Type', 'application/rss+xml; charset=utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the notes Atom feed.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function notesAtom(): Response
|
||||
{
|
||||
$notes = Note::latest()->take(20)->get();
|
||||
|
||||
return response()
|
||||
->view('notes.atom', compact('notes'))
|
||||
->header('Content-Type', 'application/atom+xml; charset=utf-8');
|
||||
->view('notes.atom', compact('notes'))
|
||||
->header('Content-Type', 'application/atom+xml; charset=utf-8');
|
||||
}
|
||||
|
||||
/** @todo sort out return type for json responses */
|
||||
|
||||
/**
|
||||
* Returns the blog JSON feed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function blogJson(): array
|
||||
{
|
||||
$articles = Article::where('published', '1')->latest('updated_at')->take(20)->get();
|
||||
$data = [
|
||||
'version' => 'https://jsonfeed.org/version/1',
|
||||
'title' => 'The JSON Feed for ' . config('app.display_name') . '’s blog',
|
||||
'version' => 'https://jsonfeed.org/version/1.1',
|
||||
'title' => 'The JSON Feed for ' . config('user.display_name') . '’s blog',
|
||||
'home_page_url' => config('app.url') . '/blog',
|
||||
'feed_url' => config('app.url') . '/blog/feed.json',
|
||||
'authors' => [
|
||||
[
|
||||
'name' => config('user.display_name'),
|
||||
'url' => config('app.url'),
|
||||
],
|
||||
],
|
||||
'items' => [],
|
||||
];
|
||||
|
||||
|
@ -95,9 +91,6 @@ class FeedsController extends Controller
|
|||
'content_html' => $article->main,
|
||||
'date_published' => $article->created_at->tz('UTC')->toRfc3339String(),
|
||||
'date_modified' => $article->updated_at->tz('UTC')->toRfc3339String(),
|
||||
'author' => [
|
||||
'name' => config('app.display_name'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -106,31 +99,35 @@ class FeedsController extends Controller
|
|||
|
||||
/**
|
||||
* Returns the notes JSON feed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function notesJson()
|
||||
public function notesJson(): array
|
||||
{
|
||||
$notes = Note::latest()->take(20)->get();
|
||||
$notes = Note::latest()->with('media', 'place', 'tags')->take(20)->get();
|
||||
$data = [
|
||||
'version' => 'https://jsonfeed.org/version/1',
|
||||
'title' => 'The JSON Feed for ' . config('app.display_name') . '’s notes',
|
||||
'version' => 'https://jsonfeed.org/version/1.1',
|
||||
'title' => 'The JSON Feed for ' . config('user.display_name') . '’s notes',
|
||||
'home_page_url' => config('app.url') . '/notes',
|
||||
'feed_url' => config('app.url') . '/notes/feed.json',
|
||||
'authors' => [
|
||||
[
|
||||
'name' => config('user.display_name'),
|
||||
'url' => config('app.url'),
|
||||
],
|
||||
],
|
||||
'items' => [],
|
||||
];
|
||||
|
||||
foreach ($notes as $key => $note) {
|
||||
$data['items'][$key] = [
|
||||
'id' => $note->longurl,
|
||||
'url' => $note->longurl,
|
||||
'content_html' => $note->content,
|
||||
'id' => $note->uri,
|
||||
'url' => $note->uri,
|
||||
'content_text' => $note->content,
|
||||
'date_published' => $note->created_at->tz('UTC')->toRfc3339String(),
|
||||
'date_modified' => $note->updated_at->tz('UTC')->toRfc3339String(),
|
||||
'author' => [
|
||||
'name' => config('app.display_name'),
|
||||
],
|
||||
];
|
||||
if ($note->tags->count() > 0) {
|
||||
$data['items'][$key]['tags'] = implode(',', $note->tags->pluck('tag')->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
@ -138,8 +135,6 @@ class FeedsController extends Controller
|
|||
|
||||
/**
|
||||
* Returns the blog JF2 feed.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function blogJf2(): JsonResponse
|
||||
{
|
||||
|
@ -165,8 +160,8 @@ class FeedsController extends Controller
|
|||
'url' => url('/blog'),
|
||||
'author' => [
|
||||
'type' => 'card',
|
||||
'name' => config('user.displayname'),
|
||||
'url' => config('app.longurl'),
|
||||
'name' => config('user.display_name'),
|
||||
'url' => config('app.url'),
|
||||
],
|
||||
'children' => $items,
|
||||
], 200, [
|
||||
|
@ -176,8 +171,6 @@ class FeedsController extends Controller
|
|||
|
||||
/**
|
||||
* Returns the notes JF2 feed.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function notesJf2(): JsonResponse
|
||||
{
|
||||
|
@ -187,8 +180,8 @@ class FeedsController extends Controller
|
|||
$items[] = [
|
||||
'type' => 'entry',
|
||||
'published' => $note->created_at,
|
||||
'uid' => $note->longurl,
|
||||
'url' => $note->longurl,
|
||||
'uid' => $note->uri,
|
||||
'url' => $note->uri,
|
||||
'content' => [
|
||||
'text' => $note->getRawOriginal('note'),
|
||||
'html' => $note->note,
|
||||
|
@ -203,8 +196,8 @@ class FeedsController extends Controller
|
|||
'url' => url('/notes'),
|
||||
'author' => [
|
||||
'type' => 'card',
|
||||
'name' => config('user.displayname'),
|
||||
'url' => config('app.longurl'),
|
||||
'name' => config('user.display_name'),
|
||||
'url' => config('app.url'),
|
||||
],
|
||||
'children' => $items,
|
||||
], 200, [
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Bio;
|
||||
use App\Models\Bookmark;
|
||||
use App\Models\Like;
|
||||
use App\Models\Note;
|
||||
use App\Services\ActivityStreamsService;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\View\View;
|
||||
|
||||
|
@ -14,18 +14,20 @@ class FrontPageController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show all the recent activity.
|
||||
*
|
||||
* @return Response|View
|
||||
*/
|
||||
public function index()
|
||||
public function index(): Response|View
|
||||
{
|
||||
if (request()->wantsActivityStream()) {
|
||||
return (new ActivityStreamsService())->siteOwnerResponse();
|
||||
}
|
||||
|
||||
$notes = Note::latest()->get();
|
||||
$notes = Note::latest()->with(['media', 'client', 'place'])->withCount(['webmentions AS replies' => function ($query) {
|
||||
$query->where('type', 'in-reply-to');
|
||||
}])
|
||||
->withCount(['webmentions AS likes' => function ($query) {
|
||||
$query->where('type', 'like-of');
|
||||
}])
|
||||
->withCount(['webmentions AS reposts' => function ($query) {
|
||||
$query->where('type', 'repost-of');
|
||||
}])->get();
|
||||
$articles = Article::latest()->get();
|
||||
$bookmarks = Bookmark::latest()->get();
|
||||
$bookmarks = Bookmark::latest()->with('tags')->get();
|
||||
$likes = Like::latest()->get();
|
||||
|
||||
$items = collect($notes)
|
||||
|
@ -35,8 +37,11 @@ class FrontPageController extends Controller
|
|||
->sortByDesc('updated_at')
|
||||
->paginate(10);
|
||||
|
||||
$bio = Bio::first()?->content;
|
||||
|
||||
return view('front-page', [
|
||||
'items' => $items,
|
||||
'bio' => $bio,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
327
app/Http/Controllers/IndieAuthController.php
Normal file
327
app/Http/Controllers/IndieAuthController.php
Normal file
|
@ -0,0 +1,327 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\TokenService;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\View\View;
|
||||
use Random\RandomException;
|
||||
use SodiumException;
|
||||
|
||||
class IndieAuthController extends Controller
|
||||
{
|
||||
public function indieAuthMetadataEndpoint(): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'issuer' => config('app.url'),
|
||||
'authorization_endpoint' => route('indieauth.start'),
|
||||
'token_endpoint' => route('indieauth.token'),
|
||||
'code_challenge_methods_supported' => ['S256'],
|
||||
// 'introspection_endpoint' => route('indieauth.introspection'),
|
||||
// 'introspection_endpoint_auth_methods_supported' => ['none'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a GET request to the IndieAuth endpoint.
|
||||
*
|
||||
* This is the first step in the IndieAuth flow, where the client app sends the user to the IndieAuth endpoint.
|
||||
*/
|
||||
public function start(Request $request): View
|
||||
{
|
||||
// First check all required params are present
|
||||
$validator = Validator::make($request->all(), [
|
||||
'response_type' => 'required:string',
|
||||
'client_id' => 'required',
|
||||
'redirect_uri' => 'required',
|
||||
'state' => 'required',
|
||||
'code_challenge' => 'required:string',
|
||||
'code_challenge_method' => 'required:string',
|
||||
], [
|
||||
'response_type' => 'response_type is required',
|
||||
'client_id.required' => 'client_id is required to display which app is asking for authentication',
|
||||
'redirect_uri.required' => 'redirect_uri is required so we can progress successful requests',
|
||||
'state.required' => 'state is required',
|
||||
'code_challenge.required' => 'code_challenge is required',
|
||||
'code_challenge_method.required' => 'code_challenge_method is required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return view('indieauth.error')->withErrors($validator);
|
||||
}
|
||||
|
||||
if ($request->get('response_type') !== 'code') {
|
||||
return view('indieauth.error')->withErrors(['response_type' => 'only a response_type of "code" is supported']);
|
||||
}
|
||||
|
||||
if (mb_strtoupper($request->get('code_challenge_method')) !== 'S256') {
|
||||
return view('indieauth.error')->withErrors(['code_challenge_method' => 'only a code_challenge_method of "S256" is supported']);
|
||||
}
|
||||
|
||||
if (! $this->isValidRedirectUri($request->get('client_id'), $request->get('redirect_uri'))) {
|
||||
return view('indieauth.error')->withErrors(['redirect_uri' => 'redirect_uri is not valid for this client_id']);
|
||||
}
|
||||
|
||||
$scopes = $request->get('scope', '');
|
||||
$scopes = explode(' ', $scopes);
|
||||
|
||||
return view('indieauth.start', [
|
||||
'me' => $request->get('me'),
|
||||
'client_id' => $request->get('client_id'),
|
||||
'redirect_uri' => $request->get('redirect_uri'),
|
||||
'state' => $request->get('state'),
|
||||
'scopes' => $scopes,
|
||||
'code_challenge' => $request->get('code_challenge'),
|
||||
'code_challenge_method' => $request->get('code_challenge_method'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm an IndieAuth approval request.
|
||||
*
|
||||
* Generates an auth code and redirects the user back to the client app.
|
||||
*
|
||||
* @throws RandomException
|
||||
*/
|
||||
public function confirm(Request $request): RedirectResponse
|
||||
{
|
||||
$authCode = bin2hex(random_bytes(16));
|
||||
|
||||
$cacheKey = hash('xxh3', $request->get('client_id'));
|
||||
|
||||
$indieAuthRequestData = [
|
||||
'code_challenge' => $request->get('code_challenge'),
|
||||
'code_challenge_method' => $request->get('code_challenge_method'),
|
||||
'client_id' => $request->get('client_id'),
|
||||
'redirect_uri' => $request->get('redirect_uri'),
|
||||
'auth_code' => $authCode,
|
||||
'scope' => implode(' ', $request->get('scope', '')),
|
||||
];
|
||||
|
||||
Cache::put($cacheKey, $indieAuthRequestData, now()->addMinutes(10));
|
||||
|
||||
$redirectUri = new Uri($request->get('redirect_uri'));
|
||||
$redirectUri = Uri::withQueryValues($redirectUri, [
|
||||
'code' => $authCode,
|
||||
'state' => $request->get('state'),
|
||||
'iss' => config('app.url'),
|
||||
]);
|
||||
|
||||
return redirect()->away($redirectUri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a POST request to the IndieAuth auth endpoint.
|
||||
*
|
||||
* This is one possible second step in the IndieAuth flow, where the client app sends the auth code to the IndieAuth
|
||||
* endpoint. As it is to the auth endpoint we return profile information. A similar request can be made to the token
|
||||
* endpoint to get an access token.
|
||||
*/
|
||||
public function processCodeExchange(Request $request): JsonResponse
|
||||
{
|
||||
$invalidCodeResponse = $this->validateAuthorizationCode($request);
|
||||
|
||||
if ($invalidCodeResponse instanceof JsonResponse) {
|
||||
return $invalidCodeResponse;
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'me' => config('app.url'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a POST request to the IndieAuth token endpoint.
|
||||
*
|
||||
* This is another possible second step in the IndieAuth flow, where the client app sends the auth code to the
|
||||
* IndieAuth token endpoint. As it is to the token endpoint we return an access token.
|
||||
*
|
||||
* @throws SodiumException
|
||||
*/
|
||||
public function processTokenRequest(Request $request): JsonResponse
|
||||
{
|
||||
$indieAuthData = $this->validateAuthorizationCode($request);
|
||||
|
||||
if ($indieAuthData instanceof JsonResponse) {
|
||||
return $indieAuthData;
|
||||
}
|
||||
|
||||
if ($indieAuthData['scope'] === '') {
|
||||
return response()->json(['errors' => [
|
||||
'scope' => [
|
||||
'The scope property must be non-empty for an access token to be issued.',
|
||||
],
|
||||
]], 400);
|
||||
}
|
||||
|
||||
$tokenData = [
|
||||
'me' => config('app.url'),
|
||||
'client_id' => $request->get('client_id'),
|
||||
'scope' => $indieAuthData['scope'],
|
||||
];
|
||||
$tokenService = resolve(TokenService::class);
|
||||
$token = $tokenService->getNewToken($tokenData);
|
||||
|
||||
return response()->json([
|
||||
'access_token' => $token,
|
||||
'token_type' => 'Bearer',
|
||||
'scope' => $indieAuthData['scope'],
|
||||
'me' => config('app.url'),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function isValidRedirectUri(string $clientId, string $redirectUri): bool
|
||||
{
|
||||
// If client_id is not a valid URL, then it's not valid
|
||||
$clientIdParsed = \Mf2\parseUriToComponents($clientId);
|
||||
if (! isset($clientIdParsed['authority'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If redirect_uri is not a valid URL, then it's not valid
|
||||
$redirectUriParsed = \Mf2\parseUriToComponents($redirectUri);
|
||||
if (! isset($redirectUriParsed['authority'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If client_id and redirect_uri are the same host, then it's valid
|
||||
if ($clientIdParsed['authority'] === $redirectUriParsed['authority']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Otherwise we need to check the redirect_uri is in the client_id's redirect_uris
|
||||
$guzzle = resolve(Client::class);
|
||||
|
||||
try {
|
||||
$clientInfo = $guzzle->get($clientId);
|
||||
} catch (Exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$clientInfoParsed = \Mf2\parse($clientInfo->getBody()->getContents(), $clientId);
|
||||
|
||||
$redirectUris = $clientInfoParsed['rels']['redirect_uri'] ?? [];
|
||||
|
||||
return in_array($redirectUri, $redirectUris, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SodiumException
|
||||
*/
|
||||
protected function validateAuthorizationCode(Request $request): JsonResponse|array
|
||||
{
|
||||
// First check all the data is present
|
||||
$validator = Validator::make($request->all(), [
|
||||
'grant_type' => 'required:string',
|
||||
'code' => 'required:string',
|
||||
'client_id' => 'required',
|
||||
'redirect_uri' => 'required',
|
||||
'code_verifier' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['errors' => $validator->errors()], 400);
|
||||
}
|
||||
|
||||
if ($request->get('grant_type') !== 'authorization_code') {
|
||||
return response()->json(['errors' => [
|
||||
'grant_type' => [
|
||||
'Only a grant type of "authorization_code" is supported.',
|
||||
],
|
||||
]], 400);
|
||||
}
|
||||
|
||||
// Check cache for auth code
|
||||
$cacheKey = hash('xxh3', $request->get('client_id'));
|
||||
$indieAuthRequestData = Cache::pull($cacheKey);
|
||||
|
||||
if ($indieAuthRequestData === null) {
|
||||
return response()->json(['errors' => [
|
||||
'code' => [
|
||||
'The code is invalid.',
|
||||
],
|
||||
]], 404);
|
||||
}
|
||||
|
||||
// Check the IndieAuth code
|
||||
if (! array_key_exists('auth_code', $indieAuthRequestData)) {
|
||||
return response()->json(['errors' => [
|
||||
'code' => [
|
||||
'The code is invalid.',
|
||||
],
|
||||
]], 400);
|
||||
}
|
||||
if ($indieAuthRequestData['auth_code'] !== $request->get('code')) {
|
||||
return response()->json(['errors' => [
|
||||
'code' => [
|
||||
'The code is invalid.',
|
||||
],
|
||||
]], 400);
|
||||
}
|
||||
|
||||
// Check code verifier
|
||||
if (! array_key_exists('code_challenge', $indieAuthRequestData)) {
|
||||
return response()->json(['errors' => [
|
||||
'code_verifier' => [
|
||||
'The code verifier is invalid.',
|
||||
],
|
||||
]], 400);
|
||||
}
|
||||
if (! hash_equals(
|
||||
$indieAuthRequestData['code_challenge'],
|
||||
sodium_bin2base64(
|
||||
hash('sha256', $request->get('code_verifier'), true),
|
||||
SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING
|
||||
)
|
||||
)) {
|
||||
return response()->json(['errors' => [
|
||||
'code_verifier' => [
|
||||
'The code verifier is invalid.',
|
||||
],
|
||||
]], 400);
|
||||
}
|
||||
|
||||
// Check redirect_uri
|
||||
if (! array_key_exists('redirect_uri', $indieAuthRequestData)) {
|
||||
return response()->json(['errors' => [
|
||||
'redirect_uri' => [
|
||||
'The redirect uri is invalid.',
|
||||
],
|
||||
]], 400);
|
||||
}
|
||||
if ($indieAuthRequestData['redirect_uri'] !== $request->get('redirect_uri')) {
|
||||
return response()->json(['errors' => [
|
||||
'redirect_uri' => [
|
||||
'The redirect uri is invalid.',
|
||||
],
|
||||
]], 400);
|
||||
}
|
||||
|
||||
// Check client_id
|
||||
if (! array_key_exists('client_id', $indieAuthRequestData)) {
|
||||
return response()->json(['errors' => [
|
||||
'client_id' => [
|
||||
'The client id is invalid.',
|
||||
],
|
||||
]], 400);
|
||||
}
|
||||
if ($indieAuthRequestData['client_id'] !== $request->get('client_id')) {
|
||||
return response()->json(['errors' => [
|
||||
'client_id' => [
|
||||
'The client id is invalid.',
|
||||
],
|
||||
]], 400);
|
||||
}
|
||||
|
||||
return $indieAuthRequestData;
|
||||
}
|
||||
}
|
|
@ -11,8 +11,6 @@ class LikesController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show the latest likes.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -23,9 +21,6 @@ class LikesController extends Controller
|
|||
|
||||
/**
|
||||
* Show a single like.
|
||||
*
|
||||
* @param Like $like
|
||||
* @return View
|
||||
*/
|
||||
public function show(Like $like): View
|
||||
{
|
||||
|
|
|
@ -4,107 +4,73 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Responses\MicropubResponses;
|
||||
use App\Exceptions\InvalidTokenScopeException;
|
||||
use App\Exceptions\MicropubHandlerException;
|
||||
use App\Http\Requests\MicropubRequest;
|
||||
use App\Models\Place;
|
||||
use App\Services\Micropub\HCardService;
|
||||
use App\Services\Micropub\HEntryService;
|
||||
use App\Services\Micropub\UpdateService;
|
||||
use App\Services\TokenService;
|
||||
use App\Models\SyndicationTarget;
|
||||
use App\Services\Micropub\MicropubHandlerRegistry;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Lcobucci\JWT\Encoding\CannotDecodeContent;
|
||||
use Lcobucci\JWT\Token\InvalidTokenStructure;
|
||||
use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Logger;
|
||||
use Illuminate\Http\Request;
|
||||
use Lcobucci\JWT\Token;
|
||||
|
||||
class MicropubController extends Controller
|
||||
{
|
||||
protected TokenService $tokenService;
|
||||
protected MicropubHandlerRegistry $handlerRegistry;
|
||||
|
||||
protected HEntryService $hentryService;
|
||||
|
||||
protected HCardService $hcardService;
|
||||
|
||||
protected UpdateService $updateService;
|
||||
|
||||
public function __construct(
|
||||
TokenService $tokenService,
|
||||
HEntryService $hentryService,
|
||||
HCardService $hcardService,
|
||||
UpdateService $updateService
|
||||
) {
|
||||
$this->tokenService = $tokenService;
|
||||
$this->hentryService = $hentryService;
|
||||
$this->hcardService = $hcardService;
|
||||
$this->updateService = $updateService;
|
||||
public function __construct(MicropubHandlerRegistry $handlerRegistry)
|
||||
{
|
||||
$this->handlerRegistry = $handlerRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function receives an API request, verifies the authenticity
|
||||
* then passes over the info to the relevant Service class.
|
||||
* Respond to a POST request to the micropub endpoint.
|
||||
*
|
||||
* @return JsonResponse
|
||||
* The request is initially processed by the MicropubRequest form request
|
||||
* class. The normalizes the data, so we can pass it into the handlers for
|
||||
* the different micropub requests, h-entry or h-card, for example.
|
||||
*/
|
||||
public function post(): JsonResponse
|
||||
public function post(MicropubRequest $request): JsonResponse
|
||||
{
|
||||
$type = $request->getType();
|
||||
|
||||
if (! $type) {
|
||||
return response()->json([
|
||||
'error' => 'invalid_request',
|
||||
'error_description' => 'Microformat object type is missing, for example: h-entry or h-card',
|
||||
], 400);
|
||||
}
|
||||
|
||||
try {
|
||||
$tokenData = $this->tokenService->validateToken(request()->input('access_token'));
|
||||
} catch (RequiredConstraintsViolated | InvalidTokenStructure | CannotDecodeContent $exception) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
|
||||
return $micropubResponses->invalidTokenResponse();
|
||||
}
|
||||
|
||||
if ($tokenData->claims()->has('scope') === false) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
|
||||
return $micropubResponses->tokenHasNoScopeResponse();
|
||||
}
|
||||
|
||||
$this->logMicropubRequest(request()->all());
|
||||
|
||||
if ((request()->input('h') == 'entry') || (request()->input('type.0') == 'h-entry')) {
|
||||
if (stristr($tokenData->claims()->get('scope'), 'create') === false) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
|
||||
return $micropubResponses->insufficientScopeResponse();
|
||||
}
|
||||
$location = $this->hentryService->process(request()->all(), $this->getCLientId());
|
||||
$handler = $this->handlerRegistry->getHandler($type);
|
||||
$result = $handler->handle($request->getMicropubData());
|
||||
|
||||
// Return appropriate response based on the handler result
|
||||
return response()->json([
|
||||
'response' => 'created',
|
||||
'location' => $location,
|
||||
], 201)->header('Location', $location);
|
||||
}
|
||||
|
||||
if (request()->input('h') == 'card' || request()->input('type.0') == 'h-card') {
|
||||
if (stristr($tokenData->claims()->get('scope'), 'create') === false) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
|
||||
return $micropubResponses->insufficientScopeResponse();
|
||||
}
|
||||
$location = $this->hcardService->process(request()->all());
|
||||
|
||||
'response' => $result['response'],
|
||||
'location' => $result['url'] ?? null,
|
||||
], 201)->header('Location', $result['url']);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return response()->json([
|
||||
'response' => 'created',
|
||||
'location' => $location,
|
||||
], 201)->header('Location', $location);
|
||||
'error' => 'invalid_request',
|
||||
'error_description' => $e->getMessage(),
|
||||
], 400);
|
||||
} catch (MicropubHandlerException) {
|
||||
return response()->json([
|
||||
'error' => 'Unknown Micropub type',
|
||||
'error_description' => 'The request could not be processed by this server',
|
||||
], 500);
|
||||
} catch (InvalidTokenScopeException) {
|
||||
return response()->json([
|
||||
'error' => 'invalid_scope',
|
||||
'error_description' => 'The token does not have the required scope for this request',
|
||||
], 403);
|
||||
} catch (\Exception) {
|
||||
return response()->json([
|
||||
'error' => 'server_error',
|
||||
'error_description' => 'An error occurred processing the request',
|
||||
], 500);
|
||||
}
|
||||
|
||||
if (request()->input('action') == 'update') {
|
||||
if (stristr($tokenData->claims()->get('scope'), 'update') === false) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
|
||||
return $micropubResponses->insufficientScopeResponse();
|
||||
}
|
||||
|
||||
return $this->updateService->process(request()->all());
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'response' => 'error',
|
||||
'error_description' => 'unsupported_request_type',
|
||||
], 500);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,39 +80,29 @@ class MicropubController extends Controller
|
|||
* token, here we check whether the token is valid and respond
|
||||
* appropriately. Further if the request has the query parameter
|
||||
* syndicate-to we respond with the known syndication endpoints.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function get(): JsonResponse
|
||||
public function get(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$tokenData = $this->tokenService->validateToken(request()->input('access_token'));
|
||||
} catch (RequiredConstraintsViolated | InvalidTokenStructure $exception) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
|
||||
return $micropubResponses->invalidTokenResponse();
|
||||
}
|
||||
|
||||
if (request()->input('q') === 'syndicate-to') {
|
||||
if ($request->input('q') === 'syndicate-to') {
|
||||
return response()->json([
|
||||
'syndicate-to' => config('syndication.targets'),
|
||||
'syndicate-to' => SyndicationTarget::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
if (request()->input('q') == 'config') {
|
||||
if ($request->input('q') === 'config') {
|
||||
return response()->json([
|
||||
'syndicate-to' => config('syndication.targets'),
|
||||
'syndicate-to' => SyndicationTarget::all(),
|
||||
'media-endpoint' => route('media-endpoint'),
|
||||
]);
|
||||
}
|
||||
|
||||
if (request()->has('q') && substr(request()->input('q'), 0, 4) === 'geo:') {
|
||||
if ($request->has('q') && str_starts_with($request->input('q'), 'geo:')) {
|
||||
preg_match_all(
|
||||
'/([0-9.\-]+)/',
|
||||
request()->input('q'),
|
||||
$request->input('q'),
|
||||
$matches
|
||||
);
|
||||
$distance = (count($matches[0]) == 3) ? 100 * $matches[0][2] : 1000;
|
||||
$distance = (count($matches[0]) === 3) ? 100 * $matches[0][2] : 1000;
|
||||
$places = Place::near(
|
||||
(object) ['latitude' => $matches[0][0], 'longitude' => $matches[0][1]],
|
||||
$distance
|
||||
|
@ -158,40 +114,17 @@ class MicropubController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
// default response is just to return the token data
|
||||
// the default response is just to return the token data
|
||||
/** @var Token $tokenData */
|
||||
$tokenData = $request->input('token_data');
|
||||
|
||||
return response()->json([
|
||||
'response' => 'token',
|
||||
'token' => [
|
||||
'me' => $tokenData->claims()->get('me'),
|
||||
'scope' => $tokenData->claims()->get('scope'),
|
||||
'client_id' => $tokenData->claims()->get('client_id'),
|
||||
'me' => $tokenData['me'],
|
||||
'scope' => $tokenData['scope'],
|
||||
'client_id' => $tokenData['client_id'],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the client id from the access token sent with the request.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws RequiredConstraintsViolated
|
||||
*/
|
||||
private function getClientId(): string
|
||||
{
|
||||
return resolve(TokenService::class)
|
||||
->validateToken(request()->input('access_token'))
|
||||
->claims()->get('client_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the details of the micropub request to a log file.
|
||||
*
|
||||
* @param array $request This is the info from request()->all()
|
||||
*/
|
||||
private function logMicropubRequest(array $request)
|
||||
{
|
||||
$logger = new Logger('micropub');
|
||||
$logger->pushHandler(new StreamHandler(storage_path('logs/micropub.log')));
|
||||
$logger->debug('MicropubLog', $request);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,85 +7,64 @@ namespace App\Http\Controllers;
|
|||
use App\Http\Responses\MicropubResponses;
|
||||
use App\Jobs\ProcessMedia;
|
||||
use App\Models\Media;
|
||||
use App\Services\TokenService;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\File;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Lcobucci\JWT\Token\InvalidTokenStructure;
|
||||
use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
class MicropubMediaController extends Controller
|
||||
{
|
||||
protected TokenService $tokenService;
|
||||
|
||||
public function __construct(TokenService $tokenService)
|
||||
public function getHandler(Request $request): JsonResponse
|
||||
{
|
||||
$this->tokenService = $tokenService;
|
||||
}
|
||||
$tokenData = $request->input('token_data');
|
||||
|
||||
public function getHandler(): JsonResponse
|
||||
{
|
||||
try {
|
||||
$tokenData = $this->tokenService->validateToken(request()->input('access_token'));
|
||||
} catch (RequiredConstraintsViolated | InvalidTokenStructure $exception) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
|
||||
return $micropubResponses->invalidTokenResponse();
|
||||
$scopes = $tokenData['scope'];
|
||||
if (is_string($scopes)) {
|
||||
$scopes = explode(' ', $scopes);
|
||||
}
|
||||
if (! in_array('create', $scopes, true)) {
|
||||
return (new MicropubResponses)->insufficientScopeResponse();
|
||||
}
|
||||
|
||||
if ($tokenData->claims()->has('scope') === false) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
if ($request->input('q') === 'last') {
|
||||
$media = Media::where('created_at', '>=', Carbon::now()->subMinutes(30))
|
||||
->where('token', $request->input('access_token'))
|
||||
->latest()
|
||||
->first();
|
||||
$mediaUrl = $media?->url;
|
||||
|
||||
return $micropubResponses->tokenHasNoScopeResponse();
|
||||
return response()->json(['url' => $mediaUrl]);
|
||||
}
|
||||
|
||||
if (Str::contains($tokenData->claims()->get('scope'), 'create') === false) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
|
||||
return $micropubResponses->insufficientScopeResponse();
|
||||
}
|
||||
|
||||
if (request()->input('q') === 'last') {
|
||||
try {
|
||||
$media = Media::latest()->whereDate('created_at', '>=', Carbon::now()->subMinutes(30))->firstOrFail();
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
return response()->json(['url' => null]);
|
||||
}
|
||||
|
||||
return response()->json(['url' => $media->url]);
|
||||
}
|
||||
|
||||
if (request()->input('q') === 'source') {
|
||||
$limit = request()->input('limit', 10);
|
||||
$offset = request()->input('offset', 0);
|
||||
if ($request->input('q') === 'source') {
|
||||
$limit = $request->input('limit', 10);
|
||||
$offset = $request->input('offset', 0);
|
||||
|
||||
$media = Media::latest()->offset($offset)->limit($limit)->get();
|
||||
|
||||
$media->transform(function ($mediaItem) {
|
||||
return [
|
||||
'url' => $mediaItem->url,
|
||||
'published' => $mediaItem->created_at->toW3cString(),
|
||||
'mime_type' => $mediaItem->mimetype,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json(['items' => $media]);
|
||||
}
|
||||
|
||||
if (request()->has('q')) {
|
||||
if ($request->has('q')) {
|
||||
return response()->json([
|
||||
'error' => 'invalid_request',
|
||||
'error_description' => sprintf(
|
||||
'This server does not know how to handle this q parameter (%s)',
|
||||
request()->input('q')
|
||||
$request->input('q')
|
||||
),
|
||||
], 400);
|
||||
}
|
||||
|
@ -96,34 +75,22 @@ class MicropubMediaController extends Controller
|
|||
/**
|
||||
* Process a media item posted to the media endpoint.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
* @throws BindingResolutionException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function media(): JsonResponse
|
||||
public function media(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$tokenData = $this->tokenService->validateToken(request()->input('access_token'));
|
||||
} catch (RequiredConstraintsViolated | InvalidTokenStructure $exception) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
$tokenData = $request->input('token_data');
|
||||
|
||||
return $micropubResponses->invalidTokenResponse();
|
||||
$scopes = $tokenData['scope'];
|
||||
if (is_string($scopes)) {
|
||||
$scopes = explode(' ', $scopes);
|
||||
}
|
||||
if (! in_array('create', $scopes, true)) {
|
||||
return (new MicropubResponses)->insufficientScopeResponse();
|
||||
}
|
||||
|
||||
if ($tokenData->claims()->has('scope') === false) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
|
||||
return $micropubResponses->tokenHasNoScopeResponse();
|
||||
}
|
||||
|
||||
if (Str::contains($tokenData->claims()->get('scope'), 'create') === false) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
|
||||
return $micropubResponses->insufficientScopeResponse();
|
||||
}
|
||||
|
||||
if (request()->hasFile('file') === false) {
|
||||
if ($request->hasFile('file') === false) {
|
||||
return response()->json([
|
||||
'response' => 'error',
|
||||
'error' => 'invalid_request',
|
||||
|
@ -131,7 +98,10 @@ class MicropubMediaController extends Controller
|
|||
], 400);
|
||||
}
|
||||
|
||||
if (request()->file('file')->isValid() === false) {
|
||||
/** @var UploadedFile $file */
|
||||
$file = $request->file('file');
|
||||
|
||||
if ($file->isValid() === false) {
|
||||
return response()->json([
|
||||
'response' => 'error',
|
||||
'error' => 'invalid_request',
|
||||
|
@ -139,31 +109,25 @@ class MicropubMediaController extends Controller
|
|||
], 400);
|
||||
}
|
||||
|
||||
$filename = $this->saveFile(request()->file('file'));
|
||||
$filename = Storage::disk('local')->putFile('media', $file);
|
||||
|
||||
/** @var ImageManager $manager */
|
||||
$manager = resolve(ImageManager::class);
|
||||
try {
|
||||
$image = $manager->make(request()->file('file'));
|
||||
$image = $manager->read($request->file('file'));
|
||||
$width = $image->width();
|
||||
} catch (NotReadableException $exception) {
|
||||
} catch (Exception) {
|
||||
// not an image
|
||||
$width = null;
|
||||
}
|
||||
|
||||
$media = Media::create([
|
||||
'token' => request()->bearerToken(),
|
||||
'path' => 'media/' . $filename,
|
||||
'type' => $this->getFileTypeFromMimeType(request()->file('file')->getMimeType()),
|
||||
'token' => $request->input('access_token'),
|
||||
'path' => $filename,
|
||||
'type' => $this->getFileTypeFromMimeType($request->file('file')->getMimeType()),
|
||||
'image_widths' => $width,
|
||||
]);
|
||||
|
||||
// put the file on S3 initially, the ProcessMedia job may edit this
|
||||
Storage::disk('s3')->putFileAs(
|
||||
'media',
|
||||
new File(storage_path('app') . '/' . $filename),
|
||||
$filename
|
||||
);
|
||||
|
||||
ProcessMedia::dispatch($filename);
|
||||
|
||||
return response()->json([
|
||||
|
@ -174,8 +138,6 @@ class MicropubMediaController extends Controller
|
|||
|
||||
/**
|
||||
* Return the relevant CORS headers to a pre-flight OPTIONS request.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function mediaOptionsResponse(): Response
|
||||
{
|
||||
|
@ -184,13 +146,10 @@ class MicropubMediaController extends Controller
|
|||
|
||||
/**
|
||||
* Get the file type from the mime-type of the uploaded file.
|
||||
*
|
||||
* @param string $mimeType
|
||||
* @return string
|
||||
*/
|
||||
private function getFileTypeFromMimeType(string $mimeType): string
|
||||
{
|
||||
//try known images
|
||||
// try known images
|
||||
$imageMimeTypes = [
|
||||
'image/gif',
|
||||
'image/jpeg',
|
||||
|
@ -202,7 +161,7 @@ class MicropubMediaController extends Controller
|
|||
if (in_array($mimeType, $imageMimeTypes)) {
|
||||
return 'image';
|
||||
}
|
||||
//try known video
|
||||
// try known video
|
||||
$videoMimeTypes = [
|
||||
'video/mp4',
|
||||
'video/mpeg',
|
||||
|
@ -213,7 +172,7 @@ class MicropubMediaController extends Controller
|
|||
if (in_array($mimeType, $videoMimeTypes)) {
|
||||
return 'video';
|
||||
}
|
||||
//try known audio types
|
||||
// try known audio types
|
||||
$audioMimeTypes = [
|
||||
'audio/midi',
|
||||
'audio/mpeg',
|
||||
|
@ -230,12 +189,9 @@ class MicropubMediaController extends Controller
|
|||
/**
|
||||
* Save an uploaded file to the local disk.
|
||||
*
|
||||
* @param UploadedFile $file
|
||||
* @return string
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function saveFile(UploadedFile $file): string
|
||||
private function saveFileToLocal(UploadedFile $file): string
|
||||
{
|
||||
$filename = Uuid::uuid4()->toString() . '.' . $file->extension();
|
||||
Storage::disk('local')->putFileAs('', $file, $filename);
|
||||
|
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Note;
|
||||
use App\Services\ActivityStreamsService;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
@ -13,25 +12,26 @@ use Illuminate\Http\Response;
|
|||
use Illuminate\View\View;
|
||||
use Jonnybarnes\IndieWeb\Numbers;
|
||||
|
||||
// Need to sort out Twitter and webmentions!
|
||||
|
||||
/**
|
||||
* @todo Need to sort out Twitter and webmentions!
|
||||
*/
|
||||
class NotesController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show all the notes. This is also the homepage.
|
||||
*
|
||||
* @return View|Response
|
||||
*/
|
||||
public function index()
|
||||
public function index(): View|Response
|
||||
{
|
||||
if (request()->wantsActivityStream()) {
|
||||
return (new ActivityStreamsService())->siteOwnerResponse();
|
||||
}
|
||||
|
||||
$notes = Note::latest()
|
||||
->with('place', 'media', 'client')
|
||||
->withCount(['webmentions As replies' => function ($query) {
|
||||
->withCount(['webmentions AS replies' => function ($query) {
|
||||
$query->where('type', 'in-reply-to');
|
||||
}])
|
||||
->withCount(['webmentions AS likes' => function ($query) {
|
||||
$query->where('type', 'like-of');
|
||||
}])
|
||||
->withCount(['webmentions AS reposts' => function ($query) {
|
||||
$query->where('type', 'repost-of');
|
||||
}])->paginate(10);
|
||||
|
||||
return view('notes.index', compact('notes'));
|
||||
|
@ -39,41 +39,37 @@ class NotesController extends Controller
|
|||
|
||||
/**
|
||||
* Show a single note.
|
||||
*
|
||||
* @param string $urlId The id of the note
|
||||
* @return View|JsonResponse|Response
|
||||
*/
|
||||
public function show(string $urlId)
|
||||
public function show(string $urlId): View|JsonResponse|Response
|
||||
{
|
||||
try {
|
||||
$note = Note::nb60($urlId)->with('webmentions')->firstOrFail();
|
||||
$note = Note::nb60($urlId)->with('place', 'media', 'client')
|
||||
->withCount(['webmentions AS replies' => function ($query) {
|
||||
$query->where('type', 'in-reply-to');
|
||||
}])
|
||||
->withCount(['webmentions AS likes' => function ($query) {
|
||||
$query->where('type', 'like-of');
|
||||
}])
|
||||
->withCount(['webmentions AS reposts' => function ($query) {
|
||||
$query->where('type', 'repost-of');
|
||||
}])->firstOrFail();
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if (request()->wantsActivityStream()) {
|
||||
return (new ActivityStreamsService())->singleNoteResponse($note);
|
||||
}
|
||||
|
||||
return view('notes.show', compact('note'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect /note/{decID} to /notes/{nb60id}.
|
||||
*
|
||||
* @param int $decId The decimal id of the note
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function redirect(int $decId): RedirectResponse
|
||||
{
|
||||
return redirect(config('app.url') . '/notes/' . (new Numbers())->numto60($decId));
|
||||
return redirect(config('app.url') . '/notes/' . (new Numbers)->numto60($decId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all notes tagged with {tag}.
|
||||
*
|
||||
* @param string $tag
|
||||
* @return View
|
||||
*/
|
||||
public function tagged(string $tag): View
|
||||
{
|
||||
|
@ -88,8 +84,6 @@ class NotesController extends Controller
|
|||
* Page to create a new note.
|
||||
*
|
||||
* Dummy page for now.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
|
|
|
@ -11,8 +11,6 @@ class PlacesController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show all the places.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -23,9 +21,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Show a specific place.
|
||||
*
|
||||
* @param Place $place
|
||||
* @return View
|
||||
*/
|
||||
public function show(Place $place): View
|
||||
{
|
||||
|
|
34
app/Http/Controllers/SearchController.php
Normal file
34
app/Http/Controllers/SearchController.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Note;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class SearchController extends Controller
|
||||
{
|
||||
public function search(Request $request): View
|
||||
{
|
||||
$search = $request->input('q');
|
||||
|
||||
$notes = Note::search($search)
|
||||
->paginate();
|
||||
|
||||
/** @var Note $note */
|
||||
foreach ($notes as $note) {
|
||||
$note->load('place', 'media', 'client')
|
||||
->loadCount(['webmentions AS replies' => function ($query) {
|
||||
$query->where('type', 'in-reply-to');
|
||||
}])
|
||||
->loadCount(['webmentions AS likes' => function ($query) {
|
||||
$query->where('type', 'like-of');
|
||||
}])
|
||||
->loadCount(['webmentions AS reposts' => function ($query) {
|
||||
$query->where('type', 'repost-of');
|
||||
}]);
|
||||
}
|
||||
|
||||
return view('search', compact('search', 'notes'));
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class ShortURLsController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Short URL Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This redirects the short urls to long ones
|
||||
|
|
||||
*/
|
||||
|
||||
/**
|
||||
* Redirect from '/' to the long url.
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function baseURL(): RedirectResponse
|
||||
{
|
||||
return redirect(config('app.url'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect from '/@' to a twitter profile.
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function twitter(): RedirectResponse
|
||||
{
|
||||
return redirect('https://twitter.com/jonnybarnes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect a short url of this site out to a long one based on post type.
|
||||
* Further redirects may happen.
|
||||
*
|
||||
* @param string Post type
|
||||
* @param string Post ID
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function expandType(string $type, string $postId): RedirectResponse
|
||||
{
|
||||
if ($type == 't') {
|
||||
$type = 'notes';
|
||||
}
|
||||
if ($type == 'b') {
|
||||
$type = 'blog/s';
|
||||
}
|
||||
|
||||
return redirect(config('app.url') . '/' . $type . '/' . $postId);
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\TokenService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use IndieAuth\Client;
|
||||
|
||||
class TokenEndpointController extends Controller
|
||||
{
|
||||
/**
|
||||
* The IndieAuth Client.
|
||||
*/
|
||||
protected Client $client;
|
||||
|
||||
/**
|
||||
* The Token handling service.
|
||||
*/
|
||||
protected TokenService $tokenService;
|
||||
|
||||
/**
|
||||
* Inject the dependencies.
|
||||
*
|
||||
* @param Client $client
|
||||
* @param TokenService $tokenService
|
||||
*/
|
||||
public function __construct(
|
||||
Client $client,
|
||||
TokenService $tokenService
|
||||
) {
|
||||
$this->client = $client;
|
||||
$this->tokenService = $tokenService;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the user has auth’d via the IndieAuth protocol, issue a valid token.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(): JsonResponse
|
||||
{
|
||||
$authorizationEndpoint = $this->client->discoverAuthorizationEndpoint(normalize_url(request()->input('me')));
|
||||
if ($authorizationEndpoint) {
|
||||
$auth = $this->client->verifyIndieAuthCode(
|
||||
$authorizationEndpoint,
|
||||
request()->input('code'),
|
||||
request()->input('me'),
|
||||
request()->input('redirect_uri'),
|
||||
request()->input('client_id'),
|
||||
null // code_verifier
|
||||
);
|
||||
if (array_key_exists('me', $auth)) {
|
||||
$scope = $auth['scope'] ?? '';
|
||||
$tokenData = [
|
||||
'me' => request()->input('me'),
|
||||
'client_id' => request()->input('client_id'),
|
||||
'scope' => $scope,
|
||||
];
|
||||
$token = $this->tokenService->getNewToken($tokenData);
|
||||
$content = [
|
||||
'me' => request()->input('me'),
|
||||
'scope' => $scope,
|
||||
'access_token' => $token,
|
||||
];
|
||||
|
||||
return response()->json($content);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'error' => 'There was an error verifying the authorisation code.',
|
||||
], 401);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'error' => 'Can’t determine the authorisation endpoint.',
|
||||
], 400);
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ namespace App\Http\Controllers;
|
|||
use App\Jobs\ProcessWebMention;
|
||||
use App\Models\Note;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\View\View;
|
||||
use Jonnybarnes\IndieWeb\Numbers;
|
||||
|
@ -18,8 +19,6 @@ class WebMentionsController extends Controller
|
|||
*
|
||||
* This is probably someone looking for information about what
|
||||
* webmentions are, or about my particular implementation.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function get(): View
|
||||
{
|
||||
|
@ -28,29 +27,27 @@ class WebMentionsController extends Controller
|
|||
|
||||
/**
|
||||
* Receive and process a webmention.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function receive(): Response
|
||||
public function receive(Request $request): Response
|
||||
{
|
||||
//first we trivially reject requests that lack all required inputs
|
||||
if ((request()->has('target') !== true) || (request()->has('source') !== true)) {
|
||||
// first we trivially reject requests that lack all required inputs
|
||||
if (($request->has('target') !== true) || ($request->has('source') !== true)) {
|
||||
return response(
|
||||
'You need both the target and source parameters',
|
||||
400
|
||||
);
|
||||
}
|
||||
|
||||
//next check the $target is valid
|
||||
$path = parse_url(request()->input('target'), PHP_URL_PATH);
|
||||
// next check the $target is valid
|
||||
$path = parse_url($request->input('target'), PHP_URL_PATH);
|
||||
$pathParts = explode('/', $path);
|
||||
|
||||
if ($pathParts[1] == 'notes') {
|
||||
//we have a note
|
||||
if ($pathParts[1] === 'notes') {
|
||||
// we have a note
|
||||
$noteId = $pathParts[2];
|
||||
try {
|
||||
$note = Note::findOrFail(resolve(Numbers::class)->b60tonum($noteId));
|
||||
dispatch(new ProcessWebMention($note, request()->input('source')));
|
||||
dispatch(new ProcessWebMention($note, $request->input('source')));
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return response('This note doesn’t exist.', 400);
|
||||
}
|
||||
|
@ -60,7 +57,7 @@ class WebMentionsController extends Controller
|
|||
202
|
||||
);
|
||||
}
|
||||
if ($pathParts[1] == 'blog') {
|
||||
if ($pathParts[1] === 'blog') {
|
||||
return response(
|
||||
'I don’t accept webmentions for blog posts yet.',
|
||||
501
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\LinkHeadersMiddleware::class,
|
||||
\App\Http\Middleware\LocalhostSessionMiddleware::class,
|
||||
\App\Http\Middleware\ActivityStreamLinks::class,
|
||||
\App\Http\Middleware\CSPHeader::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'micropub.token' => \App\Http\Middleware\VerifyMicropubToken::class,
|
||||
'myauth' => \App\Http\Middleware\MyAuthMiddleware::class,
|
||||
'cors' => \App\Http\Middleware\CorsHeaders::class,
|
||||
];
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ActivityStreamLinks
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
if ($request->path() === '/') {
|
||||
$response->header('Link', '<' . config('app.url') . '>; rel="application/activity+json"', false);
|
||||
}
|
||||
if ($request->is('notes/*')) {
|
||||
$response->header('Link', '<' . $request->url() . '>; rel="application/activity+json"', false);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
|
@ -11,14 +12,9 @@ class Authenticate extends Middleware
|
|||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
protected function redirectTo(Request $request): ?string
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
return $request->expectsJson() ? null : route('login');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class CSPHeader
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (App::environment('local', 'development')) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
// headers have to be single-line strings,
|
||||
// so we concat multiple lines
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
return $next($request)
|
||||
->header(
|
||||
'Content-Security-Policy',
|
||||
"default-src 'self'; " .
|
||||
"style-src 'self' cloud.typography.com jonnybarnes.uk; " .
|
||||
"img-src 'self' data: blob: https://pbs.twimg.com https://jbuk-media.s3-eu-west-1.amazonaws.com https://jbuk-media-dev.s3-eu-west-1.amazonaws.com https://secure.gravatar.com https://graph.facebook.com *.fbcdn.net https://*.cdninstagram.com https://*.4sqi.net https://upload.wikimedia.org; " .
|
||||
"font-src 'self' data:; " .
|
||||
"frame-src 'self' https://www.youtube.com blob:; " .
|
||||
'upgrade-insecure-requests; ' .
|
||||
'block-all-mixed-content; ' .
|
||||
'report-to csp-endpoint; ' .
|
||||
'report-uri https://jonnybarnes.report-uri.io/r/default/csp/enforce;'
|
||||
)->header(
|
||||
'Report-To',
|
||||
'{' .
|
||||
"'url': 'https://jonnybarnes.report-uri.io/r/default/csp/enforce', " .
|
||||
"'group': 'csp-endpoint', " .
|
||||
"'max-age': 10886400" .
|
||||
'}'
|
||||
);
|
||||
// phpcs:enable Generic.Files.LineLength.TooLong
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
||||
|
||||
class CheckForMaintenanceMode extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
|
@ -3,17 +3,15 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CorsHeaders
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$response = $next($request);
|
||||
if ($request->path() === 'api/media') {
|
||||
|
|
|
@ -9,7 +9,7 @@ class EncryptCookies extends Middleware
|
|||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
|
|
|
@ -3,23 +3,22 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class LinkHeadersMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$response = $next($request);
|
||||
$response->header('Link', '<https://indieauth.com/auth>; rel="authorization_endpoint"', false);
|
||||
$response->header('Link', '<' . config('app.url') . '/api/token>; rel="token_endpoint"', false);
|
||||
$response->header('Link', '<' . config('app.url') . '/api/post>; rel="micropub"', false);
|
||||
$response->header('Link', '<' . config('app.url') . '/webmention>; rel="webmention"', false);
|
||||
$response->header('Link', '<' . route('indieauth.metadata') . '>; rel="indieauth-metadata"', false);
|
||||
$response->header('Link', '<' . route('indieauth.start') . '>; rel="authorization_endpoint"', false);
|
||||
$response->header('Link', '<' . route('indieauth.token') . '>; rel="token_endpoint"', false);
|
||||
$response->header('Link', '<' . route('micropub-endpoint') . '>; rel="micropub"', false);
|
||||
$response->header('Link', '<' . route('webmention-endpoint') . '>; rel="webmention"', false);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace App\Http\Middleware;
|
|||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class LocalhostSessionMiddleware
|
||||
{
|
||||
|
@ -13,12 +14,8 @@ class LocalhostSessionMiddleware
|
|||
* Whilst we are developing locally, automatically log in as
|
||||
* `['me' => config('app.url')]` as I can’t manually log in as
|
||||
* a .localhost domain.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (config('app.env') !== 'production') {
|
||||
session(['me' => config('app.url')]);
|
||||
|
|
24
app/Http/Middleware/LogMicropubRequest.php
Normal file
24
app/Http/Middleware/LogMicropubRequest.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Logger;
|
||||
|
||||
class LogMicropubRequest
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response|JsonResponse
|
||||
{
|
||||
$logger = new Logger('micropub');
|
||||
$logger->pushHandler(new StreamHandler(storage_path('logs/micropub.log')));
|
||||
$logger->debug('MicropubLog', $request->all());
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -7,20 +7,19 @@ namespace App\Http\Middleware;
|
|||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class MyAuthMiddleware
|
||||
{
|
||||
/**
|
||||
* Check the user is logged in.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (Auth::check($request->user()) == false) {
|
||||
//they’re not logged in, so send them to login form
|
||||
if (Auth::check() === false) {
|
||||
// they’re not logged in, so send them to login form
|
||||
redirect()->setIntendedUrl($request->fullUrl());
|
||||
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ class PreventRequestsDuringMaintenance extends Middleware
|
|||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
|
|
|
@ -6,6 +6,7 @@ use App\Providers\RouteServiceProvider;
|
|||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
|
@ -15,12 +16,9 @@ class RedirectIfAuthenticated
|
|||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null ...$guards
|
||||
* @return mixed
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
public function handle(Request $request, Closure $next, string ...$guards): Response
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
|
|
|
@ -9,9 +9,10 @@ class TrimStrings extends Middleware
|
|||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
|
|
@ -12,9 +12,9 @@ class TrustHosts extends Middleware
|
|||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts()
|
||||
public function hosts(): array
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
|
|
|
@ -10,7 +10,7 @@ class TrustProxies extends Middleware
|
|||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array|string
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
|
|
22
app/Http/Middleware/ValidateSignature.php
Normal file
22
app/Http/Middleware/ValidateSignature.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||
|
||||
class ValidateSignature extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
// 'fbclid',
|
||||
// 'utm_campaign',
|
||||
// 'utm_content',
|
||||
// 'utm_medium',
|
||||
// 'utm_source',
|
||||
// 'utm_term',
|
||||
];
|
||||
}
|
|
@ -9,7 +9,7 @@ class VerifyCsrfToken extends Middleware
|
|||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'api/media',
|
||||
|
|
|
@ -4,34 +4,78 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Http\Responses\MicropubResponses;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Lcobucci\JWT\Configuration;
|
||||
use Lcobucci\JWT\Encoding\CannotDecodeContent;
|
||||
use Lcobucci\JWT\Token;
|
||||
use Lcobucci\JWT\Token\InvalidTokenStructure;
|
||||
use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class VerifyMicropubToken
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @param Closure(Request): (Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$rawToken = null;
|
||||
|
||||
if ($request->input('access_token')) {
|
||||
return $next($request);
|
||||
$rawToken = $request->input('access_token');
|
||||
} elseif ($request->bearerToken()) {
|
||||
$rawToken = $request->bearerToken();
|
||||
}
|
||||
|
||||
if ($request->bearerToken()) {
|
||||
return $next($request->merge([
|
||||
'access_token' => $request->bearerToken(),
|
||||
]));
|
||||
if (! $rawToken) {
|
||||
return response()->json([
|
||||
'response' => 'error',
|
||||
'error' => 'unauthorized',
|
||||
'error_description' => 'No access token was provided in the request',
|
||||
], 401);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'response' => 'error',
|
||||
'error' => 'unauthorized',
|
||||
'error_description' => 'No access token was provided in the request',
|
||||
], 401);
|
||||
try {
|
||||
$tokenData = $this->validateToken($rawToken);
|
||||
} catch (RequiredConstraintsViolated|InvalidTokenStructure|CannotDecodeContent) {
|
||||
$micropubResponses = new MicropubResponses;
|
||||
|
||||
return $micropubResponses->invalidTokenResponse();
|
||||
}
|
||||
|
||||
if ($tokenData->claims()->has('scope') === false) {
|
||||
$micropubResponses = new MicropubResponses;
|
||||
|
||||
return $micropubResponses->tokenHasNoScopeResponse();
|
||||
}
|
||||
|
||||
return $next($request->merge([
|
||||
'access_token' => $rawToken,
|
||||
'token_data' => [
|
||||
'me' => $tokenData->claims()->get('me'),
|
||||
'scope' => $tokenData->claims()->get('scope'),
|
||||
'client_id' => $tokenData->claims()->get('client_id'),
|
||||
],
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the token signature is valid.
|
||||
*/
|
||||
private function validateToken(string $bearerToken): Token
|
||||
{
|
||||
$config = resolve(Configuration::class);
|
||||
|
||||
$token = $config->parser()->parse($bearerToken);
|
||||
|
||||
$constraints = $config->validationConstraints();
|
||||
|
||||
$config->validator()->assert($token, ...$constraints);
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
|
|
106
app/Http/Requests/MicropubRequest.php
Normal file
106
app/Http/Requests/MicropubRequest.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class MicropubRequest extends FormRequest
|
||||
{
|
||||
protected array $micropubData = [];
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
// Validation rules
|
||||
];
|
||||
}
|
||||
|
||||
public function getMicropubData(): array
|
||||
{
|
||||
return $this->micropubData;
|
||||
}
|
||||
|
||||
public function getType(): ?string
|
||||
{
|
||||
// Return consistent type regardless of input format
|
||||
return $this->micropubData['type'] ?? null;
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
// Normalize the request data based on content type
|
||||
if ($this->isJson()) {
|
||||
$this->normalizeMicropubJson();
|
||||
} else {
|
||||
$this->normalizeMicropubForm();
|
||||
}
|
||||
}
|
||||
|
||||
private function normalizeMicropubJson(): void
|
||||
{
|
||||
$json = $this->json();
|
||||
if ($json === null) {
|
||||
throw new \InvalidArgumentException('`isJson()` passed but there is no json data');
|
||||
}
|
||||
|
||||
$data = $json->all();
|
||||
|
||||
// Convert JSON type (h-entry) to simple type (entry)
|
||||
if (isset($data['type']) && is_array($data['type'])) {
|
||||
$type = current($data['type']);
|
||||
if (strpos($type, 'h-') === 0) {
|
||||
$this->micropubData['type'] = substr($type, 2);
|
||||
}
|
||||
}
|
||||
// Or set the type to update
|
||||
elseif (isset($data['action']) && $data['action'] === 'update') {
|
||||
$this->micropubData['type'] = 'update';
|
||||
}
|
||||
|
||||
// Add in the token data
|
||||
$this->micropubData['token_data'] = $data['token_data'];
|
||||
|
||||
// Add h-entry values
|
||||
$this->micropubData['content'] = Arr::get($data, 'properties.content.0');
|
||||
$this->micropubData['in-reply-to'] = Arr::get($data, 'properties.in-reply-to.0');
|
||||
$this->micropubData['published'] = Arr::get($data, 'properties.published.0');
|
||||
$this->micropubData['location'] = Arr::get($data, 'location');
|
||||
$this->micropubData['bookmark-of'] = Arr::get($data, 'properties.bookmark-of.0');
|
||||
$this->micropubData['like-of'] = Arr::get($data, 'properties.like-of.0');
|
||||
$this->micropubData['mp-syndicate-to'] = Arr::get($data, 'properties.mp-syndicate-to');
|
||||
|
||||
// Add h-card values
|
||||
$this->micropubData['name'] = Arr::get($data, 'properties.name.0');
|
||||
$this->micropubData['description'] = Arr::get($data, 'properties.description.0');
|
||||
$this->micropubData['geo'] = Arr::get($data, 'properties.geo.0');
|
||||
|
||||
// Add checkin value
|
||||
$this->micropubData['checkin'] = Arr::get($data, 'checkin');
|
||||
$this->micropubData['syndication'] = Arr::get($data, 'properties.syndication.0');
|
||||
}
|
||||
|
||||
private function normalizeMicropubForm(): void
|
||||
{
|
||||
// Convert form h=entry to type=entry
|
||||
if ($h = $this->input('h')) {
|
||||
$this->micropubData['type'] = $h;
|
||||
}
|
||||
|
||||
// Add some fields to the micropub data with default null values
|
||||
$this->micropubData['in-reply-to'] = null;
|
||||
$this->micropubData['published'] = null;
|
||||
$this->micropubData['location'] = null;
|
||||
$this->micropubData['description'] = null;
|
||||
$this->micropubData['geo'] = null;
|
||||
$this->micropubData['latitude'] = null;
|
||||
$this->micropubData['longitude'] = null;
|
||||
|
||||
// Map form fields to micropub data
|
||||
foreach ($this->except(['h', 'access_token']) as $key => $value) {
|
||||
$this->micropubData[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,8 +10,6 @@ class MicropubResponses
|
|||
{
|
||||
/**
|
||||
* Generate a response to be returned when the token has insufficient scope.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function insufficientScopeResponse(): JsonResponse
|
||||
{
|
||||
|
@ -24,8 +22,6 @@ class MicropubResponses
|
|||
|
||||
/**
|
||||
* Generate a response to be returned when the token is invalid.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function invalidTokenResponse(): JsonResponse
|
||||
{
|
||||
|
@ -38,8 +34,6 @@ class MicropubResponses
|
|||
|
||||
/**
|
||||
* Generate a response to be returned when the token has no scope.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function tokenHasNoScopeResponse(): JsonResponse
|
||||
{
|
||||
|
|
|
@ -18,26 +18,22 @@ class AddClientToDatabase implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
protected $client_id;
|
||||
protected string $client_id;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param string $client_id
|
||||
*/
|
||||
public function __construct(string $client_id)
|
||||
public function __construct(string $clientId)
|
||||
{
|
||||
$this->client_id = $client_id;
|
||||
$this->client_id = $clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
if (MicropubClient::where('client_url', $this->client_id)->count() == 0) {
|
||||
if (MicropubClient::where('client_url', $this->client_id)->count() === 0) {
|
||||
MicropubClient::create([
|
||||
'client_url' => $this->client_id,
|
||||
'client_name' => $this->client_id, // default client name is the URL
|
||||
|
|
|
@ -19,60 +19,48 @@ class DownloadWebMention implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The webmention source URL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param string $source
|
||||
*/
|
||||
public function __construct(string $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
public function __construct(
|
||||
protected string $source
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Client $guzzle
|
||||
*
|
||||
* @throws GuzzleException
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public function handle(Client $guzzle)
|
||||
public function handle(Client $guzzle): void
|
||||
{
|
||||
$response = $guzzle->request('GET', $this->source);
|
||||
//4XX and 5XX responses should get Guzzle to throw an exception,
|
||||
//Laravel should catch and retry these automatically.
|
||||
if ($response->getStatusCode() == '200') {
|
||||
$filesystem = new FileSystem();
|
||||
// 4XX and 5XX responses should get Guzzle to throw an exception,
|
||||
// Laravel should catch and retry these automatically.
|
||||
if ($response->getStatusCode() === 200) {
|
||||
$filesystem = new FileSystem;
|
||||
$filename = storage_path('HTML') . '/' . $this->createFilenameFromURL($this->source);
|
||||
//backup file first
|
||||
// backup file first
|
||||
$filenameBackup = $filename . '.' . date('Y-m-d') . '.backup';
|
||||
if ($filesystem->exists($filename)) {
|
||||
$filesystem->copy($filename, $filenameBackup);
|
||||
}
|
||||
//check if base directory exists
|
||||
// check if base directory exists
|
||||
if (! $filesystem->exists($filesystem->dirname($filename))) {
|
||||
$filesystem->makeDirectory(
|
||||
$filesystem->dirname($filename),
|
||||
0755, //mode
|
||||
true //recursive
|
||||
0755, // mode
|
||||
true // recursive
|
||||
);
|
||||
}
|
||||
//save new HTML
|
||||
// save new HTML
|
||||
$filesystem->put(
|
||||
$filename,
|
||||
(string) $response->getBody()
|
||||
);
|
||||
//remove backup if the same
|
||||
// remove backup if the same
|
||||
if ($filesystem->exists($filenameBackup)) {
|
||||
if ($filesystem->get($filename) == $filesystem->get($filenameBackup)) {
|
||||
if ($filesystem->get($filename) === $filesystem->get($filenameBackup)) {
|
||||
$filesystem->delete($filenameBackup);
|
||||
}
|
||||
}
|
||||
|
@ -81,14 +69,11 @@ class DownloadWebMention implements ShouldQueue
|
|||
|
||||
/**
|
||||
* Create a file path from a URL. This is used when caching the HTML response.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string The path name
|
||||
*/
|
||||
private function createFilenameFromURL(string $url)
|
||||
private function createFilenameFromURL(string $url): string
|
||||
{
|
||||
$filepath = str_replace(['https://', 'http://'], ['https/', 'http/'], $url);
|
||||
if (substr($filepath, -1) == '/') {
|
||||
if (str_ends_with($filepath, '/')) {
|
||||
$filepath .= 'index.html';
|
||||
}
|
||||
|
||||
|
|
|
@ -20,32 +20,23 @@ class ProcessBookmark implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var Bookmark */
|
||||
protected $bookmark;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Bookmark $bookmark
|
||||
*/
|
||||
public function __construct(Bookmark $bookmark)
|
||||
{
|
||||
$this->bookmark = $bookmark;
|
||||
}
|
||||
public function __construct(
|
||||
protected Bookmark $bookmark
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
$uuid = (resolve(BookmarkService::class))->saveScreenshot($this->bookmark->url);
|
||||
$this->bookmark->screenshot = $uuid;
|
||||
SaveScreenshot::dispatch($this->bookmark);
|
||||
|
||||
try {
|
||||
$archiveLink = (resolve(BookmarkService::class))->getArchiveLink($this->bookmark->url);
|
||||
} catch (InternetArchiveException $e) {
|
||||
} catch (InternetArchiveException) {
|
||||
$archiveLink = null;
|
||||
}
|
||||
$this->bookmark->archive = $archiveLink;
|
||||
|
|
|
@ -25,26 +25,16 @@ class ProcessLike implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var Like */
|
||||
protected $like;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Like $like
|
||||
*/
|
||||
public function __construct(Like $like)
|
||||
{
|
||||
$this->like = $like;
|
||||
}
|
||||
public function __construct(
|
||||
protected Like $like
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Client $client
|
||||
* @param Authorship $authorship
|
||||
* @return int
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function handle(Client $client, Authorship $authorship): int
|
||||
|
@ -59,7 +49,7 @@ class ProcessLike implements ShouldQueue
|
|||
$this->like->content = $tweet->html;
|
||||
$this->like->save();
|
||||
|
||||
//POSSE like
|
||||
// POSSE like
|
||||
try {
|
||||
$client->request(
|
||||
'POST',
|
||||
|
@ -104,9 +94,6 @@ class ProcessLike implements ShouldQueue
|
|||
|
||||
/**
|
||||
* Determine if a given URL is that of a Tweet.
|
||||
*
|
||||
* @param string $url
|
||||
* @return bool
|
||||
*/
|
||||
private function isTweet(string $url): bool
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
|||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Intervention\Image\Exception\NotReadableException;
|
||||
use Intervention\Image\Exceptions\DecoderException;
|
||||
use Intervention\Image\ImageManager;
|
||||
|
||||
class ProcessMedia implements ShouldQueue
|
||||
|
@ -20,55 +20,50 @@ class ProcessMedia implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var string */
|
||||
protected $filename;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param string $filename
|
||||
*/
|
||||
public function __construct(string $filename)
|
||||
{
|
||||
$this->filename = $filename;
|
||||
}
|
||||
public function __construct(
|
||||
protected string $filename
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param ImageManager $manager
|
||||
*/
|
||||
public function handle(ImageManager $manager)
|
||||
public function handle(ImageManager $manager): void
|
||||
{
|
||||
//open file
|
||||
// Load file
|
||||
$file = Storage::disk('local')->get('media/' . $this->filename);
|
||||
|
||||
// Open file
|
||||
try {
|
||||
$image = $manager->make(storage_path('app') . '/' . $this->filename);
|
||||
} catch (NotReadableException $exception) {
|
||||
$image = $manager->read($file);
|
||||
} catch (DecoderException) {
|
||||
// not an image; delete file and end job
|
||||
unlink(storage_path('app') . '/' . $this->filename);
|
||||
Storage::disk('local')->delete('media/' . $this->filename);
|
||||
|
||||
return;
|
||||
}
|
||||
//create smaller versions if necessary
|
||||
|
||||
// Save the file publicly
|
||||
Storage::disk('public')->put('media/' . $this->filename, $file);
|
||||
|
||||
// Create smaller versions if necessary
|
||||
if ($image->width() > 1000) {
|
||||
$filenameParts = explode('.', $this->filename);
|
||||
$extension = array_pop($filenameParts);
|
||||
// the following achieves this data flow
|
||||
// foo.bar.png => ['foo', 'bar', 'png'] => ['foo', 'bar'] => foo.bar
|
||||
$basename = ltrim(array_reduce($filenameParts, function ($carry, $item) {
|
||||
return $carry . '.' . $item;
|
||||
}, ''), '.');
|
||||
$medium = $image->resize(1000, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
});
|
||||
Storage::disk('s3')->put('media/' . $basename . '-medium.' . $extension, (string) $medium->encode());
|
||||
$small = $image->resize(500, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
});
|
||||
Storage::disk('s3')->put('media/' . $basename . '-small.' . $extension, (string) $small->encode());
|
||||
$basename = trim(implode('.', $filenameParts), '.');
|
||||
|
||||
$medium = $image->resize(width: 1000);
|
||||
Storage::disk('public')->put('media/' . $basename . '-medium.' . $extension, (string) $medium->encode());
|
||||
|
||||
$small = $image->resize(width: 500);
|
||||
Storage::disk('public')->put('media/' . $basename . '-small.' . $extension, (string) $small->encode());
|
||||
}
|
||||
|
||||
// now we can delete the locally saved image
|
||||
unlink(storage_path('app') . '/' . $this->filename);
|
||||
// Now we can delete the locally saved image
|
||||
Storage::disk('local')->delete('media/' . $this->filename);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,40 +24,27 @@ class ProcessWebMention implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var Note */
|
||||
protected $note;
|
||||
|
||||
/** @var string */
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Note $note
|
||||
* @param string $source
|
||||
*/
|
||||
public function __construct(Note $note, string $source)
|
||||
{
|
||||
$this->note = $note;
|
||||
$this->source = $source;
|
||||
}
|
||||
public function __construct(
|
||||
protected Note $note,
|
||||
protected string $source
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Parser $parser
|
||||
* @param Client $guzzle
|
||||
*
|
||||
* @throws RemoteContentNotFoundException
|
||||
* @throws GuzzleException
|
||||
* @throws InvalidMentionException
|
||||
*/
|
||||
public function handle(Parser $parser, Client $guzzle)
|
||||
public function handle(Parser $parser, Client $guzzle): void
|
||||
{
|
||||
try {
|
||||
$response = $guzzle->request('GET', $this->source);
|
||||
} catch (RequestException $e) {
|
||||
throw new RemoteContentNotFoundException();
|
||||
throw new RemoteContentNotFoundException;
|
||||
}
|
||||
$this->saveRemoteContent((string) $response->getBody(), $this->source);
|
||||
$microformats = Mf2\parse((string) $response->getBody(), $this->source);
|
||||
|
@ -65,8 +52,8 @@ class ProcessWebMention implements ShouldQueue
|
|||
foreach ($webmentions as $webmention) {
|
||||
// check webmention still references target
|
||||
// we try each type of mention (reply/like/repost)
|
||||
if ($webmention->type == 'in-reply-to') {
|
||||
if ($parser->checkInReplyTo($microformats, $this->note->longurl) == false) {
|
||||
if ($webmention->type === 'in-reply-to') {
|
||||
if ($parser->checkInReplyTo($microformats, $this->note->uri) === false) {
|
||||
// it doesn’t so delete
|
||||
$webmention->delete();
|
||||
|
||||
|
@ -79,16 +66,16 @@ class ProcessWebMention implements ShouldQueue
|
|||
|
||||
return;
|
||||
}
|
||||
if ($webmention->type == 'like-of') {
|
||||
if ($parser->checkLikeOf($microformats, $this->note->longurl) == false) {
|
||||
if ($webmention->type === 'like-of') {
|
||||
if ($parser->checkLikeOf($microformats, $this->note->uri) === false) {
|
||||
// it doesn’t so delete
|
||||
$webmention->delete();
|
||||
|
||||
return;
|
||||
} // note we don’t need to do anything if it still is a like
|
||||
}
|
||||
if ($webmention->type == 'repost-of') {
|
||||
if ($parser->checkRepostOf($microformats, $this->note->longurl) == false) {
|
||||
if ($webmention->type === 'repost-of') {
|
||||
if ($parser->checkRepostOf($microformats, $this->note->uri) === false) {
|
||||
// it doesn’t so delete
|
||||
$webmention->delete();
|
||||
|
||||
|
@ -98,13 +85,13 @@ class ProcessWebMention implements ShouldQueue
|
|||
}// foreach
|
||||
|
||||
// no webmention in the db so create new one
|
||||
$webmention = new WebMention();
|
||||
$webmention = new WebMention;
|
||||
$type = $parser->getMentionType($microformats); // throw error here?
|
||||
dispatch(new SaveProfileImage($microformats));
|
||||
$webmention->source = $this->source;
|
||||
$webmention->target = $this->note->longurl;
|
||||
$webmention->target = $this->note->uri;
|
||||
$webmention->commentable_id = $this->note->id;
|
||||
$webmention->commentable_type = 'App\Model\Note';
|
||||
$webmention->commentable_type = Note::class;
|
||||
$webmention->type = $type;
|
||||
$webmention->mf2 = json_encode($microformats);
|
||||
$webmention->save();
|
||||
|
@ -112,26 +99,23 @@ class ProcessWebMention implements ShouldQueue
|
|||
|
||||
/**
|
||||
* Save the HTML of a webmention for future use.
|
||||
*
|
||||
* @param string $html
|
||||
* @param string $url
|
||||
*/
|
||||
private function saveRemoteContent($html, $url)
|
||||
private function saveRemoteContent(string $html, string $url): void
|
||||
{
|
||||
$filenameFromURL = str_replace(
|
||||
['https://', 'http://'],
|
||||
['https/', 'http/'],
|
||||
$url
|
||||
);
|
||||
if (substr($url, -1) == '/') {
|
||||
if (str_ends_with($url, '/')) {
|
||||
$filenameFromURL .= 'index.html';
|
||||
}
|
||||
$path = storage_path() . '/HTML/' . $filenameFromURL;
|
||||
$parts = explode('/', $path);
|
||||
$name = array_pop($parts);
|
||||
$dir = implode('/', $parts);
|
||||
if (! is_dir($dir)) {
|
||||
mkdir($dir, 0755, true);
|
||||
if (! is_dir($dir) && ! mkdir($dir, 0755, true) && ! is_dir($dir)) {
|
||||
throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir));
|
||||
}
|
||||
file_put_contents("$dir/$name", $html);
|
||||
}
|
||||
|
|
|
@ -20,39 +20,40 @@ class SaveProfileImage implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
protected array $microformats;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param array $microformats
|
||||
*/
|
||||
public function __construct(array $microformats)
|
||||
{
|
||||
$this->microformats = $microformats;
|
||||
}
|
||||
public function __construct(
|
||||
protected array $microformats
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Authorship $authorship
|
||||
*/
|
||||
public function handle(Authorship $authorship)
|
||||
public function handle(Authorship $authorship): void
|
||||
{
|
||||
try {
|
||||
$author = $authorship->findAuthor($this->microformats);
|
||||
} catch (AuthorshipParserException) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
$photo = Arr::get($author, 'properties.photo.0');
|
||||
$home = Arr::get($author, 'properties.url.0');
|
||||
|
||||
//dont save pbs.twimg.com links
|
||||
if (is_array($photo) && array_key_exists('value', $photo)) {
|
||||
$photo = $photo['value'];
|
||||
}
|
||||
|
||||
if (is_array($home)) {
|
||||
$home = array_shift($home);
|
||||
}
|
||||
|
||||
// dont save pbs.twimg.com links
|
||||
if (
|
||||
$photo
|
||||
&& parse_url($photo, PHP_URL_HOST) != 'pbs.twimg.com'
|
||||
&& parse_url($photo, PHP_URL_HOST) != 'twitter.com'
|
||||
&& parse_url($photo, PHP_URL_HOST) !== 'pbs.twimg.com'
|
||||
&& parse_url($photo, PHP_URL_HOST) !== 'twitter.com'
|
||||
) {
|
||||
$client = resolve(Client::class);
|
||||
|
||||
|
@ -71,8 +72,8 @@ class SaveProfileImage implements ShouldQueue
|
|||
$parts = explode('/', $path);
|
||||
$name = array_pop($parts);
|
||||
$dir = implode('/', $parts);
|
||||
if (! is_dir($dir)) {
|
||||
mkdir($dir, 0755, true);
|
||||
if (! is_dir($dir) && ! mkdir($dir, 0755, true) && ! is_dir($dir)) {
|
||||
throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir));
|
||||
}
|
||||
file_put_contents("$dir/$name", $image);
|
||||
}
|
||||
|
|
103
app/Jobs/SaveScreenshot.php
Executable file
103
app/Jobs/SaveScreenshot.php
Executable file
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Bookmark;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use JsonException;
|
||||
|
||||
class SaveScreenshot implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(
|
||||
protected Bookmark $bookmark
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
*
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
// A normal Guzzle client
|
||||
$client = resolve(Client::class);
|
||||
// A Guzzle client with a custom Middleware to retry the CloudConvert API requests
|
||||
$retryClient = resolve('RetryGuzzle');
|
||||
|
||||
// First request that CloudConvert takes a screenshot of the URL
|
||||
$takeScreenshotJobResponse = $client->request('POST', 'https://api.cloudconvert.com/v2/capture-website', [
|
||||
'headers' => [
|
||||
'Authorization' => 'Bearer ' . config('services.cloudconvert.token'),
|
||||
],
|
||||
'json' => [
|
||||
'url' => $this->bookmark->url,
|
||||
'output_format' => 'png',
|
||||
'screen_width' => 1440,
|
||||
'screen_height' => 900,
|
||||
'wait_until' => 'networkidle0',
|
||||
'wait_time' => 100,
|
||||
],
|
||||
]);
|
||||
|
||||
$taskId = json_decode($takeScreenshotJobResponse->getBody()->getContents(), false, 512, JSON_THROW_ON_ERROR)->data->id;
|
||||
|
||||
// Now wait till the status job is finished
|
||||
$screenshotJobStatusResponse = $retryClient->request('GET', 'https://api.cloudconvert.com/v2/tasks/' . $taskId, [
|
||||
'headers' => [
|
||||
'Authorization' => 'Bearer ' . config('services.cloudconvert.token'),
|
||||
],
|
||||
'query' => [
|
||||
'include' => 'payload',
|
||||
],
|
||||
]);
|
||||
|
||||
$finishedCaptureId = json_decode($screenshotJobStatusResponse->getBody()->getContents(), false, 512, JSON_THROW_ON_ERROR)->data->id;
|
||||
|
||||
// Now we can create a new job to request thst the screenshot is exported to a temporary URL we can download the screenshot from
|
||||
$exportImageJob = $client->request('POST', 'https://api.cloudconvert.com/v2/export/url', [
|
||||
'headers' => [
|
||||
'Authorization' => 'Bearer ' . config('services.cloudconvert.token'),
|
||||
],
|
||||
'json' => [
|
||||
'input' => $finishedCaptureId,
|
||||
'archive_multiple_files' => false,
|
||||
],
|
||||
]);
|
||||
|
||||
$exportImageJobId = json_decode($exportImageJob->getBody()->getContents(), false, 512, JSON_THROW_ON_ERROR)->data->id;
|
||||
|
||||
// Again, wait till the status of this export job is finished
|
||||
$finalImageUrlResponse = $retryClient->request('GET', 'https://api.cloudconvert.com/v2/tasks/' . $exportImageJobId, [
|
||||
'headers' => [
|
||||
'Authorization' => 'Bearer ' . config('services.cloudconvert.token'),
|
||||
],
|
||||
'query' => [
|
||||
'include' => 'payload',
|
||||
],
|
||||
]);
|
||||
|
||||
// Now we can download the screenshot and save it to the storage
|
||||
$finalImageUrl = json_decode($finalImageUrlResponse->getBody()->getContents(), false, 512, JSON_THROW_ON_ERROR)->data->result->files[0]->url;
|
||||
|
||||
$finalImageUrlContent = $client->request('GET', $finalImageUrl);
|
||||
|
||||
Storage::disk('public')->put('/assets/img/bookmarks/' . $taskId . '.png', $finalImageUrlContent->getBody()->getContents());
|
||||
|
||||
$this->bookmark->screenshot = $taskId;
|
||||
$this->bookmark->save();
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@ namespace App\Jobs;
|
|||
|
||||
use App\Models\Note;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Psr7\Header;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use GuzzleHttp\Psr7\UriResolver;
|
||||
use GuzzleHttp\Psr7\Utils;
|
||||
use Illuminate\Bus\Queueable;
|
||||
|
@ -22,39 +22,30 @@ class SendWebMentions implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var Note */
|
||||
protected $note;
|
||||
|
||||
/**
|
||||
* Create the job instance, inject dependencies.
|
||||
*
|
||||
* @param Note $note
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(Note $note)
|
||||
{
|
||||
$this->note = $note;
|
||||
}
|
||||
public function __construct(
|
||||
protected Note $note
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
//grab the URLs
|
||||
$inReplyTo = $this->note->in_reply_to ?? '';
|
||||
// above so explode doesn’t complain about null being passed in
|
||||
$urlsInReplyTo = explode(' ', $inReplyTo);
|
||||
$urlsInReplyTo = explode(' ', $this->note->in_reply_to ?? '');
|
||||
$urlsNote = $this->getLinks($this->note->note);
|
||||
$urls = array_filter(array_merge($urlsInReplyTo, $urlsNote)); //filter out none URLs
|
||||
$urls = array_filter(array_merge($urlsInReplyTo, $urlsNote));
|
||||
foreach ($urls as $url) {
|
||||
$endpoint = $this->discoverWebmentionEndpoint($url);
|
||||
if ($endpoint !== null) {
|
||||
$guzzle = resolve(Client::class);
|
||||
$guzzle->post($endpoint, [
|
||||
'form_params' => [
|
||||
'source' => $this->note->longurl,
|
||||
'source' => $this->note->uri,
|
||||
'target' => $url,
|
||||
],
|
||||
]);
|
||||
|
@ -65,13 +56,12 @@ class SendWebMentions implements ShouldQueue
|
|||
/**
|
||||
* Discover if a URL has a webmention endpoint.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string|null
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function discoverWebmentionEndpoint(string $url): ?string
|
||||
{
|
||||
//let’s not send webmentions to myself
|
||||
if (parse_url($url, PHP_URL_HOST) === config('app.longurl')) {
|
||||
// let’s not send webmentions to myself
|
||||
if (parse_url($url, PHP_URL_HOST) === parse_url(config('app.url'), PHP_URL_HOST)) {
|
||||
return null;
|
||||
}
|
||||
if (Str::startsWith($url, '/notes/tagged/')) {
|
||||
|
@ -82,15 +72,15 @@ class SendWebMentions implements ShouldQueue
|
|||
|
||||
$guzzle = resolve(Client::class);
|
||||
$response = $guzzle->get($url);
|
||||
//check HTTP Headers for webmention endpoint
|
||||
// check HTTP Headers for webmention endpoint
|
||||
$links = Header::parse($response->getHeader('Link'));
|
||||
foreach ($links as $link) {
|
||||
if (mb_stristr($link['rel'], 'webmention')) {
|
||||
if (array_key_exists('rel', $link) && mb_stristr($link['rel'], 'webmention')) {
|
||||
return $this->resolveUri(trim($link[0], '<>'), $url);
|
||||
}
|
||||
}
|
||||
|
||||
//failed to find a header so parse HTML
|
||||
// failed to find a header so parse HTML
|
||||
$html = (string) $response->getBody();
|
||||
|
||||
$mf2 = new \Mf2\Parser($html, $url);
|
||||
|
@ -100,16 +90,16 @@ class SendWebMentions implements ShouldQueue
|
|||
} elseif (array_key_exists('http://webmention.org/', $rels[0])) {
|
||||
$endpoint = $rels[0]['http://webmention.org/'][0];
|
||||
}
|
||||
if ($endpoint) {
|
||||
return $this->resolveUri($endpoint, $url);
|
||||
|
||||
if ($endpoint === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->resolveUri($endpoint, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URLs from a note.
|
||||
*
|
||||
* @param string|null $html
|
||||
* @return array
|
||||
*/
|
||||
public function getLinks(?string $html): array
|
||||
{
|
||||
|
@ -118,7 +108,7 @@ class SendWebMentions implements ShouldQueue
|
|||
}
|
||||
|
||||
$urls = [];
|
||||
$dom = new \DOMDocument();
|
||||
$dom = new \DOMDocument;
|
||||
$dom->loadHTML($html);
|
||||
$anchors = $dom->getElementsByTagName('a');
|
||||
foreach ($anchors as $anchor) {
|
||||
|
@ -130,12 +120,6 @@ class SendWebMentions implements ShouldQueue
|
|||
|
||||
/**
|
||||
* Resolve a URI if necessary.
|
||||
*
|
||||
* @todo Update deprecated resolve method
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $base The base of the URL
|
||||
* @return string
|
||||
*/
|
||||
public function resolveUri(string $url, string $base): string
|
||||
{
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Bookmark;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SyndicateBookmarkToTwitter implements ShouldQueue
|
||||
{
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var Bookmark */
|
||||
protected $bookmark;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Bookmark $bookmark
|
||||
*/
|
||||
public function __construct(Bookmark $bookmark)
|
||||
{
|
||||
$this->bookmark = $bookmark;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Client $guzzle
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function handle(Client $guzzle)
|
||||
{
|
||||
//send webmention
|
||||
$response = $guzzle->request(
|
||||
'POST',
|
||||
'https://brid.gy/publish/webmention',
|
||||
[
|
||||
'form_params' => [
|
||||
'source' => $this->bookmark->longurl,
|
||||
'target' => 'https://brid.gy/publish/twitter',
|
||||
'bridgy_omit_link' => 'maybe',
|
||||
],
|
||||
]
|
||||
);
|
||||
//parse for syndication URL
|
||||
if ($response->getStatusCode() == 201) {
|
||||
$json = json_decode((string) $response->getBody());
|
||||
$syndicates = $this->bookmark->syndicates;
|
||||
$syndicates['twitter'] = $json->url;
|
||||
$this->bookmark->syndicates = $syndicates;
|
||||
$this->bookmark->save();
|
||||
}
|
||||
}
|
||||
}
|
62
app/Jobs/SyndicateNoteToBluesky.php
Normal file
62
app/Jobs/SyndicateNoteToBluesky.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Note;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SyndicateNoteToBluesky implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(
|
||||
protected Note $note
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function handle(Client $guzzle): void
|
||||
{
|
||||
// We can only make the request if we have an access token
|
||||
if (config('bridgy.bluesky_token') === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make micropub request
|
||||
$response = $guzzle->request(
|
||||
'POST',
|
||||
'https://brid.gy/micropub',
|
||||
[
|
||||
'headers' => [
|
||||
'Authorization' => 'Bearer ' . config('bridgy.bluesky_token'),
|
||||
],
|
||||
'json' => [
|
||||
'type' => ['h-entry'],
|
||||
'properties' => [
|
||||
'content' => [$this->note->getRawOriginal('note')],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
// Parse for syndication URL
|
||||
if ($response->getStatusCode() === 201) {
|
||||
$this->note->bluesky_url = $response->getHeader('Location')[0];
|
||||
$this->note->save();
|
||||
}
|
||||
}
|
||||
}
|
63
app/Jobs/SyndicateNoteToMastodon.php
Normal file
63
app/Jobs/SyndicateNoteToMastodon.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Note;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SyndicateNoteToMastodon implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(
|
||||
protected Note $note
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function handle(Client $guzzle): void
|
||||
{
|
||||
// We can only make the request if we have an access token
|
||||
if (config('bridgy.mastodon_token') === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make micropub request
|
||||
$response = $guzzle->request(
|
||||
'POST',
|
||||
'https://brid.gy/micropub',
|
||||
[
|
||||
'headers' => [
|
||||
'Authorization' => 'Bearer ' . config('bridgy.mastodon_token'),
|
||||
],
|
||||
'json' => [
|
||||
'type' => ['h-entry'],
|
||||
'properties' => [
|
||||
'content' => [$this->note->getRawOriginal('note')],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
// Parse for syndication URL
|
||||
if ($response->getStatusCode() === 201) {
|
||||
$mastodonUrl = $response->getHeader('Location')[0];
|
||||
$this->note->mastodon_url = $mastodonUrl;
|
||||
$this->note->save();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Note;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SyndicateNoteToTwitter implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var Note */
|
||||
protected $note;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Note $note
|
||||
*/
|
||||
public function __construct(Note $note)
|
||||
{
|
||||
$this->note = $note;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Client $guzzle
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function handle(Client $guzzle)
|
||||
{
|
||||
//send webmention
|
||||
$response = $guzzle->request(
|
||||
'POST',
|
||||
'https://brid.gy/publish/webmention',
|
||||
[
|
||||
'form_params' => [
|
||||
'source' => $this->note->longurl,
|
||||
'target' => 'https://brid.gy/publish/twitter',
|
||||
'bridgy_omit_link' => 'maybe',
|
||||
],
|
||||
]
|
||||
);
|
||||
//parse for syndication URL
|
||||
if ($response->getStatusCode() == 201) {
|
||||
$json = json_decode((string) $response->getBody());
|
||||
$tweet_id = basename(parse_url($json->url, PHP_URL_PATH));
|
||||
$this->note->tweet_id = $tweet_id;
|
||||
$this->note->save();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ namespace App\Models;
|
|||
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
@ -23,24 +24,26 @@ class Article extends Model
|
|||
use Sluggable;
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $table = 'articles';
|
||||
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = [
|
||||
'url',
|
||||
'title',
|
||||
'main',
|
||||
'published',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Return the sluggable configuration array for this model.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sluggable(): array
|
||||
{
|
||||
|
@ -51,90 +54,62 @@ class Article extends Model
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* We shall set a blacklist of non-modifiable model attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* Process the article for display.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHtmlAttribute(): string
|
||||
protected function html(): Attribute
|
||||
{
|
||||
$environment = new Environment();
|
||||
$environment->addExtension(new CommonMarkCoreExtension());
|
||||
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer());
|
||||
$environment->addRenderer(IndentedCode::class, new IndentedCodeRenderer());
|
||||
$markdownConverter = new MarkdownConverter($environment);
|
||||
return Attribute::get(
|
||||
get: function () {
|
||||
$environment = new Environment;
|
||||
$environment->addExtension(new CommonMarkCoreExtension);
|
||||
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer);
|
||||
$environment->addRenderer(IndentedCode::class, new IndentedCodeRenderer);
|
||||
$markdownConverter = new MarkdownConverter($environment);
|
||||
|
||||
return $markdownConverter->convert($this->main)->getContent();
|
||||
return $markdownConverter->convert($this->main)->getContent();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert updated_at to W3C time format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getW3cTimeAttribute(): string
|
||||
protected function w3cTime(): Attribute
|
||||
{
|
||||
return $this->updated_at->toW3CString();
|
||||
return Attribute::get(
|
||||
get: fn () => $this->updated_at->toW3CString(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert updated_at to a tooltip appropriate format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTooltipTimeAttribute(): string
|
||||
protected function tooltipTime(): Attribute
|
||||
{
|
||||
return $this->updated_at->toRFC850String();
|
||||
return Attribute::get(
|
||||
get: fn () => $this->updated_at->toRFC850String(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert updated_at to a human readable format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHumanTimeAttribute(): string
|
||||
protected function humanTime(): Attribute
|
||||
{
|
||||
return $this->updated_at->diffForHumans();
|
||||
return Attribute::get(
|
||||
get: fn () => $this->updated_at->diffForHumans(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pubdate value for RSS feeds.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPubdateAttribute(): string
|
||||
protected function pubdate(): Attribute
|
||||
{
|
||||
return $this->updated_at->toRSSString();
|
||||
return Attribute::get(
|
||||
get: fn () => $this->updated_at->toRSSString(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A link to the article, i.e. `/blog/1999/12/25/merry-christmas`.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLinkAttribute(): string
|
||||
protected function link(): Attribute
|
||||
{
|
||||
return '/blog/' . $this->updated_at->year . '/' . $this->updated_at->format('m') . '/' . $this->titleurl;
|
||||
return Attribute::get(
|
||||
get: fn () => '/blog/' . $this->updated_at->year . '/' . $this->updated_at->format('m') . '/' . $this->titleurl,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include articles from a particular year/month.
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param int|null $year
|
||||
* @param int|null $month
|
||||
* @return Builder
|
||||
*/
|
||||
public function scopeDate(Builder $query, int $year = null, int $month = null): Builder
|
||||
public function scopeDate(Builder $query, ?int $year = null, ?int $month = null): Builder
|
||||
{
|
||||
if ($year == null) {
|
||||
if ($year === null) {
|
||||
return $query;
|
||||
}
|
||||
$start = $year . '-01-01 00:00:00';
|
||||
|
|
11
app/Models/Bio.php
Normal file
11
app/Models/Bio.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Bio extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
|
@ -4,80 +4,32 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* App\Models\Bookmark.
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $url
|
||||
* @property string|null $name
|
||||
* @property string|null $content
|
||||
* @property string|null $screenshot
|
||||
* @property string|null $archive
|
||||
* @property array|null $syndicates
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read string $longurl
|
||||
* @property-read Collection|Tag[] $tags
|
||||
* @property-read int|null $tags_count
|
||||
*
|
||||
* @method static Builder|Bookmark newModelQuery()
|
||||
* @method static Builder|Bookmark newQuery()
|
||||
* @method static Builder|Bookmark query()
|
||||
* @method static Builder|Bookmark whereArchive($value)
|
||||
* @method static Builder|Bookmark whereContent($value)
|
||||
* @method static Builder|Bookmark whereCreatedAt($value)
|
||||
* @method static Builder|Bookmark whereId($value)
|
||||
* @method static Builder|Bookmark whereName($value)
|
||||
* @method static Builder|Bookmark whereScreenshot($value)
|
||||
* @method static Builder|Bookmark whereSyndicates($value)
|
||||
* @method static Builder|Bookmark whereUpdatedAt($value)
|
||||
* @method static Builder|Bookmark whereUrl($value)
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Bookmark extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = ['url', 'name', 'content'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<string, string> */
|
||||
protected $casts = [
|
||||
'syndicates' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* The tags that belong to the bookmark.
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function tags()
|
||||
public function tags(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany('App\Models\Tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* The full url of a bookmark.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLongurlAttribute(): string
|
||||
protected function local_uri(): Attribute
|
||||
{
|
||||
return config('app.url') . '/bookmarks/' . $this->id;
|
||||
return Attribute::get(
|
||||
get: fn () => config('app.url') . '/bookmarks/' . $this->id,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,18 +12,10 @@ class Contact extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $table = 'contacts';
|
||||
|
||||
/**
|
||||
* We shall guard against mass-migration.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = ['nick', 'name', 'homepage', 'twitter', 'facebook'];
|
||||
|
||||
protected function photo(): Attribute
|
||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Models;
|
||||
|
||||
use App\Traits\FilterHtml;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
|
@ -15,48 +16,41 @@ class Like extends Model
|
|||
use FilterHtml;
|
||||
use HasFactory;
|
||||
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = ['url'];
|
||||
|
||||
/**
|
||||
* Normalize the URL of a Like.
|
||||
*
|
||||
* @param string $value The provided URL
|
||||
*/
|
||||
public function setUrlAttribute(string $value)
|
||||
protected function url(): Attribute
|
||||
{
|
||||
$this->attributes['url'] = normalize_url($value);
|
||||
return Attribute::set(
|
||||
set: fn ($value) => normalize_url($value),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize the URL of the author of the like.
|
||||
*
|
||||
* @param string|null $value The author’s url
|
||||
*/
|
||||
public function setAuthorUrlAttribute(?string $value)
|
||||
protected function authorUrl(): Attribute
|
||||
{
|
||||
$this->attributes['author_url'] = normalize_url($value);
|
||||
return Attribute::set(
|
||||
set: fn ($value) => normalize_url($value),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the content contains HTML, filter it.
|
||||
*
|
||||
* @param string|null $value The content of the like
|
||||
* @return string|null
|
||||
*/
|
||||
public function getContentAttribute(?string $value): ?string
|
||||
protected function content(): Attribute
|
||||
{
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
return Attribute::get(
|
||||
get: function ($value, $attributes) {
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$mf2 = Mf2\parse($value, $this->url);
|
||||
$mf2 = Mf2\parse($value, $attributes['url']);
|
||||
|
||||
if (Arr::get($mf2, 'items.0.properties.content.0.html')) {
|
||||
return $this->filterHtml(
|
||||
$mf2['items'][0]['properties']['content'][0]['html']
|
||||
);
|
||||
}
|
||||
if (Arr::get($mf2, 'items.0.properties.content.0.html')) {
|
||||
return $this->filterHtml(
|
||||
$mf2['items'][0]['properties']['content'][0]['html']
|
||||
);
|
||||
}
|
||||
|
||||
return $value;
|
||||
return $value;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
@ -13,77 +14,74 @@ class Media extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $table = 'media_endpoint';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = ['token', 'path', 'type', 'image_widths'];
|
||||
|
||||
/**
|
||||
* Get the note that owns this media.
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function note(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Note::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for an S3 media file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrlAttribute(): string
|
||||
protected function url(): Attribute
|
||||
{
|
||||
if (Str::startsWith($this->path, 'https://')) {
|
||||
return $this->path;
|
||||
}
|
||||
return Attribute::get(
|
||||
get: function ($value, $attributes) {
|
||||
if (Str::startsWith($attributes['path'], 'https://')) {
|
||||
return $attributes['path'];
|
||||
}
|
||||
|
||||
return config('filesystems.disks.s3.url') . '/' . $this->path;
|
||||
return config('app.url') . '/storage/' . $attributes['path'];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for the medium size of an S3 image file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMediumurlAttribute(): string
|
||||
protected function mediumurl(): Attribute
|
||||
{
|
||||
$basename = $this->getBasename($this->path);
|
||||
$extension = $this->getExtension($this->path);
|
||||
|
||||
return config('filesystems.disks.s3.url') . '/' . $basename . '-medium.' . $extension;
|
||||
return Attribute::get(
|
||||
get: fn ($value, $attributes) => $this->getSizeUrl($attributes['path'], 'medium'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for the small size of an S3 image file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSmallurlAttribute(): string
|
||||
protected function smallurl(): Attribute
|
||||
{
|
||||
$basename = $this->getBasename($this->path);
|
||||
$extension = $this->getExtension($this->path);
|
||||
|
||||
return config('filesystems.disks.s3.url') . '/' . $basename . '-small.' . $extension;
|
||||
return Attribute::get(
|
||||
get: fn ($value, $attributes) => $this->getSizeUrl($attributes['path'], 'small'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the real part of a filename, i.e. strip the file extension.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getBasename(string $path): string
|
||||
protected function mimetype(): Attribute
|
||||
{
|
||||
return Attribute::get(
|
||||
get: function ($value, $attributes) {
|
||||
$extension = $this->getExtension($attributes['path']);
|
||||
|
||||
return match ($extension) {
|
||||
'gif' => 'image/gif',
|
||||
'jpeg', 'jpg' => 'image/jpeg',
|
||||
'png' => 'image/png',
|
||||
'svg' => 'image/svg+xml',
|
||||
'tiff' => 'image/tiff',
|
||||
'webp' => 'image/webp',
|
||||
'mp4' => 'video/mp4',
|
||||
'mkv' => 'video/mkv',
|
||||
default => 'application/octet-stream',
|
||||
};
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
private function getSizeUrl(string $path, string $size): string
|
||||
{
|
||||
$basename = $this->getBasename($path);
|
||||
$extension = $this->getExtension($path);
|
||||
|
||||
return config('app.url') . '/storage/' . $basename . '-' . $size . '.' . $extension;
|
||||
}
|
||||
|
||||
private function getBasename(string $path): string
|
||||
{
|
||||
// the following achieves this data flow
|
||||
// foo.bar.png => ['foo', 'bar', 'png'] => ['foo', 'bar'] => foo.bar
|
||||
|
@ -95,13 +93,7 @@ class Media extends Model
|
|||
}, ''), '.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the extension from a given filename.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getExtension(string $path): string
|
||||
private function getExtension(string $path): string
|
||||
{
|
||||
$parts = explode('.', $path);
|
||||
|
||||
|
|
|
@ -12,25 +12,12 @@ class MicropubClient extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $table = 'clients';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = ['client_url', 'client_name'];
|
||||
|
||||
/**
|
||||
* Define the relationship with notes.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function notes(): HasMany
|
||||
{
|
||||
return $this->hasMany('App\Models\Note', 'client_id', 'client_url');
|
||||
|
|
|
@ -4,9 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\CommonMark\Generators\ContactMentionGenerator;
|
||||
use App\CommonMark\Renderers\ContactMentionRenderer;
|
||||
use App\Exceptions\TwitterContentException;
|
||||
use App\CommonMark\Generators\MentionGenerator;
|
||||
use App\CommonMark\Renderers\MentionRenderer;
|
||||
use Codebird\Codebird;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
|
@ -19,8 +18,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use Jonnybarnes\IndieWeb\Numbers;
|
||||
use Laravel\Scout\Searchable;
|
||||
use League\CommonMark\Environment\Environment;
|
||||
use League\CommonMark\Extension\Autolink\AutolinkExtension;
|
||||
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
|
||||
|
@ -36,6 +35,7 @@ use Spatie\CommonMarkHighlighter\IndentedCodeRenderer;
|
|||
class Note extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use Searchable;
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
|
@ -52,8 +52,6 @@ class Note extends Model
|
|||
|
||||
/**
|
||||
* Set our contacts variable to null.
|
||||
*
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct(array $attributes = [])
|
||||
{
|
||||
|
@ -61,87 +59,47 @@ class Note extends Model
|
|||
$this->contacts = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $table = 'notes';
|
||||
|
||||
/**
|
||||
* Mass-assignment.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = [
|
||||
'note',
|
||||
'in_reply_to',
|
||||
'client_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* Hide the column used with Laravel Scout.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $hidden = ['searchable'];
|
||||
|
||||
/**
|
||||
* Define the relationship with tags.
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function tags(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Tag::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the relationship with clients.
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function client(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MicropubClient::class, 'client_id', 'client_url');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the relationship with webmentions.
|
||||
*
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function webmentions(): MorphMany
|
||||
{
|
||||
return $this->morphMany(WebMention::class, 'commentable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the relationship with places.
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function place(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Place::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the relationship with media.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function media(): HasMany
|
||||
{
|
||||
return $this->hasMany(Media::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the attributes to be indexed for searching with Scout.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
#[ArrayShape(['note' => 'null|string'])]
|
||||
public function toSearchableArray(): array
|
||||
{
|
||||
return [
|
||||
|
@ -149,16 +107,11 @@ class Note extends Model
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize the note to Unicode FORM C.
|
||||
*
|
||||
* @param string|null $value
|
||||
*/
|
||||
public function setNoteAttribute(?string $value): void
|
||||
{
|
||||
if ($value !== null) {
|
||||
$normalized = normalizer_normalize($value, Normalizer::FORM_C);
|
||||
if ($normalized === '') { //we don’t want to save empty strings to the db
|
||||
if ($normalized === '') { // we don’t want to save empty strings to the db
|
||||
$normalized = null;
|
||||
}
|
||||
$this->attributes['note'] = $normalized;
|
||||
|
@ -167,14 +120,11 @@ class Note extends Model
|
|||
|
||||
/**
|
||||
* Pre-process notes for web-view.
|
||||
*
|
||||
* @param string|null $value
|
||||
* @return string|null
|
||||
*/
|
||||
public function getNoteAttribute(?string $value): ?string
|
||||
{
|
||||
if ($value === null && $this->place !== null) {
|
||||
$value = '📍: <a href="' . $this->place->longurl . '">' . $this->place->name . '</a>';
|
||||
$value = '📍: <a href="' . $this->place->uri . '">' . $this->place->name . '</a>';
|
||||
}
|
||||
|
||||
// if $value is still null, just return null
|
||||
|
@ -190,23 +140,21 @@ class Note extends Model
|
|||
/**
|
||||
* Provide the content_html for JSON feed.
|
||||
*
|
||||
* In particular we want to include media links such as images.
|
||||
*
|
||||
* @return string
|
||||
* In particular, we want to include media links such as images.
|
||||
*/
|
||||
public function getContentAttribute(): string
|
||||
{
|
||||
$note = $this->note;
|
||||
$note = $this->getRawOriginal('note');
|
||||
|
||||
foreach ($this->media as $media) {
|
||||
if ($media->type === 'image') {
|
||||
$note .= '<img src="' . $media->url . '" alt="">';
|
||||
$note .= PHP_EOL . '<img src="' . $media->url . '" alt="">';
|
||||
}
|
||||
if ($media->type === 'audio') {
|
||||
$note .= '<audio src="' . $media->url . '">';
|
||||
$note .= PHP_EOL . '<audio src="' . $media->url . '">';
|
||||
}
|
||||
if ($media->type === 'video') {
|
||||
$note .= '<video src="' . $media->url . '">';
|
||||
$note .= PHP_EOL . '<video src="' . $media->url . '">';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,72 +166,32 @@ class Note extends Model
|
|||
return $note;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the NewBase60 ID from primary ID.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNb60idAttribute(): string
|
||||
{
|
||||
// we cast to string because sometimes the nb60id is an “int”
|
||||
return (string) resolve(Numbers::class)->numto60($this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Long URL for a note.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLongurlAttribute(): string
|
||||
public function getUriAttribute(): string
|
||||
{
|
||||
return config('app.url') . '/notes/' . $this->nb60id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Short URL for a note.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getShorturlAttribute(): string
|
||||
{
|
||||
return config('app.shorturl') . '/notes/' . $this->nb60id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ISO8601 value for mf2.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIso8601Attribute(): string
|
||||
{
|
||||
return $this->updated_at->toISO8601String();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ISO8601 value for mf2.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHumandiffAttribute(): string
|
||||
{
|
||||
return $this->updated_at->diffForHumans();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the publish date value for RSS feeds.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPubdateAttribute(): string
|
||||
{
|
||||
return $this->updated_at->toRSSString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latitude value.
|
||||
*
|
||||
* @return float|null
|
||||
*/
|
||||
public function getLatitudeAttribute(): ?float
|
||||
{
|
||||
if ($this->place !== null) {
|
||||
|
@ -299,11 +207,6 @@ class Note extends Model
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the longitude value.
|
||||
*
|
||||
* @return float|null
|
||||
*/
|
||||
public function getLongitudeAttribute(): ?float
|
||||
{
|
||||
if ($this->place !== null) {
|
||||
|
@ -320,10 +223,9 @@ class Note extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the address for a note. This is either a reverse geo-code from the
|
||||
* location, or is derived from the associated place.
|
||||
* Get the address for a note.
|
||||
*
|
||||
* @return string|null
|
||||
* This is either a reverse geo-code from the location, or is derived from the associated place.
|
||||
*/
|
||||
public function getAddressAttribute(): ?string
|
||||
{
|
||||
|
@ -339,8 +241,6 @@ class Note extends Model
|
|||
|
||||
/**
|
||||
* Get the OEmbed html for a tweet the note is a reply to.
|
||||
*
|
||||
* @return object|null
|
||||
*/
|
||||
public function getTwitterAttribute(): ?object
|
||||
{
|
||||
|
@ -366,7 +266,7 @@ class Note extends Model
|
|||
]);
|
||||
|
||||
if ($oEmbed->httpstatus >= 400) {
|
||||
throw new Exception();
|
||||
throw new Exception;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
|
@ -376,76 +276,28 @@ class Note extends Model
|
|||
return $oEmbed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a specific form of the note for twitter.
|
||||
*
|
||||
* That is we swap the contacts names for their known Twitter handles.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws TwitterContentException
|
||||
*/
|
||||
public function getTwitterContentAttribute(): string
|
||||
{
|
||||
$this->getContacts();
|
||||
|
||||
// check for contacts
|
||||
if ($this->contacts === null || count($this->contacts) === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// here we check the matched contact from the note corresponds to a contact
|
||||
// in the database
|
||||
if (
|
||||
count(array_unique(array_values($this->contacts))) === 1
|
||||
&& array_unique(array_values($this->contacts))[0] === null
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// swap in Twitter usernames
|
||||
$swapped = preg_replace_callback(
|
||||
self::USERNAMES_REGEX,
|
||||
function ($matches) {
|
||||
if (is_null($this->contacts[$matches[1]])) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
$contact = $this->contacts[$matches[1]];
|
||||
if ($contact->twitter) {
|
||||
return '@' . $contact->twitter;
|
||||
}
|
||||
|
||||
return $contact->name;
|
||||
},
|
||||
$this->getRawOriginal('note')
|
||||
);
|
||||
|
||||
return $this->convertMarkdown($swapped);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to select a note via a NewBase60 id.
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $nb60id
|
||||
* @return Builder
|
||||
*/
|
||||
public function scopeNb60(Builder $query, string $nb60id): Builder
|
||||
{
|
||||
$realId = resolve(Numbers::class)->b60tonum($nb60id);
|
||||
|
||||
// Check nb60 does not translate to ID too big for database int4 column
|
||||
if ($realId > 2_147_483_647) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return $query->where('id', resolve(Numbers::class)->b60tonum($nb60id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Swap contact’s nicks for a full mf2 h-card.
|
||||
* Swap contact’s nicks for a full mf2 h-card.
|
||||
*
|
||||
* Take note that this method does two things, given @username (NOT [@username](URL)!)
|
||||
* we try to create a fancy hcard from our contact info. If this is not possible
|
||||
* due to lack of contact info, we assume @username is a twitter handle and link it
|
||||
* as such.
|
||||
*
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
private function makeHCards(string $text): string
|
||||
{
|
||||
|
@ -477,8 +329,6 @@ class Note extends Model
|
|||
|
||||
/**
|
||||
* Get the value of the `contacts` property.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getContacts(): array
|
||||
{
|
||||
|
@ -491,8 +341,6 @@ class Note extends Model
|
|||
|
||||
/**
|
||||
* Process the note and save the contacts to the `contacts` property.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setContacts(): void
|
||||
{
|
||||
|
@ -514,9 +362,6 @@ class Note extends Model
|
|||
* Given a string and section, finds all hashtags matching
|
||||
* `#[\-_a-zA-Z0-9]+` and wraps them in an `a` element with
|
||||
* `rel=tag` set and a `href` of 'section/tagged/' + tagname without the #.
|
||||
*
|
||||
* @param string $note
|
||||
* @return string
|
||||
*/
|
||||
public function autoLinkHashtag(string $note): string
|
||||
{
|
||||
|
@ -531,43 +376,30 @@ class Note extends Model
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass a note through the commonmark library.
|
||||
*
|
||||
* @param string $note
|
||||
* @return string
|
||||
*/
|
||||
private function convertMarkdown(string $note): string
|
||||
{
|
||||
$config = [
|
||||
'mentions' => [
|
||||
'contacts_handle' => [
|
||||
'mentions_handle' => [
|
||||
'prefix' => '@',
|
||||
'pattern' => '[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}(?!\w)',
|
||||
'generator' => new ContactMentionGenerator(),
|
||||
'pattern' => '([\w@.])+(\b)',
|
||||
'generator' => new MentionGenerator,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$environment = new Environment($config);
|
||||
$environment->addExtension(new CommonMarkCoreExtension());
|
||||
$environment->addExtension(new AutolinkExtension());
|
||||
$environment->addExtension(new MentionExtension());
|
||||
$environment->addRenderer(Mention::class, new ContactMentionRenderer());
|
||||
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer());
|
||||
$environment->addRenderer(IndentedCode::class, new IndentedCodeRenderer());
|
||||
$environment->addExtension(new CommonMarkCoreExtension);
|
||||
$environment->addExtension(new AutolinkExtension);
|
||||
$environment->addExtension(new MentionExtension);
|
||||
$environment->addRenderer(Mention::class, new MentionRenderer);
|
||||
$environment->addRenderer(FencedCode::class, new FencedCodeRenderer);
|
||||
$environment->addRenderer(IndentedCode::class, new IndentedCodeRenderer);
|
||||
$markdownConverter = new MarkdownConverter($environment);
|
||||
|
||||
return $markdownConverter->convert($note)->getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do a reverse geocode lookup of a `lat,lng` value.
|
||||
*
|
||||
* @param float $latitude
|
||||
* @param float $longitude
|
||||
* @return string
|
||||
*/
|
||||
public function reverseGeoCode(float $latitude, float $longitude): string
|
||||
{
|
||||
$latLng = $latitude . ',' . $longitude;
|
||||
|
|
25
app/Models/Passkey.php
Normal file
25
app/Models/Passkey.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Passkey extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/** @inerhitDoc */
|
||||
protected $fillable = [
|
||||
'passkey_id',
|
||||
'passkey',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ namespace App\Models;
|
|||
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
@ -16,38 +17,20 @@ class Place extends Model
|
|||
use HasFactory;
|
||||
use Sluggable;
|
||||
|
||||
/**
|
||||
* Get the route key for the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRouteKeyName()
|
||||
public function getRouteKeyName(): string
|
||||
{
|
||||
return 'slug';
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = ['name', 'slug'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<string, string> */
|
||||
protected $casts = [
|
||||
'latitude' => 'float',
|
||||
'longitude' => 'float',
|
||||
];
|
||||
|
||||
/**
|
||||
* Return the sluggable configuration array for this model.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sluggable(): array
|
||||
{
|
||||
return [
|
||||
|
@ -58,23 +41,13 @@ class Place extends Model
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the relationship with Notes.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function notes()
|
||||
public function notes(): HasMany
|
||||
{
|
||||
return $this->hasMany('App\Models\Note');
|
||||
}
|
||||
|
||||
/**
|
||||
* Select places near a given location.
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param object $location
|
||||
* @param int $distance
|
||||
* @return Builder
|
||||
*/
|
||||
public function scopeNear(Builder $query, object $location, int $distance = 1000): Builder
|
||||
{
|
||||
|
@ -86,17 +59,13 @@ class Place extends Model
|
|||
* sin(radians(places.latitude))))";
|
||||
|
||||
return $query
|
||||
->select() //pick the columns you want here.
|
||||
->select() // pick the columns you want here.
|
||||
->selectRaw("{$haversine} AS distance")
|
||||
->whereRaw("{$haversine} < ?", [$distance]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select places based on a URL.
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $url
|
||||
* @return Builder
|
||||
*/
|
||||
public function scopeWhereExternalURL(Builder $query, string $url): Builder
|
||||
{
|
||||
|
@ -105,60 +74,36 @@ class Place extends Model
|
|||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* The Long URL for a place.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLongurlAttribute(): string
|
||||
protected function uri(): Attribute
|
||||
{
|
||||
return config('app.url') . '/places/' . $this->slug;
|
||||
return Attribute::get(
|
||||
get: static fn ($value, $attributes) => config('app.url') . '/places/' . $attributes['slug'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Short URL for a place.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getShorturlAttribute(): string
|
||||
protected function externalUrls(): Attribute
|
||||
{
|
||||
return config('app.shorturl') . '/places/' . $this->slug;
|
||||
}
|
||||
return Attribute::set(
|
||||
set: function ($value, $attributes) {
|
||||
if ($value === null) {
|
||||
return $attributes['external_urls'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is an alternative for `longurl`.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUriAttribute(): string
|
||||
{
|
||||
return $this->longurl;
|
||||
}
|
||||
$type = $this->getType($value);
|
||||
$already = [];
|
||||
|
||||
/**
|
||||
* Dealing with a jsonb column, so we check input first.
|
||||
*
|
||||
* @param string|null $url
|
||||
*/
|
||||
public function setExternalUrlsAttribute(?string $url)
|
||||
{
|
||||
if ($url === null) {
|
||||
return;
|
||||
}
|
||||
$type = $this->getType($url);
|
||||
$already = [];
|
||||
if (array_key_exists('external_urls', $this->attributes)) {
|
||||
$already = json_decode($this->attributes['external_urls'], true);
|
||||
}
|
||||
$already[$type] = $url;
|
||||
$this->attributes['external_urls'] = json_encode($already);
|
||||
if (array_key_exists('external_urls', $attributes)) {
|
||||
$already = json_decode($attributes['external_urls'], true);
|
||||
}
|
||||
$already[$type] = $value;
|
||||
|
||||
return json_encode($already);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a URL, see if it is one of our known types.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string
|
||||
*/
|
||||
private function getType(string $url): string
|
||||
{
|
||||
|
|
62
app/Models/SyndicationTarget.php
Normal file
62
app/Models/SyndicationTarget.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SyndicationTarget extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = [
|
||||
'uid',
|
||||
'name',
|
||||
'service_name',
|
||||
'service_url',
|
||||
'service_photo',
|
||||
'user_name',
|
||||
'user_url',
|
||||
'user_photo',
|
||||
];
|
||||
|
||||
/** @var array<int, string> */
|
||||
protected $visible = [
|
||||
'uid',
|
||||
'name',
|
||||
'service',
|
||||
'user',
|
||||
];
|
||||
|
||||
/** @var array<int, string> */
|
||||
protected $appends = [
|
||||
'service',
|
||||
'user',
|
||||
];
|
||||
|
||||
protected function service(): Attribute
|
||||
{
|
||||
return Attribute::get(
|
||||
get: fn ($value, $attributes) => [
|
||||
'name' => $attributes['service_name'],
|
||||
'url' => $attributes['service_url'],
|
||||
'photo' => $attributes['service_photo'],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
protected function user(): Attribute
|
||||
{
|
||||
return Attribute::get(
|
||||
get: fn ($value, $attributes) => [
|
||||
'name' => $attributes['user_name'],
|
||||
'url' => $attributes['user_url'],
|
||||
'photo' => $attributes['user_photo'],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue