Parcourir la source

完善订阅功能和内容安全

懒得勤快 il y a 5 ans
Parent
commit
5d6c8e6927

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

@@ -150,8 +150,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             ViewBag.Total = posts.Count();
             var viewModel = GetIndexPageViewModel();
             viewModel.Posts = posts.OrderBy($"{nameof(PostDto.IsFixedTop)} desc,{(orderBy ?? OrderBy.ModifyDate).GetDisplay()} desc").Skip(size * (page - 1)).Take(size).Cacheable().ToList();
-            ViewBag.CategoryName = cat.Name;
-            ViewBag.Desc = cat.Description;
+            ViewBag.Category = cat;
             ViewData["page"] = new Pagination(page, size, orderBy);
             return View(viewModel);
         }

+ 18 - 2
src/Masuit.MyBlogs.Core/Controllers/PostController.cs

@@ -135,7 +135,8 @@ namespace Masuit.MyBlogs.Core.Controllers
         [Route("{id:int}/history/{v1:int}-{v2:int}"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "id", "v1", "v2" }, VaryByHeader = "Cookie")]
         public async Task<ActionResult> CompareVersion(int id, int v1, int v2)
         {
-            var main = PostService.Get(p => p.Id == id && (p.Status == Status.Pended || CurrentUser.IsAdmin)).Mapper<PostHistoryVersion>() ?? throw new NotFoundException("文章未找到");
+            var post = PostService.Get(p => p.Id == id && (p.Status == Status.Pended || CurrentUser.IsAdmin));
+            var main = post.Mapper<PostHistoryVersion>() ?? throw new NotFoundException("文章未找到");
             var left = v1 <= 0 ? main : await PostHistoryVersionService.GetAsync(v => v.Id == v1) ?? throw new NotFoundException("文章未找到");
             var right = v2 <= 0 ? main : await PostHistoryVersionService.GetAsync(v => v.Id == v2) ?? throw new NotFoundException("文章未找到");
             main.Id = id;
@@ -144,6 +145,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             right.Content = Regex.Replace(Regex.Replace(diffOutput, "<ins.+?</ins>", string.Empty), @"<\w+></\w+>", string.Empty);
             left.Content = Regex.Replace(Regex.Replace(diffOutput, "<del.+?</del>", string.Empty), @"<\w+></\w+>", string.Empty);
             ViewBag.Ads = AdsService.GetsByWeightedPrice(2, AdvertiseType.InPage, main.CategoryId);
+            ViewBag.DisableCopy = post.DisableCopy;
             return View(new[] { main, left, right });
         }
 
@@ -236,6 +238,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             p.IP = ClientIP;
             p.Modifier = p.Author;
             p.ModifierEmail = p.Email;
+            p.DisableCopy = true;
             p = PostService.AddEntitySaved(p);
             if (p == null)
             {
@@ -948,7 +951,20 @@ namespace Masuit.MyBlogs.Core.Controllers
         {
             var post = PostService.GetById(id) ?? throw new NotFoundException("文章未找到");
             post.DisableComment = !post.DisableComment;
-            return ResultData(null, SearchEngine.SaveChanges() > 0, post.DisableComment ? $"已禁用【{post.Title}】这篇文章的评论功能!" : $"已启用【{post.Title}】这篇文章的评论功能!");
+            return ResultData(null, PostService.SaveChanges() > 0, post.DisableComment ? $"已禁用【{post.Title}】这篇文章的评论功能!" : $"已启用【{post.Title}】这篇文章的评论功能!");
+        }
+
+        /// <summary>
+        /// 禁用或开启文章评论
+        /// </summary>
+        /// <param name="id">文章id</param>
+        /// <returns></returns>
+        [MyAuthorize]
+        public ActionResult DisableCopy(int id)
+        {
+            var post = PostService.GetById(id) ?? throw new NotFoundException("文章未找到");
+            post.DisableCopy = !post.DisableCopy;
+            return ResultData(null, PostService.SaveChanges() > 0, post.DisableCopy ? $"已开启【{post.Title}】这篇文章的防复制功能!" : $"已关闭【{post.Title}】这篇文章的防复制功能!");
         }
 
         /// <summary>

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

@@ -39,6 +39,8 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// </summary>
         public IPostService PostService { get; set; }
 
+        public ICategoryService CategoryService { get; set; }
+        public ICommentService CommentService { get; set; }
         public IWebHostEnvironment HostEnvironment { get; set; }
 
         /// <summary>
@@ -89,7 +91,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 Title = p.Title,
                 Permalink = scheme + "://" + host + "/" + p.Id,
                 Guid = p.Id.ToString(),
-                FullHtmlContent = p.Content
+                FullHtmlContent = p.Content.GetSummary(300, 50)
             }).Cacheable().ToList();
             var feed = new Feed()
             {
@@ -107,6 +109,143 @@ namespace Masuit.MyBlogs.Core.Controllers
             return Content(rss, "text/xml");
         }
 
+        /// <summary>
+        /// RSS分类订阅
+        /// </summary>
+        /// <returns></returns>
+        [Route("/rss/cat/{id}"), ResponseCache(Duration = 600)]
+        public IActionResult CategoryRss(int id)
+        {
+            var time = DateTime.Today.AddDays(-1);
+            string scheme = Request.Scheme;
+            var host = Request.Host;
+            var category = CategoryService.GetById(id) ?? throw new NotFoundException("分类未找到");
+            var posts = PostService.GetQueryNoTracking(p => p.CategoryId == id && p.Status == Status.Pended && p.ModifyDate >= time, p => p.ModifyDate, false).Select(p => new Item()
+            {
+                Author = new Author
+                {
+                    Name = p.Author,
+                    Email = p.Email
+                },
+                Body = p.Content.GetSummary(300, 50),
+                Categories = new List<string>
+                {
+                    p.Category.Name
+                },
+                Link = new Uri(scheme + "://" + host + "/" + p.Id),
+                PublishDate = p.ModifyDate,
+                Title = p.Title,
+                Permalink = scheme + "://" + host + "/" + p.Id,
+                Guid = p.Id.ToString(),
+                FullHtmlContent = p.Content.GetSummary(300, 50)
+            }).Cacheable().ToList();
+            var feed = new Feed()
+            {
+                Title = CommonHelper.SystemSettings["Domain"] + $":分类{category.Name}文章订阅",
+                Description = category.Description,
+                Link = new Uri(scheme + "://" + host + "/rss"),
+                Copyright = CommonHelper.SystemSettings["Title"],
+                Language = "zh-cn",
+                Items = posts.ToArray()
+            };
+            var rss = feed.Serialize(new SerializeOption()
+            {
+                Encoding = Encoding.UTF8
+            });
+            return Content(rss, "text/xml");
+        }
+
+        /// <summary>
+        /// RSS文章订阅
+        /// </summary>
+        /// <returns></returns>
+        [Route("/rss/{id}"), ResponseCache(Duration = 600)]
+        public IActionResult Rss(int id)
+        {
+            string scheme = Request.Scheme;
+            var host = Request.Host;
+            var p = PostService.Get(p => p.Status == Status.Pended && p.Id == id) ?? throw new NotFoundException("文章未找到");
+            var summary = p.Content.GetSummary(300, 50);
+            var item = new Item()
+            {
+                Author = new Author
+                {
+                    Name = p.Author,
+                    Email = p.Email
+                },
+                Body = summary,
+                Categories = new List<string>
+                {
+                    p.Category.Name
+                },
+                Link = new Uri(scheme + "://" + host + "/" + p.Id),
+                PublishDate = p.ModifyDate,
+                Title = p.Title,
+                Permalink = scheme + "://" + host + "/" + p.Id,
+                Guid = p.Id.ToString(),
+                FullHtmlContent = summary
+            };
+            var feed = new Feed()
+            {
+                Title = CommonHelper.SystemSettings["Domain"] + $":文章【{p.Title}】更新订阅",
+                Description = summary,
+                Link = new Uri(scheme + "://" + host + "/rss/" + id),
+                Copyright = CommonHelper.SystemSettings["Title"],
+                Language = "zh-cn",
+                Items = new List<Item>() { item }
+            };
+            var rss = feed.Serialize(new SerializeOption()
+            {
+                Encoding = Encoding.UTF8
+            });
+            return Content(rss, "text/xml");
+        }
+
+        /// <summary>
+        /// RSS文章评论订阅
+        /// </summary>
+        /// <returns></returns>
+        [Route("/rss/{id}/comments"), ResponseCache(Duration = 600)]
+        public IActionResult CommentsRss(int id)
+        {
+            string scheme = Request.Scheme;
+            var host = Request.Host;
+            var post = PostService.Get(p => p.Status == Status.Pended && p.Id == id) ?? throw new NotFoundException("文章不存在");
+            var start = DateTime.Today.AddDays(-7);
+            var comments = CommentService.GetQuery(c => c.PostId == post.Id && c.CommentDate > start).Select(c => new Item()
+            {
+                Author = new Author
+                {
+                    Name = c.NickName
+                },
+                Body = c.Content,
+                Categories = new List<string>
+                {
+                    c.Post.Title
+                },
+                Link = new Uri($"{scheme}://{host}/{post.Id}?cid={c.Id}#comment"),
+                PublishDate = c.CommentDate,
+                Title = c.NickName,
+                Permalink = $"{scheme}://{host}/{post.Id}?cid={c.Id}#comment",
+                Guid = c.Id.ToString(),
+                FullHtmlContent = c.Content
+            }).ToList();
+            var feed = new Feed()
+            {
+                Title = CommonHelper.SystemSettings["Domain"] + $":文章【{post.Title}】文章评论更新订阅",
+                Description = post.Content.GetSummary(300, 50),
+                Link = new Uri(scheme + "://" + host + "/rss/" + id + "/comments"),
+                Copyright = CommonHelper.SystemSettings["Title"],
+                Language = "zh-cn",
+                Items = comments.ToArray()
+            };
+            var rss = feed.Serialize(new SerializeOption()
+            {
+                Encoding = Encoding.UTF8
+            });
+            return Content(rss, "text/xml");
+        }
+
         /// <summary>
         /// 邮箱订阅
         /// </summary>

