1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-22 13:31:08 +00:00

Rename to Ibis

This commit is contained in:
Felix Ableitner 2023-12-20 17:08:19 +01:00
parent c42556ed05
commit f2c9a76d75
8 changed files with 78 additions and 74 deletions

66
Cargo.lock generated
View file

@ -669,39 +669,6 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
[[package]]
name = "fediwiki"
version = "0.1.0"
dependencies = [
"activitypub_federation",
"anyhow",
"async-trait",
"axum",
"axum-macros",
"bcrypt",
"chrono",
"diesel",
"diesel-derive-newtype",
"diesel_migrations",
"diffy",
"enum_delegate",
"env_logger",
"futures",
"hex",
"jsonwebtoken",
"once_cell",
"pretty_assertions",
"rand",
"reqwest",
"serde",
"serde_json",
"sha2",
"tokio",
"tracing",
"url",
"uuid",
]
[[package]] [[package]]
name = "fnv" name = "fnv"
version = "1.0.7" version = "1.0.7"
@ -1083,6 +1050,39 @@ dependencies = [
"cc", "cc",
] ]
[[package]]
name = "ibis"
version = "0.1.0"
dependencies = [
"activitypub_federation",
"anyhow",
"async-trait",
"axum",
"axum-macros",
"bcrypt",
"chrono",
"diesel",
"diesel-derive-newtype",
"diesel_migrations",
"diffy",
"enum_delegate",
"env_logger",
"futures",
"hex",
"jsonwebtoken",
"once_cell",
"pretty_assertions",
"rand",
"reqwest",
"serde",
"serde_json",
"sha2",
"tokio",
"tracing",
"url",
"uuid",
]
[[package]] [[package]]
name = "ident_case" name = "ident_case"
version = "1.0.1" version = "1.0.1"

View file

@ -1,5 +1,5 @@
[package] [package]
name = "fediwiki" name = "ibis"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"

View file

