diff --git a/.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from .github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md rename to .github/PULL_REQUEST_TEMPLATE.md diff --git a/Cargo.lock b/Cargo.lock index 2305c2f..e4df794 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -248,9 +248,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.34" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" +checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index a806585..bffa5bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ categories = [ "command-line-utilities", "gui", "text-processing" ] [dependencies] async-std = "1.12.0" directories = "5.0.1" -chrono = "0.4.34" +chrono = "0.4.35" dialoguer = "0.11.0" crossterm = "0.27.0" rusqlite = { version = "0.31.0", features = ["bundled"] } diff --git a/README.md b/README.md index ed9ca33..b6be051 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,11 @@ You can help us in different ways.
**Contributing guidelines** for these three roles coming soon! ## Installation -To install Notabena on **Windows**, simply run the file! +There are a few different ways of installing Notabena: +- **Recommended way:** through SourceForge: https://sourceforge.net/projects/notabena/. This requires no knowledge or programs, but if you want to run it with `notabena` you'll need to add it to `PATH` manually. Is your architecture not in there? Consider building for all the versions and [sending the binaries in our server](https://discord.gg/htNK4YcJB8). +- **Package manager:** currently, Notabena only supports *Homebrew* for **MacOS** and **Linux**. The formula is in `chiissu/macchiato`. More package managers will be added at stable. + - (Still unsure? `brew tap chiissu/macchiato && brew install notabena`) +- **The Rust way:** if you have Rust installed, we recommend installing it through `cargo` (`cargo install notabena`). It will automatically be added to your `PATH`. When running Notabena on **Linux or macOS**, you might encounter an error like this when running the file:
`bash: /home/Your-Username/Downloads/Your-Notabena-Installation: Permission denied`
@@ -42,5 +46,4 @@ MacOS: `chmod u+x /Users/Your-Username/Downloads/Your-Notabena-Installation` (filling in the blanks)
The program should now run smoothly!
-These are currently the only known errors during the installation of Notabena. -If these solutions don't work or another error occurs, please open an issue so this section can be updated! +There are no issues known with Windows installation. If you get another error or similar bug, please open an issue. diff --git a/src/main.rs b/src/main.rs index e3d839c..7e8f974 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,14 +5,21 @@ mod return_to_main; mod tests; mod utilities; +use std::process::exit; + use crate::{ note::Note, prompts::{multiselect::multiselect, select::select}, return_to_main::return_to_main, - utilities::{cursor_to_origin::cursor_to_origin, truncate_note::truncate_note}, + utilities::{ + cursor_to_origin::cursor_to_origin, + format_md::{inline, paragraph}, + truncate_note::truncate_note, + }, }; use async_std::path::PathBuf; use directories::BaseDirs; +use termimad::MadSkin; fn main() -> Result<(), Box> { let data_directory: PathBuf = BaseDirs::new().unwrap().config_dir().into(); @@ -37,23 +44,29 @@ fn main() -> Result<(), Box> { 2 => Note::edit(&db_file).expect("Editing the note failed"), 3 => Note::delete(&db_file).expect("Deleting the note failed"), 4 => display_about().expect("Viewing about failed"), - _ => { - cursor_to_origin()?; - return Ok(()); - } + 5 => exit(0), + _ => (), } - - /*if return_to_main().is_ok() { - main()?; - }*/ } } fn display_about() -> Result<(), Box> { + let skin: MadSkin = MadSkin::default(); + cursor_to_origin()?; - println!("Notabena is a FOSS note-taking CLI tool, written in Rust."); - println!("License: GPL v3\n"); - println!("COPYRIGHT (c) 2024 NOTABENA ORGANISATION\nPROJECT LEADS @ThatFrogDev, @MrSerge01, GITHUB CONTRIBUTORS\n"); + println!("{}", paragraph(&skin, &format!("# About Notabena"))); + println!( + "{}", + inline( + &skin, + "**Notabena** is a FOSS note-taking CLI tool, written in Rust.\n" + ) + ); + println!( + "version: v{}, licensed under: GPL v3", + env!("CARGO_PKG_VERSION") + ); + println!("COPYRIGHT (c) 2023-PRESENT NOTABENA ORGANISATION\nPROJECT LEADS @ThatFrogDev, @MrSerge01, GITHUB CONTRIBUTORS\n"); Ok(()) } diff --git a/src/note.rs b/src/note.rs index 7d5c170..b049452 100644 --- a/src/note.rs +++ b/src/note.rs @@ -29,10 +29,6 @@ impl Note { created: format!("{}", Local::now().format("%A %e %B, %H:%M")), }; - cursor_to_origin()?; - println!("This is the note you're about to create:"); - display(&mut inputted_note)?; - Connection::open(db_file)?.execute( "INSERT INTO saved_notes (id, name, content, created) VALUES (?1, ?2, ?3, ?4);", params![ @@ -62,7 +58,7 @@ impl Note { let mut selected_note = &saved_notes[selection]; cursor_to_origin()?; - display(&mut selected_note)?; + display(&mut selected_note); Ok(()) } diff --git a/src/utilities/display.rs b/src/utilities/display.rs index 652fa1a..66c19ce 100644 --- a/src/utilities/display.rs +++ b/src/utilities/display.rs @@ -1,16 +1,23 @@ -use termimad::*; - use crate::note::Note; -use crate::utilities::format_md::format_md; +use crate::utilities::format_md::{inline, paragraph}; +use std::io::{self, Write}; +use termimad::*; pub fn display(note: &Note) -> Result<(), Box> { let skin: MadSkin = MadSkin::default(); + let formatted_note = format!( + "=======================\n\ + {}\ + {}\n\ + {}\ + =======================\n", + paragraph(&skin, &format!("# {}", inline(&skin, ¬e.name))), + paragraph(&skin, ¬e.content), + paragraph(&skin, &format!("*{}*", note.created)) + ); - println!("======================="); - println!("Name: {}", format_md(&skin, ¬e.name)); - println!("Content: {}", format_md(&skin, ¬e.content)); - println!("Created at: {}", note.created); - println!("======================="); + print!("{}", formatted_note); + io::stdout().flush()?; Ok(()) } diff --git a/src/utilities/format_md.rs b/src/utilities/format_md.rs index 462c0cc..91a1094 100644 --- a/src/utilities/format_md.rs +++ b/src/utilities/format_md.rs @@ -1,5 +1,9 @@ use termimad::*; -pub fn format_md<'sk, 'st>(skin: &'sk MadSkin, string: &'st str) -> FmtInline<'sk, 'st> { +pub fn paragraph<'sk, 'st>(skin: &'sk MadSkin, string: &'st str) -> FmtText<'sk, 'st> { + return skin.text(string, None); +} + +pub fn inline<'sk, 'st>(skin: &'sk MadSkin, string: &'st str) -> FmtInline<'sk, 'st> { return skin.inline(string); }