public RiverSubscription(Opml opml) : this() { Title = opml.Title; DateCreated = opml.DateCreated; DateModified = opml.DateModified; var line = 0; foreach (var x in opml.Outlines) { line++; var item = new RiverSubscriptionItem(); foreach (var y in x.Attributes) { try { if (y.Key == "text") item.Text = y.Value; else if (y.Key == "name") item.Name = y.Value; else if (y.Key == "url" && !string.IsNullOrWhiteSpace(y.Value)) item.JSONPUri = new Uri(y.Value); } catch (Exception ex) { ParsingErrors.Add("Error at line " + line + " in processing attribute " + y.Key + " with value " + y.Value + " " + ex.Message); } } Items.Add(item); } }
public void LoadFromXML() { var opml = new Opml(); opml.LoadFromXML(_sampleOPML); Trace.WriteLine("Hello " + opml.Title); Assert.IsNotNull(opml.Title); Assert.IsTrue(opml.Title == "mySubscriptions.opml"); Assert.IsTrue(opml.OwnerEmail == "*****@*****.**"); Assert.IsTrue(opml.Outlines.Count > 0, "Outlines must be greater than zero"); }
public void TestSyndicationFetcher() { var opml = new Opml(); opml.LoadFromXML(_sampleOPML); var subscription = new RssSubscription(opml); var fetcher = new SyndicationFetcher(); var feeds = fetcher.DownloadAll(subscription); Assert.IsTrue(feeds.Count > 0, "All downloads must be bigger than zero"); }
public ActionResult Index(string url) { var uri = new Uri(url); var subFetcher = new SubscriptionFetcher(); var xml = subFetcher.Download(Texts.FromUriHost(uri), uri.PathAndQuery); var opml = new Opml(); opml.LoadFromXML(xml); var subscription = new RssSubscription(opml); var fetcher = new SyndicationFetcher(); var feeds = fetcher.DownloadAll(subscription); return Content("Feeds " + feeds.Count); }
public void LoadFromOPML() { var opml = new Opml(); var res = opml.LoadFromXML(_sample); Assert.IsTrue(res.IsTrue, "OPML loading must be true, not " + res.Message); var subscription = new RiverSubscription(opml); Assert.IsTrue(subscription.Items.Count > 0, "River must contains items"); Assert.IsTrue(subscription.Items.Count > 0); var item1 = subscription.Items.First(); Assert.IsNotNullOrEmpty(item1.Text); // Assert.IsNotNullOrEmpty(item1.Name); //depending on sample data // Assert.IsNotNullOrEmpty(item1.Description); //depending on sample data Assert.IsNotNullOrEmpty(item1.JSONPUri.ToString()); }
public void FromOpml(string id, Opml opmlFile) { this.Id = id; this.Title = opmlFile.Title; if(opmlFile.OwnerId != null) this.OwnerId = opmlFile.OwnerId.ToString(); this.OwnerName = opmlFile.OwnerName; this.OwnerEmail = opmlFile.OwnerEmail; this.DateCreated = opmlFile.DateCreated.HasValue ? opmlFile.DateCreated.Value.ToString("R") : DateTime.UtcNow.ToString("R"); this.DateModified = opmlFile.DateModified.HasValue ? opmlFile.DateModified.Value.ToString("R") : DateTime.UtcNow.ToString("R"); Body = new List<EditorOutline>(); foreach (var outline in opmlFile.Outlines) { var editorOutline = new EditorOutline(); Body.Add(editorOutline); TraverseEditor(outline, editorOutline); } }
public ActionResult SyndicationLists() { var lists = this.RavenSession.Query<SyndicationList>() .ToList(); var opml = new Opml(); opml.Title = "Hobi Published Syndication List"; opml.OwnerName = "hobieu"; opml.Outlines.AddRange(lists.Select(x => { var outline = new Outline(); outline.Attributes["type"] = "link"; outline.Attributes["text"] = x.Title; outline.Attributes["name"] = x.Name; outline.Attributes["url"] = Texts.FromUriHost(Request.Url) + "/s/" + x.Name; return outline; })); var xml = opml.ToXML(); this.Compress(); return Content(xml.ToString(), "text/xml"); }
public ActionResult TabbedRivers() { var rivers = this.RavenSession.Query<RiverWall>() .Where(x => x.Status == RiverWallStatus.Published || x.Status == RiverWallStatus.Draft).ToList(); var opml = new Opml(); opml.Title = "Hobi Published Wall List"; opml.OwnerName = "hobieu"; opml.Outlines.AddRange(rivers.Select(x => { var outline = new Outline(); outline.Attributes["type"] = "link"; outline.Attributes["text"] = x.Title; outline.Attributes["name"] = x.Name; outline.Attributes["url"] = Texts.FromUriHost(Request.Url) + "/r/" + x.Name; outline.Attributes["opmlUrl"] = Texts.FromUriHost(Request.Url) + "/r/opml/" + x.Name; return outline; })); var xml = opml.ToXML(); this.Compress(); return Content(xml.ToString(), "text/xml"); }
public void SaveSyndicationList() { var syndication = new SyndicationList(); syndication.Id = SyndicationList.NewId("dodyg").Full(); syndication.Guid = Stamp.GUID().ToString(); syndication.Name = "dodyg"; syndication.Title = "Dody's Syndication Wall"; syndication.Description = "Amazing Wall"; syndication.Keywords = "dody, syndication"; var opml = new Opml(); opml.LoadFromXML(_sampleOPML); syndication.Sources = new RssSubscription(opml); using (var store = Raven.GetStoreFromServer()) { using (var session = store.OpenSession(Raven.DATABASE_NAME)) { session.Store(syndication); session.SaveChanges(); } } }
public Opml GetFeedsOpml(List<BlogFeed> feeds, HttpRequestBase request) { if (Id.IsNullOrWhiteSpace()) throw new ApplicationException("This blog must have an id before performing GetFeedsOpml operations"); var opml = new Opml { Title = Title, DateCreated = DateCreated, }; foreach (var i in feeds.Select( x => { var item = new Outline(); item.Attributes["text"] = x.Title; item.Attributes["type"] = "rss"; item.Attributes["name"] = Texts.ConvertTitleToName(x.Title); if (!string.IsNullOrWhiteSpace(x.Description)) item.Attributes["description"] = x.Description; item.Attributes["htmlUrl"] = x.GetHtmlLink(request); item.Attributes["xmlUrl"] = x.GetRssLink(request); return item; })) { opml.Outlines.Add(i); } return opml; }
public IQuerySetOne<RiverSubscription> FetchDefaultRivers() { string cacheKey = "DEFAULT_RIVERS"; var cache = HttpContext.Cache[cacheKey] as RiverSubscription; if (cache != null) { return new QuerySetOne<RiverSubscription>(cache); } else { var fetcher = new SubscriptionFetcher(); #if DEBUG var xml = fetcher.Download(Texts.FromUriHost(Request.Url), "api/1/default/RiversSubscription"); #else var xml = fetcher.Download("http://hobihobi.apphb.com", "api/1/default/RiversSubscription"); #endif var opml = new Opml(); var res = opml.LoadFromXML(xml); if (res.IsTrue) { var subscriptionList = new RiverSubscription(opml); HttpContext.Cache.Add(cacheKey, subscriptionList, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 10, 0), CacheItemPriority.Default, null); return new QuerySetOne<RiverSubscription>(subscriptionList); } else { return new QuerySetOne<RiverSubscription>(null); } } }
public Opml ToOpml() { var opml = new Opml { Title = Title, OwnerName = OwnerName, OwnerEmail = OwnerEmail, DateCreated = DateCreated, DateModified = DateModified }; foreach (var i in Items.Select( x => { var item = new Outline(); item.Attributes["text"] = x.Text; item.Attributes["type"] = "rss"; if (!string.IsNullOrWhiteSpace(x.Name)) item.Attributes["name"] = x.Name; if (!string.IsNullOrWhiteSpace(x.Description)) item.Attributes["description"] = x.Description; if (x.HtmlUri != null) item.Attributes["htmlUrl"] = x.HtmlUri.ToString(); if (x.XmlUri != null) item.Attributes["xmlUrl"] = x.XmlUri.ToString(); return item; })) { opml.Outlines.Add(i); } return opml; }
public Opml RenderToOpml() { var opml = new Opml(); opml.DateCreated = DateTime.UtcNow; opml.DateModified = DateTime.UtcNow; opml.Title = "OPML Document with Id " + Id; opml.OwnerName = "temporary"; opml.OwnerName = "*****@*****.**"; foreach (var x in Body) { var o = new Outline(); opml.Outlines.Add(o); TraverseOpml(x, o); } return opml; }
public void LoadFromOPML() { var opml = new Opml(); opml.LoadFromXML(_sample); var subscription = new RssSubscription(opml); Assert.IsTrue(subscription.Items.Count > 0); var item1 = subscription.Items.First(); Assert.IsNotNullOrEmpty(item1.Title); Assert.IsNotNullOrEmpty(item1.Text); Assert.IsNotNullOrEmpty(item1.Name); Assert.IsNotNullOrEmpty(item1.Description); Assert.IsNotNullOrEmpty(item1.HtmlUri.ToString()); Assert.IsNotNullOrEmpty(item1.XmlUri.ToString()); }