Esempio n. 1
0
        //convert GopherText to GMI and save to outpath
        public static Tuple <int, string, string> GophertoGmi(string gopherPath, string outPath, string uri, GopherParseTypes parseType)
        {
            var appDir = System.AppDomain.CurrentDomain.BaseDirectory;
            var finder = new ResourceFinder();

            var parseScript = (parseType == GopherParseTypes.Map) ? "GophermapToGmi.r3" : "GophertextToGmi.r3";

            //allow for rebol and converters to be in sub folder of exe (e.g. when deployed)
            //otherwise we use the development ones which are version controlled
            var rebolPath  = finder.LocalOrDevFile(appDir, @"Rebol", @"..\..\Rebol", "r3-core.exe");
            var scriptPath = finder.LocalOrDevFile(appDir, @"GmiConverters", @"..\..\GmiConverters", parseScript);

            //due to bug in rebol 3 at the time of writing (mid 2020) there is a known bug in rebol 3 in
            //working with command line parameters, so we need to escape quotes
            //see https://stackoverflow.com/questions/6721636/passing-quoted-arguments-to-a-rebol-3-script
            //also hypens are also problematic, so we base64 each parameter and unpack it in the script
            var command = String.Format("\"{0}\" -cs \"{1}\" \"{2}\" \"{3}\" \"{4}\" ",
                                        rebolPath,
                                        scriptPath,
                                        Base64Service.Base64Encode(gopherPath),
                                        Base64Service.Base64Encode(outPath),
                                        Base64Service.Base64Encode(uri)

                                        );

            var execProcess = new ExecuteProcess();

            var result = execProcess.ExecuteCommand(command);

            return(result);
        }
Esempio n. 2
0
        //convert GMI to HTML for display and save to outpath
        public static Tuple <int, string, string> GmiToHtml(string gmiPath, string outPath, string uri, SiteIdentity siteIdentity, string theme, bool showWebHeader)
        {
            var appDir = AppDomain.CurrentDomain.BaseDirectory;

            //allow for rebol and converters to be in sub folder of exe (e.g. when deployed)
            //otherwise we use the development ones which are version controlled
            var rebolPath  = ResourceFinder.LocalOrDevFile(appDir, @"Rebol", @"..\..\..\Rebol", "r3-core.exe");
            var scriptPath = ResourceFinder.LocalOrDevFile(appDir, @"GmiConverters", @"..\..\..\GmiConverters", "GmiToHtml.r3");

            var identiconUri = new Uri(siteIdentity.IdenticonImagePath());
            var fabricUri    = new Uri(siteIdentity.FabricImagePath());

            //due to bug in rebol 3 at the time of writing (mid 2020) there is a known bug in rebol 3 in
            //working with command line parameters, so we need to escape quotes
            //see https://stackoverflow.com/questions/6721636/passing-quoted-arguments-to-a-rebol-3-script
            //also hypens are also problematic, so we base64 each param and unpack in the script
            var command = string.Format("\"{0}\" -cs \"{1}\" \"{2}\" \"{3}\" \"{4}\" \"{5}\" \"{6}\" \"{7}\" \"{8}\" \"{9}\" \"{10}\" ",
                                        rebolPath,
                                        scriptPath,
                                        Base64Service.Base64Encode(gmiPath),
                                        Base64Service.Base64Encode(outPath),
                                        Base64Service.Base64Encode(uri),
                                        Base64Service.Base64Encode(theme),
                                        Base64Service.Base64Encode(identiconUri.AbsoluteUri),
                                        Base64Service.Base64Encode(fabricUri.AbsoluteUri),
                                        Base64Service.Base64Encode(siteIdentity.GetId()),
                                        Base64Service.Base64Encode(siteIdentity.GetSiteId()),
                                        Base64Service.Base64Encode(showWebHeader ? "true" : "false"));

            var result = ExecuteProcess.ExecuteCommand(command);

            return(result);
        }