| 1 |
package website; |
| 2 |
|
| 3 |
import haxelib.server.SiteDb; |
| 4 |
import mcli.Dispatch; |
| 5 |
import ufront.api.UFApi; |
| 6 |
import ufront.tasks.UFTaskSet; |
| 7 |
import ufront.auth.*; |
| 8 |
import ufront.auth.tasks.EasyAuthTasks; |
| 9 |
import ufront.auth.EasyAuth; |
| 10 |
import ufront.web.session.*; |
| 11 |
import website.tasks.*; |
| 12 |
using ufront.core.InjectionTools; |
| 13 |
|
| 14 |
class Tasks extends UFTaskSet |
| 15 |
{ |
| 16 |
/** |
| 17 |
The CLI runner. |
| 18 |
**/ |
| 19 |
static function main() { |
| 20 |
// Only access the command line runner from the command line, not the web. |
| 21 |
if ( !neko.Web.isModNeko ) { |
| 22 |
|
| 23 |
// This is an auth system that lets you do anything regardless of permissions, handy for CLI tools |
| 24 |
var auth = new EasyAuthAdminMode(); |
| 25 |
|
| 26 |
var tasks = new Tasks(); |
| 27 |
tasks.injector.map( UFHttpSession ).toValue( new VoidSession() ); |
| 28 |
tasks.injector.map( UFAuthHandler ).toValue( auth ); |
| 29 |
tasks.injector.map( EasyAuth ).toValue( auth ); |
| 30 |
tasks.injector.map( String, "contentDirectory" ).toValue( "../uf-content" ); |
| 31 |
tasks.useCLILogging( "log/twl-webapp.log" ); |
| 32 |
|
| 33 |
// Inject our APIs |
| 34 |
for ( api in CompileTime.getAllClasses(UFApi) ) |
| 35 |
tasks.injector.mapRuntimeTypeOf( api ); |
| 36 |
|
| 37 |
SiteDb.init(); |
| 38 |
tasks.execute( Sys.args() ); |
| 39 |
SiteDb.cleanup(); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
Easyauth task set |
| 45 |
@alias a |
| 46 |
**/ |
| 47 |
public function auth( d:Dispatch ) { |
| 48 |
executeSubTasks( d, EasyAuthTasks ); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
DBCache task set |
| 53 |
@alias c |
| 54 |
**/ |
| 55 |
public function cache( d:Dispatch ) { |
| 56 |
executeSubTasks( d, HaxelibCacheTasks ); |
| 57 |
} |
| 58 |
} |