Esempio n. 1
1
		protected void Page_Load(object sender, System.EventArgs e)
		{
            if (SiteSecurity.IsInRole("admin") == false) 
            {
                Response.Redirect("~/FormatPage.aspx?path=SiteConfig/accessdenied.format.html");
            }

            

            if ( !IsPostBack || 
                Session["newtelligence.DasBlog.Web.EditBlogRollBox.OpmlTree"] == null )
            {
                SharedBasePage requestPage = Page as SharedBasePage;
                foreach( string file in Directory.GetFiles(SiteConfig.GetConfigPathFromCurrentContext(),"*.opml"))
                {
                    listFiles.Items.Add( Path.GetFileName(file) );
                }
                if ( listFiles.Items.Count == 0 )
                {
                    listFiles.Items.Add("blogroll.opml");
                }
                Session["newtelligence.DasBlog.Web.EditBlogRollBox.baseFileName"] = baseFileName = listFiles.Items[0].Text;
                string fileName = Path.Combine(SiteConfig.GetConfigPathFromCurrentContext(),baseFileName);
                LoadOutline( fileName );
            }
            else
            {
                baseFileName = Session["newtelligence.DasBlog.Web.EditBlogRollBox.baseFileName"] as string;
                opmlTree = Session["newtelligence.DasBlog.Web.EditBlogRollBox.OpmlTree"] as Opml;
            }
            BindGrid();
		}
        protected void buttonCreate_Click(object sender, System.EventArgs e)
        {
            if (textNewFileName.Text.Length > 0)
            {
                // Get the requested file name to create and stip off any extra directories
                string fileName = textNewFileName.Text;
                fileName = Path.GetFileName(fileName);

                // Double check that there is an extension.  If not, tag on opml
                if (Path.GetExtension(fileName) == String.Empty)
                {
                    fileName = fileName + ".opml";
                }

                // Add this to the list of current file names and select it as active
                listFiles.Items.Add(fileName);
                listFiles.SelectedValue = fileName;
                Session["newtelligence.DasBlog.Web.EditBlogRollBox.baseFileName"] = baseFileName = fileName;

                // This will created during LoadOutline, but have to clear it out first, otherwise this new blogroll
                // will get a copy of the currently selected one, instead of starting fresh
                opmlTree = null;

                LoadOutline(Path.Combine(SiteConfig.GetConfigPathFromCurrentContext(), baseFileName));
                BindGrid();

                textNewFileName.Text = "";
            }
        }
Esempio n. 3
0
        private static int Execute(CommandArgs commandArgs, IOutput output)
        {
            Logger.Log.Info("Enter Remove command.");

            string podcastName = commandArgs.GetParameter <string>(PodcastName);

            Logger.Log.Info($"Get the Remove command input string, is {podcastName}.");

            if (File.Exists(ProgramConfiguration.PodcastFileName))
            {
                Logger.Log.Info("Remove the podcast.");
                int res = Opml.RemovePodcast(podcastName);

                if (res == 0)
                {
                    Logger.Log.Info("Finish remove the podcast.");
                    output.WriteLine("Had removed.");
                }
                else
                {
                    Logger.Log.Warn($"There is not podcast named {podcastName}.");
                    output.WriteLine($"There is not podcast named {podcastName}.");
                }
            }
            else
            {
                Logger.Log.Warn("There is not a opml file.");
                output.WriteLine("There is not a profile. Please at least add one podcast.");
            }
            return(0);
        }
Esempio n. 4
0
        public void EntitiesTest()
        {
            Opml opml = new Opml();

            opml.Encoding = "UTF-8";
            opml.Version  = "2.0";

            opml.Head.Title     = "Things & Stuff";
            opml.Head.OwnerName = "Me, myself & I";

            Outline outline = new Outline();

            outline.Text = "Things & Stuff News";
            outline.Category.Add("Things & Stuff");
            outline.Description = "Things & Stuff News";
            outline.Title       = "Things & Stuff News";

            opml.Body.Outlines.Add(outline);

            StringBuilder xml = new StringBuilder();

            xml.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n");
            xml.Append("<opml version=\"2.0\">\r\n");
            xml.Append("<head>\r\n");
            xml.Append("<title>Things &amp; Stuff</title>\r\n");
            xml.Append("<ownerName>Me, myself &amp; I</ownerName>\r\n");
            xml.Append("</head>\r\n");
            xml.Append("<body>\r\n");
            xml.Append("<outline text=\"Things &amp; Stuff News\" category=\"Things &amp; Stuff\" description=\"Things &amp; Stuff News\" title=\"Things &amp; Stuff News\" />\r\n");
            xml.Append("</body>\r\n");
            xml.Append("</opml>");

            Assert.True(opml.ToString() == xml.ToString());
        }
Esempio n. 5
0
        private async void ExportOpmlButton_Click(object sender, RoutedEventArgs e)
        {
            ExportOpmlButton.IsEnabled = false;
            ExportOpmlButton.Content   = AppTools.GetReswLanguage("Tip_Waiting");
            var allList = MainPage.Current.Categories.ToList();

            try
            {
                var    opml     = new Opml(allList);
                string content  = opml.ToString();
                string fileName = AppTools.GetLocalSetting(AppSettings.UserName, "") + "_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss") + ".opml";
                var    file     = await IOTools.GetSaveFile(".opml", fileName, "OPML File");

                if (file != null)
                {
                    await FileIO.WriteTextAsync(file, content);

                    new PopupToast(AppTools.GetReswLanguage("Tip_ExportSuccess")).ShowPopup();
                }
            }
            catch (Exception)
            {
                new PopupToast(AppTools.GetReswLanguage("Tip_ImportError"), AppTools.GetThemeSolidColorBrush(ColorType.ErrorColor)).ShowPopup();
            }
            ExportOpmlButton.IsEnabled = true;
            ExportOpmlButton.Content   = AppTools.GetReswLanguage("Tip_Export");
        }
Esempio n. 6
0
        public async Task ShouldBeAbleToImportOpmlFeeds(string url)
        {
            Category category = null;

            _categoryManager
            .When(x => x.Insert(Arg.Any <Category>()))
            .Do(callback => category = callback.Arg <Category>());

            var opml = new Opml {
                Body = new List <OpmlOutline> {
                    new OpmlOutline {
                        XmlUrl = url
                    }
                }
            };

            _serializationService.Deserialize <Opml>(Arg.Any <Stream>()).Returns(opml);

            var success = await _opmlService.ImportOpml(new MemoryStream());

            success.Should().BeTrue();

            category.Channels.Count.Should().Be(1);
            category.Channels[0].Uri.Should().Be(url);
            category.Channels[0].Notify.Should().BeTrue();
        }
Esempio n. 7
0
        public async Task ShouldExportOpmlFeedsIntoXml(string category, string protocol, string domain, string path)
        {
            Opml opml = null;

            _serializationService
            .When(x => x.Serialize(Arg.Any <Opml>(), Arg.Any <Stream>()))
            .Do(callback => opml = callback.Arg <Opml>());

            var url      = $"{protocol}{domain}{path}";
            var channels = new List <Channel> {
                new Channel {
                    Uri = url
                }
            };
            var categories = new List <Category> {
                new Category {
                    Title = category, Channels = channels
                }
            };

            _categoryManager.GetAll().Returns(categories);

            var success = await _opmlService.ExportOpml(new MemoryStream());

            success.Should().BeTrue();

            opml.Head.Should().NotBeNull();
            opml.Body.Count.Should().Be(1);
            opml.Body[0].Title.Should().Be(category);
            opml.Body[0].ChildOutlines.Count.Should().Be(1);
            opml.Body[0].ChildOutlines[0].Title.Should().Be(domain);
            opml.Body[0].ChildOutlines[0].HtmlUrl.Should().Be(protocol + domain);
            opml.Body[0].ChildOutlines[0].XmlUrl.Should().Be(url);
        }
