コード例 #1
0
        public ActionResult Show(PagePath pagePath, string id)
        {
            var loadContext = _pageService.Load(pagePath);
            if (loadContext == null)
            {
                return this.RedirectToWikiPage(pagePath);
            }

            var tocBuilder = new TableOfContentsBuilder();
            tocBuilder.Compile(loadContext.Body);

            var tree = _pageTreeRepository.Get(loadContext.Page.Id);
            var model = new ShowViewModel
                            {
                                Body = loadContext.Body,
                                PagePath = pagePath,
                                Title = loadContext.Page.Title,
                                UpdatedAt = loadContext.Page.UpdatedAt,
                                UserName = loadContext.Page.UpdatedBy.DisplayName,
                                BackLinks = loadContext.Page.BackReferences.ToList(),
                                TableOfContents = tocBuilder.GenerateList(),
                                Path = tree.CreateLinksForPath(Url.WikiRoot())
                            };

            return View("Show", model);
        }
コード例 #2
0
ファイル: Pager.cs プロジェクト: radtek/documentor
        private async Task <PageMetadata> GetPageMetadataAsync(PagePath pagePath)
        {
            string metadata = await _pageIOManager.LoadMetadataAsync(pagePath.Location.GetDirectoryPath());

            PageMetadata pageMetadata = new PageMetadata();

            if (!string.IsNullOrWhiteSpace(metadata))
            {
                try
                {
                    pageMetadata = JsonConvert.DeserializeObject <PageMetadata>(metadata);
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, "Metadata invalid");
                }
            }

            if (string.IsNullOrWhiteSpace(pageMetadata.Title))
            {
                pageMetadata.Title = pagePath.Location.GetDestinationFolder().VirtualName;
            }

            return(pageMetadata);
        }
コード例 #3
0
 public ActionResult Improve(PagePath id, int revision)
 {
     var page = _repository.Get(id);
     var subject = page.Revisions.Single(x => x.Id == revision);
     subject.ApproveButWillImprove();
     return RedirectToRoute("WikiAdmin", new { controller = "Page", action = "Edit", id = id.ToString() });
 }
コード例 #4
0
ファイル: Pager.cs プロジェクト: radtek/documentor
        private async Task <PageData> GetPageDataAsync(PagePath pagePath)
        {
            DirectoryInfo pagesDirectory = _pageIOManager.GetPagesDirectory();
            DirectoryInfo cacheDirectory = _cacheManager.GetCacheDirectory();

            _cacheManager.ClearCache();

            FileInfo pageFileInfo = new FileInfo(Path.Combine(pagesDirectory.FullName, pagePath.ToString()));

            string pageLocationHash = Hasher.GetMd5Hash(pagePath.Location.GetDirectoryPath());
            string pageCachename    = pageLocationHash + "_" + pageFileInfo.LastWriteTime.ToString("yyyyMMddHHmmss") + Cache.PagePostfix;
            string pageCache        = await _cacheManager.LoadFromCacheAsync(pageCachename);

            string markdown = await _pageIOManager.LoadPage(pageFileInfo.FullName);

            string html;

            if (!string.IsNullOrEmpty(pageCache))
            {
                html = pageCache;
            }
            else
            {
                _cacheManager.ClearCache(pageLocationHash + "*" + Cache.PagePostfix);
                html = _markdownConverter.ConvertToHtml(markdown);

                await _cacheManager.SaveToCacheAsync(pageCachename, html);
            }

            return(new PageData(markdown, html));
        }
コード例 #5
0
 public ActionResult Approve(PagePath id, int revision)
 {
     var page = _repository.Get(id);
     var subject = page.Revisions.Single(x => x.Id == revision);
     subject.Approve();
     if (Request.IsAjaxRequest())
         return Json(new { success = true });
     return RedirectToAction("Index");
 }
