#![feature(plugin)]
#![plugin(rocket_codegen)]

extern crate comrak;
extern crate glob;
extern crate inflector;
extern crate rocket;
extern crate rocket_contrib;
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate serde_json;

mod handlers;
mod models;

use rocket::Rocket;
use std::sync::RwLock;

type ListStore = RwLock<Vec<models::list::List>>;

fn rocket(lists_path: Option<&str>) -> Rocket {
    let lists = models::list::List::load_all(lists_path);
    rocket::ignite()
        .manage(RwLock::new(lists))
        .mount("/", routes![handlers::home::index,
            handlers::static_files::all])
        .mount("/lists", routes![handlers::list::index,
            handlers::list::show_html, handlers::list::show_json,
            handlers::list::update])
        .attach(rocket_contrib::Template::fairing())
}

fn main() {
    rocket(None).launch();
}
