Example #1
0
        public string Generate(IArguments arguments)
        {
            var contentsDiv = arguments.GetArgumentOrThrow <string>("ContentsDiv");
            var targetDiv   = arguments.GetArgumentOrThrow <string>("TargetDiv");

            StringBuilder writer = new StringBuilder();

            var pagetoc = ResourceHandler.GetFile(KnownFile.PageTocJs);

            var code = pagetoc.Replace("{{contents}}", contentsDiv).Replace("{{target}}", targetDiv);

            return(writer.WriteJavaScript(code).ToString());
        }
Example #2
0
        public string Generate(IArguments arguments)
        {
            var file = arguments.GetArgumentOrThrow <string>("file");

            var path = _settings.OutputDirectory.Combine(file);

            file = _settings.Configuration.HostName + file;

            var sri = ComputeSRI(path);

            if (path.Extension == ".js")
            {
                _log.Detail("Creating SRI script tag for: {0}", path);
                return($"<script src=\"{file}\" integrity=\"{sri}\" crossorigin=\"anonymous\"></script>");
            }
            else if (path.Extension == ".css")
            {
                _log.Detail("Creating SRI css tag for: {0}", path);
                return($"<link rel=\"stylesheet\" href=\"{file}\" integrity=\"{sri}\" crossorigin=\"anonymous\"/>");
            }
            else
            {
                _log.Warning("Unsupprted file type for SRI linking: {0}", path.Extension);
            }

            return(string.Empty);
        }
Example #3
0
        public string Generate(IArguments arguments)
        {
            var file = arguments.GetArgumentOrThrow <string>("file");

            _log.Info("Trying to execute PHP CGI script: {0} ...", file);

            return(ExecuteScriptProcess("php-cgi", _appSetting.PhpPath, file, _appSetting.PhpTimeout));
        }
Example #4
0
        public string Generate(IArguments arguments)
        {
            var file = arguments.GetArgumentOrThrow <string>("file");

            _log.Info("Trying to execute NoseJs script: {0} ...", file);

            return(ExecuteScriptProcess("node", _appSetting.NodeJsPath, file, _appSetting.NodeJsTimeout));
        }
Example #5
0
        public string Generate(IArguments arguments)
        {
            var name = arguments.GetArgumentOrThrow <string>("file");

            FsPath file = new FsPath(name);

            _log.Detail("Inlineing {0}...", file);

            return(file.ReadFile(_log));
        }
Example #6
0
        public string Generate(IArguments arguments)
        {
            var file = new FsPath(arguments.GetArgumentOrThrow <string>("file"));

            _log.Info("Trying to execute {0}", file);

            var nodeProgram = ProcessInterop.AppendExecutableExtension(processName);

            string?programPath = ProcessInterop.ResolveProgramFullPath(nodeProgram);

            if (programPath == null)
            {
                _log.Warning("{0} was not found on path.", processName);
                return($"{processName} was not found on path");
            }

            StringBuilder script = new StringBuilder(16 * 1024);

            script.AppendLine(SerializeHostInfo());
            script.AppendLine(file.ReadFile(_log));

            var temp = new FsPath(Path.GetTempFileName());

            temp.WriteFile(_log, script.ToString());

            var(exitcode, output) = ProcessInterop.RunProcess("node", temp.ToString(), ScriptTimeOut);

            if (temp.IsExisting)
            {
                File.Delete(temp.ToString());
            }

            if (exitcode != 0)
            {
                _log.Warning("Script run failed. Exit code: {0}", exitcode);
                _log.Detail("Script output: {0}", output);
                return($"Script run failed: {temp}");
            }
            else
            {
                return(output);
            }
        }
 public string Generate(IArguments arguments)
 {
     return(arguments.GetArgumentOrThrow <string>("parameter"));
 }