예제 #1
0
        public async Task <ActionResult> load()
        {
            var json   = new StreamReader(Request.Body).ReadToEnd();
            var data   = JsonConvert.DeserializeObject <BlogEntity>(json);
            var _posts = await BlogsBLL.LoadItems(_context, data);

            /* setup thumb path */
            foreach (var ph in _posts)
            {
                ph.url         = BlogUrlConfig.Generate_Post_Url(ph);
                ph.description = BlogScripts.PrepareShortDescription(ph.description, 2);
                Setup_Item(ph);
            }
            var _categories = new List <JGN_Categories>();

            if (data.loadstats)
            {
                _categories = await CategoryBLL.LoadItems(_context, new CategoryEntity()
                {
                    id         = 0,
                    type       = 6,
                    mode       = 0,
                    isenabled  = EnabledTypes.All,
                    parentid   = -1,
                    order      = "level asc", // don't change this
                    issummary  = false,
                    isdropdown = true,
                    loadall    = true // load all data
                });
            }
            var _records = 0;

            if (data.postid == 0)
            {
                _records = await BlogsBLL.Count(_context, data);
            }

            var settings = new
            {
                general = Jugnoon.Blogs.Configs.BlogSettings,
                aws     = Jugnoon.Blogs.Configs.AwsSettings
            };

            return(Ok(new { posts = _posts, records = _records, categories = _categories, settings = settings }));
        }
예제 #2
0
        public async Task <ActionResult> getinfo()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <BlogEntity>(json);

            data.nofilter = true;
            var _posts = await BlogsBLL.LoadItems(_context, data);

            if (_posts.Count > 0)
            {
                if (_posts[0].picture_url != "")
                {
                    var _pics = _posts[0].picture_url.Split(char.Parse(","));
                    _posts[0].files = new List <FileEntity>();
                    foreach (var pic in _pics)
                    {
                        _posts[0].files.Add(new FileEntity()
                        {
                            filename = pic,
                            img_url  = pic
                        });
                    }
                }

                Setup_Item(_posts[0]);

                _posts[0].author.img_url = UserUrlConfig.ProfilePhoto(_posts[0].author.Id, _posts[0].author.picturename, 0);
                // array of associate category list
                _posts[0].category_list = await CategoryContentsBLL.FetchContentCategoryList(_context, data.id, (byte)CategoryContentsBLL.Types.Blogs);

                return(Ok(new { status = "success", post = _posts[0] }));
            }
            else
            {
                return(Ok(new { status = "error", message = SiteConfig.generalLocalizer["_no_records"].Value }));
            }
        }
예제 #3
0
        // GET: post
        public async Task <IActionResult> Index(long?id, string title)
        {
            if (id == null)
            {
                return(Redirect(Config.GetUrl("blogs")));
            }

            var model = new PostViewModel();

            model.isExist = true;

            var _lst = await BlogsBLL.LoadItems(_context, new BlogEntity()
            {
                id         = (long)id,
                isapproved = ApprovedTypes.All,
                ispublic   = false,
                isenabled  = EnabledTypes.Enabled
            });

            if (_lst.Count == 0)
            {
                model.isExist = false;
                return(View(model));
            }

            model.Post = _lst[0];
            // fetch associated categories
            model.Post.category_list = await CategoryContentsBLL.FetchContentCategoryList(_context, model.Post.id, (byte)CategoryContentsBLL.Types.Blogs);

            model.PermaUrl = BlogUrlConfig.Generate_Post_Url(new JGN_Blogs()
            {
                id    = (long)id,
                title = model.Post.title
            });

            if (model.Post.isadult == 1)
            {
                // 1:-> adult content, 0:-> non adult content
                var getValue = HttpContext.Session.GetString("adultmember");
                if (getValue == null)
                {
                    return(Redirect(Config.GetUrl("default/validateadult?surl=" + WebUtility.UrlEncode(model.PermaUrl) + "")));;
                }
            }

            // increment views
            model.Post.views++;
            BlogsBLL.Update_Field_V3(_context, (long)id, _lst[0].views, "views");

            string meta_title = _lst[0].title;

            if (meta_title == "")
            {
                meta_title = "Post ID: " + _lst[0].id;
            }

            ViewBag.title = meta_title;

            string _desc = UtilityBLL.StripHTML(_lst[0].description);

            if (_desc == "")
            {
                _desc = _lst[0].title;
            }
            else if (_desc.Length > 160)
            {
                _desc = _desc.Substring(0, 160);
            }

            ViewBag.description = _desc + ", posted date: " + _lst[0].created_at + ", PostID: " + _lst[0].id;

            ViewBag.RSS = Config.GetUrl("agency/rss");

            ViewBag.ATOM = Config.GetUrl("agency/atom");

            return(View(model));
        }
예제 #4
0
        // GET: blogs
        public async Task <IActionResult> Index(string order, string filter, int?pagenumber)
        {
            ViewBag.BlogsTabCss = "active";

            if (pagenumber == null)
            {
                pagenumber = 1;
            }

            string _order          = "blog.created_at desc";
            var    _dateFilter     = DateFilter.AllTime;
            var    _featuredFilter = FeaturedTypes.All;
            /* ***************************************/
            // Process Page Meta & BreaCrumb
            /* ***************************************/
            var pageOrder  = "recent";
            var pageFilter = "";

            if (order != null)
            {
                pageOrder = order;
            }
            if (filter != null)
            {
                pageFilter = filter;
            }
            var _meta = PageMeta.returnPageMeta(new PageQuery()
            {
                controller = ControllerContext.ActionDescriptor.ControllerName,
                index      = ControllerContext.ActionDescriptor.ActionName,
                order      = pageOrder,
                filter     = pageFilter,
                pagenumber = (int)pagenumber
            });

            // pagination
            var DefaultUrl    = Config.GetUrl("blogs/");
            var PaginationUrl = Config.GetUrl("blogs/page/[p]/");

            // order
            var selectedOrder  = SiteConfig.generalLocalizer["_recent"].Value;
            var selectedFilter = SiteConfig.generalLocalizer["_all_time"].Value;

            if (order != null)
            {
                DefaultUrl    = Config.GetUrl("blogs/" + order.ToLower().Trim());
                PaginationUrl = Config.GetUrl("blogs/" + order.ToLower().Trim() + "/[p]/");
                switch (order)
                {
                case "featured":
                    selectedOrder   = SiteConfig.generalLocalizer["_featured"].Value;
                    _order          = "blog.created_at desc";
                    _featuredFilter = FeaturedTypes.Featured;
                    break;
                }
            }

            if (filter != null)
            {
                // pagination setting
                if (filter == "today" || filter == "thisweek" || filter == "thismonth")
                {
                    DefaultUrl    = Config.GetUrl("blogs/added/" + filter.ToLower().Trim());
                    PaginationUrl = Config.GetUrl("blogs/added/" + filter.ToLower().Trim() + "/[p]/");
                }

                switch (filter)
                {
                case "today":
                    selectedFilter = SiteConfig.generalLocalizer["_today"].Value;
                    _dateFilter    = DateFilter.Today;
                    break;

                case "thisweek":
                    selectedFilter = SiteConfig.generalLocalizer["_this_week"].Value;
                    _dateFilter    = DateFilter.ThisWeek;
                    break;

                case "thismonth":
                    selectedFilter = SiteConfig.generalLocalizer["_this_month"].Value;
                    _dateFilter    = DateFilter.ThisWeek;
                    break;
                }
            }

            /* List Initialization */
            var ListEntity = new BlogListViewModel()
            {
                isListStatus = false,
                Navigation   = prepareFilterLinks("/blogs/", selectedOrder, selectedFilter),
                QueryOptions = new BlogEntity()
                {
                    pagenumber = (int)pagenumber,
                    term       = "",
                    iscache    = true,
                    ispublic   = true,
                    pagesize   = Jugnoon.Settings.Configs.GeneralSettings.pagesize,
                    isfeatured = _featuredFilter,
                    datefilter = _dateFilter,
                    order      = _order,
                },
                ListObject = new ListItems()
                {
                    // ColWidth = "col-md-4 col-masonry",
                    ListType = ListType.List, // 0: grid 1: list
                },
                HeadingTitle      = _meta.title,
                BreadItems        = _meta.BreadItems,
                DefaultUrl        = DefaultUrl,
                PaginationUrl     = PaginationUrl,
                NoRecordFoundText = SiteConfig.generalLocalizer["_no_records"].Value,
            };

            ListEntity.TotalRecords = await BlogsBLL.Count(_context, ListEntity.QueryOptions);

            if (ListEntity.TotalRecords > 0)
            {
                ListEntity.DataList = await BlogsBLL.LoadItems(_context, ListEntity.QueryOptions);
            }

            // Page Meta Description
            ViewBag.title       = _meta.title;
            ViewBag.description = _meta.description;
            ViewBag.keywords    = _meta.keywords;
            ViewBag.imageurl    = _meta.imageurl;

            return(View(ListEntity));
        }
예제 #5
0
        // GET: blogs/archive
        public async Task <IActionResult> archive(string month, int?year, string order, int?pagenumber)
        {
            if (pagenumber == null)
            {
                pagenumber = 1;
            }

            if (month == null || year == null)
            {
                return(Redirect(Config.GetUrl("blogs/")));
            }

            /* ***************************************/
            // Process Page Meta & BreaCrumb
            /* ***************************************/
            var _meta = PageMeta.returnPageMeta(new PageQuery()
            {
                controller = ControllerContext.ActionDescriptor.ControllerName,
                index      = ControllerContext.ActionDescriptor.ActionName,
                pagenumber = (int)pagenumber,
                matchterm  = month,
                matchterm2 = year.ToString()
            });

            /* List Initialization */
            var ListEntity = new BlogListViewModel()
            {
                isListStatus = false,
                isListNav    = false,
                QueryOptions = new BlogEntity()
                {
                    pagenumber = (int)pagenumber,
                    term       = "",
                    month      = UtilityBLL.ReturnMonth(month),
                    year       = (int)year,
                    iscache    = false,
                    ispublic   = true,
                    isfeatured = FeaturedTypes.All,
                    pagesize   = 20,
                    order      = "blog.created_at desc",
                },
                ListObject = new ListItems()
                {
                    ListType = ListType.List,
                },
                HeadingTitle      = _meta.title,
                BreadItems        = _meta.BreadItems,
                DefaultUrl        = Config.GetUrl("blogs/archive/" + month + "/" + year + "/"),
                PaginationUrl     = Config.GetUrl("blogs/archive/" + month + "/" + year + "/[p]/"),
                NoRecordFoundText = SiteConfig.generalLocalizer["_no_records"].Value,
            };

            ListEntity.TotalRecords = await BlogsBLL.Count(_context, ListEntity.QueryOptions);

            if (ListEntity.TotalRecords > 0)
            {
                ListEntity.DataList = await BlogsBLL.LoadItems(_context, ListEntity.QueryOptions);
            }


            /**********************************************/
            // Page Meta Setup
            /**********************************************/
            ViewBag.title       = _meta.title;
            ViewBag.description = _meta.description;

            return(View(ListEntity));
        }