Esempio n. 1
0
        private void RegisterTocMap(TocItemViewModel item, string key, IDocumentBuildContext context)
        {
            var href = item.Href; // Should be original href from working folder starting with ~

            if (!PathUtility.IsRelativePath(href))
            {
                return;
            }

            context.RegisterToc(key, href);
        }
Esempio n. 2
0
        private void RegisterTocMap(TocItemViewModel item, string key, IDocumentBuildContext context)
        {
            // If tocHref is set, href is originally RelativeFolder type, and href is set to the homepage of TocHref,
            // So in this case, TocHref should be used to in TocMap
            // TODO: what if user wants to set TocHref?
            var tocHref     = item.TocHref;
            var tocHrefType = Utility.GetHrefType(tocHref);

            if (tocHrefType == HrefType.MarkdownTocFile || tocHrefType == HrefType.YamlTocFile)
            {
                context.RegisterToc(key, tocHref);
            }
            else
            {
                var href = item.Href; // Should be original href from working folder starting with ~
                if (Utility.IsSupportedRelativeHref(href))
                {
                    context.RegisterToc(key, href);
                }
            }
        }
Esempio n. 3
0
        protected override void RegisterTocMapToContext(TocItemViewModel item, FileModel model, IDocumentBuildContext context)
        {
            var key = model.Key;
            // If tocHref is set, href is originally RelativeFolder type, and href is set to the homepage of TocHref,
            // So in this case, TocHref should be used to in TocMap
            // TODO: what if user wants to set TocHref?
            var tocHref     = item.TocHref;
            var tocHrefType = Utility.GetHrefType(tocHref);

            if (tocHrefType == HrefType.MarkdownTocFile || tocHrefType == HrefType.YamlTocFile)
            {
                context.RegisterToc(key, HttpUtility.UrlDecode(UriUtility.GetPath(tocHref)));
            }
            else
            {
                var href = item.Href; // Should be original href from working folder starting with ~
                if (Utility.IsSupportedRelativeHref(href))
                {
                    context.RegisterToc(key, HttpUtility.UrlDecode(UriUtility.GetPath(href)));
                }
            }
        }
Esempio n. 4
0
        public override void UpdateHref(FileModel model, IDocumentBuildContext context)
        {
            var toc = (TocViewModel)model.Content;
            var key = model.Key;

            // Add current folder to the toc mapping, e.g. `a/` maps to `a/toc`
            var directory = ((RelativePath)key).GetPathFromWorkingFolder().GetDirectoryPath();
            context.RegisterToc(key, directory);

            if (toc.Count > 0)
            {
                foreach (var item in toc)
                {
                    UpdateTocItemHref(item, model, context);
                }
            }
        }
Esempio n. 5
0
        public override void UpdateHref(FileModel model, IDocumentBuildContext context)
        {
            var toc = (TocViewModel)model.Content;
            var key = model.Key;

            // Add current folder to the toc mapping, e.g. `a/` maps to `a/toc`
            var directory = ((RelativePath)key).GetPathFromWorkingFolder().GetDirectoryPath();

            context.RegisterToc(key, directory);

            if (toc.Count > 0)
            {
                foreach (var item in toc)
                {
                    UpdateTocItemHref(item, model, context);
                }
            }
        }
Esempio n. 6
0
        public override void UpdateHref(FileModel model, IDocumentBuildContext context)
        {
            var toc = (TocItemViewModel)model.Content;
            var key = model.Key;

            // Add current folder to the toc mapping, e.g. `a/` maps to `a/toc`
            var directory = ((TypeForwardedToRelativePath)key).GetPathFromWorkingFolder().GetDirectoryPath();
            context.RegisterToc(key, directory);
            UpdateTocItemHref(toc, model, context);
            var tocInfo = new TocInfo(key);
            if (toc.Homepage != null)
            {
                if (TypeForwardedToPathUtility.IsRelativePath(toc.Homepage))
                {
                    var pathToRoot = ((TypeForwardedToRelativePath)model.File + (TypeForwardedToRelativePath)toc.Homepage).GetPathFromWorkingFolder();
                    tocInfo.Homepage = pathToRoot;
                }
            }

            context.RegisterTocInfo(tocInfo);
        }
Esempio n. 7
0
        protected override void RegisterTocToContext(TocItemViewModel toc, FileModel model, IDocumentBuildContext context)
        {
            var key = model.Key;

            // Add current folder to the toc mapping, e.g. `a/` maps to `a/toc`
            var directory = ((RelativePath)key).GetPathFromWorkingFolder().GetDirectoryPath();

            context.RegisterToc(key, directory);

            var tocInfo = new TocInfo(key);

            if (toc.Homepage != null)
            {
                if (PathUtility.IsRelativePath(toc.Homepage))
                {
                    var pathToRoot = ((RelativePath)model.File + (RelativePath)toc.Homepage).GetPathFromWorkingFolder();
                    tocInfo.Homepage = pathToRoot;
                }
            }

            context.RegisterTocInfo(tocInfo);
        }
Esempio n. 8
0
        public override void UpdateHref(FileModel model, IDocumentBuildContext context)
        {
            var toc = (TocItemViewModel)model.Content;
            var key = model.Key;

            // Add current folder to the toc mapping, e.g. `a/` maps to `a/toc`
            var directory = ((TypeForwardedToRelativePath)key).GetPathFromWorkingFolder().GetDirectoryPath();

            context.RegisterToc(key, directory);
            UpdateTocItemHref(toc, model, context);
            var tocInfo = new TocInfo(key);

            if (toc.Homepage != null)
            {
                if (TypeForwardedToPathUtility.IsRelativePath(toc.Homepage))
                {
                    var pathToRoot = ((TypeForwardedToRelativePath)model.File + (TypeForwardedToRelativePath)toc.Homepage).GetPathFromWorkingFolder();
                    tocInfo.Homepage = pathToRoot;
                }
            }

            context.RegisterTocInfo(tocInfo);
        }
Esempio n. 9
0
        private void RegisterTocMap(TocItemViewModel item, string key, IDocumentBuildContext context)
        {
            var href = item.Href; // Should be original href from working folder starting with ~
            if (!PathUtility.IsRelativePath(href)) return;

            context.RegisterToc(key, href);
        }
Esempio n. 10
0
 private void RegisterTocMap(TocItemViewModel item, string key, IDocumentBuildContext context)
 {
     // If tocHref is set, href is originally RelativeFolder type, and href is set to the homepage of TocHref,
     // So in this case, TocHref should be used to in TocMap
     // TODO: what if user wants to set TocHref?
     var tocHref = item.TocHref;
     var tocHrefType = Utility.GetHrefType(tocHref);
     if (tocHrefType == HrefType.MarkdownTocFile || tocHrefType == HrefType.YamlTocFile)
     {
         context.RegisterToc(key, tocHref);
     }
     else
     {
         var href = item.Href; // Should be original href from working folder starting with ~
         if (Utility.IsSupportedRelativeHref(href))
         {
             context.RegisterToc(key, href);
         }
     }
 }