updage docs

This commit is contained in:
deepzz0 committed 2017-07-13 21:23:28 +08:00
1 parent d8f0e30285
commit b94fc825b3
7 files changed
+44 -57

No files matched your search

+2 -1
View File
@@ -1,11 +1,12 @@
# Eiblog Changelog
## v1.3.0 (暂定)
## v1.3.0 (2017-07-13)
* 更改 app.yml 配置项,将大部分配置归在 general 常规配置下。注意,部署时请先更新 app.yml。
* 静态文件采用动态渲染,即用户不再需要管理 view、static 目录。
* 通过 acme.sh 使用双证书啦,可到 Makefile 查看相关信息。
* 使用 autocert 自动生成证书功能,从此再也不用担心证书过期,移步 [证书更新](https://github.com/eiblog/eiblog/blob/master/docs/autocert.md)。
* 开启配置项 enablehttps, 将自动重定向 http 到 https 啦。
* disqus.js 文件由配置指定,请看 app.yml 下的 disqus 相关配置。
## v1.2.0 (2017-06-14)
* 更新评论功能,基础评论 0 回复也可评论了。
+3
View File
@@ -42,6 +42,9 @@ disqus:
postslist: https://disqus.com/api/3.0/threads/listPosts.json
postcreate: https://disqus.com/api/3.0/posts/create.json
postapprove: https://disqus.com/api/3.0/posts/approve.json
# disqus.js 文件名
embed: disqus_7d3cf2.js
# 获取评论数量间隔
interval: 5
# 谷歌统计
google:
+11 -5
View File
@@ -6,8 +6,14 @@
* [acme.sh](https://github.com/Neilpang/acme.sh),强大的 acme 脚本,多种自动更新证书方式,满足你各方面的需求。双证书
#### 方式一
什么是 autocert,简单点,你只需要两步操作:
一键开启 autocert 功能,修改 `conf/app.yml` 文件内容:
1. 将域名解析到你的服务器。
2. 在服务器上运行开启 autocert 功能的程序(这里不需要配置证书),需要占用 443 端口。
其它过程你不需要过问,即会完成自动申请证书,自动更新证书的功能(默认 30 天)。这个是在 tcp/ip 层的操作,对用户完全透明,非常棒。
一键开启 autocert 功能,只需修改 `conf/app.yml` 文件内容:
```
# 运行模式
@@ -19,9 +25,9 @@ mode:
enablehttps: true # 必须开启
autocert: false # autocert 功能开关
httpsport: 9001
certfile: conf/ssl/domain.rsa.pem
keyfile: conf/ssl/domain.rsa.key
domain: deepzz.com
certfile:
keyfile:
domain: deepzz.com # 申请证书的域名,也是博客的域名
```
首先,使用 HTTPS 必须启用 `enablehttps`,它有两个作用:
@@ -60,4 +66,4 @@ export Ali_Secret="jlsdflanljkljlfdsaklkjflsa"
```
$ make gencert -cn=common_name -sans="-d example.com -d example1.com"
```
```
+17 -41
View File
@@ -86,13 +86,14 @@ $ docker run -d --name eisearch \
#### 文件准备
博主是一个有强迫症的人,一些文件的路径我使用了固定的路径,请大家见谅。假如你的 cdn 域名为 `st.example.com`,你需要确定这些文件已经在你的 cdn 中,它们路径分别是:
* `favicon.ico`,默认为 `st.example.com/static/img/favicon.ico`。故你在 cdn 中的文件名为 `static/img/favicon.ico`,以下如是。
* 你还可以将 favicon.ico 复制到 static 文件夹下,这样通过 `https://example.com/favicon.ico` 也是能够访问的。docker 用户需要自行重新打包镜像。
* `bg04.jpg`,左侧背景图片,`500*1200` 左右,cdn 文件名:`static/img/bg04.jpg`。如需更改,请在 `eiblog/view/st_blog.css` 中替换该名称。
* `avatar.jpg`,左侧头像,`160*160~256*256`之间,cdn 文件名:`static/img/avatar.jpg`。
* `blank.gif`,cdn 文件名:`static/img/blank.gif`。该图片请从 [这里](https://st.deepzz.com/static/img/blank.gif) 下载并上传至你的 cdn。
* `default_avatar.png`,Disqus 默认头像,cdn 文件名:`static/img/default_avatar.png`,请从 [这里](https://st.deepzz.com/static/img/default_avatar.png) 下载并上传至你的 cdn。
* `disqus.js`,该文件是专属的,通过 https://short_name.disqus.com/embed.js 下载,替换掉 short_name。,cdn 文件名格式是:`static/js/disqus_xxx.js`。在我写这篇文章是使用的是:`static/js/disqus_a9d3fd.js`。另外修改 `eiblog/views/st_blog.js` 中的`disqus_a9d3fd.js` 为你新文件的名称,提升一个静态文件版本(请看配置文件说明)。
| 文件 | 地址 | 描述 |
| ------------------ | ---------------------------------------- | ---------------------------------------- |
| favicon.ico | st.example.com/static/img/favicon.ico | cdn 中的文件名为 `static/img/favicon.ico`。你也可以复制 favicon.ico 到 static 文件夹下,通过 example.com/favicon.ico 也是能够访问到。docker 用户可能需要重新打包镜像。 |
| bg04.jpg | st.example.com/static/img/bg04.jpg | 首页左侧的大背景图,需要更名请到 views/st_blog.css 修改。 |
| avatar.jpg | st.example.com/static/img/avatar.jpg | 头像 |
| blank.gif | st.example.com/static/img/blank.gif | 空白图片,[下载](https://st.deepzz.com/static/img/blank.gif) |
| default_avatar.png | st.example.com/static/img/default_avatar.png | disqus 默认图片,[下载](https://st.deepzz.com/static/img/default_avatar.png) |
| disqus.js | st.example.com/static/js/disqus_xxx.js | disqus 文件,你可以通过 https://short_name.disqus.com/embed.js 下载你的专属文件,并上传到七牛。更新配置文件 app.yml。 |
> 注意:每次修改 views 内的以 `st_` 开头的文件,请将 `app.yml` 中的 staticversion 提高一个版本。 cdn 提到的文件下载,请复制链接进行下载,因为博主使用了防盗链功能。
@@ -136,40 +137,15 @@ $ docker run -d --name eisearch \
├── robotsTpl.xml
└── sitemapTpl.xml
```
1、app.yml,整个程序的配置文件,里面已经列出了所有配置项的说明,这里不再阐述。
2、blackip.yml,如果没有使用 `Nginx`,博客内置 `ip` 过滤系统。
3、`es` 全名 `elasticsearch`,非常强大的分布式搜索引擎,`github` 用的就是它。里面的配置基本不用修改,但 `es/analysis/synonym.txt` 是同义词,你可以照着已有的随意增加。
```
├── es
│   ├── config
│   │   ├── analysis
│   │   │   └── synonym.txt # 同义词配置
│   │   ├── elasticsearch.yml # 分词器配置
│   │   ├── logging.yml # 日志配置
│   │   └── scripts # 脚本
│   └── plugins # 中文分词插件
│   └── ik1.10.0
│
```
> `注意`,scripts 文件夹虽然是空的,但必需存在,不然 elasticsearch 报错。
4、`nginx`,系统采用 `nginx` 作为代理(相信博客系统也不会独占一台服务器~)。请使用 `nginx.conf` 替换原 `nginx` 的配置。博客系统的配置文件是 `domain/eiblog.conf`,或则重命名(只要是满足`*.conf`)。`eiblog.conf`文件里面学问是最多的。或许你想一一弄懂,或许…。
> 注意本配置需要更新 nginx 到最新版,openssl 更新到1.0.2j,具体请到 Jerry Qu 的 [本博客 Nginx 配置之完整篇](https://imququ.com/post/my-nginx-conf.html) 查看,了解详情。
5、`scts`,存放 ct 文件。
6、`ssl`,这里存放了所有证书相关的内容。
```
├── dhparams.pem # 参见eiblog/conf/nginx/domain/deepzz.conf
├── domain.key # 证书私钥,一般颁发者处下载
├── domain.pem # 证书链,一般从证书颁发者那可以直接下载到
├── full_chained.pem # 参见eiblog/conf/nginx/domain/deepzz.conf
└── session_ticket.key # 参见eiblog/conf/nginx/domain/deepzz.conf
```
7、`tpl` 模版相关,不用修改。
| 名称 | 描述 |
| ----------- | ---------------------------------------- |
| app.yml | 整个程序的配置文件,里面已经列出了所有配置项的说明,这里不再阐述。 |
| blackip.yml | 如果没有使用 `Nginx`,博客内置 `ip` 过滤系统。 |
| es | elasticsearch,非常强大的分布式搜索引擎,`github` 用的就是它。里面的配置基本不用修改,但 `es/analysis/synonym.txt` 是同义词,你可以照着已有的随意增加。注意,scripts 虽然是空的,但请保持存在。 |
| nginx | 系统采用 `nginx` 作为代理(相信博客系统也不会独占一台服务器~)。请使用 `nginx.conf` 替换原 `nginx` 的配置。博客系统的配置文件是 `domain/eiblog.conf`,或则重命名(只要是满足`*.conf`)。`eiblog.conf`文件里面学问是最多的。或许你想一一弄懂,或许…。注意本配置需要更新 nginx 到最新版,openssl 更新到1.0.2j,具体请到 Jerry Qu 的 [本博客 Nginx 配置之完整篇](https://imququ.com/post/my-nginx-conf.html) 查看,了解详情。 |
| scts | 存放 ct 文件。 |
| ssl | 这里存放了所有证书相关的内容。 |
| tpl | 模版相关,不用修改。 |
### 开始部署
+9 -9
View File
@@ -79,15 +79,15 @@ func StaticVersion(c *gin.Context) (version int) {
func GetBase() gin.H {
return gin.H{
"BlogName": Ei.BlogName,
"SubTitle": Ei.SubTitle,
"Twitter": setting.Conf.Twitter,
"CopyYear": time.Now().Year(),
"BTitle": Ei.BTitle,
"BeiAn": Ei.BeiAn,
"Domain": setting.Conf.Mode.Domain,
"Kodo": setting.Conf.Kodo,
"ShortName": setting.Conf.Disqus.ShortName,
"BlogName": Ei.BlogName,
"SubTitle": Ei.SubTitle,
"Twitter": setting.Conf.Twitter,
"CopyYear": time.Now().Year(),
"BTitle": Ei.BTitle,
"BeiAn": Ei.BeiAn,
"Domain": setting.Conf.Mode.Domain,
"Kodo": setting.Conf.Kodo,
"Disqus": setting.Conf.Disqus,
}
}
+1
View File
@@ -42,6 +42,7 @@ type Config struct {
PostsList string
PostCreate string
PostApprove string
Embed string
Interval int
}
Google struct { // 谷歌统计
+1 -1
View File
@@ -1,3 +1,3 @@
{{define "blog_js"}}
var stringProto=String.prototype;stringProto.stripTags=function(){return this.replace(/<[^>]*>/gi,"")},stringProto.decode4Html=function(){var t=document.createElement("div");return t.innerHTML=this.stripTags(),t.childNodes[0]?t.childNodes[0].nodeValue||"":""},stringProto.queryUrl=function(t){var a=this.replace(/^[^?=]*\?/gi,"").split("#")[0],e={};return a.replace(/(^|&)([^&=]+)=([^&]*)/g,function(t,a,n,i){try{n=decodeURIComponent(n)}catch(o){}try{i=decodeURIComponent(i)}catch(o){}n in e?e[n] instanceof Array?e[n].push(i):e[n]=[e[n],i]:e[n]=/\[\]$/.test(n)?[i]:i}),t?e[t]:e},function(t){t.disqus_shortname="{{.ShortName}}",$.each(["CURRENT_PAGE","CDN_DOMAIN"],function(a,e){t[e]="";var n=$("#"+e);n&&(t[e]=n.val())})}(this),function(t){function a(a){var e,n,i={selector:null,height:200};i=$.extend(i,a),e=i.height,n=function(){var a=$(t).scrollTop(),n=$(t).height()+a;$(i.selector).find("img[data-src]").each(function(){var t=$(this);setTimeout(function(){var i,o=t.offset(),s=t.height();o.top>n+e||o.top+s<a-e||(i=t.data("src"),i&&(t.on("load",function(){t.addClass("loaded")}),t.attr("src",i),t.removeAttr("data-src")))},0)})},$(t).on("resize",n),$(t).on("scroll",n),n()}t.lazyLoad=a}(this),function(t){$(function(){$(".entry-content pre").each(function(t){var a,e,n,i=$(this),o=i.find("code");if(o.length&&o.prop("className")&&(o.hasClass("language-html")&&(a="__HTML_CODE_"+t,o.prop("id",a),e=$('<input data-id="'+a+'" type="button" class="runcode" value="在新窗口运行以上代码" />'),e.insertAfter(i)),o.html().split("\n").length>3&&o.prop("className").indexOf("language")>-1)){switch(n=o.prop("className").replace("language-","").toUpperCase()){case"XML":n="HTML";break;case"SHELL":n="BASH"}$('<b class="name">'+n+"</a>").insertBefore(o)}}),$(".entry-content input.runcode").each(function(){var a=$(this);a.click(function(a){var e,n,i;a.preventDefault(),e=$("#"+$(this).data("id")).html().stripTags().decode4Html(),n=t.open("","_preview",""),i=n.document,i.open(),i.write(e),i.close()})}),$(".entry-content > pre code").each(function(i,block){hljs.highlightBlock(block)})})}(this),function(){$(function(){$(".entry-content img[data-replace]").each(function(){var t=$(this);t.click(function(){var a,e,n,i,o=1000*(t.data("dur")||20);t.css("cursor")&&(a="/static/img/blank.gif",e=t.prop("src"),n=t.data("replace"),t.prop("src",a),t.css("cursor",""),i=new Image,i.onload=function(){t.prop("src",n),setTimeout(function(){t.prop("src",e),t.css("cursor","pointer")},o)},i.src=n)}),t.css("cursor","pointer")})})}(this),function(t){var a=function(){var e=[],n="comment_type",i=function(){if(!t.atob){return 1}try{t.postMessage("ping","*")}catch(a){return 2}return 0};return{addService:function(t){e.push(t)},clear:function(){localStorage.removeItem(n)},init:function(t){var o,r,s,c;return e.length?t.length?(o=t.data("url")||location.href,r=t.data("identifier"),o&&r?i()?void t.html("很抱歉,本站评论功能只支持这些浏览器:Chrome、Firefox、Safari、Opera、Edge、IE11+。"):(s=function(i){var c,l=e[i];l&&(c=$("<div>").prop("id",l.id),t.append(c),l.init(c,o,r),l.check(function(t){t?(c.hide(),s(++i)):(l.load(),localStorage[n]=i,a.currentServer=l)},c,o,r))},c=0,localStorage.comment_type&&(c=parseInt(localStorage[n],10)||0),c=Math.min(e.length-1,c),c=Math.max(c,0),void s(c)):void alert("没有找到评论所需标记!")):void alert("没有找到评论容器!"):void alert("没有找到可用的服务!")}}}();t.TotalThread=a}(this),function(t){var a=function(){var a=!1;return{id:"disqus_thread",check:function(a){var e,n,i=["https://c.disquscdn.com/favicon.ico","https://disqus.com/favicon.ico"],o=0,r=0,s=function(){o==i.length&&a(r==o?0:1)};for(t.__disqus_img=[],e=function(a){var e=new Image,n=setTimeout(function(){e.onerror=e.onload=null,o++,s()},2500);e.onerror=function(){clearTimeout(n),o++,s()},e.onload=function(){clearTimeout(n),o++,r++,s()},e.src=i[a]+"?"+ +new Date,t.__disqus_img[a]=e},n=0;n<i.length;n++){e(n)}},load:function(){if(!a){a=!0;var e=this;t.disqus_config=function(){this.page.url=e.url,this.page.identifier=e.identifier},$.ajax({url:t.CDN_DOMAIN+"/static/js/disqus_7d3cf2.js",dataType:"script",cache:!0})}},init:function(t,a,e){t.html("评论完整模式加载中...<br /><br />注:如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理。"),this.elThread=t,this.url=a,this.identifier=e}}}();t.TotalThread.addService(a)}(this),function(t){var a=function(){var e=!1,n=function(e,n){var i,o,r=!1,s="",c=function(a){var e='<li class="post '+(a.isDeleted?"minimized":"")+'" id="post-'+a.id+'"><div class="post-content clearfix"><div class="indicator"></div><div class="avatar"><div class="user">'+(a.url?'<a href="'+a.url+'"><img data-src="'+a.avatar+'" /></a>':'<img data-src="'+t.CDN_DOMAIN+'/static/img/default_avatar.png" />')+'</div></div><div class="post-body"><header class="post-header"><span class="post-byline"><span class="author publisher-anchor-color">'+(a.url?'<a href="'+a.url+'">'+aLine truncated
var stringProto=String.prototype;stringProto.stripTags=function(){return this.replace(/<[^>]*>/gi,"")},stringProto.decode4Html=function(){var t=document.createElement("div");return t.innerHTML=this.stripTags(),t.childNodes[0]?t.childNodes[0].nodeValue||"":""},stringProto.queryUrl=function(t){var a=this.replace(/^[^?=]*\?/gi,"").split("#")[0],e={};return a.replace(/(^|&)([^&=]+)=([^&]*)/g,function(t,a,n,i){try{n=decodeURIComponent(n)}catch(o){}try{i=decodeURIComponent(i)}catch(o){}n in e?e[n] instanceof Array?e[n].push(i):e[n]=[e[n],i]:e[n]=/\[\]$/.test(n)?[i]:i}),t?e[t]:e},function(t){t.disqus_shortname="{{.Disqus.ShortName}}",$.each(["CURRENT_PAGE","CDN_DOMAIN"],function(a,e){t[e]="";var n=$("#"+e);n&&(t[e]=n.val())})}(this),function(t){function a(a){var e,n,i={selector:null,height:200};i=$.extend(i,a),e=i.height,n=function(){var a=$(t).scrollTop(),n=$(t).height()+a;$(i.selector).find("img[data-src]").each(function(){var t=$(this);setTimeout(function(){var i,o=t.offset(),s=t.height();o.top>n+e||o.top+s<a-e||(i=t.data("src"),i&&(t.on("load",function(){t.addClass("loaded")}),t.attr("src",i),t.removeAttr("data-src")))},0)})},$(t).on("resize",n),$(t).on("scroll",n),n()}t.lazyLoad=a}(this),function(t){$(function(){$(".entry-content pre").each(function(t){var a,e,n,i=$(this),o=i.find("code");if(o.length&&o.prop("className")&&(o.hasClass("language-html")&&(a="__HTML_CODE_"+t,o.prop("id",a),e=$('<input data-id="'+a+'" type="button" class="runcode" value="在新窗口运行以上代码" />'),e.insertAfter(i)),o.html().split("\n").length>3&&o.prop("className").indexOf("language")>-1)){switch(n=o.prop("className").replace("language-","").toUpperCase()){case"XML":n="HTML";break;case"SHELL":n="BASH"}$('<b class="name">'+n+"</a>").insertBefore(o)}}),$(".entry-content input.runcode").each(function(){var a=$(this);a.click(function(a){var e,n,i;a.preventDefault(),e=$("#"+$(this).data("id")).html().stripTags().decode4Html(),n=t.open("","_preview",""),i=n.document,i.open(),i.write(e),i.close()})}),$(".entry-content > pre code").each(function(i,block){hljs.highlightBlock(block)})})}(this),function(){$(function(){$(".entry-content img[data-replace]").each(function(){var t=$(this);t.click(function(){var a,e,n,i,o=1000*(t.data("dur")||20);t.css("cursor")&&(a="/static/img/blank.gif",e=t.prop("src"),n=t.data("replace"),t.prop("src",a),t.css("cursor",""),i=new Image,i.onload=function(){t.prop("src",n),setTimeout(function(){t.prop("src",e),t.css("cursor","pointer")},o)},i.src=n)}),t.css("cursor","pointer")})})}(this),function(t){var a=function(){var e=[],n="comment_type",i=function(){if(!t.atob){return 1}try{t.postMessage("ping","*")}catch(a){return 2}return 0};return{addService:function(t){e.push(t)},clear:function(){localStorage.removeItem(n)},init:function(t){var o,r,s,c;return e.length?t.length?(o=t.data("url")||location.href,r=t.data("identifier"),o&&r?i()?void t.html("很抱歉,本站评论功能只支持这些浏览器:Chrome、Firefox、Safari、Opera、Edge、IE11+。"):(s=function(i){var c,l=e[i];l&&(c=$("<div>").prop("id",l.id),t.append(c),l.init(c,o,r),l.check(function(t){t?(c.hide(),s(++i)):(l.load(),localStorage[n]=i,a.currentServer=l)},c,o,r))},c=0,localStorage.comment_type&&(c=parseInt(localStorage[n],10)||0),c=Math.min(e.length-1,c),c=Math.max(c,0),void s(c)):void alert("没有找到评论所需标记!")):void alert("没有找到评论容器!"):void alert("没有找到可用的服务!")}}}();t.TotalThread=a}(this),function(t){var a=function(){var a=!1;return{id:"disqus_thread",check:function(a){var e,n,i=["https://c.disquscdn.com/favicon.ico","https://disqus.com/favicon.ico"],o=0,r=0,s=function(){o==i.length&&a(r==o?0:1)};for(t.__disqus_img=[],e=function(a){var e=new Image,n=setTimeout(function(){e.onerror=e.onload=null,o++,s()},2500);e.onerror=function(){clearTimeout(n),o++,s()},e.onload=function(){clearTimeout(n),o++,r++,s()},e.src=i[a]+"?"+ +new Date,t.__disqus_img[a]=e},n=0;n<i.length;n++){e(n)}},load:function(){if(!a){a=!0;var e=this;t.disqus_config=function(){this.page.url=e.url,this.page.identifier=e.identifier},$.ajax({url:t.CDN_DOMAIN+"/static/js/{{.Disqus.Embed}}",dataType:"script",cache:!0})}},init:function(t,a,e){t.html("评论完整模式加载中...<br /><br />注:如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理。"),this.elThread=t,this.url=a,this.identifier=e}}}();t.TotalThread.addService(a)}(this),function(t){var a=function(){var e=!1,n=function(e,n){var i,o,r=!1,s="",c=function(a){var e='<li class="post '+(a.isDeleted?"minimized":"")+'" id="post-'+a.id+'"><div class="post-content clearfix"><div class="indicator"></div><div class="avatar"><div class="user">'+(a.url?'<a href="'+a.url+'"><img data-src="'+a.avatar+'" /></a>':'<img data-src="'+t.CDN_DOMAIN+'/static/img/default_avatar.png" />')+'</div></div><div class="post-body"><header class="post-header"><span class="post-byline"><span class="author publisher-anchor-color">'+(a.url?'<a href="'+a.urLine truncated
{{end}}