This commit is contained in:
parent
a046dd2118
commit
172aff4ef4
7 changed files with 119 additions and 2 deletions
|
@ -26,6 +26,7 @@ steps:
|
||||||
- cargo install cargo-deb
|
- cargo install cargo-deb
|
||||||
- cargo deb -v -p cli -o target/debian/jm.deb
|
- cargo deb -v -p cli -o target/debian/jm.deb
|
||||||
- cargo deb -v -p tokencracker -o target/debian/jmtoken.deb
|
- cargo deb -v -p tokencracker -o target/debian/jmtoken.deb
|
||||||
|
- cargo deb -v -p gui -o target/debian/jmg.deb
|
||||||
|
|
||||||
- name: publish
|
- name: publish
|
||||||
image: plugins/gitea-release
|
image: plugins/gitea-release
|
||||||
|
@ -38,10 +39,13 @@ steps:
|
||||||
files:
|
files:
|
||||||
- target/release/jm
|
- target/release/jm
|
||||||
- target/release/jmtoken
|
- target/release/jmtoken
|
||||||
|
- target/release/jmg
|
||||||
- target/x86_64-pc-windows-gnu/release/jm.exe
|
- target/x86_64-pc-windows-gnu/release/jm.exe
|
||||||
- target/x86_64-pc-windows-gnu/release/jmtoken.exe
|
- target/x86_64-pc-windows-gnu/release/jmtoken.exe
|
||||||
|
- target/x86_64-pc-windows-gnu/release/jmg.exe
|
||||||
- target/debian/jm.deb
|
- target/debian/jm.deb
|
||||||
- target/debian/jmtoken.deb
|
- target/debian/jmtoken.deb
|
||||||
|
- target/debian/jmg.deb
|
||||||
when:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"tokencracker",
|
|
||||||
"cli",
|
"cli",
|
||||||
|
"gui",
|
||||||
"jm_client_core",
|
"jm_client_core",
|
||||||
|
"tokencracker",
|
||||||
]
|
]
|
||||||
|
|
|
@ -29,4 +29,5 @@ term-table = "1.3.0"
|
||||||
term_size = "0.3.2"
|
term_size = "0.3.2"
|
||||||
tokio = { version = "0.2.23", features = ["macros", "fs", "process"] }
|
tokio = { version = "0.2.23", features = ["macros", "fs", "process"] }
|
||||||
url = "2.2.0"
|
url = "2.2.0"
|
||||||
|
reqwest = { version = "0.10", features = ["stream"] }
|
||||||
|
|
||||||
|
|
21
gui/Cargo.toml
Normal file
21
gui/Cargo.toml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
[package]
|
||||||
|
name = "gui"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["LordMZTE <lord@mzte.de>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[package.metadata.deb]
|
||||||
|
name = "jensmemes-gui"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "jmg"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1.0.40"
|
||||||
|
druid = "0.7.0"
|
||||||
|
jm_client_core = { path = "../jm_client_core" }
|
||||||
|
tokio = { version = "0.2.23", features = ["macros"] }
|
||||||
|
reqwest = "0.10"
|
80
gui/src/main.rs
Normal file
80
gui/src/main.rs
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
use std::{cmp::Ordering, sync::Arc};
|
||||||
|
|
||||||
|
use crate::util::EqData;
|
||||||
|
use druid::{
|
||||||
|
widget::{Flex, Label, List, Scroll},
|
||||||
|
AppLauncher,
|
||||||
|
Color,
|
||||||
|
Data,
|
||||||
|
Lens,
|
||||||
|
Widget,
|
||||||
|
WidgetExt,
|
||||||
|
WindowDesc,
|
||||||
|
};
|
||||||
|
use jm_client_core::api::Meme;
|
||||||
|
use reqwest::Client;
|
||||||
|
|
||||||
|
pub(crate) mod util;
|
||||||
|
|
||||||
|
const LIST_COLS: &[(&str, f64)] = &[("Link", 1000.), ("User", 50.)];
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() -> anyhow::Result<()> {
|
||||||
|
let http = Client::new();
|
||||||
|
let mut memes = jm_client_core::util::api::memes(&http, None, None)
|
||||||
|
.await?
|
||||||
|
.iter()
|
||||||
|
.map(|m| EqData(m.clone()))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
memes.sort_by(|a, b| {
|
||||||
|
if let Ok((a, b)) =
|
||||||
|
a.0.file_name()
|
||||||
|
.and_then(|a| b.0.file_name().map(|b| (a, b)))
|
||||||
|
{
|
||||||
|
a.cmp(b)
|
||||||
|
} else {
|
||||||
|
Ordering::Equal
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let main_gui = WindowDesc::new(build_root_widget).title("JensMemes GUI");
|
||||||
|
|
||||||
|
AppLauncher::with_window(main_gui).launch(State {
|
||||||
|
memes: Arc::new(memes),
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Data, Lens)]
|
||||||
|
pub struct State {
|
||||||
|
pub memes: Arc<Vec<EqData<Meme>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_root_widget() -> impl Widget<State> {
|
||||||
|
Scroll::new(
|
||||||
|
Flex::column()
|
||||||
|
.with_child(
|
||||||
|
Flex::row()
|
||||||
|
.with_child(Label::new(LIST_COLS[0].0).fix_width(LIST_COLS[0].1))
|
||||||
|
.with_child(Label::new(LIST_COLS[1].0).fix_width(LIST_COLS[1].1))
|
||||||
|
.background(Color::grey8(0x33)),
|
||||||
|
)
|
||||||
|
.with_child(
|
||||||
|
List::new(|| {
|
||||||
|
Flex::row()
|
||||||
|
.with_child(
|
||||||
|
Label::dynamic(|d: &EqData<Meme>, _| d.0.link.clone())
|
||||||
|
.fix_width(LIST_COLS[0].1),
|
||||||
|
)
|
||||||
|
.with_child(
|
||||||
|
Label::dynamic(|d: &EqData<Meme>, _| d.0.user.clone())
|
||||||
|
.fix_width(LIST_COLS[1].1),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.lens(State::memes),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.padding(5.)
|
||||||
|
}
|
10
gui/src/util.rs
Normal file
10
gui/src/util.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
use druid::Data;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct EqData<T: 'static + PartialEq + Clone>(pub T);
|
||||||
|
|
||||||
|
impl<T: 'static + PartialEq + Clone> Data for EqData<T> {
|
||||||
|
fn same(&self, other: &Self) -> bool {
|
||||||
|
self == other
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,5 +16,5 @@ reqwest = "0.10.9"
|
||||||
serde = { version = "1.0.117", features = ["derive"] }
|
serde = { version = "1.0.117", features = ["derive"] }
|
||||||
serde_json = "1.0.60"
|
serde_json = "1.0.60"
|
||||||
thiserror = "1.0.23"
|
thiserror = "1.0.23"
|
||||||
tokio = { version = "0.2.23", features = ["macros", "fs", "process"] }
|
tokio = { version = "0.2.23", features = ["macros", "fs"] }
|
||||||
url = "2.2.0"
|
url = "2.2.0"
|
||||||
|
|
Loading…
Reference in a new issue