Skip to content

Commit

Permalink
Add update index.html site title from dynamic config
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitrijOkeanij committed Jun 27, 2021
1 parent d507525 commit fa398bf
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sunengine-client",
"version": "2.13.3",
"version": "2.13.4",
"description": "SunEngine - web engine with support of blog, forum and articles functionality",
"productName": "SunEngine",
"author": "Dmitrij Polianin",
Expand Down
2 changes: 1 addition & 1 deletion README.RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# SunEngine

<a href="#"><img src="https://img.shields.io/static/v1?label=%D0%92%D0%B5%D1%80%D1%81%D0%B8%D1%8F&message=v2.13.3&color=green"></a>
<a href="#"><img src="https://img.shields.io/static/v1?label=%D0%92%D0%B5%D1%80%D1%81%D0%B8%D1%8F&message=v2.13.4&color=green"></a>
<a href="#"><img src="https://github.com/sunengine/SunEngine/workflows/.NET%20Core/badge.svg" ></a>
<a href="#"><img src="https://github.com/sunengine/SunEngine/workflows/Quasar/badge.svg" ></a>
<br/>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Build on AspNet Core, VueJS, Quasar.</h3>

# SunEngine

<a href="#"><img src="https://img.shields.io/static/v1?label=Version&message=v2.13.3&color=green"></a>
<a href="#"><img src="https://img.shields.io/static/v1?label=Version&message=v2.13.4&color=green"></a>
<a href="#"><img src="https://github.com/sunengine/SunEngine/workflows/.NET%20Core/badge.svg" ></a>
<a href="#"><img src="https://github.com/sunengine/SunEngine/workflows/Quasar/badge.svg" ></a>
<br/>
Expand Down
21 changes: 13 additions & 8 deletions Server/SunEngine.Admin/Services/ConfigurationAdminService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void UpdateClientScripts()
File.WriteAllText(configJsPath, configJs);

UpdateConfigAndCustomCssVersion();
UpdateDescription();
UpdateTitleAndDescription();
}

public void UpdateConfigAndCustomCssVersion()
Expand Down Expand Up @@ -154,22 +154,27 @@ protected void UpdateCustomJavaScriptVersion()
File.WriteAllText(configJsPath, text);
}

public void UpdateDescription()
public void UpdateTitleAndDescription()
{
string description = configurationRoot.GetValue(typeof(String), "Global:SiteDescription").ToString();

description = new Regex("[<>\"\'/`]").Replace(description,"");

var indexHtmlPath = pathService.Combine(PathNames.WwwRootDirName, PathNames.IndexHtmlFileName);
if (!File.Exists(indexHtmlPath))
{
Console.WriteLine("Can not write to file " + indexHtmlPath);
return;
}

string text = File.ReadAllText(indexHtmlPath);
Regex reg = new Regex("<meta name=\"{0,1}description\"{0,1} content=\"(.*?)\"");

string title = configurationRoot.GetValue(typeof(String), "Global:SiteName").ToString();
title = new Regex("[<>\"\'/`]").Replace(title,"");
Regex reg = new Regex("<title>(.*?)</title>");
text = reg.Replace(text, $"<title>{title}</title>");

string description = configurationRoot.GetValue(typeof(String), "Global:SiteDescription").ToString();
description = new Regex("[<>\"\'/`]").Replace(description,"");
reg = new Regex("<meta name=\"{0,1}description\"{0,1} content=\"(.*?)\"");
text = reg.Replace(text, $"<meta name=\"description\" content=\"{description}\"");


File.WriteAllText(indexHtmlPath, text);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Server/SunEngine.Cli/SunEngine.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Version>2.13.3</Version>
<Version>2.13.4</Version>
<Title>SunEngine</Title>
<Authors>Dmitrij Polianin</Authors>
<Description>Site engine with blog, forum and articles functionalities on Asp.Net Core and Vue.Js.</Description>
Expand Down
2 changes: 1 addition & 1 deletion Server/SunEngine.Core/SunEngine.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Version>2.13.3</Version>
<Version>2.13.4</Version>
<LangVersion>default</LangVersion>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion SunEngine.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SunEngine
**Version 2.13.3**
**Version 2.13.4**
***************************************************************
Do not delete this file! This file need to detect project root.
***************************************************************
Expand Down

0 comments on commit fa398bf

Please sign in to comment.