Optionally show authors in _changes based on --trust-identity command line argument.
This fixes #19
This commit is contained in:
parent
ef4a3e689b
commit
4ca748f180
5 changed files with 20 additions and 13 deletions
|
@ -76,7 +76,7 @@ fn core_main() -> Result<(), Box<std::error::Error>> {
|
||||||
let cpu_pool = futures_cpupool::CpuPool::new_num_cpus();
|
let cpu_pool = futures_cpupool::CpuPool::new_num_cpus();
|
||||||
|
|
||||||
let state = state::State::new(db_pool, cpu_pool);
|
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 =
|
let server =
|
||||||
hyper::server::Http::new()
|
hyper::server::Http::new()
|
||||||
|
|
|
@ -22,6 +22,7 @@ type BoxResource = Box<Resource + Sync + Send>;
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ChangesLookup {
|
pub struct ChangesLookup {
|
||||||
state: State,
|
state: State,
|
||||||
|
show_authors: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Default)]
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
|
@ -91,14 +92,15 @@ fn apply_query_config<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChangesLookup {
|
impl ChangesLookup {
|
||||||
pub fn new(state: State) -> ChangesLookup {
|
pub fn new(state: State, show_authors: bool) -> ChangesLookup {
|
||||||
Self { state }
|
Self { state, show_authors }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lookup(&self, query: Option<&str>) -> Box<Future<Item=Option<BoxResource>, Error=::web::Error>> {
|
pub fn lookup(&self, query: Option<&str>) -> Box<Future<Item=Option<BoxResource>, Error=::web::Error>> {
|
||||||
use super::pagination;
|
use super::pagination;
|
||||||
|
|
||||||
let state = self.state.clone();
|
let state = self.state.clone();
|
||||||
|
let show_authors = self.show_authors;
|
||||||
|
|
||||||
Box::new(
|
Box::new(
|
||||||
done((|| {
|
done((|| {
|
||||||
|
@ -153,8 +155,8 @@ impl ChangesLookup {
|
||||||
}))
|
}))
|
||||||
})) as Box<Future<Item=Option<BoxResource>, Error=::web::Error>>
|
})) as Box<Future<Item=Option<BoxResource>, Error=::web::Error>>
|
||||||
},
|
},
|
||||||
Pagination::Before(x) => Box::new(finished(Some(Box::new(ChangesResource::new(state, Some(x), 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, None, 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 {
|
pub struct ChangesResource {
|
||||||
state: State,
|
state: State,
|
||||||
|
show_authors: bool,
|
||||||
before: Option<i32>,
|
before: Option<i32>,
|
||||||
article_id: Option<i32>,
|
article_id: Option<i32>,
|
||||||
author: Option<String>,
|
author: Option<String>,
|
||||||
|
@ -169,8 +172,8 @@ pub struct ChangesResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChangesResource {
|
impl ChangesResource {
|
||||||
pub fn new(state: State, before: Option<i32>, article_id: Option<i32>, author: Option<String>, limit: i32) -> Self {
|
pub fn new(state: State, show_authors: bool, before: Option<i32>, article_id: Option<i32>, author: Option<String>, limit: i32) -> Self {
|
||||||
Self { state, before, article_id, author, limit }
|
Self { state, show_authors, before, article_id, author, limit }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn query_args(&self) -> QueryParameters {
|
fn query_args(&self) -> QueryParameters {
|
||||||
|
@ -235,6 +238,7 @@ impl Resource for ChangesResource {
|
||||||
struct Template<'a> {
|
struct Template<'a> {
|
||||||
resource: &'a ChangesResource,
|
resource: &'a ChangesResource,
|
||||||
|
|
||||||
|
show_authors: bool,
|
||||||
newer: Option<NavLinks>,
|
newer: Option<NavLinks>,
|
||||||
older: Option<NavLinks>,
|
older: Option<NavLinks>,
|
||||||
changes: &'a [Row<'a>],
|
changes: &'a [Row<'a>],
|
||||||
|
@ -339,6 +343,7 @@ impl Resource for ChangesResource {
|
||||||
title: "Changes",
|
title: "Changes",
|
||||||
body: &Template {
|
body: &Template {
|
||||||
resource: &self,
|
resource: &self,
|
||||||
|
show_authors: self.show_authors,
|
||||||
newer,
|
newer,
|
||||||
older,
|
older,
|
||||||
changes
|
changes
|
||||||
|
|
|
@ -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;
|
use schema::article_revisions;
|
||||||
|
|
||||||
let mut slug = base_slug.clone();
|
let mut slug = base_slug.to_owned();
|
||||||
let mut disambiguator = 1;
|
let mut disambiguator = 1;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -76,8 +76,8 @@ fn asset_lookup(path: &str) -> FutureResult<Option<BoxResource>, Box<::std::erro
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WikiLookup {
|
impl WikiLookup {
|
||||||
pub fn new(state: State) -> WikiLookup {
|
pub fn new(state: State, show_authors: bool) -> WikiLookup {
|
||||||
let changes_lookup = ChangesLookup::new(state.clone());
|
let changes_lookup = ChangesLookup::new(state.clone(), show_authors);
|
||||||
let search_lookup = SearchLookup::new(state.clone());
|
let search_lookup = SearchLookup::new(state.clone());
|
||||||
|
|
||||||
WikiLookup { state, changes_lookup, search_lookup }
|
WikiLookup { state, changes_lookup, search_lookup }
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
<p>
|
<p>
|
||||||
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()}}.
|
made to{{{subject_clause()}}}{{#author()}} by {{.}}{{/author()}}.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -23,14 +23,14 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>Article</th>
|
<th>Article</th>
|
||||||
<th>Updated</th>
|
<th>Updated</th>
|
||||||
<th>Author</th>
|
{{#show_authors?}}<th>Author</th>{{/show_authors}}
|
||||||
</tr>
|
</tr>
|
||||||
{{/changes}}
|
{{/changes}}
|
||||||
{{#changes}}
|
{{#changes}}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="_revisions/{{.article_id}}/{{.revision}}">{{.title}}</a></td>
|
<td><a href="_revisions/{{.article_id}}/{{.revision}}">{{.title}}</a></td>
|
||||||
<td>{{.created}}</td>
|
<td>{{.created}}</td>
|
||||||
<td>{{#.author}}<a href="{{..author_link()}}">{{.}}</a>{{/.author}}{{^.author}}<i>Anonymous</i>{{/.author}}</td>
|
{{#show_authors?}}<td>{{#..author}}<a href="{{...author_link()}}">{{.}}</a>{{/..author}}{{^..author}}<i>Anonymous</i>{{/..author}}</td>{{/show_authors}}
|
||||||
</tr>
|
</tr>
|
||||||
{{/changes}}
|
{{/changes}}
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in a new issue