diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2018-04-18 15:42:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-18 15:42:27 +0200 |
commit | 51205af6689fea68944f26ad327d5eec1baa6aed (patch) | |
tree | 3cceaef2ce44259ec28773c0a264667553d43a62 /lib/domain/libimagwiki/src | |
parent | 95d3fbebccd18db50fbe4d9a61a5a2baf1731a7a (diff) | |
parent | 962b5fffd84bc8b919d369c2a8cf7d3efbfa616c (diff) |
Merge pull request #1400 from matthiasbeyer/imag-wiki/init
imag-wiki: init
Diffstat (limited to 'lib/domain/libimagwiki/src')
-rw-r--r-- | lib/domain/libimagwiki/src/store.rs | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/lib/domain/libimagwiki/src/store.rs b/lib/domain/libimagwiki/src/store.rs index 36106761..7113aa17 100644 --- a/lib/domain/libimagwiki/src/store.rs +++ b/lib/domain/libimagwiki/src/store.rs @@ -29,10 +29,10 @@ pub trait WikiStore { fn get_wiki<'a, 'b>(&'a self, name: &'b str) -> Result<Option<Wiki<'a, 'b>>>; - fn create_wiki<'a, 'b>(&'a self, name: &'b str, mainpagename: Option<&str>) + fn create_wiki<'a, 'b>(&'a self, name: &'b str) -> Result<Wiki<'a, 'b>>; - fn retrieve_wiki<'a, 'b>(&'a self, name: &'b str, mainpagename: Option<&str>) + fn retrieve_wiki<'a, 'b>(&'a self, name: &'b str) -> Result<Wiki<'a, 'b>>; } @@ -56,31 +56,23 @@ impl WikiStore for Store { /// /// Returns the Wiki object. /// - /// Ob success, an empty Wiki entry with the name `mainpagename` (or "main" if none is passed) - /// is created inside the wiki. + /// Ob success, an empty Wiki entry with the name `index` is created inside the wiki. Later, new + /// entries are automatically linked to this entry. /// - fn create_wiki<'a, 'b>(&'a self, name: &'b str, mainpagename: Option<&str>) - -> Result<Wiki<'a, 'b>> - { + fn create_wiki<'a, 'b>(&'a self, name: &'b str) -> Result<Wiki<'a, 'b>> { debug!("Trying to get wiki '{}'", name); - debug!("Trying to create wiki '{}' with mainpage: '{:?}'", name, mainpagename); let wiki = Wiki::new(self, name); let _ = wiki.create_index_page()?; - - wiki.create_entry(mainpagename.unwrap_or("main")) - .map(|_| wiki) + Ok(wiki) } - fn retrieve_wiki<'a, 'b>(&'a self, name: &'b str, mainpagename: Option<&str>) + fn retrieve_wiki<'a, 'b>(&'a self, name: &'b str) -> Result<Wiki<'a, 'b>> { match self.get_wiki(name)? { - None => self.create_wiki(name, mainpagename), - Some(wiki) => { - let _ = wiki.retrieve_entry(mainpagename.unwrap_or("main"))?; // to make sure the page exists - Ok(wiki) - } + None => self.create_wiki(name), + Some(wiki) => Ok(wiki), } } |