start webmention code
This commit is contained in:
parent
9b76fdb03b
commit
a2a82eba8e
File diff suppressed because it is too large
Load Diff
|
@ -11,6 +11,8 @@ build = "src/build.rs"
|
|||
chrono = "0.4"
|
||||
color-eyre = "0.5.2"
|
||||
diesel = { version = "1.4.4", features = ["sqlite"] }
|
||||
egg-mode = "0.15.0"
|
||||
elefren = "0.22"
|
||||
hyper = "0.13"
|
||||
kankyo = "0.3"
|
||||
log = "0.4"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
PRAGMA foreign_keys = ON;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS members
|
||||
( id INT PRIMARY KEY
|
||||
( id INT UNIQUE NOT NULL PRIMARY KEY
|
||||
, cmene TEXT UNIQUE NOT NULL
|
||||
, picurl TEXT UNIQUE NOT NULL
|
||||
);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
DROP TABLE webmentions;
|
|
@ -0,0 +1,5 @@
|
|||
CREATE TABLE IF NOT EXISTS webmentions
|
||||
( id TEXT UNIQUE NOT NULL PRIMARY KEY
|
||||
, source_url TEXT NOT NULL
|
||||
, target_url TEXT NOT NULL
|
||||
);
|
|
@ -2,7 +2,9 @@ let
|
|||
sources = import ./nix/sources.nix;
|
||||
pkgs =
|
||||
import sources.nixpkgs { overlays = [ (import sources.nixpkgs-mozilla) ]; };
|
||||
ruststable = (pkgs.latest.rustChannels.stable.rust.override { extensions = [ "rust-src" "rls-preview" "rust-analysis" "rustfmt-preview" ];});
|
||||
ruststable = (pkgs.latest.rustChannels.stable.rust.override {
|
||||
extensions = [ "rust-src" "rls-preview" "rust-analysis" "rustfmt-preview" ];
|
||||
});
|
||||
|
||||
in pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
|
@ -19,6 +21,6 @@ in pkgs.mkShell {
|
|||
bashInteractive
|
||||
];
|
||||
|
||||
RUST_LOG="info";
|
||||
DATABASE_URL = "./mi.db";
|
||||
RUST_LOG = "info";
|
||||
}
|
||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -11,8 +11,8 @@ use warp::Filter;
|
|||
const APPLICATION_NAME: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
|
||||
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
|
||||
|
||||
pub mod schema;
|
||||
pub mod models;
|
||||
pub mod schema;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
|
@ -20,11 +20,14 @@ async fn main() -> Result<()> {
|
|||
pretty_env_logger::init();
|
||||
color_eyre::install()?;
|
||||
|
||||
log::info!("starting up {} commit {}", APPLICATION_NAME, env!("GITHUB_SHA"));
|
||||
log::info!(
|
||||
"starting up {} commit {}",
|
||||
APPLICATION_NAME,
|
||||
env!("GITHUB_SHA")
|
||||
);
|
||||
|
||||
let database_url = std::env::var("DATABASE_URL")
|
||||
.expect("DATABASE_URL must be set");
|
||||
SqliteConnection::establish(&database_url)
|
||||
let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
|
||||
let connection = SqliteConnection::establish(&database_url)
|
||||
.expect(&format!("Error connecting to {}", database_url));
|
||||
|
||||
let healthcheck = warp::get().and(warp::path(".within").and(warp::path("health")).map(|| "OK"));
|
||||
|
@ -49,3 +52,11 @@ async fn main() -> Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_members(connection: &SqliteConnection) -> Result<Vec<models::Member>> {
|
||||
use schema::members;
|
||||
let results = members::table
|
||||
.load::<models::Member>(connection)?;
|
||||
|
||||
Ok(results)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#[derive(Queryable)]
|
||||
#[derive(Queryable, Debug)]
|
||||
pub struct Member {
|
||||
pub id: i32,
|
||||
pub cmene: String,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
table! {
|
||||
members (id) {
|
||||
id -> Nullable<Integer>,
|
||||
id -> Integer,
|
||||
cmene -> Text,
|
||||
picurl -> Text,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue