Exemple #1
0
 public void CreateSpaceButtonMacroTest()
 {
     CreateSpaceButtonMacroConverter buttonConverter = new CreateSpaceButtonMacroConverter();
     Macro testMacro = new Macro("{create-space-button}");
     string convertedMacro = buttonConverter.ConvertMacro(null, testMacro, null);
     Assert.That(convertedMacro, Is.EqualTo("{{wiki.create()}}"));
 }
Exemple #2
0
 public void FavPagesMacroTest()
 {
     FavPagesMacroConverter converter = new FavPagesMacroConverter();
     Macro testMacro = new Macro("{favpages}");
     string convertedMacro = converter.ConvertMacro(null, testMacro, null);
     Assert.That(convertedMacro, Is.EqualTo("{{favPages();}}"));
 }
Exemple #3
0
        public override string ConvertMacro(Dictionary<string, string> pathMap, Macro macro, ACConverterPageInfo pageInfo)
        {
            int max = Utils.MAXRESULTS;
            bool result = false;
            string dekiMacro = "";

            if (macro != null)
            {
                if (macro.Arguments.Keys.Contains("max"))
                {
                    result = int.TryParse(macro.Arguments["max"], out max);
                }

                //string treePath = Utils.GetTopLevelPage(pageInfo.DekiPagePath);

                if (macro.Arguments.Keys.Contains("url"))
                {
                    if (result)
                    {
                        // There was a max
                        dekiMacro = "{{ feed.list(\"" + macro.Arguments["url"] + "\", " + max.ToString() + ") }}";
                    }
                    else
                    {
                        // Default to 10
                        dekiMacro = "{{ feed.list(\"" + macro.Arguments["url"] + "\", 10) }}";
                    }
                }
            }

            return dekiMacro;
        }
Exemple #4
0
        public void ContributorsMacroTest()
        {
            ContributorsMacroConverter contribConverter = new ContributorsMacroConverter();
            Macro testMacro = new Macro("{contributors}");

            string convertedMacro = contribConverter.ConvertMacro(null, testMacro, null);
            Assert.That(convertedMacro, Is.EqualTo("{{wiki.contributors()}}"));
        }
Exemple #5
0
        public void Init()
        {
            pathMap = new Dictionary<string, string>();
            pathMap.Add("/display/ds/Breadcrumb+demonstration", "demo/ds/Confluence_Overview/Creating_pages_and_linking/Breadcrumb_demonstration");
            pathMap.Add("/display/ds/Creating+pages+and+linking", "demo/ds/Confluence_Overview/Creating_pages_and_linking");
            pathMap.Add("/display/ds/Email+archiving", "demo/ds/Confluence_Overview/Email_archiving");
            pathMap.Add("/display/ds/Example+Index", "demo/ds/Confluence_Overview/Example_Index");
            macro = new Macro(ConfluenceMacroText);

            _includeConverter = new IncludeMacroConverter();
        }
Exemple #6
0
        public void CreateBodyMacroTest()
        {
            string codeMacro = "(((code:xml)))Console.WriteLine(\"This is some code\");(((code)))";
            Macro testMacro = new Macro(codeMacro, true);
            Assert.That(testMacro.Name, Is.EqualTo("code"));
            Assert.That(testMacro.HasBody);
            Assert.That(testMacro.Body, Is.EqualTo("Console.WriteLine(\"This is some code\");"));
            Assert.That(testMacro.Original, Is.EqualTo(codeMacro));

            //TODO - add test for a body macro with arguments.
        }
        /// <summary>
        /// Takes a confluence macro (without the surrounding curly bracket), and converts it into dekiscript
        /// </summary>
        /// <param name="macro"></param>
        /// <param name="pageContext"></param>
        /// <returns></returns>
        public override string ConvertMacro(Dictionary<string, string> pathMap, Macro macro, ACConverterPageInfo pageInfo)
        {
            // index doesn't take any arguments, so ignore the macro argument

            // Get the path for the index we return
            string treePath = Utils.GetTopLevelPage(pageInfo.DekiPagePath);

            string dekiMacro = "{{ wiki.tree{path: \"" + treePath + "\"} }}";

            return dekiMacro;
        }
Exemple #8
0
        public void RssMacroTest()
        {
            RssMacroConverter rssConverter = new RssMacroConverter();

            Macro testMacro = new Macro("{rss:url=http://feeds.feedburner.com/Mashable?format=xml|max=3|showTitlesOnly=true}");
            string convertedMacro = rssConverter.ConvertMacro(null,testMacro, null);
            Assert.That(convertedMacro, Is.EqualTo("{{ feed.list(\"http://feeds.feedburner.com/Mashable?format=xml\", 3) }}"));

            // Check it works when no max property is set
            testMacro = new Macro("{rss:url=http://feeds.feedburner.com/Mashable?format=xml|showTitlesOnly=true}");
            convertedMacro = rssConverter.ConvertMacro(null,testMacro, null);
            Assert.That(convertedMacro, Is.EqualTo("{{ feed.list(\"http://feeds.feedburner.com/Mashable?format=xml\", 5) }}"));
        }
Exemple #9
0
 public override string ConvertMacro(Dictionary<string, string> pathMap, Macro macro, ACConverterPageInfo pageInfo)
 {
     if (macro.Arguments == null)
     {
         return "<pre>" + macro.Body + "</pre>";
     }
     else
     {
         if (macro.Arguments.Keys.Contains("default"))
             return "<pre class=\"deki-transform\" function=\"syntax." + macro.Arguments["default"] + "\">" + macro.Body + "</pre>";
     }
     return "<pre>" + macro.Body + "</pre>";
     
     
 }
        public override string ConvertMacro(Dictionary<string, string> pathMap, Macro macro, ACConverterPageInfo pageInfo)
        {
            string dekiMacro = "";//"{{ wiki.page(" + objMacro + ") }}";
            if (macro.Arguments != null)
            {
                string spaceKey = (macro.Arguments.Keys.Contains("spaceKey")) ? macro.Arguments["spaceKey"] : pageInfo.ConfluencePage.space;
                string pageTitle = (macro.Arguments.Keys.Contains("pageTitle")) ? macro.Arguments["pageTitle"] : macro.Arguments[Utils.DefaultParamName];

                ACConverter aconverter = new ACConverter();
                dekiMacro = aconverter.GetMtPathFromConfluencePath(pathMap, spaceKey, pageTitle);

                dekiMacro = "{{ wiki.page(\"" + dekiMacro + "\") }}";
            }

            return dekiMacro;
        }
