Exemplo n.º 1
0
        static List <Package> GetWidgets()
        {
            var installedWidgets = new List <Package>();
            var path             = HttpContext.Current.Server.MapPath($"{Utils.ApplicationRelativeWebRoot}Custom/Widgets/");

            foreach (var p in from d in Directory.GetDirectories(path)
                     let index = d.LastIndexOf(Path.DirectorySeparatorChar) + 1
                                 select d.Substring(index)
                                 into widgetId
                                 select GetPackageManifest(widgetId, Constants.Widget) ??
                                 new Package {
                Id = widgetId, PackageType = Constants.Widget
            })
            {
                if (string.IsNullOrEmpty(p.IconUrl))
                {
                    p.IconUrl = DefaultIconUrl(p);
                }

                if (string.IsNullOrEmpty(p.Title))
                {
                    p.Title = p.Id;
                }

                p.OnlineVersion = GetInstalledVersion(p.Id);

                if (!string.IsNullOrEmpty(p.OnlineVersion))
                {
                    var extra = Gallery.GetPackageExtra(p.Id + "." + p.OnlineVersion);
                    if (extra != null)
                    {
                        p.DownloadCount = extra.DownloadCount;
                        p.Rating        = extra.Rating;
                    }
                }

                installedWidgets.Add(p);
            }
            return(installedWidgets);
        }
Exemplo n.º 2
0
        static List <Package> GetThemes()
        {
            var installedThemes = new List <Package>();
            var path            = HttpContext.Current.Server.MapPath(string.Format("{0}Custom/Themes/", Utils.ApplicationRelativeWebRoot));

            foreach (var p in from d in Directory.GetDirectories(path)
                     let index = d.LastIndexOf(Path.DirectorySeparatorChar) + 1
                                 select d.Substring(index)
                                 into themeId select GetPackageManifest(themeId, Constants.Theme) ??
                                 new Package {
                Id = themeId, PackageType = Constants.Theme
            }
                     into p where p.Id != "RazorHost" select p)
            {
                if (string.IsNullOrEmpty(p.IconUrl))
                {
                    p.IconUrl = DefaultIconUrl(p);
                }

                if (string.IsNullOrEmpty(p.Title))
                {
                    p.Title = p.Id;
                }

                p.OnlineVersion = GetInstalledVersion(p.Id);

                if (!string.IsNullOrEmpty(p.OnlineVersion))
                {
                    var extra = Gallery.GetPackageExtra(p.Id + "." + p.OnlineVersion);
                    if (extra != null)
                    {
                        p.DownloadCount = extra.DownloadCount;
                        p.Rating        = extra.Rating;
                    }
                }

                installedThemes.Add(p);
            }
            return(installedThemes);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Load extensions from extensions manager
        /// </summary>
        /// <returns>List of installed extensions</returns>
        public static List <Package> LoadExtensions()
        {
            var extensions = ExtensionManager.Extensions.Where(x => x.Key != "MetaExtension").ToList();
            var packages   = new List <Package>();

            foreach (KeyValuePair <string, ManagedExtension> ext in extensions)
            {
                var x         = ExtensionManager.GetExtension(ext.Key);
                var adminPage = string.IsNullOrEmpty(x.AdminPage) ?
                                string.Format(Utils.RelativeWebRoot + "neet/Extensions/Settings.aspx?ext={0}&enb={1}", x.Name, x.Enabled) :
                                string.Format(x.AdminPage, x.Name, x.Enabled);

                var onlineVersion = GetInstalledVersion(x.Name);
                var p             = new Package
                {
                    Id            = x.Name,
                    PackageType   = "Extension",
                    Title         = x.Name,
                    Description   = x.Description,
                    LocalVersion  = x.Version,
                    OnlineVersion = onlineVersion,
                    Authors       = x.Author,
                    IconUrl       = $"{Utils.ApplicationRelativeWebRoot}Content/images/blog/ext.png",
                    Enabled       = x.Enabled,
                    Priority      = x.Priority,
                    SettingsUrl   = x.Settings.Count > 0 ? adminPage : ""
                };
                if (!string.IsNullOrEmpty(onlineVersion))
                {
                    var extra = Gallery.GetPackageExtra(x.Name + "." + onlineVersion);
                    p.DownloadCount = extra.DownloadCount;
                    p.Rating        = extra.Rating;
                }
                packages.Add(p);
            }
            return(packages);
        }