v0.1.2
This commit is contained in:
parent
a7e0f1d410
commit
022a7f1f72
@ -8,3 +8,6 @@
|
|||||||
* Languages currently available:
|
* Languages currently available:
|
||||||
- English
|
- English
|
||||||
- Basque
|
- Basque
|
||||||
|
|
||||||
|
## v0.1.2
|
||||||
|
* Including the resource directory to the executable binary.
|
||||||
|
22
Cargo.lock
generated
22
Cargo.lock
generated
@ -105,10 +105,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dokugile"
|
name = "dokugile"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"colorize",
|
"colorize",
|
||||||
"dirs",
|
"dirs",
|
||||||
|
"include_dir",
|
||||||
"pandoc",
|
"pandoc",
|
||||||
"rust-i18n",
|
"rust-i18n",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
@ -195,6 +196,25 @@ dependencies = [
|
|||||||
"winapi-util",
|
"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]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "1.9.3"
|
version = "1.9.3"
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "dokugile"
|
name = "dokugile"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
author = "Aitzol Berasategi"
|
||||||
|
repository = "https://git.lainoa.eus/aitzol/dokugile.git"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
walkdir = "2.5"
|
walkdir = "2.5"
|
||||||
@ -9,3 +11,4 @@ pandoc = "0.8.11"
|
|||||||
colorize = "0.1.0"
|
colorize = "0.1.0"
|
||||||
dirs = "5.0.1"
|
dirs = "5.0.1"
|
||||||
rust-i18n = "3.0.1"
|
rust-i18n = "3.0.1"
|
||||||
|
include_dir = "0.7.3"
|
||||||
|
17
src/main.rs
17
src/main.rs
@ -10,6 +10,7 @@ use dirs;
|
|||||||
use pandoc::PandocError;
|
use pandoc::PandocError;
|
||||||
use dokugile::template;
|
use dokugile::template;
|
||||||
use rust_i18n::t;
|
use rust_i18n::t;
|
||||||
|
use include_dir::{include_dir, Dir};
|
||||||
|
|
||||||
rust_i18n::i18n!("locales");
|
rust_i18n::i18n!("locales");
|
||||||
|
|
||||||
@ -32,6 +33,12 @@ impl Project {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
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 _ = set_lang();
|
||||||
let mut wiki_path = String::new();
|
let mut wiki_path = String::new();
|
||||||
let mut doc_path = String::new();
|
let mut doc_path = String::new();
|
||||||
@ -85,6 +92,8 @@ fn main() {
|
|||||||
//doc_path.push_str(&capitalize_first_letter(&doc_title.trim_end()));
|
//doc_path.push_str(&capitalize_first_letter(&doc_title.trim_end()));
|
||||||
let res_path = wiki_path.clone()+"/res";
|
let res_path = wiki_path.clone()+"/res";
|
||||||
if !Path::new(&doc_path).exists() || !Path::new(&res_path).exists(){
|
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();
|
let mut ans = String::new();
|
||||||
if !Path::new(&doc_path).exists() {
|
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()));
|
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()));
|
||||||
@ -95,8 +104,8 @@ fn main() {
|
|||||||
"y" | "yes" | "Y" | "B" | "Bai" => {
|
"y" | "yes" | "Y" | "B" | "Bai" => {
|
||||||
let _ = mkdir(&doc_path);
|
let _ = mkdir(&doc_path);
|
||||||
// create resources
|
// create resources
|
||||||
for entry in WalkDir::new("assets").into_iter().filter_map(|e| e.ok()) {
|
for entry in WalkDir::new("/tmp/assets").into_iter().filter_map(|e| e.ok()) {
|
||||||
let input_entry = String::from(entry.path().strip_prefix("assets").expect(&t!("Path not found")).display().to_string());
|
let input_entry = String::from(entry.path().strip_prefix("/tmp/assets").expect(&t!("Path not found")).display().to_string());
|
||||||
let subdirs = wiki_path.to_string()+"/"+&input_entry;
|
let subdirs = wiki_path.to_string()+"/"+&input_entry;
|
||||||
let images = wiki_path.to_string()+"/"+&doc_title.trim()+"/"+&input_entry;
|
let images = wiki_path.to_string()+"/"+&doc_title.trim()+"/"+&input_entry;
|
||||||
|
|
||||||
@ -124,6 +133,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()));
|
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"));
|
||||||
},
|
},
|
||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
@ -212,7 +223,7 @@ fn processing(project: Project) -> Result<String, String>{
|
|||||||
index.push_str("/index.html");
|
index.push_str("/index.html");
|
||||||
sanitize(Path::new(&index));
|
sanitize(Path::new(&index));
|
||||||
//Ok("Success")
|
//Ok("Success")
|
||||||
let link = String::from("file://".to_owned()+&index).cyan();
|
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 message:String = String::from(t!("Congrats! Check your documentation at.. %{s}", s = &link));
|
||||||
Ok(message)
|
Ok(message)
|
||||||
}else{
|
}else{
|
||||||
|
Loading…
Reference in New Issue
Block a user