Remove notion of "main page"
This commit is contained in:
parent
8ea3f62fbc
commit
adede7bf26
1 changed files with 9 additions and 17 deletions
|
@ -29,10 +29,10 @@ pub trait WikiStore {
|
||||||
|
|
||||||
fn get_wiki<'a, 'b>(&'a self, name: &'b str) -> Result<Option<Wiki<'a, 'b>>>;
|
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>>;
|
-> 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>>;
|
-> Result<Wiki<'a, 'b>>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,31 +56,23 @@ impl WikiStore for Store {
|
||||||
///
|
///
|
||||||
/// Returns the Wiki object.
|
/// Returns the Wiki object.
|
||||||
///
|
///
|
||||||
/// Ob success, an empty Wiki entry with the name `mainpagename` (or "main" if none is passed)
|
/// Ob success, an empty Wiki entry with the name `index` is created inside the wiki. Later, new
|
||||||
/// is created inside the wiki.
|
/// entries are automatically linked to this entry.
|
||||||
///
|
///
|
||||||
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>> {
|
||||||
-> Result<Wiki<'a, 'b>>
|
|
||||||
{
|
|
||||||
debug!("Trying to get wiki '{}'", name);
|
debug!("Trying to get wiki '{}'", name);
|
||||||
debug!("Trying to create wiki '{}' with mainpage: '{:?}'", name, mainpagename);
|
|
||||||
|
|
||||||
let wiki = Wiki::new(self, name);
|
let wiki = Wiki::new(self, name);
|
||||||
let _ = wiki.create_index_page()?;
|
let _ = wiki.create_index_page()?;
|
||||||
|
Ok(wiki)
|
||||||
wiki.create_entry(mainpagename.unwrap_or("main"))
|
|
||||||
.map(|_| 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>>
|
-> Result<Wiki<'a, 'b>>
|
||||||
{
|
{
|
||||||
match self.get_wiki(name)? {
|
match self.get_wiki(name)? {
|
||||||
None => self.create_wiki(name, mainpagename),
|
None => self.create_wiki(name),
|
||||||
Some(wiki) => {
|
Some(wiki) => Ok(wiki),
|
||||||
let _ = wiki.retrieve_entry(mainpagename.unwrap_or("main"))?; // to make sure the page exists
|
|
||||||
Ok(wiki)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue