private string GetTabsScript(string instanceVarName, OpmlOutlines _outlines)
        {
            var js         = new StringBuilder("");
            int tabCounter = -1;

            foreach (OpmlOutline item in _outlines)
            {
                if ((item.Category.StartsWith("Tab")))
                {
                    tabCounter = tabCounter + 1;
                    string tabVarName = instanceVarName + "tab" + tabCounter;

                    //Create a call to the "addTab" method
                    //addTab accepts one parameter -- a TabInfo object
                    //Here the TabInfo object is dynamically created
                    //with the parameters  Label, Url and Template
                    js.Append("var " + tabVarName + " = new TabInfo('" + item.Text + "',");

                    if ((item.Type == "none"))
                    {
                        js.Append("''");
                    }
                    else
                    {
                        js.Append("'" + item.XmlUrl.AbsoluteUri + "'");
                    }

                    //Template detection
                    //The category field indicates if the outline node is a tab, section or category
                    //If the field value includes a / character, then portion of the value to the right of /
                    //contains the name of the template that should be used for that tab/section/category
                    //and its children
                    if ((item.Category.IndexOf("/") > 0))
                    {
                        js.Append(",'" + item.Category.Substring(item.Category.IndexOf("/") + 1) + "'");
                    }
                    js.Append(");");
                    if ((item.Outlines != null))
                    {
                        js.Append(GetSectionsScript(item.Outlines, tabVarName));
                    }
                    js.Append(instanceVarName + "tabs[" + instanceVarName + "tabs.length] = " + tabVarName + ";");
                }
            }
            return(js.ToString());
        }
        private string GetSectionsScript(OpmlOutlines _outlines, string tabVarName)
        {
            var js             = new StringBuilder("");
            int sectionCounter = -1;

            foreach (OpmlOutline item in _outlines)
            {
                if ((item.Category.StartsWith("Section")))
                {
                    sectionCounter = sectionCounter + 1;
                    string sectionVarName = tabVarName + "_" + sectionCounter;
                    string sectionUrl     = "";
                    if ((item.XmlUrl != null))
                    {
                        sectionUrl = ", '" + item.XmlUrl.AbsoluteUri + "'";
                    }
                    //Create a call to the addSection method
                    //addSection accepts one parameter -- a SectionInfo object
                    //Here the SectionInfo object is dyncamically created
                    //with the parameters Label, Url and Template
                    //A section Url is the Url called for obtaining search results
                    //If the Url contains a [KEYWORD] token, the user's search keyword
                    //is substituted for the token. If no token exists then &keyword={keyword value}
                    //is appended to the Url
                    js.Append("var " + sectionVarName + " = " + tabVarName + ".addSection(new SectionInfo('" + item.Text + "'" + sectionUrl);

                    //Template detection
                    //The category field indicates if the outline node is a tab, section or category
                    //If the field value includes a / character, then portion of the value to the right of /
                    //contains the name of the template that should be used for that section/category
                    //and its children
                    if ((item.Category.IndexOf("/") > 0))
                    {
                        js.Append(",'" + item.Category.Substring(item.Category.IndexOf("/") + 1) + "'");
                    }
                    js.Append("));");
                    if ((item.Outlines != null))
                    {
                        int counter = -1;
                        js.Append(GetCategoriesScript(item.Outlines, sectionVarName, -1, ref counter));
                    }
                }
            }
            return(js.ToString());
        }
        private string GetRenderingScript(string instanceVarName, OpmlOutlines _outlines)
        {
            string script = "";

            //First fetch any linked OPML files
            //Only one level of link fetching is supported so
            //no recursion
            var expandedOutlines = new OpmlOutlines();

            foreach (OpmlOutline item in _outlines)
            {
                if ((item.Type == "link"))
                {
                    Opml linkedFeed = Opml.LoadFromUrl(item.XmlUrl);
                    if ((item.Category.StartsWith("Tab")))
                    {
                        expandedOutlines.Add(item);
                        foreach (OpmlOutline linkedOutline in linkedFeed.Outlines)
                        {
                            item.Outlines.Add(linkedOutline);
                        }
                    }
                    else
                    {
                        foreach (OpmlOutline linkedOutline in linkedFeed.Outlines)
                        {
                            expandedOutlines.Add(linkedOutline);
                        }
                    }
                }
                else
                {
                    expandedOutlines.Add(item);
                }
            }
            script = GetTabsScript(instanceVarName, expandedOutlines);

            return(script);
        }
        private string GetCategoriesScript(OpmlOutlines _outlines, string sectionVarName, int depth, ref int counter)
        {
            var js = new StringBuilder("");

            depth = depth + 1;
            foreach (OpmlOutline item in _outlines)
            {
                if ((item.Category.StartsWith("Category")))
                {
                    counter = counter + 1;
                    js.Append(sectionVarName + ".addCategory(new CategoryInfo('" + item.Text + "','" + item.XmlUrl.AbsoluteUri + "'," + depth);

                    //Template detection
                    //The category field indicates if the outline node is a tab, section or category
                    //If the field value includes a / character, then portion of the value to the right of /
                    //contains the name of the template that should be used for that category
                    if ((item.Category.IndexOf("/") > 0))
                    {
                        js.Append(",'" + item.Category.Substring(item.Category.IndexOf("/") + 1) + "'");
                    }
                    js.Append("));");

                    //If the Category field includes "Default" in its list of values,
                    //the item is marked as the default category
                    if ((item.Category.IndexOf("Default") > -1))
                    {
                        js.Append(sectionVarName + ".setDefaultCategory(" + counter + ");");
                    }
                    if ((item.Outlines != null))
                    {
                        js.Append(GetCategoriesScript(item.Outlines, sectionVarName, depth, ref counter));
                    }
                }
            }
            return(js.ToString());
        }
