1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-25 21:11:10 +00:00

basic page loading

This commit is contained in:
Felix Ableitner 2024-01-03 13:29:25 +01:00
parent 166426e48f
commit 2ceab5a23c
54 changed files with 678 additions and 1397 deletions

385
Cargo.lock generated
View file

@ -69,6 +69,29 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "ahash"
version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd"
dependencies = [
"getrandom",
"once_cell",
"version_check",
]
[[package]]
name = "ahash"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01"
dependencies = [
"cfg-if",
"once_cell",
"version_check",
"zerocopy",
]
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "1.1.2" version = "1.1.2"
@ -78,6 +101,12 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "allocator-api2"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]] [[package]]
name = "android-tzdata" name = "android-tzdata"
version = "0.1.1" version = "0.1.1"
@ -99,16 +128,6 @@ version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]]
name = "api_client"
version = "0.1.0"
dependencies = [
"anyhow",
"once_cell",
"reqwest",
"serde_json",
]
[[package]] [[package]]
name = "async-lock" name = "async-lock"
version = "2.8.0" version = "2.8.0"
@ -182,6 +201,7 @@ checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"axum-core", "axum-core",
"axum-macros",
"bitflags 1.3.2", "bitflags 1.3.2",
"bytes", "bytes",
"futures-util", "futures-util",
@ -288,6 +308,18 @@ version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
[[package]]
name = "bitvec"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"
dependencies = [
"funty",
"radium",
"tap",
"wyz",
]
[[package]] [[package]]
name = "block-buffer" name = "block-buffer"
version = "0.10.4" version = "0.10.4"
@ -313,6 +345,29 @@ version = "3.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
[[package]]
name = "bytecheck"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627"
dependencies = [
"bytecheck_derive",
"ptr_meta",
"simdutf8",
"uuid",
]
[[package]]
name = "bytecheck_derive"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]] [[package]]
name = "bytecount" name = "bytecount"
version = "0.6.7" version = "0.6.7"
@ -331,6 +386,38 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
[[package]]
name = "cached"
version = "0.45.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90eb5776f28a149524d1d8623035760b4454ec881e8cf3838fa8d7e1b11254b3"
dependencies = [
"cached_proc_macro",
"cached_proc_macro_types",
"hashbrown 0.13.2",
"instant",
"once_cell",
"thiserror",
]
[[package]]
name = "cached_proc_macro"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c878c71c2821aa2058722038a59a67583a4240524687c6028571c9b395ded61f"
dependencies = [
"darling",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "cached_proc_macro_types"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a4f925191b4367301851c6d99b09890311d74b0d43f274c0b34c86d308a3663"
[[package]] [[package]]
name = "camino" name = "camino"
version = "1.1.6" version = "1.1.6"
@ -862,17 +949,10 @@ dependencies = [
] ]
[[package]] [[package]]
name = "frontend" name = "funty"
version = "0.1.0" version = "2.0.0"
dependencies = [ source = "registry+https://github.com/rust-lang/crates.io-index"
"console_error_panic_hook", checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
"console_log",
"leptos",
"log",
"reqwest",
"serde",
"url",
]
[[package]] [[package]]
name = "futures" name = "futures"
@ -1061,12 +1141,25 @@ name = "hashbrown"
version = "0.12.3" version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
dependencies = [
"ahash 0.7.7",
]
[[package]]
name = "hashbrown"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.14.2" version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156"
dependencies = [
"ahash 0.8.7",
"allocator-api2",
]
[[package]] [[package]]
name = "headers" name = "headers"
@ -1289,7 +1382,10 @@ dependencies = [
"axum", "axum",
"axum-macros", "axum-macros",
"bcrypt", "bcrypt",
"cfg-if",
"chrono", "chrono",
"console_error_panic_hook",
"console_log",
"diesel", "diesel",
"diesel-derive-newtype", "diesel-derive-newtype",
"diesel_migrations", "diesel_migrations",
@ -1299,6 +1395,11 @@ dependencies = [
"futures", "futures",
"hex", "hex",
"jsonwebtoken", "jsonwebtoken",
"leptos",
"leptos_axum",
"leptos_meta",
"leptos_router",
"log",
"once_cell", "once_cell",
"pretty_assertions", "pretty_assertions",
"rand", "rand",
@ -1308,15 +1409,12 @@ dependencies = [
"sha2", "sha2",
"tokio", "tokio",
"tower-http", "tower-http",
"tracing",
"url", "url",
"uuid", "uuid",
"wasm-bindgen",
"web-sys",
] ]
[[package]]
name = "ibis_workspace"
version = "0.1.0"
[[package]] [[package]]
name = "ident_case" name = "ident_case"
version = "1.0.1" version = "1.0.1"
@ -1362,6 +1460,15 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "instant"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if",
]
[[package]] [[package]]
name = "interpolator" name = "interpolator"
version = "0.5.0" version = "0.5.0"
@ -1463,6 +1570,29 @@ dependencies = [
"web-sys", "web-sys",
] ]
[[package]]
name = "leptos_axum"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6283fd19b98f4f7535b80a32064747028fbf4f88ceac4e2a24e9a7d5ed6caf5a"
dependencies = [
"axum",
"cfg-if",
"futures",
"http 0.2.11",
"hyper",
"leptos",
"leptos_integration_utils",
"leptos_meta",
"leptos_router",
"once_cell",
"parking_lot",
"serde_json",
"tokio",
"tokio-util",
"tracing",
]
[[package]] [[package]]
name = "leptos_config" name = "leptos_config"
version = "0.5.4" version = "0.5.4"
@ -1524,6 +1654,20 @@ dependencies = [
"walkdir", "walkdir",
] ]
[[package]]
name = "leptos_integration_utils"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2dbbd7d721bcdd9aa7b20987063de41314c836a3ac67e263ca489857e337dec"
dependencies = [
"futures",
"leptos",
"leptos_config",
"leptos_hot_reload",
"leptos_meta",
"tracing",
]
[[package]] [[package]]
name = "leptos_macro" name = "leptos_macro"
version = "0.5.4" version = "0.5.4"
@ -1547,6 +1691,20 @@ dependencies = [
"uuid", "uuid",
] ]
[[package]]
name = "leptos_meta"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "983bbf829598d275b01e96bd9fca71e4739dd7b9fdf69cb8898b30ebfb124332"
dependencies = [
"cfg-if",
"indexmap 2.1.0",
"leptos",
"tracing",
"wasm-bindgen",
"web-sys",
]
[[package]] [[package]]
name = "leptos_reactive" name = "leptos_reactive"
version = "0.5.4" version = "0.5.4"
@ -1560,6 +1718,7 @@ dependencies = [
"js-sys", "js-sys",
"paste", "paste",
"pin-project", "pin-project",
"rkyv",
"rustc-hash", "rustc-hash",
"self_cell", "self_cell",
"serde", "serde",
@ -1567,12 +1726,44 @@ dependencies = [
"serde_json", "serde_json",
"slotmap", "slotmap",
"thiserror", "thiserror",
"tokio",
"tracing", "tracing",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
"web-sys", "web-sys",
] ]
[[package]]
name = "leptos_router"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1a2ff8b8e8ae8b17efd8be2a407f7f83ed57c5243f70f2d03e6635f9ff61848"
dependencies = [
"cached",
"cfg-if",
"gloo-net",
"itertools 0.11.0",
"js-sys",
"lazy_static",
"leptos",
"leptos_integration_utils",
"leptos_meta",
"linear-map",
"lru",
"once_cell",
"percent-encoding",
"regex",
"serde",
"serde_json",
"serde_qs",
"thiserror",
"tracing",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
]
[[package]] [[package]]
name = "leptos_server" name = "leptos_server"
version = "0.5.4" version = "0.5.4"
@ -1595,6 +1786,16 @@ version = "0.2.150"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
[[package]]
name = "linear-map"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfae20f6b19ad527b550c223fddc3077a547fc70cda94b9b566575423fd303ee"
dependencies = [
"serde",
"serde_test",
]
[[package]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"
version = "0.4.11" version = "0.4.11"
@ -1617,6 +1818,15 @@ version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "lru"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21"
dependencies = [
"hashbrown 0.14.2",
]
[[package]] [[package]]
name = "mach2" name = "mach2"
version = "0.4.1" version = "0.4.1"
@ -2092,6 +2302,26 @@ dependencies = [
"yansi 1.0.0-rc.1", "yansi 1.0.0-rc.1",
] ]
[[package]]
name = "ptr_meta"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1"
dependencies = [
"ptr_meta_derive",
]
[[package]]
name = "ptr_meta_derive"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]] [[package]]
name = "pulldown-cmark" name = "pulldown-cmark"
version = "0.9.3" version = "0.9.3"
@ -2151,6 +2381,12 @@ dependencies = [
"syn 2.0.39", "syn 2.0.39",
] ]
[[package]]
name = "radium"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09"
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.8.5" version = "0.8.5"
@ -2228,6 +2464,15 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "rend"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2571463863a6bd50c32f94402933f03457a3fbaf697a707c5be741e459f08fd"
dependencies = [
"bytecheck",
]
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.11.22" version = "0.11.22"
@ -2298,6 +2543,35 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "rkyv"
version = "0.7.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "527a97cdfef66f65998b5f3b637c26f5a5ec09cc52a3f9932313ac645f4190f5"
dependencies = [
"bitvec",
"bytecheck",
"bytes",
"hashbrown 0.12.3",
"ptr_meta",
"rend",
"rkyv_derive",
"seahash",
"tinyvec",
"uuid",
]
[[package]]
name = "rkyv_derive"
version = "0.7.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5c462a1328c8e67e4d6dbad1eb0355dd43e8ab432c6e227a43657f16ade5033"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]] [[package]]
name = "rstml" name = "rstml"
version = "0.11.2" version = "0.11.2"
@ -2382,6 +2656,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "seahash"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b"
[[package]] [[package]]
name = "security-framework" name = "security-framework"
version = "2.9.2" version = "2.9.2"
@ -2493,6 +2773,15 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "serde_test"
version = "1.0.176"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a2f49ace1498612d14f7e0b8245519584db8299541dfe31a06374a828d620ab"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "serde_urlencoded" name = "serde_urlencoded"
version = "0.7.1" version = "0.7.1"
@ -2514,6 +2803,7 @@ dependencies = [
"ciborium", "ciborium",
"const_format", "const_format",
"gloo-net", "gloo-net",
"inventory",
"js-sys", "js-sys",
"lazy_static", "lazy_static",
"once_cell", "once_cell",
@ -2585,6 +2875,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "simdutf8"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a"
[[package]] [[package]]
name = "simple_asn1" name = "simple_asn1"
version = "0.6.2" version = "0.6.2"
@ -2742,6 +3038,12 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417"
[[package]]
name = "tap"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]] [[package]]
name = "task-local-extensions" name = "task-local-extensions"
version = "0.1.4" version = "0.1.4"
@ -2877,6 +3179,8 @@ dependencies = [
"bytes", "bytes",
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"futures-util",
"hashbrown 0.14.2",
"pin-project-lite", "pin-project-lite",
"tokio", "tokio",
"tracing", "tracing",
@ -3368,6 +3672,15 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "wyz"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed"
dependencies = [
"tap",
]
[[package]] [[package]]
name = "xxhash-rust" name = "xxhash-rust"
version = "0.8.8" version = "0.8.8"
@ -3386,6 +3699,26 @@ version = "1.0.0-rc.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377"
[[package]]
name = "zerocopy"
version = "0.7.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.7.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
]
[[package]] [[package]]
name = "zeroize" name = "zeroize"
version = "1.7.0" version = "1.7.0"