Esempio n. 8
0
        /// <summary>
        /// 从OPML文件中获取分类列表
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public async static Task <List <Category> > GetRssListFromFile(StorageFile file)
        {
            string content = await FileIO.ReadTextAsync(file);

            var opml            = new Opml(content);
            var list            = new List <Category>();
            var defaultCategory = new Category("Default", "");

            if (opml.Body.Outlines.Count > 0)
            {
                foreach (var outline in opml.Body.Outlines)
                {
                    if (outline.Outlines != null && outline.Outlines.Count > 0 && string.IsNullOrEmpty(outline.XMLUrl))
                    {
                        list.Add(new Category(outline));
                    }
                    else
                    {
                        var c = new Channel(outline);
                        if (c != null && !string.IsNullOrEmpty(c.Name))
                        {
                            defaultCategory.Channels.Add(c);
                        }
                    }
                }
            }
            if (defaultCategory.Channels.Count > 0)
            {
                list.Add(defaultCategory);
            }
            return(list);
        }
Esempio n. 9
0
        private async void ImportButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.file == null)
            {
                return;
            }

            try
            {
                using (var stream = await this.file.OpenStreamForReadAsync())
                {
                    var xml = new XmlDocument();
                    xml.Load(stream);
                    var opml  = new Opml(xml);
                    var feeds = new List <string>();
                    opml.Body?.Outlines.ForEach(o => feeds.AddRange(this.GetFeeds(o)));
                    if (!string.IsNullOrWhiteSpace(Helper.Request <string>("/rss/addfeeds", "POST", feeds)))
                    {
                        Helper.ShowMessageDialog("Tip", "Import success");
                    }
                    else
                    {
                        Helper.ShowMessageDialog("Tip", "Failed to import");
                    }
                }
            }
            catch (Exception ex)
            {
                Helper.LogException(ex);
            }
        }
Esempio n. 10
0
        public async Task <bool> ExportOpmlFeedsAsync(Stream stream)
        {
            var opml = new Opml {
                Head = new OpmlHead {
                    Title = "Feeds from myFeed App"
                }
            };
            var categories = await _categoryManager.GetAllAsync();

            var outlines = categories.Select(x => new OpmlOutline
            {
                ChildOutlines = x.Channels
                                .Select(i => new { Entity = i, Uri = new Uri(i.Uri) })
                                .Select(y => new OpmlOutline
                {
                    HtmlUrl = $"{y.Uri.Scheme}://{y.Uri.Host}",
                    XmlUrl  = y.Uri.ToString(),
                    Title   = y.Uri.Host,
                    Text    = y.Uri.Host,
                    Version = "rss",
                    Type    = "rss"
                })
                                .ToList(),
                Title = x.Title,
                Text  = x.Title
            });

            opml.Body = new List <OpmlOutline>(outlines);
            if (stream == null)
            {
                return(false);
            }
            _serializationService.Serialize(opml, stream);
            return(true);
        }
Esempio n. 11
0
        private XmlElement LoadBlogroll(string fileName)
        {
            // This may seem horribly inefficient, but we need to run this
            // through the object model once to make sure we're schema compliant
            // We can't emit OPML schema into WSDL, because the friggin' spec defines
            // no namespace
            XmlSerializer ser      = new XmlSerializer(typeof(Opml));
            Opml          opmlTree = null;

            if (File.Exists(fileName))
            {
                using (Stream s = File.OpenRead(fileName))
                {
                    opmlTree = ser.Deserialize(s) as Opml;
                }
            }
            if (opmlTree == null)
            {
                opmlTree = new Opml("Generated by newtelligence dasBlog 1.4");
            }

            XmlDocument   xmlDoc    = new XmlDocument();
            MemoryStream  memStream = new MemoryStream();
            XmlTextWriter xtw       = new XmlTextWriter(memStream, System.Text.Encoding.UTF8);

            ser.Serialize(xtw, opmlTree);
            xtw.Flush();

            memStream.Position = 0;

            XmlTextReader xtr = new XmlTextReader(memStream);

            xmlDoc.Load(xtr);
            return(xmlDoc.DocumentElement);
        }
