Ver código fonte

支持markdown

懒得勤快 3 anos atrás
pai
commit
2ab7dc6007

+ 2 - 1
src/Masuit.MyBlogs.Core/Controllers/SubscribeController.cs

@@ -12,6 +12,7 @@ using Masuit.Tools.AspNetCore.Mime;
 using Masuit.Tools.Core.Net;
 using Masuit.Tools.Linq;
 using Masuit.Tools.Models;
+using Masuit.Tools.Systems;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Caching.Memory;
@@ -109,7 +110,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                         Body = ad.Description,
                         Title = ad.Title,
                         FullHtmlContent = ad.Description,
-                        Guid = ad.IndexId,
+                        Guid = SnowFlake.NewId,
                         PublishDate = DateTime.UtcNow,
                         Link = new Uri(Url.ActionLink("Redirect", "Advertisement", new { id = ad.Id })),
                         Permalink = Url.ActionLink("Redirect", "Advertisement", new { id = ad.Id })

+ 2 - 1
src/Masuit.MyBlogs.Core/Extensions/Firewall/FirewallAttribute.cs

@@ -1,5 +1,6 @@
 using CacheManager.Core;
 using FreeRedis;
+using Markdig;
 using Masuit.MyBlogs.Core.Common;
 using Masuit.MyBlogs.Core.Configs;
 using Masuit.MyBlogs.Core.Controllers;
@@ -71,7 +72,7 @@ public class FirewallAttribute : IAsyncActionFilter
             var msg = CommonHelper.SystemSettings.GetOrAdd("UserAgentBlockedMsg", "当前浏览器不支持访问本站");
             context.Result = new ContentResult()
             {
-                Content = Template.Create(msg).Set("browser", agent.Browser + " " + agent.BrowserVersion).Set("os", agent.Platform).Render(),
+                Content = Markdown.ToHtml(Template.Create(msg).Set("browser", agent.Browser + " " + agent.BrowserVersion).Set("os", agent.Platform).Render()),
                 ContentType = ContentType.Html + "; charset=utf-8",
                 StatusCode = 403
             };

+ 2 - 1
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj

@@ -53,7 +53,8 @@
         <PackageReference Include="htmldiff.net" Version="1.4.0" />
         <PackageReference Include="IP2Region" Version="1.2.0" />
         <PackageReference Include="Karambolo.AspNetCore.Bundling.NUglify" Version="3.5.1" />
-        <PackageReference Include="Masuit.Tools.Excel" Version="1.2.3-beta5" />
+        <PackageReference Include="Markdig" Version="0.30.4" />
+        <PackageReference Include="Masuit.Tools.Excel" Version="1.2.3.1" />
         <PackageReference Include="MaxMind.GeoIP2" Version="5.1.0" />
         <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.10" />
         <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.10" />

+ 4 - 2
src/Masuit.MyBlogs.Core/Views/Error/AccessDeny.cshtml

