diff --git a/src/Dfe.ContentSupport.Web/Controllers/SitemapController.cs b/src/Dfe.ContentSupport.Web/Controllers/SitemapController.cs index fe6530d..ac02f92 100644 --- a/src/Dfe.ContentSupport.Web/Controllers/SitemapController.cs +++ b/src/Dfe.ContentSupport.Web/Controllers/SitemapController.cs @@ -1,11 +1,34 @@ -using Dfe.ContentSupport.Web.Services; +using Dfe.ContentSupport.Web.Models.Mapped; +using Dfe.ContentSupport.Web.Services; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Dfe.ContentSupport.Web.Controllers; +[Route("/sitemap")] +[AllowAnonymous] public class SitemapController(IContentService contentfulService) : Controller { - public async Task Index() + [HttpGet] + [Route("/")] + public IActionResult Index() + { + var defaultModel = new CsPage + { + Heading = new Models.Heading + { + Title = "Department for Education", + Subtitle = "Content and Support" + } + }; + + + return View(defaultModel); + } + + [HttpGet] + [Route("/sitemap.xml")] + public async Task Sitemap() { var baseUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}/"; var sitemap = await contentfulService.GenerateSitemap(baseUrl); diff --git a/src/Dfe.ContentSupport.Web/Extensions/DateTimeExtensions.cs b/src/Dfe.ContentSupport.Web/Extensions/DateTimeExtensions.cs new file mode 100644 index 0000000..8b327c0 --- /dev/null +++ b/src/Dfe.ContentSupport.Web/Extensions/DateTimeExtensions.cs @@ -0,0 +1,9 @@ +namespace Dfe.ContentSupport.Web.Extensions; + +public static class DateTimeExtensions +{ + public static string ToLongString(this DateTime dateTime) + { + return dateTime.ToString("dd MMMM yyyy"); + } +} \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Models/ContentBase.cs b/src/Dfe.ContentSupport.Web/Models/ContentBase.cs index 9379dcf..636506b 100644 --- a/src/Dfe.ContentSupport.Web/Models/ContentBase.cs +++ b/src/Dfe.ContentSupport.Web/Models/ContentBase.cs @@ -3,7 +3,7 @@ namespace Dfe.ContentSupport.Web.Models; [ExcludeFromCodeCoverage] -public class ContentBase +public class ContentBase : ContentType { public string InternalName { get; set; } = null!; } \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Models/ContentItemBase.cs b/src/Dfe.ContentSupport.Web/Models/ContentItemBase.cs index 475a159..a33cad6 100644 --- a/src/Dfe.ContentSupport.Web/Models/ContentItemBase.cs +++ b/src/Dfe.ContentSupport.Web/Models/ContentItemBase.cs @@ -3,9 +3,8 @@ namespace Dfe.ContentSupport.Web.Models; [ExcludeFromCodeCoverage] -public class ContentItemBase +public class ContentItemBase:ContentBase { - public string InternalName { get; set; } = null!; public string NodeType { get; set; } = null!; public Data Data { get; set; } = null!; public List Content { get; set; } = []; diff --git a/src/Dfe.ContentSupport.Web/Models/Mapped/CsPage.cs b/src/Dfe.ContentSupport.Web/Models/Mapped/CsPage.cs index f449fce..2017016 100644 --- a/src/Dfe.ContentSupport.Web/Models/Mapped/CsPage.cs +++ b/src/Dfe.ContentSupport.Web/Models/Mapped/CsPage.cs @@ -8,5 +8,9 @@ public class CsPage public Heading Heading { get; set; } = null!; public string Slug { get; set; } = null!; public bool IsSitemap { get; set; } + public bool HasCitation { get; set; } + public bool HasBackToTop { get; set; } public List Content { get; set; } = null!; + public DateTime? CreatedAt { get; init; } + public DateTime? UpdatedAt { get; init; } } \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Models/Mapped/Custom/CustomAccordion.cs b/src/Dfe.ContentSupport.Web/Models/Mapped/Custom/CustomAccordion.cs index e7def64..3846d31 100644 --- a/src/Dfe.ContentSupport.Web/Models/Mapped/Custom/CustomAccordion.cs +++ b/src/Dfe.ContentSupport.Web/Models/Mapped/Custom/CustomAccordion.cs @@ -12,7 +12,7 @@ public CustomAccordion() } public List Accordions { get; set; } = null!; - public string Body { get; set; } = null!; + public RichTextContentItem? Body { get; set; } public string SummaryLine { get; set; } = null!; public string Title { get; set; } = null!; } \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Models/Mapped/Custom/CustomAttachment.cs b/src/Dfe.ContentSupport.Web/Models/Mapped/Custom/CustomAttachment.cs index 5312ccc..c444284 100644 --- a/src/Dfe.ContentSupport.Web/Models/Mapped/Custom/CustomAttachment.cs +++ b/src/Dfe.ContentSupport.Web/Models/Mapped/Custom/CustomAttachment.cs @@ -1,4 +1,4 @@ -using Dfe.ContentSupport.Web.Models.Mapped.Types; +using Dfe.ContentSupport.Web.Models.Mapped.Types; using System.Diagnostics.CodeAnalysis; namespace Dfe.ContentSupport.Web.Models.Mapped.Custom; @@ -15,4 +15,5 @@ public CustomAttachment() public long Size { get; set; } public string Title { get; set; } = null!; public string Uri { get; set; } = null!; + public DateTime? UpdatedAt { get; set; } = null!; } \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Models/Sys.cs b/src/Dfe.ContentSupport.Web/Models/Sys.cs index d0ab621..3ac86c9 100644 --- a/src/Dfe.ContentSupport.Web/Models/Sys.cs +++ b/src/Dfe.ContentSupport.Web/Models/Sys.cs @@ -7,4 +7,6 @@ public class Sys { public string Id { get; set; } = null!; public ContentType? ContentType { get; set; } = null!; + public DateTime? CreatedAt { get; init; } + public DateTime? UpdatedAt { get; init; } } \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Models/Target.cs b/src/Dfe.ContentSupport.Web/Models/Target.cs index e554449..adc0772 100644 --- a/src/Dfe.ContentSupport.Web/Models/Target.cs +++ b/src/Dfe.ContentSupport.Web/Models/Target.cs @@ -7,11 +7,9 @@ namespace Dfe.ContentSupport.Web.Models; public class Target : Entry { public Fields Fields { get; set; } = null!; - public Sys Sys { get; set; } = null!; public string Title { get; set; } = null!; public Asset Asset { get; set; } = null!; public string SummaryLine { get; set; } = null!; - public string Body { get; set; } = null!; public string Description { get; set; } = null!; public string Meta { get; set; } = null!; public string ImageAlt { get; set; } = null!; diff --git a/src/Dfe.ContentSupport.Web/Program.cs b/src/Dfe.ContentSupport.Web/Program.cs index f2d3870..62b2e40 100644 --- a/src/Dfe.ContentSupport.Web/Program.cs +++ b/src/Dfe.ContentSupport.Web/Program.cs @@ -41,7 +41,7 @@ public static void Main(string[] args) app.UseCookiePolicy(); app.MapControllerRoute( - "sitemap", + "Default", "sitemap.xml", new { controller = "Sitemap", action = "Index" } ); @@ -52,9 +52,6 @@ public static void Main(string[] args) pattern: "{controller=Cache}/{action=Clear}" ); - app.MapControllerRoute( - name: "home", - pattern: "{controller=Home}/{action=Home}"); app.MapControllerRoute( name: "slug", diff --git a/src/Dfe.ContentSupport.Web/Services/ModelMapper.cs b/src/Dfe.ContentSupport.Web/Services/ModelMapper.cs index 1341d97..a9b8262 100644 --- a/src/Dfe.ContentSupport.Web/Services/ModelMapper.cs +++ b/src/Dfe.ContentSupport.Web/Services/ModelMapper.cs @@ -23,7 +23,11 @@ public CsPage MapToCsPage(ContentSupportPage incoming) Heading = incoming.Heading, Slug = incoming.Slug, IsSitemap = incoming.IsSitemap, - Content = MapEntriesToContent(incoming.Content) + HasCitation = incoming.HasCitation, + HasBackToTop = incoming.HasBackToTop, + Content = MapEntriesToContent(incoming.Content), + CreatedAt = incoming.Sys.CreatedAt, + UpdatedAt = incoming.Sys.UpdatedAt }; return result; } @@ -124,7 +128,7 @@ public List MapRichTextNodes(List nodes) default: return null; } - + item.Content = MapRichTextNodes(contentItem.Content); item.Value = contentItem.Value; item.InternalName = internalName; @@ -150,7 +154,7 @@ private CustomAccordion GenerateCustomAccordion(Target target) return new CustomAccordion { InternalName = target.InternalName, - Body = target.Body, + Body = MapRichTextContent(target.RichText), SummaryLine = target.SummaryLine, Title = target.Title, Accordions = target.Content.Select(GenerateCustomAccordion).ToList() @@ -165,7 +169,8 @@ private CustomAttachment GenerateCustomAttachment(Target target) ContentType = target.Asset.File.ContentType, Size = target.Asset.File.Details.Size, Title = target.Title, - Uri = target.Asset.File.Url + Uri = target.Asset.File.Url, + UpdatedAt = target.Asset.SystemProperties.UpdatedAt }; } @@ -220,8 +225,8 @@ public RichTextNodeType ConvertToRichTextNodeType(string str) _ => RichTextNodeType.Unknown }; } - - + + public AssetContentType ConvertToAssetContentType(string str) { if (supportedAssetTypes.ImageTypes.Contains(str)) return AssetContentType.Image; diff --git a/src/Dfe.ContentSupport.Web/ViewModels/ContentSupportPage.cs b/src/Dfe.ContentSupport.Web/ViewModels/ContentSupportPage.cs index bcb5de5..90b0f42 100644 --- a/src/Dfe.ContentSupport.Web/ViewModels/ContentSupportPage.cs +++ b/src/Dfe.ContentSupport.Web/ViewModels/ContentSupportPage.cs @@ -15,8 +15,6 @@ public class ContentSupportPage : ContentBase public bool DisplayBackButton { get; init; } public bool IsSitemap { get; init; } - - public DateTime? CreatedAt { get; init; } - - public DateTime? UpdatedAt { get; init; } + public bool HasCitation { get; init; } + public bool HasBackToTop { get; init; } } \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Views/Content/CsIndex.cshtml b/src/Dfe.ContentSupport.Web/Views/Content/CsIndex.cshtml index 14d1321..940966e 100644 --- a/src/Dfe.ContentSupport.Web/Views/Content/CsIndex.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Content/CsIndex.cshtml @@ -4,7 +4,22 @@ Layout = "_CsLayout"; } -@foreach (var content in Model.Content) -{ - -} \ No newline at end of file +
+
+ + @foreach (var content in Model.Content) + { + + } + + @if (Model.HasCitation) + { + + } + + @if (Model.HasBackToTop) + { + + } +
+
\ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Views/Content/Home.cshtml b/src/Dfe.ContentSupport.Web/Views/Content/Home.cshtml index 459a1e7..3a047f9 100644 --- a/src/Dfe.ContentSupport.Web/Views/Content/Home.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Content/Home.cshtml @@ -15,8 +15,8 @@

@csPage.Heading.Title

-

@csPage.Heading.Subtitle

-

Slug: @csPage.Slug

+

@csPage.Heading.Subtitle

+

Slug: @csPage.Slug

} diff --git a/src/Dfe.ContentSupport.Web/Views/Content/Privacy.cshtml b/src/Dfe.ContentSupport.Web/Views/Content/Privacy.cshtml index e6eef70..88d5bc4 100644 --- a/src/Dfe.ContentSupport.Web/Views/Content/Privacy.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Content/Privacy.cshtml @@ -3,4 +3,4 @@ }

