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 & Stuff</title>\r\n"); xml.Append("<ownerName>Me, myself & I</ownerName>\r\n"); xml.Append("</head>\r\n"); xml.Append("<body>\r\n"); xml.Append("<outline text=\"Things & Stuff News\" category=\"Things & Stuff\" description=\"Things & Stuff News\" title=\"Things & Stuff News\" />\r\n"); xml.Append("</body>\r\n"); xml.Append("</opml>"); Assert.True(opml.ToString() == xml.ToString()); }
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"); }
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); } }
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()); }
public string ExportOpml() { var opml = new Opml { Body = new Body(), Head = new Head() }; foreach (var source in _siteService.AsQueryable().ToList()) { foreach (var channel in source.Channels) { opml.Body.Outlines.Add(new Outline() { HTMLUrl = source.SiteUrl, Title = source.SiteName, Text = source.SiteName, XMLUrl = source.SiteUrl + channel.Link }); } } return(opml.ToString()); }
public void WithNamespaceTest() { Opml opml = new Opml(); opml.Encoding = "UTF-8"; opml.Version = "2.0"; opml.UseNamespace = true; Head head = new Head(); head.Title = "mySubscriptions.opml"; opml.Head = head; Outline outline = new Outline(); outline.Text = "CNET News.com"; 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\" xmlns=\"http://opml.org/spec2\">\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 "); xml.Append("text=\"CNET News.com\" "); xml.Append("/>\r\n"); xml.Append("</body>\r\n"); xml.Append("</opml>"); Assert.True(opml.ToString() == xml.ToString()); }
public void CreateNormalOpmlTest() { Opml opml = new Opml(); opml.Encoding = "UTF-8"; opml.Version = "2.0"; Head head = new Head(); head.Title = "mySubscriptions.opml"; head.DateCreated = DateTime.Parse("Sat, 18 Jun 2005 12:11:52 GMT").ToUniversalTime(); head.DateModified = DateTime.Parse("Tue, 02 Aug 2005 21:42:48 GMT").ToUniversalTime(); head.OwnerName = "fnya"; head.OwnerEmail = "*****@*****.**"; head.OwnerId = "http://news.com.com/"; head.Docs = "http://news.com.com/"; head.ExpansionState.Add("1"); head.ExpansionState.Add("6"); head.ExpansionState.Add("13"); head.ExpansionState.Add("16"); head.ExpansionState.Add("18"); head.ExpansionState.Add("20"); head.VertScrollState = "1"; head.WindowTop = "106"; head.WindowLeft = "106"; head.WindowBottom = "558"; head.WindowRight = "479"; opml.Head = head; Outline outline = new Outline(); outline.Text = "CNET News.com"; outline.IsComment = "true"; outline.IsBreakpoint = "true"; outline.Created = DateTime.Parse("Tue, 02 Aug 2005 21:42:48 GMT").ToUniversalTime(); outline.Category.Add("/Harvard/Berkman"); outline.Category.Add("/Politics"); outline.Description = "Tech news and business reports by CNET News.com."; outline.HTMLUrl = "http://news.com.com/"; outline.Language = "unknown"; outline.Title = "CNET News.com"; outline.Type = "rss"; outline.Version = "RSS2"; outline.XMLUrl = "http://news.com.com/2547-1_3-0-5.xml"; 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("<dateCreated>Sat, 18 Jun 2005 12:11:52 GMT</dateCreated>\r\n"); xml.Append("<dateModified>Tue, 02 Aug 2005 21:42:48 GMT</dateModified>\r\n"); xml.Append("<ownerName>fnya</ownerName>\r\n"); xml.Append("<ownerEmail>[email protected]</ownerEmail>\r\n"); xml.Append("<ownerId>http://news.com.com/</ownerId>\r\n"); xml.Append("<docs>http://news.com.com/</docs>\r\n"); xml.Append("<expansionState>1,6,13,16,18,20</expansionState>\r\n"); xml.Append("<vertScrollState>1</vertScrollState>\r\n"); xml.Append("<windowTop>106</windowTop>\r\n"); xml.Append("<windowLeft>106</windowLeft>\r\n"); xml.Append("<windowBottom>558</windowBottom>\r\n"); xml.Append("<windowRight>479</windowRight>\r\n"); xml.Append("</head>\r\n"); xml.Append("<body>\r\n"); xml.Append("<outline "); xml.Append("text=\"CNET News.com\" "); xml.Append("isComment=\"true\" "); xml.Append("isBreakpoint=\"true\" "); xml.Append("created=\"Tue, 02 Aug 2005 21:42:48 GMT\" "); xml.Append("category=\"/Harvard/Berkman,/Politics\" "); xml.Append("description=\"Tech news and business reports by CNET News.com.\" "); xml.Append("htmlUrl=\"http://news.com.com/\" "); xml.Append("language=\"unknown\" "); xml.Append("title=\"CNET News.com\" "); xml.Append("type=\"rss\" "); xml.Append("version=\"RSS2\" "); xml.Append("xmlUrl=\"http://news.com.com/2547-1_3-0-5.xml\" "); xml.Append("/>\r\n"); xml.Append("</body>\r\n"); xml.Append("</opml>"); Assert.True(opml.ToString() == xml.ToString()); }