diff --git a/.gitignore b/.gitignore index 30b3294..0f3156d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,23 @@ # Node.js **/node_modules **/package-lock.json +**/.DS_Store +**/dist + +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw* diff --git a/planner/src/bin/weekly.rs b/planner/src/bin/weekly.rs index 9282959..ead7ef2 100644 --- a/planner/src/bin/weekly.rs +++ b/planner/src/bin/weekly.rs @@ -11,16 +11,31 @@ use self::planner::solver::{Variables, Domain, Problem}; /// Breakfast => RecipeCategory::Breakfast /// Lunch => RecipeCategory::MainCourse /// Dinner => RecipeCategory::MainCourse -type Day = String; -const DAYS: &[&str] = &["Lundi", "Mardi", "Mercredi"]; -#[allow(dead_code)] -enum Meals { - Breakfast(Day), - Lunch(Day), - Dinner(Day) +mod template { + //! Exports the [`Template`] struct. + + type Day = String; + const DAYS: &[&str] = &["Lundi", "Mardi", "Mercredi"]; + + #[allow(dead_code)] + enum Meals { + Breakfast(Day), + Lunch(Day), + Dinner(Day) + } + + pub struct Template; + + impl Template { + fn empty() { + + } + } } + + impl Into for Meals { fn into(self) -> String { match self { diff --git a/planner/src/solver.rs b/planner/src/solver.rs index 5cd8319..2e1e557 100644 --- a/planner/src/solver.rs +++ b/planner/src/solver.rs @@ -18,7 +18,7 @@ type Domains<'a, V> = HashMap>; /// The domain of values that can be assigned to variables #[derive(Clone)] pub struct Domain { - pub values: Vec + values: Vec } impl Domain { @@ -26,6 +26,9 @@ impl Domain { Domain { values } } + pub fn values(&self) -> &Vec { + &self.values + } /// Returns a new domain with the given filter applied to inner values /// /// # Examples diff --git a/web/Cargo.toml b/web/Cargo.toml index 0c073d9..50e444a 100644 --- a/web/Cargo.toml +++ b/web/Cargo.toml @@ -6,6 +6,7 @@ edition = "2018" [dependencies] rocket = "0.4.0" +rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", branch = "master" } cookbook = { path = "../cookbook/" } serde = "1.0" serde_derive = "1.0" diff --git a/web/src/main.rs b/web/src/main.rs index 87b9972..eeb1131 100644 --- a/web/src/main.rs +++ b/web/src/main.rs @@ -3,11 +3,15 @@ #[macro_use] extern crate rocket; #[macro_use] extern crate rocket_contrib; #[macro_use] extern crate serde_derive; - +extern crate rocket_cors; extern crate cookbook; use std::path::Path; -use rocket::response::{NamedFile, status::NotFound}; +use rocket::{ + response::{NamedFile, status::NotFound}, + http::Method, +}; +use rocket_cors::{AllowedHeaders, AllowedOrigins, Error}; #[get("/")] fn index() -> Result> { @@ -66,9 +70,25 @@ mod api { } } -fn main() { +fn main() -> Result<(), Error> { + let (allowed_origins, failed_origins) = AllowedOrigins::some(&["http://localhost:8080"]); + assert!(failed_origins.is_empty()); + + // You can also deserialize this + let cors = rocket_cors::CorsOptions { + allowed_origins: allowed_origins, + allowed_methods: vec![Method::Get].into_iter().map(From::from).collect(), + allowed_headers: AllowedHeaders::some(&["Authorization", "Accept"]), + allow_credentials: true, + ..Default::default() + } + .to_cors()?; + rocket::ignite() .attach(api::CookbookDbConn::fairing()) .mount("/", routes![index]) - .mount("/api", routes![api::recipes_list, api::delete_recipe]).launch(); + .mount("/api", routes![api::recipes_list, api::delete_recipe]) + .attach(cors) + .launch(); + Ok(()) } diff --git a/web/vue/README.md b/web/vue/README.md new file mode 100644 index 0000000..6083444 --- /dev/null +++ b/web/vue/README.md @@ -0,0 +1,29 @@ +# vue + +## Project setup +``` +npm install +``` + +### Compiles and hot-reloads for development +``` +npm run serve +``` + +### Compiles and minifies for production +``` +npm run build +``` + +### Run your tests +``` +npm run test +``` + +### Lints and fixes files +``` +npm run lint +``` + +### Customize configuration +See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/web/vue/babel.config.js b/web/vue/babel.config.js new file mode 100644 index 0000000..ba17966 --- /dev/null +++ b/web/vue/babel.config.js @@ -0,0 +1,5 @@ +module.exports = { + presets: [ + '@vue/app' + ] +} diff --git a/web/vue/package.json b/web/vue/package.json new file mode 100644 index 0000000..c3de63a --- /dev/null +++ b/web/vue/package.json @@ -0,0 +1,46 @@ +{ + "name": "vue", + "version": "0.1.0", + "private": true, + "scripts": { + "serve": "vue-cli-service serve", + "build": "vue-cli-service build", + "lint": "vue-cli-service lint" + }, + "dependencies": { + "vue": "^2.5.22" + }, + "devDependencies": { + "@vue/cli-plugin-babel": "^3.4.0", + "@vue/cli-plugin-eslint": "^3.4.0", + "@vue/cli-service": "^3.4.0", + "babel-eslint": "^10.0.1", + "eslint": "^5.8.0", + "eslint-plugin-vue": "^5.0.0", + "vue-template-compiler": "^2.5.21" + }, + "eslintConfig": { + "root": true, + "env": { + "node": true + }, + "extends": [ + "plugin:vue/essential", + "eslint:recommended" + ], + "rules": {}, + "parserOptions": { + "parser": "babel-eslint" + } + }, + "postcss": { + "plugins": { + "autoprefixer": {} + } + }, + "browserslist": [ + "> 1%", + "last 2 versions", + "not ie <= 8" + ] +} diff --git a/web/vue/public/favicon.ico b/web/vue/public/favicon.ico new file mode 100644 index 0000000..c7b9a43 Binary files /dev/null and b/web/vue/public/favicon.ico differ diff --git a/web/vue/public/index.html b/web/vue/public/index.html new file mode 100644 index 0000000..eac2e22 --- /dev/null +++ b/web/vue/public/index.html @@ -0,0 +1,17 @@ + + + + + + + + vue + + + +
+ + + diff --git a/web/vue/src/App.vue b/web/vue/src/App.vue new file mode 100644 index 0000000..6a05259 --- /dev/null +++ b/web/vue/src/App.vue @@ -0,0 +1,78 @@ + + + + + diff --git a/web/vue/src/assets/logo.png b/web/vue/src/assets/logo.png new file mode 100644 index 0000000..f3d2503 Binary files /dev/null and b/web/vue/src/assets/logo.png differ diff --git a/web/vue/src/components/HelloWorld.vue b/web/vue/src/components/HelloWorld.vue new file mode 100644 index 0000000..d285cb6 --- /dev/null +++ b/web/vue/src/components/HelloWorld.vue @@ -0,0 +1,37 @@ + + + + + + diff --git a/web/vue/src/components/RecipeDetails.vue b/web/vue/src/components/RecipeDetails.vue new file mode 100644 index 0000000..450b87d --- /dev/null +++ b/web/vue/src/components/RecipeDetails.vue @@ -0,0 +1,22 @@ + + +