+ 10 - 0
src/Masuit.MyBlogs.Core/Models/DTO/PostCommand.cs

@@ -66,5 +66,15 @@ namespace Masuit.MyBlogs.Core.Models.DTO
         /// רÌâ
         /// </summary>
         public string Seminars { get; set; }
+
+        /// <summary>
+        /// ½ûÖ¹ÆÀÂÛ
+        /// </summary>
+        public bool DisableComment { get; set; }
+
+        /// <summary>
+        /// ½ûÖ¹×ªÔØ
+        /// </summary>
+        public bool DisableCopy { get; set; }
     }
 }

+ 5 - 0
src/Masuit.MyBlogs.Core/Models/Entity/Post.cs

@@ -132,6 +132,11 @@ namespace Masuit.MyBlogs.Core.Models.Entity
         /// </summary>
         public bool DisableComment { get; set; }
 
+        /// <summary>
+        /// ½ûÖ¹×ªÔØ
+        /// </summary>
+        public bool DisableCopy { get; set; }
+
         /// <summary>
         /// ·ÖÀà
         /// </summary>

+ 5 - 0
src/Masuit.MyBlogs.Core/Models/ViewModel/PostDataModel.cs

@@ -64,5 +64,10 @@
         /// </summary>
         public bool DisableComment { get; set; }
 
+        /// <summary>
+        /// 禁止转载
+        /// </summary>
+        public bool DisableCopy { get; set; }
+
     }
 }

+ 9 - 4
src/Masuit.MyBlogs.Core/Views/Home/Category.cshtml

@@ -1,9 +1,11 @@
 @using Masuit.MyBlogs.Core.Models.DTO
+@using Masuit.MyBlogs.Core.Models.Entity
 @using Masuit.MyBlogs.Core.Models.ViewModel
 @using Masuit.Tools.Core.Net
 @model Masuit.MyBlogs.Core.Models.ViewModel.HomePageViewModel
 @{
-    ViewBag.Title = "分类_" + ViewBag.CategoryName;
+    Category cat = ViewBag.Category;
+    ViewBag.Title = "分类_" + cat.Name;
     Layout = "~/Views/Shared/_Layout.cshtml";
     Random r = new Random();
 }
@@ -39,15 +41,18 @@
 <div class="bg-title">
     <div class="header-content text-center">
         <h1 class="size48">
-            @ViewBag.CategoryName
+            @cat.Name
+            <a class="btn btn-lg btn-danger" asp-controller="Subscribe" asp-action="CategoryRss" asp-route-id="@cat.Id" target="_blank">
+                <i class="icon-rss4"></i>
+            </a>
         </h1>
         <div class="divider"></div>
         <p class="size24">
-            @ViewBag.Desc
+            @cat.Description
         </p>
     </div>
 </div>
 @{
-    UserInfoDto user = Context.Session.Get<UserInfoDto>(SessionKey.UserInfo) ?? new UserInfoDto();
+    var user = Context.Session.Get<UserInfoDto>(SessionKey.UserInfo) ?? new UserInfoDto();
     await Html.RenderPartialAsync(user.IsAdmin ? "_MainContainer_Admin" : "_MainContainer", Model);
 }

+ 9 - 0
src/Masuit.MyBlogs.Core/Views/Post/CompareVersion.cshtml

@@ -205,6 +205,9 @@
     </div>
     <div id="cyReward" role="cylabs" data-use="reward"></div>
 </div>
+<noscript>
+    <iframe src="*.htm"></iframe>
+</noscript>
 <script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/shCore.min.js"></script>
 <script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/bundle.min.js"></script>
 <script>
@@ -212,4 +215,10 @@
         SyntaxHighlighter.all();
         SyntaxHighlighter.defaults['toolbar'] = false;
     })
+    @if(ViewBag.DisableCopy) {
+        <text>
+    debugger;
+    GlobalCopyrightProtect();
+        </text>
+    }
 </script>

+ 43 - 26
src/Masuit.MyBlogs.Core/Views/Post/Details.cshtml

@@ -176,7 +176,10 @@
                     </div>
                     <div class="col-xs-6 text-right">
                         <div class="btn-group">
-                            <button type="button" id="donate" class="btn btn-@colors[new Random().Next() % colors.Length] btn-lg">
+                            <a class="btn btn-danger btn-lg" asp-controller="Subscribe" asp-action="Rss" asp-route-id="@Model.Id" target="_blank">
+                                <i class="icon-rss4"></i><span>订阅本文更新</span>
+                            </a>
+                            <button type="button" id="donate" class="btn btn-info btn-lg">
                                 <i class="icon-coin-yen"></i><span>支持站长</span>
                             </button>
                         </div>
@@ -290,10 +293,15 @@
                                 </div>
                                 <input type="checkbox" name="Agree" id="aggrement" value="true" /><label for="aggrement">我已接受<a asp-controller="Misc" asp-action="agreement" target="_blank">《评论须知》</a></label>
                                 <div class="form-group">
-                                    <div class="col-xs-12">
+                                    <div class="col-xs-6">
                                         <button type="submit" class="btn btn-info btn-lg">提交</button>
                                         <a class="text-red">评论框可粘贴网络图片</a>
                                     </div>
+                                    <div class="col-xs-6 text-right">
+                                        <a class="btn btn-danger btn-lg" asp-controller="Subscribe" asp-action="CommentsRss" asp-route-id="@Model.Id" target="_blank">
+                                            <i class="icon-rss4"></i><span>订阅本文评论更新</span>
+                                        </a>
+                                    </div>
                                 </div>
                             </form>
                         }
@@ -361,55 +369,64 @@
         </form>
     </div>
 </div>
+<noscript>
+    <iframe src="*.htm"></iframe>
+</noscript>
 <script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/shCore.min.js"></script>
 <script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/bundle.min.js"></script>
 <script src="~/Assets/jquery.tocify/jquery.tocify.js"></script>
 <script src="~/Scripts/global/article.min.js"></script>
 <script>
-	window.onload = function() {
+    window.onload = function() {
         var keywords = @Html.Raw(ViewData["keywords"] ?? "[]");
         for (var i = 0; i < keywords.length; i++) {
             $("#article").highlight(keywords[i]);
         }
         loading();
-		$('#pageToolbar').Paging({ //异步加载评论
-			pagesize: 10,
-			count: @Model.Comment.Count(c =>c.ParentId==0&& c.Status==Status.Pended),
-			toolbar: true,
-			callback: function(page, size, count) {
-				window.post("/comment/getcomments", {
-					id: @Model.Id,
-					page: page,
-					size: size
+        $('#pageToolbar').Paging({ //异步加载评论
+            pagesize: 10,
+            count: @Model.Comment.Count(c =>c.ParentId==0&& c.Status==Status.Pended),
+            toolbar: true,
+            callback: function(page, size, count) {
+                window.post("/comment/getcomments", {
+                    id: @Model.Id,
+                    page: page,
+                    size: size
                 }, (data) => {
                     data = data.Data;
                     if (data) {
                         document.querySelector(".media-list").innerHTML = loadParentComments(data);
                         bindReplyBtn();
                         commentVoteBind(); //评论投票
-					}
-				});
-			}
-		});
+                    }
+                });
+            }
+        });
         loadingDone();
     };
 
-	/**
+    /**
    * 获取评论
    */
-	function getcomments() {
-		window.post("/comment/getcomments", {
-			id: $("#postId").val(),
-			page: 1,
+    function getcomments() {
+        window.post("/comment/getcomments", {
+            id: $("#postId").val(),
+            page: 1,
             size: 10,
             cid:@cid
-		}, (data) => {
+        }, (data) => {
             data = data.Data;
-			if (data) {
+            if (data) {
                 document.querySelector(".media-list").innerHTML = loadParentComments(data);
                 bindReplyBtn();
                 commentVoteBind(); //评论投票
-			}
-		});
-	}
+            }
+        });
+    }
+    @if(Model.DisableCopy) {
+        <text>
+    debugger;
+    GlobalCopyrightProtect();
+        </text>
+    }
 </script>

+ 9 - 0
src/Masuit.MyBlogs.Core/Views/Post/HistoryVersion.cshtml

@@ -179,6 +179,9 @@
         </div>
     </div>
 </div>
+<noscript>
+    <iframe src="*.htm"></iframe>
+</noscript>
 <script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/shCore.min.js"></script>
 <script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/bundle.min.js"></script>
 <script src="~/Assets/jquery.tocify/jquery.tocify.js"></script>
@@ -223,4 +226,10 @@
             });
         });
     })
+    @if(Model.Post.DisableCopy) {
+        <text>
+    debugger;
+    GlobalCopyrightProtect();
+        </text>
+    }
 </script>

+ 7 - 0
src/Masuit.MyBlogs.Core/Views/Post/PushMerge.cshtml

@@ -192,4 +192,11 @@
             });
         });
     });
+
+    @if(Model.DisableCopy) {
+        <text>
+    debugger;
+    CopyrightProtect4Editor();
+        </text>
+    }
 </script>

+ 6 - 0
src/Masuit.MyBlogs.Core/Views/Post/RepushMerge.cshtml

@@ -193,4 +193,10 @@
             });
         });
     });
+    @if(Model.Post.DisableCopy) {
+        <text>
+    debugger;
+    CopyrightProtect4Editor();
+        </text>
+    }
 </script>

+ 10 - 5
src/Masuit.MyBlogs.Core/Views/Shared/_Aside.cshtml

@@ -32,7 +32,8 @@
         <section class="wow animated fadeIn">
             <article class="panel panel-default">
                 <div class="panel-heading">