コード例 #6
0
 /// <summary>
 /// Find three depths (-1, current, children)
 /// </summary>
 /// <param name="pagePath">Page to get map from</param>
 /// <returns>Items sorted by depths and titles</returns>
 public IEnumerable<WikiPageTreeNode> GetPartial(PagePath pagePath)
 {
     var myNode = _session.Query<WikiPageTreeNode>().First(x => x.Page.PagePath == pagePath);
     return (from x in _session.Query<WikiPageTreeNode>().Fetch(x => x.Page)
             where (x.Depth == myNode.Depth - 1 && x.Lineage.StartsWith(myNode.ParentLinage))
                   || (x.Depth == myNode.Depth && x.Lineage.StartsWith(myNode.ParentLinage))
                   || (x.Depth == myNode.Depth + 1 && x.Lineage.StartsWith(myNode.Lineage))
             orderby x.Depth, x.Titles
             select x).ToList();
 }
コード例 #7
0
        private string CreateHtmlLink(PagePath parsedPage, WikiLink link)
        {
            if (link.Exists)
            {
                return string.Format(@"<a href=""{0}"" class=""wiki-link"">{1}</a>", parsedPage.GetPathRelativeTo(link.PagePath), link.Title);
            }

            return string.Format(
                @"<a href=""{0}?title={1}"" class=""wiki-link missing"">{2}</a>", parsedPage.GetPathRelativeTo(link.PagePath),
                link.Title, link.Title);
        }
コード例 #8
0
        private Control getPagePath()
        {
            var pagePath =
                new PagePath(
                    currentPageBehavior:
                    getEntityResourceGroups().Any()
                                                        ? PagePathCurrentPageBehavior.IncludeCurrentPageAndExcludePageNameIfEntitySetupExists
                                                        : PagePathCurrentPageBehavior.IncludeCurrentPage);

            return(pagePath.IsEmpty ? null : pagePath);
        }
コード例 #9
0
ファイル: Pager.cs プロジェクト: radtek/documentor
        public async Task <PageContext> GetPageContextAsync(string virtualPath)
        {
            PagePath pagePath = GetPagePath(virtualPath);

            if (pagePath == null)
            {
                throw new AppException("Page not found");
            }
            PageMetadata pageMetadata = await GetPageMetadataAsync(pagePath);

            return(new PageContext(pagePath, pageMetadata));
        }
コード例 #10
0
        private Control getPagePath()
        {
            var entitySetupInfo = EwfPage.Instance.InfoAsBaseType.EsInfoAsBaseType;
            var pagePath        =
                new PagePath(
                    currentPageBehavior:
                    entitySetupInfo != null && EwfPage.Instance.InfoAsBaseType.ParentResource == null && entitySetupInfo.Resources.Any()
                                                        ? PagePathCurrentPageBehavior.IncludeCurrentPageAndExcludePageNameIfEntitySetupExists
                                                        : PagePathCurrentPageBehavior.IncludeCurrentPage);

            return(pagePath.IsEmpty ? null : pagePath);
        }
コード例 #11
0
ファイル: Route.cs プロジェクト: oqtane/oqtane.framework
        /// <summary>
        /// default constructor
        /// the route parameter can be obtained from NavigationManager.Uri on client or HttpContext.Request.GetEncodedUrl() on server
        /// the aliaspath parameter can be obtained from PageState.Alias.Path on client or TenantManager.GetAlias().Path on server
        /// </summary>
        public Route(string route, string aliaspath)
        {
            Uri uri = new Uri(route);

            Authority     = uri.Authority;
            Scheme        = uri.Scheme;
            Host          = uri.Host;
            Port          = uri.Port.ToString();
            Query         = uri.Query;
            Fragment      = uri.Fragment;
            AbsolutePath  = uri.AbsolutePath;
            AliasPath     = aliaspath;
            PagePath      = AbsolutePath;
            ModuleId      = "";
            Action        = "";
            UrlParameters = "";

            if (AliasPath.Length != 0 && PagePath.StartsWith("/" + AliasPath))
            {
                PagePath = PagePath.Substring(AliasPath.Length + 1);
            }
            int pos = PagePath.IndexOf("/" + Constants.UrlParametersDelimiter + "/");

            if (pos != -1)
            {
                UrlParameters = PagePath.Substring(pos + 3);
                PagePath      = PagePath.Substring(1, pos);
            }
            pos = PagePath.IndexOf("/" + Constants.ModuleDelimiter + "/");
            if (pos != -1)
            {
                ModuleId = PagePath.Substring(pos + 3);
                PagePath = PagePath.Substring(1, pos);
            }
            if (ModuleId.Length != 0)
            {
                pos = ModuleId.IndexOf("/");
                if (pos != -1)
                {
                    Action   = ModuleId.Substring(pos + 1);
                    ModuleId = ModuleId.Substring(0, pos);
                }
            }
            if (PagePath.StartsWith("/"))
            {
                PagePath = (PagePath.Length == 1) ? "" : PagePath.Substring(1);
            }
            if (PagePath.EndsWith("/"))
            {
                PagePath = PagePath.Substring(0, PagePath.Length - 1);
            }
        }
