Ejemplo n.º 1
0
        public virtual ActionResult GoogleGroupSitemap()
        {
            // Allowed Groups for a guest
            var guestRole     = RoleService.GetRole(Constants.GuestRoleName);
            var allowedGroups = _groupService.GetAllowedGroups(guestRole, LoggedOnReadOnlyUser?.Id);

            // Sitemap holder
            var sitemap = new List <SitemapEntry>();

            // #### Groups
            foreach (var Group in allowedGroups)
            {
                // Get last post
                var topic        = Group.Topics.OrderByDescending(x => x.LastPost.DateEdited).FirstOrDefault();
                var sitemapEntry = new SitemapEntry
                {
                    Name            = Group.Name,
                    Url             = Group.NiceUrl,
                    LastUpdated     = topic?.LastPost.DateEdited ?? Group.CreatedAtUtc,
                    ChangeFrequency = SiteMapChangeFreqency.Monthly
                };
                sitemap.Add(sitemapEntry);
            }

            //HttpResponse.RemoveOutputCacheItem(Url.Action("details", "product", new { id = 1234 }));

            return(new GoogleSitemapResult(sitemap));
        }
Ejemplo n.º 2
0
        public ActionResult GoogleCategorySitemap()
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                // Allowed Categories for a guest
                var guestRole         = RoleService.GetRole(AppConstants.GuestRoleName);
                var allowedCategories = _categoryService.GetAllowedCategories(guestRole);

                // Sitemap holder
                var sitemap = new List <SitemapEntry>();

                // #### CATEGORIES
                foreach (var category in allowedCategories)
                {
                    // Get last post
                    var topic        = category.Topics.OrderByDescending(x => x.LastPost.DateEdited).FirstOrDefault();
                    var sitemapEntry = new SitemapEntry
                    {
                        Name            = category.Name,
                        Url             = category.NiceUrl,
                        LastUpdated     = topic != null ? topic.LastPost.DateEdited : category.DateCreated,
                        ChangeFrequency = SiteMapChangeFreqency.monthly
                    };
                    sitemap.Add(sitemapEntry);
                }

                return(new GoogleSitemapResult(sitemap));
            }
        }
        public SitemapEntryMetadata GetEntryMetadata(SitemapEntry entry)
        {
            var context = new SitemapEntryMetadataContext(entry);

            Invoke(handler => handler.GetSitemapEntryMetadata(context));
            return(context.Metadata);
        }
Ejemplo n.º 4
0
        public void ProcessSection(SitemapEntry entry)
        {
            var lines = new List <string>();

            lines.Add("---");
            //lines.Add("layout: default");
            lines.Add($"title: {entry.Context[EntryContextType.sectionName]}");

            List <SitemapEntry> childSections = entry.Childs.Where(x => x.IsSection).ToList();
            List <SitemapEntry> childPages    = entry.Childs.Where(x => x.IsTopic).ToList();

            if (childSections.Count > 0)
            {
                lines.Add("sections:");
                foreach (SitemapEntry sec in childSections)
                {
                    lines.Add($"  - \"{sec.Context[EntryContextType.folderName]}\"");
                }
            }

            if (childPages.Count > 0)
            {
                lines.Add("sorted_pages:");
                foreach (SitemapEntry page in childPages)
                {
                    lines.Add($"  - \"{Path.GetFileNameWithoutExtension(page.Context[EntryContextType.topicFileName])}\"");
                }
            }

            lines.Add("---");
            lines.Add("# {{page.title}}");

            File.AppendAllLines(entry.Context[EntryContextType.folderFullPath] + "index.md", lines);
        }
