2017-07-01 07:47:41 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
|
|
|
extern crate toml;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate errors;
|
2017-08-07 11:38:13 +00:00
|
|
|
extern crate chrono;
|
Filter ignored content in page.rs.
* Add ignored_content to the Config structure.
* Use the GlobSet crate to parse the glob patterns into a matcher, which
is created once at program initialization. If there are no patterns in
ignored_content, an empty globber is created, which excludes no files.
This is consistent with the existing behaviour of Gutenberg, before
this feature was added.
* Bail if there are any errors in the glob patterns.
* Add a call to the globber in page.rs to actually do the filtering.
* Update documentation.
A note on the Config structure
------------------------------
* I had to remove the PartialEq derive from the Config structure as it
does not work for the GlobSet type. No harm is done, Config does not
need to be PartialEq anyway, since there is no need to sort Configs.
* The implementation follows the pattern of the existing config settings
in that it uses an Option<...>. This would appear unnecessary, in that
an empty vec could be used as the default, but it appears to be needed
by the TOML parsing. A better approach would be to use a separate
SerializableConfig and map to/from a Config struct. This would also
allow the elimination of most, if not all, of the other Options in
the Config structure, but that ought to be another PR.
2018-02-25 11:42:31 +00:00
|
|
|
extern crate globset;
|
2018-10-09 12:33:43 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate lazy_static;
|
|
|
|
extern crate syntect;
|
2016-12-06 05:51:33 +00:00
|
|
|
|
2018-10-09 12:33:43 +00:00
|
|
|
mod config;
|
|
|
|
pub mod highlighting;
|
2018-10-31 07:18:57 +00:00
|
|
|
mod theme;
|
2018-12-29 10:17:43 +00:00
|
|
|
pub use config::{Config, Language, Taxonomy};
|
2017-08-24 23:38:03 +00:00
|
|
|
|
2018-10-09 12:33:43 +00:00
|
|
|
use std::path::Path;
|
2017-03-06 14:45:57 +00:00
|
|
|
|
2017-03-03 08:12:40 +00:00
|
|
|
/// Get and parse the config.
|
|
|
|
/// If it doesn't succeed, exit
|
2017-03-25 04:18:15 +00:00
|
|
|
pub fn get_config(path: &Path, filename: &str) -> Config {
|
|
|
|
match Config::from_file(path.join(filename)) {
|
2017-03-03 08:12:40 +00:00
|
|
|
Ok(c) => c,
|
|
|
|
Err(e) => {
|
2017-03-25 04:18:15 +00:00
|
|
|
println!("Failed to load {}", filename);
|
2017-03-03 08:12:40 +00:00
|
|
|
println!("Error: {}", e);
|
|
|
|
::std::process::exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|