Exemple #1
0
        public async Task <ActionResult> Index()
        {
            ActionResult result = null;

            var model = new PageModel();

            model.Url = Request.Url.PathAndQuery.Replace("?", string.Empty);

            model.Authorized = await Policies.EvaluatePage((string)Session["Username"], Request.Url.PathAndQuery.Replace("?", string.Empty));

            if (model.Authorized)
            {
                foreach (var i in await Groups.GetGroups())
                {
                    model.Groups.Add(new GroupModel()
                    {
                        Name    = i.Name,
                        Builtin = i.Builtin
                    });
                }

                var page = await Pages.GetPageByUrl(Request.Url.PathAndQuery);

                if (page != null)
                {
                    model.Url      = page.Url;
                    model.Name     = page.Name;
                    model.Group    = page.Group;
                    model.Markdown = page.Body;
                    model.Html     = await Markdown.Convert(page);
                }
            }
            else
            {
                model.Name     = "Unauthorized";
                model.Markdown = "You're not authorized to view this page. Please contact your system administrator.";
                model.Html     = await Markdown.Convert(model.Markdown);
            }

            result = View(model);

            return(result);
        }