Ejemplo n.º 5
0
 public Opml()
 {
     _outlines = new OpmlOutlines();
 }
Ejemplo n.º 6
0
        public void AddOutline(string text, string type, Uri xmlUrl, string category, OpmlOutlines outlines)
        {
            var item = new OpmlOutline();

            item.Text     = text;
            item.Type     = type;
            item.XmlUrl   = xmlUrl;
            item.Category = category;
            item.Outlines = outlines;
            _outlines.Add(item);
        }
Ejemplo n.º 7
0
 public OpmlOutline()
 {
     Outlines = new OpmlOutlines();
 }
Ejemplo n.º 8
0
 public OpmlOutline() : base()
 {
     _outlines = new OpmlOutlines();
 }
Ejemplo n.º 9
0
        private string GetSectionsScript(OpmlOutlines _outlines, string tabVarName)
        {
            var js = new StringBuilder("");
            int sectionCounter = -1;
            foreach (OpmlOutline item in _outlines)
            {
                if ((item.Category.StartsWith("Section")))
                {
                    sectionCounter = sectionCounter + 1;
                    string sectionVarName = tabVarName + "_" + sectionCounter;
                    string sectionUrl = "";
                    if ((item.XmlUrl != null))
                    {
                        sectionUrl = ", '" + item.XmlUrl.AbsoluteUri + "'";
                    }
                    //Create a call to the addSection method
                    //addSection accepts one parameter -- a SectionInfo object
                    //Here the SectionInfo object is dyncamically created
                    //with the parameters Label, Url and Template
                    //A section Url is the Url called for obtaining search results
                    //If the Url contains a [KEYWORD] token, the user's search keyword
                    //is substituted for the token. If no token exists then &keyword={keyword value}
                    //is appended to the Url
                    js.Append("var " + sectionVarName + " = " + tabVarName + ".addSection(new SectionInfo('" + item.Text + "'" + sectionUrl);

                    //Template detection
                    //The category field indicates if the outline node is a tab, section or category
                    //If the field value includes a / character, then portion of the value to the right of /
                    //contains the name of the template that should be used for that section/category
                    //and its children
                    if ((item.Category.IndexOf("/") > 0))
                    {
                        js.Append(",'" + item.Category.Substring(item.Category.IndexOf("/") + 1) + "'");
                    }
                    js.Append("));");
                    if ((item.Outlines != null))
                    {
                        int counter = -1;
                        js.Append(GetCategoriesScript(item.Outlines, sectionVarName, -1, ref counter));
                    }
                }
            }
            return js.ToString();
        }
Ejemplo n.º 10
0
        private string GetCategoriesScript(OpmlOutlines _outlines, string sectionVarName, int depth, ref int counter)
        {
            var js = new StringBuilder("");
            depth = depth + 1;
            foreach (OpmlOutline item in _outlines)
            {
                if ((item.Category.StartsWith("Category")))
                {
                    counter = counter + 1;
                    js.Append(sectionVarName + ".addCategory(new CategoryInfo('" + item.Text + "','" + item.XmlUrl.AbsoluteUri + "'," + depth);

                    //Template detection
                    //The category field indicates if the outline node is a tab, section or category
                    //If the field value includes a / character, then portion of the value to the right of /
                    //contains the name of the template that should be used for that category
                    if ((item.Category.IndexOf("/") > 0))
                    {
                        js.Append(",'" + item.Category.Substring(item.Category.IndexOf("/") + 1) + "'");
                    }
                    js.Append("));");

                    //If the Category field includes "Default" in its list of values,
                    //the item is marked as the default category
                    if ((item.Category.IndexOf("Default") > -1))
                    {
                        js.Append(sectionVarName + ".setDefaultCategory(" + counter + ");");
                    }
                    if ((item.Outlines != null))
                    {
                        js.Append(GetCategoriesScript(item.Outlines, sectionVarName, depth, ref counter));
                    }
                }
            }
            return js.ToString();
        }
Ejemplo n.º 11
0
        private string GetTabsScript(string instanceVarName, OpmlOutlines _outlines)
        {
            var js = new StringBuilder("");
            int tabCounter = -1;
            foreach (OpmlOutline item in _outlines)
            {
                if ((item.Category.StartsWith("Tab")))
                {
                    tabCounter = tabCounter + 1;
                    string tabVarName = instanceVarName + "tab" + tabCounter;

                    //Create a call to the "addTab" method
                    //addTab accepts one parameter -- a TabInfo object
                    //Here the TabInfo object is dynamically created
                	//with the parameters  Label, Url and Template
                    js.Append("var " + tabVarName + " = new TabInfo('" + item.Text + "',");

                    if ((item.Type == "none"))
                    {
                        js.Append("''");
                    }
                    else
                    {
                        js.Append("'" + item.XmlUrl.AbsoluteUri + "'");
                    }
					
                    //Template detection
                    //The category field indicates if the outline node is a tab, section or category
                    //If the field value includes a / character, then portion of the value to the right of /
                    //contains the name of the template that should be used for that tab/section/category
                    //and its children
                    if ((item.Category.IndexOf("/") > 0))
                    {
                        js.Append(",'" + item.Category.Substring(item.Category.IndexOf("/") + 1) + "'");
                    }
                    js.Append(");");
                    if ((item.Outlines != null))
                    {
                        js.Append(GetSectionsScript(item.Outlines, tabVarName));
                    }
                    js.Append(instanceVarName + "tabs[" + instanceVarName + "tabs.length] = " + tabVarName + ";");
                }
            }
            return js.ToString();
        }
Ejemplo n.º 12
0
        private string GetRenderingScript(string instanceVarName, OpmlOutlines _outlines)
        {
            string script = "";

            //First fetch any linked OPML files
            //Only one level of link fetching is supported so
            //no recursion
            var expandedOutlines = new OpmlOutlines();
            foreach (OpmlOutline item in _outlines)
            {
                if ((item.Type == "link"))
                {
                    Opml linkedFeed = Opml.LoadFromUrl(item.XmlUrl);
                    if ((item.Category.StartsWith("Tab")))
                    {
                        expandedOutlines.Add(item);
                        foreach (OpmlOutline linkedOutline in linkedFeed.Outlines)
                        {
                            item.Outlines.Add(linkedOutline);
                        }
                    }
                    else
                    {
                        foreach (OpmlOutline linkedOutline in linkedFeed.Outlines)
                        {
                            expandedOutlines.Add(linkedOutline);
                        }
                    }
                }
                else
                {
                    expandedOutlines.Add(item);
                }
            }
            script = GetTabsScript(instanceVarName, expandedOutlines);

            return script;
        }
Ejemplo n.º 13
0
Archivo: Opml.cs Proyecto: biganth/Curt
 public Opml()
 {
     _outlines = new OpmlOutlines();
 }
Ejemplo n.º 14
0
Archivo: Opml.cs Proyecto: biganth/Curt
 public void AddOutline(string text, string type, Uri xmlUrl, string category, OpmlOutlines outlines)
 {
     var item = new OpmlOutline();
     item.Text = text;
     item.Type = type;
     item.XmlUrl = xmlUrl;
     item.Category = category;
     item.Outlines = outlines;
     _outlines.Add(item);
 }
Ejemplo n.º 15
0
 public Opml()
 {
     this._outlines = new OpmlOutlines();
 }