GetArticleStubPage() public method

public GetArticleStubPage ( System.DateTime date ) : ArticleStubPage
date System.DateTime
return Postworthy.Models.Web.ArticleStubPage
Ejemplo n.º 1
0
        public void ExcludeArticleStub(DateTime date, string slug)
        {
            var dayTag = "_" + date.ToShortDateString();
            var model  = new PostworthyArticleModel(PrimaryUser);
            var page   = model.GetArticleStubPage(date);

            var article = page.ArticleStubs.Where(s => s.GetSlug() == slug).FirstOrDefault();

            page.ExcludedArticleStubs.Add(article);

            page.ExcludedArticleStubs = page.ExcludedArticleStubs.Distinct().ToList();

            CachedRepository <ArticleStubPage> .Instance(PrimaryUser.TwitterScreenName).Save(TwitterModel.Instance(PrimaryUser.TwitterScreenName).CONTENT + dayTag, page);
        }
        public void ExcludeArticleStub(DateTime date, string slug)
        {
            var dayTag = "_" + date.ToShortDateString();
            var model = new PostworthyArticleModel(PrimaryUser);
            var page = model.GetArticleStubPage(date);

            var article = page.ArticleStubs.Where(s => s.GetSlug() == slug).FirstOrDefault();
            page.ExcludedArticleStubs.Add(article);

            page.ExcludedArticleStubs = page.ExcludedArticleStubs.Distinct().ToList();

            CachedRepository<ArticleStubPage>.Instance(PrimaryUser.TwitterScreenName).Save(TwitterModel.Instance(PrimaryUser.TwitterScreenName).CONTENT + dayTag, page);
        }
Ejemplo n.º 3
0
        public ActionResult Videos(DateTime? id)
        {
            DateTime date = DateTime.Now;
            if (id.HasValue)
                date = id.Value;

            ViewBag.Date = date;

            var model = new PostworthyArticleModel(PrimaryUser);
            var page = model.GetArticleStubPage(date);

            var videos = page.ArticleStubs.Where(s => s.Video != null).ToList();

            ViewBag.Videos = videos;

            if (videos != null && videos.Count > 0)
                return View("Video", null);
            else
                return RedirectPermanent("~/");
        }
Ejemplo n.º 4
0
        public ActionResult Video(DateTime? id, string slug)
        {
            DateTime date = DateTime.Now;
            if (id.HasValue)
                date = id.Value;

            ViewBag.Date = date;

            var model = new PostworthyArticleModel(PrimaryUser);
            var page = model.GetArticleStubPage(date);

            var videos = page.ArticleStubs.Where(s => s.Video != null).ToList();
            var stub = videos.Where(s => s.GetSlug() == slug).FirstOrDefault();

            ViewBag.Videos = videos;

            if (stub != null)
                return View("Video", stub);
            else
                return RedirectPermanent("~/");
        }
Ejemplo n.º 5
0
        public ActionResult Photos(DateTime? id)
        {
            DateTime date = DateTime.Now;
            if (id.HasValue)
                date = id.Value;

            ViewBag.Date = date;

            var model = new PostworthyArticleModel(PrimaryUser);
            var page = model.GetArticleStubPage(date);
            var photoStubs = page.ArticleStubs.Where(s => IMAGE_DOMAINS.Contains(s.Link.Authority.ToLower())).ToList();

            if (photoStubs != null && photoStubs.Count > 0)
                return View("Photos", photoStubs);
            else
                return RedirectPermanent("~/");
        }
Ejemplo n.º 6
0
 public ActionResult Out(DateTime id, string slug)
 {
     var model = new PostworthyArticleModel(PrimaryUser);
     var articles = model.GetArticleStubPage(id).ArticleStubs;
     var article = articles
         .Where(x => x.GetSlug().ToLower() == slug.ToLower())
         .FirstOrDefault();
     ViewBag.OriginalPage = "~/" + id.ToShortDateString().Replace("/", "-");
     if (article != null)
     {
         if (Request.UrlReferrer != null && Request.UrlReferrer.Authority != Request.Url.Authority)
             return View(article);
         else
         {
             ViewBag.Outbound = article.Link.ToString();
             return View();
         }
     }
     else
     {
         ViewBag.OriginalPage = "~/";
         ViewBag.Outbound = Url.Content("~/");
         Response.StatusCode = 404;
         return View();
     }
 }
Ejemplo n.º 7
0
        public ActionResult Index(DateTime? id = null, string slug = null)
        {
            var p = Request.QueryString["p"];
            if (!string.IsNullOrEmpty(p))
            {
                Session[p] = Request.Url.ToString();
                return RedirectToAction("Details", "Article", new { id = p, slug = "p" });
            }

            if (Request.Url.ToString().ToLower().Contains("/home/article?id=") || Request.Url.ToString().ToLower().Contains("/home/article/?id="))
            {
                Session[Request.QueryString["id"]] = Request.Url.ToString();
                return RedirectToAction("Details", "Article", new { id = Request.QueryString["id"], slug = "p" });
            }

            DateTime date = DateTime.Now;
            if (id.HasValue)
            {
                date = id.Value;
                if (!string.IsNullOrEmpty(slug))
                {
                    switch (slug)
                    {
                        case PHOTOS_SLUG:
                            return Photos(DateTime.Now.ToShortDateString() != date.ToShortDateString() ? (DateTime?)date : null);
                        case VIDEOS_SLUG:
                            return Videos(DateTime.Now.ToShortDateString() != date.ToShortDateString() ? (DateTime?)date : null);
                        default:
                            return Video(DateTime.Now.ToShortDateString() != date.ToShortDateString() ? (DateTime?)date : null, slug);
                    }
                }
            }

            var model = new PostworthyArticleModel(PrimaryUser);
            var articles = model.GetArticleIndex();

            if (articles.Articles.Count >= 5 && !id.HasValue && PrimaryUser.EnableFrontPage)
                return FrontPage();

            ViewBag.Date = date;
            ViewBag.ArticleStubIndex = model.GetArticleStubIndex();
            ViewBag.ArticlesIndex = articles;

            return View(model.GetArticleStubPage(date));
        }