Compare commits

..

No commits in common. "main" and "v0.1.0" have entirely different histories.
main ... v0.1.0

7 changed files with 25 additions and 525 deletions

View File

@ -2,12 +2,3 @@
## v0.1.0
* Initial version
## v0.1.1
* Localization using [rust_i18n](https://docs.rs/rust-i18n/latest/rust_i18n/).
* Languages currently available:
- English
- Basque
## v0.1.2
* Including the resource directory to the executable binary.

429
Cargo.lock generated
View File

@ -2,49 +2,12 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "arc-swap"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
[[package]]
name = "autocfg"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
[[package]]
name = "bstr"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706"
dependencies = [
"memchr",
"serde",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -57,31 +20,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc17e449bc7854c50b943d113a98bc0e01dc6585d2c66eaa09ca645ebd8a7e62"
[[package]]
name = "crossbeam-deque"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
[[package]]
name = "dirs"
version = "5.0.1"
@ -105,13 +43,11 @@ dependencies = [
[[package]]
name = "dokugile"
version = "0.1.2"
version = "0.1.0"
dependencies = [
"colorize",
"dirs",
"include_dir",
"pandoc",
"rust-i18n",
"walkdir",
]
@ -121,12 +57,6 @@ version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b"
[[package]]
name = "equivalent"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "getrandom"
version = "0.2.15"
@ -138,103 +68,6 @@ dependencies = [
"wasi",
]
[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "globset"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1"
dependencies = [
"aho-corasick",
"bstr",
"log",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "globwalk"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc"
dependencies = [
"bitflags 1.3.2",
"ignore",
"walkdir",
]
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashbrown"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
[[package]]
name = "ignore"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1"
dependencies = [
"crossbeam-deque",
"globset",
"log",
"memchr",
"regex-automata",
"same-file",
"walkdir",
"winapi-util",
]
[[package]]
name = "include_dir"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18762faeff7122e89e0857b02f7ce6fcc0d101d5e9ad2ad7846cc01d61b7f19e"
dependencies = [
"include_dir_macros",
]
[[package]]
name = "include_dir_macros"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b139284b5cf57ecfa712bcc66950bb635b31aff41c188e8a4cfc758eca374a3f"
dependencies = [
"proc-macro2",
"quote",
]
[[package]]
name = "indexmap"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg",
"hashbrown 0.12.3",
]
[[package]]
name = "indexmap"
version = "2.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
dependencies = [
"equivalent",
"hashbrown 0.14.5",
]
[[package]]
name = "itertools"
version = "0.12.1"
@ -244,18 +77,6 @@ dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.155"
@ -268,43 +89,10 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
dependencies = [
"bitflags 2.5.0",
"bitflags",
"libc",
]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "log"
version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
[[package]]
name = "memchr"
version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
[[package]]
name = "normpath"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5831952a9476f2fed74b77d74182fa5ddc4d21c72ec45a333b250e3ed0272804"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "once_cell"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "option-ext"
version = "0.2.0"
@ -349,92 +137,6 @@ dependencies = [
"thiserror",
]
[[package]]
name = "regex"
version = "1.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
[[package]]
name = "rust-i18n"
version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dcd94370631e5658a0a23635f7f47e43d06a00ad948e0bb5de79b00d85b880c"
dependencies = [
"globwalk",
"once_cell",
"regex",
"rust-i18n-macro",
"rust-i18n-support",
"smallvec",
]
[[package]]
name = "rust-i18n-macro"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "355763801dcf287e777e42def7c578410783477b804b1107852119e0b2518396"
dependencies = [
"glob",
"once_cell",
"proc-macro2",
"quote",
"rust-i18n-support",
"serde",
"serde_json",
"serde_yaml",
"syn",
]
[[package]]
name = "rust-i18n-support"
version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "399801f4d955abf1c3ce3ce2215dc76bd40beb4ae39e3a84936b21a79ce2caa5"
dependencies = [
"arc-swap",
"globwalk",
"lazy_static",
"normpath",
"once_cell",
"proc-macro2",
"regex",
"serde",
"serde_json",
"serde_yaml",
"toml",
"triomphe",
]
[[package]]
name = "ryu"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
[[package]]
name = "same-file"
version = "1.0.6"
@ -444,70 +146,6 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "serde"
version = "1.0.203"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.203"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "serde_spanned"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0"
dependencies = [
"serde",
]
[[package]]
name = "serde_yaml"
version = "0.8.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b"
dependencies = [
"indexmap 1.9.3",
"ryu",
"serde",
"yaml-rust",
]
[[package]]
name = "smallvec"
version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "syn"
version = "2.0.66"
@ -539,51 +177,6 @@ dependencies = [
"syn",
]
[[package]]
name = "toml"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit",
]
[[package]]
name = "toml_datetime"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap 2.2.6",
"serde",
"serde_spanned",
"toml_datetime",
"winnow",
]
[[package]]
name = "triomphe"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b2cb4fbb9995eeb36ac86fadf24031ccd58f99d6b4b2d7b911db70bddb80d90"
dependencies = [
"arc-swap",
"serde",
"stable_deref_trait",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
@ -753,21 +346,3 @@ name = "windows_x86_64_msvc"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
[[package]]
name = "winnow"
version = "0.5.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"
dependencies = [
"memchr",
]
[[package]]
name = "yaml-rust"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
dependencies = [
"linked-hash-map",
]

View File

@ -1,14 +1,10 @@
[package]
name = "dokugile"
version = "0.1.2"
version = "0.1.0"
edition = "2021"
author = "Aitzol Berasategi"
repository = "https://git.lainoa.eus/aitzol/dokugile.git"
[dependencies]
walkdir = "2.5"
pandoc = "0.8.11"
colorize = "0.1.0"
dirs = "5.0.1"
rust-i18n = "3.0.1"
include_dir = "0.7.3"

View File

@ -6,12 +6,10 @@ Simple document generator from Markdown to Html.
# how to use
These steps are indicated for _Debian_ based distros.
* _Pandoc_ version 3.1.13 or higher is required. You can try to install it from the repositories by running the following command, but you will probably find newer versions here: https://github.com/jgm/pandoc/releases
* _Pandoc_ is required. To install it run
```bash
sudo apt-get install pandoc
```
* Download and execute _dokugile_ binary
```bash
sudo chmod +x dokugile

View File

@ -1,17 +0,0 @@
_version: 1
Project name: 'Project name'
Project location: 'Project location'
Do you want to create a new location called %{s} for the documents?(y/n)[Y]: 'Do you want to create a new location called %{s} for the documents?(y/n)[Y]'
Location %{s} has been created: 'Location %{s} has been created'
The project %{s} has not been found. Do you want to create it?(y/n)[Y]: 'The project %{s} has not been found. Do you want to create it?(y/n)[Y]'
Project %{s} has been created. Now you can edit index.md file and create content: 'Project %{s} has been created. Now you can edit index.md file and create content'
found... %{s}: 'found... %{s}'
No markdown files found!: 'No markdown files found!'
Pleade edit first your documents in markdown format and come back to convert them to html. Bye!: 'Please edit first your documents in markdown format and come back to convert them to html. Bye!'
Processed markdown files.. %{s}: 'Processed markdown files.. %{s}'
Congrats! Check your documentation at.. %{s}: 'Congrats! Check your documentation at.. %{s}'
Please consider renaming your main page to index.md and restart the document conversion again. See you later!: 'Please consider renaming your main page to index.md and restart the document conversion again. See you later!'
Failed to read line: 'Failed to read line'
Path not found: 'Path not found'
The operation failed with error %{s}: 'The operation failed with error %{s}'
sed command failed to start: 'sed command failed to start'

View File

@ -1,17 +0,0 @@
_version: 1
Project name: 'Proiektuaren izena'
Project location: 'Proiektuaren kokapena'
Do you want to create a new location called %{s} for the documents?(y/n)[Y]: 'Dokumentuentzako %{s} izeneko kokapen berria sortu nahi duzu?(b/e)[B]'
Location %{s} has been created: '%{s} kokapena sortu da'
The project %{s} has not been found. Do you want to create it?(y/n)[Y]: '%{s} proiektua ez da aurkitu. Sortu egin nahi duzu?(b/e)[B]'
Project %{s} has been created. Now you can edit index.md file and create content: '%{s} proiektua sortu da. Orain index.md fitxategia editatu eta edukiak sor ditzakezu'
found... %{s}: 'aurkitua... %{s}'
No markdown files found!: 'Ez da markdown fitxategirik aurkitu!'
Pleade edit first your documents in markdown format and come back to convert them to html. Bye!: 'Mesedez editatu lehenbizi zure dokumentuak markdown formatuan eta itzuli html-ra itzultzeko. Aioo!'
Processed markdown files.. %{s}: 'Prozesaturiko markdown fitxategi kopurua.. %{s}'
Congrats! Check your documentation at.. %{s}: 'Zorionak! Ikuskatu zure dokumentazioa hemen.. %{s}'
Please consider renaming your main page to index.md and restart the document conversion again. See you later!: 'Mesedez berrizendatu zure orri nagusia index.md izenarekin eta saia zaitez berriro. Laster arte!'
Failed to read line: 'Akatsa ilara irakurtzean'
Path not found: 'Ez da bidea aurkitu'
The operation failed with error %{s}: 'Eragiketak %{s} erroreaz huts egin du'
sed command failed to start: 'sed komandoak huts egin du abioan'

View File

@ -9,10 +9,6 @@ use colorize::AnsiColor;
use dirs;
use pandoc::PandocError;
use dokugile::template;
use rust_i18n::t;
use include_dir::{include_dir, Dir};
rust_i18n::i18n!("locales");
struct Project {
wiki_path: String,
@ -33,13 +29,6 @@ impl Project {
}
fn main() {
const NAME: &str = env!("CARGO_PKG_NAME");
const VERSION: &str = env!("CARGO_PKG_VERSION");
const REPO: &str = env!("CARGO_PKG_REPOSITORY");
println!("{} {}\n{}\n",NAME.b_magenta(), VERSION.b_magenta(), REPO.b_blue());
static ASSETS_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/assets");
let _ = set_lang();
let mut wiki_path = String::new();
let mut doc_path = String::new();
let mut doc_title = String::new();
@ -49,28 +38,28 @@ fn main() {
while !Path::new(&doc_path).exists() || doc_title.trim().is_empty(){
doc_path = String::new();
let mut input = String::new();
println!("{}:", t!("Project name"));
io::stdin().read_line(&mut input).expect(&t!("Failed to read line"));
println!("Proiektuaren izena: ");
io::stdin().read_line(&mut input).expect("Failed to read line");
let root = env::var("HOME").unwrap().to_string()+"/";
let user_documents_path = dirs::document_dir().unwrap().display().to_string();
let user_doc_dir = user_documents_path.split("/").collect::<Vec<_>>().last().unwrap().to_string();
while !Path::new(&wiki_path).exists() {
let mut project_dir = String::new();
println!("{}:[{}/Wiki] ", t!("Project location"), &user_doc_dir);
io::stdin().read_line(&mut project_dir).expect(&t!("Failed to read line"));
println!("Proiektuaren kokapena:[{}/Wiki] ", &user_doc_dir);
io::stdin().read_line(&mut project_dir).expect("Failed to read line");
if project_dir.trim().is_empty() { project_dir = String::from(user_doc_dir.clone()+"/Wiki") };
wiki_path = root.clone()+project_dir.trim();
if !Path::new(&wiki_path).exists(){
let mut ans = String::new();
println!("{}", t!("Do you want to create a new location called %{s} for the documents?(y/n)[Y]", s = &project_dir.trim().to_owned().green().bold()));
println!("{} dokumentuentzako kokapen berria sortu nahi duzu?(y/n)[Y]", &project_dir.trim().to_owned().green().bold());
io::stdin().read_line(&mut ans).expect("Failed to read line");
if ans.trim().is_empty() { ans = String::from("Y") };
match ans.trim() {
"y" | "yes" | "Y" | "B" | "Bai" => { //let _ = fs::create_dir(&wiki_path);
let _ = mkdir(&wiki_path);
println!("{}.", t!("Location %{s} has been created", s = &project_dir.trim().to_owned().green().bold()));
println!("{} kokapena sortu da.", &project_dir.trim().to_owned().green().bold());
},
_ => continue,
};
@ -92,20 +81,18 @@ fn main() {
//doc_path.push_str(&capitalize_first_letter(&doc_title.trim_end()));
let res_path = wiki_path.clone()+"/res";
if !Path::new(&doc_path).exists() || !Path::new(&res_path).exists(){
// extract assets to temporary directory
let _ = ASSETS_DIR.extract("/tmp/assets");
let mut ans = String::new();
if !Path::new(&doc_path).exists() {
println!("{}", t!("The project %{s} has not been found. Do you want to create it?(y/n)[Y]", s = &input.trim().to_owned().green().bold()));
io::stdin().read_line(&mut ans).expect(&t!("Failed to read line"));
println!("{} proiektua ez da aurkitu. Sortu egin nahi duzu?(y/n)[Y]", &input.trim().to_owned().green().bold());
io::stdin().read_line(&mut ans).expect("Failed to read line");
}
if ans.trim().is_empty() { ans = String::from("Y") };
match ans.trim() {
"y" | "yes" | "Y" | "B" | "Bai" => {
let _ = mkdir(&doc_path);
// create resources
for entry in WalkDir::new("/tmp/assets").into_iter().filter_map(|e| e.ok()) {
let input_entry = String::from(entry.path().strip_prefix("/tmp/assets").expect(&t!("Path not found")).display().to_string());
for entry in WalkDir::new("assets").into_iter().filter_map(|e| e.ok()) {
let input_entry = String::from(entry.path().strip_prefix("assets").expect("Path not found").display().to_string());
let subdirs = wiki_path.to_string()+"/"+&input_entry;
let images = wiki_path.to_string()+"/"+&doc_title.trim()+"/"+&input_entry;
@ -132,9 +119,8 @@ fn main() {
};
}
}
println!("{}.", t!("Project %{s} has been created. Now you can edit index.md file and create content", s = &input.trim().to_owned().green().bold()));
//remove temporary created assets directory
let _ = fs::remove_dir_all(Path::new("/tmp/assets"));
println!("{} proiektua sortu da. Orain index.md fitxategia editatu eta edukiak \
sor ditzakezu", &input.trim().to_owned().green().bold());
},
_ => continue,
};
@ -148,7 +134,7 @@ fn main() {
let res = processing(Project::new(wiki_path.clone(), doc_path.clone(), doc_title, output_dir));
match res {
Err(e) => println!("{}", t!("The operation failed with error %{s}", s = e)),
Err(e) => println!("The operation failed with error: {}", e),
Ok(e) => println!("{}", e)
};
}
@ -196,7 +182,7 @@ fn processing(project: Project) -> Result<String, String>{
match extension {
"md" => {
//md_count += 1;
println!("{}", t!("found... %{s}", s = entry.path().display()));
println!("found: {}", entry.path().display());
let conv = md_to_html(entry.path(), &project.doc_title, &project.output_dir, &project.wiki_path);
match conv {
Ok(()) => md_count += 1,
@ -214,17 +200,17 @@ fn processing(project: Project) -> Result<String, String>{
if error.is_empty() {
if md_count == 0 {
println!("{}", t!("No markdown files found!"));
println!("{}", t!("Pleade edit first your documents in markdown format and come back to convert them to html. Bye!"));
println!("No markdown files found!");
println!("Pleade edit first your documents in markdown format and come back to convert them to html. Bye!");
}else{
println!("{}", t!("Processed markdown files.. %{s}", s = md_count));
println!("Processed {} markdown files.", md_count);
}
let mut index = project.wiki_path.to_owned()+"/"+&project.output_dir.trim_end();
index.push_str("/index.html");
sanitize(Path::new(&index));
//Ok("Success")
let link = String::from("file://".to_owned()+&index).b_blue();
let message:String = String::from(t!("Congrats! Check your documentation at.. %{s}", s = &link));
let link = String::from("file://".to_owned()+&index).cyan();
let message:String = String::from("Congrats! Check your documentation at.. ".to_owned()+&link);
Ok(message)
}else{
//Err(std::stringify!(error))
@ -274,21 +260,9 @@ fn sanitize(index: &Path){
Command::new("sed")
.args(["-i", r"-e s/\.md/\.html/g", &index.display().to_string()])
.status()
.expect(&t!("sed command failed start"));
.expect("sed command failed start");
}else{
println!("{}", t!("Please consider renaming your main page to index.md and restart the document conversion again. See you later!"));
println!("Please consider renaming your main page to index.md and restart the document conversion again. See you later!")
};
}
fn set_lang(){
let default = String::from("en_US"); // default locale
let locales = rust_i18n::available_locales!(); // available locales
let lang:String = match env::var("LANG") { // find out user's lang
Ok(val) => match val {
v if !v.is_empty() && locales.iter().any(|e| v.contains(e)) => v[..5].to_string(),
_ => default
} ,
Err(..) => default,
};
rust_i18n::set_locale(&lang); // set user lang
}