wip
This commit is contained in:
parent
1b0c7c7863
commit
f6b6972ee5
6 changed files with 64 additions and 5 deletions
42
Cargo.lock
generated
42
Cargo.lock
generated
|
@ -55,6 +55,12 @@ version = "3.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
|
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bytecount"
|
||||||
|
version = "0.6.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.4.3"
|
version = "1.4.3"
|
||||||
|
@ -77,6 +83,7 @@ dependencies = [
|
||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"scraper",
|
"scraper",
|
||||||
|
"tabled",
|
||||||
"tokio",
|
"tokio",
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
@ -766,6 +773,17 @@ version = "6.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
|
checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "papergrid"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "453cf71f2a37af495a1a124bf30d4d7469cfbea58e9f2479be9d222396a518a2"
|
||||||
|
dependencies = [
|
||||||
|
"bytecount",
|
||||||
|
"fnv",
|
||||||
|
"unicode-width",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking_lot"
|
name = "parking_lot"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
|
@ -1342,6 +1360,30 @@ dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tabled"
|
||||||
|
version = "0.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e5b2f8c37d26d87d2252187b0a45ea3cbf42baca10377c7e7eaaa2800fa9bf97"
|
||||||
|
dependencies = [
|
||||||
|
"papergrid",
|
||||||
|
"tabled_derive",
|
||||||
|
"unicode-width",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tabled_derive"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f9ee618502f497abf593e1c5c9577f34775b111480009ffccd7ad70d23fcaba8"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro-error",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempfile"
|
name = "tempfile"
|
||||||
version = "3.3.0"
|
version = "3.3.0"
|
||||||
|
|
|
@ -18,3 +18,4 @@ chrono = ">=0.4.20"
|
||||||
ics = "0.5"
|
ics = "0.5"
|
||||||
uuid = { version = "1.1", features = ["v4", "fast-rng"] }
|
uuid = { version = "1.1", features = ["v4", "fast-rng"] }
|
||||||
clap = { version = "3.2", features = ["derive"] }
|
clap = { version = "3.2", features = ["derive"] }
|
||||||
|
tabled = "0.8"
|
||||||
|
|
|
@ -61,6 +61,6 @@ async fn main() {
|
||||||
} else {
|
} else {
|
||||||
// Show the calendar
|
// Show the calendar
|
||||||
println!("Displaying...");
|
println!("Displaying...");
|
||||||
timetable::display();
|
timetable::display(timetable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use chrono::{Datelike, Duration, TimeZone, Utc};
|
use chrono::{Datelike, Duration, TimeZone, Utc};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use scraper::{Html, Selector};
|
use scraper::{Html, Selector};
|
||||||
|
|
||||||
pub mod models;
|
pub mod models;
|
||||||
|
|
||||||
/// Fetch the timetable for a class
|
/// Fetch the timetable for a class
|
||||||
|
@ -322,6 +321,6 @@ fn get_semester(semester: Option<i8>, letter: Option<char>) -> i8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Display the timetable
|
/// Display the timetable
|
||||||
pub fn display() {
|
pub fn display(timetable: (Vec<String>, (usize, Vec<models::Day>))) {
|
||||||
todo!("WIP")
|
println!("{:#?}", timetable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
#[derive(Clone)]
|
use tabled::Tabled;
|
||||||
|
|
||||||
|
#[derive(Tabled, Clone, Debug)]
|
||||||
|
#[tabled(rename_all = "CamelCase")]
|
||||||
pub struct Course {
|
pub struct Course {
|
||||||
/// Course's name
|
/// Course's name
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
||||||
/// Professor's name
|
/// Professor's name
|
||||||
|
#[tabled(display_with = "crate::utils::display_option")]
|
||||||
pub professor: Option<String>,
|
pub professor: Option<String>,
|
||||||
|
|
||||||
/// List of rooms where the course takes place
|
/// List of rooms where the course takes place
|
||||||
|
@ -13,20 +17,25 @@ pub struct Course {
|
||||||
/// - 0 => first possible class of the day
|
/// - 0 => first possible class of the day
|
||||||
/// - 1 => second possible class of the day
|
/// - 1 => second possible class of the day
|
||||||
/// - etc.
|
/// - etc.
|
||||||
|
#[tabled(skip)]
|
||||||
pub start: usize,
|
pub start: usize,
|
||||||
|
|
||||||
/// Number of time slots the course takes up in the timetable
|
/// Number of time slots the course takes up in the timetable
|
||||||
|
#[tabled(skip)]
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
|
|
||||||
/// Datetime when the course start
|
/// Datetime when the course start
|
||||||
/// Filled only when building for the ICS
|
/// Filled only when building for the ICS
|
||||||
|
#[tabled(skip)]
|
||||||
pub dtstart: Option<chrono::DateTime<chrono::Utc>>,
|
pub dtstart: Option<chrono::DateTime<chrono::Utc>>,
|
||||||
|
|
||||||
/// Datetime when the course end
|
/// Datetime when the course end
|
||||||
/// Filled only when building for the ICS
|
/// Filled only when building for the ICS
|
||||||
|
#[tabled(skip)]
|
||||||
pub dtend: Option<chrono::DateTime<chrono::Utc>>,
|
pub dtend: Option<chrono::DateTime<chrono::Utc>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Day {
|
pub struct Day {
|
||||||
/// Day's name
|
/// Day's name
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
|
@ -13,3 +13,11 @@ pub fn check_errors(html: &String, loc: &str) {
|
||||||
fn err_code(code: i32) -> String {
|
fn err_code(code: i32) -> String {
|
||||||
format!("HTTP Code : {}", code)
|
format!("HTTP Code : {}", code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the string if exists, otherwise return empty string
|
||||||
|
pub fn display_option(o: &Option<String>) -> String {
|
||||||
|
match o {
|
||||||
|
Some(s) => s.to_string(),
|
||||||
|
None => String::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in a new issue