private SiteNameNode Add(Site s) { ProfileNameNode pnn = (ProfileNameNode)sitesTreeView.Nodes[0]; Profile p = pnn.Profile; p.Add(s); return CreateSiteNodes(s); }
public void FetchingSucceeded(Site s) { if (thread.IsAlive == false) { threadRunning = true; thread.Start(); } }
protected override Article CreateArticle(Site s, XPathNavigator navigator) { Article output = new Article(s.Guid); UpdateTitle(output, navigator); UpdateContent(output, navigator); UpdateUri(output, navigator); UpdateMedias(output, navigator); return output; }
private void addRssFetcherMenuItem_Click(object sender, EventArgs e) { Site s = new Site(); s.Name = GFResources.GetString("RSS_FEED_DEFAULT_NAME"); s.Uri = new Uri(GFResources.GetString("RSS_FEED_DEFAULT_URI")); s.FetcherPlugin = "GetFacts.Plugins.RssFetcher"; TreeNode tn = Add(s); tn.Expand(); sitesTreeView.Focus(); sitesTreeView.SelectedNode = tn; }
protected override XPathNodeIterator CreateArticlesIterator(Site s, XPathNavigator navigator) { // RSS XPathNodeIterator output = navigator.Select("/rss/channel/item"); if (output.Count == 0) { // ATOM output = navigator.Select("/atom:feed/atom:entry", xmlnsManager); } return output; }
/// <summary> /// Analyze the content of the XML data freshly fetched from /// the Site and return a FrontPage filled with all the required information. /// The method does not process the Articles. /// </summary> /// <param name="s">The Site from which the XML data has been collected</param> /// <param name="navigator">The XPathNavigator set to explore the XML data</param> /// <returns>A fully filled FrontPage object, without Articles.</returns> protected override FrontPage CreateFrontPage(Site s, XPathNavigator navigator) { // Create the front page with the default values FrontPage output = new FrontPage(s.Guid); UpdateTitle(output, navigator); UpdateCaption(output, navigator); UpdateUri(output, navigator); return output; }
public void FetchingSucceeded(Site s) { treeView1.BeginInvoke((MethodInvoker)delegate { // Find or create a node in the tree for that site TreeNode siteNode = FindOrCreateRoot(s.Guid); // Change the icon of the node siteNode.ImageKey = "site_idle.png"; siteNode.SelectedImageKey = siteNode.ImageKey; }); }
public FrontPage Fetch(Site s) { // Retrieve the url of the document, get it and // create an XmlDocument from the raw document. XmlDocument doc = GetXmlDocument(s.Uri); Prefetch(doc); XPathNavigator navigator = doc.CreateNavigator(); // Create a new FrontPage (without articles) FrontPage output = CreateFrontPage(s, navigator); // Get an iterator to scan through all the articles in the XML XPathNodeIterator articlesIterator = CreateArticlesIterator(s, navigator); // browse through all articles while (articlesIterator.MoveNext() == true) { Article a = CreateArticle(s, articlesIterator.Current); output.Add(a); } return output; }
internal void Add(Site s) { sites.Add(s); }
private void ProcessSite(Site s) { Database database = Database.GetInstance(); // Prepare a list of all articles in the database // for the Site List<Article> toBeRemoved = null; // obtain the plugin that can fetch the data string pluginName = s.FetcherPlugin; using (IFetcherPlugin plugin = PluginsManager.GetInstance().GetFetcher(pluginName) ) { FrontPage fetchedData = plugin.Fetch(s); toBeRemoved = database.Push(fetchedData); } // remove articles that are not available // anymore on the Site. if ((toBeRemoved != null) && (toBeRemoved.Count > 0)) { database.Remove(toBeRemoved); } }
private void FetchSite(Site s) { viewer.FetchingStarted(s); try { ProcessSite(s); viewer.FetchingSucceeded(s); } catch (Exception e) { viewer.FetchingFailed(s, e); throw; } finally { } }
internal LayoutNode(Site s) : base(s.LayoutPlugin) { this.site = s; }
internal SiteNameNode(Site s) : base(s.Name) { this.site = s; }
internal SiteUriNode(Site s) : base(s.Uri) { this.site = s; }
private static List<Profile> Load(string srcFile) { Hashtable profiles = new Hashtable(); // read xml using (FileStream fs = File.Open(srcFile, FileMode.Open, FileAccess.Read)) { using (StreamReader sr = new StreamReader(fs, Encoding.Unicode)) { using (XmlReader input = XmlReader.Create(sr)) { while (input.Read()) { if (input.NodeType == XmlNodeType.Element) { if (input.Name == "profile") { using (XmlReader subTree = input.ReadSubtree()) { Profile p = new Profile(subTree); profiles[p.Guid] = p; } } if (input.Name == "site") { string guid = input.GetAttribute("profile"); Guid profileId = new Guid(guid); using (XmlReader subTree = input.ReadSubtree()) { Site s = new Site(subTree); Profile p = (Profile)profiles[profileId]; p.Add(s); } } } } } } } List<Profile> output = new List<Profile>(); foreach (Profile p in profiles.Values) { output.Add(p); } return output; }
/// <summary> /// Loads use profiles from the XML backup. /// </summary> /// <returns></returns> private static List<Profile> DemoProfile() { List<Profile> output = new List<Profile>(); Profile demoProfile = new Profile(Guid.Empty); demoProfile.Name = "Demo"; demoProfile.Description = "Select this profile to get a glimpse at what GetFacts can do..."; output.Add(demoProfile); Site ignRss = new Site(new Guid("a6268b26-13c3-8d53-1e34-8f862f168475")); ignRss.Name = "IGN Video reviews"; ignRss.FetcherPlugin = "GetFacts.Plugins.RssFetcher"; ignRss.Uri = new Uri("http://feeds.ign.com/ign/video-reviews"); demoProfile.Add(ignRss); Site devBestOfRss = new Site(new Guid("b99b539a-67e0-4079-8a76-0468f302ff2c")); devBestOfRss.Name = "Developpez.net - Débats sur le développement, le best of"; devBestOfRss.FetcherPlugin = "GetFacts.Plugins.RssFetcher"; devBestOfRss.Uri = new Uri("http://www.developpez.net/forums/external.php?type=RSS2&forumids=40"); demoProfile.Add(devBestOfRss); Site devEmploiRss = new Site(new Guid("efbb9d1e-e644-4530-9b3d-95c8fb381339")); devEmploiRss.Name = "Developpez.net - Emploi"; devEmploiRss.FetcherPlugin = "GetFacts.Plugins.RssFetcher"; devEmploiRss.Uri = new Uri("http://www.developpez.net/forums/external.php?type=RSS2&forumids=258"); demoProfile.Add(devEmploiRss); Site slateFrRss = new Site(new Guid("af3b0618-f4de-4772-b0d2-a6de8b5edd27")); slateFrRss.Name = "Slate.fr"; slateFrRss.FetcherPlugin = "GetFacts.Plugins.RssFetcher"; slateFrRss.Uri = new Uri("http://www.slate.fr/rss.xml"); demoProfile.Add(slateFrRss); Site rue89Rss = new Site(new Guid("cd614176-e942-4da2-ab21-d6e1d367ee82")); rue89Rss.Name = "Rue89"; rue89Rss.FetcherPlugin = "GetFacts.Plugins.RssFetcher"; rue89Rss.Uri = new Uri("http://www.rue89.com/feed"); demoProfile.Add(rue89Rss); Site clubicRss = new Site(new Guid("89ba3fca-09b4-4c84-9bed-1b8d12034fe3")); clubicRss.Name = "clubic.com"; clubicRss.FetcherPlugin = "GetFacts.Plugins.RssFetcher"; clubicRss.Uri = new Uri("http://www.clubic.com/articles.rss"); demoProfile.Add(clubicRss); return output; }
private void SiteToXml(Profile p, Site s, XmlTextWriter w) { w.WriteStartElement("site"); w.WriteAttributeString("profile", p.Guid.ToString()); w.WriteElementString("guid", s.Guid.ToString()); w.WriteElementString("name", s.Name); w.WriteElementString("url", s.Uri.ToString()); w.WriteElementString("plugin", s.FetcherPlugin); w.WriteElementString("layout", s.LayoutPlugin); w.WriteEndElement(); }
public void FetchingStarted(Site s) { //throw new NotImplementedException(); }
public void FetchingSucceeded(Site s) { if (articlesRotatorThread.IsAlive == false) { rotatorThreadRunning = true; articlesRotatorThread.Start(); } if (articlesPopupThread.IsAlive == false) { popupThreadRunning = true; articlesPopupThread.Start(); } }
/// <summary> /// Analyze the content of the XML data freshly fetched from /// the Site and return a FrontPage filled with all the required information. /// The method does not process the Articles. /// </summary> /// <param name="s">The Site from which the XML data has been collected</param> /// <param name="navigator">The XPathNavigator set to explore the XML data</param> /// <returns>A fully filled FrontPage object, without Articles.</returns> protected abstract FrontPage CreateFrontPage(Site s, XPathNavigator navigator);
protected abstract XPathNodeIterator CreateArticlesIterator(Site s, XPathNavigator navigator);
protected abstract Article CreateArticle(Site s, XPathNavigator navigator);
public void FetchingFailed(Site s, Exception e) { //throw new NotImplementedException(); }
internal bool Contains(Site s) { return sites.Contains(s); }
internal bool Remove(Site s) { return sites.Remove(s); }
private SiteNameNode CreateSiteNodes(Site s) { TreeNode root = sitesTreeView.Nodes[s.FetcherPlugin]; SiteNameNode siteNameNode = new SiteNameNode(s); root.Nodes.Add(siteNameNode); SiteUriNode siteUriNode = new SiteUriNode(s); siteNameNode.Nodes.Add(siteUriNode); LayoutNode layoutNode = new LayoutNode(s); siteNameNode.Nodes.Add(layoutNode); return siteNameNode; }