Skip to content

Commit

Permalink
Add CustomCss tab at Skins Admin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Okeanij committed Jan 16, 2020
1 parent d7c4d38 commit d78bc34
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Client/src/admin/skins/CustomCssAdmin.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<template>
<div class="custom-css-admin q-gutter-y-md">
<q-input
filled
input-class="custom-css-admin__text-area"
type="textarea"
v-model="customCss"
/>
<div class="clear"></div>
<div class="flex">
<q-btn
no-caps
Expand All @@ -24,6 +17,13 @@
:label="$tl('refreshBtn')"
/>
</div>
<q-input
filled
:label="$tl('cssInput')"
input-class="custom-css-admin__text-area"
type="textarea"
v-model="customCss"
/>
</div>
</template>

Expand Down
1 change: 1 addition & 0 deletions Client/src/i18n/en-us/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ export default {
},
CustomCssAdmin: {
title: "Custom CSS",
cssInput: "Custom CSS",
saveBtn: "@:Global.btn.save",
refreshBtn: "Reload from server",
reloadSuccessNotify: "Css reloaded from server",
Expand Down
1 change: 1 addition & 0 deletions Client/src/i18n/ru/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ export default {
},
CustomCssAdmin: {
title: "Произвольный CSS",
cssInput: "Произвольный CSS",
saveBtn: "@:Global.btn.save",
refreshBtn: "Перегрузить с сервера",
reloadSuccessNotify: "Данные перезагружены с сервера",
Expand Down
2 changes: 1 addition & 1 deletion Client/src/statics/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ else if (config.Global.SiteUrl.startsWith("https://"))
config.Global.SiteSchema = "https://";
else throw "SiteUrl in config.js have to start with 'http://' or 'https://'.";

document.writeln(`<link href="${config.Global.CustomCssUrl}" rel="stylesheet" />`);
document.writeln(`<link href="${config.Global.CustomCssUrl}?customcssver=111111" rel="stylesheet" />`);

2 changes: 1 addition & 1 deletion Config.template/Init/Materials/index-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ <h1 class="index-page__header index-page__demo-header">Sun<wbr/>Engine
<span class="index-page__info-block-accent">Moderator</span>,
<span class="index-page__info-block-accent">Admin</span>.</p>
<p>Пароль: <span class="index-page__info-block-accent">password</span>.</p>
<p class="index-page__version">Версия: <span class="num">v2.1.3</span></p>
<p class="index-page__version">Версия: <span class="num">v2.2.0</span></p>
</div>
</div>
19 changes: 15 additions & 4 deletions Server/SunEngine.Admin/Services/ConfigurationAdminService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class ConfigurationAdminService
protected IConfigurationRoot configurationRoot { get; }
protected IOptionsMonitor<GlobalOptions> globalOptions { get; }

protected Random ran = new Random();

public ConfigurationAdminService(
IPathService pathService,
IConfigurationRoot configurationRoot)
Expand Down Expand Up @@ -89,18 +91,27 @@ public void UpdateClientScripts()
$"// auto-start\n{json}\n // auto-end", RegexOptions.Singleline);
File.WriteAllText(configJsPath, configJs);

UpdateScriptsVersion();
UpdateConfigVersion();
}

protected void UpdateScriptsVersion()
public void UpdateConfigVersion()
{
var ran = new Random();

var indexHtmlPath = pathService.Combine(PathNames.WwwRootDirName, "index.html");
string text = File.ReadAllText(indexHtmlPath);
Regex reg = new Regex("configver=\\d+\"");
text = reg.Replace(text, $"configver={ran.Next()}\"");
File.WriteAllText(indexHtmlPath, text);
}

public void UpdateCustomCssVersion()
{
UpdateConfigVersion();

var configJsPath = pathService.Combine(PathNames.WwwRootDirName,"statics" ,"config.js");
string text = File.ReadAllText(configJsPath);
Regex reg = new Regex("customcssver=\\d+\"");
text = reg.Replace(text, $"customcssver={ran.Next()}\"");
File.WriteAllText(configJsPath, text);
}
}
}
2 changes: 2 additions & 0 deletions Server/SunEngine.Admin/Services/SkinsAdminService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ public void UpdateCustomCss(string cssText)
File.Delete(customCssPath);

File.WriteAllText(customCssPath, cssText);

configurationAdminService.UpdateCustomCssVersion();
}

public List<SkinInfo> GetAllSkins(SkinType skinType)
Expand Down

0 comments on commit d78bc34

Please sign in to comment.