Skip to content

博客优化 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*


# idea file
.idea
.settings
.project
.classpath
SSMBlogv2.iml
target
33 changes: 15 additions & 18 deletions WebRoot/WEB-INF/classes/applicationContext.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd">
<context:component-scan base-package="service"></context:component-scan>
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<context:component-scan base-package="service"/>

<!-- 配置数据源 -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="url" value="jdbc:mysql://localhost:3306/jspblog"></property>
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="username" value="root"></property>
<property name="password" value="College86"></property>
<property name="url" value="jdbc:mysql://localhost:3306/jspblog"/>
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="username" value="admin"/>
<property name="password" value="password"/>
</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations">
<array>
<value>classpath:mapping/*.xml</value>
Expand Down Expand Up @@ -59,8 +56,8 @@
</bean>

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="mapping"></property>
<property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
<property name="basePackage" value="mapping"/>
<property name="sqlSessionFactory" ref="sqlSessionFactory"/>
</bean>

<aop:aspectj-autoproxy />
Expand All @@ -83,4 +80,4 @@
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
</beans>
</beans>
40 changes: 20 additions & 20 deletions WebRoot/WEB-INF/jsp/admin/backadmin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/nav.css" rel="stylesheet">
<link href="${APP_PATH}/css/bootstrap.min.css" rel="stylesheet">
<link href="${APP_PATH}/css/nav.css" rel="stylesheet">
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script src="${APP_PATH}/js/bootstrap.min.js"></script>
<script src="https://cdn.bootcss.com/jquery/3.2.0/jquery.min.js"></script>
<link href="js/editormd/css/editormd.min.css" rel="stylesheet"
<link href="${APP_PATH}/js/editormd/css/editormd.min.css" rel="stylesheet"
type="text/css" />
<script src="js/editormd/editormd.js"></script>
<script src="js/editormd/editormd.amd.js"></script>
<script src="${APP_PATH}/js/editormd/editormd.js"></script>
<script src="${APP_PATH}/js/editormd/editormd.amd.js"></script>
</head>
<body>
<header>
<ul class="navul">
<li class="navli"><a href="${APP_PATH }/validatellogin">文章管理</a></li>
<li class="navli"><a href="${APP_PATH }/admin/">文章管理</a></li>
<li class="navli"><a href="${APP_PATH }/commentback">评论管理</a></li>
<li class="navli"><a href="${APP_PATH }/tagadmin">分类管理</a></li>
<li class="navli"><a href="${APP_PATH }/logout">log out</a></li>
Expand All @@ -53,11 +53,11 @@
<div class="row" style="text-align: center;">
<div class="col-md-18 row" id="page_info_area"></div>
</div>

<!-- 删除模态框 Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
Expand All @@ -72,7 +72,7 @@
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
</div>
</div>

</div>
</div>
</div>
Expand Down Expand Up @@ -116,16 +116,16 @@
li.css("word-wrap","break-word").css("word-break","break-all")
.css("overflow","hidden");
var div = $("<div></div>").addClass("btn-group").css("float","right");
/* <button type="button" class="btn btn-info btn-lg"

/* <button type="button" class="btn btn-info btn-lg"
data-toggle="modal" data-target="#myModal">Open Large Modal</button> */


var editBtn = $("<button></button>").addClass("btn btn-primary").append("编辑")
.appendTo(div);
editBtn.bind("click", function() {
edit(item.id);
});
});
var delBtn = $("<button></button>").addClass("btn btn-danger").append("删除").attr("data-toggle", "modal")
.attr("data-target", "#myModal").appendTo(div);
delBtn.bind("click", function() {
Expand Down Expand Up @@ -212,17 +212,17 @@
var navEle = $("<nav></nav>").append(ul);
navEle.appendTo("#page_nav_area");
}

// 新建博客的控制器映射
function newblog() {
window.location='${APP_PATH }/islogin';
window.location='${APP_PATH }/islogin';
}

// 编辑博客发出的请求
function edit(id) {
window.location='${APP_PATH }/edit?id=' + id;
};

// 删除函数
function del(id, pageNum) {
alert(id);
Expand All @@ -235,7 +235,7 @@
alert("删除成功!");
// 回到当前页
to_page(pageNum);
}
}
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion WebRoot/WEB-INF/jsp/admin/commentadmin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<body>
<header>
<ul class="navul">
<li class="navli"><a href="${APP_PATH }/validatellogin">文章管理</a></li>
<li class="navli"><a href="${APP_PATH }/admin/">文章管理</a></li>
<li class="navli"><a href="${APP_PATH }/commentback">评论管理</a></li>
<li class="navli"><a href="${APP_PATH }/tagadmin">分类管理</a></li>
<li class="navli"><a href="${APP_PATH }/logout">log out</a></li>
Expand Down
110 changes: 68 additions & 42 deletions WebRoot/WEB-INF/jsp/admin/edit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>王锐鹏博客</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="${APP_PATH}/css/bootstrap.min.css" rel="stylesheet">
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<link href="js/editormd/css/editormd.min.css" rel="stylesheet"
<script src="${APP_PATH}/js/bootstrap.min.js"></script>
<link href="${APP_PATH}/js/editormd/css/editormd.min.css" rel="stylesheet"
type="text/css" />
<script src="https://cdn.bootcss.com/jquery/3.2.0/jquery.min.js"></script>
<script src="js/editormd/editormd.js"></script>
<script src="js/editormd/editormd.amd.js"></script>
<script src="${APP_PATH}/js/editormd/editormd.js"></script>
<script src="${APP_PATH}/js/editormd/editormd.amd.js"></script>