Ejemplo n.º 5
0
        public virtual ActionResult GoogleCategorySitemap()
        {
            // Allowed Categories for a guest
            var guestRole         = RoleService.GetRole(Constants.GuestRoleName);
            var allowedCategories = _categoryService.GetAllowedCategories(guestRole);

            // Sitemap holder
            var sitemap = new List <SitemapEntry>();

            // #### CATEGORIES
            foreach (var category in allowedCategories)
            {
                // Get last post
                var topic        = category.Topics.OrderByDescending(x => x.LastPost.DateEdited).FirstOrDefault();
                var sitemapEntry = new SitemapEntry
                {
                    Name            = category.Name,
                    Url             = category.NiceUrl,
                    LastUpdated     = topic?.LastPost.DateEdited ?? category.DateCreated,
                    ChangeFrequency = SiteMapChangeFreqency.Monthly
                };
                sitemap.Add(sitemapEntry);
            }

            //HttpResponse.RemoveOutputCacheItem(Url.Action("details", "product", new { id = 1234 }));

            return(new GoogleSitemapResult(sitemap));
        }
Ejemplo n.º 6
0
        public ActionResult GoogleMemberSitemap()
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                // get all members profiles
                var members = MembershipService.GetAll();

                // Sitemap holder
                var sitemap = new List <SitemapEntry>();

                // #### MEMBERS
                foreach (var member in members)
                {
                    var sitemapEntry = new SitemapEntry
                    {
                        Name            = member.UserName,
                        Url             = member.NiceUrl,
                        LastUpdated     = member.CreateDate,
                        ChangeFrequency = SiteMapChangeFreqency.weekly,
                        Priority        = "0.4"
                    };
                    sitemap.Add(sitemapEntry);
                }

                return(new GoogleSitemapResult(sitemap));
            }
        }
Ejemplo n.º 7
0
        public ActionResult GoogleSitemap()
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                // Allowed Categories for a guest
                var guestRole         = RoleService.GetRole(AppConstants.GuestRoleName);
                var allowedCategories = _categoryService.GetAllowedCategories(guestRole);

                // Get all topics that a guest has access to
                var allTopics = _topicService.GetAll(allowedCategories);

                // Sitemap holder
                var sitemap = new List <SitemapEntry>();

                // ##### TOPICS
                foreach (var topic in allTopics.Where(x => x.LastPost != null))
                {
                    var sitemapEntry = new SitemapEntry
                    {
                        Name            = topic.Name,
                        Url             = topic.NiceUrl,
                        LastUpdated     = topic.LastPost.DateEdited,
                        ChangeFrequency = SiteMapChangeFreqency.daily,
                        Priority        = "0.6"
                    };
                    sitemap.Add(sitemapEntry);
                }

                return(new GoogleSitemapResult(sitemap));
            }
        }
Ejemplo n.º 8
0
        private XElement ToUrlElement(SitemapEntry entry)
        {
            var urlElement = new XElement(Namespace + "url",
                                          new XElement(Namespace + "loc", mUrlHelper.MakeAbsolute(entry.Url)));

            if (entry.LastModifiedUtc != null)
            {
                urlElement.Add(new XElement(Namespace + "lastmod", entry.LastModifiedUtc.Value.ToString("o", CultureInfo.InvariantCulture)));
            }

            if (entry.ChangeFrequency != null)
            {
                urlElement.Add(new XElement(Namespace + "changefreq", entry.ChangeFrequency.ToString().ToLowerInvariant()));
            }

            if (entry.Priority != null)
            {
                urlElement.Add(new XElement(Namespace + "priority", entry.Priority.Value.ToString(CultureInfo.InvariantCulture)));
            }

            foreach (var imageEntry in entry.Images)
            {
                urlElement.Add(ToImageElement(imageEntry));
            }

            return(urlElement);
        }
Ejemplo n.º 9
0
        public ActionResult GoogleCategorySitemap()
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                // Allowed Categories for a guest
                var guestRole         = RoleService.GetRole(AppConstants.GuestRoleName);
                var allowedCategories = _categoryService.GetAllowedCategories(guestRole);

                // Sitemap holder
                var sitemap = new List <SitemapEntry>();

                // #### CATEGORIES
                foreach (var category in allowedCategories)
                {
                    var sitemapEntry = new SitemapEntry
                    {
                        Name            = category.Name,
                        Url             = category.NiceUrl,
                        LastUpdated     = category.DateCreated,
                        ChangeFrequency = SiteMapChangeFreqency.monthly
                    };
                    sitemap.Add(sitemapEntry);
                }

                return(new GoogleSitemapResult(sitemap));
            }
        }