@ -1,8 +1,12 @@
fediwiki Ibis - A federated Wikipedia Alternative
=== ===
A federated Wikipedia alternative. Main objects in terms of federation are the `Instance` and `Article`. Each article belongs to a single origin instance, the one where it was originally created. Articles have a collection of `Edit`s a custom ActivityPub type containing a diff. The text of any article can be built by starting from empty string and applying all associated edits in order. Instances can synchronize their articles with each other, and follow each other to receive updates about articles. Edits are done with diffs which are generated on the backend, and allow for conflict resolution similar to git. Editing also works over federation. In this case an activity `Update/Edit` is sent to the origin instance. If the diff applies cleanly, the origin instance sends the new text in an `Update/Article` activity to its followers. In case there is a conflict, a `Reject` activity is sent back, the editor needs to resolve and resubmit the edit. A federated Wikipedia alternative. Main objects in terms of federation are the `Instance` and `Article`. Each article belongs to a single origin instance, the one where it was originally created. Articles have a collection of `Edit`s a custom ActivityPub type containing a diff. The text of any article can be built by starting from empty string and applying all associated edits in order. Instances can synchronize their articles with each other, and follow each other to receive updates about articles. Edits are done with diffs which are generated on the backend, and allow for conflict resolution similar to git. Editing also works over federation. In this case an activity `Update/Edit` is sent to the origin instance. If the diff applies cleanly, the origin instance sends the new text in an `Update/Article` activity to its followers. In case there is a conflict, a `Reject` activity is sent back, the editor needs to resolve and resubmit the edit.
## Name
The Ibis is a [bird which is related to the Egyptian god of knowledge and science](https://en.wikipedia.org/wiki/African_sacred_ibis#In_myth_and_legend).
## License ## License
[AGPL](LICENSE) [AGPL](LICENSE)

View file

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

View file

@ -1,14 +1,14 @@
use anyhow::anyhow; use anyhow::anyhow;
use fediwiki::api::article::{CreateArticleData, EditArticleData, ForkArticleData, GetArticleData}; use ibis::api::article::{CreateArticleData, EditArticleData, ForkArticleData, GetArticleData};
use fediwiki::api::instance::FollowInstance; use ibis::api::instance::FollowInstance;
use fediwiki::api::user::RegisterUserData; use ibis::api::user::RegisterUserData;
use fediwiki::api::user::{LoginResponse, LoginUserData}; use ibis::api::user::{LoginResponse, LoginUserData};
use fediwiki::api::ResolveObject; use ibis::api::ResolveObject;
use fediwiki::database::article::ArticleView; use ibis::database::article::ArticleView;
use fediwiki::database::conflict::ApiConflict; use ibis::database::conflict::ApiConflict;
use fediwiki::database::instance::DbInstance; use ibis::database::instance::DbInstance;
use fediwiki::error::MyResult; use ibis::error::MyResult;
use fediwiki::start; use ibis::start;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use reqwest::{Client, RequestBuilder, StatusCode}; use reqwest::{Client, RequestBuilder, StatusCode};
use serde::de::Deserialize; use serde::de::Deserialize;
@ -27,9 +27,9 @@ use url::Url;
pub static CLIENT: Lazy<Client> = Lazy::new(Client::new); pub static CLIENT: Lazy<Client> = Lazy::new(Client::new);
pub struct TestData { pub struct TestData {
pub alpha: FediwikiInstance, pub alpha: IbisInstance,
pub beta: FediwikiInstance, pub beta: IbisInstance,
pub gamma: FediwikiInstance, pub gamma: IbisInstance,
} }
impl TestData { impl TestData {
@ -39,7 +39,7 @@ impl TestData {
env_logger::builder() env_logger::builder()
.filter_level(LevelFilter::Warn) .filter_level(LevelFilter::Warn)
.filter_module("activitypub_federation", LevelFilter::Info) .filter_module("activitypub_federation", LevelFilter::Info)
.filter_module("fediwiki", LevelFilter::Info) .filter_module("ibis", LevelFilter::Info)
.init(); .init();
}); });
@ -61,17 +61,17 @@ impl TestData {
// initialize postgres databases in parallel because its slow // initialize postgres databases in parallel because its slow
for j in [ for j in [
FediwikiInstance::prepare_db(alpha_db_path.clone()), IbisInstance::prepare_db(alpha_db_path.clone()),
FediwikiInstance::prepare_db(beta_db_path.clone()), IbisInstance::prepare_db(beta_db_path.clone()),
FediwikiInstance::prepare_db(gamma_db_path.clone()), IbisInstance::prepare_db(gamma_db_path.clone()),
] { ] {
j.join().unwrap(); j.join().unwrap();
} }
Self { Self {
alpha: FediwikiInstance::start(alpha_db_path, port_alpha, "alpha").await, alpha: IbisInstance::start(alpha_db_path, port_alpha, "alpha").await,
beta: FediwikiInstance::start(beta_db_path, port_beta, "beta").await, beta: IbisInstance::start(beta_db_path, port_beta, "beta").await,
gamma: FediwikiInstance::start(gamma_db_path, port_gamma, "gamma").await, gamma: IbisInstance::start(gamma_db_path, port_gamma, "gamma").await,
} }
} }
@ -93,14 +93,14 @@ fn generate_db_path(name: &'static str, port: i32) -> String {
path path
} }
pub struct FediwikiInstance { pub struct IbisInstance {
pub hostname: String, pub hostname: String,
pub jwt: String, pub jwt: String,
db_path: String, db_path: String,
db_handle: JoinHandle<()>, db_handle: JoinHandle<()>,
} }
impl FediwikiInstance { impl IbisInstance {
fn prepare_db(db_path: String) -> std::thread::JoinHandle<()> { fn prepare_db(db_path: String) -> std::thread::JoinHandle<()> {
spawn(move || { spawn(move || {
Command::new("./tests/scripts/start_dev_db.sh") Command::new("./tests/scripts/start_dev_db.sh")
@ -146,7 +146,7 @@ impl FediwikiInstance {
pub const TEST_ARTICLE_DEFAULT_TEXT: &str = "some\nexample\ntext\n"; pub const TEST_ARTICLE_DEFAULT_TEXT: &str = "some\nexample\ntext\n";
pub async fn create_article(instance: &FediwikiInstance, title: String) -> MyResult<ArticleView> { pub async fn create_article(instance: &IbisInstance, title: String) -> MyResult<ArticleView> {
let create_form = CreateArticleData { let create_form = CreateArticleData {
title: title.clone(), title: title.clone(),
}; };
@ -172,7 +172,7 @@ pub async fn get_article(hostname: &str, article_id: i32) -> MyResult<ArticleVie
} }
pub async fn edit_article_with_conflict( pub async fn edit_article_with_conflict(
instance: &FediwikiInstance, instance: &IbisInstance,
edit_form: &EditArticleData, edit_form: &EditArticleData,
) -> MyResult<Option<ApiConflict>> { ) -> MyResult<Option<ApiConflict>> {
let req = CLIENT let req = CLIENT
@ -182,7 +182,7 @@ pub async fn edit_article_with_conflict(
handle_json_res(req).await handle_json_res(req).await
} }
pub async fn get_conflicts(instance: &FediwikiInstance) -> MyResult<Vec<ApiConflict>> { pub async fn get_conflicts(instance: &IbisInstance) -> MyResult<Vec<ApiConflict>> {
let req = CLIENT let req = CLIENT
.get(format!( .get(format!(
"http://{}/api/v1/edit_conflicts", "http://{}/api/v1/edit_conflicts",
@ -193,7 +193,7 @@ pub async fn get_conflicts(instance: &FediwikiInstance) -> MyResult<Vec<ApiConfl
} }
pub async fn edit_article( pub async fn edit_article(
instance: &FediwikiInstance, instance: &IbisInstance,
edit_form: &EditArticleData, edit_form: &EditArticleData,
) -> MyResult<ArticleView> { ) -> MyResult<ArticleView> {
let edit_res = edit_article_with_conflict(instance, edit_form).await?; let edit_res = edit_article_with_conflict(instance, edit_form).await?;
@ -221,7 +221,7 @@ where
} }
pub async fn fork_article( pub async fn fork_article(
instance: &FediwikiInstance, instance: &IbisInstance,
form: &ForkArticleData, form: &ForkArticleData,
) -> MyResult<ArticleView> { ) -> MyResult<ArticleView> {
let req = CLIENT let req = CLIENT
@ -245,7 +245,7 @@ where
} }
} }
pub async fn follow_instance(instance: &FediwikiInstance, follow_instance: &str) -> MyResult<()> { pub async fn follow_instance(instance: &IbisInstance, follow_instance: &str) -> MyResult<()> {
// fetch beta instance on alpha // fetch beta instance on alpha
let resolve_form = ResolveObject { let resolve_form = ResolveObject {
id: Url::parse(&format!("http://{}", follow_instance))?, id: Url::parse(&format!("http://{}", follow_instance))?,
@ -286,7 +286,7 @@ pub async fn register(hostname: &str, username: &str, password: &str) -> MyResul
} }
pub async fn login( pub async fn login(
instance: &FediwikiInstance, instance: &IbisInstance,
username: &str, username: &str,
password: &str, password: &str,
) -> MyResult<LoginResponse> { ) -> MyResult<LoginResponse> {

View file

@ -1,4 +1,4 @@
extern crate fediwiki; extern crate ibis;
mod common; mod common;
@ -9,11 +9,11 @@ use crate::common::{
use crate::common::{fork_article, handle_json_res, login}; use crate::common::{fork_article, handle_json_res, login};
use crate::common::{get_conflicts, register}; use crate::common::{get_conflicts, register};
use common::get; use common::get;
use fediwiki::api::article::{CreateArticleData, EditArticleData, ForkArticleData}; use ibis::api::article::{CreateArticleData, EditArticleData, ForkArticleData};
use fediwiki::api::{ResolveObject, SearchArticleData}; use ibis::api::{ResolveObject, SearchArticleData};
use fediwiki::database::article::{ArticleView, DbArticle}; use ibis::database::article::{ArticleView, DbArticle};
use fediwiki::database::instance::{DbInstance, InstanceView}; use ibis::database::instance::{DbInstance, InstanceView};
use fediwiki::error::MyResult; use ibis::error::MyResult;
use pretty_assertions::{assert_eq, assert_ne}; use pretty_assertions::{assert_eq, assert_ne};
use url::Url; use url::Url;