コード例 #12
0
ファイル: WikiPage.cs プロジェクト: jgauffin/Griffin.Wiki
        /// <summary>
        ///   Initializes a new instance of the <see cref="WikiPage" /> class.
        /// </summary>
        /// <param name="parent"> Parent page. </param>
        /// <param name="pagePath"> Absolute path from wiki root. </param>
        /// <param name="title"> Page title. </param>
        /// <param name="template"> Template to use for child pages (if any). </param>
        public WikiPage(WikiPage parent, PagePath pagePath, string title, PageTemplate template)
        {
            if (pagePath == null) throw new ArgumentNullException("pagePath");
            if (title == null) throw new ArgumentNullException("title");

            Parent = parent;
            PagePath = pagePath;
            Title = title;
            CreatedBy = WikiContext.Current.User;
            CreatedAt = DateTime.Now;
            UpdatedAt = DateTime.Now;
            ChildTemplate = template;
            _backReferences = new List<WikiPage>();
        }
コード例 #13
0
        public ActionResult Show(PagePath id, int revision)
        {
            var page = _repository.Get(id);
            var subject = page.Revisions.Single(x => x.Id == revision);


            return View(new ShowViewModel
                            {
                                Body = subject.HtmlBody,
                                CreatedBy = subject.CreatedBy.DisplayName,
                                PagePath = page.PagePath,
                                RevisionId = revision
                            });
        }
コード例 #14
0
        private void AddChildren(PagePath pagePath, string pageUri, SiteMapNode currentMapNode, WikiPageTreeNode currentTreeNode,
                                 IEnumerable<WikiPageTreeNode> completeTree)
        {
            foreach (var childTreeNode in completeTree.Where(x => x.ParentLinage == currentTreeNode.Lineage))
            {
                var child = new SiteMapNode(childTreeNode.Page.Title, childTreeNode.Path,
                                            childTreeNode.CreateLink(pageUri),
                                            childTreeNode.CreateLinksForPath(pageUri));
                if (child.Path.Equals(pagePath))
                    child.IsCurrent = true;

                currentMapNode.AddChild(child);
                AddChildren(pagePath, pageUri, child, childTreeNode, completeTree);
            }
        }
コード例 #15
0
ファイル: Pager.cs プロジェクト: radtek/documentor
        public async Task <Page> GetPageAsync(string virtualPath)
        {
            PagePath pagePath = GetPagePath(virtualPath);

            if (pagePath == null)
            {
                return(null);
            }

            PageData pageData = await GetPageDataAsync(pagePath);

            PageMetadata pageMetadata = await GetPageMetadataAsync(pagePath);

            return(new Page(new PageContext(pagePath, pageMetadata), pageData));
        }
