diff --git a/src/main.rs b/src/main.rs index c6d99d6..aa25480 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,7 +76,7 @@ fn core_main() -> Result<(), Box> { let cpu_pool = futures_cpupool::CpuPool::new_num_cpus(); let state = state::State::new(db_pool, cpu_pool); - let lookup = wiki_lookup::WikiLookup::new(state); + let lookup = wiki_lookup::WikiLookup::new(state, trust_identity); let server = hyper::server::Http::new() diff --git a/src/resources/changes_resource.rs b/src/resources/changes_resource.rs index e8e2b1f..0f3ef6c 100644 --- a/src/resources/changes_resource.rs +++ b/src/resources/changes_resource.rs @@ -22,6 +22,7 @@ type BoxResource = Box; #[derive(Clone)] pub struct ChangesLookup { state: State, + show_authors: bool, } #[derive(Serialize, Deserialize, Default)] @@ -91,14 +92,15 @@ fn apply_query_config<'a>( } impl ChangesLookup { - pub fn new(state: State) -> ChangesLookup { - Self { state } + pub fn new(state: State, show_authors: bool) -> ChangesLookup { + Self { state, show_authors } } pub fn lookup(&self, query: Option<&str>) -> Box, Error=::web::Error>> { use super::pagination; let state = self.state.clone(); + let show_authors = self.show_authors; Box::new( done((|| { @@ -153,8 +155,8 @@ impl ChangesLookup { })) })) as Box, Error=::web::Error>> }, - Pagination::Before(x) => Box::new(finished(Some(Box::new(ChangesResource::new(state, Some(x), article_id, author, limit)) as BoxResource))), - Pagination::None => Box::new(finished(Some(Box::new(ChangesResource::new(state, None, article_id, author, limit)) as BoxResource))), + Pagination::Before(x) => Box::new(finished(Some(Box::new(ChangesResource::new(state, show_authors, Some(x), article_id, author, limit)) as BoxResource))), + Pagination::None => Box::new(finished(Some(Box::new(ChangesResource::new(state, show_authors, None, article_id, author, limit)) as BoxResource))), }) ) } @@ -162,6 +164,7 @@ impl ChangesLookup { pub struct ChangesResource { state: State, + show_authors: bool, before: Option, article_id: Option, author: Option, @@ -169,8 +172,8 @@ pub struct ChangesResource { } impl ChangesResource { - pub fn new(state: State, before: Option, article_id: Option, author: Option, limit: i32) -> Self { - Self { state, before, article_id, author, limit } + pub fn new(state: State, show_authors: bool, before: Option, article_id: Option, author: Option, limit: i32) -> Self { + Self { state, show_authors, before, article_id, author, limit } } fn query_args(&self) -> QueryParameters { @@ -235,6 +238,7 @@ impl Resource for ChangesResource { struct Template<'a> { resource: &'a ChangesResource, + show_authors: bool, newer: Option, older: Option, changes: &'a [Row<'a>], @@ -339,6 +343,7 @@ impl Resource for ChangesResource { title: "Changes", body: &Template { resource: &self, + show_authors: self.show_authors, newer, older, changes diff --git a/src/state.rs b/src/state.rs index f463056..3063db2 100644 --- a/src/state.rs +++ b/src/state.rs @@ -57,9 +57,11 @@ fn decide_slug(conn: &SqliteConnection, article_id: i32, prev_title: &str, title } } + let base_slug = if base_slug.is_empty() { "article" } else { &base_slug }; + use schema::article_revisions; - let mut slug = base_slug.clone(); + let mut slug = base_slug.to_owned(); let mut disambiguator = 1; loop { diff --git a/src/wiki_lookup.rs b/src/wiki_lookup.rs index bf00c2e..24a916e 100644 --- a/src/wiki_lookup.rs +++ b/src/wiki_lookup.rs @@ -76,8 +76,8 @@ fn asset_lookup(path: &str) -> FutureResult, Box<::std::erro } impl WikiLookup { - pub fn new(state: State) -> WikiLookup { - let changes_lookup = ChangesLookup::new(state.clone()); + pub fn new(state: State, show_authors: bool) -> WikiLookup { + let changes_lookup = ChangesLookup::new(state.clone(), show_authors); let search_lookup = SearchLookup::new(state.clone()); WikiLookup { state, changes_lookup, search_lookup } diff --git a/templates/changes.html b/templates/changes.html index 43515fb..733c50b 100644 --- a/templates/changes.html +++ b/templates/changes.html @@ -5,7 +5,7 @@

- These are the {{^newer}}most recent{{/newer}} changes that have been + These are the {{^newer}}most recent{{/newer}} changes made to{{{subject_clause()}}}{{#author()}} by {{.}}{{/author()}}.

@@ -23,14 +23,14 @@ Article Updated - Author + {{#show_authors?}}Author{{/show_authors}} {{/changes}} {{#changes}} {{.title}} {{.created}} - {{#.author}}{{.}}{{/.author}}{{^.author}}Anonymous{{/.author}} + {{#show_authors?}}{{#..author}}{{.}}{{/..author}}{{^..author}}Anonymous{{/..author}}{{/show_authors}} {{/changes}}