Ejemplo n.º 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 }));
        }
Ejemplo n.º 2
0
        private void Setup_Item(JGN_Blogs blg)
        {
            blg.files = new List <FileEntity>();

            if (blg.cover_url == null)
            {
                blg.cover_url = "";
            }

            if (blg.picture_url == null)
            {
                blg.picture_url = "";
            }

            if (blg.cover_url != "")
            {
                blg.cover_url = BlogUtil.Return_Blog_Cover(blg.cover_url);
            }

            if (blg.picture_url != "")
            {
                var _pics = blg.picture_url.Split(char.Parse(","));
                foreach (var pic in _pics)
                {
                    string imgUrl = BlogUtil.Return_Blog_Image(pic, Jugnoon.Blogs.Configs.BlogSettings.default_path);

                    blg.files.Add(new FileEntity()
                    {
                        filename = pic,
                        img_url  = imgUrl
                    });
                }
            }
            if (blg.created_at == null)
            {
                blg.created_at = DateTime.Now;
            }
            blg.url        = BlogUrlConfig.Generate_Post_Url(blg);
            blg.author_url = UserUrlConfig.ProfileUrl(blg.author, Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption);
            // process content
            blg.description = UtilityBLL.Process_Content_Text(blg.description);
        }
Ejemplo n.º 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));
        }