View file

@ -1,11 +1,79 @@
[package] [package]
name = "ibis_workspace" name = "ibis"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
[workspace] [features]
members = [ ssr = [
"frontend", "activitypub_federation",
"backend", "axum",
"api_client", "axum-macros",
"tower-http",
"diesel",
"diesel-derive-newtype",
"diesel_migrations",
"tokio",
"leptos_axum"
] ]
csr = ["leptos/csr", "leptos_meta/csr", "leptos_router/csr"]
[dependencies]
# shared
serde = { version = "1.0.192", features = ["derive"] }
url = { version = "2.4.1", features = ["serde"] }
reqwest = { version = "0.11.22", features = ["json"] }
log = "0.4"
# backend
activitypub_federation = { version = "0.5.0-beta.6", features = [
"axum",
"diesel",
], default-features = false, optional = true }
anyhow = "1.0.75"
async-trait = "0.1.74"
axum = { version = "0.6.20", optional = true }
axum-macros = { version = "0.3.8", optional = true }
bcrypt = "0.15.0"
chrono = { version = "0.4.31", features = ["serde"] }
diesel = { version = "2.1.4", features = [
"postgres",
"chrono",
"uuid",
], optional = true }
diesel-derive-newtype = { version = "2.1.0", optional = true }
diesel_migrations = { version = "2.1.0", optional = true }
diffy = "0.3.0"
enum_delegate = "0.2.0"
env_logger = { version = "0.10.1", default-features = false }
futures = "0.3.29"
hex = "0.4.3"
jsonwebtoken = "9.2.0"
rand = "0.8.5"
serde_json = "1.0.108"
sha2 = "0.10.8"
tokio = { version = "1.34.0", features = ["full"], optional = true }
uuid = { version = "1.6.1", features = ["serde"] }
tower-http = { version = "0.4.0", features = ["cors"], optional = true }
leptos_axum = { version = "0.5.4", optional = true }
# frontend
leptos = { version = "0.5.4", features = ["nightly"] }
leptos_meta = { version = "0.5.4", features = ["nightly"] }
leptos_router = { version = "0.5.4", features = ["nightly"] }
console_log = "1"
console_error_panic_hook = "0.1"
wasm-bindgen = "0.2"
web-sys = { version = "0.3", features = ["AbortController", "AbortSignal"] }
[dev-dependencies]
once_cell = "1.18.0"
pretty_assertions = "1.4.0"
reqwest = "0.11.22"
[package.metadata.leptos]
output-name = "ibis"
bin-features = ["ssr"]
lib-features = ["csr"]
[lib]
crate-type = ["cdylib", "rlib"]

View file

@ -1,10 +0,0 @@
[package]
name = "api_client"
version = "0.1.0"
edition = "2021"
[dependencies]
reqwest = "0.11.22"
serde_json = "1.0.108"
once_cell = "1.18.0"
anyhow = "1.0.75"

View file

@ -1,157 +0,0 @@
use reqwest::Client;use once_cell::sync::Lazy;use anyhow::anyhow;
pub static CLIENT: Lazy<Client> = Lazy::new(Client::new);
pub async fn create_article(instance: &IbisInstance, title: String) -> MyResult<ArticleView> {
let create_form = CreateArticleData {
title: title.clone(),
};
let req = CLIENT
.post(format!("http://{}/api/v1/article", &instance.hostname))
.form(&create_form)
.bearer_auth(&instance.jwt);
let article: ArticleView = handle_json_res(req).await?;
// create initial edit to ensure that conflicts are generated (there are no conflicts on empty file)
let edit_form = EditArticleData {
article_id: article.article.id,
new_text: TEST_ARTICLE_DEFAULT_TEXT.to_string(),
previous_version_id: article.latest_version,
resolve_conflict_id: None,
};
edit_article(instance, &edit_form).await
}
pub async fn get_article(hostname: &str, article_id: i32) -> MyResult<ArticleView> {
let get_article = GetArticleData { article_id };
get_query::<ArticleView, _>(hostname, "article", Some(get_article.clone())).await
}
pub async fn edit_article_with_conflict(
instance: &IbisInstance,
edit_form: &EditArticleData,
) -> MyResult<Option<ApiConflict>> {
let req = CLIENT
.patch(format!("http://{}/api/v1/article", instance.hostname))
.form(edit_form)
.bearer_auth(&instance.jwt);
handle_json_res(req).await
}
pub async fn get_conflicts(instance: &IbisInstance) -> MyResult<Vec<ApiConflict>> {
let req = CLIENT
.get(format!(
"http://{}/api/v1/edit_conflicts",
&instance.hostname
))
.bearer_auth(&instance.jwt);
handle_json_res(req).await
}
pub async fn edit_article(
instance: &IbisInstance,
edit_form: &EditArticleData,
) -> MyResult<ArticleView> {
let edit_res = edit_article_with_conflict(instance, edit_form).await?;
assert!(edit_res.is_none());
get_article(&instance.hostname, edit_form.article_id).await
}
pub async fn get<T>(hostname: &str, endpoint: &str) -> MyResult<T>
where
T: for<'de> Deserialize<'de>,
{
get_query(hostname, endpoint, None::<i32>).await
}
pub async fn get_query<T, R>(hostname: &str, endpoint: &str, query: Option<R>) -> MyResult<T>
where
T: for<'de> Deserialize<'de>,
R: Serialize,
{
let mut req = CLIENT.get(format!("http://{}/api/v1/{}", hostname, endpoint));
if let Some(query) = query {
req = req.query(&query);
}
handle_json_res(req).await
}
pub async fn fork_article(
instance: &IbisInstance,
form: &ForkArticleData,
) -> MyResult<ArticleView> {
let req = CLIENT
.post(format!("http://{}/api/v1/article/fork", instance.hostname))
.form(form)
.bearer_auth(&instance.jwt);
handle_json_res(req).await
}
pub async fn handle_json_res<T>(req: RequestBuilder) -> MyResult<T>
where
T: for<'de> Deserialize<'de>,
{
let res = req.send().await?;
let status = res.status();
let text = res.text().await?;
if status == StatusCode::OK {
Ok(serde_json::from_str(&text).map_err(|e| anyhow!("Json error on {text}: {e}"))?)
} else {
Err(anyhow!("API error: {text}").into())
}
}
pub async fn follow_instance(instance: &IbisInstance, follow_instance: &str) -> MyResult<()> {
// fetch beta instance on alpha
let resolve_form = ResolveObject {
id: Url::parse(&format!("http://{}", follow_instance))?,
};
let instance_resolved: DbInstance =
get_query(&instance.hostname, "resolve_instance", Some(resolve_form)).await?;
// send follow
let follow_form = FollowInstance {
id: instance_resolved.id,
};
// cant use post helper because follow doesnt return json
let res = CLIENT
.post(format!(
"http://{}/api/v1/instance/follow",
instance.hostname
))
.form(&follow_form)
.bearer_auth(&instance.jwt)
.send()
.await?;
if res.status() == StatusCode::OK {
Ok(())
} else {
Err(anyhow!("API error: {}", res.text().await?).into())
}
}
pub async fn register(hostname: &str, username: &str, password: &str) -> MyResult<LoginResponse> {
let register_form = RegisterUserData {
username: username.to_string(),
password: password.to_string(),
};
let req = CLIENT
.post(format!("http://{}/api/v1/user/register", hostname))
.form(&register_form);
handle_json_res(req).await
}
pub async fn login(
instance: &IbisInstance,
username: &str,
password: &str,
) -> MyResult<LoginResponse> {
let login_form = LoginUserData {
username: username.to_string(),
password: password.to_string(),
};
let req = CLIENT
.post(format!("http://{}/api/v1/user/login", instance.hostname))
.form(&login_form);
handle_json_res(req).await
}

View file

@ -1,36 +0,0 @@
[package]
name = "ibis"
version = "0.1.0"
edition = "2021"
[dependencies]
activitypub_federation = { version = "0.5.0-beta.6", features = ["axum", "diesel"], default-features = false }
anyhow = "1.0.75"
async-trait = "0.1.74"
axum = "0.6.20"
axum-macros = "0.3.8"
bcrypt = "0.15.0"
chrono = { version = "0.4.31", features = ["serde"] }
diesel = {version = "2.1.4", features = ["postgres", "chrono", "uuid"] }
diesel-derive-newtype = "2.1.0"
diesel_migrations = "2.1.0"
diffy = "0.3.0"
enum_delegate = "0.2.0"
env_logger = { version = "0.10.1", default-features = false }
futures = "0.3.29"
hex = "0.4.3"
jsonwebtoken = "9.2.0"
rand = "0.8.5"
serde = "1.0.192"
serde_json = "1.0.108"
sha2 = "0.10.8"
tokio = { version = "1.34.0", features = ["full"] }
tracing = "0.1.40"
url = "2.4.1"
uuid = { version = "1.6.1", features = ["serde"] }
tower-http = { version = "0.4.0", features = ["cors"] }
[dev-dependencies]
once_cell = "1.18.0"
pretty_assertions = "1.4.0"
reqwest = "0.11.22"

View file

@ -1,15 +0,0 @@
use ibis::error::MyResult;
use ibis::start;
use tracing::log::LevelFilter;
#[tokio::main]
pub async fn main() -> MyResult<()> {
env_logger::builder()
.filter_level(LevelFilter::Warn)
.filter_module("activitypub_federation", LevelFilter::Info)
.filter_module("ibis", LevelFilter::Info)
.init();
let database_url = "postgres://ibis:password@localhost:5432/ibis";
start("localhost:8131", database_url).await?;
Ok(())
}

View file

@ -1,13 +0,0 @@
[package]
name = "frontend"
version = "0.1.0"
edition = "2021"
[dependencies]
leptos = { version = "0.5.4", features = ["csr"] }
reqwest = { version = "0.11.22", features = ["json"] }
console_log = "1"
console_error_panic_hook = "0.1"
log = "0.4"
serde = { version = "1", features = ["derive"] }
url = {version = "2.4.1", features = ["serde"] }

