@@ 23,6 23,7 @@ ushort PORT = 80 ;
string FRIENDLYNAME = "KB Web UI" ;
bool LIGHTTHEME = false ;
string SERVER = "localhost:8000" ;
+string STATICDIR = "./static" ;
int main( string[] args ) {
// read config
@@ 46,24 47,22 @@ int main( string[] args ) {
if ( isFile( CONFFILE ) ) { readconf( CONFFILE.readText() ) ; }
// display config options on startup
- writeln( " Port : " , PORT ) ;
- writeln( " Friendly name : " , FRIENDLYNAME ) ;
- writeln( "Use light theme : " , LIGHTTHEME ) ;
- writeln( " API server : " , SERVER ) ;
+ writeln( " Port : " , PORT ) ;
+ writeln( " Friendly name : " , FRIENDLYNAME ) ;
+ writeln( " Use light theme : " , LIGHTTHEME ) ;
+ writeln( " API server : " , SERVER ) ;
+ writeln( "Static content dir : " , STATICDIR ) ;
Server server = new Server() ;
server.host( "0.0.0.0" , PORT ) ;
server.host( "::" , PORT ) ;
server.router.add( new router() ) ;
- server.router.add( Get( "global.css" ) ,
- new Resource( "text/css" ,
- readText( "static/global.css" ) ) ) ;
- server.router.add( Get( "light.css" ) ,
- new Resource( "text/css" ,
- readText( "static/light.css" ) ) ) ;
- server.router.add( Get( "dark.css" ) ,
- new Resource( "text/css" ,
- readText( "static/dark.css" ) ) ) ;
+ server.router.add( Get( "global.css" ) , new Resource( "text/css" ,
+ readText( buildPath( STATICDIR , "global.css" ) ) ) ) ;
+ server.router.add( Get( "light.css" ) , new Resource( "text/css" ,
+ readText( buildPath( STATICDIR , "light.css" ) ) ) ) ;
+ server.router.add( Get( "dark.css" ) , new Resource( "text/css" ,
+ readText( buildPath( STATICDIR , "dark.css" ) ) ) ) ;
server.run() ;
return 0 ;
}
@@ 78,6 77,7 @@ void readconf( string content ) {
LIGHTTHEME = j["light-theme"].boolean ;
}
if ( ( "server" in j ) !is null ) { SERVER = j["server"].str ; }
+ if ( ( "static-dir" in j ) !is null ) { STATICDIR = j["static-dir"].str ; }
}
string fmtdate( long ts ) {
@@ 1,11 0,0 @@
-<!DOCTYPE html>
-<head>
- <meta charset="utf-8">
- <link rel="stylesheet" type="text/css" href="/global.css">
- <title>Error</title>
-</head>
-<body>
- <h1>Oh no</h1>
- The API server didn't send back the right information. Check the API server
- is up and kb-web is pointing at it.
-</body>