edit_blog.html 5.66 KB
<% 
	var headContent = {
%>
	<% include("/template/mtg/includes/header.html"){} %>
	
<!-- jquery -->
<% include("/template/includes/jquery.html"){} %> 
<% include("/template/includes/umeditor.html"){} %>
	
<script type="text/javascript">
	var um;
	$(document).ready(function(){
		um = UM.getEditor('editor',{
			initialFrameHeight:350  //初始化编辑器高度,默认320
			,compressSide:1
			,imageScaleEnabled:false // 图片不允许拖拽
			,imageUrl:"umeditor/personimageup"             //图片上传提交地址
			,toolbar:[
			            'source | bold italic underline strikethrough | forecolor backcolor  |',
			            'insertorderedlist insertunorderedlist | paragraph  ' ,
			            '| justifyleft justifycenter justifyright justifyjustify |',
			            'link unlink | emotion image '
			        ]
		});
		
	});

	function oper_save(id) {
		var title = $('[name="model.title"]').val();
		if(title=='') {
			Alert('请输入博文题目');
			return false;
		}
		if(title.length > 80 ) {
			Alert('博文('+title.length+'字)题目过长,请输入小于80个字');
			return false;
		}
		
		if(!um.hasContents()){
			Alert('请输入博文内容');
			return false;
		}
		if(um.getContentTxt().length > 1200){
			Alert('博文('+um.getContentTxt().length+'字)文字过长,请输入小于1200个字');
			return false;
		}
		
		var tags = $('#tags_content').val().replace(/,/g, ",");
		if(tags!='' && tags.length > 150 ) {
			Alert('关键词('+tags.length+'字)过长,请输入小于150个字');
			return false;
		}
		
		if(tags!='') {
			$('[name="tags"]').val(tags);
		}
		
		jQuery.ajax({
			type:'POST',
			url:jflyfox.BASE_PATH + 'front/person/saveblog/'+id,
			data:$("form").serialize(),
			success:function(data){
				if(data.status==1){
					alert('发布成功');
					form1.action = jflyfox.BASE_PATH + "front/person";
					form1.submit();
					return true;
				} else {
					alert('发布失败:'+data.msg);
				}
				$('[name="old_password"]').val('');
				$('[name="new_password"]').val('');
				$('[name="new_password2"]').val('');
			},
			error:function(html){
				var flag = (typeof console != 'undefined');
				if(flag) console.log("服务器忙,提交数据失败,代码:" +html.status+ ",请联系管理员!");
				alert("服务器忙,提交数据失败,请联系管理员!");
			}
		});
		
		
		return false;
	}
	
</script>

<%
};

var bodyContent = {
%>
<%  include("/template/mtg/includes/header_menu.html"){} %>	

<div class="container">

	<div class="row">
		<div class="col-md-12">	
	
		<div class="panel panel-default">
			 <div class="panel-body" style="padding:0px;">
			<ol class="breadcrumb" style="margin:0px;">
			  <li><a href="${BASE_PATH }home.html">首页</a></li>
			  <li><a href="${BASE_PATH }front/person">我的空间</a></li>
			  <li>发布博文</li>
			</ol>
			</div>
		</div>
	
		</div>
	</div>

	<div class="row">
	<!-- 文章 -->
	<div class="col-md-8">	
		<div class="panel panel-default">
		  <div class="panel-heading">
			<h3 class="panel-title">发布博文</h3>
		  </div>
		 	 
	 	  <div class="panel-body">
	  
			<form class="form-horizontal" name="form1" action="" method="post">
					 <input type="hidden" name="model.id" class="form-control" id="model.id"  
					 value="${model.id!'0'}">
					 <div class="form-group">
					    <label for="model.title" class="col-sm-2 control-label">博文题目</label>
					    <div class="col-sm-10">
					    	<input name="model.title" class="form-control" id="model.title" 
					      	value="${model.title!''}" placeholder="博文题目">
					    </div>
					  </div>
					 
					  <div class="form-group">
					    <label for="remark" class="col-sm-2 control-label">博文内容</label>
					    <div class="col-sm-10">
					    	<script id="editor" type="text/plain" name="model.content"
									style="width: 98%; height: 320px;">${model.content!''}</script>
					    </div>
					  </div>
						  
					  <div class="form-group">
					    <label for="title_url" class="col-sm-2 control-label">关键词</label>
					    <div class="col-sm-10">
					      <input name="tags" type="hidden" value="${tags!''}" />
					      <input name="tags_content" type="text" class="form-control" id="tags_content" 
					      	value="${tags!''}" placeholder="关键词">
					    </div>
					  </div>
						 
						 
					  
					  
					   <div class="form-group">
						    <div class="col-sm-offset-2 col-sm-10">
						      <input type="button" value="发 布"  class="btn btn-primary" onclick="oper_save(${model.id!'0'});"/>
									&nbsp;&nbsp;&nbsp;&nbsp;
							  <input type="reset" value="重 置"  class="btn btn-default" />
						    </div>
						</div>
						<div class="form-group">
						    <div class="col-sm-offset-2 col-sm-10" style="color: red;">
						      1. 博文题目必须填写,并且不能超过80个文字。<br>
						      2. 博文内容尽量控制在1200个文字内,内容合法健康,否则可能会被删除。<br>
							  3. 关键词请使用逗号分隔不同标签,最多5个哦,并且不能超过150个文字。 <br>
						    </div>
						</div>
					
					</form>
			
			</div>
		</div>

	</div>
	
	<!-- 信息列表 -->
	<div class="col-md-4">	
		<!-- 用户信息 -->
		<%include("/template/mtg/person/userinfo.html"){} %>
		
		<!-- 推荐文章 -->
		<%  include("/template/mtg/includes/recommend.html"){} %>
		
		<!-- 友情链接 -->
		<%  include("/template/mtg/includes/friendly.html"){} %>
	</div>
	</div>

</div>
	
<%  include("/template/mtg/includes/footer.html"){} %>
	
<a id="scrollTop" href="javacript:void(0);" title="返回顶部" style="display: inline;"></a>
	
<%}; %>

<% layout("/pages/template/_layout.html",{head:headContent,body:bodyContent}){ %>
<%} %>