@ViewData["Title"]

-

Use this page to detail your site's privacy policy.

\ No newline at end of file +

Use this page to detail your site's privacy policy.

\ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Views/Shared/Error.cshtml b/src/Dfe.ContentSupport.Web/Views/Shared/Error.cshtml index 3516938..e44e743 100644 --- a/src/Dfe.ContentSupport.Web/Views/Shared/Error.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Shared/Error.cshtml @@ -8,9 +8,9 @@ @if (Model.ShowRequestId) { -

+

Request ID: @Model.RequestId -

+

}

Development Mode

diff --git a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/Custom/_Accordion.cshtml b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/Custom/_Accordion.cshtml index df01048..b918313 100644 --- a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/Custom/_Accordion.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/Custom/_Accordion.cshtml @@ -16,7 +16,7 @@
-

@accordion.Body

+
} diff --git a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/Custom/_Attachment.cshtml b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/Custom/_Attachment.cshtml index 6b74d22..1b528f2 100644 --- a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/Custom/_Attachment.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/Custom/_Attachment.cshtml @@ -1,49 +1,64 @@ +@using System @model CustomAttachment -
-
\ No newline at end of file + \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_H.cshtml b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_H.cshtml index cfe5e1c..830e6bf 100644 --- a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_H.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_H.cshtml @@ -4,12 +4,12 @@ switch (Model.NodeType) { case RichTextNodeType.Heading2: -

+

break; case RichTextNodeType.Heading3: -

+

break; diff --git a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_HyperLink.cshtml b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_HyperLink.cshtml index e0a5040..46be2f8 100644 --- a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_HyperLink.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_HyperLink.cshtml @@ -6,7 +6,7 @@ } else { - + } \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_Paragraph.cshtml b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_Paragraph.cshtml index f09928e..ca45f0f 100644 --- a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_Paragraph.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_Paragraph.cshtml @@ -1,5 +1,5 @@ @model RichTextContentItem -

