Skip to content

Commit

Permalink
Infrastructure Preparation 40
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Nov 21, 2023
1 parent c6a7487 commit 7352e82
Show file tree
Hide file tree
Showing 14 changed files with 209 additions and 118 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"Demo": {
"icon-1": 1,
"icon-2": 3,
"icon-3": 2
}
}
219 changes: 110 additions & 109 deletions demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/DemoSettings.json
Original file line number Diff line number Diff line change
@@ -1,113 +1,114 @@
{
"Demo": {
"Domain": "https://www.vegalya.com/",
"PartialsDir": "~/Shared/Partials",
"LayoutDir": "~/Shared/Layout",
"ExceptionHandler": "/Error",
"MapFallbackPage": "/_Host",
"LocaleSwitchEnabled": true,
"ModeSwitchEnabled": true,
"LocaleDefault": "en-GB",
"SvgDir": "media/icons/",
"ModeDefault": "system",
"AssetsDir": "assets/",
"PagesDir": "~/Pages",
"Direction": "rtl",
"Preloader": true,
"Major": 1,
"Minor": 0,
"Build": 1,
"SocialMedia": {
"YouTube": {
"Url": "https://www.youtube.com/@iTaiizor",
"Alt": "YouTube Address",
"Icon": "youtube",
"Line": "<a href='https://www.youtube.com/@iTaiizor'><img src='youtube.svg' alt='YouTube Address' /></a>"
},
"GitHub": {
"Url": "https://github.com/Taiizor",
"Alt": "GitHub Address",
"Icon": "github",
"Line": "<a href='https://github.com/Taiizor'><img src='github.svg' alt='GitHub Address' /></a>"
}
},
"Compression": {
"StaticFile": {
"CacheControl": "public, max-age={0}",
"MaxAge": "1.00:00:00",
"Mode": "Compress",
"Change": true,
"Extensions": [
".jpeg",
".css",
".svg",
".png",
".jpg",
".js"
],
"Headers": {
"Vary": "Accept-Encoding"
"Demo": {
"Domain": "https://www.vegalya.com/",
"PartialsDir": "~/Shared/Partials",
"LayoutDir": "~/Shared/Layout",
"ExceptionHandler": "/Error",
"MapFallbackPage": "/_Host",
"LocaleSwitchEnabled": true,
"ModeSwitchEnabled": true,
"LocaleDefault": "en-GB",
"SvgDir": "media/icons/",
"ModeDefault": "system",
"AssetsDir": "assets/",
"PagesDir": "~/Pages",
"IconType": "solid",
"Direction": "rtl",
"Preloader": true,
"Major": 1,
"Minor": 0,
"Build": 1,
"SocialMedia": {
"YouTube": {
"Url": "https://www.youtube.com/@iTaiizor",
"Alt": "YouTube Address",
"Icon": "youtube",
"Line": "<a href='https://www.youtube.com/@iTaiizor'><img src='youtube.svg' alt='YouTube Address' /></a>"
},
"GitHub": {
"Url": "https://github.com/Taiizor",
"Alt": "GitHub Address",
"Icon": "github",
"Line": "<a href='https://github.com/Taiizor'><img src='github.svg' alt='GitHub Address' /></a>"
}
},
"Compression": {
"StaticFile": {
"CacheControl": "public, max-age={0}",
"MaxAge": "1.00:00:00",
"Mode": "Compress",
"Change": true,
"Extensions": [
".jpeg",
".css",
".svg",
".png",
".jpg",
".js"
],
"Headers": {
"Vary": "Accept-Encoding"
}
},
"Response": {
"EnableHttps": true,
"MimeTypes": [
"*/*"
]
},
"Level": {
"Deflate": "Optimal",
"Brotli": "Optimal",
"Gzip": "Optimal"
}
},
"ThirdParty": {
"GoogleAnalytics": "NULL",
"GoogleAdsense": "NULL",
"YandexMetrika": "NULL"
},
"Languages": {
"DefaultFlag": "european-union",
"CookieName": "Factorial",
"UnknownName": "Unknown",
"UnknownLang": "xy-XY",
"CookieExpires": 30,
"ActiveLang": [
"en-GB"
],
"List": {
"English": {
"en-GB": "united-kingdom"
}
}
},
"Assets": {
"Favicon": "favicon.png",
"Manifest": "manifest.json",
"Version": true,
"Font": [
"https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700,800,900"
],
"Css": [
"css/bootstrap/bootstrap.min.css",
"css/site.css"
],
"Js": [
"js/jquery.min.js"
]
},
"Vendors": {
"special-library": {
"Font": [
"plugins/custom/special-library/special-library.ttf"
],
"Css": [
"plugins/custom/special-library/special-library.css"
],
"Js": [
"plugins/custom/special-library/special-library.js"
]
}
}
},
"Response": {
"EnableHttps": true,
"MimeTypes": [
"*/*"
]
},
"Level": {
"Deflate": "Optimal",
"Brotli": "Optimal",
"Gzip": "Optimal"
}
},
"ThirdParty": {
"GoogleAnalytics": "NULL",
"GoogleAdsense": "NULL",
"YandexMetrika": "NULL"
},
"Languages": {
"DefaultFlag": "european-union",
"CookieName": "Factorial",
"UnknownName": "Unknown",
"UnknownLang": "xy-XY",
"CookieExpires": 30,
"ActiveLang": [
"en-GB"
],
"List": {
"English": {
"en-GB": "united-kingdom"
}
}
},
"Assets": {
"Favicon": "favicon.png",
"Manifest": "manifest.json",
"Version": true,
"Font": [
"https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700,800,900"
],
"Css": [
"css/bootstrap/bootstrap.min.css",
"css/site.css"
],
"Js": [
"js/jquery.min.js"
]
},
"Vendors": {
"special-library": {
"Font": [
"plugins/custom/special-library/special-library.ttf"
],
"Css": [
"plugins/custom/special-library/special-library.css"
],
"Js": [
"plugins/custom/special-library/special-library.js"
]
}
}
}
}
15 changes: 12 additions & 3 deletions demo/Taiizor.Starterkit.Demo/Taiizor.Starterkit.Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ public static void Main(string[] args)
{
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

// Set settings to the configuration
//IConfiguration configuration = new ConfigurationBuilder()
// Set theme to the configuration
//IConfiguration themeConfiguration = new ConfigurationBuilder()
// .AddJsonFile("DemoSettings.json")
// .Build();

//ThemeSettings.Init(configuration, "Demo");
//ThemeSettings.Init(themeConfiguration, "Demo");

// Set icons to the configuration
//IConfiguration iconConfiguration = new ConfigurationBuilder()
// .AddJsonFile("DemoIcons.json")
// .Build();

//ThemeIcons.Init(iconConfiguration, "Demo");

ThemeSettings.Init("DemoSettings.json", "Demo");
ThemeIcons.Init("DemoIcons.json", "Demo");

// Add services to the container.
builder.Services.AddRazorPages();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Taiizor.Starterkit" Version="1.1.3" />
<PackageReference Include="Taiizor.Starterkit" Version="1.1.3.1" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion src/Taiizor.Starterkit/Extension/BootstrapBase.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Taiizor.Starterkit.Enum;
using Taiizor.Starterkit.Helper;
using Taiizor.Starterkit.Interface;

Expand Down Expand Up @@ -63,7 +64,7 @@ public void Init(ITheme theme)
// Init theme direction option (RTL or LTR) from settings
public void InitThemeDirection()
{
_theme.SetDirection(Converter.Convert(ThemeSettings.Config.Direction, Enum.DirectionEnum.LTR));
_theme.SetDirection(Converter.Convert(ThemeSettings.Config.Direction, DirectionEnum.LTR));
}
}
}
38 changes: 38 additions & 0 deletions src/Taiizor.Starterkit/Extension/Theme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,44 @@ public string GetSvgIcon(string path, string classNames)
return $"<span class=\"{classNames}\">{svg}</span>";
}

// Get icon content
public string GetIcon(string iconName, string iconClass = "", string iconType = "")
{
string tag = "i";
string output = "";
string iconsFinalClass = iconClass == "" ? "" : " " + iconClass;

if (string.IsNullOrEmpty(iconType) && !string.IsNullOrEmpty(ThemeSettings.Config.IconsType))
{
iconType = ThemeSettings.Config.IconsType;
}

if (string.IsNullOrEmpty(iconType))
{
iconType = "duotone";
}

if (iconType == "duotone")
{
int paths = ThemeIcons.Config.TryGetValue(iconName, out int number) ? number : 0;

output += $"<{tag} class='ki-{iconType} ki-{iconName}{iconsFinalClass}'>";

for (int i = 0; i < paths; i++)
{
output += $"<span class='path{i + 1}'></span>";
}

output += $"</{tag}>";
}
else
{
output = $"<{tag} class='ki-{iconType} ki-{iconName}{iconsFinalClass}'></{tag}>";
}

return output;
}

// Set preloader option from settings
public void SetPreloader(bool flag)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Taiizor.Starterkit/Extension/ThemeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class ThemeBase

public string LayoutDir { get; set; }

public string IconsType { get; set; }

public string PartialsDir { get; set; }

public string ModeDefault { get; set; }
Expand Down
23 changes: 23 additions & 0 deletions src/Taiizor.Starterkit/Extension/ThemeIcons.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.Extensions.Configuration;

namespace Taiizor.Starterkit.Extension
{
public class ThemeIcons
{
public static SortedDictionary<string, int> Config { get; set; } = [];

public static void Init(string Path, string Key)
{
IConfiguration Configuration = new ConfigurationBuilder()
.AddJsonFile(Path)
.Build();

Init(Configuration, Key);
}

public static void Init(IConfiguration Configuration, string Key)
{
Config = Configuration.GetSection(Key).Get<SortedDictionary<string, int>>() ?? Config;
}
}
}
4 changes: 2 additions & 2 deletions src/Taiizor.Starterkit/Extension/ThemeSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Taiizor.Starterkit.Extension
{
public class ThemeSettings
{
public static ThemeBase Config;
public static ThemeBase Config = new();

public static void Init(string Path, string Key)
{
Expand All @@ -17,7 +17,7 @@ public static void Init(string Path, string Key)

public static void Init(IConfiguration Configuration, string Key)
{
Config = Configuration.GetSection(Key).Get<ThemeBase>();
Config = Configuration.GetSection(Key).Get<ThemeBase>() ?? Config;
}
}
}
2 changes: 2 additions & 0 deletions src/Taiizor.Starterkit/Interface/ITheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public interface ITheme

string GetSvgIcon(string path, string classNames);

string GetIcon(string iconName, string iconClass = "", string iconType = "");

void SetDomain(string flag);

string GetDomain();
Expand Down
Loading

0 comments on commit 7352e82

Please sign in to comment.