<style>
h1{
Expand All @@ -32,47 +32,48 @@
<body>
<h1>编辑保存文章</h1>
<br>
<form class="form-horizontal" action="<%=path%>/updatearticle" method="post" style="text-align:center">
<input type="hidden" name="id" value="${blogid }"/>
<div class="form-group">
<label for="title" class="col-sm-2 control-label">title</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="title" name="title" placeholder="title"
value="${blog.title }">
</div>
</div>
<div class="form-group">
<label for="titleIntro" class="col-sm-2 control-label">titleIntro</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="titleIntro" name="titleIntro">
</div>
</div>
<div class="form-group">
<label for="createdtime" class="col-sm-2 control-label">createdtime</label>
<div class="col-sm-8">
<input type="date" class="form-control" id="createdtime" name="createdtime">
</div>
</div>
<div class="form-group">
<label for="categoryName" class="col-sm-2 control-label">categoryName</label>
<div class="col-sm-8">
<select class="form-control" id="categoryName" name="categoryName">
</select>
</div>
<button type="submit" class="btn btn-default">保存修改</button>
</div>
<form class="form-horizontal" style="text-align:center">
<input type="hidden" name="id" value="${blogid }"/>
<div class="form-group">
<label for="title" class="col-sm-2 control-label">title</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="title" name="title" placeholder="文章标题"
value="${blog.title }">
</div>
</div>
<div class="form-group">
<label for="titleIntro" class="col-sm-2 control-label">文章简介</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="titleIntro" name="titleIntro" placeholder="文章简介">
</div>
</div>
<div class="form-group">
<label for="createdTime" class="col-sm-2 control-label">创建时间</label>
<div class="col-sm-8">
<input type="date" class="form-control" id="createdTime" name="createdTime">
</div>
</div>

<div class="form-group">
<label for="categoryName" class="col-sm-2 control-label">分类名字</label>
<div class="col-sm-8">
<select class="form-control" id="categoryName" name="categoryName">
</select>
</div>
<button type="button" class="btn btn-default" id="updateArticle">保存修改</button>
</div>
<!-- editormd start -->
<div id="test-editormd" class="editormd form-control form-group" style="margin: 2px;">
<textarea id="editormd" name="test-editormd-markdown-doc"
class="editormd-markdown-textarea"></textarea>
<textarea id="editorMarkdown" name="editorMarkdown"
class="editormd-markdown-textarea"></textarea>
<!-- 第二个隐藏文本域,用来构造生成的HTML代码,方便表单POST提交,这里的name可以任意取,后台接受时以这个name键为准 -->
<!-- html textarea 需要开启配置项 saveHTMLToTextarea == true -->
<textarea id="editorhtml" name="editorhtml" class="editormd-html-textarea"></textarea>
<textarea id="editorHtml" name="editorHtml" class="editormd-html-textarea"></textarea>
</div>
<!-- editormd end -->
<!-- editormd end -->
</form>


<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script type="text/javascript">
var testEditor;
testEditor=$(function() {
Expand All @@ -94,6 +95,31 @@
codeFold : true
});
});

$('#updateArticle').click(function () {

// 取出表单里面的数据
var formData = $('.form-horizontal').serialize();
// 使用正则删除 &test-editormd-html-code 后面的内容
var result = formData.match(/.*(?=&test-editormd-html-code)/)

$.ajax({
type: "POST",
url: "${APP_PATH}/updateArticle",
// 取出正则的结果,发送数据
data: result[0],
success: function (data) {
if (data.code == 100) {
swal({
text: data.msg
});
setTimeout(function () {
}, 3000);
window.location.href = "${APP_PATH}/admin/";
}
}
})
});
</script>
<script type="text/javascript">
$(function() {
Expand All @@ -113,8 +139,8 @@
success: function(result) {
$("#title").val(result.title);
$("#titleIntro").val(result.titleintro);
$("#createdtime").val(showdate(result.createdtime));
$("#editormd").val(result.md);
$("#createdTime").val(showdate(result.createdtime));
$("#editorMarkdown").val(result.md);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion WebRoot/WEB-INF/jsp/admin/editsuccess.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<title>王锐鹏博客</title>
</head>
<body>
${map.message }<a href="${APP_PATH }/validatellogin">继续修改文章</a>
${map.message }<a href="${APP_PATH}/admin/">继续修改文章</a>
</body>
</html>
14 changes: 13 additions & 1 deletion WebRoot/WEB-INF/jsp/admin/error.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
<title>王锐鹏博客!</title>
</head>
<body>
你没有登陆!
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script>
// 弹出请登录
swal({
text: "请登录!"
})
// 延时1S
setTimeout(function () {
}, 1000);
// 重定向
window.location.href = "${pageContext.request.contextPath}/login";
</script>
</html>
Loading