mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add markdown rendering of company description.
This commit is contained in:
@@ -32,6 +32,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cicm.Database.Schemas;
|
||||
using Markdig;
|
||||
|
||||
namespace cicm_web.Models
|
||||
{
|
||||
@@ -60,6 +61,7 @@ namespace cicm_web.Models
|
||||
public static CompanyWithItems GetItem(int id)
|
||||
{
|
||||
Cicm.Database.Schemas.Company dbItem = Program.Database?.Operations.GetCompany(id);
|
||||
MarkdownPipeline pipeline = new Markdig.MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
|
||||
|
||||
return dbItem == null
|
||||
? null
|
||||
@@ -83,7 +85,7 @@ namespace cicm_web.Models
|
||||
Website = dbItem.Website,
|
||||
Logos = dbItem.Logos,
|
||||
LastLogo = dbItem.LastLogo,
|
||||
Description = dbItem.Description
|
||||
Description = dbItem.Description == null ? null : Markdig.Markdown.ToHtml(dbItem.Description, pipeline)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -92,6 +94,7 @@ namespace cicm_web.Models
|
||||
List<Cicm.Database.Schemas.Company> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetCompanies(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
MarkdownPipeline pipeline = new Markdig.MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
|
||||
|
||||
return dbItems.Select(t => new CompanyWithItems
|
||||
{
|
||||
@@ -113,7 +116,7 @@ namespace cicm_web.Models
|
||||
Website = t.Website,
|
||||
Logos = t.Logos,
|
||||
LastLogo = t.LastLogo,
|
||||
Description = t.Description
|
||||
Description = t.Description == null ? null : Markdig.Markdown.ToHtml(t.Description, pipeline)
|
||||
}).OrderBy(t => t.Name).ToArray();
|
||||
}
|
||||
|
||||
@@ -122,6 +125,7 @@ namespace cicm_web.Models
|
||||
List<Cicm.Database.Schemas.Company> dbItems = null;
|
||||
bool? result = Program.Database?.Operations.GetCompanies(out dbItems);
|
||||
if(result == null || result.Value == false || dbItems == null) return null;
|
||||
MarkdownPipeline pipeline = new Markdig.MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
|
||||
|
||||
return dbItems
|
||||
.Where(t => t.Name.StartsWith(new string(letter, 1), StringComparison.InvariantCultureIgnoreCase))
|
||||
@@ -145,7 +149,7 @@ namespace cicm_web.Models
|
||||
Website = t.Website,
|
||||
Logos = t.Logos,
|
||||
LastLogo = t.LastLogo,
|
||||
Description = t.Description
|
||||
Description = t.Description == null ? null : Markdig.Markdown.ToHtml(t.Description, pipeline)
|
||||
}).OrderBy(t => t.Name).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
}
|
||||
@using System.IO
|
||||
@using Cicm.Database.Schemas
|
||||
@using Markdig
|
||||
@model CompanyWithItems
|
||||
|
||||
@if(Model != null)
|
||||
@@ -431,7 +432,7 @@
|
||||
@if(Model.Description != null)
|
||||
{
|
||||
<div class="row container-fluid">
|
||||
@Model.Description
|
||||
@Html.Raw(Model.Description)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<Version>3.0.99.150</Version>
|
||||
<Version>3.0.99.153</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
@@ -14,6 +14,7 @@
|
||||
<NrtShowRevision>true</NrtShowRevision>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Markdig" Version="0.15.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
|
||||
<PackageReference Include="Microsoft.NETCore.App" Version="2.0.6" />
|
||||
<PackageReference Include="MSBump" Version="2.3.2" PrivateAssets="All" />
|
||||
|
||||
Reference in New Issue
Block a user