Ejemplo n.º 10
0
        public virtual ActionResult GoogleSitemap()
        {
            // Allowed Groups for a guest
            var guestRole     = RoleService.GetRole(Constants.GuestRoleName);
            var allowedGroups = _groupService.GetAllowedGroups(guestRole, LoggedOnReadOnlyUser?.Id);

            // Get all topics that a guest has access to
            var allTopics = _topicService.GetAll(allowedGroups);

            // Sitemap holder
            var sitemap = new List <SitemapEntry>();

            // ##### TOPICS
            foreach (var topic in allTopics.Where(x => x.LastPost != null))
            {
                var sitemapEntry = new SitemapEntry
                {
                    Name            = topic.Name,
                    Url             = topic.NiceUrl,
                    LastUpdated     = topic.LastPost.DateEdited,
                    ChangeFrequency = SiteMapChangeFreqency.Daily,
                    Priority        = "0.6"
                };
                sitemap.Add(sitemapEntry);
            }

            return(new GoogleSitemapResult(sitemap));
        }
Ejemplo n.º 11
0
        public void Equals_NotEqualSitemapAndUri()
        {
            var x = new SitemapEntry
            {
                Location = new Uri("https://localhost/abc")
            };
            var y = new Uri("https://localhost/def");

            Assert.IsFalse(x.Equals(y));
            Assert.IsFalse(x.Equals((Uri)null));
        }
Ejemplo n.º 12
0
        public void Equals_EqualSitemapAndUri()
        {
            var x = new SitemapEntry
            {
                Location     = new Uri("https://localhost/"),
                LastModified = new DateTime(2000, 1, 1),
                Priority     = 0.7
            };
            var y = new Uri("https://localhost/");

            Assert.IsTrue(x.Equals(y));
        }
Ejemplo n.º 13
0
        protected virtual SitemapEntry CreateEntry(object source, string url, DateTime?lastModifiedUtc = null, ChangeFrequency?changeFrequency = null, float?priority = null)
        {
            var entry = new SitemapEntry(Name, DisplayName.ToString(), url, lastModifiedUtc, changeFrequency, priority);

            _sitemapEntryHandlers.EntryCreated(new SitemapEntryCreatedContext
            {
                Source = source,
                Entry  = entry
            });

            return(entry);
        }
Ejemplo n.º 14
0
        public void NotEqualsOperator_EqualSitemapAndUri()
        {
            var x = new SitemapEntry
            {
                Location     = new Uri("https://localhost/"),
                LastModified = new DateTime(2000, 1, 1),
                Priority     = 0.7
            };
            var y = new Uri("https://localhost/");

            Assert.IsFalse(x != y);
            Assert.IsFalse(y != x);
        }
Ejemplo n.º 15
0
        public List <string> GrabSitemap(SitemapEntry sitemap)
        {
            if (null == sitemap)
            {
                throw new Exception("no next sitemap");
            }
            var sitemapResponse = _client.GetAsync(sitemap.Loc).Result;

            if (!sitemapResponse.IsSuccessStatusCode)
            {
                throw new Exception("http sitemap request failed");
            }
            return(GetIdsFromSitemap(XDocument.Parse(sitemapResponse.Content.ReadAsStringAsync().Result)));
        }
Ejemplo n.º 16
0
 public void MarkSitemapAsDownloaded(SitemapEntry sitemapEntry)
 {
     lock (_sitemaps)
     {
         _sitemaps[sitemapEntry.SourceType] = _sitemaps[sitemapEntry.SourceType].Select(s =>
         {
             if (s.Loc == sitemapEntry.Loc)
             {
                 s.DownloadedLastmod = s.Lastmod;
             }
             return(s);
         }).ToList();
     }
 }