コード例 #16
0
        /// <summary>
        ///   Get a site map for three levels only (previous, current, children)
        /// </summary>
        /// <param name="pagePath"> /path/to/page/ of the page to generate the partial map for </param>
        /// <param name="pageUri"> Uri to the action that shows a page </param>
        /// <returns> Hierchical site map </returns>
        /// <example>
        ///   var map = siteMapService.Get("BestPractices", Url.Action("Show", "Page"));
        /// </example>
        public IEnumerable<SiteMapNode> GetPartial(PagePath pagePath, string pageUri)
        {
            if (!_pageTreeRepository.Exists(pagePath))
                return new LinkedList<SiteMapNode>();

            var completeTree = _pageTreeRepository.GetPartial(pagePath);
            var nodes = new List<SiteMapNode>();

            var minDepth = completeTree.OrderBy(x => x.Depth).FirstOrDefault().Depth;
            foreach (var pageTreeNode in completeTree.Where(x => x.Depth == minDepth))
            {
                var node = new SiteMapNode(pageTreeNode.Page.Title, pageTreeNode.Path, pageTreeNode.CreateLink(pageUri),
                                           pageTreeNode.CreateLinksForPath(pageUri));
                if (node.Path.Equals(pagePath))
                    node.IsCurrent = true;
                nodes.Add(node);
                AddChildren(pagePath, pageUri, node, pageTreeNode, completeTree);
            }

            return nodes;
        }
コード例 #17
0
        public ActionResult Index(PagePath id = null)
        {
            _logger.Warning("Get id " + id);
            var images = id == null
                             ? _repository.FindAll()
                             : _repository.FindForPage(id);


            if (Request.Headers["Accept"].Contains("json"))
            {
                var response = new
                                   {
                                       success = true,
                                       body = images.Select(CreateImageModel).ToList()
                                   };
                return Json(response, JsonRequestBehavior.AllowGet);
            }
            return ViewOrPartial(new IndexViewModel
                                     {
                                         Images = images,
                                         PagePath = (id ?? new WikiRoot()).ToString()
                                     });
        }
コード例 #18
0
ファイル: Pager.cs プロジェクト: radtek/documentor
        public async Task <Page> EditPageAsync(PagePath pagePath, string markdown)
        {
            if (pagePath == null)
            {
                throw new ArgumentNullException(nameof(pagePath));
            }

            DirectoryInfo pagesDirectory = _pageIOManager.GetPagesDirectory();
            FileInfo      pageFileInfo   = new FileInfo(Path.Combine(pagesDirectory.FullName, pagePath.ToString()));

            string pageLocationHash = Hasher.GetMd5Hash(pagePath.Location.GetDirectoryPath());
            string pageCachename    = pageLocationHash + "_" + pageFileInfo.LastWriteTime.ToString("yyyyMMddHHmmss") + Cache.PagePostfix;

            _cacheManager.ClearCache(pageCachename);

            await _pageIOManager.SavePage(pageFileInfo.FullName, markdown);

            PageData pageData = await GetPageDataAsync(pagePath);

            PageMetadata pageMetadata = await GetPageMetadataAsync(pagePath);

            return(new Page(new PageContext(pagePath, pageMetadata), pageData));
        }
コード例 #19
0
ファイル: Pager.cs プロジェクト: radtek/documentor
        public async Task ModifyPageAsync(PageModifyCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            PagePath pagePath = GetPagePath(command.VirtualPath);

            if (pagePath == null)
            {
                throw new AppException("Page not found");
            }

            _cacheManager.ClearCache("*" + Cache.NavPostfix);

            string pageDirectoryPath = pagePath.Location.GetDirectoryPath();

            PageMetadata pageMetadata = await GetPageMetadataAsync(pagePath);

            pageMetadata.Title       = command.Title;
            pageMetadata.Description = command.Description;
            await _pageIOManager.SaveMetadataAsync(pageDirectoryPath, pageMetadata);

            if (!command.VirtualName.Equals(pagePath.Location.GetDestinationFolder().VirtualName))
            {
                string pagesDirectoryPath   = _pageIOManager.GetPagesDirectory().FullName;
                string oldPageDirectoryName = pagePath.Location.GetDestinationFolder().DirectoryName;
                string newPageDirectoryPath = pageDirectoryPath.Remove(pageDirectoryPath.LastIndexOf(Separator.Path) + 1) +
                                              oldPageDirectoryName.Split(Separator.Sequence)[0] +
                                              Separator.Sequence +
                                              command.VirtualName;
                string fakePageDirectoryPath = newPageDirectoryPath + "_";
                Directory.Move(Path.Combine(pagesDirectoryPath, pageDirectoryPath), Path.Combine(pagesDirectoryPath, fakePageDirectoryPath));
                Directory.Move(Path.Combine(pagesDirectoryPath, fakePageDirectoryPath), Path.Combine(pagesDirectoryPath, newPageDirectoryPath));
            }
        }
