~exprez135/castor

e0159f7a47c0851474923bca14bc5a43726e6b78 — Julien Blanchard 1 year, 7 months ago 7c3d49a
Add start_url setting
4 files changed, 25 insertions(+), 8 deletions(-)

M README.md
M data/castor_settings.toml.example
M src/main.rs
M src/settings.rs
M README.md => README.md +5 -2
@@ 47,13 47,16 @@ You will need some development libraries:
- Open Castor and visit gemini://gemini.circumlunar.space and enjoy your trip!


## Changing colors
## Changing settings

You can change colors and delimiters for Headers, Lists, Text and Background.
You can change some settings like initial URL, colors and delimiters for Headers, Lists, Text and Background.
Edit `~/.local/share/castor_settings.toml` and add the values you need.
These are the keys currently supported, you can use hex codes, plain colors names or even emojis!

```
[general]
start_url = "gemini://gemini.circumlunar.space/capcom"

[colors]
h1 = "red"
h2 = "#FF6347"

M data/castor_settings.toml.example => data/castor_settings.toml.example +3 -0
@@ 1,3 1,6 @@
[general]
start_url = "gemini://gemini.circumlunar.space/capcom"

[colors]
h1 = "red"
h2 = "#FF6347"

M src/main.rs => src/main.rs +4 -6
@@ 4,7 4,6 @@ extern crate gtk;
#[macro_use]
extern crate lazy_static;

use std::env;
use std::str::FromStr;
use std::sync::Arc;



@@ 85,11 84,10 @@ fn main() {
        });
    }

    // Visit URL if one was provided
    let args: Vec<String> = env::args().collect();
    if args.len() > 1 {
        let url = String::from(&args[1]);
        route_url(&gui, url)
    // Visit start URL setting if provided
    match settings::start_url() {
        Some(url) => route_url(&gui, url),
        None => ()
    }

    gui.start();

M src/settings.rs => src/settings.rs +13 -0
@@ 8,11 8,17 @@ use serde_derive::Deserialize;

#[derive(Deserialize)]
struct Settings {
    general: Option<General>,
    colors: Option<Color>,
    characters: Option<Character>,
}

#[derive(Deserialize)]
struct General {
    start_url: Option<String>,
}

#[derive(Deserialize)]
struct Color {
    h1: Option<String>,
    h2: Option<String>,


@@ 30,6 36,13 @@ struct Character {
    list: Option<String>,
}

pub fn start_url() -> Option<String> {
    match read().general {
        Some(general) => general.start_url,
        None => None
    }
}

pub fn h1_color() -> String {
    match read().colors {
        Some(colors) => match colors.h1 {