Refactor build information and add more information #44
This commit is contained in:
parent
990f570a31
commit
88b3df21c2
9 changed files with 39 additions and 10 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -579,7 +579,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sausagewiki"
|
name = "sausagewiki"
|
||||||
version = "0.1.0"
|
version = "0.1.0-dev"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bart 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bart 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bart_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bart_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "sausagewiki"
|
name = "sausagewiki"
|
||||||
version = "0.1.0"
|
version = "0.1.0-dev"
|
||||||
description = "A wiki engine"
|
description = "A wiki engine"
|
||||||
authors = ["Magnus Hoff <maghoff@gmail.com>"]
|
authors = ["Magnus Hoff <maghoff@gmail.com>"]
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
|
|
22
src/build_config.rs
Normal file
22
src/build_config.rs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
pub const PROJECT_NAME: &str = env!("CARGO_PKG_NAME");
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
pub static ref VERSION: String = || -> String {
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
let mut components = Vec::<&'static str>::new();
|
||||||
|
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
components.push("debug");
|
||||||
|
|
||||||
|
if components.len() > 0 {
|
||||||
|
format!("{} ({})", env!("CARGO_PKG_VERSION"), components.join(" "))
|
||||||
|
} else {
|
||||||
|
env!("CARGO_PKG_VERSION").to_string()
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
pub static ref HTTP_SERVER: String =
|
||||||
|
format!("{}/{}", PROJECT_NAME, VERSION.as_str());
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ extern crate titlecase;
|
||||||
use std::net::{IpAddr, SocketAddr};
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
mod assets;
|
mod assets;
|
||||||
|
mod build_config;
|
||||||
mod db;
|
mod db;
|
||||||
mod merge;
|
mod merge;
|
||||||
mod mimes;
|
mod mimes;
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
|
#[macro_use] extern crate lazy_static;
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
extern crate sausagewiki;
|
extern crate sausagewiki;
|
||||||
|
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
|
|
||||||
|
mod build_config;
|
||||||
|
use build_config::*;
|
||||||
|
|
||||||
const DATABASE: &str = "DATABASE";
|
const DATABASE: &str = "DATABASE";
|
||||||
const TRUST_IDENTITY: &str = "trust-identity";
|
const TRUST_IDENTITY: &str = "trust-identity";
|
||||||
const ADDRESS: &str = "address";
|
const ADDRESS: &str = "address";
|
||||||
|
@ -11,8 +15,8 @@ const PORT: &str = "port";
|
||||||
fn args<'a>() -> clap::ArgMatches<'a> {
|
fn args<'a>() -> clap::ArgMatches<'a> {
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
|
|
||||||
App::new(env!("CARGO_PKG_NAME"))
|
App::new(PROJECT_NAME)
|
||||||
.version(env!("CARGO_PKG_VERSION"))
|
.version(VERSION.as_str())
|
||||||
.about(env!("CARGO_PKG_DESCRIPTION"))
|
.about(env!("CARGO_PKG_DESCRIPTION"))
|
||||||
.arg(Arg::with_name(DATABASE)
|
.arg(Arg::with_name(DATABASE)
|
||||||
.help("Sets the database file to use")
|
.help("Sets the database file to use")
|
||||||
|
|
|
@ -3,6 +3,7 @@ use hyper;
|
||||||
use hyper::header::ContentType;
|
use hyper::header::ContentType;
|
||||||
use hyper::server::*;
|
use hyper::server::*;
|
||||||
|
|
||||||
|
use build_config;
|
||||||
use mimes::*;
|
use mimes::*;
|
||||||
use site::Layout;
|
use site::Layout;
|
||||||
use web::{Resource, ResponseFuture};
|
use web::{Resource, ResponseFuture};
|
||||||
|
@ -59,7 +60,7 @@ struct Template<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Template<'a> {
|
impl<'a> Template<'a> {
|
||||||
fn pkg_version(&self) -> &str { env!("CARGO_PKG_VERSION") }
|
fn version(&self) -> &str { &build_config::VERSION }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Resource for AboutResource {
|
impl Resource for AboutResource {
|
||||||
|
|
|
@ -10,13 +10,14 @@ use hyper::server::*;
|
||||||
use hyper;
|
use hyper;
|
||||||
|
|
||||||
use assets::{StyleCss, SearchJs};
|
use assets::{StyleCss, SearchJs};
|
||||||
|
use build_config;
|
||||||
use web::Lookup;
|
use web::Lookup;
|
||||||
use wiki_lookup::WikiLookup;
|
use wiki_lookup::WikiLookup;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref TEXT_HTML: mime::Mime = "text/html;charset=utf-8".parse().unwrap();
|
static ref TEXT_HTML: mime::Mime = "text/html;charset=utf-8".parse().unwrap();
|
||||||
static ref SERVER: Server =
|
static ref SERVER: Server =
|
||||||
Server::new(concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")));
|
Server::new(build_config::HTTP_SERVER.as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
header! { (XIdentity, "X-Identity") => [String] }
|
header! { (XIdentity, "X-Identity") => [String] }
|
||||||
|
@ -33,8 +34,8 @@ impl<'a, T: 'a + fmt::Display> Layout<'a, T> {
|
||||||
pub fn style_css_checksum(&self) -> &str { StyleCss::checksum() }
|
pub fn style_css_checksum(&self) -> &str { StyleCss::checksum() }
|
||||||
pub fn search_js_checksum(&self) -> &str { SearchJs::checksum() }
|
pub fn search_js_checksum(&self) -> &str { SearchJs::checksum() }
|
||||||
|
|
||||||
pub fn pkg_name(&self) -> &str { env!("CARGO_PKG_NAME") }
|
pub fn project_name(&self) -> &str { build_config::PROJECT_NAME }
|
||||||
pub fn pkg_version(&self) -> &str { env!("CARGO_PKG_VERSION") }
|
pub fn version(&self) -> &str { build_config::VERSION.as_str() }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(BartDisplay)]
|
#[derive(BartDisplay)]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
<p>This site is running version {{pkg_version()}} of Sausagewiki, a simple,
|
<p>This site is running version {{version()}} of Sausagewiki, a simple,
|
||||||
self-contained wiki engine.</p>
|
self-contained wiki engine.</p>
|
||||||
<p>Copyright © 2017 Magnus Hovland Hoff.</p>
|
<p>Copyright © 2017 Magnus Hovland Hoff.</p>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{{#base}}<base href="{{.}}">{{/base}}
|
{{#base}}<base href="{{.}}">{{/base}}
|
||||||
<link rel=preload href="_assets/amatic-sc-v9-latin-regular.woff" as=font crossorigin>
|
<link rel=preload href="_assets/amatic-sc-v9-latin-regular.woff" as=font crossorigin>
|
||||||
<link href="_assets/style-{{style_css_checksum()}}.css" rel="stylesheet">
|
<link href="_assets/style-{{style_css_checksum()}}.css" rel="stylesheet">
|
||||||
<meta name="generator" content="{{pkg_name()}} {{pkg_version()}}" />
|
<meta name="generator" content="{{project_name()}} {{version()}}" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{{>search_input.html}}
|
{{>search_input.html}}
|
||||||
|
|
Loading…
Reference in a new issue