@@ -1,4 +1,6 @@
-@model string
+@using Markdig
+@using Microsoft.AspNetCore.Mvc.TagHelpers
+@model string
 
 @{
     Layout = null;
@@ -52,7 +54,7 @@
                     <span class="STYLE1">Sorry!访问被拒绝&nbsp;</span>
                 </em>
             </h3>
-            @Html.Raw(Model)
+            @Html.Raw(Markdown.ToHtml(Model))
             <form action="/" method="post" class="form-inline" id="code-token">
                 @Html.AntiForgeryToken()
                 <div class="input-group">

+ 3 - 1
src/Masuit.MyBlogs.Core/Views/Seminar/Index.cshtml

@@ -6,6 +6,8 @@
 @using Masuit.MyBlogs.Core.Models.Enum
 @using Masuit.Tools.Systems
 @using Masuit.MyBlogs.Core.Common
+@using Microsoft.AspNetCore.Mvc.TagHelpers
+@using Markdig
 @model Masuit.Tools.Models.PagedList<Masuit.MyBlogs.Core.Models.DTO.PostDto>
 @{
     Layout = "~/Views/Shared/_Layout.cshtml";
@@ -68,7 +70,7 @@
                 </h3>
             </div>
             <p>
-                @Html.Raw(ViewBag.Desc)
+                @Html.Raw(Markdown.ToHtml(ViewBag.Desc))
             </p>
         </div>
     </div>

+ 1 - 0
src/Masuit.MyBlogs.Core/wwwroot/ng-views/app/route.config.js

@@ -238,6 +238,7 @@ myApp.config([
                         return $ocLazyLoad.load([
                             {
                                 files: [
+                                    "/vs/editor/editor.main.css","/vs/loader.js","/vs/editor/editor.main.nls.js","/vs/editor/editor.main.js",
                                     "https://cdn.jsdelivr.net/gh/abodelot/jquery.json-viewer@master/json-viewer/jquery.json-viewer.css",
                                     "https://cdn.jsdelivr.net/gh/abodelot/jquery.json-viewer@master/json-viewer/jquery.json-viewer.js"
                                 ],

+ 18 - 0
src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/system.js

@@ -317,6 +317,24 @@ myApp.controller("firewall", ["$scope", "$http","NgTableParams","$timeout", func
 			settings[item.name] = item.value;
 		});
 		$scope.Settings = settings;
+		let userAgentBlockedMsgEditor = monaco.editor.create(document.getElementById('UserAgentBlockedMsg'), {
+            value: $scope.Settings.UserAgentBlockedMsg,
+            language: 'html'
+        });
+		userAgentBlockedMsgEditor.onDidChangeModelContent(function(e) {
+            $scope.$apply(function () {
+			   $scope.Settings.UserAgentBlockedMsg = userAgentBlockedMsgEditor.getValue();
+			});
+        });
+        let accessDenyTipsEditor = monaco.editor.create(document.getElementById('AccessDenyTips'), {
+            value: $scope.Settings.AccessDenyTips,
+            language: 'html'
+        });
+		accessDenyTipsEditor.onDidChangeModelContent(function(e) {
+            $scope.$apply(function () {
+			   $scope.Settings.AccessDenyTips = accessDenyTipsEditor.getValue();
+			});
+        });
 	});
 	this.load = function() {
 		$scope.get("/system/InterceptLog", function(res) {

+ 1 - 1
src/Masuit.MyBlogs.Core/wwwroot/ng-views/template/sidebar-left.html

@@ -45,7 +45,7 @@
                 <li><a data-ui-sref-active="active" data-ui-sref="post-pending" data-ng-click="mactrl.sidebarStat($event)">文章审核</a></li>
                 <li><a data-ui-sref-active="active" data-ui-sref="merge-list" data-ng-click="mactrl.sidebarStat($event)">文章合并</a></li>
                 <li><a data-ui-sref-active="active" data-ui-sref="post-cat" data-ng-click="mactrl.sidebarStat($event)">文章分类管理</a></li>
-                <li><a data-ui-sref-active="active" data-ui-sref="seminar" data-ng-click="mactrl.sidebarStat($event)"><i class="zmdi zmdi-format-underlined"></i>文章专题管理</a></li>
+                <li><a data-ui-sref-active="active" data-ui-sref="seminar" data-ng-click="mactrl.sidebarStat($event)">文章专题管理</a></li>
                 <li><a data-ui-sref-active="active" data-ui-sref="share" data-ng-click="mactrl.sidebarStat($event)">快速分享</a></li>
             </ul>
         </li>

+ 2 - 6
src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/system/firewall.html

@@ -96,9 +96,7 @@
                 <div class="col-md-12">
                     <div class="input-group">
                         <span class="input-group-addon">受限制提示语:</span>
-                        <div class="fg-line">
-                            <textarea class="form-control" ng-model="Settings.AccessDenyTips" placeholder="基于主观因素考虑,您所在的地区暂时不允许访问本站,如有疑问,请联系站长!或者请联系站长开通本站的访问权限!" rows="4"></textarea>
-                        </div>
+                        <div id="AccessDenyTips" style="height: 200px"></div>
                     </div>
                 </div>
                 <div class="col-md-12">
@@ -120,9 +118,7 @@
                 <div class="col-md-12">
                     <div class="input-group">
                         <span class="input-group-addon">UA限制提示语:</span>
-                        <div class="fg-line">
-                            <textarea class="form-control" ng-model="Settings.UserAgentBlockedMsg" placeholder="当前浏览器不支持访问本站" rows="4"></textarea>
-                        </div>
+                        <div id="UserAgentBlockedMsg" style="height: 200px"></div>
                     </div>
                 </div>
             </div>