Ejemplo n.º 17
0
        public void EqualsOperator_NotEqualSitemapAndUri()
        {
            var x = new SitemapEntry
            {
                Location = new Uri("https://localhost/abc")
            };
            var y = new Uri("https://localhost/def");

            Assert.IsFalse((Uri)null == x);
            Assert.IsFalse(x == (Uri)null);
            Assert.IsFalse((SitemapEntry)null == new Uri("https://localhost/"));
            Assert.IsFalse(new Uri("https://localhost/") == (SitemapEntry)null);
            Assert.IsFalse(x == y);
            Assert.IsFalse(y == x);
        }
Ejemplo n.º 18
0
        public void Equals_NotEqualSitemaps()
        {
            var x = new SitemapEntry
            {
                Location = new Uri("https://localhost/abc")
            };
            var y = new SitemapEntry
            {
                Location = new Uri("https://localhost/def")
            };

            Assert.IsFalse(new SitemapEntry().Equals((SitemapEntry)null));
            Assert.IsFalse(x.Equals(y));
            Assert.IsFalse(y.Equals(x));
        }
Ejemplo n.º 19
0
        public void NotEqualsOperator_NotEqualSitemapAndUri()
        {
            var x = new SitemapEntry
            {
                Location = new Uri("https://localhost/abc")
            };
            var y = new Uri("https://localhost/def");

            Assert.IsTrue((Uri)null != x);
            Assert.IsTrue(x != (Uri)null);
            Assert.IsTrue((SitemapEntry)null != new Uri("https://localhost/"));
            Assert.IsTrue(new Uri("https://localhost/") != (SitemapEntry)null);
            Assert.IsTrue(x != y);
            Assert.IsTrue(y != x);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// TOC entries processing
        /// </summary>
        /// <param name="entry"></param>
        public void ProcessTopic(SitemapEntry entry)
        {
            string topicFileName = entry.Context[EntryContextType.topicFileName].ToLower();
            string topicPath     = entry.Context[EntryContextType.topicFullPath];
            string topicRelPath  = topicPath.Substring(_projectFolderLength);

            if (!_files.ContainsKey(topicFileName))
            {
                _files.Add(topicFileName, new List <string> {
                    topicRelPath
                });
            }
            else
            {
                _files[topicFileName].Add(topicRelPath);
            }

            FixTopicPath(entry.Node, topicRelPath);
        }
Ejemplo n.º 21
0
        private static SitemapEntry SitemapEntry(ContentPart part)
        {
            var result = new SitemapEntry();

            if (part.Is <IAliasAspect>())
            {
                result.Url = "/" + part.As <IAliasAspect>().Path;
            }
            if (part.Is <TitlePart>())
            {
                result.Name = part.As <TitlePart>().Title;
            }
            if (part.Is <CommonPart>())
            {
                var commonPart = part.As <CommonPart>();
                result.LastModified = commonPart.ModifiedUtc ?? commonPart.CreatedUtc;
            }
            return(result);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Index processing
        ///  - if file is not in the hash of known files then we should move it into misc and update hash
        /// </summary>
        /// <param name="entry"></param>
        public void OnEntry(SitemapEntry entry)
        {
            //process topics only
            if (!entry.IsTopic)
            {
                return;
            }

            //enumerate all referred topics
            string[] topics = entry.Params.Where(x => string.Compare(x.Key, "local", true) == 0).Select(y => y.Value.ToLower().Trim()).ToArray();
            foreach (string file in topics)
            {
                string topicNewRelPath = string.Empty;

                if (!_files.ContainsKey(file))
                {
                    //copy file into /misc/<file> folder
                    string destPath = _miscFolder + file;
                    _parser.CopyTopic(file, destPath);

                    //update hash
                    topicNewRelPath = destPath.Substring(_projectFolderLength);
                    _files.Add(file, new List <string> {
                        topicNewRelPath
                    });
                }
                else
                {
                    topicNewRelPath = _files[file].First();
                    if (_files[file].Count > 1)
                    {
                        Console.WriteLine($"WARN: many entries for {file}:");
                        foreach (string f in _files[file])
                        {
                            Console.WriteLine($"  {f}");
                        }
                    }
                }

                FixTopicPath(entry.Node, topicNewRelPath, file);
            }
        }
Ejemplo n.º 23
0
        private SitemapEntry ParseSitemapEntry(XmlNode urlNode)
        {
            var result = new SitemapEntry();

            foreach (XmlNode urlDetail in urlNode.ChildNodes)
            {
                var nodeName  = urlDetail.Name.ToLower();
                var nodeValue = urlDetail.InnerText;

                if (nodeName == "loc")
                {
                    Uri tmpUri;
                    if (Uri.TryCreate(nodeValue, UriKind.Absolute, out tmpUri))
                    {
                        result.Location = tmpUri;
                    }
                }
                else if (nodeName == "lastmod")
                {
                    DateTime tmpLastModified;
                    if (DateTime.TryParse(nodeValue, out tmpLastModified))
                    {
                        result.LastModified = tmpLastModified;
                    }
                }
                else if (nodeName == "changefreq")
                {
                    result.ChangeFrequency = ParseChangeFrequency(nodeValue);
                }
                else if (nodeName == "priority")
                {
                    decimal tmpPriority;
                    if (decimal.TryParse(nodeValue, out tmpPriority))
                    {
                        result.Priority = tmpPriority;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 24
0
        public void ProcessTopic(SitemapEntry entry)
        {
            string topicFilename = entry.GetLastParam("local").ToLower();

            entry.Context[EntryContextType.topicFileName] = topicFilename;


            //retrieve topic name (getting last name since it was seen sometimes there are more than one Name param)
            entry.Context[EntryContextType.topicName] = entry.GetLastParam("name");


            string topicFullPath;

            //sometime section has linked topic so copy the file into topic's folder (otherwise into parent folder)
            if (entry.IsSection && entry.IsTopic)
            {
                topicFullPath = entry.Context[EntryContextType.folderFullPath] + topicFilename;
                Console.WriteLine($"!!!!!!!!!! ATTENTION: Topic and Section in the same entry: {topicFullPath}");
            }
            else if (entry.IsTopic)
            {
                topicFullPath = entry.Parent.Context[EntryContextType.folderFullPath] + topicFilename;
            }
            else
            {
                throw new Exception("HtmlTopicsGenerator - cannot handle section only entry");
            }
            try
            {
                //topicFullPath = @"\\?\" + topicFullPath;
                _parser.CopyTopic(topicFilename, topicFullPath);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Failed to copy topic {topicFullPath} {e.Message}");
            }
            entry.Context[EntryContextType.topicFullPath] = topicFullPath;
        }
Ejemplo n.º 25
0
        public void ProcessSection(SitemapEntry entry)
        {
            string sectionName = string.Empty, name = string.Empty, folderFullPath = string.Empty;

            if (entry.Parent != null)
            {
                //retrieve section name (getting last name since it was seen sometimes there are more than one Name param)
                sectionName = entry.GetLastParam("name");
                name        = sectionName.SEO();

                string shortName;
                if (_shortNames != null && _shortNames.TryGetValue(name, out shortName))
                {
                    name = shortName;
                }

                //name = $"{idx++}";
                //File.AppendAllText(@"c:\temp\bp-shorts.txt", $"{sectionName.SEO()},{name}{Environment.NewLine}");

                folderFullPath = entry.Parent.Context[EntryContextType.folderFullPath] + name + Path.DirectorySeparatorChar;
            }
            else
            {
                //make sure base folder exists and empty
                if (Directory.Exists(_baseFolder))
                {
                    Directory.Delete(_baseFolder, true);
                }

                folderFullPath = _baseFolder;
            }

            Directory.CreateDirectory(folderFullPath);

            entry.Context[EntryContextType.folderFullPath] = folderFullPath;
            entry.Context[EntryContextType.folderName]     = name;
            entry.Context[EntryContextType.sectionName]    = sectionName;
        }
Ejemplo n.º 26
0
        private XElement Url(SitemapEntry sitemapResult)
        {
            var url = new XElement(_xmlNamespace + "url");

            if (!String.IsNullOrEmpty(sitemapResult.Url))
            {
                var fullPath = _baseUrl.Value + sitemapResult.Url;
                url.Add(new XElement(_xmlNamespace + "loc", fullPath));
            }
            if (sitemapResult.LastModified.HasValue)
            {
                url.Add(new XElement(_xmlNamespace + "lastmod", sitemapResult.LastModified.Value.ToString("yyyy-MM-ddTHH:mm:ss.fffffffzzz")));
            }
            if (sitemapResult.Priority.HasValue)
            {
                url.Add(new XElement(_xmlNamespace + "priority", sitemapResult.Priority.Value.ToString("#.#")));
            }
            if (sitemapResult.ChangeFrequency.HasValue)
            {
                url.Add(new XElement(_xmlNamespace + "changefreq", sitemapResult.ChangeFrequency.Value.ToString().ToLower()));
            }
            return(url);
        }
        private SitemapEntry CreateSitemapEntryFromCompositeC1SiteMapNode(string baseUrl, CmsPageSiteMapNode node)
        {
            var baseUrlWithoutEndSlash = baseUrl.TrimEnd('/');
            var nodeUrl = node.Url.TrimStart('/');

            var sitemapEntry = new SitemapEntry
            {
                Location         = $"{baseUrlWithoutEndSlash}/{nodeUrl}",
                LastModification = node.LastModified.ToUniversalTime().ToString("u").Replace(" ", "T"),
            };

            if (node.Priority.HasValue)
            {
                sitemapEntry.Priority = ((decimal)node.Priority.Value / 10).ToString("0.0", CultureInfo.InvariantCulture);
            }

            if (node.ChangeFrequency.HasValue)
            {
                sitemapEntry.ChangeFrequency = node.ChangeFrequency.Value.ToString().ToLowerInvariant();
            }

            return(sitemapEntry);
        }
Ejemplo n.º 28
0
        public void NotEqualsOperator_EqualSitemaps()
        {
            var sameReferenceSitemap = new SitemapEntry();
            var x = new SitemapEntry
            {
                Location     = new Uri("https://localhost/"),
                LastModified = new DateTime(2000, 1, 1),
                Priority     = 0.7
            };
            var y = new SitemapEntry
            {
                Location     = new Uri("https://localhost/"),
                LastModified = new DateTime(1970, 1, 1),
                Priority     = 0.3
            };

#pragma warning disable CS1718 // Comparison made to same variable
            Assert.IsFalse(sameReferenceSitemap != sameReferenceSitemap);
#pragma warning restore CS1718 // Comparison made to same variable
            Assert.IsFalse(new SitemapEntry() != new SitemapEntry());
            Assert.IsFalse(x != y);
            Assert.IsFalse(y != x);
        }
Ejemplo n.º 29
0
        public void Equals_EqualSitemaps()
        {
            var sameReferenceSitemap = new SitemapEntry();
            var x = new SitemapEntry
            {
                Location     = new Uri("https://localhost/"),
                LastModified = new DateTime(2000, 1, 1),
                Priority     = 0.7
            };
            var y = new SitemapEntry
            {
                Location     = new Uri("https://localhost/"),
                LastModified = new DateTime(1970, 1, 1),
                Priority     = 0.3
            };

#pragma warning disable CS1718 // Comparison made to same variable
            Assert.IsTrue(sameReferenceSitemap.Equals(sameReferenceSitemap));
#pragma warning restore CS1718 // Comparison made to same variable
            Assert.IsTrue(new SitemapEntry().Equals(new SitemapEntry()));
            Assert.IsTrue(x.Equals(y));
            Assert.IsTrue(y.Equals(x));
        }
Ejemplo n.º 30
0
        private SitemapEntry ParseSitemapEntry(XElement urlNode)
        {
            var result = new SitemapEntry();

            foreach (var urlDetail in urlNode.Elements())
            {
                var nodeName  = urlDetail.Name.LocalName;
                var nodeValue = urlDetail.Value;

                if (nodeName.Equals("loc", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (Uri.TryCreate(nodeValue, UriKind.Absolute, out var tmpUri))
                    {
                        result.Location = tmpUri;
                    }
                }
                else if (nodeName.Equals("lastmod", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (DateTime.TryParse(nodeValue, CultureInfo.InvariantCulture, DateTimeStyles.None, out var tmpLastModified))
                    {
                        result.LastModified = tmpLastModified;
                    }
                }
                else if (nodeName.Equals("changefreq", StringComparison.InvariantCultureIgnoreCase))
                {
                    result.ChangeFrequency = ParseChangeFrequency(nodeValue);
                }
                else if (nodeName.Equals("priority", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (double.TryParse(nodeValue, NumberStyles.Float, CultureInfo.InvariantCulture, out var tmpPriority))
                    {
                        result.Priority = tmpPriority;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 31
0
        public ActionResult GoogleCategorySitemap()
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                // Allowed Categories for a guest
                var guestRole = RoleService.GetRole(AppConstants.GuestRoleName);
                var allowedCategories = _categoryService.GetAllowedCategories(guestRole);

                // Sitemap holder
                var sitemap = new List<SitemapEntry>();

                // #### CATEGORIES
                foreach (var category in allowedCategories)
                {
                    // Get last post
                    var topic = category.Topics.OrderByDescending(x => x.LastPost.DateEdited).FirstOrDefault();
                    var sitemapEntry = new SitemapEntry
                    {
                        Name = category.Name,
                        Url = category.NiceUrl,
                        LastUpdated = topic?.LastPost.DateEdited ?? category.DateCreated,
                        ChangeFrequency = SiteMapChangeFreqency.monthly
                    };
                    sitemap.Add(sitemapEntry);
                }

                return new GoogleSitemapResult(sitemap);
            }
        }
Ejemplo n.º 32
0
        public ActionResult GoogleMemberSitemap()
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                // get all members profiles
                var members = MembershipService.GetAll();

                // Sitemap holder
                var sitemap = new List<SitemapEntry>();

                // #### MEMBERS
                foreach (var member in members)
                {
                    var sitemapEntry = new SitemapEntry
                    {
                        Name = member.UserName,
                        Url = member.NiceUrl,
                        LastUpdated = member.CreateDate,
                        ChangeFrequency = SiteMapChangeFreqency.weekly,
                        Priority = "0.4"
                    };
                    sitemap.Add(sitemapEntry);
                }

                return new GoogleSitemapResult(sitemap);
            }
        }
Ejemplo n.º 33
0
        public ActionResult GoogleSitemap()
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                // Allowed Categories for a guest
                var guestRole = RoleService.GetRole(AppConstants.GuestRoleName);
                var allowedCategories = _categoryService.GetAllowedCategories(guestRole);

                // Get all topics that a guest has access to
                var allTopics = _topicService.GetAll(allowedCategories);

                // Sitemap holder
                var sitemap = new List<SitemapEntry>();

                // ##### TOPICS
                foreach (var topic in allTopics.Where(x => x.LastPost != null))
                {
                    var sitemapEntry = new SitemapEntry
                    {
                        Name = topic.Name,
                        Url = topic.NiceUrl,
                        LastUpdated = topic.LastPost.DateEdited,
                        ChangeFrequency = SiteMapChangeFreqency.daily,
                        Priority = "0.6"
                    };
                    sitemap.Add(sitemapEntry);
                }

                return new GoogleSitemapResult(sitemap);
            }
        }