|
|
@ -33,6 +33,13 @@ static INLINABLE: [&'static str; 4] = ["jpeg", "jpg", "png", "gif"]; |
|
|
|
/// This is the folder structured returned by Joplin. It is here so Reqwests can
|
|
|
|
/// This is the folder structured returned by Joplin. It is here so Reqwests can
|
|
|
|
/// unjson the data (there are more fields, but these are the only ones we need
|
|
|
|
/// unjson the data (there are more fields, but these are the only ones we need
|
|
|
|
/// right now).
|
|
|
|
/// right now).
|
|
|
|
|
|
|
|
#[allow(dead_code)] |
|
|
|
|
|
|
|
#[derive(Deserialize, Debug)] |
|
|
|
|
|
|
|
struct FolderList { |
|
|
|
|
|
|
|
items: Vec<Folder>, |
|
|
|
|
|
|
|
has_more: bool, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[allow(dead_code)] |
|
|
|
#[allow(dead_code)] |
|
|
|
#[derive(Deserialize, Debug)] |
|
|
|
#[derive(Deserialize, Debug)] |
|
|
|
struct Folder { |
|
|
|
struct Folder { |
|
|
@ -95,12 +102,31 @@ impl Joplin { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn get_folder_list(config: &JoplinConfig) -> Result<Vec<Folder>, Error> { |
|
|
|
fn get_folder_list(config: &JoplinConfig) -> Result<Vec<Folder>, Error> { |
|
|
|
let base_url = format!( |
|
|
|
let mut page = 1; |
|
|
|
"http://localhost:{port}/folders?token={token}", |
|
|
|
let mut has_more = true; |
|
|
|
port = config.port, |
|
|
|
let mut folders: Vec<Folder> = Vec::new(); |
|
|
|
token = config.token |
|
|
|
|
|
|
|
); |
|
|
|
while has_more { |
|
|
|
let folders: Vec<Folder> = reqwest::get(&base_url)?.json()?; |
|
|
|
let base_url = dbg!(format!( |
|
|
|
|
|
|
|
"http://localhost:{port}/folders?token={token}&page={page}", |
|
|
|
|
|
|
|
port = config.port, |
|
|
|
|
|
|
|
token = config.token, |
|
|
|
|
|
|
|
page = page |
|
|
|
|
|
|
|
)); |
|
|
|
|
|
|
|
let folder_list: FolderList = reqwest::get(&base_url)?.json()?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
folder_list.items.iter().for_each(|folder| { |
|
|
|
|
|
|
|
folders.push(Folder { |
|
|
|
|
|
|
|
// XXX this is silly and I should change this to use an
|
|
|
|
|
|
|
|
// iterator over the results
|
|
|
|
|
|
|
|
id: folder.id.to_string(), |
|
|
|
|
|
|
|
title: folder.title.to_string(), |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
page += 1; |
|
|
|
|
|
|
|
has_more = folder_list.has_more; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Ok(folders) |
|
|
|
Ok(folders) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|