Ejemplo n.º 1
0
 public List<FrontPageArticleEntity> GetFeatures(HtmlDocument doc)
 {
     List<FrontPageArticleEntity> frontPageFeatureList = new List<FrontPageArticleEntity>();
     HtmlNode frontPageNode = doc.DocumentNode.Descendants("ul").FirstOrDefault(node => node.GetAttributeValue("class", string.Empty).Contains("featured"));
     foreach (HtmlNode frontPageFeature in frontPageNode.Descendants("li"))
     {
         FrontPageArticleEntity article = new FrontPageArticleEntity();
         article.ParseFeatured(frontPageFeature);
         frontPageFeatureList.Add(article);
     }
     return frontPageFeatureList;
 }
Ejemplo n.º 2
0
        /// <summary>
        ///     Populates the page with content passed during navigation. Any saved state is also
        ///     provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        ///     The source of the event; typically <see cref="NavigationHelper" />
        /// </param>
        /// <param name="e">
        ///     Event data that provides both the navigation parameter passed to
        ///     <see cref="Frame.Navigate(Type, Object)" /> when this page was initially requested and
        ///     a dictionary of state preserved by this page during an earlier
        ///     session. The state will be null the first time a page is visited.
        /// </param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            // TODO: This view should NOT need to do any html parsing. Get this out of here!
            HtmlDocument doc = await _frontPageManager.GetFrontPage();
            DefaultViewModel["PopularThreads"] = _frontPageManager.GetPopularThreads(doc);
            DefaultViewModel["PopularTrends"] = _frontPageManager.GetPopularTrends(doc);
            List<FrontPageArticleEntity> frontPageArticles = _frontPageManager.GetFrontPageArticles(doc);

            FrontPageArticleEntity mainArticle = frontPageArticles.FirstOrDefault();
            DefaultViewModel["MainArticle"] = mainArticle;
            _mainArticle = mainArticle;
            frontPageArticles.Remove(mainArticle);

            DefaultViewModel["FrontPageArticles"] = frontPageArticles;
            DefaultViewModel["FrontPageFeatures"] = _frontPageManager.GetFeatures(doc);
        }
Ejemplo n.º 3
0
 public List<FrontPageArticleEntity> GetFrontPageArticles(HtmlDocument doc)
 {
     List<FrontPageArticleEntity> frontPageArticleList = new List<FrontPageArticleEntity>();
     HtmlNode frontPageNode = doc.DocumentNode.Descendants("div").FirstOrDefault(node => node.GetAttributeValue("class", string.Empty).Contains("main_article"));
     FrontPageArticleEntity mainArticle = new FrontPageArticleEntity();
     mainArticle.ParseMainArticle(frontPageNode);
     frontPageArticleList.Add(mainArticle);
     frontPageNode = doc.DocumentNode.Descendants("ul").FirstOrDefault(node => node.GetAttributeValue("class", string.Empty).Contains("news"));
     foreach(HtmlNode frontPageNewsArticle in frontPageNode.Descendants("li"))
     {
         FrontPageArticleEntity article = new FrontPageArticleEntity();
         article.ParseFrontPageArticle(frontPageNewsArticle);
         frontPageArticleList.Add(article);
     }
     return frontPageArticleList;
 }