diff --git a/pom.xml b/pom.xml index e1a46beee..537f22a24 100755 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ com.alibaba - druid + druid-spring-boot-starter ${druid.version} diff --git a/src/main/java/cc/ryanc/halo/config/MvcConfiguration.java b/src/main/java/cc/ryanc/halo/config/MvcConfiguration.java index b46f715fa..500b3e6ed 100644 --- a/src/main/java/cc/ryanc/halo/config/MvcConfiguration.java +++ b/src/main/java/cc/ryanc/halo/config/MvcConfiguration.java @@ -7,7 +7,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import org.springframework.web.servlet.config.annotation.*; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; /** * @author : RYAN0UP diff --git a/src/main/java/cc/ryanc/halo/util/HaloUtil.java b/src/main/java/cc/ryanc/halo/util/HaloUtil.java index 018046750..6bb4f91f9 100755 --- a/src/main/java/cc/ryanc/halo/util/HaloUtil.java +++ b/src/main/java/cc/ryanc/halo/util/HaloUtil.java @@ -3,6 +3,8 @@ package cc.ryanc.halo.util; import cc.ryanc.halo.model.domain.Post; import cc.ryanc.halo.model.dto.HaloConst; import cc.ryanc.halo.model.dto.Theme; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import com.sun.syndication.feed.rss.Channel; import com.sun.syndication.feed.rss.Content; import com.sun.syndication.feed.rss.Item; @@ -21,6 +23,9 @@ import javax.servlet.http.HttpServletRequest; import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; +import java.net.URI; +import java.net.URL; +import java.net.URLConnection; import java.security.MessageDigest; import java.text.SimpleDateFormat; import java.util.*; @@ -370,9 +375,6 @@ public class HaloUtil { return md5; } - public static void main(String[] args){ - System.out.println(getMD5("123456")); - } /** * 2进制转16进制 @@ -584,4 +586,41 @@ public class HaloUtil { // System.out.println(StringUtils.substringBetween("title","\n","\n")); // } // } + + /** + * 访问路径获取json数据 + * @param url + * @return + */ + public static String getHttpResponse(String enterUrl) { + BufferedReader in = null; + StringBuffer result = null; + try { + URI uri = new URI(enterUrl); + URL url = uri.toURL(); + URLConnection connection = url.openConnection(); + connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + connection.setRequestProperty("Charset", "utf-8"); + connection.connect(); + result = new StringBuffer(); + in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result.append(line); + } + return result.toString(); + + } catch (Exception e) { + e.printStackTrace(); + }finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return null; + } } diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/PostController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/PostController.java index b3d592df0..f18599ffe 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/PostController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/PostController.java @@ -129,7 +129,9 @@ public class PostController extends BaseController{ public String newPost(Model model){ try { List categories = categoryService.findAllCategories(); + List tags = tagService.findAllTags(); model.addAttribute("categories",categories); + model.addAttribute("tags",tags); model.addAttribute("btnPush","发布"); //设置选项 model.addAttribute("options",HaloConst.OPTIONS); diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 1abc4755a..3106a1c25 100755 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -5,7 +5,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource # H2database 配置 driver-class-name: org.h2.Driver - url: jdbc:h2:file:~/halo/halo_db + url: jdbc:h2:file:~/halo/halo username: admin password: 123456 h2: diff --git a/src/main/resources/static/js/app.js b/src/main/resources/static/js/app.js index 5ce59acc2..4a1776443 100755 --- a/src/main/resources/static/js/app.js +++ b/src/main/resources/static/js/app.js @@ -18,4 +18,19 @@ function showMsg(text,icon,hideAfter) { loader: true, loaderBg: '#ffffff' }); +} + +/** + * 转义 + * @param str str + * @returns {string} + */ +function stringEncode(str){ + var div=document.createElement('div'); + if(div.innerText){ + div.innerText=str; + }else{ + div.textContent=str; + } + return div.innerHTML; } \ No newline at end of file diff --git a/src/main/resources/static/js/login.js b/src/main/resources/static/js/login.js new file mode 100644 index 000000000..8598134c8 --- /dev/null +++ b/src/main/resources/static/js/login.js @@ -0,0 +1,82 @@ +function btn_login() { + $('#btn-login').button('loading'); + var name = $("#login-name").val(); + var pwd = $("#login-pwd").val(); + if(name==""||pwd==""){ + showMsg("请输入完整信息!","info",2000); + $('#btn-login').button('reset'); + }else{ + $.ajax({ + type: 'POST', + url: '/admin/getLogin', + async: false, + data:{ + 'loginName': name, + 'loginPwd': pwd + }, + success: function (status) { + if(status=="true"){ + $.toast({ + text: "登录成功!", + heading: '提示', + icon: 'success', + showHideTransition: 'fade', + allowToastClose: true, + hideAfter: 1000, + stack: 1, + position: 'top-center', + textAlign: 'left', + loader: true, + loaderBg: '#ffffff', + afterHidden: function () { + window.location.href="/admin"; + } + }); + }else if(status=="disable"){ + $('.login-body').addClass('animate shake'); + $.toast({ + text: "密码错误已达到5次,请10分钟后再试!", + heading: '提示', + icon: 'error', + showHideTransition: 'fade', + allowToastClose: true, + hideAfter: 2000, + stack: 1, + position: 'top-center', + textAlign: 'left', + loader: true, + loaderBg: '#ffffff', + afterHidden: function () { + $('.login-body').removeClass('animate shake'); + } + }); + $('#btn-login').button('reset'); + }else{ + $('.login-body').addClass('animate shake'); + $.toast({ + text: "用户名或者密码错误!", + heading: '提示', + icon: 'error', + showHideTransition: 'fade', + allowToastClose: true, + hideAfter: 2000, + stack: 1, + position: 'top-center', + textAlign: 'left', + loader: true, + loaderBg: '#ffffff', + afterHidden: function () { + $('.login-body').removeClass('animate shake'); + } + }); + $('#btn-login').button('reset'); + } + } + }); + } +} +$(document).keydown(function (event) { + if(event.keyCode == 13){ + btn_login(); + } +}); \ No newline at end of file diff --git a/src/main/resources/templates/admin/admin_attachment.ftl b/src/main/resources/templates/admin/admin_attachment.ftl index a3ec7c034..83d6d8474 100755 --- a/src/main/resources/templates/admin/admin_attachment.ftl +++ b/src/main/resources/templates/admin/admin_attachment.ftl @@ -49,10 +49,10 @@ 第${attachments.number+1}/${attachments.totalPages}页 diff --git a/src/main/resources/templates/admin/admin_login.ftl b/src/main/resources/templates/admin/admin_login.ftl index cbf205442..d7301bf85 100755 --- a/src/main/resources/templates/admin/admin_login.ftl +++ b/src/main/resources/templates/admin/admin_login.ftl @@ -44,91 +44,6 @@ - + \ No newline at end of file diff --git a/src/main/resources/templates/admin/admin_md-editor.ftl b/src/main/resources/templates/admin/admin_md-editor.ftl index f5741548c..9471728df 100644 --- a/src/main/resources/templates/admin/admin_md-editor.ftl +++ b/src/main/resources/templates/admin/admin_md-editor.ftl @@ -107,7 +107,17 @@
- +
+
@@ -148,6 +158,11 @@ + + $('#chooseTag').change(function () { + $('#tagList').tagEditor('addTag',$(this).val()); + }); + /** * 打开附件 */ @@ -227,7 +242,6 @@ * @param status 文章状态 */ function push(status) { - alert( $('#tagList').tagEditor('getTags')[0].tags ); var Title = ""; if(postTitle.val()){ Title = postTitle.val(); diff --git a/src/main/resources/templates/admin/admin_tag.ftl b/src/main/resources/templates/admin/admin_tag.ftl index d9debfaf7..6d367ded6 100755 --- a/src/main/resources/templates/admin/admin_tag.ftl +++ b/src/main/resources/templates/admin/admin_tag.ftl @@ -164,18 +164,23 @@ <#list tags as tag>
diff --git a/src/main/resources/templates/common/install.ftl b/src/main/resources/templates/common/install.ftl index 0070429be..1afa19a08 100644 --- a/src/main/resources/templates/common/install.ftl +++ b/src/main/resources/templates/common/install.ftl @@ -120,6 +120,97 @@ <#else >

已经安装过了,不能重复安装的酱紫!

+
+                                    .'+:
+                                  `+@#'##
+                                   +#.```#+
+                                 `.@` `` .# `
+                                  '+`  `  @,`
+                                  +'`   ``++
+                        ,#@@' `   ++      ;#
+                      .@#'..'#`   ,#      .@               ``.,::;;:,,`
+                     `#+`    '@   `#`     `@         `.:'##@@###+#++#@@#,
+                     .@      `@'   #'     `@  ` `.;+#@@#':..` ``;:    .'@#`
+                     ,@       ,@`  ,@`     @`.'@@##;,`` `      ., `     .## `
+                     `#        #+   #'`    ##@+,.`           ` +         `#+
+                     `#,     ` :#`  .@.   `@.`    .    `      `,`         .#:
+                      ;#       `#,   +#`  `` `   `+';+`       :`        `  '#`
+                      `@:`      ++`:@@#:         +``  +       '    ,.  ;@#``@,
+                     ` ,@`      .@@#:```        .. ##.`:      '`  ;@@.`#@#;`+'
+                        ++       @:  ` ` `.`    , ,#@'`'      ;   #@@' +@@:`,#`
+                         @;      #:  ` ,'` ,+   ..`@@``:      .`  ;@@:``++  .#`
+                        `.@,     ::   ,,  `` #   +``` +`     ``;`` :;   `   .#`
+                          ;@.  `      # `:   `.  `+;;+``      `+`           ,@
+                         `@@#        `, @@@```'  `  `          `:           ;#``
+                        `@+ ;` `     `: @@#` `;```  ` `         ;.          #:
+                        @'`           +``:  `..                  +`      ` .#`
+                       +#             ,.   ` '                    +.`    ``#'
+                      .@.              :'``,+                      ,'.` `.#@. ``
+                      #'                 ..`                         `;';;#`
+                     .@` `                                            ``:@,``
+                   ``#+                                           `    '@,
+                     @`                                           `  `#@``
+                    ;#                                             .'#'` `
+                   `#:                                  ` ` ,;` `,#@+.
+                   `@`                                    :;'@+#@#;``  `
+                  `.#``                                   '#+#@,.  `
+                   ;#                                         @:`
+                   #;                                        `:@
+                   @.                                          #.
+                   @.                                         `+'
+                   @.                                          ;#
+                   @.                                    :`    .@`
+                   @.                                    ;.   ``@`
+                   @.                                    ;,  ` `#
+                   @,                  `                 +.    `@
+                   +'                  ;:                @`     @
+                   ,#`                  +,              :;     `@
+                  ``@`                   +;          ``,#      .@
+                   `#;                    ;#.`      ``'+       ;#`
+                    :@ `                  ` '@',..,;#+.      ``#;
+                     #:                   ` ```:;;:.`         `@`
+                  `` :@                        `    `         ;#``
+                     `#+                                      @,
+                      `@:`                                   +#`
+                       ,#.                                 `,@.`
+                      ` ;@.`                               .@:`
+                         '@,                              .@;`
+                      ```@+#;                         ```;@@  `
+                     ` `@' ,@+`                        ,#@.#'
+                       ## ```+@;                    `,#@'. `@.
+                     `;@ `    ,@#' `      `  `   `;+@@;`    ;@` `
+                      #:       `,@@#',` ` ```.;#@@@;. `  `   @@#,
+               ``   ;@@`           ;+@@@@@@@@##'.`           ,@@@#:`
+                 `+@@@:`           ` ` ```.``   `            `@::#@@'`
+               .#@@+++                `                       ,@` .+@@+.
+   `    `    :#@@;` @,                                         @,   `+@@#.``;#@@@`
+    @@@@#, :@@@: ` ,#                                        ``'#``   `'@@#@@@##@`
+   `;''+@@@#@:`    #'                                          .@``    ` ;@@#.
+       ,#@@:       @`                                           @:      `.@#@@'`
+      '@@'@.      :#                                            '#       `@;`+@#``
+    `'#+ :@.    ``#'                                            .@      ``#+` ;' `
+     .,  #@``     @`                                             @.     ``:@,
+       `.@;      .@                                              ++       `;`
+        `,`     `;#                                              :#
+                `#'                                               @`
+                 @.                                              `@.
+                 @`                                               #'`
+                `@                                                ;#
+                ,#                                                .#
+                ;+                                                `@`
+                #'                                                 @.
+                #:                                                 #:
+                @,                                                `++
+                @`                                                 ;#`
+               `@`                                                 ,@
+               `@`                                                 `@  `
+               `@`                                                 `@`
+               `@`                                                  @`
+               `@`                                                  @.
+               `@`                                                  #: `
+               `@@@@@@@@@##################@@@@@@@@@@@@@@@@@@@@@@@#@@;
+             ` `::::::::::::::::::::::::::::,:::::,,,,,,,,,,,,,,,,,:,.`
+