-                    <i class="icon-clipboard2"></i><span>近期公告</span> @Html.ActionLink("所有公告", "Index", "Notice", null, new { @class = "pull-right text-success" })
+                    <i class="icon-clipboard2"></i><span>近期公告</span>
+                    <a class="pull-right text-success" asp-controller="Notice" asp-action="Index">所有公告</a>
                 </div>
                 <div class="panel-body">
                     <div class="row">
@@ -41,7 +42,7 @@
                                 @foreach (NoticeDto notice in Model.Notices)
                                 {
                                     <li class="news-item">
-                                        @Html.ActionLink(notice.Content.GetSummary(45, 2), "Details", "Notice", new { id = notice.Id }, new { @class = "tippy-scale", title = "查看详情" })
+                                        <a class="tippy-scale" title="查看详情" asp-controller="Notice" asp-action="Details" asp-route-id="@notice.Id">@notice.Content.GetSummary(45, 2)</a>
                                     </li>
                                 }
                             </ul>
@@ -54,16 +55,20 @@
     <section class="wow animated fadeIn">
         <article class="panel panel-warning">
             <div class="panel-heading">
-                <i class="icon-lab2"></i>文章分类 @Html.ActionLink("所有分类", "All", "Post", null, new { @class = "pull-right text-success" })
+                <i class="icon-lab2"></i>文章分类
+                <a asp-controller="Post" asp-action="All" class="pull-right text-success">所有分类</a>
             </div>
             <div class="panel-body">
-                <ul class="list-group text-center">
+                <ul class="list-group">
                     @foreach (CategoryDto cat in Model.Categories)
                     {
                         if (cat.PendedPostCount > 0)
                         {
                             <li class="list-group-item">
-                                @Html.ActionLink(cat.Name + "(共" + cat.PendedPostCount + "篇)", "Category", "Home", new { id = cat.Id }, null)
+                                <a asp-controller="Home" asp-action="Category" asp-route-id="@cat.Id">@cat.Name 共(@cat.PendedPostCount 篇)</a>
+                                <a class="pull-right" asp-controller="Subscribe" asp-action="CategoryRss" asp-route-id="@cat.Id" target="_blank">
+                                    <i class="icon-rss4"></i>
+                                </a>
                             </li>
                         }
                     }

+ 130 - 0
src/Masuit.MyBlogs.Core/wwwroot/Scripts/global/scripts.js

@@ -338,6 +338,136 @@ function post(url, params, callback, error) {
     });
 }
 
+/**禁止全局复制 */
+function GlobalCopyrightProtect() {
+    setInterval(function() {
+        document.onkeydown = function(e){
+            var currKey=0,evt=e||window.event;
+            currKey=evt.keyCode||evt.which||evt.charCode;
+            if (currKey == 123) {
+                window.event.cancelBubble = true;
+                window.event.returnValue = false;
+            }
+            if( event.ctrlKey&&currKey==67 ){
+                event.returnValue = false;
+                return false;
+            }
+            if( event.ctrlKey&&currKey==85 ){
+                event.returnValue = false;
+                return false;
+            }
+            if( event.ctrlKey ){
+                event.returnValue = false;
+                return false;
+            }
+            if( event.ctrlKey&&event.shiftKey){
+                event.returnValue = false;
+                return false;
+            }
+            if ( event.altKey ){
+                event.returnValue = false;
+                return false;
+            }
+        }
+        document.ondragstart = function(){
+            event.returnValue = false;
+            return false;
+        }
+        document.oncopy = function(){
+            event.returnValue = false;
+            return false;
+        }
+        document.oncontextmenu = function(){
+            event.returnValue = false;
+            return false;
+        }
+    },100);
+}
+
+/**禁止复制 */
+function CopyrightProtect() {
+    setInterval(function() {
+        document.onkeydown = function(e){
+            var currKey=0,evt=e||window.event;
+            currKey=evt.keyCode||evt.which||evt.charCode;
+            if (currKey == 123) {
+                window.event.cancelBubble = true;
+                window.event.returnValue = false;
+            }
+            if( event.ctrlKey&&currKey==67 ){//C
+                event.returnValue = false;
+                return false;
+            }
+            if( event.ctrlKey&&currKey==85 ){//U
+                event.returnValue = false;
+                return false;
+            }
+            if( event.ctrlKey&&event.shiftKey){
+                event.returnValue = false;
+                return false;
+            }
+            if ( event.altKey ){
+                event.returnValue = false;
+                return false;
+            }
+        }
+        document.ondragstart = function(){
+            event.returnValue = false;
+            return false;
+        }
+        document.oncopy = function(){
+            event.returnValue = false;
+            return false;
+        }
+        document.oncontextmenu = function(){
+            event.returnValue = false;
+            return false;
+        }
+    },100);
+}
+
+/**禁止编辑器内复制 */
+function CopyrightProtect4Editor() {
+    setInterval(function() {
+        document.getElementById("ueditor_0").contentWindow.document.body.onkeydown = function(e){
+            var currKey=0,evt=e||window.event;
+            currKey=evt.keyCode||evt.which||evt.charCode;
+            if (currKey == 123) {
+                window.event.cancelBubble = true;
+                window.event.returnValue = false;
+            }
+            if( event.ctrlKey&&currKey==67 ){ //C
+                event.returnValue = false;
+                return false;
+            }
+            if( event.ctrlKey&&currKey==85 ){ //U
+                event.returnValue = false;
+                return false;
+            }
+            if( event.ctrlKey&&currKey==88 ){ //X
+                event.returnValue = false;
+                return false;
+            }
+            if( event.ctrlKey&&event.shiftKey){
+                event.returnValue = false;
+                return false;
+            }
+            if ( event.altKey ){
+                event.returnValue = false;
+                return false;
+            }
+        }
+        document.getElementById("ueditor_0").contentWindow.document.body.ondragstart = function(){
+            event.returnValue = false;
+            return false;
+        }
+        document.getElementById("ueditor_0").contentWindow.document.body.oncopy = function(){
+            event.returnValue = false;
+            return false;
+        }
+    },100);
+}
+
 /**
  * 鼠标桃心
  */