+

\ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_UnorderedList.cshtml b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_UnorderedList.cshtml index 2c47203..39232a5 100644 --- a/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_UnorderedList.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Shared/RichText/_UnorderedList.cshtml @@ -1,5 +1,5 @@ @model RichTextContentItem -
    +
    \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Views/Shared/_BackToTop.cshtml b/src/Dfe.ContentSupport.Web/Views/Shared/_BackToTop.cshtml new file mode 100644 index 0000000..43539fd --- /dev/null +++ b/src/Dfe.ContentSupport.Web/Views/Shared/_BackToTop.cshtml @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Views/Shared/_Citation.cshtml b/src/Dfe.ContentSupport.Web/Views/Shared/_Citation.cshtml new file mode 100644 index 0000000..a465c88 --- /dev/null +++ b/src/Dfe.ContentSupport.Web/Views/Shared/_Citation.cshtml @@ -0,0 +1,15 @@ +@using Dfe.ContentSupport.Web.Extensions +@model CsPage + +
    + +
    \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Views/Shared/_CsHeader.cshtml b/src/Dfe.ContentSupport.Web/Views/Shared/_CsHeader.cshtml index 750993c..94f8019 100644 --- a/src/Dfe.ContentSupport.Web/Views/Shared/_CsHeader.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Shared/_CsHeader.cshtml @@ -5,11 +5,6 @@ DfE Homepage - \ No newline at end of file diff --git a/src/Dfe.ContentSupport.Web/Views/Shared/_Hero.cshtml b/src/Dfe.ContentSupport.Web/Views/Shared/_Hero.cshtml index e0aab88..2385506 100644 --- a/src/Dfe.ContentSupport.Web/Views/Shared/_Hero.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Shared/_Hero.cshtml @@ -6,7 +6,7 @@

    @Model.Title

    -

    @Model.Subtitle

    +

    @Model.Subtitle

    diff --git a/src/Dfe.ContentSupport.Web/Views/Shared/_UnsupportedElement.cshtml b/src/Dfe.ContentSupport.Web/Views/Shared/_UnsupportedElement.cshtml index 9810087..4018476 100644 --- a/src/Dfe.ContentSupport.Web/Views/Shared/_UnsupportedElement.cshtml +++ b/src/Dfe.ContentSupport.Web/Views/Shared/_UnsupportedElement.cshtml @@ -1,7 +1,7 @@ @model RichTextContentItem
    -

    +

    Unsupported element
    - internalName: @Model.InternalName
    - nodeType: @Model.NodeType diff --git a/src/Dfe.ContentSupport.Web/Views/Sitemap/Index.cshtml b/src/Dfe.ContentSupport.Web/Views/Sitemap/Index.cshtml new file mode 100644 index 0000000..33c6f37 --- /dev/null +++ b/src/Dfe.ContentSupport.Web/Views/Sitemap/Index.cshtml @@ -0,0 +1,2 @@ +@model CsPage + diff --git a/src/Dfe.ContentSupport.Web/wwwroot/assets/images/generic-file-icon.svg b/src/Dfe.ContentSupport.Web/wwwroot/assets/images/generic-file-icon.svg index 44eade0..78e30f8 100644 --- a/src/Dfe.ContentSupport.Web/wwwroot/assets/images/generic-file-icon.svg +++ b/src/Dfe.ContentSupport.Web/wwwroot/assets/images/generic-file-icon.svg @@ -1,4 +1,4 @@ -