shaman-website-compiler
Version:
Compile raw HTML, CSS and Javascript into the smallest possible, SEO friendly website.
47 lines • 2.18 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddTextHandler = void 0;
var event_handler_1 = require("./event-handler");
var app_composition_1 = require("../composition/app.composition");
var AddTextHandler = /** @class */ (function (_super) {
__extends(AddTextHandler, _super);
function AddTextHandler() {
var _this = _super.call(this) || this;
_this.event = 'file-added';
_this.processEvent = function (file) {
return _this.updateFileText(file).then(function (_) {
_this.logger.log("Text has been updated for file '".concat(file.name, "'."));
_this.eventService.publish('file-contents-added', file);
});
};
_this.updateFileText = function (file) {
return _this.fileImportService.importFileText(file).then(function (rslt) {
_this.context.models.files.update(file.name, (function (file) {
file.text = rslt.text;
return file;
}));
return _this.context.saveChanges();
});
};
_this.fileImportService = app_composition_1.IoC.get(app_composition_1.TYPES.FileImportService);
return _this;
}
return AddTextHandler;
}(event_handler_1.EventHandler));
exports.AddTextHandler = AddTextHandler;
//# sourceMappingURL=add-text.handler.js.map