Compare commits

..

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

7 changed files with 13 additions and 74 deletions

View File

@ -8,10 +8,3 @@
* Languages currently available: * Languages currently available:
- English - English
- Basque - Basque
## v0.1.2
* Including the resource directory to the executable binary.
## v0.1.3
* Assign the working directory name to the document(project) if the user does not enter one.
* Minor bug fixes.

22
Cargo.lock generated
View File

@ -105,11 +105,10 @@ dependencies = [
[[package]] [[package]]
name = "dokugile" name = "dokugile"
version = "0.1.3" version = "0.1.1"
dependencies = [ dependencies = [
"colorize", "colorize",
"dirs", "dirs",
"include_dir",
"pandoc", "pandoc",
"rust-i18n", "rust-i18n",
"walkdir", "walkdir",
@ -196,25 +195,6 @@ 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"

View File

@ -1,9 +1,7 @@
[package] [package]
name = "dokugile" name = "dokugile"
version = "0.1.3" version = "0.1.1"
edition = "2021" edition = "2021"
author = "Aitzol Berasategi"
repository = "https://git.lainoa.eus/aitzol/dokugile.git"
[dependencies] [dependencies]
walkdir = "2.5" walkdir = "2.5"
@ -11,4 +9,3 @@ 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"

View File

@ -6,12 +6,10 @@ Simple document generator from Markdown to Html.
# how to use # how to use
These steps are indicated for _Debian_ based distros. These steps are indicated for _Debian_ based distros.
* _Pandoc_ is required. To install it run
* _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
```bash ```bash
sudo apt-get install pandoc sudo apt-get install pandoc
``` ```
* Download and execute _dokugile_ binary * Download and execute _dokugile_ binary
```bash ```bash
sudo chmod +x dokugile sudo chmod +x dokugile

View File

@ -2,14 +2,12 @@ _version: 1
Project name: 'Project name' Project name: 'Project name'
Project location: 'Project location' 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]' 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]'
You must assign a name to your project. Would you like to call it %{s}?(y/n)[Y]: 'You must assign a name to your project. Would you like to call it %{s}?(y/n)[Y]'
Okay, so your project is called %{s}: 'Okay, so your project is called %{s}'
Location %{s} has been created: 'Location %{s} has been created' 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]' 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' 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}' found... %{s}: 'found... %{s}'
No markdown files found!: 'No markdown files found!' No markdown files found!: 'No markdown files found!'
Please 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!' 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}' Processed markdown files.. %{s}: 'Processed markdown files.. %{s}'
Congrats! Check your documentation at.. %{s}: 'Congrats! Check your documentation at.. %{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!' 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!'

View File

@ -2,8 +2,6 @@ _version: 1
Project name: 'Proiektuaren izena' Project name: 'Proiektuaren izena'
Project location: 'Proiektuaren kokapena' 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]' 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]'
You must assign a name to your project. Would you like to call it %{s}?(y/n)[Y]: 'Izena jarri behar diozu zure proiektuari. %{s} deitzea nahiko zenuke?(b/e)[B]'
Okay, so your project is called %{s}: 'Ederki, zure proiektua %{s} deitzen da'
Location %{s} has been created: '%{s} kokapena sortu da' 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]' 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' 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'

View File

@ -10,7 +10,6 @@ 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");
@ -33,12 +32,6 @@ 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();
@ -68,7 +61,7 @@ fn main() {
io::stdin().read_line(&mut ans).expect("Failed to read line"); io::stdin().read_line(&mut ans).expect("Failed to read line");
if ans.trim().is_empty() { ans = String::from("Y") }; if ans.trim().is_empty() { ans = String::from("Y") };
match ans.trim() { match ans.trim() {
"y" | "yes" | "Y" | "b" | "B" | "Bai" => { //let _ = fs::create_dir(&wiki_path); "y" | "yes" | "Y" | "B" | "Bai" => { //let _ = fs::create_dir(&wiki_path);
let _ = mkdir(&wiki_path); let _ = mkdir(&wiki_path);
println!("{}.", t!("Location %{s} has been created", s = &project_dir.trim().to_owned().green().bold())); println!("{}.", t!("Location %{s} has been created", s = &project_dir.trim().to_owned().green().bold()));
}, },
@ -81,21 +74,7 @@ fn main() {
attempts += 1; attempts += 1;
} }
if attempts == 3 { if attempts == 3 {
//break break
let cwd = env::current_dir().unwrap().display().to_string();
let dirs: Vec<&str> = cwd.split('/').collect();
if input.trim().is_empty() { input = capitalize_first_letter( dirs.last().unwrap() ) };
let mut ans = String::new();
println!("{}", t!("You must assign a name to your project. Would you like to call it %{s}?(y/n)[Y]", s = input.clone().green()));
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" | "B" | "Bai" => {
println!("{}.\n", t!("Okay, so your project is called %{s}", s = &input.trim().to_owned().green().bold()));
},
_ => std::process::abort(),
};
}; };
doc_title = input.to_string(); doc_title = input.to_string();
@ -106,8 +85,6 @@ 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()));
@ -118,8 +95,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("/tmp/assets").into_iter().filter_map(|e| e.ok()) { for entry in WalkDir::new("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()); let input_entry = String::from(entry.path().strip_prefix("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;
@ -146,9 +123,7 @@ fn main() {
}; };
} }
} }
println!("{}.\n", 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,
}; };
@ -181,11 +156,11 @@ fn copy(source: &String, dest: &String) -> std::io::Result<()> {
fs::copy(source, dest)?; fs::copy(source, dest)?;
Ok(()) Ok(())
} }
/*
fn capitalize_first_letter(s: &str) -> String { fn capitalize_first_letter(s: &str) -> String {
s[0..1].to_uppercase() + &s[1..] s[0..1].to_uppercase() + &s[1..]
} }
*/
fn processing(project: Project) -> Result<String, String>{ fn processing(project: Project) -> Result<String, String>{
let mut md_count :i32 = 0; let mut md_count :i32 = 0;
@ -229,7 +204,7 @@ fn processing(project: Project) -> Result<String, String>{
if error.is_empty() { if error.is_empty() {
if md_count == 0 { if md_count == 0 {
println!("{}", t!("No markdown files found!")); println!("{}", t!("No markdown files found!"));
println!("{}", t!("Please edit first your documents in markdown format and come back to convert them to html. Bye!")); println!("{}", t!("Pleade edit first your documents in markdown format and come back to convert them to html. Bye!"));
}else{ }else{
println!("{}", t!("Processed markdown files.. %{s}", s = md_count)); println!("{}", t!("Processed markdown files.. %{s}", s = md_count));
} }
@ -237,7 +212,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).b_blue(); let link = String::from("file://".to_owned()+&index).cyan();
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{