1 module uim.vue.apps.app; 2 3 import uim.vue; 4 5 @safe: 6 7 class DVUEApp : DH5App { 8 this() { super(); } 9 this(string aName) { this().name(aName); } 10 this(string aName, string aRootPath) { this().name(aName).rootPath(aRootPath); } 11 12 O imports(this O)(DVUEComponent aComponent) { components(aComponent); return cast(O)this; } 13 O imports(this O)(DVUEMixin aMixin) { mixins(aMixin); return cast(O)this; } 14 O imports(this O)(DVUEModule aModule) { modules(aModule); return cast(O)this; } 15 16 private DVUEComponent[string] _components; 17 18 auto component(string name) { if (name in _components) return _components[name]; return null; } 19 20 auto components() { return _components; } 21 auto components(string[] names...) { return components(names); } 22 auto components(string[] names) { DVUEComponent[string] results; /* = this.components.select(names); */ return results; } 23 24 O components(this O)(DVUEComponent newComponent) { this.components(newComponent.app(this).name, newComponent); return cast(O)this; } 25 O components(this O)(string name, string newComponent) { return this.components(name, VUEComponent(this).content(newComponent)); } 26 O components(this O)(string name, DVUEComponent newComponent) { 27 newComponent.app(this); 28 _components[name] = newComponent; 29 return cast(O)this; 30 } 31 32 /* DVUEModule[string] _modules; 33 auto modules() { return _modules; } 34 O modules(this O)(string[string] newModules) { foreach(name, mod; newModules) this.modules(name, VUEModule(this).content(mod)); return cast(O)this; } 35 O modules(this O)(DVUEModule[string] newModules) { foreach(name, mod; newModules) this.modules(name, VUEModule(this).content(mod)); return cast(O)this; } 36 O modules(this O)(string name, string newModule) { return this.modules(name, VUEModule(this).content(newnewModuleontent)); } 37 O modules(this O)(string name, DVUEModule newModule) { 38 newModule.app(this); 39 _modules[name] = newModule; 40 return cast(O)this; 41 } 42 */ unittest { 43 /// TODO 44 } 45 46 /* 47 } 48 if (pathItems.length == 2) { 49 auto type = pathItems[0]; 50 // debug writeln("[IN APP] My type is ", type); 51 auto name = pathItems[1]; 52 // debug writeln("[IN APP] My path is ", name); 53 switch (type) 54 { 55 case "component": 56 if (name in _components) 57 _components[name].request(req, res); 58 break; 59 case "css": 60 break; 61 case "img": 62 break; 63 case "js": 64 break; 65 case "mixin": 66 if (name in _mixins) 67 _mixins[name].request(req, res); 68 break; 69 case "module": 70 if (name in _modules) 71 _modules[name].request(req, res); 72 break; 73 case "page": 74 // debug writeln("It's a page"); 75 if (name in _pages) 76 _pages[name].request(req, res); 77 break; 78 default: 79 break; 80 } 81 }*/ 82 } 83 auto VUEApp() { return new DVUEApp(); } 84 auto VUEApp(string aName) { return new DVUEApp(aName); } 85 auto VUEApp(string aName, string aRootPath) { return new DVUEApp(aName, aRootPath); } 86 87 unittest { 88 } 89 90