コード例 #20
0
 public ActionResult ReviewRequired(PagePath id)
 {
     return View(id);
 }
コード例 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MissingPageLink"/> class.
 /// </summary>
 /// <param name="page">Page that links to a missing page.</param>
 /// <param name="missingPagePath">Name of the missing page.</param>
 public MissingPageLink(WikiPage page, PagePath missingPagePath)
 {
     Page = page;
     MissingPagePath = missingPagePath.ToString();
 }
コード例 #22
0
        private PagePath CreatePath(PagePath pagePath, string linkPath)
        {
            // child page
            if (!linkPath.Contains("..") && !linkPath.Contains("/"))
                return new PagePath(pagePath + linkPath + "/");

            if (linkPath.Contains(".."))
                return new RelativePagePath(pagePath, linkPath).ToAbsolute();

            return linkPath.StartsWith("/")
                       ? new PagePath(linkPath)
                       : pagePath.CreateChildPath(linkPath);
        }
コード例 #23
0
 public WikiPageTreeNode GetByPath(PagePath pageName)
 {
     return _session.Query<WikiPageTreeNode>().FirstOrDefault(x => x.Page.PagePath == pageName);
 }
コード例 #24
0
        public ActionResult Upload(string pagePath, string title, HttpPostedFileBase imageFile)
        {
            if (string.IsNullOrEmpty(pagePath))
                pagePath = "/";

            var path = new PagePath(pagePath);
            object result = null;
            if (imageFile == null || imageFile.ContentLength == 0)
            {
                result = new
                             {
                                 success = false,
                                 body = "No file was uploaded."
                             };
            }
            else if (imageFile.ContentLength > 5000000)
            {
                result = new
                             {
                                 succcess = false,
                                 body = "Too large image, 5Mb is the limit."
                             };
            }
            else
            {
                var image = _repository.Create(path, Path.GetFileName(imageFile.FileName), title, imageFile.ContentType, imageFile.InputStream);
                result = new
                             {
                                 success = true,
                                 body = CreateImageModel(image)
                             };
            }


            return new WrappedJsonResult(result);
        }
コード例 #25
0
        public ActionResult Edit(PagePath id)
        {
            var path = id ?? new WikiRoot();
            var page = _repository.Get(path);
            var revision = page.GetLatestRevision();

            var model = new EditViewModel {Path = path, Title = page.Title, Content = revision.RawBody};
            return View(model);
        }
コード例 #26
0
 public bool Exists(PagePath pagePath)
 {
     return _session.Query<WikiPageTreeNode>().Any(x => x.Page.PagePath == pagePath);
 }
コード例 #27
0
 public ActionResult Delete(DeleteViewModel model)
 {
     var path = new PagePath(model.PageName);
     _pageService.DeletePage(path);
     return this.RedirectToWikiPage(new PagePath("/"));
 }
コード例 #28
0
 public ActionResult Delete(PagePath id)
 {
     var page = _repository.Get(id);
     return View(new DeleteViewModel
                     {
                         PageName = page.PagePath.ToString(),
                         Title = page.Title,
                         Children = page.Children.Select(x => x.PagePath.ToString()).ToList()
                     });
 }
コード例 #29
0
 public WikiPageTreeNode GetByPath(string wikiPath)
 {
     var path = new PagePath(wikiPath);
     return _session.Query<WikiPageTreeNode>().FirstOrDefault(x => x.Path == path);
 }
