author | Jordan Johnson-Doyle <jordan@doyle.la> | 2019-02-12 1:23:06.0 +00:00:00 |
---|---|---|
committer | Jordan Johnson-Doyle <jordan@doyle.la> | 2019-02-12 1:23:06.0 +00:00:00 |
commit | 4fde2681173c2f8ba1d255535661f76cd83d7f2c [patch] |
|
tree | c33298c456a479a7b9706f5ab1a13c67a83146c9 |
|
parent | 2c1571881e9eb7236a41adc3df61726eb4008aa0 |
|
download | 4fde2681173c2f8ba1d255535661f76cd83d7f2c.tar.gz |
Add more comments
Diff
src/highlight.rs | 2 ++ src/io.rs | 8 ++++++++ src/main.rs | 13 +++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/highlight.rs b/src/highlight.rs index 9bd96c8..e0e5ae1 100644 --- a/src/highlight.rs +++ a/src/highlight.rs @@ -7,6 +7,8 @@ /// Takes the content of a paste and the extension passed in by the viewer and will return the content /// highlighted in the appropriate format in HTML. /// /// Returns `None` if the extension isn't supported. pub fn highlight(content: &str, ext: &str) -> Option<String> { lazy_static! { static ref SS: SyntaxSet = SyntaxSet::load_defaults_newlines(); diff --git a/src/io.rs b/src/io.rs index 7e9a77b..6b6a343 100644 --- a/src/io.rs +++ a/src/io.rs @@ -13,6 +13,8 @@ /// Ensures `ENTRIES` is less than the size of `BIN_BUFFER_SIZE`. If it isn't then /// `ENTRIES.len() - BIN_BUFFER_SIZE` elements will be popped off the front of the map. /// /// During the purge, `ENTRIES` is locked and the current thread will block. fn purge_old() { let entries_len = ENTRIES.read().unwrap().len(); let buffer_size = env::var("BIN_BUFFER_SIZE").map(|f| f.parse::<usize>().unwrap()).unwrap_or(1000usize); @@ -29,6 +31,8 @@ } /// Generates a randomly generated id, stores the given paste under that id and then returns the id. /// /// Uses gpw to generate a (most likely) pronounceable URL. pub fn store_paste(content: String) -> String { thread_local!(static KEYGEN: RefCell<gpw::PasswordGenerator> = RefCell::new(gpw::PasswordGenerator::default())); let id = KEYGEN.with(|k| k.borrow_mut().next().unwrap()); @@ -39,7 +43,9 @@ id } /// Get a paste by id. Returns `None` if the paste doesn't exist. /// Get a paste by id. /// /// Returns `None` if the paste doesn't exist. pub fn get_paste(id: &str) -> Option<String> { ENTRIES.read().unwrap().get(id).cloned() } diff --git a/src/main.rs b/src/main.rs index d1dba56..84361e5 100644 --- a/src/main.rs +++ a/src/main.rs @@ -1,5 +1,4 @@ #![feature(proc_macro_hygiene, decl_macro)] #![feature(uniform_paths)] #![feature(type_alias_enum_variants)] #[macro_use] extern crate lazy_static; @@ -28,6 +27,10 @@ use std::io::Read; /// /// Homepage /// #[derive(Template)] #[template(path = "index.html")] struct Index {} @@ -38,6 +41,10 @@ } /// /// Submit Paste /// #[derive(FromForm)] struct IndexForm { val: String @@ -61,7 +68,11 @@ None => Ok(paste) } } /// /// Show paste page /// #[derive(Template)] #[template(path = "paste.html")]