Skip to content

Commit

Permalink
Updatre README
Browse files Browse the repository at this point in the history
  • Loading branch information
dantleech committed Nov 10, 2024
1 parent 91042b0 commit 39d81c8
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 22 deletions.
67 changes: 58 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,73 @@ Strava TUI written in Rust! This is an experimental TUI for Strava.
Features:

- List activities in a comparable way
- Filter activites by name
- Filter activites by with expressions
- Sort listed activities
- Display the route
- Show laps
- Race predictions
- Filter by route similarity ("anchoring")

## Screenshots

### List activities

![image](https://github.com/dantleech/strava-rs/assets/530801/7187befb-65e2-4fbc-b5b4-8710510c5e1a)
*Numbers*
![image](https://github.com/user-attachments/assets/f13ed611-d764-4941-a3df-c95db8636ba7)

### Acivity View

![image](https://github.com/user-attachments/assets/88c9b34a-7cee-409d-9d01-39bd22ef8259)

## Key Map

- `q`: **Quit**: quit!
- `k`: **Up** - select previous activity
- `j`: **Down** - select next activity
- `n`: **Next** - (in activity view) next split
- `p`: **Previous** - (in activity view) previous split
- `o`: **ToggleSortOrder** - switch between ascending and descending order
- `u`: **ToggleUnitSystem** - switch between imperial and metric units
- `s`: **Sort** - show sort dialog
- `S`: **Rank** - choose ranking
- `f`: **Filter** - filter (see filter section below)
- `r`: **Refresh** - reload activities
- `a`: **Anchor** - show activities with similar routes
- `+`: **IncreaseTolerance** - incease the anchor tolerance
- `-`: **DecreaseTolerance** - descrease the ancor tolerance
- `0`: **ToggleLogView** - toggle log view

## Filter

Press `f` on the activity list view to open the filter input.

### Examples

Show all runs that are of a half marathon distance or more:

```
type = "Run" and distance > 21000
```

Show all runs with "Park" in the title:

```
type = "Run" and title ~ "Park"
```

### Filter activities
### Fields

![image](https://github.com/dantleech/strava-rs/assets/530801/42a5a2e2-0925-4d1f-a780-e1a5d11b0ab1)
*Chronological*
- `distance`: Distance (in meters)
- `type`: `Run`, `Ride` etc.
- `heartrate`: Heart rate in BPM.
- `title`: Activity title
- `elevation`: Elevation (in meters)
- `time`: Time (in seconds, 3600 = 1 hour)

### Details
### Operators

![image](https://github.com/dantleech/strava-rs/assets/530801/633ea4ff-12c8-4ead-817b-80db8efcf61a)
*Detailed Maps*
- `>`, `<`: Greater than, Less than (e.g. `distance > 21000`)
- `and`, `or`: Logical operators (e.g. `type = "Run" and time > 0`)
- `=`: Equal to
- `~`: String contains
- `!=`: Not equal to (e.g. `type != "Run"`)
- `!~`: String does not contain (e.g. `title ~ "Parkrun"`)
23 changes: 12 additions & 11 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ use log::info;
use tokio::sync::mpsc::{Receiver, Sender};
use tui::{
backend::{Backend, CrosstermBackend},
widgets::TableState, Terminal,
widgets::TableState,
Terminal,
};
use tui_input::Input;
use tui_logger::TuiWidgetState;

use crate::{
component::{activity_list, unit_formatter::UnitFormatter, log_view::LogView},
component::{activity_list, log_view::LogView, unit_formatter::UnitFormatter},
event::keymap::KeyMap,
expr::evaluator::Evaluator,
store::activity::Activity,
ui, expr::{self, evaluator::{Evaluator, Vars}},
ui,
};
use crate::{
component::{
Expand Down Expand Up @@ -138,7 +140,8 @@ impl App<'_> {
pace_table_state: TableState::default(),
selected_split: None,
},
log_view_state: TuiWidgetState::default().set_default_display_level(log::LevelFilter::Debug),
log_view_state: TuiWidgetState::default()
.set_default_display_level(log::LevelFilter::Debug),
filters: ActivityFilters {
sort_by: SortBy::Date,
sort_order: SortOrder::Desc,
Expand Down Expand Up @@ -176,8 +179,8 @@ impl App<'_> {

let mut view: Box<dyn View> = match self.active_page {
ActivePage::ActivityList => Box::new(ActivityList::new()),
ActivePage::Activity => Box::new(ActivityView{}),
ActivePage::LogView => Box::new(LogView::new())
ActivePage::Activity => Box::new(ActivityView {}),
ActivePage::LogView => Box::new(LogView::new()),
};

if let Some(message) = &self.info_message {
Expand All @@ -194,9 +197,7 @@ impl App<'_> {
while self.event_queue.len() > 1 {
let event = self.event_queue.pop().unwrap();
info!("Sending event: {:?}", event);
self.event_sender
.send(event)
.await?;
self.event_sender.send(event).await?;
}

if let Some(event) = self.event_receiver.recv().await {
Expand Down Expand Up @@ -233,7 +234,7 @@ impl App<'_> {
Ok(expr) => activities.by_expr(&evaluator, &expr),
Err(_) => activities.where_title_contains(self.filters.filter.as_str()),
};

if let Some(activity_type) = self.activity_type.clone() {
activities = activities.having_activity_type(activity_type);
}
Expand Down Expand Up @@ -299,7 +300,7 @@ impl App<'_> {
fn render(
&mut self,
terminal: &mut Terminal<CrosstermBackend<io::Stdout>>,
view: &mut dyn View
view: &mut dyn View,
) -> Result<(), anyhow::Error> {
let area = terminal.size().expect("Could not determine terminal size'");
terminal.autoresize()?;
Expand Down
2 changes: 0 additions & 2 deletions src/expr/parser.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::ascii::AsciiExt;

use super::lexer::{Lexer, Token, TokenKind};

#[derive(PartialEq, Debug, Clone)]
Expand Down
2 changes: 2 additions & 0 deletions src/store/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ impl Activities {
("type".to_string(), Evalue::String(a.activity_type.to_string())),
("heartrate".to_string(), Evalue::Number(a.average_heartrate.unwrap_or(0.0))),
("title".to_string(), Evalue::String(a.title.clone())),
("elevation".to_string(), Evalue::Number(a.total_elevation_gain)),
("time".to_string(), Evalue::Number(a.moving_time as f64)),
])) {
Ok(v) => v,
Err(_) => false,
Expand Down

0 comments on commit 39d81c8

Please sign in to comment.