View file

@ -1,763 +0,0 @@
let wasm;
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
let cachedUint8Memory0 = null;
function getUint8Memory0() {
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8Memory0;
}
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
const heap = new Array(128).fill(undefined);
heap.push(undefined, null, true, false);
let heap_next = heap.length;
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
function getObject(idx) { return heap[idx]; }
let WASM_VECTOR_LEN = 0;
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
? function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
}
: function (arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
});
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8Memory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
function isLikeNone(x) {
return x === undefined || x === null;
}
let cachedInt32Memory0 = null;
function getInt32Memory0() {
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
}
return cachedInt32Memory0;
}
function dropObject(idx) {
if (idx < 132) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
function debugString(val) {
// primitive types
const type = typeof val;
if (type == 'number' || type == 'boolean' || val == null) {
return `${val}`;
}
if (type == 'string') {
return `"${val}"`;
}
if (type == 'symbol') {
const description = val.description;
if (description == null) {
return 'Symbol';
} else {
return `Symbol(${description})`;
}
}
if (type == 'function') {
const name = val.name;
if (typeof name == 'string' && name.length > 0) {
return `Function(${name})`;
} else {
return 'Function';
}
}
// objects
if (Array.isArray(val)) {
const length = val.length;
let debug = '[';
if (length > 0) {
debug += debugString(val[0]);
}
for(let i = 1; i < length; i++) {
debug += ', ' + debugString(val[i]);
}
debug += ']';
return debug;
}
// Test for built-in
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
let className;
if (builtInMatches.length > 1) {
className = builtInMatches[1];
} else {
// Failed to match the standard '[object ClassName]'
return toString.call(val);
}
if (className == 'Object') {
// we're a user defined class or Object
// JSON.stringify avoids problems with cycles, and is generally much
// easier than looping through ownProperties of `val`.
try {
return 'Object(' + JSON.stringify(val) + ')';
} catch (_) {
return 'Object';
}
}
// errors
if (val instanceof Error) {
return `${val.name}: ${val.message}\n${val.stack}`;
}
// TODO we could test for more things here, like `Set`s and `Map`s.
return className;
}
function makeMutClosure(arg0, arg1, dtor, f) {
const state = { a: arg0, b: arg1, cnt: 1, dtor };
const real = (...args) => {
// First up with a closure we increment the internal reference
// count. This ensures that the Rust closure environment won't
// be deallocated while we're invoking it.
state.cnt++;
const a = state.a;
state.a = 0;
try {
return f(a, state.b, ...args);
} finally {
if (--state.cnt === 0) {
wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
} else {
state.a = a;
}
}
};
real.original = state;
return real;
}
function __wbg_adapter_28(arg0, arg1) {
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h317d618a1c63285e(arg0, arg1);
}
function __wbg_adapter_31(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h5924f6ec2668bdab(arg0, arg1, addHeapObject(arg2));
}
function __wbg_adapter_34(arg0, arg1, arg2) {
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hecf0bddf191eb724(arg0, arg1, addHeapObject(arg2));
}
function getCachedStringFromWasm0(ptr, len) {
if (ptr === 0) {
return getObject(len);
} else {
return getStringFromWasm0(ptr, len);
}
}
function handleError(f, args) {
try {
return f.apply(this, args);
} catch (e) {
wasm.__wbindgen_exn_store(addHeapObject(e));
}
}
async function __wbg_load(module, imports) {
if (typeof Response === 'function' && module instanceof Response) {
if (typeof WebAssembly.instantiateStreaming === 'function') {
try {
return await WebAssembly.instantiateStreaming(module, imports);
} catch (e) {
if (module.headers.get('Content-Type') != 'application/wasm') {
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
} else {
throw e;
}
}
}
const bytes = await module.arrayBuffer();
return await WebAssembly.instantiate(bytes, imports);
} else {
const instance = await WebAssembly.instantiate(module, imports);
if (instance instanceof WebAssembly.Instance) {
return { instance, module };
} else {
return instance;
}
}
}
function __wbg_get_imports() {
const imports = {};
imports.wbg = {};
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
const ret = getObject(arg0);
return addHeapObject(ret);
};
imports.wbg.__wbg_fetch_b5d6bebed1e6c2d2 = function(arg0) {
const ret = fetch(getObject(arg0));
return addHeapObject(ret);
};
imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
var v0 = getCachedStringFromWasm0(arg0, arg1);
if (arg0 !== 0) { wasm.__wbindgen_free(arg0, arg1, 1); }
console.error(v0);
};
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
const ret = new Error();
return addHeapObject(ret);
};
imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
const ret = getObject(arg1).stack;
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};
imports.wbg.__wbindgen_is_undefined = function(arg0) {
const ret = getObject(arg0) === undefined;
return ret;
};
imports.wbg.__wbindgen_is_null = function(arg0) {
const ret = getObject(arg0) === null;
return ret;
};
imports.wbg.__wbindgen_is_falsy = function(arg0) {
const ret = !getObject(arg0);
return ret;
};
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
const obj = getObject(arg1);
const ret = typeof(obj) === 'string' ? obj : undefined;
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};
imports.wbg.__wbindgen_cb_drop = function(arg0) {
const obj = takeObject(arg0).original;
if (obj.cnt-- == 1) {
obj.a = 0;
return true;
}
const ret = false;
return ret;
};
imports.wbg.__wbg_instanceof_Window_cde2416cf5126a72 = function(arg0) {
let result;
try {
result = getObject(arg0) instanceof Window;
} catch (_) {
result = false;
}
const ret = result;
return ret;
};
imports.wbg.__wbg_document_183cf1eecfdbffee = function(arg0) {
const ret = getObject(arg0).document;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_body_11da0c1aa9610cb3 = function(arg0) {
const ret = getObject(arg0).body;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_createComment_3b18d83b12cfbf48 = function(arg0, arg1, arg2) {
var v0 = getCachedStringFromWasm0(arg1, arg2);
const ret = getObject(arg0).createComment(v0);
return addHeapObject(ret);
};
imports.wbg.__wbg_createDocumentFragment_acf4f9887c44b09f = function(arg0) {
const ret = getObject(arg0).createDocumentFragment();
return addHeapObject(ret);
};
imports.wbg.__wbg_createElement_9ce3fdea8322ff34 = function() { return handleError(function (arg0, arg1, arg2) {
var v0 = getCachedStringFromWasm0(arg1, arg2);
const ret = getObject(arg0).createElement(v0);
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_createTextNode_01a7250c5ca46b04 = function(arg0, arg1, arg2) {
var v0 = getCachedStringFromWasm0(arg1, arg2);
const ret = getObject(arg0).createTextNode(v0);
return addHeapObject(ret);
};
imports.wbg.__wbg_namespaceURI_2dd94d0147ffddf2 = function(arg0, arg1) {
const ret = getObject(arg1).namespaceURI;
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};
imports.wbg.__wbg_setinnerHTML_b88bf159b62c2334 = function(arg0, arg1, arg2) {
var v0 = getCachedStringFromWasm0(arg1, arg2);
getObject(arg0).innerHTML = v0;
};
imports.wbg.__wbg_outerHTML_72dcf3aa34725f10 = function(arg0, arg1) {
const ret = getObject(arg1).outerHTML;
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};
imports.wbg.__wbg_removeAttribute_dbd76981f9bb9f59 = function() { return handleError(function (arg0, arg1, arg2) {
var v0 = getCachedStringFromWasm0(arg1, arg2);
getObject(arg0).removeAttribute(v0);
}, arguments) };
imports.wbg.__wbg_setAttribute_aebcae2169f2f869 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
var v0 = getCachedStringFromWasm0(arg1, arg2);
var v1 = getCachedStringFromWasm0(arg3, arg4);
getObject(arg0).setAttribute(v0, v1);
}, arguments) };
imports.wbg.__wbg_before_cf3a1481df28e2d5 = function() { return handleError(function (arg0, arg1) {
getObject(arg0).before(getObject(arg1));
}, arguments) };
imports.wbg.__wbg_remove_e8b7a30da3792f66 = function(arg0) {
getObject(arg0).remove();
};
imports.wbg.__wbg_append_a7f308e9b0724ea2 = function() { return handleError(function (arg0, arg1, arg2) {
getObject(arg0).append(getObject(arg1), getObject(arg2));
}, arguments) };
imports.wbg.__wbg_value_5e860795f53217cd = function(arg0, arg1) {
const ret = getObject(arg1).value;
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};
imports.wbg.__wbg_parentNode_e1c214fc3f362af0 = function(arg0) {
const ret = getObject(arg0).parentNode;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_childNodes_e62200b977bdb1a0 = function(arg0) {
const ret = getObject(arg0).childNodes;
return addHeapObject(ret);
};
imports.wbg.__wbg_previousSibling_de863aa81066e2fe = function(arg0) {
const ret = getObject(arg0).previousSibling;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_nextSibling_d029031876ed1b1b = function(arg0) {
const ret = getObject(arg0).nextSibling;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_textContent_d69d000f6081b514 = function(arg0, arg1) {
const ret = getObject(arg1).textContent;
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};
imports.wbg.__wbg_settextContent_57c7c19d2b0e7614 = function(arg0, arg1, arg2) {
var v0 = getCachedStringFromWasm0(arg1, arg2);
getObject(arg0).textContent = v0;
};
imports.wbg.__wbg_appendChild_2e6a6c9d1f0d443d = function() { return handleError(function (arg0, arg1) {
const ret = getObject(arg0).appendChild(getObject(arg1));
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_cloneNode_df9cbf9711e3707d = function() { return handleError(function (arg0) {
const ret = getObject(arg0).cloneNode();
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_newwithstrandinit_29038da14d09e330 = function() { return handleError(function (arg0, arg1, arg2) {
var v0 = getCachedStringFromWasm0(arg0, arg1);
const ret = new Request(v0, getObject(arg2));
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_signal_1ed842bebd6ae322 = function(arg0) {
const ret = getObject(arg0).signal;
return addHeapObject(ret);
};
imports.wbg.__wbg_new_e4960143e41697a4 = function() { return handleError(function () {
const ret = new AbortController();
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_abort_8355f201f30300bb = function(arg0) {
getObject(arg0).abort();
};
imports.wbg.__wbg_setdata_21158d298225cbec = function(arg0, arg1, arg2) {
var v0 = getCachedStringFromWasm0(arg1, arg2);
getObject(arg0).data = v0;
};
imports.wbg.__wbg_addEventListener_0f2891b0794e07fa = function() { return handleError(function (arg0, arg1, arg2, arg3) {
var v0 = getCachedStringFromWasm0(arg1, arg2);
getObject(arg0).addEventListener(v0, getObject(arg3));
}, arguments) };
imports.wbg.__wbg_addEventListener_51709b9747ad8980 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
var v0 = getCachedStringFromWasm0(arg1, arg2);
getObject(arg0).addEventListener(v0, getObject(arg3), getObject(arg4));
}, arguments) };
imports.wbg.__wbg_length_eae3bc233f10d60d = function(arg0) {
const ret = getObject(arg0).length;
return ret;
};
imports.wbg.__wbg_instanceof_Response_944e2745b5db71f5 = function(arg0) {
let result;
try {
result = getObject(arg0) instanceof Response;
} catch (_) {
result = false;
}
const ret = result;
return ret;
};
imports.wbg.__wbg_url_1f609e63ff1a7983 = function(arg0, arg1) {
const ret = getObject(arg1).url;
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};
imports.wbg.__wbg_status_7841bb47be2a8f16 = function(arg0) {
const ret = getObject(arg0).status;
return ret;
};
imports.wbg.__wbg_headers_ea7ef583d1564b08 = function(arg0) {
const ret = getObject(arg0).headers;
return addHeapObject(ret);
};
imports.wbg.__wbg_arrayBuffer_e32d72b052ba31d7 = function() { return handleError(function (arg0) {
const ret = getObject(arg0).arrayBuffer();
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_instanceof_ShadowRoot_f85f709c953844de = function(arg0) {
let result;
try {
result = getObject(arg0) instanceof ShadowRoot;
} catch (_) {
result = false;
}
const ret = result;
return ret;
};
imports.wbg.__wbg_host_73c8e95bf9b31ccd = function(arg0) {
const ret = getObject(arg0).host;
return addHeapObject(ret);
};
imports.wbg.__wbg_target_6efb4504c149139f = function(arg0) {
const ret = getObject(arg0).target;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
};
imports.wbg.__wbg_cancelBubble_ee3f70328e901584 = function(arg0) {
const ret = getObject(arg0).cancelBubble;
return ret;
};
imports.wbg.__wbg_composedPath_ee37eece046b69a2 = function(arg0) {
const ret = getObject(arg0).composedPath();
return addHeapObject(ret);
};
imports.wbg.__wbg_new_19676474aa414d62 = function() { return handleError(function () {
const ret = new Headers();
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_append_feec4143bbf21904 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
var v0 = getCachedStringFromWasm0(arg1, arg2);
var v1 = getCachedStringFromWasm0(arg3, arg4);
getObject(arg0).append(v0, v1);
}, arguments) };
imports.wbg.__wbg_fetch_701fcd2bde06379a = function(arg0, arg1) {
const ret = getObject(arg0).fetch(getObject(arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_debug_2ef5d777cf4811fa = function(arg0) {
console.debug(getObject(arg0));
};
imports.wbg.__wbg_error_f0a6627f4b23c19d = function(arg0) {
console.error(getObject(arg0));
};
imports.wbg.__wbg_info_3ca7870690403fee = function(arg0) {
console.info(getObject(arg0));
};
imports.wbg.__wbg_log_7811587c4c6d2844 = function(arg0) {
console.log(getObject(arg0));
};
imports.wbg.__wbg_warn_4affe1093892a4ef = function(arg0) {
console.warn(getObject(arg0));
};
imports.wbg.__wbindgen_is_function = function(arg0) {
const ret = typeof(getObject(arg0)) === 'function';
return ret;
};
imports.wbg.__wbg_queueMicrotask_e5949c35d772a669 = function(arg0) {
queueMicrotask(getObject(arg0));
};
imports.wbg.__wbg_queueMicrotask_2be8b97a81fe4d00 = function(arg0) {
const ret = getObject(arg0).queueMicrotask;
return addHeapObject(ret);
};
imports.wbg.__wbg_get_4a9aa5157afeb382 = function(arg0, arg1) {
const ret = getObject(arg0)[arg1 >>> 0];
return addHeapObject(ret);
};
imports.wbg.__wbg_newnoargs_ccdcae30fd002262 = function(arg0, arg1) {
var v0 = getCachedStringFromWasm0(arg0, arg1);
const ret = new Function(v0);
return addHeapObject(ret);
};
imports.wbg.__wbg_call_669127b9d730c650 = function() { return handleError(function (arg0, arg1) {
const ret = getObject(arg0).call(getObject(arg1));
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_call_53fc3abd42e24ec8 = function() { return handleError(function (arg0, arg1, arg2) {
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_next_1989a20442400aaa = function() { return handleError(function (arg0) {
const ret = getObject(arg0).next();
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_next_15da6a3df9290720 = function(arg0) {
const ret = getObject(arg0).next;
return addHeapObject(ret);
};
imports.wbg.__wbg_done_bc26bf4ada718266 = function(arg0) {
const ret = getObject(arg0).done;
return ret;
};
imports.wbg.__wbg_value_0570714ff7d75f35 = function(arg0) {
const ret = getObject(arg0).value;
return addHeapObject(ret);
};
imports.wbg.__wbg_is_c74aa9bb973d6109 = function(arg0, arg1) {
const ret = Object.is(getObject(arg0), getObject(arg1));
return ret;
};
imports.wbg.__wbg_new_c728d68b8b34487e = function() {
const ret = new Object();
return addHeapObject(ret);
};
imports.wbg.__wbg_iterator_7ee1a391d310f8e4 = function() {
const ret = Symbol.iterator;
return addHeapObject(ret);
};
imports.wbg.__wbg_resolve_a3252b2860f0a09e = function(arg0) {
const ret = Promise.resolve(getObject(arg0));
return addHeapObject(ret);
};
imports.wbg.__wbg_then_89e1c559530b85cf = function(arg0, arg1) {
const ret = getObject(arg0).then(getObject(arg1));
return addHeapObject(ret);
};
imports.wbg.__wbg_then_1bbc9edafd859b06 = function(arg0, arg1, arg2) {
const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
return addHeapObject(ret);
};
imports.wbg.__wbg_globalThis_17eff828815f7d84 = function() { return handleError(function () {
const ret = globalThis.globalThis;
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_self_3fad056edded10bd = function() { return handleError(function () {
const ret = self.self;
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_window_a4f46c98a61d4089 = function() { return handleError(function () {
const ret = window.window;
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_global_46f939f6541643c5 = function() { return handleError(function () {
const ret = global.global;
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_new_d8a000788389a31e = function(arg0) {
const ret = new Uint8Array(getObject(arg0));
return addHeapObject(ret);
};
imports.wbg.__wbg_newwithbyteoffsetandlength_2dc04d99088b15e3 = function(arg0, arg1, arg2) {
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
return addHeapObject(ret);
};
imports.wbg.__wbg_length_a5587d6cd79ab197 = function(arg0) {
const ret = getObject(arg0).length;
return ret;
};
imports.wbg.__wbg_set_dcfd613a3420f908 = function(arg0, arg1, arg2) {
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
};
imports.wbg.__wbindgen_is_object = function(arg0) {
const val = getObject(arg0);
const ret = typeof(val) === 'object' && val !== null;
return ret;
};
imports.wbg.__wbg_buffer_344d9b41efe96da7 = function(arg0) {
const ret = getObject(arg0).buffer;
return addHeapObject(ret);
};
imports.wbg.__wbg_stringify_4039297315a25b00 = function() { return handleError(function (arg0) {
const ret = JSON.stringify(getObject(arg0));
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_get_2aff440840bb6202 = function() { return handleError(function (arg0, arg1) {
const ret = Reflect.get(getObject(arg0), getObject(arg1));
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_has_cdf8b85f6e903c80 = function() { return handleError(function (arg0, arg1) {
const ret = Reflect.has(getObject(arg0), getObject(arg1));
return ret;
}, arguments) };
imports.wbg.__wbg_set_40f7786a25a9cc7e = function() { return handleError(function (arg0, arg1, arg2) {
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
return ret;
}, arguments) };
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
const ret = debugString(getObject(arg1));
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};
imports.wbg.__wbindgen_memory = function() {
const ret = wasm.memory;
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper5350 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 595, __wbg_adapter_28);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper5352 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 593, __wbg_adapter_31);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper10787 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 699, __wbg_adapter_34);
return addHeapObject(ret);
};
return imports;
}
function __wbg_init_memory(imports, maybe_memory) {
}
function __wbg_finalize_init(instance, module) {
wasm = instance.exports;
__wbg_init.__wbindgen_wasm_module = module;
cachedInt32Memory0 = null;
cachedUint8Memory0 = null;
wasm.__wbindgen_start();
return wasm;
}
function initSync(module) {
if (wasm !== undefined) return wasm;
const imports = __wbg_get_imports();
__wbg_init_memory(imports);
if (!(module instanceof WebAssembly.Module)) {
module = new WebAssembly.Module(module);
}
const instance = new WebAssembly.Instance(module, imports);
return __wbg_finalize_init(instance, module);
}
async function __wbg_init(input) {
if (wasm !== undefined) return wasm;
if (typeof input === 'undefined') {
input = new URL('frontend-570f3815d7fd92194c0bd8caac6e873c37520262d948b899db110969bdd20a82965a58d200fb559dee4285a369e3013a_bg.wasm', import.meta.url);
}
const imports = __wbg_get_imports();
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
input = fetch(input);
}
__wbg_init_memory(imports);
const { instance, module } = await __wbg_load(await input, imports);
return __wbg_finalize_init(instance, module);
}
export { initSync }
export default __wbg_init;

View file

@ -1,153 +0,0 @@
<!DOCTYPE html><html><head>
<script type="module">
import init, * as bindings from '/frontend-570f3815d7fd92194c0bd8caac6e873c37520262d948b899db110969bdd20a82965a58d200fb559dee4285a369e3013a.js';
init('/frontend-570f3815d7fd92194c0bd8caac6e873c37520262d948b899db110969bdd20a82965a58d200fb559dee4285a369e3013a_bg.wasm');
window.wasmBindings = bindings;
</script>
<style>
img {
max-width: 250px;
height: auto;
}
.error {
border: 1px solid red;
color: red;
background-color: lightpink;
}
</style>
<link rel="preload" href="/frontend-570f3815d7fd92194c0bd8caac6e873c37520262d948b899db110969bdd20a82965a58d200fb559dee4285a369e3013a_bg.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" integrity="sha384-Vw84Fdf9khlMC9jKrG6HPDdSAmLZSLiZ2xEJab3SCoKWWljSAPtVne5ChaNp4wE6">
<link rel="modulepreload" href="/frontend-570f3815d7fd92194c0bd8caac6e873c37520262d948b899db110969bdd20a82965a58d200fb559dee4285a369e3013a.js" crossorigin="anonymous" integrity="sha384-uvU8cJ-rIWGrY5c2Ms2A0n6dIWdhqLgCPj6u5m_zninPENzyXtefBjknYTthlevK"></head>
<body>
<script>"use strict";
(function () {
const address = '{{__TRUNK_ADDRESS__}}';
let protocol = '';
protocol =
protocol
? protocol
: window.location.protocol === 'https:'
? 'wss'
: 'ws';
const url = protocol + '://' + address + '/_trunk/ws';
class Overlay {
constructor() {
// create an overlay
this._overlay = document.createElement("div");
const style = this._overlay.style;
style.height = "100vh";
style.width = "100vw";
style.position = "fixed";
style.top = "0";
style.left = "0";
style.backgroundColor = "rgba(222, 222, 222, 0.5)";
style.fontFamily = "sans-serif";
// not sure that's the right approach
style.zIndex = "1000000";
style.backdropFilter = "blur(1rem)";
const container = document.createElement("div");
// center it
container.style.position = "absolute";
container.style.top = "30%";
container.style.left = "15%";
container.style.maxWidth = "85%";
this._title = document.createElement("div");
this._title.innerText = "Build failure";
this._title.style.paddingBottom = "2rem";
this._title.style.fontSize = "2.5rem";
this._message = document.createElement("div");
this._message.style.whiteSpace = "pre-wrap";
const icon= document.createElement("div");
icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" fill="#dc3545" viewBox="0 0 16 16"><path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/></svg>';
this._title.prepend(icon);
container.append(this._title, this._message);
this._overlay.append(container);
this._inject();
window.setInterval(() => {
this._inject();
}, 250);
}
set reason(reason) {
this._message.textContent = reason;
}
_inject() {
if (!this._overlay.isConnected) {
// prepend it
document.body?.prepend(this._overlay);
}
}
}
class Client {
constructor(url) {
this.url = url;
this.poll_interval = 5000;
this._overlay = null;
}
start() {
const ws = new WebSocket(this.url);
ws.onmessage = (ev) => {
const msg = JSON.parse(ev.data);
switch (msg.type) {
case "reload":
this.reload();
break;
case "buildFailure":
this.buildFailure(msg.data)
break;
}
};
ws.onclose = this.onclose;
}
onclose() {
window.setTimeout(
() => {
// when we successfully reconnect, we'll force a
// reload (since we presumably lost connection to
// trunk due to it being killed, so it will have
// rebuilt on restart)
const ws = new WebSocket(this.url);
ws.onopen = () => window.location.reload();
ws.onclose = this.onclose;
},
this.poll_interval);
}
reload() {
window.location.reload();
}
buildFailure({reason}) {
// also log the console
console.error("Build failed:", reason);
console.debug("Overlay", this._overlay);
if (!this._overlay) {
this._overlay = new Overlay();
}
this._overlay.reason = reason;
}
}
new Client(url).start();
})()
</script></body></html>

View file

@ -1,3 +0,0 @@
[toolchain]
profile = "default"
channel = "nightly"

View file

@ -1,14 +1,14 @@
use crate::database::article::{ArticleView, DbArticle, DbArticleForm}; use crate::backend::database::article::{ArticleView, DbArticle, DbArticleForm};
use crate::database::conflict::{ApiConflict, DbConflict, DbConflictForm}; use crate::backend::database::conflict::{ApiConflict, DbConflict, DbConflictForm};
use crate::database::edit::{DbEdit, DbEditForm}; use crate::backend::database::edit::{DbEdit, DbEditForm};
use crate::database::instance::DbInstance; use crate::backend::database::instance::DbInstance;
use crate::database::user::LocalUserView; use crate::backend::database::user::LocalUserView;
use crate::database::version::EditVersion; use crate::backend::database::version::EditVersion;
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use crate::error::MyResult; use crate::backend::error::MyResult;
use crate::federation::activities::create_article::CreateArticle; use crate::backend::federation::activities::create_article::CreateArticle;
use crate::federation::activities::submit_article_update; use crate::backend::federation::activities::submit_article_update;
use crate::utils::generate_article_version; use crate::backend::utils::generate_article_version;
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
use activitypub_federation::fetch::object_id::ObjectId; use activitypub_federation::fetch::object_id::ObjectId;
use axum::extract::Query; use axum::extract::Query;
@ -26,7 +26,7 @@ pub struct CreateArticleData {
/// Create a new article with empty text, and federate it to followers. /// Create a new article with empty text, and federate it to followers.
#[debug_handler] #[debug_handler]
pub(in crate::api) async fn create_article( pub(in crate::backend::api) async fn create_article(
Extension(_user): Extension<LocalUserView>, Extension(_user): Extension<LocalUserView>,
data: Data<MyDataHandle>, data: Data<MyDataHandle>,
Form(create_article): Form<CreateArticleData>, Form(create_article): Form<CreateArticleData>,
@ -56,7 +56,7 @@ pub(in crate::api) async fn create_article(
pub struct EditArticleData { pub struct EditArticleData {
/// Id of the article to edit /// Id of the article to edit
pub article_id: i32, pub article_id: i32,
/// Full, new text of the article. A diff against `previous_version` is generated on the server /// Full, new text of the article. A diff against `previous_version` is generated on the backend
/// side to handle conflicts. /// side to handle conflicts.
pub new_text: String, pub new_text: String,
/// The version that this edit is based on, ie [DbArticle.latest_version] or /// The version that this edit is based on, ie [DbArticle.latest_version] or
@ -76,7 +76,7 @@ pub struct EditArticleData {
/// ///
/// Conflicts are stored in the database so they can be retrieved later from `/api/v3/edit_conflicts`. /// Conflicts are stored in the database so they can be retrieved later from `/api/v3/edit_conflicts`.
#[debug_handler] #[debug_handler]
pub(in crate::api) async fn edit_article( pub(in crate::backend::api) async fn edit_article(
Extension(user): Extension<LocalUserView>, Extension(user): Extension<LocalUserView>,
data: Data<MyDataHandle>, data: Data<MyDataHandle>,
Form(edit_form): Form<EditArticleData>, Form(edit_form): Form<EditArticleData>,
@ -125,7 +125,7 @@ pub struct GetArticleData {
/// Retrieve an article by ID. It must already be stored in the local database. /// Retrieve an article by ID. It must already be stored in the local database.
#[debug_handler] #[debug_handler]
pub(in crate::api) async fn get_article( pub(in crate::backend::api) async fn get_article(
Query(query): Query<GetArticleData>, Query(query): Query<GetArticleData>,
data: Data<MyDataHandle>, data: Data<MyDataHandle>,
) -> MyResult<Json<ArticleView>> { ) -> MyResult<Json<ArticleView>> {
@ -146,7 +146,7 @@ pub struct ForkArticleData {
/// Fork a remote article to local instance. This is useful if there are disagreements about /// Fork a remote article to local instance. This is useful if there are disagreements about
/// how an article should be edited. /// how an article should be edited.
#[debug_handler] #[debug_handler]
pub(in crate::api) async fn fork_article( pub(in crate::backend::api) async fn fork_article(
Extension(_user): Extension<LocalUserView>, Extension(_user): Extension<LocalUserView>,
data: Data<MyDataHandle>, data: Data<MyDataHandle>,
Form(fork_form): Form<ForkArticleData>, Form(fork_form): Form<ForkArticleData>,

View file

@ -1,8 +1,8 @@
use crate::database::instance::{DbInstance, InstanceView}; use crate::backend::database::instance::{DbInstance, InstanceView};
use crate::database::user::LocalUserView; use crate::backend::database::user::LocalUserView;
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use crate::error::MyResult; use crate::backend::error::MyResult;
use crate::federation::activities::follow::Follow; use crate::backend::federation::activities::follow::Follow;
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
use axum::Extension; use axum::Extension;
use axum::{Form, Json}; use axum::{Form, Json};
@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
/// Retrieve the local instance info. /// Retrieve the local instance info.
#[debug_handler] #[debug_handler]
pub(in crate::api) async fn get_local_instance( pub(in crate::backend::api) async fn get_local_instance(
data: Data<MyDataHandle>, data: Data<MyDataHandle>,
) -> MyResult<Json<InstanceView>> { ) -> MyResult<Json<InstanceView>> {
let local_instance = DbInstance::read_local_view(&data.db_connection)?; let local_instance = DbInstance::read_local_view(&data.db_connection)?;
@ -26,7 +26,7 @@ pub struct FollowInstance {
/// Make the local instance follow a given remote instance, to receive activities about new and /// Make the local instance follow a given remote instance, to receive activities about new and
/// updated articles. /// updated articles.
#[debug_handler] #[debug_handler]
pub(in crate::api) async fn follow_instance( pub(in crate::backend::api) async fn follow_instance(
Extension(user): Extension<LocalUserView>, Extension(user): Extension<LocalUserView>,
data: Data<MyDataHandle>, data: Data<MyDataHandle>,
Form(query): Form<FollowInstance>, Form(query): Form<FollowInstance>,

View file

@ -1,17 +1,17 @@
use crate::api::article::create_article; use crate::backend::api::article::create_article;
use crate::api::article::{edit_article, fork_article, get_article}; use crate::backend::api::article::{edit_article, fork_article, get_article};
use crate::api::instance::follow_instance; use crate::backend::api::instance::follow_instance;
use crate::api::instance::get_local_instance; use crate::backend::api::instance::get_local_instance;
use crate::api::user::login_user; use crate::backend::api::user::login_user;
use crate::api::user::register_user; use crate::backend::api::user::register_user;
use crate::api::user::validate; use crate::backend::api::user::validate;
use crate::database::article::{ArticleView, DbArticle}; use crate::backend::database::article::{ArticleView, DbArticle};
use crate::database::conflict::{ApiConflict, DbConflict}; use crate::backend::database::conflict::{ApiConflict, DbConflict};
use crate::database::edit::DbEdit; use crate::backend::database::edit::DbEdit;
use crate::database::instance::DbInstance; use crate::backend::database::instance::DbInstance;
use crate::database::user::LocalUserView; use crate::backend::database::user::LocalUserView;
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use crate::error::MyResult; use crate::backend::error::MyResult;
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
use activitypub_federation::fetch::object_id::ObjectId; use activitypub_federation::fetch::object_id::ObjectId;
use axum::extract::Query; use axum::extract::Query;
@ -29,7 +29,7 @@ use axum::{Json, Router};
use axum_macros::debug_handler; use axum_macros::debug_handler;
use futures::future::try_join_all; use futures::future::try_join_all;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tracing::warn; use log::warn;
use url::Url; use url::Url;
pub mod article; pub mod article;

View file

@ -1,6 +1,6 @@
use crate::database::user::{DbLocalUser, DbPerson, LocalUserView}; use crate::backend::database::user::{DbLocalUser, DbPerson, LocalUserView};
use crate::database::{read_jwt_secret, MyDataHandle}; use crate::backend::database::{read_jwt_secret, MyDataHandle};
use crate::error::MyResult; use crate::backend::error::MyResult;
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
use anyhow::anyhow; use anyhow::anyhow;
use axum::{Form, Json}; use axum::{Form, Json};
@ -25,7 +25,7 @@ pub struct Claims {
pub exp: u64, pub exp: u64,
} }
pub(in crate::api) fn generate_login_token( pub(in crate::backend::api) fn generate_login_token(
local_user: DbLocalUser, local_user: DbLocalUser,
data: &Data<MyDataHandle>, data: &Data<MyDataHandle>,
) -> MyResult<LoginResponse> { ) -> MyResult<LoginResponse> {
@ -63,7 +63,7 @@ pub struct LoginResponse {
} }
#[debug_handler] #[debug_handler]
pub(in crate::api) async fn register_user( pub(in crate::backend::api) async fn register_user(
data: Data<MyDataHandle>, data: Data<MyDataHandle>,
Form(form): Form<RegisterUserData>, Form(form): Form<RegisterUserData>,
) -> MyResult<Json<LoginResponse>> { ) -> MyResult<Json<LoginResponse>> {
@ -78,7 +78,7 @@ pub struct LoginUserData {
} }
#[debug_handler] #[debug_handler]
pub(in crate::api) async fn login_user( pub(in crate::backend::api) async fn login_user(
data: Data<MyDataHandle>, data: Data<MyDataHandle>,
Form(form): Form<LoginUserData>, Form(form): Form<LoginUserData>,
) -> MyResult<Json<LoginResponse>> { ) -> MyResult<Json<LoginResponse>> {

View file

@ -1,8 +1,8 @@
use crate::database::edit::DbEdit; use crate::backend::database::edit::DbEdit;
use crate::database::schema::{article, edit}; use crate::backend::database::schema::{article, edit};
use crate::error::MyResult; use crate::backend::error::MyResult;
use crate::federation::objects::edits_collection::DbEditCollection; use crate::backend::federation::objects::edits_collection::DbEditCollection;
use activitypub_federation::fetch::collection_id::CollectionId; use activitypub_federation::fetch::collection_id::CollectionId;
use activitypub_federation::fetch::object_id::ObjectId; use activitypub_federation::fetch::object_id::ObjectId;
use diesel::pg::PgConnection; use diesel::pg::PgConnection;
@ -14,7 +14,7 @@ use diesel::{
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::database::version::EditVersion; use crate::backend::database::version::EditVersion;
use std::ops::DerefMut; use std::ops::DerefMut;
use std::sync::Mutex; use std::sync::Mutex;

View file

@ -1,12 +1,12 @@
use crate::database::article::DbArticle; use crate::backend::database::article::DbArticle;
use crate::database::edit::DbEdit; use crate::backend::database::edit::DbEdit;
use crate::database::schema::conflict; use crate::backend::database::schema::conflict;
use crate::database::user::DbLocalUser; use crate::backend::database::user::DbLocalUser;
use crate::database::version::EditVersion; use crate::backend::database::version::EditVersion;
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use crate::error::MyResult; use crate::backend::error::MyResult;
use crate::federation::activities::submit_article_update; use crate::backend::federation::activities::submit_article_update;
use crate::utils::generate_article_version; use crate::backend::utils::generate_article_version;
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
use diesel::ExpressionMethods; use diesel::ExpressionMethods;
use diesel::{ use diesel::{

View file

@ -1,7 +1,7 @@
use crate::database::schema::edit; use crate::backend::database::schema::edit;
use crate::database::version::EditVersion; use crate::backend::database::version::EditVersion;
use crate::database::DbArticle; use crate::backend::database::DbArticle;
use crate::error::MyResult; use crate::backend::error::MyResult;
use activitypub_federation::fetch::object_id::ObjectId; use activitypub_federation::fetch::object_id::ObjectId;
use diesel::ExpressionMethods; use diesel::ExpressionMethods;
use diesel::{ use diesel::{

View file

@ -1,8 +1,8 @@
use crate::database::schema::{instance, instance_follow}; use crate::backend::database::schema::{instance, instance_follow};
use crate::database::user::DbPerson; use crate::backend::database::user::DbPerson;
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use crate::error::MyResult; use crate::backend::error::MyResult;
use crate::federation::objects::articles_collection::DbArticleCollection; use crate::backend::federation::objects::articles_collection::DbArticleCollection;
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
use activitypub_federation::fetch::collection_id::CollectionId; use activitypub_federation::fetch::collection_id::CollectionId;
use activitypub_federation::fetch::object_id::ObjectId; use activitypub_federation::fetch::object_id::ObjectId;
@ -122,7 +122,7 @@ impl DbInstance {
} }
pub fn read_followers(id_: i32, conn: &Mutex<PgConnection>) -> MyResult<Vec<DbPerson>> { pub fn read_followers(id_: i32, conn: &Mutex<PgConnection>) -> MyResult<Vec<DbPerson>> {
use crate::database::schema::person; use crate::backend::database::schema::person;
use instance_follow::dsl::{follower_id, instance_id}; use instance_follow::dsl::{follower_id, instance_id};
let mut conn = conn.lock().unwrap(); let mut conn = conn.lock().unwrap();
Ok(instance_follow::table Ok(instance_follow::table

View file

@ -1,10 +1,10 @@
use crate::database::article::DbArticle; use crate::backend::database::article::DbArticle;
use diesel::PgConnection; use diesel::PgConnection;
use std::ops::Deref; use std::ops::Deref;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
pub type MyDataHandle = MyData; pub type MyDataHandle = MyData;
use crate::database::schema::jwt_secret; use crate::backend::database::schema::jwt_secret;
use crate::error::MyResult; use crate::backend::error::MyResult;
use diesel::{QueryDsl, RunQueryDsl}; use diesel::{QueryDsl, RunQueryDsl};
use std::ops::DerefMut; use std::ops::DerefMut;

View file

@ -1,6 +1,6 @@
use crate::database::schema::{local_user, person}; use crate::backend::database::schema::{local_user, person};
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use crate::error::MyResult; use crate::backend::error::MyResult;
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
use activitypub_federation::fetch::object_id::ObjectId; use activitypub_federation::fetch::object_id::ObjectId;
use activitypub_federation::http_signatures::generate_actor_keypair; use activitypub_federation::http_signatures::generate_actor_keypair;

View file

@ -1,4 +1,4 @@
use crate::error::MyResult; use crate::backend::error::MyResult;
use std::hash::Hash; use std::hash::Hash;
use diesel_derive_newtype::DieselNewType; use diesel_derive_newtype::DieselNewType;

View file

@ -1,8 +1,8 @@
use crate::database::instance::DbInstance; use crate::backend::database::instance::DbInstance;
use crate::error::MyResult; use crate::backend::error::MyResult;
use crate::federation::send_activity; use crate::backend::federation::send_activity;
use crate::utils::generate_activity_id; use crate::backend::utils::generate_activity_id;
use crate::{database::MyDataHandle, federation::activities::follow::Follow}; use crate::backend::{database::MyDataHandle, federation::activities::follow::Follow};
use activitypub_federation::traits::Actor; use activitypub_federation::traits::Actor;
use activitypub_federation::{ use activitypub_federation::{
config::Data, fetch::object_id::ObjectId, kinds::activity::AcceptType, traits::ActivityHandler, config::Data, fetch::object_id::ObjectId, kinds::activity::AcceptType, traits::ActivityHandler,
@ -48,7 +48,7 @@ impl Accept {
#[async_trait::async_trait] #[async_trait::async_trait]
impl ActivityHandler for Accept { impl ActivityHandler for Accept {
type DataType = MyDataHandle; type DataType = MyDataHandle;
type Error = crate::error::Error; type Error = crate::backend::error::Error;
fn id(&self) -> &Url { fn id(&self) -> &Url {
&self.id &self.id

View file

@ -1,8 +1,8 @@
use crate::database::instance::DbInstance; use crate::backend::database::instance::DbInstance;
use crate::database::{article::DbArticle, MyDataHandle}; use crate::backend::database::{article::DbArticle, MyDataHandle};
use crate::error::MyResult; use crate::backend::error::MyResult;
use crate::federation::objects::article::ApubArticle; use crate::backend::federation::objects::article::ApubArticle;
use crate::utils::generate_activity_id; use crate::backend::utils::generate_activity_id;
use activitypub_federation::kinds::activity::CreateType; use activitypub_federation::kinds::activity::CreateType;
use activitypub_federation::{ use activitypub_federation::{
config::Data, config::Data,
@ -47,7 +47,7 @@ impl CreateArticle {
#[async_trait::async_trait] #[async_trait::async_trait]
impl ActivityHandler for CreateArticle { impl ActivityHandler for CreateArticle {
type DataType = MyDataHandle; type DataType = MyDataHandle;
type Error = crate::error::Error; type Error = crate::backend::error::Error;
fn id(&self) -> &Url { fn id(&self) -> &Url {
&self.id &self.id

View file

@ -1,8 +1,8 @@
use crate::database::instance::DbInstance; use crate::backend::database::instance::DbInstance;
use crate::database::user::DbPerson; use crate::backend::database::user::DbPerson;
use crate::error::MyResult; use crate::backend::error::MyResult;
use crate::federation::send_activity; use crate::backend::federation::send_activity;
use crate::{database::MyDataHandle, federation::activities::accept::Accept, generate_activity_id}; use crate::backend::{database::MyDataHandle, federation::activities::accept::Accept, generate_activity_id};
use activitypub_federation::{ use activitypub_federation::{
config::Data, config::Data,
fetch::object_id::ObjectId, fetch::object_id::ObjectId,
@ -40,7 +40,7 @@ impl Follow {
#[async_trait::async_trait] #[async_trait::async_trait]
impl ActivityHandler for Follow { impl ActivityHandler for Follow {
type DataType = MyDataHandle; type DataType = MyDataHandle;
type Error = crate::error::Error; type Error = crate::backend::error::Error;
fn id(&self) -> &Url { fn id(&self) -> &Url {
&self.id &self.id

View file

@ -1,12 +1,11 @@
use crate::database::article::DbArticle; use crate::backend::database::article::DbArticle;
use crate::database::edit::{DbEdit, DbEditForm}; use crate::backend::database::edit::{DbEdit, DbEditForm};
use crate::database::instance::DbInstance; use crate::backend::database::instance::DbInstance;
use crate::backend::database::version::EditVersion;
use crate::database::version::EditVersion; use crate::backend::database::MyDataHandle;
use crate::database::MyDataHandle; use crate::backend::error::Error;
use crate::error::Error; use crate::backend::federation::activities::update_local_article::UpdateLocalArticle;
use crate::federation::activities::update_local_article::UpdateLocalArticle; use crate::backend::federation::activities::update_remote_article::UpdateRemoteArticle;
use crate::federation::activities::update_remote_article::UpdateRemoteArticle;
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
pub mod accept; pub mod accept;

View file

@ -1,17 +1,17 @@
use crate::database::conflict::{DbConflict, DbConflictForm}; use crate::backend::database::conflict::{DbConflict, DbConflictForm};
use crate::database::instance::DbInstance; use crate::backend::database::instance::DbInstance;
use crate::database::version::EditVersion; use crate::backend::database::version::EditVersion;
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use crate::error::MyResult; use crate::backend::error::MyResult;
use crate::federation::objects::edit::ApubEdit; use crate::backend::federation::objects::edit::ApubEdit;
use crate::utils::generate_activity_id; use crate::backend::utils::generate_activity_id;
use activitypub_federation::kinds::activity::RejectType; use activitypub_federation::kinds::activity::RejectType;
use activitypub_federation::{ use activitypub_federation::{
config::Data, fetch::object_id::ObjectId, protocol::helpers::deserialize_one_or_many, config::Data, fetch::object_id::ObjectId, protocol::helpers::deserialize_one_or_many,
traits::ActivityHandler, traits::ActivityHandler,
}; };
use crate::federation::send_activity; use crate::backend::federation::send_activity;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use url::Url; use url::Url;
@ -56,7 +56,7 @@ impl RejectEdit {
#[async_trait::async_trait] #[async_trait::async_trait]
impl ActivityHandler for RejectEdit { impl ActivityHandler for RejectEdit {
type DataType = MyDataHandle; type DataType = MyDataHandle;
type Error = crate::error::Error; type Error = crate::backend::error::Error;
fn id(&self) -> &Url { fn id(&self) -> &Url {
&self.id &self.id

View file

@ -1,9 +1,9 @@
use crate::database::{article::DbArticle, MyDataHandle}; use crate::backend::database::{article::DbArticle, MyDataHandle};
use crate::error::MyResult; use crate::backend::error::MyResult;
use crate::federation::objects::article::ApubArticle; use crate::backend::federation::objects::article::ApubArticle;
use crate::database::instance::DbInstance; use crate::backend::database::instance::DbInstance;
use crate::utils::generate_activity_id; use crate::backend::utils::generate_activity_id;
use activitypub_federation::kinds::activity::UpdateType; use activitypub_federation::kinds::activity::UpdateType;
use activitypub_federation::{ use activitypub_federation::{
config::Data, config::Data,
@ -56,7 +56,7 @@ impl UpdateLocalArticle {
#[async_trait::async_trait] #[async_trait::async_trait]
impl ActivityHandler for UpdateLocalArticle { impl ActivityHandler for UpdateLocalArticle {
type DataType = MyDataHandle; type DataType = MyDataHandle;
type Error = crate::error::Error; type Error = crate::backend::error::Error;
fn id(&self) -> &Url { fn id(&self) -> &Url {
&self.id &self.id

View file

@ -1,14 +1,14 @@
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use crate::error::MyResult; use crate::backend::error::MyResult;
use crate::database::article::DbArticle; use crate::backend::database::article::DbArticle;
use crate::database::edit::DbEdit; use crate::backend::database::edit::DbEdit;
use crate::database::instance::DbInstance; use crate::backend::database::instance::DbInstance;
use crate::federation::activities::reject::RejectEdit; use crate::backend::federation::activities::reject::RejectEdit;
use crate::federation::activities::update_local_article::UpdateLocalArticle; use crate::backend::federation::activities::update_local_article::UpdateLocalArticle;
use crate::federation::objects::edit::ApubEdit; use crate::backend::federation::objects::edit::ApubEdit;
use crate::federation::send_activity; use crate::backend::federation::send_activity;
use crate::utils::generate_activity_id; use crate::backend::utils::generate_activity_id;
use activitypub_federation::kinds::activity::UpdateType; use activitypub_federation::kinds::activity::UpdateType;
use activitypub_federation::{ use activitypub_federation::{
config::Data, config::Data,
@ -62,7 +62,7 @@ impl UpdateRemoteArticle {
#[async_trait::async_trait] #[async_trait::async_trait]
impl ActivityHandler for UpdateRemoteArticle { impl ActivityHandler for UpdateRemoteArticle {
type DataType = MyDataHandle; type DataType = MyDataHandle;
type Error = crate::error::Error; type Error = crate::backend::error::Error;
fn id(&self) -> &Url { fn id(&self) -> &Url {
&self.id &self.id

View file

@ -1,11 +1,11 @@
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use activitypub_federation::activity_sending::SendActivityTask; use activitypub_federation::activity_sending::SendActivityTask;
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
use activitypub_federation::protocol::context::WithContext; use activitypub_federation::protocol::context::WithContext;
use activitypub_federation::traits::{ActivityHandler, Actor}; use activitypub_federation::traits::{ActivityHandler, Actor};
use serde::Serialize; use serde::Serialize;
use std::fmt::Debug; use std::fmt::Debug;
use tracing::log::warn; use log::warn;
use url::Url; use url::Url;
pub mod activities; pub mod activities;

View file

@ -1,9 +1,9 @@
use crate::database::article::DbArticleForm; use crate::backend::database::article::DbArticleForm;
use crate::database::instance::DbInstance; use crate::backend::database::instance::DbInstance;
use crate::database::version::EditVersion; use crate::backend::database::version::EditVersion;
use crate::database::{article::DbArticle, MyDataHandle}; use crate::backend::database::{article::DbArticle, MyDataHandle};
use crate::error::Error; use crate::backend::error::Error;
use crate::federation::objects::edits_collection::DbEditCollection; use crate::backend::federation::objects::edits_collection::DbEditCollection;
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
use activitypub_federation::fetch::collection_id::CollectionId; use activitypub_federation::fetch::collection_id::CollectionId;
use activitypub_federation::kinds::object::ArticleType; use activitypub_federation::kinds::object::ArticleType;

View file

@ -1,7 +1,7 @@
use crate::database::instance::DbInstance; use crate::backend::database::instance::DbInstance;
use crate::database::{article::DbArticle, MyDataHandle}; use crate::backend::database::{article::DbArticle, MyDataHandle};
use crate::error::Error; use crate::backend::error::Error;
use crate::federation::objects::article::ApubArticle; use crate::backend::federation::objects::article::ApubArticle;
use activitypub_federation::kinds::collection::CollectionType; use activitypub_federation::kinds::collection::CollectionType;
use activitypub_federation::{ use activitypub_federation::{

View file

@ -1,9 +1,9 @@
use crate::database::article::DbArticle; use crate::backend::database::article::DbArticle;
use crate::database::edit::{DbEdit, DbEditForm}; use crate::backend::database::edit::{DbEdit, DbEditForm};
use crate::database::user::DbPerson; use crate::backend::database::user::DbPerson;
use crate::database::version::EditVersion; use crate::backend::database::version::EditVersion;
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use crate::error::Error; use crate::backend::error::Error;
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
use activitypub_federation::fetch::object_id::ObjectId; use activitypub_federation::fetch::object_id::ObjectId;
use activitypub_federation::traits::Object; use activitypub_federation::traits::Object;

View file

@ -1,10 +1,10 @@
use crate::database::article::DbArticle; use crate::backend::database::article::DbArticle;
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use crate::error::Error; use crate::backend::error::Error;
use crate::federation::objects::edit::ApubEdit; use crate::backend::federation::objects::edit::ApubEdit;
use crate::database::edit::DbEdit; use crate::backend::database::edit::DbEdit;
use crate::database::instance::DbInstance; use crate::backend::database::instance::DbInstance;
use activitypub_federation::kinds::collection::OrderedCollectionType; use activitypub_federation::kinds::collection::OrderedCollectionType;
use activitypub_federation::{ use activitypub_federation::{
config::Data, config::Data,

View file

@ -1,8 +1,8 @@
use crate::database::instance::{DbInstance, DbInstanceForm}; use crate::backend::database::instance::{DbInstance, DbInstanceForm};
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use crate::error::{Error, MyResult}; use crate::backend::error::{Error, MyResult};
use crate::federation::objects::articles_collection::DbArticleCollection; use crate::backend::federation::objects::articles_collection::DbArticleCollection;
use crate::federation::send_activity; use crate::backend::federation::send_activity;
use activitypub_federation::fetch::collection_id::CollectionId; use activitypub_federation::fetch::collection_id::CollectionId;
use activitypub_federation::kinds::actor::ServiceType; use activitypub_federation::kinds::actor::ServiceType;

View file

@ -1,6 +1,6 @@
use crate::database::user::{DbPerson, DbPersonForm}; use crate::backend::database::user::{DbPerson, DbPersonForm};
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use crate::error::Error; use crate::backend::error::Error;
use activitypub_federation::kinds::actor::PersonType; use activitypub_federation::kinds::actor::PersonType;
use activitypub_federation::{ use activitypub_federation::{
config::Data, config::Data,

View file

@ -1,19 +1,19 @@
use crate::database::article::DbArticle; use crate::backend::database::article::DbArticle;
use crate::database::instance::DbInstance; use crate::backend::database::instance::DbInstance;
use crate::database::user::DbPerson; use crate::backend::database::user::DbPerson;
use crate::database::MyDataHandle; use crate::backend::database::MyDataHandle;
use crate::error::{Error, MyResult}; use crate::backend::error::{Error, MyResult};
use crate::federation::activities::accept::Accept; use crate::backend::federation::activities::accept::Accept;
use crate::federation::activities::create_article::CreateArticle; use crate::backend::federation::activities::create_article::CreateArticle;
use crate::federation::activities::follow::Follow; use crate::backend::federation::activities::follow::Follow;
use crate::federation::activities::reject::RejectEdit; use crate::backend::federation::activities::reject::RejectEdit;
use crate::federation::activities::update_local_article::UpdateLocalArticle; use crate::backend::federation::activities::update_local_article::UpdateLocalArticle;
use crate::federation::activities::update_remote_article::UpdateRemoteArticle; use crate::backend::federation::activities::update_remote_article::UpdateRemoteArticle;
use crate::federation::objects::article::ApubArticle; use crate::backend::federation::objects::article::ApubArticle;
use crate::federation::objects::articles_collection::{ArticleCollection, DbArticleCollection}; use crate::backend::federation::objects::articles_collection::{ArticleCollection, DbArticleCollection};
use crate::federation::objects::edits_collection::{ApubEditCollection, DbEditCollection}; use crate::backend::federation::objects::edits_collection::{ApubEditCollection, DbEditCollection};
use crate::federation::objects::instance::ApubInstance; use crate::backend::federation::objects::instance::ApubInstance;
use crate::federation::objects::user::ApubUser; use crate::backend::federation::objects::user::ApubUser;
use activitypub_federation::axum::inbox::{receive_activity, ActivityData}; use activitypub_federation::axum::inbox::{receive_activity, ActivityData};
use activitypub_federation::axum::json::FederationJson; use activitypub_federation::axum::json::FederationJson;
use activitypub_federation::config::Data; use activitypub_federation::config::Data;
@ -32,7 +32,8 @@ use url::Url;
pub fn federation_routes() -> Router { pub fn federation_routes() -> Router {
Router::new() Router::new()
.route("/", get(http_get_instance)) // TODO
//.route("/", get(http_get_instance))
.route("/user/:name", get(http_get_person)) .route("/user/:name", get(http_get_person))
.route("/all_articles", get(http_get_all_articles)) .route("/all_articles", get(http_get_all_articles))
.route("/article/:title", get(http_get_article)) .route("/article/:title", get(http_get_article))
@ -145,7 +146,6 @@ impl Object for UserOrInstance {
}) })
} }
#[tracing::instrument(skip_all)]
async fn read_from_id( async fn read_from_id(
object_id: Url, object_id: Url,
data: &Data<Self::DataType>, data: &Data<Self::DataType>,
@ -159,7 +159,6 @@ impl Object for UserOrInstance {
}) })
} }
#[tracing::instrument(skip_all)]
async fn delete(self, data: &Data<Self::DataType>) -> Result<(), Error> { async fn delete(self, data: &Data<Self::DataType>) -> Result<(), Error> {
match self { match self {
UserOrInstance::User(p) => p.delete(data).await, UserOrInstance::User(p) => p.delete(data).await,
@ -171,7 +170,6 @@ impl Object for UserOrInstance {
unimplemented!() unimplemented!()
} }
#[tracing::instrument(skip_all)]
async fn verify( async fn verify(
apub: &Self::Kind, apub: &Self::Kind,
expected_domain: &Url, expected_domain: &Url,
@ -183,7 +181,6 @@ impl Object for UserOrInstance {
} }
} }
#[tracing::instrument(skip_all)]
async fn from_json(apub: Self::Kind, data: &Data<Self::DataType>) -> Result<Self, Error> { async fn from_json(apub: Self::Kind, data: &Data<Self::DataType>) -> Result<Self, Error> {
Ok(match apub { Ok(match apub {
PersonOrInstance::Person(p) => { PersonOrInstance::Person(p) => {

View file

@ -1,8 +1,8 @@
use crate::database::instance::{DbInstance, DbInstanceForm}; use crate::backend::database::instance::{DbInstance, DbInstanceForm};
use crate::database::MyData; use crate::backend::database::MyData;
use crate::error::MyResult; use crate::backend::error::MyResult;
use crate::federation::routes::federation_routes; use crate::backend::federation::routes::federation_routes;
use crate::utils::generate_activity_id; use crate::backend::utils::generate_activity_id;
use activitypub_federation::config::{FederationConfig, FederationMiddleware}; use activitypub_federation::config::{FederationConfig, FederationMiddleware};
use activitypub_federation::fetch::collection_id::CollectionId; use activitypub_federation::fetch::collection_id::CollectionId;
use activitypub_federation::fetch::object_id::ObjectId; use activitypub_federation::fetch::object_id::ObjectId;
@ -17,7 +17,10 @@ use diesel_migrations::EmbeddedMigrations;
use diesel_migrations::MigrationHarness; use diesel_migrations::MigrationHarness;
use std::net::ToSocketAddrs; use std::net::ToSocketAddrs;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use tracing::info;use tower_http::cors::CorsLayer; use tower_http::cors::CorsLayer;
use log::info;
use leptos_axum::{generate_route_list, LeptosRoutes};
use leptos::*;use leptos_meta::*;use leptos_router::*;
pub mod api; pub mod api;
pub mod database; pub mod database;
@ -25,6 +28,7 @@ pub mod error;
pub mod federation; pub mod federation;
mod utils; mod utils;
const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations"); const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");
pub async fn start(hostname: &str, database_url: &str) -> MyResult<()> { pub async fn start(hostname: &str, database_url: &str) -> MyResult<()> {
@ -59,19 +63,41 @@ pub async fn start(hostname: &str, database_url: &str) -> MyResult<()> {
}; };
DbInstance::create(&form, &config.db_connection)?; DbInstance::create(&form, &config.db_connection)?;
let conf = get_configuration(Some("Cargo.toml")).await.unwrap();
let leptos_options = conf.leptos_options;
let addr = leptos_options.site_addr;
let routes = generate_route_list(App);
info!("Listening with axum on {hostname}"); info!("Listening with axum on {hostname}");
let config = config.clone(); let config = config.clone();
let app = Router::new() let app = Router::new()
.leptos_routes(&leptos_options, routes, || view! { <App/> } )
.with_state(leptos_options)
.nest("", federation_routes()) .nest("", federation_routes())
.nest("/api/v1", api_routes()) .nest("/api/v1", api_routes())
.layer(FederationMiddleware::new(config)) .layer(FederationMiddleware::new(config))
.layer(CorsLayer::permissive()); .layer(CorsLayer::permissive());
/*
let addr = hostname let addr = hostname
.to_socket_addrs()? .to_socket_addrs()?
.next() .next()
.expect("Failed to lookup domain name"); .expect("Failed to lookup domain name");
*/
Server::bind(&addr).serve(app.into_make_service()).await?; Server::bind(&addr).serve(app.into_make_service()).await?;
Ok(()) Ok(())
} }
#[component]
pub fn App() -> impl IntoView {
provide_meta_context();
view! {
<>
<Link rel="shortcut icon" type_="image/ico" href="/favicon.ico"/>
<Stylesheet id="leptos" href="/pkg/ibis.css"/>
<Meta name="description" content="Leptos implementation of a HackerNews demo."/>
test
</>
}
}

View file

@ -1,6 +1,6 @@
use crate::database::edit::DbEdit; use crate::backend::database::edit::DbEdit;
use crate::database::version::EditVersion; use crate::backend::database::version::EditVersion;
use crate::error::MyResult; use crate::backend::error::MyResult;
use anyhow::anyhow; use anyhow::anyhow;
use diffy::{apply, Patch}; use diffy::{apply, Patch};
use rand::{distributions::Alphanumeric, thread_rng, Rng}; use rand::{distributions::Alphanumeric, thread_rng, Rng};

View file

@ -4,12 +4,6 @@ use log::info;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use url::Url; use url::Url;
pub fn main() {
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
mount_to_body(fetch_example)
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Cat { pub struct Cat {
url: String, url: String,
@ -71,10 +65,10 @@ pub fn fetch_example() -> impl IntoView {
// we use local_resource here because // we use local_resource here because
// 1) our error type isn't serializable/deserializable // 1) our error type isn't serializable/deserializable
// 2) we're not doing server-side rendering in this example anyway // 2) we're not doing backend-side rendering in this example anyway
// (during SSR, create_resource will begin loading on the server and resolve on the client) // (during SSR, create_resource will begin loading on the backend and resolve on the client)
let cats = create_local_resource(move || cat_count.get(), fetch_cats); let cats = create_local_resource(move || cat_count.get(), fetch_cats);
let instance = create_local_resource(move || "http://localhost:8131/api/v1/instance", fetch_instance); //let instance = create_local_resource(move || "http://localhost:8131/api/v1/instance", fetch_instance);
let fallback = move |errors: RwSignal<Errors>| { let fallback = move |errors: RwSignal<Errors>| {
let error_list = move || { let error_list = move || {
@ -106,14 +100,16 @@ pub fn fetch_example() -> impl IntoView {
}) })
}; };
/*
let instance_view = move || { let instance_view = move || {
instance.and_then(|data| { instance.and_then(|data| {
view! { <h1>{data.instance.ap_id.to_string()}</h1> } view! { <h1>{data.instance.ap_id.to_string()}</h1> }
}) })
}; };
*/
view! { view! {
{instance_view} //{instance_view}
<div> <div>
<label> <label>
"How many cats would you like?" "How many cats would you like?"

3
src/lib.rs Normal file
View file

@ -0,0 +1,3 @@
#[cfg(feature = "ssr")]
pub mod backend;
pub mod frontend;

View file

@ -1,3 +1,12 @@
pub fn main() { #[tokio::main]
unimplemented!(); pub async fn main() -> ibis::backend::error::MyResult<()> {
use log::LevelFilter;
env_logger::builder()
.filter_level(LevelFilter::Warn)
.filter_module("activitypub_federation", LevelFilter::Info)
.filter_module("ibis", LevelFilter::Info)
.init();
let database_url = "postgres://ibis:password@localhost:5432/ibis";
ibis::backend::start("localhost:8131", database_url).await?;
Ok(())
} }

View file

@ -119,7 +119,7 @@ impl IbisInstance {
let handle = tokio::task::spawn(async move { let handle = tokio::task::spawn(async move {
start(&hostname_, &db_url).await.unwrap(); start(&hostname_, &db_url).await.unwrap();
}); });
// wait a moment for the server to start // wait a moment for the backend to start
tokio::time::sleep(Duration::from_millis(100)).await; tokio::time::sleep(Duration::from_millis(100)).await;
let register_res = register(&hostname, username, "hunter2").await.unwrap(); let register_res = register(&hostname, username, "hunter2").await.unwrap();
assert!(!register_res.jwt.is_empty()); assert!(!register_res.jwt.is_empty());

View file

@ -4,10 +4,10 @@ set -e
export PGHOST=$1 export PGHOST=$1
export PGDATA="$1/dev_pgdata" export PGDATA="$1/dev_pgdata"
# If cluster exists, stop the server # If cluster exists, stop the backend
if [ -d $PGDATA ] if [ -d $PGDATA ]
then then
# Prevent `stop` from failing if server already stopped # Prevent `stop` from failing if backend already stopped
#pg_ctl restart > /dev/null #pg_ctl restart > /dev/null
pg_ctl stop pg_ctl stop
fi fi
@ -21,7 +21,7 @@ initdb --username=postgres --auth=trust --no-instructions
touch "$PGHOST/.s.PGSQL.5432" touch "$PGHOST/.s.PGSQL.5432"
echo "$PGHOST/.s.PGSQL.5432" echo "$PGHOST/.s.PGSQL.5432"
# Start server that only listens to socket in current directory # Start backend that only listens to socket in current directory
pg_ctl start --options="-c listen_addresses= -c unix_socket_directories=$PGHOST" pg_ctl start --options="-c listen_addresses= -c unix_socket_directories=$PGHOST"
# Setup database # Setup database