add "news" URL to server list page

main
_ 2021-04-27 14:10:11 -05:00
parent 633a2356b9
commit b659d6b74f
4 changed files with 27 additions and 9 deletions

3
.gitconfig Normal file
View File

@ -0,0 +1,3 @@
[user]
name = _
email = _@_

View File

@ -66,6 +66,8 @@ pub mod file {
// Adding a DB will take a while, so I'm moving these out of dev mode.
pub scraper_keys: Option <Vec <ScraperKey <Valid30Days>>>,
pub news_url: Option <String>,
}
}
@ -77,6 +79,7 @@ pub struct Config {
pub port: Option <u16>,
pub servers: HashMap <String, file::Server>,
pub scraper_keys: HashMap <String, ScraperKey <Valid30Days>>,
pub news_url: Option <String>,
}
impl TryFrom <file::Config> for Config {
@ -101,6 +104,7 @@ impl TryFrom <file::Config> for Config {
port: f.port,
servers,
scraper_keys,
news_url: f.news_url.clone (),
})
}
}

View File

@ -269,6 +269,7 @@ struct ServerListPage <'a> {
dev_mode: bool,
git_version: Option <String>,
servers: Vec <ServerEntry <'a>>,
news_url: Option <String>,
}
#[derive (Serialize)]
@ -288,17 +289,19 @@ struct AuditLogPage {
audit_log: Vec <String>,
}
async fn handle_server_list_internal (state: &Arc <Relay>)
-> ServerListPage <'static>
{
use LastSeen::*;
let dev_mode = {
let dev_mode;
let news_url;
{
let guard = state.config.read ().await;
guard.iso.dev_mode.is_some ()
};
dev_mode = guard.iso.dev_mode.is_some ();
news_url = guard.news_url.clone ();
}
let git_version = git_version::read ().await;
let server_list = scraper_api::v1_server_list (&state).await;
@ -328,6 +331,7 @@ async fn handle_server_list_internal (state: &Arc <Relay>)
dev_mode,
git_version,
servers,
news_url,
}
}

View File

@ -44,11 +44,10 @@ AIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAA" rel="icon" type="image/x-icon" />
<div style="color: red;">Relay is in dev mode. This should never be seen in production!</div>
{{/if}}
{{#if news_url}}
<p>
<a href="../unregistered_servers">Unregistered servers</a>
<p>
<a href="../audit_log">Audit log</a>
<a href="{{news_url}}">News</a>
{{/if}}
<div style="padding-top: 1em;">
{{#if servers}}
@ -75,6 +74,14 @@ AIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAA" rel="icon" type="image/x-icon" />
{{/if}}
</div>
<h2>Admin</h2>
<p>
<a href="../unregistered_servers">Unregistered servers</a>
<p>
<a href="../audit_log">Audit log</a>
<div style="color: #888; padding-top: 1em;">
{{#if git_version}}
Git version: {{git_version}}