public ActionResult Delete(string id)
        {
            var model = new PostworthyArticleModel(PrimaryUser);
            model.DeleteArticle(id.GetUintHashCode());

            return RedirectToAction("Admin", new { id = PrimaryUser.TwitterScreenName });
        }
 /*public ActionResult Directory()
 {
     return View(UsersCollection.All());
 }*/
 public ActionResult Archive()
 {
     //if (MobileHelper.IsMobileDevice(Request.UserAgent)) return RedirectToAction("about", "mobile");
     ViewBag.Archive = true;
     ViewBag.Home = false;
     var model = new PostworthyArticleModel(PrimaryUser);
     return View(model.GetArticleStubIndex());
 }
Beispiel #3
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 ActionResult Create(Article article)
        {
            try
            {
                SplitTags(article);
                GetImages(article);

                article.PublishedBy = PrimaryUser.TwitterScreenName;
                article.PublishedDate = DateTime.Now;

                var model = new PostworthyArticleModel(PrimaryUser);

                model.SaveArticle(article);

                return Json(new { result = "success" }, JsonRequestBehavior.AllowGet);
            }
            catch
            {
                return Json(new { result = "failure" }, JsonRequestBehavior.AllowGet);
            }
        }
        public ActionResult Details(uint id, string slug, bool seo = false)
        {
            Article article = null;

            var model = new PostworthyArticleModel(PrimaryUser);

            if (slug != "p" && seo == true)
            {
                article = model.GetArticle(id);
                if (article != null)
                    ViewBag.RelatedArticles = model
                        .Articles(x =>
                            x.ID() != article.ID() &&
                            x.Tags.Any(y =>
                                article.Tags.Where(z =>
                                    z.ToLower() == y.ToLower()).Any()))
                        .Where(x => x != null)
                        .Take(3)
                        .ToList();
                else
                    ViewBag.RelatedArticles = null;
            }
            else if(slug == "p")
            {
                var oldURL = (Session[id.ToString()] ?? id.ToString()).ToString().ToLower();

                if (!string.IsNullOrEmpty(oldURL))
                {
                    article = model.Articles(x => x.MetaData.Where(y =>
                        y.Key == OLD_URL &&
                        (
                            y.Value.ToLower() == oldURL ||
                            y.Value.ToLower().EndsWith("?p="+id.ToString())  ||
                            y.Value.ToLower().EndsWith("?id="+id.ToString())
                        )).Any())
                        .FirstOrDefault();

                    if (article != null)
                        return RedirectPermanent("~/article/" + article.GetSlug() + "_" + article.ID());
                }
            }
            else if(!seo)
            {
                article = model.GetArticle(id);
                return RedirectPermanent("~/article/" + article.GetSlug() + "_" + article.ID());
            }

            if (article != null)
            {
                article.Tags = article.Tags.Select(x => GetTagLink(x)).ToList();
                ViewBag.Tags = model.GetArticleIndex().Articles.SelectMany(x => x.Tags).Distinct().Select(x => GetTagLink(x));
                return View(article);
            }
            else
                return RedirectToAction("Index", new { id = 0 });
        }
 public ActionResult Admin()
 {
     var model = new PostworthyArticleModel(PrimaryUser);
     return View(model.GetArticleIndex());
 }
 public ActionResult TwitterCardMeta(uint id, string slug)
 {
     var model = new PostworthyArticleModel(PrimaryUser);
     return View(model.GetArticle(id));
 }
        public ActionResult Index(int id = 0, string slug = "")
        {
            slug = slug.ToLower();
            ViewBag.Slug = slug;
            ViewBag.Page = id;
            ViewBag.PageSize = PAGE_SIZE;

            var model = new PostworthyArticleModel(PrimaryUser);
            int pageCount = 0;
            var viewModel = model.PagedArticles(PAGE_SIZE * id, PAGE_SIZE, slug, out pageCount);

            ViewBag.Tags = model.GetArticleIndex().Articles.SelectMany(x => x.Tags).Distinct().Select(x => GetTagLink(x));
            ViewBag.PageCount = pageCount;

            return View(viewModel);
        }
        public ActionResult Index(string slug, DateTime? id = null)
        {
            DateTime date = DateTime.Now;
            if (id.HasValue)
                date = id.Value;

            ViewBag.Date = date;

            var model = new PostworthyArticleModel(PrimaryUser);
            model.ExcludeArticleStub(date, slug);

            HttpResponse.RemoveOutputCacheItem(Url.RouteUrl(Request.RequestContext.RouteData.Values));

            return RedirectToAction("Index", new { id = !id.HasValue ? null : (id.Value.ToShortDateString().Replace('/', '-')) });
        }
        public ActionResult Edit(string id)
        {
            var model = new PostworthyArticleModel(PrimaryUser);
            var article = model.GetArticle(id.GetUintHashCode());

            if (article != null)
                return View("Create", article);
            else
                return RedirectToAction("Admin", new { id = PrimaryUser.TwitterScreenName });
        }
Beispiel #11
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("~/");
        }
Beispiel #12
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("~/");
        }
Beispiel #13
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("~/");
        }
Beispiel #14
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();
     }
 }
        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 ActionResult Edit(string id, Article article)
        {
            try
            {
                //article.PublishedBy = PrimaryUser.TwitterScreenName;
                //article.PublishedDate = DateTime.Now;
                SplitTags(article);
                GetImages(article);

                var model = new PostworthyArticleModel(PrimaryUser);
                model.EditArticle(article);

                var route = @Url.RouteUrl("Article", new { controller = "article", action = "details", id = article.ID(), slug = article.GetSlug() });

                Response.RemoveOutputCacheItem(route);

                return Json(new { result = "success" }, JsonRequestBehavior.AllowGet);
            }
            catch
            {
                return Json(new { result = "failure" }, JsonRequestBehavior.AllowGet);
            }
        }
Beispiel #17
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));
        }