init
This commit is contained in:
21
app/views/Blog/about_me.html
Normal file
21
app/views/Blog/about_me.html
Normal file
@@ -0,0 +1,21 @@
|
||||
{{template "Blog/header.html" .}}
|
||||
|
||||
<div id="postsContainer">
|
||||
<div id="posts">
|
||||
<div class="each-post">
|
||||
<div class="title">
|
||||
关于我
|
||||
</div>
|
||||
<div class="created-time">
|
||||
</div>
|
||||
<div class="desc">
|
||||
{{.userBlog.AboutMe | raw}}
|
||||
</div>
|
||||
|
||||
<!-- comment -->
|
||||
{{template "blog/comment.html" .}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{template "Blog/footer.html" .}}
|
||||
18
app/views/Blog/comment.html
Normal file
18
app/views/Blog/comment.html
Normal file
@@ -0,0 +1,18 @@
|
||||
{{if .userBlog.CanComment}}
|
||||
<div id="disqus_thread"></div>
|
||||
<!-- comment -->
|
||||
<script type="text/javascript">
|
||||
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
|
||||
var disqus_shortname = '{{.userBlog.DisqusId}}'; // required: replace example with your forum shortname
|
||||
var disqus_identifier = '{{.userBlog.UserId.Hex}}/{{.blog.NoteId.Hex}}/{{.blog.Title}}'; // 博客链接
|
||||
|
||||
/* * * DON'T EDIT BELOW THIS LINE * * */
|
||||
(function() {
|
||||
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
||||
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||
})();
|
||||
</script>
|
||||
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
||||
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
|
||||
{{end}}
|
||||
62
app/views/Blog/footer.html
Normal file
62
app/views/Blog/footer.html
Normal file
@@ -0,0 +1,62 @@
|
||||
<div id="footerContainer">
|
||||
{{$userId := .userBlog.UserId.Hex}}
|
||||
<div class="container" id="footer">
|
||||
<div class="col-md-4">
|
||||
<h3>导航</h3>
|
||||
<ul>
|
||||
<li><a href="/blog/{{$userId}}">首页</a></li>
|
||||
{{range .notebooks}}
|
||||
<li>
|
||||
<a href="/blog/{{$userId}}/{{.NotebookId.Hex}}">{{.Title}}</a>
|
||||
</li>
|
||||
{{end}}
|
||||
<li><a href="/blog/aboutMe/{{$userId}}">关于我</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h3>最近发表</h3>
|
||||
<ul>
|
||||
{{range .recentBlogs}}
|
||||
<li title="{{.Title}}"><a href="/blog/view/{{.NoteId.Hex}}/">{{.Title}}</a></li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h3>快速链接</h3>
|
||||
<ul>
|
||||
<li><a href="/note">我的笔记</a></li>
|
||||
<li><a href="/login">登录</a></li>
|
||||
<li><a href="http://leanote.com" target="_blank">leanote</a></li>
|
||||
<li><a href="https://github.com/leanote/leanote" target="_blank">leanote github</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/js/jquery-1.9.0.min.js"></script>
|
||||
<script src="/js/bootstrap-min.js"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
/*
|
||||
$("#searchInput").click(function() {
|
||||
$("#search").width("130px");
|
||||
$("#searchInput").width("100px");
|
||||
});
|
||||
$("#searchInput").blur(function() {
|
||||
$("#search").width(0);
|
||||
$("#searchInput").width(0);
|
||||
});
|
||||
*/
|
||||
});
|
||||
// 搜索
|
||||
function search(e) {
|
||||
var key = $("#searchInput").val();
|
||||
if(!key) {
|
||||
location.href = "/blog/" + UserInfo.Username;
|
||||
} else {
|
||||
var tpl = '<form action="/blog/searchBlog/' + UserInfo.Username +'" method="get">';
|
||||
tpl += '<input name="key" value="' + key + '" />';
|
||||
tpl += "</form";
|
||||
$(tpl).submit();
|
||||
}
|
||||
}
|
||||
88
app/views/Blog/header.html
Normal file
88
app/views/Blog/header.html
Normal file
@@ -0,0 +1,88 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="keywords" content="leanote,leanote.com">
|
||||
<meta name="description" content="leanote, your own cloud note!">
|
||||
<meta name="author" content="leanote">
|
||||
|
||||
<title>{{.title}}</title>
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link href="/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="/css/font-awesome-4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
<link id="styleLink" href="/css/blog/{{if .userBlog.Style}}{{.userBlog.Style}}{{else}}blog_default{{end}}.css" rel="stylesheet">
|
||||
|
||||
<script>
|
||||
function log(o) {
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="headerAndNav" >
|
||||
<div id="headerContainer" class="container">
|
||||
<!-- 头部可放博客名, 导航 -->
|
||||
<div id="header">
|
||||
{{$userId := .userBlog.UserId.Hex}} <!-- 可不要了 -->
|
||||
{{$username := .userInfo.Username}}
|
||||
<h1>
|
||||
<a href="/blog/{{$username}}" id="logo">
|
||||
{{if .userBlog.Logo}}
|
||||
<img src="{{.userBlog.Logo}}" title="{{.userBlog.Title}}"/>
|
||||
{{else}}
|
||||
{{.userBlog.Title | raw}}
|
||||
{{end}}
|
||||
</a>
|
||||
</h1>
|
||||
<div id="blogDesc">
|
||||
{{.userBlog.SubTitle | raw}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Static navbar -->
|
||||
<div class="navbar navbar-default">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
{{$navNotebookId := .notebookId}}
|
||||
<li class="{{if .index}}active{{end}}"><a href="/blog/{{$username}}">首页</a></li>
|
||||
{{range .notebooks}}
|
||||
{{$notebookId := .NotebookId.Hex}}
|
||||
<li class="{{if eq $navNotebookId $notebookId}}active{{else}}{{end}}">
|
||||
<a href="/blog/{{$username}}/{{$notebookId}}"
|
||||
>{{.Title}}</a>
|
||||
</li>
|
||||
{{end}}
|
||||
<li class="{{if .aboutMe}}active{{end}}"><a href="/blog/aboutMe/{{$username}}">关于我</a></li>
|
||||
{{if .isMe}}
|
||||
<li class="{{if .set}}active{{end}}"><a href="/blog/set" >博客设置</a></li>
|
||||
<li><a href="/note" >{{msg . "myNote"}}</a></li>
|
||||
{{end}}
|
||||
</ul>
|
||||
<form class="navbar-form navbar-right" id="search" onsubmit="search(event);return false;">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" id="searchIcon" onclick="search(event);"><i class="fa fa-search"></i></span>
|
||||
<input type="text" placeholder="search" id="searchInput" class="form-control" value="{{.key}}">
|
||||
</div>
|
||||
</form>
|
||||
</div><!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var UserInfo = {UserId: "{{$userId}}", Email: "{{.userInfo.Email}}", Username: "{{.userInfo.Username}}"};
|
||||
</script>
|
||||
71
app/views/Blog/highlight.html
Normal file
71
app/views/Blog/highlight.html
Normal file
@@ -0,0 +1,71 @@
|
||||
<link href="/public/mdeditor/editor/google-code-prettify/prettify.css" type="text/css" rel="stylesheet">
|
||||
<script src="/public/mdeditor/editor/google-code-prettify/prettify.js"></script>
|
||||
|
||||
<script>
|
||||
$("pre").addClass("prettyprint linenums");
|
||||
prettyPrint();
|
||||
</script>
|
||||
|
||||
<!--
|
||||
<script type="text/javascript" src="/js/syntaxhighlighter/scripts/shCore.js"></script>
|
||||
<link href="/js/syntaxhighlighter/styles/shCore.css" rel="stylesheet" type="text/css" />
|
||||
<link href="/js/syntaxhighlighter/styles/shThemeDefault.css" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var pathPrefix = "/js/syntaxhighlighter/scripts/";
|
||||
var map = {
|
||||
"brush: jscript": "shBrushJScript.js",
|
||||
"brush: c#": "shBrushCSharp.js",
|
||||
"brush: css": "shBrushCss.js",
|
||||
"brush: cpp": "shBrushCpp.js",
|
||||
"brush: java": "shBrushJava.js",
|
||||
"brush: xml": "shBrushXml.js",
|
||||
"brush: php": "shBrushPhp.js",
|
||||
"brush: perl": "shBrushPerl.js",
|
||||
"brush: python": "shBrushPython.js",
|
||||
"brush: ruby": "shBrushRuby.js",
|
||||
"brush: sql": "shBrushSql.js"}
|
||||
var needLoadCount = 0;
|
||||
var alreadyLoadCount = 0;
|
||||
$('pre[class]').each(function() {
|
||||
var brush = $(this).attr("class");
|
||||
var js = map[brush]
|
||||
if (js) {
|
||||
needLoadCount++;
|
||||
map[brush] = null; // 不要重复加载
|
||||
loadJS(pathPrefix + js, function () {
|
||||
alreadyLoadCount++;
|
||||
if (alreadyLoadCount == needLoadCount) {
|
||||
//setTimeout(function() {
|
||||
SyntaxHighlighter.highlight();
|
||||
//}, 500);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function loadJS(url, callback) {
|
||||
$.getScript(url, function() {
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
function loadJS(url, callback, charset) {
|
||||
var script = document.createElement('script');
|
||||
script.onload = script.onreadystatechange = function () {
|
||||
if (script && script.readyState && /^(?!(?:loaded|complete)$)/.test(script.readyState)) return;
|
||||
script.onload = script.onreadystatechange = null;
|
||||
script.src = '';
|
||||
script.parentNode.removeChild(script);
|
||||
script = null;
|
||||
if (callback) callback();
|
||||
};
|
||||
script.charset = charset || document.charset || document.characterSet;
|
||||
script.src = url;
|
||||
try { document.getElementsByTagName("head")[0].appendChild(script); } catch (e) { }
|
||||
}
|
||||
*/
|
||||
</script>
|
||||
-->
|
||||
44
app/views/Blog/index.html
Normal file
44
app/views/Blog/index.html
Normal file
@@ -0,0 +1,44 @@
|
||||
{{template "Blog/header.html" .}}
|
||||
|
||||
<div id="postsContainer">
|
||||
<div class="container">
|
||||
{{if .notebookId}}
|
||||
<h2>分类 {{.notebook.Title}}</h2>
|
||||
{{end}}
|
||||
</div>
|
||||
<div id="posts">
|
||||
{{range .blogs}}
|
||||
<div class="each-post">
|
||||
<div class="title">
|
||||
<a href="/blog/view/{{.NoteId.Hex}}" title="全文">
|
||||
{{.Title}}
|
||||
</a>
|
||||
</div>
|
||||
<div class="created-time">
|
||||
<i class="fa fa-bookmark-o" style="color: #666"></i>
|
||||
{{if .Tags}}
|
||||
{{blogTags .Tags}}
|
||||
{{else}}
|
||||
无
|
||||
{{end}}
|
||||
|
|
||||
<i class="fa fa-calendar" style="color: #666"></i> 更新 {{.UpdatedTime | datetime}} |
|
||||
<i class="fa fa-calendar" style="color: #666"></i> 创建 {{.CreatedTime | datetime}}
|
||||
</div>
|
||||
<div class="desc">
|
||||
{{.Content | raw}}
|
||||
</div>
|
||||
<a class="more" href="/blog/view/{{.NoteId.Hex}}" title="更多">More...</a>
|
||||
</div>
|
||||
{{end}}
|
||||
<!-- 分页 -->
|
||||
<ul class="pager">
|
||||
{{page .userInfo.Username .notebookId .page .pageSize .count}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{template "Blog/footer.html" .}}
|
||||
{{template "Blog/highlight.html"}}
|
||||
</body>
|
||||
</html>
|
||||
45
app/views/Blog/search.html
Normal file
45
app/views/Blog/search.html
Normal file
@@ -0,0 +1,45 @@
|
||||
{{template "Blog/header.html" .}}
|
||||
|
||||
<div id="postsContainer">
|
||||
<div class="container">
|
||||
<h2>搜索 {{.key}} </h2>
|
||||
</div>
|
||||
|
||||
<div id="posts">
|
||||
{{range .blogs}}
|
||||
<div class="each-post">
|
||||
<div class="title">
|
||||
<a href="/blog/view/{{.NoteId.Hex}}" title="全文">
|
||||
{{.Title}}
|
||||
</a>
|
||||
</div>
|
||||
<div class="created-time">
|
||||
<i class="fa fa-bookmark-o" style="color: #666"></i>
|
||||
{{if .Tags}}
|
||||
{{blogTags .Tags}}
|
||||
{{else}}
|
||||
无
|
||||
{{end}}
|
||||
|
|
||||
<i class="fa fa-calendar" style="color: #666"></i> 更新 {{.UpdatedTime | datetime}} |
|
||||
<i class="fa fa-calendar" style="color: #666"></i> 创建 {{.CreatedTime | datetime}}
|
||||
</div>
|
||||
<div class="desc">
|
||||
{{.Content | raw}}
|
||||
</div>
|
||||
<a class="more" href="/blog/view/{{.NoteId.Hex}}" title="更多">More...</a>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if not .blogs }}
|
||||
<div class="each-post">
|
||||
无
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{template "Blog/footer.html" .}}
|
||||
{{template "Blog/highlight.html"}}
|
||||
</body>
|
||||
</html>
|
||||
301
app/views/Blog/set.html
Normal file
301
app/views/Blog/set.html
Normal file
@@ -0,0 +1,301 @@
|
||||
{{template "Blog/header.html" .}}
|
||||
|
||||
<!-- -->
|
||||
<link rel="stylesheet" href="/tinymce/skins/custom/skin.min.css"
|
||||
type="text/css">
|
||||
<style>
|
||||
.tab-pane {
|
||||
padding-top: 10px;
|
||||
}
|
||||
</style>
|
||||
<div id="postsContainer">
|
||||
<div id="posts">
|
||||
<ul id="myTab" class="nav nav-tabs">
|
||||
<li class="active"><a href="#baseInfo" data-toggle="tab">基本设置</a></li>
|
||||
<li class=""><a href="#commentInfo" data-toggle="tab">评论设置</a></li>
|
||||
<li class=""><a href="#styleInfo" data-toggle="tab">主题设置</a></li>
|
||||
</ul>
|
||||
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane" id="styleInfo">
|
||||
<form class="form-horizontal" role="form">
|
||||
<div class="form-group">
|
||||
<label for="Style" class="col-sm-2 control-label">主题</label>
|
||||
<div class="col-sm-10">
|
||||
<label><input type="radio" name="Style"
|
||||
value="blog_default"
|
||||
{{if not .userBlog.Style}}
|
||||
checked="checked"
|
||||
{{else}}
|
||||
{{if eq .userBlog.Style "blog_default"}}
|
||||
checked="checked"
|
||||
{{end}}
|
||||
{{end}}>
|
||||
默认 </label>
|
||||
<label><input type="radio" name="Style"
|
||||
value="blog_daqi"
|
||||
{{if eq .userBlog.Style "blog_daqi"}}checked="checked"{{end}}>
|
||||
大气</label>
|
||||
<label><input type="radio" name="Style"
|
||||
value="blog_left_fixed"
|
||||
{{if eq .userBlog.Style "blog_left_fixed"}}checked="checked"{{end}}>
|
||||
左侧导航固定</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button class="btn btn-success">保存</button>
|
||||
<span class="msg"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane" id="commentInfo">
|
||||
<form class="form-horizontal" role="form">
|
||||
<div class="form-group">
|
||||
<label for="subTitle" class="col-sm-2 control-label">开启评论</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="checkbox" id="CanComment" name="CanComment"
|
||||
{{if .userBlog.CanComment}}checked="checked"{{end}} >
|
||||
<br />
|
||||
leanote采用 <a href="http://disqus.com" target="_blank">Disqus</a>
|
||||
作为评论系统
|
||||
<div id="disqusSet">
|
||||
<label for="DisqusId">Disqus Id</label> <input type="text"
|
||||
class="form-control" style="display: inline; width: 50%"
|
||||
id="DisqusId" name="DisqusId"
|
||||
value="{{if .userBlog.DisqusId}}{{.userBlog.DisqusId}}{{else}}leanote{{end}}">
|
||||
<br /> (请填写您申请的Disqus唯一url前缀, 建议您申请Disqus帐号, 这样可以自己管理评论.
|
||||
或使用leanote的默认Disqus Id. <a target="_blank"
|
||||
href="/blog/view/52db8463e01c530ef8000001">需要帮助?</a>)
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button class="btn btn-success">保存</button>
|
||||
<span class="msg"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane active" id="baseInfo">
|
||||
<div class="form-horizontal" role="form" id="userBlogForm">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-10">
|
||||
<div class="alert alert-success" id="msg"
|
||||
style="display: none; margin-bottom: 3px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="title" class="col-sm-2 control-label">博客名称</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="Title" name="Title"
|
||||
placeholder="比如: leanote的博客"
|
||||
value="{{if .userBlog.Title}}{{.userBlog.Title}}{{else}}{{.userInfo.Email}} 的博客{{end}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="logo" class="col-sm-2 control-label">博客Logo</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="hidden" name="Logo" id="Logo"
|
||||
value="{{.userBlog.Logo}}" />
|
||||
<form id="formLogo" action="/file/uploadBlogLogo" method="post"
|
||||
enctype="multipart/form-data" target="logoTarget"
|
||||
onsubmit="inProgress()">
|
||||
<input type="file" class="form-control" id="logo2" name="file"
|
||||
onChange='$("#formLogo").submit();' /> 上传logo将显示logo(替代博客标题)
|
||||
<div id="logoImg"
|
||||
{{if .userBlog.Logo }}
|
||||
{{else}}
|
||||
style="display: none"{{end}}
|
||||
>
|
||||
<img src="{{.userBlog.Logo}}" style="height: 40px" /> <a
|
||||
href="#" id="deleteLogo">删除</a>
|
||||
</div>
|
||||
</form>
|
||||
<iframe id="logoTarget" name="logoTarget" src="#"
|
||||
style="display: none"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="subTitle" class="col-sm-2 control-label">博客描述</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="SubTitle"
|
||||
name="SubTitle" value="{{.userBlog.SubTitle}}"
|
||||
placeholder="比如: leanote, 不只是笔记">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="aboutMe" class="col-sm-2 control-label"></label>
|
||||
<div class="col-sm-10">
|
||||
<div id="popularToolbar"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="aboutMe" class="col-sm-2 control-label">关于我</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea id="AboutMe" name="AboutMe">{{.userBlog.AboutMe}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button class="btn btn-success">保存</button>
|
||||
<span class="msg"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{template "Blog/footer.html" .}}
|
||||
|
||||
<script src="/js/common-min.js"></script>
|
||||
|
||||
<script type="text/javascript" src="/tinymce/tinymce.min.js"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
tinymce.init({
|
||||
selector : "#AboutMe",
|
||||
content_css : [ "/css/bootstrap.css", "/css/editor.css" ],
|
||||
skin : "custom",
|
||||
language : "zh_CN",
|
||||
height : 300,
|
||||
width : "100%",
|
||||
plugins : [
|
||||
"advlist autolink link image lists charmap hr ",
|
||||
"searchreplace visualblocks visualchars code tabfocus",
|
||||
"table contextmenu directionality textcolor paste fullpage textcolor" ],
|
||||
|
||||
toolbar1 : "formatselect fontselect fontsizeselect | forecolor backcolor | bold italic underline strikethrough | image | bullist numlist | alignleft aligncenter alignright alignjustify",
|
||||
toolbar2 : "outdent indent blockquote | link unlink | table | hr removeformat | subscript superscript | visualchars visualblocks | searchreplace | code",
|
||||
|
||||
menubar : false,
|
||||
toolbar_items_size : 'small',
|
||||
statusbar : false,
|
||||
font_formats : "Arial=arial,helvetica,sans-serif;"
|
||||
+ "Arial Black=arial black,avant garde;"
|
||||
+ "Times New Roman=times new roman,times;"
|
||||
+ "Courier New=courier new,courier;"
|
||||
+ "Tahoma=tahoma,arial,helvetica,sans-serif;"
|
||||
+ "Verdana=verdana,geneva;" + "宋体=SimSun;"
|
||||
+ "新宋体=NSimSun;" + "黑体=SimHei;"
|
||||
+ "微软雅黑=Microsoft YaHei",
|
||||
block_formats : "Header 1=h1;Header 2=h2;Header 3=h3; Header 4=h4;Pre=pre;Paragraph=p"
|
||||
});
|
||||
$("#deleteLogo").click(function() {
|
||||
$("#Logo").val("");
|
||||
$("#logoImg").hide();
|
||||
});
|
||||
|
||||
$("#CanComment").click(function() {
|
||||
if ($(this).is(":checked")) {
|
||||
$("#disqusSet").show();
|
||||
} else {
|
||||
$("#disqusSet").hide();
|
||||
}
|
||||
});
|
||||
$("#CanComment").trigger("click").trigger("click"); // 恶心的想法
|
||||
|
||||
|
||||
// 基本设置
|
||||
$("#baseInfo .btn-success").click(function() {
|
||||
var data = {
|
||||
Title : $("#Title").val(),
|
||||
SubTitle : $("#SubTitle").val(),
|
||||
Logo : $("#Logo").val(),
|
||||
AboutMe : getEditorContent()
|
||||
}
|
||||
|
||||
post("/blog/setUserBlogBase", data, function(ret) {
|
||||
showMsg2($("#baseInfo .msg"), "保存成功", 2000);
|
||||
$("#blogDesc").html(data.SubTitle);
|
||||
$("#logo").html(data.Title);
|
||||
if(data.Logo) {
|
||||
$("#logo").html(t('<img src="?" />', data.Logo));
|
||||
}
|
||||
}, this);
|
||||
});
|
||||
// 评论
|
||||
$("#commentInfo .btn-success").click(function(e) {
|
||||
e.preventDefault();
|
||||
var data = {
|
||||
CanComment : $("#CanComment").is(":checked"),
|
||||
DisqusId : $("#DisqusId").val(),
|
||||
}
|
||||
post("/blog/setUserBlogComment", data, function(ret) {
|
||||
showMsg2($("#commentInfo .msg"), "保存成功", 2000);
|
||||
}, this);
|
||||
});
|
||||
// 主题
|
||||
$("#styleInfo .btn-success").click(function(e) {
|
||||
e.preventDefault();
|
||||
var data = {
|
||||
Style : $("input[name='Style']:checked").val()
|
||||
}
|
||||
post("/blog/setUserBlogStyle", data, function(ret) {
|
||||
showMsg2($("#styleInfo .msg"), "保存成功", 2000);
|
||||
}, this);
|
||||
});
|
||||
$("input[name='Style']").click(function() {
|
||||
$("#styleLink").attr("href", "/css/blog/" + $(this).val() + ".css");
|
||||
});
|
||||
});
|
||||
|
||||
function inProgress() {
|
||||
}
|
||||
|
||||
// filename, result, resultCode
|
||||
function uploadFinish(ret) {
|
||||
if (ret) {
|
||||
if (ret.resultCode == '1') {
|
||||
$("#logoImg img").attr("src", ret.filename).parent().show();
|
||||
$("#Logo").val(ret.filename);
|
||||
return;
|
||||
}
|
||||
alert(ret.result);
|
||||
return;
|
||||
}
|
||||
// 上传出错
|
||||
alert("上传出错");
|
||||
}
|
||||
|
||||
function submit() {
|
||||
var tpl = '<form action="/blog/setBlog" method="post"><input name="Title" value="?" />';
|
||||
tpl += '<input name="SubTitle" value="?" />';
|
||||
tpl += '<input name="Logo" value="?" />';
|
||||
tpl += '<input name="CanComment" value="?" />';
|
||||
tpl += '<input name="DisqusId" value="?" />';
|
||||
tpl += '<input name="Style" value="?" />';
|
||||
tpl += '<textarea name="AboutMe">?</textarea>';
|
||||
tpl += "</form";
|
||||
var data = {
|
||||
Title : $("#Title").val(),
|
||||
SubTitle : $("#SubTitle").val(),
|
||||
Logo : $("#Logo").val(),
|
||||
AboutMe : getEditorContent(),
|
||||
CanComment : $("#CanComment").is(":checked"),
|
||||
DisqusId : $("#DisqusId").val(),
|
||||
Style : $("input[name='Style']:checked").val()
|
||||
}
|
||||
if (!data.DisqusId) {
|
||||
data.DisqusId = "leanote";
|
||||
}
|
||||
$(t(tpl, data.Title, data.SubTitle, data.Logo,
|
||||
data.CanComment, data.DisqusId, data.Style,
|
||||
data.AboutMe)).submit();
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
139
app/views/Blog/view.html
Normal file
139
app/views/Blog/view.html
Normal file
@@ -0,0 +1,139 @@
|
||||
{{template "Blog/header.html" .}}
|
||||
|
||||
<!-- -->
|
||||
<div id="postsContainer">
|
||||
<div id="posts">
|
||||
<div class="each-post">
|
||||
<div class="title">
|
||||
{{.blog.Title}}
|
||||
</div>
|
||||
<div class="created-time">
|
||||
<i class="fa fa-bookmark-o" style="color: #666"></i>
|
||||
{{if .blog.Tags}}
|
||||
{{blogTags .blog.Tags}}
|
||||
{{else}}
|
||||
无
|
||||
{{end}}
|
||||
|
|
||||
<i class="fa fa-calendar" style="color: #666"></i> 更新 {{.blog.UpdatedTime | datetime}} |
|
||||
<i class="fa fa-calendar" style="color: #666"></i> 创建 {{.blog.CreatedTime | datetime}}
|
||||
</div>
|
||||
|
||||
<div class="desc" id="content">
|
||||
{{if .blog.IsMarkdown }}
|
||||
<div id="markdownContent" style="display: none">
|
||||
<!-- 用textarea装html, 防止得到的值失真 -->
|
||||
<textarea>
|
||||
{{.blog.Content | raw}}
|
||||
</textarea>
|
||||
</div>
|
||||
<div style="padding: 20px; text-align: center">
|
||||
<img src="/images/loading-32.gif" />
|
||||
</div>
|
||||
{{else}}
|
||||
{{.blog.Content | raw}}
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<!-- comment -->
|
||||
{{template "blog/comment.html" .}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{template "Blog/footer.html" .}}
|
||||
{{template "Blog/highlight.html"}}
|
||||
|
||||
<!-- Nav -->
|
||||
<style>
|
||||
#blogNav {
|
||||
display: none;
|
||||
background-color: #fff;
|
||||
opacity: 0.7;
|
||||
position: fixed;
|
||||
z-index: 10;
|
||||
padding: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
#blogNavContent {
|
||||
overflow-y: auto;
|
||||
max-height: 250px;
|
||||
display: none;
|
||||
}
|
||||
#blogNavNav {
|
||||
cursor: pointer;
|
||||
}
|
||||
#blogNav a {
|
||||
color: #666;
|
||||
}
|
||||
#blogNav:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
#blogNav a:hover {
|
||||
color: #0fb264;
|
||||
}
|
||||
#blogNav ul {
|
||||
padding-left: 20px;
|
||||
}
|
||||
#blogNav ul .nav-h1 {
|
||||
}
|
||||
#blogNav ul .nav-h2 {
|
||||
margin-left: 20px;
|
||||
}
|
||||
#blogNav ul .nav-h3 {
|
||||
margin-left: 30px;
|
||||
}
|
||||
#blogNav ul .nav-h4 {
|
||||
margin-left: 40px;
|
||||
}
|
||||
#blogNav ul .nav-h5 {
|
||||
margin-left: 50px;
|
||||
}
|
||||
</style>
|
||||
<div id="blogNav">
|
||||
<div id="blogNavNav">
|
||||
<i class="fa fa-align-justify" title="文档导航"></i>
|
||||
<span>{{msg . "nav"}}</span>
|
||||
</div>
|
||||
<div id="blogNavContent" style="max-width: 200px">
|
||||
</div>
|
||||
</div>
|
||||
<script src="/public/js/app/blog/nav.js"></script>
|
||||
|
||||
{{if .blog.IsMarkdown }}
|
||||
<script src="/public/mdeditor/editor/google-code-prettify/prettify.js"></script>
|
||||
<script src="/public/mdeditor/editor/pagedown/Markdown.Converter.js"></script>
|
||||
<script src="/public/mdeditor/editor/pagedown/Markdown.Sanitizer.js"></script>
|
||||
<script src="/public/mdeditor/editor/pagedown/Markdown.Editor.js"></script>
|
||||
<script src="/public/mdeditor/editor/pagedown/local/Markdown.local.zh.js"></script>
|
||||
<script src="/public/mdeditor/editor/Markdown.Extra.js"></script>
|
||||
|
||||
<!--mathjax-->
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ["\\(","\\)"]], processEscapes: true }, messageStyle: "none"});
|
||||
</script>
|
||||
<script src="/public/mdeditor/editor/mathJax.js"></script>
|
||||
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script>
|
||||
var content = $.trim($("#markdownContent textarea").val());
|
||||
|
||||
// $("#markdownContent").html("");
|
||||
var converter = Markdown.getSanitizingConverter();
|
||||
Markdown.Extra.init(converter, {extensions: ["tables", "fenced_code_gfm", "def_list"]});
|
||||
var html = converter.makeHtml(content);
|
||||
$("#content").html(html);
|
||||
$("pre").addClass("prettyprint linenums");
|
||||
prettyPrint();
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"wmd-preview"]);
|
||||
|
||||
initNav();
|
||||
</script>
|
||||
{{else}}
|
||||
<script>
|
||||
$(function() {
|
||||
initNav();
|
||||
});
|
||||
</script>
|
||||
{{end}}
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user