Skip to content

Commit

Permalink
Nicholasguyett/stable migration (#265)
Browse files Browse the repository at this point in the history
* aa

* Remove nightly toolchain annotation

* aardwolf-models: Add missing getters for updated_at/created_at/confirmed_at

* aardwolf-models: Add more missing getters

* Replace deprecated table_name attribute

* Upgrade disel and uuid

* Replace deprecated sql_type attribute

* Update connection and transaction handling code to match new diesel interface

* Reconcile diesel serialization/deserialization changes

* Update uuid in aardwolf-models

* Update test and examples to compile using updated version of diesel

* aardwolf-types: Use latest stable futures instead of preview

* aardwolf-types: Update to latest diesel and update usage of test utility functions

* Upgrade ruct and gettext.  Fixed compiler errors in src/*.rs files

* Update and/or reconcile templates and associated structs to compiler without error

* aardwolf-templates: Move compile_i18n! above include_i18n! in the file

* Add explainer comment for the ordering of gettext macros

* Initialize nav_top in Home constructor instead of requiring external initialization

* aardwolf-actix: Update actix and diesel dependencies

* aardwold-actix: replace deprecated use of `header()` on `HttpResponse`

* aardwolf-actix: Update server setup

* aardwolf-actix: update route function declarations and input handling

* aardwolf-actix: update cookie setting logic

* aardwolf-actix: update import of HttpResponseBuilder

* aardwolf-actix - Update FromRequest implementations

* Applying `cargo fix` suggestion.

* Remove nightly-only dependencies and made sure all shared dependencies are in-sync

---------

Co-authored-by: Banjo Fox <drbanjofox@protonmail.com>
Co-authored-by: Banjo Fox <4459812+BanjoFox@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 23, 2023
1 parent 9034a7b commit 0077fba
Show file tree
Hide file tree
Showing 99 changed files with 2,677 additions and 4,240 deletions.
3,816 changes: 1,184 additions & 2,632 deletions Cargo.lock

Large diffs are not rendered by default.

82 changes: 41 additions & 41 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
[package]
name = "aardwolf"
version = "0.1.0"
authors = ["Eric Chadbourne <sillystring@protonmail.com>", "Elijah Mark Anderson <kd0bpv@gmail.com>", "Paul Woolcock <paul@woolcock.us>", "asonix <asonix@asonix.dog>"]
description = "Powering connected social communities with free software."
edition = "2018"

[workspace]
members = [
"aardwolf-actix",
"aardwolf-models",
"aardwolf-templates",
"aardwolf-test-helpers",
"aardwolf-types",
]

[features]
default = ["simple-logging", "actix"]
actix = ["aardwolf-actix"]

[dependencies]
config = "~0.9.3"
failure = "~0.1.8"
log = "~0.4.14"
yaml-rust = "~0.4.5"
# Use simple log files or stdout/stderr. Conflicts with use-systemd and
# log-* features.
simple-logging = { version = "~2.0", optional = true }
# Use syslog for writing logs. Conflicts with use-systemd and log-* features.
syslog = { version = "~5.0", optional = true }
# Integrate with Systemd, includes Journald for logging. Conflicts with log-*
# features.
systemd = { version = "~0.8.2", optional = true }

[dependencies.aardwolf-actix]
version = "0.1"
path = "aardwolf-actix"
optional = true

[dependencies.clap]
version = "~2.33"
[package]
name = "aardwolf"
version = "0.1.0"
authors = ["Eric Chadbourne <sillystring@protonmail.com>", "Elijah Mark Anderson <kd0bpv@gmail.com>", "Paul Woolcock <paul@woolcock.us>", "asonix <asonix@asonix.dog>"]
description = "Powering connected social communities with free software."
edition = "2018"

[workspace]
members = [
"aardwolf-actix",
"aardwolf-models",
"aardwolf-templates",
"aardwolf-test-helpers",
"aardwolf-types",
]

[features]
default = ["simple-logging", "actix"]
actix = ["aardwolf-actix"]

[dependencies]
config = "0.9"
failure = "0.1"
log = "0.4"
yaml-rust = "~0.4.5"
# Use simple log files or stdout/stderr. Conflicts with use-systemd and
# log-* features.
simple-logging = { version = "~2.0", optional = true }
# Use syslog for writing logs. Conflicts with use-systemd and log-* features.
syslog = { version = "~5.0", optional = true }
# Integrate with Systemd, includes Journald for logging. Conflicts with log-*
# features.
systemd = { version = "~0.8.2", optional = true }

[dependencies.aardwolf-actix]
version = "0.1"
path = "aardwolf-actix"
optional = true

[dependencies.clap]
version = "~2.33"
features = ["yaml"]
32 changes: 15 additions & 17 deletions aardwolf-actix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,18 @@ authors = ["asonix <asonix@asonix.dog>"]
edition = "2018"

[dependencies]
actix = "0.8.1"
actix-files = "0.1"
actix-http = "2.2"
actix-session = "0.2"
actix-web = "1.0"
actix-web-async-compat = "0.1.0"
config = "0.9.0"
failure = "~0.1"
futures-old = { version = "0.1", package = "futures" }
futures-preview = { version = "0.3.0-alpha.18", features = ["compat", "nightly", "async-await"] }
actix = "0.12"
actix-files = "0.6"
actix-http = "3.3"
actix-web = "4.3"
config = "0.9"
failure = "0.1"
log = "0.4"
r2d2 = "0.8"
r2d2-diesel = "1.0"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
uuid = "0.6"
uuid = "1.3"

[dependencies.aardwolf-models]
version = "0.1"
Expand All @@ -35,12 +30,15 @@ path = "../aardwolf-templates"
version = "0.1"
path = "../aardwolf-types"

[dependencies.actix-session]
version = "0.7"
features = ["cookie-session"]

[dependencies.diesel]
version = "1.4"
version = "2.1"
default-features = false
features = ["postgres", "uuid", "chrono"]

[dependencies.rocket_i18n]
version = "0.4"
git = "https://github.com/Plume-org/rocket_i18n"
rev = "3eca920593b41d3232aec702733f5c91da8ec808"
[dependencies.futures]
version = "0.3"
features = ["compat"]
4 changes: 3 additions & 1 deletion aardwolf-actix/src/action.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use actix_web::{http::header::LOCATION, HttpResponse};

pub fn redirect(to: &str) -> HttpResponse {
HttpResponse::SeeOther().header(LOCATION, to).finish()
HttpResponse::SeeOther()
.append_header((LOCATION, to))
.finish()
}
2 changes: 1 addition & 1 deletion aardwolf-actix/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ pub fn redirect_error(to: &str, msg: Option<String>) -> HttpResponse {
let location = format!("{}{}", to, msg);

HttpResponse::SeeOther()
.header(LOCATION, location.as_str())
.append_header((LOCATION, location.as_str()))
.finish()
}
58 changes: 27 additions & 31 deletions aardwolf-actix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ use std::{error::Error, fmt};
use aardwolf_models::{base_actor::BaseActor, generate_urls::GenerateUrls, sql_types::Url};
use actix::System;
use actix_files::Files;
use actix_session::CookieSession;
use actix_session::{storage::CookieSessionStore, SessionMiddleware};
use actix_web::{
cookie::Key,
middleware::Logger,
web::{get, post, resource, scope},
web::{get, post, resource, scope, Data},
App, HttpServer,
};
use actix_web_async_compat::async_compat;
use config::Config;
use diesel::r2d2::ConnectionManager;
use diesel::PgConnection;
use r2d2::Pool;
use r2d2_diesel::ConnectionManager;
use uuid::Uuid;

mod action;
Expand Down Expand Up @@ -155,7 +155,7 @@ mod assets {
}

pub fn run(config: &Config, database_url: &str) -> Result<(), Box<dyn Error>> {
let sys = System::new("aardwolf-actix");
let sys = System::new();

let pool = db_pool(database_url)?;

Expand All @@ -170,6 +170,9 @@ pub fn run(config: &Config, database_url: &str) -> Result<(), Box<dyn Error>> {
https: config.get_bool("Instance.https")?,
};

// TODO: Allow key to be loaded from config file
let secret_key = Key::generate();

#[cfg(debug_assertions)]
let assets = assets::Assets::from_config(&config)?;

Expand All @@ -182,57 +185,50 @@ pub fn run(config: &Config, database_url: &str) -> Result<(), Box<dyn Error>> {
let translations = aardwolf_templates::managed_state();

App::new()
.data(state.clone())
.data(translations)
.app_data(Data::new(state))
.app_data(Data::new(translations))
.wrap(Logger::default())
.wrap(CookieSession::signed(&[0; 32]).secure(false))
.wrap(SessionMiddleware::new(
CookieSessionStore::default(),
secret_key.clone(),
))
.service(
scope("/auth")
.service(
resource("/sign_up")
.route(get().to_async(self::routes::auth::sign_up_form))
.route(post().to_async(async_compat(self::routes::auth::sign_up))),
.route(get().to(self::routes::auth::sign_up_form))
.route(post().to(self::routes::auth::sign_up)),
)
.service(
resource("/sign_in")
.route(get().to_async(self::routes::auth::sign_in_form))
.route(post().to_async(async_compat(self::routes::auth::sign_in))),
.route(get().to(self::routes::auth::sign_in_form))
.route(post().to(self::routes::auth::sign_in)),
)
.service(
resource("/confirmation")
.route(get().to_async(async_compat(self::routes::auth::confirm))),
)
.service(
resource("/sign_out").route(get().to_async(self::routes::auth::sign_out)),
),
.service(resource("/confirmation").route(get().to(self::routes::auth::confirm)))
.service(resource("/sign_out").route(get().to(self::routes::auth::sign_out))),
)
.service(
scope("/posts").service(
resource("/create")
.route(post().to_async(async_compat(self::routes::posts::create))),
),
scope("/posts")
.service(resource("/create").route(post().to(self::routes::posts::create))),
)
.service(
scope("/personas")
.service(
resource("/create")
.route(get().to_async(self::routes::personas::new))
.route(post().to_async(async_compat(self::routes::personas::create))),
.route(get().to(self::routes::personas::new))
.route(post().to(self::routes::personas::create)),
)
.service(
resource("/delete")
.route(get().to_async(async_compat(self::routes::personas::delete))),
),
.service(resource("/delete").route(get().to(self::routes::personas::delete))),
)
.service(resource("/").route(get().to_async(self::routes::app::index)))
.service(resource("/").route(get().to(self::routes::app::index)))
.service(Files::new("/web", assets.web()))
.service(Files::new("/images", assets.images()))
.service(Files::new("/themes", assets.themes()))
.service(Files::new("/emoji", assets.emoji()))
.service(Files::new("/stylesheets", assets.stylesheets()))
})
.bind(&listen_address)?
.start();
.run();

sys.run()?;

Expand Down
8 changes: 5 additions & 3 deletions aardwolf-actix/src/routes/app.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use aardwolf_templates::Home;
use aardwolf_templates::home::Home;
use aardwolf_types::forms::posts::PostCreationFormState;
use actix_web::{web::Data, HttpResponse};
use rocket_i18n::I18n;
use actix_web::HttpResponse;

use crate::{
traits::RenderableExt,
types::{actor::CurrentActor, user::SignedInUser},
};

pub(crate) fn index((_user, actor, i18n): (SignedInUser, CurrentActor, I18n)) -> HttpResponse {
pub(crate) async fn index(
(_user, actor, i18n): (SignedInUser, CurrentActor, Data<I18n>),
) -> HttpResponse {
Home::new(
&i18n.catalog,
&actor.1.shortname(),
Expand Down
Loading

0 comments on commit 0077fba

Please sign in to comment.