コード例 #30
0
        /// <summary>
        /// LUA结构支持
        /// </summary>
        /// <returns></returns>
        public override void GetLuaStruct(StringBuilder code)
        {
            base.GetLuaStruct(code);
            int idx;

            idx = 0;
            code.AppendLine("['ApiItems'] ={");
            foreach (var val in ApiItems)
            {
                if (idx++ > 0)
                {
                    code.Append(',');
                }
                code.AppendLine($@"{val.GetLuaStruct()}");
            }
            code.AppendLine("},");

            idx = 0;
            code.AppendLine("['Entities'] ={");
            foreach (var val in Entities)
            {
                if (idx++ > 0)
                {
                    code.Append(',');
                }
                code.AppendLine($@"{val.GetLuaStruct()}");
            }
            code.AppendLine("},");

            code.AppendLine($@"['ReadOnly'] ={(ReadOnly.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(DataBaseObjectName))
            {
                code.AppendLine($@"['DataBaseObjectName'] = '{DataBaseObjectName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DataBaseObjectName'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(NameSpace))
            {
                code.AppendLine($@"['NameSpace'] = '{NameSpace.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['NameSpace'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(PagePath))
            {
                code.AppendLine($@"['PagePath'] = '{PagePath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['PagePath'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(BusinessPath))
            {
                code.AppendLine($@"['BusinessPath'] = '{BusinessPath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['BusinessPath'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ClientCsPath))
            {
                code.AppendLine($@"['ClientCsPath'] = '{ClientCsPath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ClientCsPath'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ModelPath))
            {
                code.AppendLine($@"['ModelPath'] = '{ModelPath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ModelPath'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(CodePath))
            {
                code.AppendLine($@"['CodePath'] = '{CodePath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CodePath'] = nil,");
            }

            code.AppendLine($@"['DbType'] ='{DbType}',");

            if (!string.IsNullOrWhiteSpace(DbHost))
            {
                code.AppendLine($@"['DbHost'] = '{DbHost.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DbHost'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(DbSoruce))
            {
                code.AppendLine($@"['DbSoruce'] = '{DbSoruce.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DbSoruce'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(DbPassWord))
            {
                code.AppendLine($@"['DbPassWord'] = '******',");
            }
            else
            {
                code.AppendLine($@"['DbPassWord'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(DbUser))
            {
                code.AppendLine($@"['DbUser'] = '******',");
            }
            else
            {
                code.AppendLine($@"['DbUser'] = nil,");
            }
        }
コード例 #31
0
        public ActionResult Create(PagePath id, string title = null)
        {
            if (!User.IsInRole(WikiRole.Contributor))
                return View("MayNotCreate");

            var model = new CreateViewModel
                            {
                                PagePath = id,
                                Title = title ?? id.Name,
                                Content = "",
                                Templates = new List<SelectListItem>(),
                            };

            var parent = _repository.Get(id.ParentPath);
            if (parent != null)
            {
                model.ParentId = parent.Id;
                model.ParentPath = parent.PagePath.ToString();
                if (parent.ChildTemplate != null)
                {
                    model.TemplateId = parent.ChildTemplate.Id;
                    model.Content = parent.ChildTemplate.Content;
                }
            }

            model.Templates = _templateRepository.Find().Select(x => new SelectListItem
                                                                         {
                                                                             Selected = x.Id == model.TemplateId,
                                                                             Text = x.Title,
                                                                             Value =
                                                                                 x.Id.ToString(
                                                                                     CultureInfo.InvariantCulture)
                                                                         });

            return View(model);
        }
コード例 #32
0
        public ConsoleResultModel Run()
        {
            TabController        tc     = new TabController();
            List <PageModelBase> lst    = new List <PageModelBase>();
            List <PageModelBase> lstOut = new List <PageModelBase>();

            if (ParentId.HasValue)
            {
                lst = GetPagesByParentId((int)ParentId);
            }
            else
            {
                TabCollection tabs = tc.GetTabsByPortal(PortalId);
                foreach (KeyValuePair <int, TabInfo> kvp in tabs)
                {
                    lst.Add(new PageModelBase(kvp.Value));
                }
            }

            // filter results if needed
            if (Deleted.HasValue)
            {
                var query = from page in lst
                            where page.IsDeleted == Deleted
                            select page;
                List <PageModelBase> filteredList = query.ToList();
                lst = filteredList;
            }


            bool   bSearchTitle     = false;
            string searchTitle      = null;
            bool   bSearchName      = false;
            string searchName       = null;
            bool   bSearchPath      = false;
            string searchPath       = null;
            bool   bSearchSkin      = false;
            string searchSkin       = null;
            bool   bMatchVisibility = PageVisible.HasValue;

            if (!string.IsNullOrEmpty(PageName))
            {
                searchName  = PageName.Replace("*", ".*");
                bSearchName = true;
            }
            if (!string.IsNullOrEmpty(PageTitle))
            {
                searchTitle  = PageTitle.Replace("*", ".*");
                bSearchTitle = true;
            }
            if (!string.IsNullOrEmpty(PagePath))
            {
                searchPath  = PagePath.Replace("*", ".*");
                bSearchPath = true;
            }
            if (!string.IsNullOrEmpty(PageSkin))
            {
                searchSkin  = PageSkin.Replace("*", ".*");
                bSearchSkin = true;
            }

            if (bSearchTitle || bSearchName || bSearchPath || bSearchSkin || bMatchVisibility)
            {
                bool bIsMatch = false;
                foreach (PageModelBase pim in lst)
                {
                    bIsMatch = true;
                    if (bSearchTitle)
                    {
                        bIsMatch = bIsMatch & Regex.IsMatch(pim.Title, searchTitle, RegexOptions.IgnoreCase);
                    }
                    if (bSearchName)
                    {
                        bIsMatch = bIsMatch & Regex.IsMatch(pim.Name, searchName, RegexOptions.IgnoreCase);
                    }
                    if (bSearchPath)
                    {
                        bIsMatch = bIsMatch & Regex.IsMatch(pim.Path, searchPath, RegexOptions.IgnoreCase);
                    }
                    if (bSearchSkin)
                    {
                        bIsMatch = bIsMatch & Regex.IsMatch(pim.Skin, searchSkin, RegexOptions.IgnoreCase);
                    }
                    if (bMatchVisibility)
                    {
                        bIsMatch = bIsMatch & (pim.IncludeInMenu == PageVisible);
                    }
                    if (bIsMatch)
                    {
                        lstOut.Add(pim);
                    }
                }
            }
            else
            {
                lstOut = lst;
            }

            var msg = string.Format("{0} page{1} found", lstOut.Count, (lstOut.Count != 1 ? "s" : ""));

            return(new ConsoleResultModel(msg)
            {
                data = lstOut,
                fieldOrder = new string[] {
                    "TabId", "ParentId", "Name", "Title", "Skin", "Path", "IncludeInMenu", "IsDeleted"
                }
            });
        }
コード例 #33
0
        public ActionResult Revisions(string id)
        {
            if (string.IsNullOrEmpty(id))
                id = "/";
            else if (!id.StartsWith("/"))
                id = "/" + id;
            var path = new PagePath(id);
            var page = _repository.Get(path);

            var userIds = page.Revisions.Select(k => k.CreatedBy).ToList();
            if (!userIds.Contains(page.UpdatedBy))
                userIds.Add(page.UpdatedBy);

            var items = page.Revisions.Select(history =>
                                              new DiffViewModelItem
                                                  {
                                                      RevisionId = history.Id,
                                                      CreatedAt = history.CreatedAt,
                                                      UserDisplayName = page.UpdatedBy.DisplayName,
                                                      Comment = history.ChangeDescription
                                                  }).OrderByDescending(x => x.CreatedAt).ToList();


            return View(new DiffViewModel
                            {
                                Path = path,
                                Revisions = items
                            });
        }