public IActionResult OnGet() { string baseUrl = "https://www.vault.themotte.org"; // get a list of published posts var posts = postLoader.VisiblePosts(); var siteMapBuilder = new SitemapBuilder(); // add the home page to the sitemap siteMapBuilder.AddUrl(baseUrl + "/"); // add the blog posts to the sitemap foreach (var post in posts) { siteMapBuilder.AddUrl(baseUrl + post.FullURL); } var pages = new List <string>() { "about" }; foreach (var staticPage in pages) { siteMapBuilder.AddUrl(baseUrl + "/" + staticPage); } // generate the sitemap xml string xml = siteMapBuilder.ToString(); return(Content(xml, "text/xml")); }
public async Task <String> GetSiteMapXmlAsync(String baseUrl, CancellationToken cancel = default) { var blogStories = await _blogStoryRepository.GetAsync(BlogStoryQuery.AllPublished, cancel); var siteMapBuilder = new SitemapBuilder(); var modifiedDate = blogStories.Any() ? (DateTime?)blogStories.First().ModifiedDate : null; siteMapBuilder.AddUrl(baseUrl, modifiedDate, ChangeFrequency.Daily); var tags = await _tagManager.GetAllPublishedAsync(cancel); foreach (var tag in tags) { siteMapBuilder.AddUrl(tag.ToSitemapItem(baseUrl)); } foreach (var blogStory in blogStories) { siteMapBuilder.AddUrl(blogStory.ToSitemapItem(baseUrl)); } return(siteMapBuilder.ToString()); }
public IActionResult Sitemap() { string host = Request.Scheme + "://" + Request.Host; var about = host + "/Home/About"; var contact = host + "/Home/Contact"; var gallery = host + "/Home/Gallery"; var services = host + "/Home/Services"; var blog = host + "/Blog/Index"; var siteMapBuilder = new SitemapBuilder(); siteMapBuilder.AddUrl(host, modified: DateTime.UtcNow, changeFrequency: ChangeFrequency.Never, priority: 1.0); siteMapBuilder.AddUrl(about, modified: DateTime.UtcNow, changeFrequency: ChangeFrequency.Never, priority: 1.0); siteMapBuilder.AddUrl(contact, modified: DateTime.UtcNow, changeFrequency: ChangeFrequency.Never, priority: 1.0); siteMapBuilder.AddUrl(services, modified: DateTime.UtcNow, changeFrequency: ChangeFrequency.Never, priority: 1.0); if (_repository.GetPosts().Any()) { foreach (var post in _repository.GetPosts()) { siteMapBuilder.AddUrl(host + _repository.GetLink(post.Slug), modified: post.DateCreated, changeFrequency: ChangeFrequency.Weekly, priority: 0.9); } } string xml = siteMapBuilder.ToString(); return(Content(xml, "text/xml")); }
public ActionResult Sitemap() { string baseUrl = "https://matteofabbri.org/"; // get a list of published articles var posts = BlogArticle.Queryable(); // get last modified date of the home page var siteMapBuilder = new SitemapBuilder(); // add the home page to the sitemap siteMapBuilder.AddUrl(baseUrl, modified: DateTime.UtcNow, changeFrequency: ChangeFrequency.Weekly, priority: 1.0); // add the blog posts to the sitemap foreach (var post in posts) { siteMapBuilder.AddUrl($"{baseUrl}read/{post.Link}", modified: post.DateTime, changeFrequency: null, priority: 0.9); } siteMapBuilder.AddUrl($"{baseUrl}/privacy", modified: DateTime.UtcNow, changeFrequency: ChangeFrequency.Weekly, priority: 1.0); siteMapBuilder.AddUrl($"{baseUrl}/stat", modified: DateTime.UtcNow, changeFrequency: ChangeFrequency.Weekly, priority: 1.0); // generate the sitemap xml string xml = siteMapBuilder.ToString(); return(Content(xml, "text/xml")); }
public ActionResult SitemapAsync() { string baseUrl = Request.Host.Value + "/"; // get a list of published articles var posts = _context.Posts.Include("Language").Where(x => x.IsPublished == true).ToList(); // get a list of published articles var page = _context.Pages.Include("Language").Where(x => x.IsPublished == true).ToList(); // get last modified date of the home page var siteMapBuilder = new SitemapBuilder(); // add the home page to the sitemap siteMapBuilder.AddUrl(baseUrl, modified: DateTime.UtcNow, changeFrequency: ChangeFrequency.Daily, priority: 1.0); // add the blog posts to the sitemap foreach (var post in posts) { siteMapBuilder.AddUrl(baseUrl + post.Language.Culture + "/" + post.Slug, modified: post.UpdateDate, changeFrequency: null, priority: 0.9); } foreach (var pages in page) { siteMapBuilder.AddUrl(baseUrl + pages.Language.Culture + "/" + pages.Slug, modified: pages.UpdateDate, changeFrequency: null, priority: 0.9); } // generate the sitemap xml string xml = siteMapBuilder.ToString(); return(Content(xml, "text/xml")); }
public async Task <IActionResult> SitemapAsync() { string baseUrl = "https://telemview.telem-hit.net/"; // get a list of published products var products = await _repo.GetAllProducts(); // get last modified date of the home page var siteMapBuilder = new SitemapBuilder(); // add the home page to the sitemap siteMapBuilder.AddUrl(baseUrl, modified: DateTime.UtcNow, changeFrequency: ChangeFrequency.Weekly, priority: 1.0); // add the blog posts to the sitemap foreach (var product in products) { siteMapBuilder.AddUrl(baseUrl + product.Id, modified: product.TimeStamp, changeFrequency: null, priority: 0.9); } // generate the sitemap xml string xml = siteMapBuilder.ToString(); XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(xml); xdoc.Save(@"wwwroot\sitemap.xml"); return(Ok()); }
public async Task <ActionResult> SitemapAsync() { var preferredhost = _config["PreferredHost"]; // CDN rewrites headers, so needed to make this less dynamic. string baseUrl = $"https://{preferredhost}"; // get a list of public clubs var clubs = await _clubservice.GetClubs(false); var siteMapBuilder = new SitemapBuilder(); siteMapBuilder.AddUrl(baseUrl + webPathDelimiter, changeFrequency: ChangeFrequency.Monthly, priority: 0.8); siteMapBuilder.AddUrl(baseUrl + Url.Action("News", "Home"), changeFrequency: ChangeFrequency.Monthly, priority: 0.5); siteMapBuilder.AddUrl(baseUrl + Url.Action("About", "Home"), changeFrequency: ChangeFrequency.Monthly, priority: 0.5); foreach (var club in clubs) { siteMapBuilder.AddUrl(baseUrl + webPathDelimiter + club.Initials, priority: 1.0); } // generate the sitemap xml string xml = siteMapBuilder.ToString(); return(Content(xml, "text/xml")); }
public void ProcessRequest(System.Web.HttpContext context) { try { HttpResponse Response = context.Response; PortalSettings ps = PortalController.GetCurrentPortalSettings(); Response.ContentType = "text/xml"; Response.ContentEncoding = Encoding.UTF8; SitemapBuilder builder = new SitemapBuilder(ps); if ((context.Request.QueryString["i"] != null)) { // This is a request for one of the files that build the sitemapindex builder.GetSitemapIndexFile(context.Request.QueryString["i"], Response.Output); } else { builder.BuildSiteMap(Response.Output); } } catch (Exception exc) { CommonLibrary.Services.Exceptions.Exceptions.LogException(exc); } }
public ActionResult Sitemap() { string baseUrl = "http://kuku.mba/"; // get a list of published articles var recipes = db.Recipes.ToList(); // get last modified date of the home page var siteMapBuilder = new SitemapBuilder(); // add the home page to the sitemap siteMapBuilder.AddUrl(baseUrl, modified: DateTime.UtcNow, changeFrequency: ChangeFrequency.Weekly, priority: 1.0); siteMapBuilder.AddUrl(baseUrl + "Home/Contact", modified: DateTime.UtcNow, changeFrequency: null, priority: 0.5); siteMapBuilder.AddUrl(baseUrl + "Home/About", modified: DateTime.UtcNow, changeFrequency: null, priority: 0.5); // add details recipe to the sitemap foreach (var recipe in recipes) { siteMapBuilder.AddUrl(baseUrl + "Home/DetailsRecipe/" + recipe.RecipeId, modified: recipe.CreatedDate, changeFrequency: null, priority: 0.5); } // generate the sitemap xml string xml = siteMapBuilder.ToString(); return(Content(xml, "text/xml")); }
public async Task <IActionResult> SitemapXml([FromServices] SitemapBuilder sitemapBuilder, [FromServices] GetPostsQuery getPostsQuery) { DateTime now = DateTime.Now; sitemapBuilder.AddUrl(new SitemapNode { Url = $"{this.Request.Scheme}://{this.Request.Host}", ChangeFrequency = ChangeFrequency.Always, Modified = now, Priority = 1 }); var posts = await getPostsQuery.Build().Select(p => new { PostUrl = p.Url, CategoryCode = p.Category.Code, p.PublicationDate }).ToListAsync(); foreach (var post in posts) { sitemapBuilder.AddUrl(new SitemapNode { Url = $"{this.Request.Scheme}://{this.Request.Host}/posts/{post.CategoryCode}/{post.PostUrl}", Priority = 0.5, Modified = post.PublicationDate, ChangeFrequency = ChangeFrequency.Always }); } return(Content(sitemapBuilder.ToString(), "application/xml", Encoding.UTF8)); }
private SitemapModel BuildPageTreeItem(Site site) { var model = new SitemapModel(); model.SiteId = site.ContentId; model.SiteName = site.Name; model.IsFrontendSite = site.IsFrontendSite; var draftSitemap = SitemapBuilder.BuildSitemap(site, ContentEnvironment.Draft, SitemapBuilderFilters.All); foreach (var childNode in draftSitemap.ChildNodes) { model.ChildNodes.Add(CreateSiteMapNode(childNode, 0)); } var liveSitemap = SitemapBuilder.BuildSitemap(site, ContentEnvironment.Live, SitemapBuilderFilters.All); var flatItems = model.GetAllDescendents <SitemapModelNode>(); foreach (var item in flatItems) { var liveNode = liveSitemap.GetSitemapNode(item.PageId); item.IsPublished = liveNode != null; item.IsHomePage = item.PageId == site.HomepageId; } return(model); }
// ReSharper disable once UnusedMember.Global public async Task Invoke(HttpContext context, SitemapBuilder sitemapBuilder, ILogger <StoryblokSitemapMiddleware> logger) { logger.LogTrace("Responding with sitemap XML ..."); var xml = await sitemapBuilder.BuildXml(); context.Response.ContentType = "application/xml"; context.Response.Headers.Add("cache-control", $"public; max-age={(60 * 60 * 12).ToString(CultureInfo.InvariantCulture)}"); await context.Response.WriteAsync(xml); }
public async Task <ActionResult> SitemapAsync() { string root = "http://phimcodoc.net/"; string filmRoot = "http://phimcodoc.net/phim/"; string downloadFilm = "http://phimcodoc.net/tai-phim/"; string watchFilm = "http://phimcodoc.net/xem-phim/"; string ImagesRoot = "http://phimcodoc.net/images/"; string Images115x175 = "http://phimcodoc.net/images/115x175/"; string Images182x268 = "http://phimcodoc.net/images/182x268/"; string Images268x268 = "http://phimcodoc.net/images/268x268/"; string Images640x351 = "http://phimcodoc.net/images/640x351/"; string Images1140x641 = "http://phimcodoc.net/images/1140x641/"; string Images1300x500 = "http://phimcodoc.net/images/1300x500/"; // get a list of published articles var films = await _blogService.Film.ToListAsync(); var images = await _blogService.Images.ToListAsync(); // get last modified date of the home page var siteMapBuilder = new SitemapBuilder(); // add the home page to the sitemap siteMapBuilder.AddUrl(root, modified: DateTime.UtcNow, changeFrequency: ChangeFrequency.Weekly, priority: 1.0); // add the blog posts to the sitemap foreach (var film in films) { siteMapBuilder.AddUrl(filmRoot + film.Slug, modified: film.CreateDT, changeFrequency: null, priority: 0.9); siteMapBuilder.AddUrl(downloadFilm + film.Slug, modified: film.CreateDT, changeFrequency: null, priority: 0.9); siteMapBuilder.AddUrl(watchFilm + film.Slug, modified: film.CreateDT, changeFrequency: null, priority: 0.9); } foreach (var image in images) { siteMapBuilder.AddUrl(ImagesRoot + image.Name, modified: image.CreateDT, changeFrequency: null, priority: 0.9); siteMapBuilder.AddUrl(Images115x175 + image.Name, modified: image.CreateDT, changeFrequency: null, priority: 0.9); siteMapBuilder.AddUrl(Images182x268 + image.Name, modified: image.CreateDT, changeFrequency: null, priority: 0.9); siteMapBuilder.AddUrl(Images268x268 + image.Name, modified: image.CreateDT, changeFrequency: null, priority: 0.9); siteMapBuilder.AddUrl(Images1140x641 + image.Name, modified: image.CreateDT, changeFrequency: null, priority: 0.9); siteMapBuilder.AddUrl(Images1300x500 + image.Name, modified: image.CreateDT, changeFrequency: null, priority: 0.9); siteMapBuilder.AddUrl(Images640x351 + image.Name, modified: image.CreateDT, changeFrequency: null, priority: 0.9); } // generate the sitemap xml string xml = siteMapBuilder.ToString(); return(Content(xml, "text/xml")); }
private IReadOnlyCollection <NavBarItem> CreateNavBarItems() { var rt = WebPipeline.CurrentRequest; var siteId = rt.Route.SiteId; var adminSite = _siteRepository.GetById(siteId); var sitemap = SitemapBuilder.BuildSitemap(adminSite, ContentEnvironment.Live, SitemapBuilderFilters.DisplayInNavigation); List <NavBarItem> navBarItems = new List <NavBarItem>(); foreach (var node in sitemap.ChildNodes) { var item = CreateNavBarItem(node); navBarItems.Add(item); } return(navBarItems); }
public async Task <ActionResult> SitemapAsync() { string baseUrl = $"{Request.Scheme}://{Request.Host}"; var siteMapBuilder = new SitemapBuilder(); // add the home page siteMapBuilder.AddUrl(baseUrl, modified: DateTime.UtcNow, changeFrequency: ChangeFrequency.Weekly, priority: 1.0); // add blog posts var posts = await _blog.GetPosts(); foreach (var post in posts) { string postUrl = $"{baseUrl}/blog/{post.ID}"; siteMapBuilder.AddUrl(postUrl, modified: post.LastModified, changeFrequency: null, priority: 0.9); } return(Content(siteMapBuilder.ToString(), "text/xml")); }
public void SitemapIndex() { const int count = 10; var items = new IndexElement[count]; for (var i = 0; i < count; i++) { items[i] = new IndexElement { Url = "http://example.com/page" + (i + 1), Modified = DateTime.Now.Add(TimeSpan.FromMinutes(i + 1)) }; } var xDoc = SitemapBuilder.BuildIndexMap(items); Assert.Equal(count, xDoc.Root.Descendants(SitemapConstants.NS + "sitemap").Count()); xDoc.Save("sitemap_index.xml"); }
public async Task <ActionResult> GetSitemap() { var siteMapBuilder = new SitemapBuilder(); string baseAddress = Configuration.GetBaseAddress().TrimEnd('/'); siteMapBuilder.AddUrl(baseAddress); { var posts = await BlogService.PostService.All(); siteMapBuilder.AddUrl($"{baseAddress}/posts"); siteMapBuilder.AddUrl($"{baseAddress}/articles"); siteMapBuilder.AddUrl($"{baseAddress}/slides"); siteMapBuilder.AddUrl($"{baseAddress}/notes"); foreach (var id in posts) { siteMapBuilder.AddUrl($"{baseAddress}/posts/{id}"); } }; { var keywords = await BlogService.KeywordService.All(); siteMapBuilder.AddUrl($"{baseAddress}/keywords"); foreach (var id in keywords) { siteMapBuilder.AddUrl($"{baseAddress}/keywords/{id}"); } }; { var categories = await BlogService.CategoryService.All(); siteMapBuilder.AddUrl($"{baseAddress}/categories"); foreach (var id in categories) { siteMapBuilder.AddUrl($"{baseAddress}/categories/{id}"); } }; return(Content(siteMapBuilder.ToString(), "text/xml")); }
public ActionResult sitemap() { SitemapBuilder builder = new SitemapBuilder(); builder.AppendUrl(Url.Action("Index", "Home", null, this.Request.Url.Scheme), ChangefreqEnum.daily); builder.AppendUrl(Url.Action("register", "user", null, this.Request.Url.Scheme), ChangefreqEnum.monthly); builder.AppendUrl(Url.Action("login", "user", null, this.Request.Url.Scheme), ChangefreqEnum.monthly); builder.AppendUrl(Url.Action("contact", "home", null, this.Request.Url.Scheme), ChangefreqEnum.monthly); builder.AppendUrl(Url.Action("specialOffers", "product", null, this.Request.Url.Scheme), ChangefreqEnum.monthly); builder.AppendUrl(Url.Action("about", "Home", null, this.Request.Url.Scheme), ChangefreqEnum.monthly); builder.AppendUrl(Url.Action("privacy", "home", null, this.Request.Url.Scheme), ChangefreqEnum.daily); builder.AppendUrl(Url.Action("faqs", "home", null, this.Request.Url.Scheme), ChangefreqEnum.daily); var pID = db.Products.Select(c => c.productID); foreach (var item in pID) { builder.AppendUrl(Url.Action("show", "product", new { id = item }, this.Request.Url.Scheme), ChangefreqEnum.daily); } var brands = db.Brands.Select(c => c.brandID); foreach (var item in brands) { builder.AppendUrl(Url.Action("list", "productcategory", new { b = item }, this.Request.Url.Scheme), ChangefreqEnum.daily); } var categories = db.ProductCategories.Select(c => c.categoryID); foreach (var item in categories) { builder.AppendUrl(Url.Action("list", "productcategory", new { c = item }, this.Request.Url.Scheme), ChangefreqEnum.monthly); } return(new XmlViewResult(builder.XmlDocument)); }
public IActionResult Sitemap() { string baseUrl = "https://gustafsgallery.co.uk"; // get a list of products var products = _context.Products. Include(x => x.ProductBrand). ToList(); // get last modified date of the home page var siteMapBuilder = new SitemapBuilder(); // add the home page to the sitemap siteMapBuilder.AddUrl(baseUrl, modified: DateTime.Now, changeFrequency: ChangeFrequency.Weekly, priority: 1.0); // add the blog posts to the sitemap foreach (var product in products) { siteMapBuilder.AddUrl(string.Format("{0}/Products/Product?id={1}", baseUrl, product.Id), modified: product.CreateDate, changeFrequency: null, priority: 0.9); siteMapBuilder.AddUrl(string.Format("{0}/Products/ProductByName?product={1}", baseUrl, product.Title.Replace(' ', '_') + "_by_" + product.ProductBrand.Brand.Replace(' ', '_')), modified: product.CreateDate, changeFrequency: null, priority: 0.9); } siteMapBuilder.AddUrl(string.Format("{0}/Products", baseUrl), modified: DateTime.Now, changeFrequency: ChangeFrequency.Weekly, priority: 0.9); siteMapBuilder.AddUrl(string.Format("{0}/Orders", baseUrl), modified: DateTime.Now, changeFrequency: ChangeFrequency.Weekly, priority: 0.9); siteMapBuilder.AddUrl(string.Format("{0}/Home/{1}", baseUrl, "Privacy"), modified: DateTime.Now, changeFrequency: ChangeFrequency.Weekly, priority: 0.9); siteMapBuilder.AddUrl(string.Format("{0}/Home/{1}", baseUrl, "TermsAndConditions"), modified: DateTime.Now, changeFrequency: ChangeFrequency.Weekly, priority: 0.9); siteMapBuilder.AddUrl(string.Format("{0}/Home/{1}", baseUrl, "CookiePolicy"), modified: DateTime.Now, changeFrequency: ChangeFrequency.Weekly, priority: 0.9); siteMapBuilder.AddUrl(string.Format("{0}/Home/{1}", baseUrl, "AnimalFayreDesigns"), modified: DateTime.Now, changeFrequency: ChangeFrequency.Weekly, priority: 0.9); siteMapBuilder.AddUrl(string.Format("{0}/Home/{1}", baseUrl, "JackConkieIllustrations"), modified: DateTime.Now, changeFrequency: ChangeFrequency.Weekly, priority: 0.9); siteMapBuilder.AddUrl(string.Format("{0}/Home/{1}", baseUrl, "SilverBoughJewellery"), modified: DateTime.Now, changeFrequency: ChangeFrequency.Weekly, priority: 0.9); siteMapBuilder.AddUrl(string.Format("{0}/Home/{1}", baseUrl, "Contact"), modified: DateTime.Now, changeFrequency: ChangeFrequency.Weekly, priority: 0.9); // generate the sitemap xml string xml = siteMapBuilder.ToString(); return(Content(xml, "text/xml")); }
public async Task <IActionResult> Sitemap() { string baseUrl = "http://itlibrary.site/books/"; // get a list of published articles var books = await _booksService.ReadAll(); // get last modified date of the home page var siteMapBuilder = new SitemapBuilder(); // add the home page to the sitemap siteMapBuilder.AddUrl(baseUrl, modified: DateTime.UtcNow, changeFrequency: ChangeFrequency.Weekly, priority: 1.0); // add the blog posts to the sitemap foreach (var book in books) { siteMapBuilder.AddUrl(baseUrl + book.BookGuid, modified: DateTime.Now, changeFrequency: null, priority: 0.9); } // generate the sitemap xml string xml = siteMapBuilder.ToString(); return(Content(xml, "text/xml")); }
public void Urlset() { const int count = 10; var items = new UrlElement[count]; for (var i = 0; i < count; i++) { var urlEntry = new UrlElement { Url = "http://example.com/page" + (i + 1), Modified = DateTime.Now.Add(TimeSpan.FromMinutes(i + 1)), ChangeFrequency = ChangeFrequency.Always, Priority = 1 }; for (var j = 0; j < 5; j++) { urlEntry.Images.Add(new ImageElement { Url = "http://example.com/page" + i + "/image" + j + ".jpg", Caption = "Image caption " + j, Geo = "geo location address", Title = "Image title " + j, License = "License" }); } items[i] = urlEntry; } var xDoc = SitemapBuilder.BuildUrlset(items); Assert.Equal(count, xDoc.Root.Descendants(SitemapConstants.NS + "url").Count()); xDoc.Save("urlset.xml"); }
private void BindProviders() { var builder = new SitemapBuilder(PortalSettings); grdProviders.DataSource = builder.Providers; }
public IEnumerable <SitemapProvider> GetSitemapProviders() { var builder = new SitemapBuilder(_portalSettings); return(builder.Providers); }