Replace personal desktop with dashboard downloader

ILIAS 7 update, see #27
This commit is contained in:
FliegendeWurst 2022-01-06 15:37:57 +01:00
parent d919643dfa
commit 6dd16deb40
2 changed files with 15 additions and 9 deletions

View File

@ -26,6 +26,7 @@ pub mod weblink;
static LINKS: Lazy<Selector> = Lazy::new(|| Selector::parse("a").unwrap()); static LINKS: Lazy<Selector> = Lazy::new(|| Selector::parse("a").unwrap());
static ALERT_DANGER: Lazy<Selector> = Lazy::new(|| Selector::parse("div.alert-danger").unwrap()); static ALERT_DANGER: Lazy<Selector> = Lazy::new(|| Selector::parse("div.alert-danger").unwrap());
static IL_CONTENT_CONTAINER: Lazy<Selector> = Lazy::new(|| Selector::parse("#il_center_col").unwrap()); static IL_CONTENT_CONTAINER: Lazy<Selector> = Lazy::new(|| Selector::parse("#il_center_col").unwrap());
static BLOCK_FAVORITES: Lazy<Selector> = Lazy::new(|| Selector::parse("#block_pditems_0").unwrap());
static ITEM_PROP: Lazy<Selector> = Lazy::new(|| Selector::parse("span.il_ItemProperty").unwrap()); static ITEM_PROP: Lazy<Selector> = Lazy::new(|| Selector::parse("span.il_ItemProperty").unwrap());
static CONTAINER_ITEMS: Lazy<Selector> = Lazy::new(|| Selector::parse("div.il_ContainerListItem").unwrap()); static CONTAINER_ITEMS: Lazy<Selector> = Lazy::new(|| Selector::parse("div.il_ContainerListItem").unwrap());
static CONTAINER_ITEM_TITLE: Lazy<Selector> = Lazy::new(|| Selector::parse("a.il_ContainerItemTitle").unwrap()); static CONTAINER_ITEM_TITLE: Lazy<Selector> = Lazy::new(|| Selector::parse("a.il_ContainerItemTitle").unwrap());
@ -265,7 +266,12 @@ impl ILIAS {
let html = self.get_html(&url.url).await?; let html = self.get_html(&url.url).await?;
let main_text = if let Some(el) = html.select(&IL_CONTENT_CONTAINER).next() { let main_text = if let Some(el) = html.select(&IL_CONTENT_CONTAINER).next() {
Some(wrap_html(&el.inner_html())) // if we are currently extracting the dashboard, only select the favorites
if let Some(el) = el.select(&BLOCK_FAVORITES).next() {
Some(wrap_html(&el.inner_html()))
} else {
Some(wrap_html(&el.inner_html()))
}
} else { } else {
None None
}; };
@ -298,7 +304,7 @@ trait IliasObject {
pub enum Object { pub enum Object {
Course { name: String, url: URL }, Course { name: String, url: URL },
Folder { name: String, url: URL }, Folder { name: String, url: URL },
PersonalDesktop { url: URL }, Dashboard { url: URL },
File { name: String, url: URL }, File { name: String, url: URL },
Forum { name: String, url: URL }, Forum { name: String, url: URL },
Thread { url: URL }, Thread { url: URL },
@ -330,7 +336,7 @@ impl Object {
| Generic { name, .. } => &name, | Generic { name, .. } => &name,
Thread { url } => &url.thr_pk.as_ref().unwrap(), Thread { url } => &url.thr_pk.as_ref().unwrap(),
Video { url } => &url.url, Video { url } => &url.url,
PersonalDesktop { .. } => panic!("name of personal desktop requested (this should never happen)"), Dashboard { url } => &url.url
} }
} }
@ -338,7 +344,7 @@ impl Object {
match self { match self {
Course { url, .. } Course { url, .. }
| Folder { url, .. } | Folder { url, .. }
| PersonalDesktop { url } | Dashboard { url }
| File { url, .. } | File { url, .. }
| Forum { url, .. } | Forum { url, .. }
| Thread { url } | Thread { url }
@ -357,7 +363,7 @@ impl Object {
match self { match self {
Course { .. } => "course", Course { .. } => "course",
Folder { .. } => "folder", Folder { .. } => "folder",
PersonalDesktop { .. } => "personal desktop", Dashboard { .. } => "dashboard",
File { .. } => "file", File { .. } => "file",
Forum { .. } => "forum", Forum { .. } => "forum",
Thread { .. } => "thread", Thread { .. } => "thread",
@ -376,7 +382,7 @@ impl Object {
matches!( matches!(
self, self,
Course { .. } Course { .. }
| Folder { .. } | PersonalDesktop { .. } | Folder { .. } | Dashboard { .. }
| Forum { .. } | Thread { .. } | Forum { .. } | Thread { .. }
| Wiki { .. } | ExerciseHandler { .. } | Wiki { .. } | ExerciseHandler { .. }
| PluginDispatch { .. } | PluginDispatch { .. }
@ -471,7 +477,7 @@ impl Object {
None => Course { name, url }, None => Course { name, url },
}, },
"ilobjplugindispatchgui" => PluginDispatch { name, url }, "ilobjplugindispatchgui" => PluginDispatch { name, url },
"ilpersonaldesktopgui" => PersonalDesktop { url }, "ildashboardgui" => Dashboard { url },
_ => Generic { name, url }, _ => Generic { name, url },
}) })
} }

View File

@ -19,7 +19,7 @@ use std::time::SystemTime;
static ILIAS_URL: &str = "https://ilias.studium.kit.edu/"; static ILIAS_URL: &str = "https://ilias.studium.kit.edu/";
/// main personal desktop /// main personal desktop
static DEFAULT_SYNC_URL: &str = static DEFAULT_SYNC_URL: &str =
"https://ilias.studium.kit.edu/ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToSelectedItems"; "https://ilias.studium.kit.edu/ilias.php?baseClass=ilDashboardGUI&cmd=jumpToMemberships";
#[macro_use] #[macro_use]
mod cli; mod cli;
@ -245,7 +245,7 @@ async fn process(ilias: Arc<ILIAS>, path: PathBuf, obj: Object) -> Result<()> {
Course { url, name } => { Course { url, name } => {
ilias::course::download(path, ilias, url, name).await?; ilias::course::download(path, ilias, url, name).await?;
}, },
Folder { url, .. } | PersonalDesktop { url } => { Folder { url, .. } | Dashboard { url } => {
ilias::folder::download(&path, ilias, url).await?; ilias::folder::download(&path, ilias, url).await?;
}, },
File { url, .. } => { File { url, .. } => {