+ 11 - 0
src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/post.js

@@ -202,6 +202,17 @@
 			});
 		});
     }
+    $scope.toggleDisableCopy= function(row) {
+        $scope.request("/post/DisableCopy", {
+			id: row.Id
+		}, function(data) {
+			window.notie.alert({
+				type: 1,
+				text: data.Message,
+				time: 4
+			});
+		});
+    }
 }]);
 myApp.controller("writeblog", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
 	window.hub.stop();

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/post.min.js


+ 40 - 28
src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/post/edit.html

@@ -17,7 +17,7 @@
         <div style="height: 200px;" class="ueditor" ng-model="post.ProtectContent" type="text/plain"></div>
     </div>
     <div class="row">
-        <div class="col-md-4 col-sm-5">
+        <div class="col-md-3 col-sm-6">
             <div class="input-group">
                 <span class="input-group-addon">分类:</span>
                 <div class="ui fluid search selection dropdown category">
@@ -30,11 +30,9 @@
                 </div>
             </div>
         </div>
-        <div class="col-md-8 col-sm-6">
+        <div class="col-md-4 col-sm-6">
             <div class="input-group">
-                <span class="input-group-addon">
-                    <label for="Label">标签:</label>
-                </span>
+                <span class="input-group-addon"><label for="Label">标签:</label></span>
                 <div class="ui fluid multiple search selection dropdown tags">
                     <input name="Label" type="hidden" id="Label">
                     <i class="dropdown icon"></i>
@@ -45,9 +43,20 @@
                 </div>
             </div>
         </div>
+        <div class="col-md-5 col-sm-6">
+            <div class="input-group">
+                <span class="input-group-addon"><label for="keyword">文章关键词:</label></span>
+                <div class="ui fluid multiple search selection dropdown keyword">
+                    <input name="keyword" type="hidden" id="keyword">
+                    <i class="dropdown icon"></i>
+                    <div class="default text">文章关键词</div>
+                    <div class="menu"></div>
+                </div>
+            </div>
+        </div>
     </div>
     <div class="row">
-        <div class="col-md-4 col-sm-3">
+        <div class="col-md-5 col-sm-6">
             <div class="input-group">
                 <span class="input-group-addon">
                     <label>选择专题:</label>
@@ -62,28 +71,14 @@
                 </div>
             </div>
         </div>
-        <div class="col-md-5 col-sm-3">
-            <div class="input-group">
-                <span class="input-group-addon"><label for="keyword">文章关键词:</label></span>
-                <div class="ui fluid multiple search selection dropdown keyword">
-                    <input name="keyword" type="hidden" id="keyword">
-                    <i class="dropdown icon"></i>
-                    <div class="default text">文章关键词</div>
-                    <div class="menu"></div>
-                </div>
-            </div>
-        </div>
-        <div class="col-md-3 col-sm-2">
+        <div class="col-md-7 col-sm-6">
             <div class="pull-right">
                 <span class="checkboxWrapper theme4 smallCheckboxSize" ng-click="notify=!notify">
                     <input type="checkbox" id="notify" ng-model="notify">
                     <label for="notify">
                         <i>
-                            <svg version="1.1" id="Layer_notify" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="50px" height="50px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
-                            <circle fill="none" stroke="#B7B7B7" stroke-width="3" stroke-miterlimit="10" cx="25.11" cy="24.883" r="23.519" />
-                            <path fill="none" stroke-width="3" stroke-miterlimit="10" d="M48.659,25c0,12.998-10.537,23.534-23.534,23.534
-							S1.591,37.998,1.591,25S12.127,1.466,25.125,1.466c9.291,0,17.325,5.384,21.151,13.203L19,36l-9-14" />
-                        </svg>
+                            <svg version="1.1" id="Layer_notify" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="50px" height="50px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve"><circle fill="none" stroke="#B7B7B7" stroke-width="3" stroke-miterlimit="10" cx="25.11" cy="24.883" r="23.519" /><path fill="none" stroke-width="3" stroke-miterlimit="10" d="M48.659,25c0,12.998-10.537,23.534-23.534,23.534
+							S1.591,37.998,1.591,25S12.127,1.466,25.125,1.466c9.291,0,17.325,5.384,21.151,13.203L19,36l-9-14" /></svg>
                         </i>
                         是否广播
                     </label>
@@ -92,15 +87,32 @@
                     <input type="checkbox" id="reserve" ng-model="reserve">
                     <label for="reserve">
                         <i>
-                            <svg version="1.1" id="Layer_reserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="50px" height="50px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
-                            <circle fill="none" stroke="#B7B7B7" stroke-width="3" stroke-miterlimit="10" cx="25.11" cy="24.883" r="23.519" />
-                            <path fill="none" stroke-width="3" stroke-miterlimit="10" d="M48.659,25c0,12.998-10.537,23.534-23.534,23.534
-							S1.591,37.998,1.591,25S12.127,1.466,25.125,1.466c9.291,0,17.325,5.384,21.151,13.203L19,36l-9-14" />
-                        </svg>
+                            <svg version="1.1" id="Layer_reserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="50px" height="50px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve"><circle fill="none" stroke="#B7B7B7" stroke-width="3" stroke-miterlimit="10" cx="25.11" cy="24.883" r="23.519" /><path fill="none" stroke-width="3" stroke-miterlimit="10" d="M48.659,25c0,12.998-10.537,23.534-23.534,23.534
+							S1.591,37.998,1.591,25S12.127,1.466,25.125,1.466c9.291,0,17.325,5.384,21.151,13.203L19,36l-9-14" /></svg>
                         </i>
                         保留历史版本
                     </label>
                 </span>
+                <span class="checkboxWrapper theme4 smallCheckboxSize">
+                    <input type="checkbox" id="DisableCpoy" ng-model="post.DisableCpoy">
+                    <label for="DisableCpoy">
+                        <i>
+                            <svg version="1.1" id="DisableCpoy-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="50px" height="50px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
+                            <circle fill="none" stroke="#B7B7B7" stroke-width="3" stroke-miterlimit="10" cx="25.11" cy="24.883" r="23.519" /><path fill="none" stroke-width="3" stroke-miterlimit="10" d="M48.659,25c0,12.998-10.537,23.534-23.534,23.534 S1.591,37.998,1.591,25S12.127,1.466,25.125,1.466c9.291,0,17.325,5.384,21.151,13.203L19,36l-9-14" />
+                            </svg>
+                        </i>
+                        禁止转载
+                    </label>
+                </span>
+                    <span class="checkboxWrapper theme4 smallCheckboxSize">
+                        <input type="checkbox" id="DisableComment" ng-model="post.DisableComment">
+                        <label for="DisableComment">
+                            <i>
+                                <svg version="1.1" id="DisableComment-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="50px" height="50px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve"><circle fill="none" stroke="#B7B7B7" stroke-width="3" stroke-miterlimit="10" cx="25.11" cy="24.883" r="23.519" /><path fill="none" stroke-width="3" stroke-miterlimit="10" d="M48.659,25c0,12.998-10.537,23.534-23.534,23.534 S1.591,37.998,1.591,25S12.127,1.466,25.125,1.466c9.291,0,17.325,5.384,21.151,13.203L19,36l-9-14" /></svg>
+                            </i>
+                            禁止评论
+                        </label>
+                    </span>
                 <button type="button" class="btn btn-info waves-effect" ng-click="submit(post)">确认修改</button>
             </div>
         </div>

+ 6 - 0
src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/post/postlist.html

@@ -78,6 +78,12 @@
                     <span class="el-switch-style" ng-click="toggleDisableComment(row)"></span>
                 </label>
             </td>
+            <td title="'禁止转载'">
+                <label class="el-switch">
+                    <input type="checkbox" name="switch" ng-checked="row.DisableCopy">
+                    <span class="el-switch-style" ng-click="toggleDisableCopy(row)"></span>
+                </label>
+            </td>
             <td title="'操作'" style="width: 185px;">
                 <div class="btn-group">
                     <button class="btn btn-default btn-sm waves-effect" ng-click="list.pass(row)" ng-if="row.Status=='审核中'">

+ 46 - 22
src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/post/writeblog.html

@@ -35,7 +35,7 @@
         <div style="height: 200px;" class="ueditor" ng-model="post.ProtectContent" type="text/plain"></div>
     </div>
     <div class="row">
-        <div class="col-md-4 col-sm-5">
+        <div class="col-md-3 col-sm-6">
             <div class="input-group">
                 <span class="input-group-addon">分类:</span>
                 <div class="ui fluid search selection dropdown category">
@@ -48,7 +48,7 @@
                 </div>
             </div>
         </div>
-        <div class="col-md-8 col-sm-6">
+        <div class="col-md-4 col-sm-6">
             <div class="input-group">
                 <span class="input-group-addon"><label for="Label">标签:</label></span>
                 <div class="ui fluid multiple search selection dropdown tags">
@@ -61,9 +61,20 @@
                 </div>
             </div>
         </div>
+        <div class="col-md-5 col-sm-6">
+            <div class="input-group">
+                <span class="input-group-addon"><label for="keyword">文章关键词:</label></span>
+                <div class="ui fluid multiple search selection dropdown keyword">
+                    <input name="keyword" type="hidden" id="keyword">
+                    <i class="dropdown icon"></i>
+                    <div class="default text">文章关键词</div>
+                    <div class="menu"></div>
+                </div>
+            </div>
+        </div>
     </div>
     <div class="row">
-        <div class="col-md-5 col-sm-3">
+        <div class="col-md-5 col-sm-6">
             <div class="input-group">
                 <span class="input-group-addon"><label for="seminar">专题:</label></span>
                 <div class="ui fluid multiple search selection dropdown seminar">
@@ -76,39 +87,52 @@
                 </div>
             </div>
         </div>
-        <div class="col-md-5 col-sm-3">
-            <div class="input-group">
-                <span class="input-group-addon"><label for="keyword">文章关键词:</label></span>
-                <div class="ui fluid multiple search selection dropdown keyword">
-                    <input name="keyword" type="hidden" id="keyword">
-                    <i class="dropdown icon"></i>
-                    <div class="default text">文章关键词</div>
-                    <div class="menu"></div>
-                </div>
-            </div>
-        </div>
-        <div class="col-md-2">
+        <div class="col-md-3">
             <div class="input-group" ng-if="post.schedule">
                 <span class="input-group-addon"><label for="Label">选择时间:</label></span>
                 <input type="text" class="workinput wicon" id="timespan" ng-model="post.timespan" readonly="readonly" />
             </div>
         </div>
-        <div class="col-md-2">
-            <div class="pull-right">
-                <button type="button" class="btn btn-info" ng-click="submit(post)">发布</button>
-            </div>
-            <span class="checkboxWrapper theme4 smallCheckboxSize pull-right" ng-click="Scheduled()">
+        <div class="col-md-4 text-right">
+            <span class="checkboxWrapper theme4 smallCheckboxSize">
+                <input type="checkbox" id="DisableCpoy" ng-model="post.DisableCpoy">
+                <label for="DisableCpoy">
+                    <i>
+                        <svg version="1.1" id="DisableCpoy-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="50px" height="50px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
+                        <circle fill="none" stroke="#B7B7B7" stroke-width="3" stroke-miterlimit="10" cx="25.11" cy="24.883" r="23.519" />
+                        <path fill="none" stroke-width="3" stroke-miterlimit="10" d="M48.659,25c0,12.998-10.537,23.534-23.534,23.534 S1.591,37.998,1.591,25S12.127,1.466,25.125,1.466c9.291,0,17.325,5.384,21.151,13.203L19,36l-9-14" />
+                        </svg>
+                    </i>
+                    禁止转载
+                </label>
+            </span>
+            <span class="checkboxWrapper theme4 smallCheckboxSize">
+                <input type="checkbox" id="DisableComment" ng-model="post.DisableComment">
+                <label for="DisableComment">
+                    <i>
+                        <svg version="1.1" id="DisableComment-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="50px" height="50px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
+                        <circle fill="none" stroke="#B7B7B7" stroke-width="3" stroke-miterlimit="10" cx="25.11" cy="24.883" r="23.519" />
+                        <path fill="none" stroke-width="3" stroke-miterlimit="10" d="M48.659,25c0,12.998-10.537,23.534-23.534,23.534 S1.591,37.998,1.591,25S12.127,1.466,25.125,1.466c9.291,0,17.325,5.384,21.151,13.203L19,36l-9-14" />
+                        </svg>
+                    </i>
+                    禁止评论
+                </label>
+            </span>
+            <span class="checkboxWrapper theme4 smallCheckboxSize" ng-click="Scheduled()">
                 <input type="checkbox" id="sample9" ng-model="post.schedule">
                 <label for="sample9">
                     <i>
                         <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="50px" height="50px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve">
                         <circle fill="none" stroke="#B7B7B7" stroke-width="3" stroke-miterlimit="10" cx="25.11" cy="24.883" r="23.519" />
-                            <path fill="none" stroke-width="3" stroke-miterlimit="10" d="M48.659,25c0,12.998-10.537,23.534-23.534,23.534 S1.591,37.998,1.591,25S12.127,1.466,25.125,1.466c9.291,0,17.325,5.384,21.151,13.203L19,36l-9-14" />
+                        <path fill="none" stroke-width="3" stroke-miterlimit="10" d="M48.659,25c0,12.998-10.537,23.534-23.534,23.534 S1.591,37.998,1.591,25S12.127,1.466,25.125,1.466c9.291,0,17.325,5.384,21.151,13.203L19,36l-9-14" />
                         </svg>
                     </i>
-                    定时发表
+                    定时发表&nbsp;&nbsp;&nbsp;
                 </label>
             </span>
+            <div class="pull-right">
+                <button type="button" class="btn btn-info" ng-click="submit(post)">发布</button>
+            </div>
         </div>
     </div>
 </form>

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff