Beispiel #1
0
        private Task OnPreCompile(ISite site)
        {
            m_Site = site;

            AssetsHelper.AddTextAsset(Resources.code_snippet_css, site.MainPage, CSS_FILE_PATH);
            AssetsHelper.AddTextAsset(Resources.code_snippet_js, site.MainPage, JS_FILE_PATH);

            m_SnippetFileIds = new List <string>();
            m_UsedTabIds     = new Dictionary <IPage, List <string> >();
            m_UsedSnippetIds = new Dictionary <IPage, List <string> >();

            if (!string.IsNullOrEmpty(m_Settings.SnippetsFolder))
            {
                try
                {
                    m_SnippetsFolder = site.MainPage.FindFolder(PluginLocation.FromPath(m_Settings.SnippetsFolder));
                }
                catch (AssetNotFoundException)
                {
                    throw new PluginUserMessageException($"Failed to find the folder for snippets: '{m_Settings.SnippetsFolder}'");
                }

                foreach (var snipAsset in m_SnippetsFolder.GetAllAssets())
                {
                    m_SnippetFileIds.Add(snipAsset.Id);
                }
            }

            return(Task.CompletedTask);
        }
Beispiel #2
0
        public static IAsset FindAsset(ISite site, IAssetsFolder page, string path)
        {
            var loc    = PluginLocation.FromPath(path);
            var folder = GetBaseFolder(site, page, loc);

            return(folder.FindAsset(loc));
        }
Beispiel #3
0
        public void Init(IDocifyApplication app, FilesPromoterPluginSettings setts)
        {
            m_App   = app;
            m_Setts = setts;

            m_App.Loader.PreLoadFile += OnPreLoadFile;

            m_PromoteLocations = setts.Folders?.Select(f => PluginLocation.FromPath(f)).ToArray();
        }
Beispiel #4
0
        private IAssetsFolder FindSnippetFolder(ISite site, IPage page, ref string snipLoc)
        {
            IAssetsFolder snippetsBaseFolder = null;

            if (snipLoc.StartsWith(SNIPPETS_FOLDER_PATH))
            {
                if (m_SnippetsFolder == null)
                {
                    throw new PluginUserMessageException("Snippets folder is not set");
                }

                snipLoc            = snipLoc.TrimStart(SNIPPETS_FOLDER_PATH);
                snippetsBaseFolder = m_SnippetsFolder;
            }
            else
            {
                snippetsBaseFolder = AssetsHelper.GetBaseFolder(site, page, PluginLocation.FromPath(snipLoc));
            }

            return(snippetsBaseFolder.FindFolder(PluginLocation.FromPath(snipLoc)));
        }