Exemple #11
0
        public void CreateMacroTest()
        {
            string testMacro = "{include:spaceKey=FOO|pageTitle=Home}";
            Macro objMacro = new Macro(testMacro);
            Assert.AreEqual("include", objMacro.Name);
            Assert.AreEqual("FOO", objMacro.Arguments["spaceKey"]);
            Assert.AreEqual("Home", objMacro.Arguments["pageTitle"]);

            testMacro = ACConverter.MacroStubStart + "include:spaceKey=FOO|pageTitle=Home" + ACConverter.MacroStubEnd;
            objMacro = new Macro(testMacro);
            Assert.AreEqual("include", objMacro.Name);
            Assert.AreEqual("FOO", objMacro.Arguments["spaceKey"]);
            Assert.AreEqual("Home", objMacro.Arguments["pageTitle"]);

            Macro testMacroWithEqualsInArg = new Macro("{rss:url=http://feeds.feedburner.com/Mashable?format=xml|max=3|showTitlesOnly=true}");
            Assert.That(testMacroWithEqualsInArg.Arguments["url"], Is.EqualTo("http://feeds.feedburner.com/Mashable?format=xml"));
        }
        public string Convert(Dictionary<string, string> pathMap, string stubContent, ACConverterPageInfo pageInfo)
        {
            // Find all the macros called MacroName that are in stubContent, and call ConvertMacro

            string regexStubStart = ACConverter.MacroStubStart;
            string regexStubEnd = ACConverter.MacroStubEnd;

            string regexPattern = regexStubStart + MacroName + ":?[^" + ACConverter.MacroStubEnd + "]*" + regexStubEnd;

            string regexPatternClose = regexStubStart + MacroName + regexStubEnd;

            if (IsBodyMacro)
            {
                regexPattern = "(" + regexPattern + ")([^" + ACConverter.MacroStubStart + "]*)(" + regexPatternClose + ")";
            }

            Regex macroRegex = new Regex(regexPattern);

            MatchCollection matches = macroRegex.Matches(stubContent);

            foreach (Match match in matches)
            {
                Macro macro;

                if (IsBodyMacro)
                {
                    string macroHeader = match.Groups[1].Value;
                    string macroContent = match.Groups[2].Value;
                    string macroFooter = match.Groups[3].Value;
                    macro = new Macro(macroHeader, macroContent, macroFooter);
                }
                else
                {
                    macro = new Macro(match.Value);
                }

                string convertedMacro = ConvertMacro(pathMap, macro, pageInfo);
                stubContent = stubContent.Replace(match.Value, convertedMacro);
            }

            return stubContent;
        }
        public override string ConvertMacro(Dictionary<string, string> pathMap, Macro macro, ACConverterPageInfo pageInfo)
        {
            String label = String.Empty;
            String wrapAfter = String.Empty;
            String cellWidth = String.Empty;
            String cellHeight = String.Empty;

            if (macro.Arguments != null)
            {
                
                if (macro.Arguments.Keys.Contains("wrapAfter"))
                {
                    wrapAfter = ", columns:" + macro.Arguments["wrapAfter"].ToString();
                }
                
                ////////////////////
                
                if (macro.Arguments.Keys.Contains("cellWidth"))
                {
                    cellWidth = ", width:" + macro.Arguments["cellWidth"].ToString();
                }

                ////////////////////
                
                if (macro.Arguments.Keys.Contains("cellHeight"))
                {
                    cellHeight = ", height:" + macro.Arguments["cellHeight"].ToString();
                }

                /////////////////// SINGLE LABEL EXPECTED WITH THIS ARGUMENT

                if (macro.Arguments.Keys.Contains(Utils.DefaultParamName))
                {
                    label = macro.Arguments[Utils.DefaultParamName].ToString();
                }
            }
                       
            
            string dekiMacro = "{{ navMap{ tag: \"" + label + wrapAfter + cellWidth + cellHeight + "\" } }}";

            return dekiMacro;
        }
        public override string ConvertMacro(Dictionary<string, string> pathMap, Macro macro, ACConverterPageInfo pageInfo)
        {
            // Go through and gather all possible arguments - insert them into variables

            /*
             * Type - (optional) search for types of content. Accepted values:             
                * page: basic pages
                * comment: comments on pages or blogs
                * blogpost/news: blog posts
                * attachment: attachments to pages or blogs
                * userinfo: personal information
                * spacedesc: space descriptions
                * personalspacedesc: personal space descriptions
                * mail: emails in a space 
             */
            // TODO - Some of these will be multiples that are comma separated, so a function will be needed in the superclass
            // that can split them and remove spaces at either end, leaving just the argument
            // TODO - if we are doing multiple parameters for an argument - also need a way to know that an argument has multiples
            String label = String.Empty;

            if (macro.Arguments != null)
            {

                String type = "page";
                if (macro.Arguments.Keys.Contains("type"))
                {
                    type = macro.Arguments["type"].ToString();
                }

                ////////////////////
                int max = 5;
                if (macro.Arguments.Keys.Contains("max"))
                {
                    bool resMax = int.TryParse(macro.Arguments["max"], out max);
                }
                if (macro.Arguments.Keys.Contains("maxResults"))
                {
                    bool resMaxResults = int.TryParse(macro.Arguments["maxResults"], out max);
                }

                ////////////////////
                String spaces = "spaces";
                if (macro.Arguments.Keys.Contains("spaces"))
                {
                    spaces = macro.Arguments["spaces"].ToString();
                }

                ////////////////////
                String space = "space";
                if (macro.Arguments.Keys.Contains("space"))
                {
                    space = macro.Arguments["space"].ToString();
                }

                /////////////////// SINGLE LABEL EXPECTED WITH THIS ARGUMENT
                
                if (macro.Arguments.Keys.Contains("label"))
                {
                    label = macro.Arguments["label"].ToString();
                }

                if (macro.Arguments.Keys.Contains("labels"))
                {
                    label = macro.Arguments["labels"].ToString();
                }

                /////////////////// WE ARE NOT SUPPORTING MULTIPLE LABELS AT PRESENT
                /*
                String labels = "labels";
                if (macro.Arguments.Keys.Contains("labels"))
                {
                    labels = macro.Arguments["labels"].ToString();
                }
                */

                ///////////////////
                String sort = "creation";
                if (macro.Arguments.Keys.Contains("sort"))
                {
                    sort = macro.Arguments["sort"].ToString();
                }
            }

            // TODO - need to know the exact DekiScript to be able to create this macro
            string dekiMacro = "{{ taggedPages{ tag: \"" + label + "\" } }}";

            return dekiMacro;
        }
 public abstract string ConvertMacro(Dictionary <string, string> pathMap, Macro macro, ACConverterPageInfo pageInfo);
