Skip to content

Commit ddcb39b

Browse files
committed
* Fixes #2 Bad format of priority in not US culture
* Also added test project
1 parent 6f06c27 commit ddcb39b

20 files changed

+362
-2
lines changed

src/Cofoundry.Plugins.SiteMap.sln

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
44
VisualStudioVersion = 15.0.26430.13
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cofoundry.Plugins.SiteMap", "Cofoundry.Plugins.SiteMap\Cofoundry.Plugins.SiteMap.csproj", "{EB0B3CB1-8AF1-41F9-97CA-5208BF17FA5A}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cofoundry.Plugins.SiteMap", "Cofoundry.Plugins.SiteMap\Cofoundry.Plugins.SiteMap.csproj", "{EB0B3CB1-8AF1-41F9-97CA-5208BF17FA5A}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SitemapExample", "SitemapExample\SitemapExample.csproj", "{16753557-7C98-46B4-925A-F2E18F869974}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{2A5BFC8A-1F5F-414C-B67F-964364273F8A}"
711
EndProject
812
Global
913
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,8 +19,18 @@ Global
1519
{EB0B3CB1-8AF1-41F9-97CA-5208BF17FA5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
1620
{EB0B3CB1-8AF1-41F9-97CA-5208BF17FA5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
1721
{EB0B3CB1-8AF1-41F9-97CA-5208BF17FA5A}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{16753557-7C98-46B4-925A-F2E18F869974}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{16753557-7C98-46B4-925A-F2E18F869974}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{16753557-7C98-46B4-925A-F2E18F869974}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{16753557-7C98-46B4-925A-F2E18F869974}.Release|Any CPU.Build.0 = Release|Any CPU
1826
EndGlobalSection
1927
GlobalSection(SolutionProperties) = preSolution
2028
HideSolutionNode = FALSE
2129
EndGlobalSection
30+
GlobalSection(NestedProjects) = preSolution
31+
{16753557-7C98-46B4-925A-F2E18F869974} = {2A5BFC8A-1F5F-414C-B67F-964364273F8A}
32+
EndGlobalSection
33+
GlobalSection(ExtensibilityGlobals) = postSolution
34+
SolutionGuid = {929E9936-0E37-4DE7-943D-61FDE8FD101A}
35+
EndGlobalSection
2236
EndGlobal

src/Cofoundry.Plugins.SiteMap/Framework/Builder/SiteMapBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Cofoundry.Core.Web;
88
using Cofoundry.Core.Validation;
99
using Cofoundry.Core.IO;
10+
using System.Globalization;
1011

1112
namespace Cofoundry.Plugins.SiteMap
1213
{
@@ -71,7 +72,7 @@ public XDocument ToXml()
7172

7273
if (resource.Priority.HasValue)
7374
{
74-
el.Add(new XElement(ns + "priority", resource.Priority.Value.ToString("0.0")));
75+
el.Add(new XElement(ns + "priority", resource.Priority.Value.ToString("0.0", CultureInfo.InvariantCulture)));
7576
}
7677

7778
urlset.Add(el);
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using Cofoundry.Domain;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
6+
namespace SitemapExample
7+
{
8+
/// <summary>
9+
/// An example custom entity definition.
10+
/// See https://github.com/cofoundry-cms/cofoundry/wiki/Custom-Entities
11+
/// for more information
12+
/// </summary>
13+
public class ProductCustomEntityDefinition : ICustomEntityDefinition<ProductDataModel>
14+
{
15+
/// <summary>
16+
/// This constant is a convention that allows us to reference this definition code
17+
/// in other parts of the application (e.g. querying)
18+
/// </summary>
19+
public const string DefinitionCode = "EXAPRD";
20+
21+
/// <summary>
22+
/// Unique 6 letter code representing the entity (the convention is to use uppercase)
23+
/// </summary>
24+
public string CustomEntityDefinitionCode => DefinitionCode;
25+
26+
/// <summary>
27+
/// Singlar name of the entity
28+
/// </summary>
29+
public string Name => "Product";
30+
31+
/// <summary>
32+
/// Plural name of the entity
33+
/// </summary>
34+
public string NamePlural => "Products";
35+
36+
/// <summary>
37+
/// A short description that shows up as a tooltip for the admin
38+
/// module.
39+
/// </summary>
40+
public string Description => "An example custom entity type.";
41+
42+
/// <summary>
43+
/// Indicates whether the UrlSlug property should be treated
44+
/// as a unique property and be validated as such.
45+
/// </summary>
46+
public bool ForceUrlSlugUniqueness => true;
47+
48+
/// <summary>
49+
/// Indicates whether the url slug should be autogenerated. If this
50+
/// is selected then the user will not be shown the UrlSlug property
51+
/// and it will be auto-generated based on the title.
52+
/// </summary>
53+
public bool AutoGenerateUrlSlug => true;
54+
55+
/// <summary>
56+
/// Indicates whether this custom entity should always be published when
57+
/// saved, provided the user has permissions to do so. Useful if this isn't
58+
/// the sort of entity that needs a draft state workflow
59+
/// </summary>
60+
public bool AutoPublish => false;
61+
62+
/// <summary>
63+
/// Indicates whether the entities are partitioned by locale
64+
/// </summary>
65+
public bool HasLocale => false;
66+
}
67+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Cofoundry.Domain;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.ComponentModel.DataAnnotations;
5+
using System.Linq;
6+
7+
namespace SitemapExample
8+
{
9+
public class ProductDataModel : ICustomEntityDataModel
10+
{
11+
[MaxLength(500)]
12+
[Display(Description = "A short description of the product.")]
13+
[MultiLineText]
14+
public string ShortDescription { get; set; }
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@model IPageViewModel
2+
@inject ICofoundryTemplateHelper<IPageViewModel> Cofoundry
3+
4+
@Cofoundry.Template.UseDescription("A template for simple pages with flexible module content")
5+
6+
<h1>@Model.PageTitle</h1>
7+
<div>
8+
@(await Cofoundry.Template.Region("Body")
9+
.AllowMultipleBlocks()
10+
.AllowBlockType<PlainTextDataModel>()
11+
.EmptyContentMinHeight(500)
12+
.InvokeAsync())
13+
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
Layout = "~/Views/Shared/_Layout.cshtml";
3+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Cofoundry.Plugins.SiteMap;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
7+
namespace SitemapExample.Cofoundry
8+
{
9+
public class SiteMapResourceRegistration : ISiteMapResourceRegistration
10+
{
11+
public IEnumerable<ISiteMapResource> GetResources()
12+
{
13+
yield return new SiteMapResource()
14+
{
15+
Url = "/test",
16+
LastModifiedDate = DateTime.UtcNow,
17+
Priority = 0.7m
18+
};
19+
}
20+
}
21+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@using SitemapExample
2+
@using Cofoundry.Core
3+
@using Cofoundry.Domain
4+
@using Cofoundry.Web
5+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

src/SitemapExample/Program.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore;
7+
using Microsoft.AspNetCore.Hosting;
8+
9+
namespace SitemapExample
10+
{
11+
public class Program
12+
{
13+
public static void Main(string[] args)
14+
{
15+
CreateWebHostBuilder(args).Build().Run();
16+
}
17+
18+
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
19+
WebHost.CreateDefaultBuilder(args)
20+
.UseStartup<Startup>();
21+
}
22+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:39063",
7+
"sslPort": 44312
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
}
17+
},
18+
"SitemapExample": {
19+
"commandName": "Project",
20+
"launchBrowser": true,
21+
"applicationUrl": "https://localhost:5001;http://localhost:5000",
22+
"environmentVariables": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
}
25+
}
26+
}
27+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<MvcRazorExcludeViewFilesFromPublish>false</MvcRazorExcludeViewFilesFromPublish>
6+
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Cofoundry.Plugins.ErrorLogging.Admin" Version="0.5.0" />
11+
<PackageReference Include="Cofoundry.Plugins.Imaging.ImageSharp" Version="0.1.0-ci0017" />
12+
<PackageReference Include="Cofoundry.Plugins.SiteMap" Version="0.5.0" />
13+
<PackageReference Include="Cofoundry.Web.Admin" Version="0.5.1" />
14+
<PackageReference Include="Microsoft.AspNetCore.App" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference Include="..\Cofoundry.Plugins.SiteMap\Cofoundry.Plugins.SiteMap.csproj" />
19+
</ItemGroup>
20+
21+
</Project>

src/SitemapExample/Startup.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Cofoundry.Web;
6+
using Microsoft.AspNetCore.Builder;
7+
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.DependencyInjection;
10+
11+
namespace SitemapExample
12+
{
13+
public class Startup
14+
{
15+
public IConfiguration Configuration { get; }
16+
17+
public Startup(IConfiguration configuration)
18+
{
19+
Configuration = configuration;
20+
}
21+
22+
public void ConfigureServices(IServiceCollection services)
23+
{
24+
services
25+
.AddMvc()
26+
.AddCofoundry(Configuration);
27+
}
28+
29+
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
30+
{
31+
if (!env.IsDevelopment())
32+
{
33+
app.UseHsts();
34+
}
35+
36+
app.UseHttpsRedirection();
37+
app.UseCofoundry();
38+
}
39+
}
40+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@model IErrorPageViewModel
2+
3+
@{
4+
var title = "Error";
5+
ViewBag.Title = title;
6+
}
7+
8+
9+
<h1>@title</h1>
10+
11+
<h2>@Model.StatusCodeDescription</h2>
12+
<p>Sorry, there has been an error</p>
13+
<p>Please press back and try again. If the error persists then then please contact us.</p>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@model INotFoundPageViewModel
2+
3+
@{
4+
var title = "404: Not Found";
5+
ViewBag.Title = title;
6+
}
7+
8+
<h1>@title</h1>
9+
<p>
10+
Sorry, that page could not be found
11+
</p>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@inject ICofoundryHelper Cofoundry
2+
3+
@{
4+
Layout = null;
5+
6+
string title = null;
7+
string description = null;
8+
9+
var metaDataModel = Model as IPageWithMetaDataViewModel;
10+
if (metaDataModel != null)
11+
{
12+
description = metaDataModel.MetaDescription;
13+
title = metaDataModel.PageTitle;
14+
}
15+
else
16+
{
17+
description = "TODO: Add default description";
18+
}
19+
20+
title = StringHelper.FirstNonEmpty(title, ViewBag.Title, "TODO: Add default title");
21+
title += " | Cofoundry Template Site";
22+
}
23+
24+
<!DOCTYPE html>
25+
<html lang="en">
26+
<head>
27+
<meta charset="utf-8">
28+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
29+
<meta name="viewport" content="width=device-width, initial-scale=1">
30+
31+
<title>@title</title>
32+
33+
<meta name="description" content="@description" />
34+
35+
<link rel="stylesheet" href="~/css/style.css" asp-append-version="true" />
36+
37+
</head>
38+
<body>
39+
40+
<nav>
41+
<span>Cofoundry Template Site</span>
42+
</nav>
43+
44+
<main>
45+
@RenderBody()
46+
</main>
47+
48+
<footer>
49+
<span>Copyright © @DateTime.Now.Year Example Inc. All Rights Reserved</span>
50+
</footer>
51+
52+
@RenderSection("FooterScripts", required: false)
53+
54+
</body>
55+
</html>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@using SitemapExample
2+
@using Cofoundry.Core
3+
@using Cofoundry.Domain
4+
@using Cofoundry.Web
5+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
Layout = "~/Views/Shared/_Layout.cshtml";
3+
}

0 commit comments

Comments
 (0)