Esempio n. 12
0
        public async Task <bool> ExportOpmlFeedsAsync(Stream stream)
        {
            // Initialize new Opml instance and read categories from db.
            var opml = new Opml {
                Head = new OpmlHead {
                    Title = "Feeds from myFeed App"
                }
            };
            var categories = await _categoriesRepository.GetAllAsync();

            var outlines = categories.Select(x => new OpmlOutline
            {
                ChildOutlines = x.Channels
                                .Select(i => new { Entity = i, Uri = new Uri(i.Uri) })
                                .Select(y => new OpmlOutline
                {
                    HtmlUrl = $"{y.Uri.Scheme}://{y.Uri.Host}",
                    XmlUrl  = y.Uri.ToString(),
                    Title   = y.Uri.Host,
                    Text    = y.Uri.Host,
                    Version = "rss",
                    Type    = "rss"
                })
                                .ToList(),
                Title = x.Title,
                Text  = x.Title
            });

            // Fill opml with categories.
            opml.Body = new List <OpmlOutline>(outlines);
            _serializationService.Serialize(opml, stream);
            return(true);
        }
Esempio n. 13
0
        private void ProcessHead(Opml opml, XmlNode headNode)
        {
            foreach (XmlNode node in headNode.ChildNodes)
            {
                string text = node.LocalName;
                text = string.IsInterned(text);

                if (text == "title")
                {
                    opml.Title = node.InnerText;
                }
                else if (text == "dateCreated")
                {
                    opml.DateCreated = DateTimeExt.Parse(node.InnerText);
                }
                else if (text == "dateModified")
                {
                    opml.DateModified = DateTimeExt.Parse(node.InnerText);
                }
                else if (text == "ownerEmail")
                {
                    opml.OwnerEmail = node.InnerText;
                }
                else if (text == "ownerName")
                {
                    opml.OwnerName = node.InnerText;
                }
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (SiteSecurity.IsInRole("admin") == false)
            {
                Response.Redirect("~/FormatPage.aspx?path=SiteConfig/accessdenied.format.html");
            }



            if (!IsPostBack ||
                Session["newtelligence.DasBlog.Web.EditBlogRollBox.OpmlTree"] == null)
            {
                SharedBasePage requestPage = Page as SharedBasePage;
                foreach (string file in Directory.GetFiles(SiteConfig.GetConfigPathFromCurrentContext(), "*.opml"))
                {
                    listFiles.Items.Add(Path.GetFileName(file));
                }
                if (listFiles.Items.Count == 0)
                {
                    listFiles.Items.Add("blogroll.opml");
                }
                Session["newtelligence.DasBlog.Web.EditBlogRollBox.baseFileName"] = baseFileName = listFiles.Items[0].Text;
                string fileName = Path.Combine(SiteConfig.GetConfigPathFromCurrentContext(), baseFileName);
                LoadOutline(fileName);
            }
            else
            {
                baseFileName = Session["newtelligence.DasBlog.Web.EditBlogRollBox.baseFileName"] as string;
                opmlTree     = Session["newtelligence.DasBlog.Web.EditBlogRollBox.OpmlTree"] as Opml;
            }
            BindGrid();
        }
Esempio n. 15
0
        private async void ExportButton_Click(object sender, RoutedEventArgs e)
        {
            var feeds = Helper.Request <List <Feed> >("/rss/feeds", "GET");

            if (feeds == null || !feeds.Any())
            {
                return;
            }

            try
            {
                var opml = new Opml();
                opml.Encoding = "UTF-8";
                opml.Version  = "2.0";
                var head = new Head();
                head.Title        = _fileName;
                head.DateCreated  = DateTime.Now;
                head.DateModified = DateTime.Now;
                opml.Head         = head;

                Body body = new Body();
                feeds.ForEach(feed =>
                {
                    body.Outlines.Add(new Outline
                    {
                        Text    = feed.Title,
                        Title   = feed.Title,
                        Created = DateTime.Now,
                        HTMLUrl = feed.Url,
                        Type    = "rss",
                        XMLUrl  = feed.Url
                    });
                });
                opml.Body = body;

                var files = await this.folder.GetFilesAsync();

                StorageFile file;
                if (!files.Any(f => f.Name == _fileName))
                {
                    file = await this.folder.CreateFileAsync(_fileName);
                }
                else
                {
                    file = await this.folder.GetFileAsync(_fileName);
                }
                using (var writer = new StreamWriter(await file.OpenStreamForWriteAsync()))
                {
                    writer.Write(opml.ToString());
                }

                Helper.ShowMessageDialog("Tip", "Export success");
            }
            catch (Exception ex)
            {
                Helper.LogException(ex);
            }
        }
        private static int Execute(CommandArgs commandArgs, IOutput output)
        {
            Logger.Log.Info("Enter Download Select command.");

            int[]  selectIndex = commandArgs.GetParameter <int[]>(SelectIndex);
            string name        = commandArgs.GetParameter <string>(PodcastName);

            Logger.Log.Info($"Input podcast name is {name}.");
            Logger.Log.Info($"Input select index are {string.Join(";", selectIndex)}.");

            output.WriteLine("Building downloading file...");

            if (!Directory.Exists(ProgramConfiguration.DownloadConfigurations.DownloadPodcastPath))
            {
                Logger.Log.Info($"Create directory, is {ProgramConfiguration.DownloadConfigurations.DownloadPodcastPath}.");

                Directory.CreateDirectory(ProgramConfiguration.DownloadConfigurations.DownloadPodcastPath);
            }

            int res = Opml.DownloadPodcastSelectRelease(name, selectIndex,
                                                        ProgramConfiguration.DownloadConfigurations.DownloadPodcastPath, false,
                                                        ProgramConfiguration.DownloadConfigurations.DownloadProgram);

            if (res != 0)
            {
                Logger.Log.Warn("The input name is NOT in the library.");

                output.WriteLine("Error. Input of Name does not contain in the library.");
                return(0);
            }

            output.WriteLine("Building done");

            Logger.Log.Info("Finish build download file.");

            output.WriteLine("Downloading...");

            if (ProgramConfiguration.DownloadConfigurations.DownloadProgram == DownloadTools.Aria2Name)
            {
                Logger.Log.Info("Start download newly release use aria2.");

                DownloadTools.DownloadAria2(ProgramConfiguration.DownloadConfigurations.DownloadProgramPathName, ProgramConfiguration.DownloadFileName, output);
            }
            else if (ProgramConfiguration.DownloadConfigurations.DownloadProgram == DownloadTools.IdmName)
            {
                Logger.Log.Info("Start download newly release use idm.");

                DownloadTools.DownloadIdm(ProgramConfiguration.DownloadConfigurations.DownloadProgramPathName, ProgramConfiguration.DownloadFileName, output);
            }

            Logger.Log.Info("Finish download.");

            output.WriteLine("Done.");

            return(0);
        }
        private Opml GetDefaultOpmlFeed()
        {
            var    opmlFeed = new Opml();
            string filePath = Config.GetPathToFile(Config.ConfigFileType.SolutionsExplorer);

            if (File.Exists(filePath))
            {
                opmlFeed = Opml.LoadFromFile(filePath);
            }
            return(opmlFeed);
        }
        private static int Execute(CommandArgs commandArgs, IOutput output)
        {
            Logger.Log.Info("Enter List command.");

            Logger.Log.Info("Show all podcast info.");

            output.WriteLine("Podcasts:");

            Opml.ListPodcast(ref output);

            return(0);
        }
Esempio n. 19
0
        private void ProcessOpmlElements(Opml opml, XmlNode bodyNode)
        {
            ArrayList items = new ArrayList();

            foreach (XmlNode node in bodyNode.ChildNodes)
            {
                XmlElement element = node as XmlElement;

                // skip over non-elements (like comments)
                if (element == null)
                {
                    continue;
                }

                if (element.LocalName == "outline")
                {
                    OpmlItem item = new OpmlItem();

                    if (element.HasAttribute("title"))
                    {
                        item.Title = element.Attributes["title"].Value;
                    }

                    if (element.HasAttribute("text"))
                    {
                        item.Title = element.Attributes["text"].Value;
                    }

                    if (element.HasAttribute("htmlUrl"))
                    {
                        item.HtmlUrl = element.Attributes["htmlUrl"].Value;
                    }

                    if (element.HasAttribute("xmlUrl"))
                    {
                        item.XmlUrl = element.Attributes["xmlUrl"].Value;
                    }

                    if (element.HasAttribute("Type"))
                    {
                        item.Type = element.Attributes["type"].Value;
                    }
                    items.Add(item);

                    //if (element.HasChildNodes)
                    //{
                    //    ProcessOpmlElements(opml, element);
                    //}
                }
            }

            opml.Items = (OpmlItem[])items.ToArray(typeof(OpmlItem));
        }
        private static int Execute(CommandArgs commandArgs, IOutput output)
        {
            Logger.Log.Info("Enter Add command.");

            string url = commandArgs.GetParameter <string>(PodcastUrl);

            Logger.Log.Info($"Get the Add command input string, is {url}.");

            bool result = Uri.TryCreate(url, UriKind.Absolute, out var uriResult) &&
                          (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);

            if (result)
            {
                Logger.Log.Info("The Add command input string is a valid url.");

                if (File.Exists(ProgramConfiguration.PodcastFileName))
                {
                    Logger.Log.Info($"PodcastFileName exists. Path is {ProgramConfiguration.PodcastFileName}.");
                    Logger.Log.Info("Add the podcast url.");
                    output.WriteLine("Adding...");
                    string podcastName = Opml.AddPodcast(url);
                    output.WriteLine("Have added a new podcast.");
                    output.WriteLine($"Name: {podcastName}");
                    output.WriteLine($"URL: {url}");
                    Logger.Log.Info($"Url has been added. Name: {podcastName}; URL: {url}.");
                }
                else
                {
                    Logger.Log.Info($"PodcastFileName does NOT exist. Path is {ProgramConfiguration.PodcastFileName}.");
                    Logger.Log.Info("Create the opml file.");
                    output.WriteLine("Not find old profile, creating a new one...");
                    Opml.Create();
                    output.WriteLine("Have created a new profile.");
                    Logger.Log.Info("The opml file has benn created.");
                    Logger.Log.Info("Add the podcast url.");
                    string podcastName = Opml.AddPodcast(url);
                    output.WriteLine("Have added a new podcast.");
                    output.WriteLine($"Name: {podcastName}");
                    output.WriteLine($"URL: {url}");
                    Logger.Log.Info($"Url has been added. Name: {podcastName}; URL: {url}.");
                }
            }
            else
            {
                Logger.Log.Warn("The Add command input string is NOT a valid url.");

                output.WriteLine("URL is not valid.");
            }

            return(0);
        }
Esempio n. 21
0
        public void Serialize()
        {
            Opml opml = new Opml();
            OpmlOutline a           =new OpmlOutline();
            a.title = "a";
            a.xmlUrl ="a.xml";
            opml.body.outline.Add(a);

            XmlSerializer ser = new XmlSerializer(typeof(Opml));
            using (Stream s = File.OpenWrite("opml.txt"))
            {
                ser.Serialize(s, opml);
            }
        }
Esempio n. 22
0
        private static int Execute(CommandArgs commandArgs, IOutput output)
        {
            Logger.Log.Info("Enter Show command.");

            string podcastName = commandArgs.GetParameter <string>(PodcastName);

            Logger.Log.Info($"Get the Show command input string, is {podcastName}.");

            string detail = Opml.ShowPodcastDetail(podcastName);

            Logger.Log.Info("Show the podcast detail results.");
            output.WriteLine(detail);
            return(0);
        }
Esempio n. 23
0
        /// <summary>
        /// Subscribes to the RSS feeds supplied in the OPML object.
        /// </summary>
        /// <param name="opml">The Opml object.</param>
        /// <returns>The Opml object.</returns>
        public static Opml SubscribeOpml(Opml opml)
        {
            if (opml == null)
            {
                throw new ArgumentNullException();
            }

            foreach (OpmlItem item in opml.Items)
            {
                FeedEngine.Subscribe(new Uri(item.XmlUrl));
            }

            return(opml);
        }
Esempio n. 24
0
        private static int Execute(CommandArgs commandArgs, IOutput output)
        {
            Logger.Log.Info("Enter Update command.");

            //File.Delete(ProgramConfiguration.PodcastNewlyReleaseInfo);

            output.WriteLine("Updating...");
            Logger.Log.Info("Show the update results.");

            int count = Opml.UpdateAllPodcasts(ref output);

            output.WriteLine(count == 0 ? "All up-to-date." : "pdlm was updated successfully!");

            return(0);
        }
Esempio n. 25
0
        public void LoadOpmlNullInputTest()
        {
            ArgumentNullException expected = null;

            try
            {
                Opml opml = FeedEngine.LoadOpml(null);
            }
            catch (ArgumentNullException ex)
            {
                expected = ex;
            }

            Assert.IsNotNull(expected);
        }
Esempio n. 26
0
        public void SubscribeOpmlNullObjectInputTest()
        {
            ArgumentNullException expected = null;

            try
            {
                Opml opml = FeedEngine.SubscribeOpml((Opml)null);
            }
            catch (ArgumentNullException ex)
            {
                expected = ex;
            }

            Assert.IsNotNull(expected);
        }
Esempio n. 27
0
        public void SubscribeOpmlEmptyStringInputTest()
        {
            ArgumentException expected = null;

            try
            {
                Opml opml = FeedEngine.SubscribeOpml(string.Empty);
            }
            catch (ArgumentException ex)
            {
                expected = ex;
            }

            Assert.IsNotNull(expected);
        }
Esempio n. 28
0
        public void Serialize()
        {
            Opml        opml = new Opml();
            OpmlOutline a    = new OpmlOutline();

            a.title  = "a";
            a.xmlUrl = "a.xml";
            opml.body.outline.Add(a);

            XmlSerializer ser = new XmlSerializer(typeof(Opml));

            using (Stream s = File.OpenWrite("opml.txt"))
            {
                ser.Serialize(s, opml);
            }
        }
Esempio n. 29
0
        private async void OnLoaded(object sender, RoutedEventArgs e)
        {
            var folder = Package.Current.InstalledLocation;

            using (var stream = await folder.OpenStreamForReadAsync("sample-opml.xml"))
            {
                var opml = await Opml.ParseAsync(stream);

                var outlines = opml.GetOutlines();
                RssList.Clear();
                foreach (var outline in outlines)
                {
                    RssList.Add(outline);
                }
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Loads the OPML file.
        /// </summary>
        /// <param name="opmlPath">The full path to the OPML file.</param>
        /// <returns>The Opml object.</returns>
        public static Opml LoadOpml(string opmlPath)
        {
            if (opmlPath == null)
            {
                throw new ArgumentNullException();
            }
            if (opmlPath == string.Empty)
            {
                throw new ArgumentException();
            }

            OpmlParser parser = new OpmlParser();
            Opml       opml   = parser.Process(opmlPath);

            return(opml);
        }
 private void LoadOutline(string fileName)
 {
     if (File.Exists(fileName))
     {
         using (Stream s = File.OpenRead(fileName))
         {
             XmlSerializer ser = new XmlSerializer(typeof(Opml));
             opmlTree = ser.Deserialize(s) as Opml;
         }
     }
     if (opmlTree == null)
     {
         opmlTree = new Opml("Generated by newtelligence dasBlog 1.0");
     }
     Session["newtelligence.DasBlog.Web.EditBlogRollBox.OpmlTree"] = opmlTree;
 }
Esempio n. 32
0
        public void CreateChildOpmlTest()
        {
            Opml opml = new Opml();

            opml.Encoding = "UTF-8";
            opml.Version  = "2.0";

            Head head = new Head();

            head.Title = "mySubscriptions.opml";
            opml.Head  = head;

            Outline outline = new Outline();

            outline.Text = "IT";

            Outline childOutline = new Outline();

            childOutline.Text    = "CNET News.com";
            childOutline.HTMLUrl = "http://news.com.com/";
            childOutline.XMLUrl  = "http://news.com.com/2547-1_3-0-5.xml";

            outline.Outlines.Add(childOutline);

            Body body = new Body();

            body.Outlines.Add(outline);
            opml.Body = body;

            StringBuilder xml = new StringBuilder();

            xml.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n");
            xml.Append("<opml version=\"2.0\">\r\n");
            xml.Append("<head>\r\n");
            xml.Append("<title>mySubscriptions.opml</title>\r\n");
            xml.Append("</head>\r\n");
            xml.Append("<body>\r\n");
            xml.Append("<outline text=\"IT\">\r\n");
            xml.Append("<outline text=\"CNET News.com\" ");
            xml.Append("htmlUrl=\"http://news.com.com/\" ");
            xml.Append("xmlUrl=\"http://news.com.com/2547-1_3-0-5.xml\" />\r\n");
            xml.Append("</outline>\r\n");
            xml.Append("</body>\r\n");
            xml.Append("</opml>");

            Assert.True(opml.ToString() == xml.ToString());
        }
Esempio n. 33
0
        private void LoadOutline( string fileName )
        {
            if ( File.Exists( fileName ) )
            {
                using (Stream s = File.OpenRead(fileName))
                {
                    XmlSerializer ser = new XmlSerializer(typeof(Opml));
                    opmlTree = ser.Deserialize(s) as Opml;
                }

            }
            if ( opmlTree == null )
            {
                opmlTree = new Opml("Generated by newtelligence dasBlog 1.0");
            }            
            Session["newtelligence.DasBlog.Web.EditBlogRollBox.OpmlTree"] = opmlTree;
        }
        private XmlElement LoadBlogroll( string fileName )
        {
            // This may seem horribly inefficient, but we need to run this
            // through the object model once to make sure we're schema compliant
            // We can't emit OPML schema into WSDL, because the friggin' spec defines 
            // no namespace
            XmlSerializer ser = new XmlSerializer(typeof(Opml));
            Opml opmlTree=null;
            
            if ( File.Exists( fileName ) )
            {
                using (Stream s = File.OpenRead(fileName))
                {
                    opmlTree = ser.Deserialize(s) as Opml;
                }

            }
            if ( opmlTree == null )
            {
                opmlTree = new Opml("Generated by newtelligence dasBlog 1.4");
            }
            
            XmlDocument xmlDoc = new XmlDocument();
            MemoryStream memStream = new MemoryStream();
            XmlTextWriter xtw = new XmlTextWriter(memStream,System.Text.Encoding.UTF8);
            ser.Serialize( xtw, opmlTree );
            xtw.Flush();

            memStream.Position = 0;

            XmlTextReader xtr = new XmlTextReader(memStream);            
            xmlDoc.Load( xtr );
            return xmlDoc.DocumentElement;
        }
Esempio n. 35
0
        protected void buttonCreate_Click(object sender, System.EventArgs e)
        {
            if ( textNewFileName.Text.Length > 0 )
            {
                // Get the requested file name to create and stip off any extra directories
                string fileName = textNewFileName.Text;
                fileName = Path.GetFileName( fileName );
                
                // Double check that there is an extension.  If not, tag on opml
                if ( Path.GetExtension( fileName ) == String.Empty )
                    fileName = fileName + ".opml";
                
                // Add this to the list of current file names and select it as active
                listFiles.Items.Add( fileName );
                listFiles.SelectedValue = fileName;
                Session["newtelligence.DasBlog.Web.EditBlogRollBox.baseFileName"] = baseFileName = fileName;

                // This will created during LoadOutline, but have to clear it out first, otherwise this new blogroll
                // will get a copy of the currently selected one, instead of starting fresh
                opmlTree = null;

                LoadOutline( Path.Combine(SiteConfig.GetConfigPathFromCurrentContext(),baseFileName ));
                BindGrid();

                textNewFileName.Text = "";
            }
        }