Exemple #16
0
        public override string ConvertMacro(Dictionary <string, string> pathMap, Macro macro, ACConverterPageInfo pageInfo)
        {
            string dekiMacro = "{{wiki.contributors()}}";

            return(dekiMacro);
        }
 public override string ConvertMacro(Dictionary<string, string> pathMap, Macro macro, ACConverterPageInfo pageInfo)
 {
     string dekiMacro = "{{wiki.create()}}";
     return dekiMacro;
 }
Exemple #18
0
 public void ContentByLabelMacroTest()
 {
     ContentByLabelMacroConverter contentbylabelConverter = new ContentByLabelMacroConverter();
     Macro testMacro = new Macro("{contentbylabel:label=cool}");
     string convertedMacro = contentbylabelConverter.ConvertMacro(null, testMacro, null);
     Assert.That(convertedMacro, Is.EqualTo("{{ taggedPages{ tag: \"cool\" }; }}"));
 }
 public abstract string ConvertMacro(Dictionary<string, string> pathMap,Macro macro, ACConverterPageInfo pageInfo);
Exemple #20
0
        public void CodeMacroTest()
        {
            CodeMacroConverter codeConverter = new CodeMacroConverter();
            
            Macro testMacro = new Macro("{code}Console.WriteLine(\"This is some code\");{code}");
            string convertedMacro = codeConverter.ConvertMacro(null,testMacro, null);
            Assert.That(convertedMacro, Is.EqualTo("<pre>Console.WriteLine(\"This is some code\");</pre>"));

        }
        public override string ConvertMacro(Dictionary <string, string> pathMap, Macro macro, ACConverterPageInfo pageInfo)
        {
            // Go through and gather all possible arguments - insert them into variables

            /*
             * Type - (optional) search for types of content. Accepted values:
             * page: basic pages
             * comment: comments on pages or blogs
             * blogpost/news: blog posts
             * attachment: attachments to pages or blogs
             * userinfo: personal information
             * spacedesc: space descriptions
             * personalspacedesc: personal space descriptions
             * mail: emails in a space
             */
            // TODO - Some of these will be multiples that are comma separated, so a function will be needed in the superclass
            // that can split them and remove spaces at either end, leaving just the argument
            // TODO - if we are doing multiple parameters for an argument - also need a way to know that an argument has multiples
            String label = String.Empty;

            if (macro.Arguments != null)
            {
                String type = "page";
                if (macro.Arguments.Keys.Contains("type"))
                {
                    type = macro.Arguments["type"].ToString();
                }

                ////////////////////
                int max = 5;
                if (macro.Arguments.Keys.Contains("max"))
                {
                    bool resMax = int.TryParse(macro.Arguments["max"], out max);
                }
                if (macro.Arguments.Keys.Contains("maxResults"))
                {
                    bool resMaxResults = int.TryParse(macro.Arguments["maxResults"], out max);
                }

                ////////////////////
                String spaces = "spaces";
                if (macro.Arguments.Keys.Contains("spaces"))
                {
                    spaces = macro.Arguments["spaces"].ToString();
                }

                ////////////////////
                String space = "space";
                if (macro.Arguments.Keys.Contains("space"))
                {
                    space = macro.Arguments["space"].ToString();
                }

                /////////////////// SINGLE LABEL EXPECTED WITH THIS ARGUMENT

                if (macro.Arguments.Keys.Contains("label"))
                {
                    label = macro.Arguments["label"].ToString();
                }

                if (macro.Arguments.Keys.Contains("labels"))
                {
                    label = macro.Arguments["labels"].ToString();
                }

                /////////////////// WE ARE NOT SUPPORTING MULTIPLE LABELS AT PRESENT

                /*
                 * String labels = "labels";
                 * if (macro.Arguments.Keys.Contains("labels"))
                 * {
                 *  labels = macro.Arguments["labels"].ToString();
                 * }
                 */

                ///////////////////
                String sort = "creation";
                if (macro.Arguments.Keys.Contains("sort"))
                {
                    sort = macro.Arguments["sort"].ToString();
                }
            }

            // TODO - need to know the exact DekiScript to be able to create this macro
            string dekiMacro = "{{ taggedPages{ tag: \"" + label + "\" } }}";

            return(dekiMacro);
        }