This commit is contained in:
deepzz0
2016-10-02 00:11:15 +08:00
parent ddf508825c
commit ead9533be3
34 changed files with 359 additions and 181 deletions

View File

@@ -1,13 +1,15 @@
FROM ubuntu:trusty FROM ubuntu:trusty
MAINTAINER deepzz <deepzz.qi@gmail.com> MAINTAINER deepzz <deepzz.qi@gmail.com>
RUN apt-get update
RUN apt-get install -y ca-certificates
ADD conf /eiblog/conf ADD conf /eiblog/conf
ADD static /eiblog/static ADD static /eiblog/static
ADD views /eiblog/views ADD views /eiblog/views
ADD eiblog /eiblog/eiblog ADD eiblog /eiblog/eiblog
EXPOSE 80 EXPOSE 9000
EXPOSE 443
WORKDIR /eiblog WORKDIR /eiblog
ENTRYPOINT ["./eiblog"] ENTRYPOINT ["./eiblog"]

View File

@@ -1,7 +1,7 @@
# 静态文件版本 # 静态文件版本
staticversion: 2 staticversion: 2
# 运行模式 dev or prod # 运行模式 dev or prod
runmode: dev runmode: prod
# 回收箱保留48小时 # 回收箱保留48小时
trash: -48 trash: -48
# 定时清理回收箱,%d小时 # 定时清理回收箱,%d小时
@@ -15,11 +15,11 @@ length: 200
# 截取预览标识 # 截取预览标识
identifier: <!-- more --> identifier: <!-- more -->
# favicon # favicon
favicon: //st.deepzz.com/static/img/favicon.png favicon: //st.deepzz.com/static/img/favicon.ico
# 起始ID预留id不时之需, 不用管 # 起始ID预留id不时之需, 不用管
startid: 11 startid: 11
# 静态文件地址, 后台js,css在用, cdn: //domain.com # 静态文件地址, 后台js,css在用, cdn: //domain.com
static: //127.0.0.1:8080 static: //deepzz.com
# elasticsearch url # elasticsearch url
searchurl: http://elasticsearch:9200 searchurl: http://elasticsearch:9200
# 评论相关 # 评论相关
@@ -33,13 +33,13 @@ modes:
dev: dev:
# don't modify # don't modify
enablehttp: true enablehttp: true
httpport: 8080 httpport: 9000
domain: 127.0.0.1:8080 domain: deepzz.com
prod: prod:
# you can fix certfile, keyfile, domain # you can fix certfile, keyfile, domain
enablehttp: true enablehttp: true
httpport: 80 httpport: 9000
enablehttps: true enablehttps: false
httpsport: 443 httpsport: 443
certfile: conf/certs/domain.pem certfile: conf/certs/domain.pem
keyfile: conf/certs/domain.key keyfile: conf/certs/domain.key

View File

@@ -4,24 +4,25 @@ server {
server_name www.deepzz.com deepzz.com; server_name www.deepzz.com deepzz.com;
server_tokens off; server_tokens off;
include /data/eiblog/nginx/ip.blacklist; include /data/eiblog/conf/nginx/ip.blacklist;
# 现在一般证书是内置的。可以注释该项
# https://imququ.com/post/certificate-transparency.html#toc-2 # https://imququ.com/post/certificate-transparency.html#toc-2
# ssl_ct on; # ssl_ct on;
# ssl_ct_static_scts /home/jerry/www/scts; # ssl_ct_static_scts /data/eiblog/conf/scts;
# 中间证书 + 站点证书 # 中间证书 + 站点证书
ssl_certificate /data/eiblog/conf/certs/chained.pem; ssl_certificate /data/eiblog/conf/ssl/domain.pem;
# 创建 CSR 文件时用的密钥 # 创建 CSR 文件时用的密钥
ssl_certificate_key /data/eiblog/conf/certs/domain.key; ssl_certificate_key /data/eiblog/conf/ssl/domain.key;
# openssl dhparam -out dhparams.pem 2048 # openssl dhparam -out dhparams.pem 2048
# https://weakdh.org/sysadmin.html # https://weakdh.org/sysadmin.html
ssl_dhparam /data/eiblog/conf/ssl/dhparams.pem; ssl_dhparam /data/eiblog/conf/ssl/dhparams.pem;
# https://github.com/cloudflare/sslconfig/blob/master/conf # https://github.com/cloudflare/sslconfig/blob/master/conf
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
# 如果启用了 RSA + ECDSA 双证书Cipher Suite 可以参考以下配置: # 如果启用了 RSA + ECDSA 双证书Cipher Suite 可以参考以下配置:
# ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5; # ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5;
@@ -37,19 +38,19 @@ server {
# openssl rand 48 > session_ticket.key # openssl rand 48 > session_ticket.key
# 单机部署可以不指定 ssl_session_ticket_key # 单机部署可以不指定 ssl_session_ticket_key
ssl_session_ticket_key /data/eiblog/conf/ssl/session_ticket.key; # ssl_session_ticket_key /data/eiblog/conf/ssl/session_ticket.key;
ssl_stapling on; ssl_stapling on;
ssl_stapling_verify on; ssl_stapling_verify on;
# 根证书 + 中间证书 # 根证书 + 中间证书
# https://imququ.com/post/why-can-not-turn-on-ocsp-stapling.html # https://imququ.com/post/why-can-not-turn-on-ocsp-stapling.html
# ssl_trusted_certificate /home/jerry/www/ssl/full_chained.pem; # ssl_trusted_certificate /data/eiblog/conf/ssl/full_chained.pem;
resolver 114.114.114.114 valid=300s; resolver 114.114.114.114 valid=300s;
resolver_timeout 10s; resolver_timeout 10s;
access_log /data/eiblog/log/nginx.log; access_log /data/eiblog/logdata/nginx.log;
if ($request_method !~ ^(GET|HEAD|POST|OPTIONS)$ ) { if ($request_method !~ ^(GET|HEAD|POST|OPTIONS)$ ) {
return 444; return 444;
@@ -59,8 +60,9 @@ server {
rewrite ^/(.*)$ https://deepzz.com/$1 permanent; rewrite ^/(.*)$ https://deepzz.com/$1 permanent;
} }
# webmaster 站点验证相关
location ~* (robots\.txt|favicon\.ico|crossdomain\.xml|google4c90d18e696bdcf8\.html|BingSiteAuth\.xml)$ { location ~* (robots\.txt|favicon\.ico|crossdomain\.xml|google4c90d18e696bdcf8\.html|BingSiteAuth\.xml)$ {
root /home/jerry/www/imququ.com/www/static; root /data/eiblog/static;
expires 1d; expires 1d;
} }
@@ -80,7 +82,7 @@ server {
} }
location ^~ /static/ { location ^~ /static/ {
root /home/jerry/www/imququ.com/www; root /data/eiblog;
add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Origin *;
expires max; expires max;
} }
@@ -96,13 +98,14 @@ server {
add_header X-Content-Type-Options nosniff; add_header X-Content-Type-Options nosniff;
proxy_set_header X-Via QingDao.Aliyun; # proxy_set_header X-Via QingDao.Aliyun;
proxy_set_header Connection ""; proxy_set_header Connection "";
proxy_set_header Host imququ.com; proxy_set_header Host deepzz.com;
proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-XSS-Protection 1; mode=block;
proxy_pass http://127.0.0.1:9095; proxy_pass http://127.0.0.1:9000;
} }
location / { location / {
@@ -111,8 +114,11 @@ server {
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
add_header X-Frame-Options deny; add_header X-Frame-Options deny;
add_header X-Content-Type-Options nosniff; add_header X-Content-Type-Options nosniff;
add_header Content-Security-Policy "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; img-src data: https: http://ip.qgy18.com; style-src 'unsafe-inline' https:; child-src https:; connect-src 'self' https://translate.googleapis.com; frame-src https://disqus.com https://www.slideshare.net"; # 改deepzz相关的
add_header Public-Key-Pins 'pin-sha256="YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg="; pin-sha256="aef6IF2UF6jNEwA2pNmP7kpgT6NFSdt7Tqf5HzaIGWI="; max-age=2592000; includeSubDomains'; add_header Content-Security-Policy "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; img-src data: https: https://st.deepzz.com; style-src 'unsafe-inline' https:; child-src https:; connect-src 'self' https://translate.googleapis.com; frame-src https://disqus.com https://www.slideshare.net";
# 中间证书证书指纹
# https://imququ.com/post/http-public-key-pinning.html
add_header Public-Key-Pins 'pin-sha256="JbQbUG5JMJUoI6brnx0x3vZF6jilxsapbXGVfjhN8Fg="; pin-sha256="YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg="; max-age=2592000; includeSubDomains';
add_header Cache-Control no-cache; add_header Cache-Control no-cache;
proxy_ignore_headers Set-Cookie; proxy_ignore_headers Set-Cookie;
@@ -120,13 +126,13 @@ server {
proxy_hide_header Vary; proxy_hide_header Vary;
proxy_hide_header X-Powered-By; proxy_hide_header X-Powered-By;
proxy_set_header X-Via QingDao.Aliyun; # proxy_set_header X-Via QingDao.Aliyun;
proxy_set_header Connection ""; proxy_set_header Connection "";
proxy_set_header Host deepzz.com; proxy_set_header Host deepzz.com;
proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:9095; proxy_pass http://127.0.0.1:9000;
} }
} }
@@ -148,4 +154,29 @@ server {
location / { location / {
rewrite ^/(.*)$ https://deepzz.com/$1 permanent; rewrite ^/(.*)$ https://deepzz.com/$1 permanent;
} }
}
# 原博客,内部做的转发
server {
server_name blog.deepzz.com;
access_log /dev/null;
location / {
rewrite ^/(.*)$ https://blog.deepzz.com/$1 permanent;
}
}
server {
listen 443;
server_name blog.deepzz.com;
add_header Strict-Transport-Security "max-age=31536000";
add_header X-Frame-Options deny;
add_header X-Content-Type-Options nosniff;
add_header X-Xss-Protection "1; mode=block;";
location / {
proxy_pass https://127.0.0.1:9010;
}
} }

0
conf/nginx/ip.blacklist Normal file
View File

View File

@@ -1,95 +1,131 @@
user www-data;
worker_processes 4; #user nobody;
pid /run/nginx.pid; worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events { events {
worker_connections 768; worker_connections 1024;
# multi_accept on;
} }
http { http {
include mime.types;
default_type application/octet-stream;
charset UTF-8;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
## #access_log logs/access.log main;
# Basic Settings
##
sendfile on; sendfile on;
tcp_nopush on; tcp_nopush on;
tcp_nodelay on; tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64; #keepalive_timeout 0;
# server_name_in_redirect off; keepalive_timeout 65;
include /etc/nginx/mime.types; gzip on;
default_type application/octet-stream; gzip_vary on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log; gzip_comp_level 6;
error_log /var/log/nginx/error.log; gzip_buffers 16 8k;
## gzip_min_length 1000;
# Gzip Settings gzip_proxied any;
## gzip_disable "msie6";
gzip on; gzip_http_version 1.0;
gzip_disable "msie6";
gzip_min_length 1000; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules; server {
listen 80;
server_name localhost;
## #charset koi8-r;
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr; #access_log logs/host.access.log main;
#passenger_ruby /usr/bin/ruby;
## location / {
# Virtual Host Configs root html;
## index index.html index.htm;
}
include /etc/nginx/conf.d/*.conf; #error_page 404 /404.html;
include /etc/nginx/sites-enabled/*;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
include /data/eiblog/conf/nginx/domain/*.conf;
} }
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}

BIN
conf/scts/aviator.sct Normal file

Binary file not shown.

BIN
conf/scts/digicert.sct Normal file

Binary file not shown.

8
conf/ssl/dhparams.pem Normal file
View File

@@ -0,0 +1,8 @@
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEAzkJoGFJJGMXQBVIq0DFom7qI3vD7Z8JMQnfCLpoi9AfqW6kGq/bR
FhK9fuRkO+GdzZasx1mSNRQeX8GdaQM4GUn0yel7fxlxNC59mxo++P8NvmxQ47l4
K9QpIRuqxa5UKIG6g3N5pkLwGjcD9a79v4DJn4X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BBQUHAwEGCCsGAQUFBwMCMCkGA1Ud
EQQiMCCkHjAcMRowGAYDVQQDExFTeW1hbnRlY1BLSS0yLTYwMTAdBgNVHQ4EFgQU
bVjHfxrn4T8upoyXNUK79NM4rD8wHwYDVR0jBBgwFoAUf9Nlp8Ld7LvwMAnzQzn6
Aq8zMTMwDQYJKoZIhvcNAQELBQADggEBABUphhBbeG7scE3EveIN0dOjXPgwgQi8
I2ZAKYm6DawoGz1lEJVdvFmkyMbP973X80b7mKmn0nNbe1kjA4M0O0hHaMM1ZaEv
7e9vHEAoGyysMO6HzPWYMkyNxcCV7Nos2Uv4RvLDpQHh7P4Kt6fUU13ipcynrtQD
1lFUM0yoTzwwFsPu3Pk+94hL58ErqwqJQwxoHMgLIQeMVHeNKcWFy1bddSbIbCWU
Zs6cMxhrra062ZCpDCbxyEaFNGAtYQMqNz55Z/14XgSUONZ/cJTns6QKhpcgTOwB
fnNzRnk+aWreP7osKhXlz4zs+llP7goBDKFOMMtoEXx3YjJCKgpqmBU=
-----END CERTIFICATE-----

View File

@@ -0,0 +1 @@
╟░Щ`*dы≤\ЛвH

View File

@@ -3,7 +3,7 @@
<channel> <channel>
<title>{{.Title}}</title> <title>{{.Title}}</title>
<link>{{if .EnableHttps}}https://{{else}}http://{{end}}{{.Domain}}</link> <link>{{if .EnableHttps}}https://{{else}}http://{{end}}{{.Domain}}</link>
<atom:link href="{{if .EnableHttps}}https://{{else}}http://{{end}}{{.Domain}}/feed" rel="self"/> <atom:link href="{{if .EnableHttps}}https://{{else}}http://{{end}}{{.Domain}}/rss.html" rel="self"/>
<description>{{.SubTitle}}</description> <description>{{.SubTitle}}</description>
<language>zh-CN</language> <language>zh-CN</language>
<lastBuildDate>{{.BuildDate}}</lastBuildDate> <lastBuildDate>{{.BuildDate}}</lastBuildDate>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="utf-8" ?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"> <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Deepzz's Blog</ShortName> <ShortName>{{.BTitle}}</ShortName>
<Description>不抛弃,不放弃</Description> <Description>{{.SubTitle}}</Description>
<Url type="text/html" template="https://deepzz.com/search.html?s={searchTerms}" /> <Url type="text/html" template="https://deepzz.com/search.html?q={searchTerms}" />
</OpenSearchDescription> </OpenSearchDescription>

7
db.go
View File

@@ -11,7 +11,6 @@ import (
"time" "time"
"github.com/EiBlog/blackfriday" "github.com/EiBlog/blackfriday"
"github.com/EiBlog/eiblog/helper"
"github.com/EiBlog/eiblog/setting" "github.com/EiBlog/eiblog/setting"
"github.com/EiBlog/utils/logd" "github.com/EiBlog/utils/logd"
db "github.com/EiBlog/utils/mgo" db "github.com/EiBlog/utils/mgo"
@@ -95,7 +94,7 @@ func init() {
// 启动定时器 // 启动定时器
go timer() go timer()
// 获取评论数量 // 获取评论数量
// go CommentsCount() go CommentsCount()
} }
// 读取或初始化帐号信息 // 读取或初始化帐号信息
@@ -106,7 +105,7 @@ func loadAccount() (a *Account) {
if err == mgo.ErrNotFound { if err == mgo.ErrNotFound {
a = &Account{ a = &Account{
Username: setting.Conf.Account.Username, Username: setting.Conf.Account.Username,
Password: helper.EncryptPasswd(setting.Conf.Account.Username, setting.Conf.Account.Password), Password: EncryptPasswd(setting.Conf.Account.Username, setting.Conf.Account.Password),
Email: setting.Conf.Account.Email, Email: setting.Conf.Account.Email,
PhoneN: setting.Conf.Account.PhoneNumber, PhoneN: setting.Conf.Account.PhoneNumber,
Address: setting.Conf.Account.Address, Address: setting.Conf.Account.Address,
@@ -173,7 +172,7 @@ func generateMarkdown() {
buffer.WriteString(serie.Desc) buffer.WriteString(serie.Desc)
buffer.WriteString("\n\n") buffer.WriteString("\n\n")
for _, artc := range serie.Articles { for _, artc := range serie.Articles {
// * [标题一](/post/hello-world.html) <span class="date">(Man 02, 2006)</span> //eg. * [标题一](/post/hello-world.html) <span class="date">(Man 02, 2006)</span>
buffer.WriteString("* [" + artc.Title + "](/post/" + artc.Slug + ".html) <span class=\"date\">(" + artc.CreateTime.Format("Jan 02, 2006") + ")</span>\n") buffer.WriteString("* [" + artc.Title + "](/post/" + artc.Slug + ".html) <span class=\"date\">(" + artc.CreateTime.Format("Jan 02, 2006") + ")</span>\n")
} }
buffer.WriteByte('\n') buffer.WriteByte('\n')

View File

@@ -27,9 +27,9 @@ func CommentsCount() {
return return
} }
baseUrl := setting.Conf.Disqus.URL + "?api_key=" + setting.Conf.Disqus.PublicKey + "&forum=" + setting.Conf.Disqus.ShortName + "&" baseUrl := setting.Conf.Disqus.URL + "?api_key=" + setting.Conf.Disqus.PublicKey + "&forum=" + setting.Conf.Disqus.ShortName + "&"
domain := "http:" + runmode.Domain domain := "http://" + runmode.Domain
if runmode.EnableHttps { if runmode.EnableHttps {
domain = "https:" + runmode.Domain domain = "https://" + runmode.Domain
} }
var count, index int var count, index int
for index < len(Ei.Articles) { for index < len(Ei.Articles) {

View File

@@ -4,7 +4,7 @@ services:
image: mongo:3.2 image: mongo:3.2
container_name: eidb container_name: eidb
volumes: volumes:
- /data/eiblog/db:/data/db - /data/eiblog/mgodb:/data/db
restart: always restart: always
elasticsearch: elasticsearch:
image: elasticsearch:2.4 image: elasticsearch:2.4
@@ -26,11 +26,10 @@ services:
volumes: volumes:
- /data/eiblog/logdata:/eiblog/logdata - /data/eiblog/logdata:/eiblog/logdata
- /data/eiblog/conf:/eiblog/conf - /data/eiblog/conf:/eiblog/conf
- /data/eiblog/static:/eiblog/static
links: links:
- elasticsearch - elasticsearch
- mongodb - mongodb
ports: ports:
- "443:443" - "9000:9000"
- "80:80"
- "8080:8080"
restart: always restart: always

View File

@@ -145,7 +145,7 @@ func ElasticIndex(artc *Article) error {
"content": artc.Content, "content": artc.Content,
"slug": artc.Slug, "slug": artc.Slug,
"tags": artc.Tags, "tags": artc.Tags,
"create_time": artc.CreateTime.Format("2006-01-02"), "create_time": artc.CreateTime,
} }
b, _ := json.Marshal(mapping) b, _ := json.Marshal(mapping)
return IndexOrUpdateDocument(INDEX, TYPE, artc.ID, b) return IndexOrUpdateDocument(INDEX, TYPE, artc.ID, b)

View File

@@ -79,7 +79,7 @@ func GetBase() gin.H {
func HandleHomePage(c *gin.Context) { func HandleHomePage(c *gin.Context) {
h := GetBase() h := GetBase()
h["Version"] = StaticVersion(c) h["Version"] = StaticVersion(c)
h["Title"] = Ei.BTitle h["Title"] = Ei.BTitle + " | " + Ei.SubTitle
h["Path"] = c.Request.URL.Path h["Path"] = c.Request.URL.Path
h["HomePage"] = true h["HomePage"] = true
h["CurrentPage"] = "blog-home" h["CurrentPage"] = "blog-home"
@@ -198,25 +198,22 @@ func HandleSearchPage(c *gin.Context) {
c.HTML(http.StatusOK, "homeLayout.html", h) c.HTML(http.StatusOK, "homeLayout.html", h)
} }
func HandleBeacon(c *gin.Context) {}
func HandleFeed(c *gin.Context) { func HandleFeed(c *gin.Context) {
http.ServeFile(c.Writer, c.Request, "conf/feed.xml") http.ServeFile(c.Writer, c.Request, "static/feed.xml")
} }
func HandleOpenSearch(c *gin.Context) { func HandleOpenSearch(c *gin.Context) {
c.Header("Content-Type", "application/xml; charset=utf-8") http.ServeFile(c.Writer, c.Request, "static/opensearch.xml")
c.Writer.WriteString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
c.HTML(http.StatusOK, "opensearch.xml", gin.H{
"BTitle": Ei.BTitle,
"SubTitle": Ei.SubTitle,
})
} }
func HandleRobots(c *gin.Context) { func HandleRobots(c *gin.Context) {
http.ServeFile(c.Writer, c.Request, "conf/robots.txt") http.ServeFile(c.Writer, c.Request, "static/robots.txt")
} }
func HandleSitemap(c *gin.Context) { func HandleSitemap(c *gin.Context) {
http.ServeFile(c.Writer, c.Request, "conf/sitemap.xml") http.ServeFile(c.Writer, c.Request, "static/sitemap.xml")
} }
func HandleComments(c *gin.Context) { func HandleComments(c *gin.Context) {

14
main.go
View File

@@ -2,18 +2,14 @@
package main package main
import ( import (
"net/http" // "net/http"
_ "net/http/pprof" // _ "net/http/pprof"
"github.com/EiBlog/utils/logd"
) )
func main() { func main() {
// set log print level
logd.SetLevel(logd.Ldebug)
// pprof // pprof
go func() { // go func() {
http.ListenAndServe(":6060", nil) // http.ListenAndServe(":6060", nil)
}() // }()
Run() Run()
} }

1
pingrpc.go Normal file
View File

@@ -0,0 +1 @@
package main

View File

@@ -19,6 +19,8 @@ var runmode = setting.Conf.Modes[setting.Conf.RunMode]
func init() { func init() {
if setting.Conf.RunMode == setting.PROD { if setting.Conf.RunMode == setting.PROD {
gin.SetMode(gin.ReleaseMode) gin.SetMode(gin.ReleaseMode)
// set log print level
logd.SetLevel(logd.Lerror)
} }
router = gin.Default() router = gin.Default()
store := sessions.NewCookieStore([]byte("eiblog321")) store := sessions.NewCookieStore([]byte("eiblog321"))
@@ -49,7 +51,9 @@ func init() {
router.GET("/series.html", HandleSeriesPage) router.GET("/series.html", HandleSeriesPage)
router.GET("/archives.html", HandleArchivesPage) router.GET("/archives.html", HandleArchivesPage)
router.GET("/search.html", HandleSearchPage) router.GET("/search.html", HandleSearchPage)
router.GET("/beacon.html", HandleBeacon)
router.GET("/data/comment", HandleComments) router.GET("/data/comment", HandleComments)
router.GET("/rss.html", HandleFeed)
router.GET("/feed", HandleFeed) router.GET("/feed", HandleFeed)
router.GET("/opensearch.xml", HandleOpenSearch) router.GET("/opensearch.xml", HandleOpenSearch)
router.GET("/sitemap.xml", HandleSitemap) router.GET("/sitemap.xml", HandleSitemap)

View File

@@ -81,7 +81,7 @@ func init() {
data, err = ioutil.ReadFile(path.Join(dir, "blackip.yml")) data, err = ioutil.ReadFile(path.Join(dir, "blackip.yml"))
checkError(err) checkError(err)
err = yaml.Unmarshal(data, BlackIP) err = yaml.Unmarshal(data, BlackIP)
chekError(err) checkError(err)
} }
func checkError(err error) { func checkError(err error) {

0
static/BingSiteAuth.xml Normal file
View File

File diff suppressed because one or more lines are too long

6
static/crossdoamin.xml Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

BIN
static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -5,7 +5,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name=viewport> <meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name=viewport>
<meta name=robots content="noindex, nofollow"> <meta name=robots content="noindex, nofollow">
<title>Login | {{.BTitle}}</title> <title>登录 | {{.BTitle}}</title>
<link rel=stylesheet href="/static/admin/background.css"> <link rel=stylesheet href="/static/admin/background.css">
</head> </head>

View File

@@ -96,8 +96,8 @@
}); });
})(); })();
</script> </script>
<script src="/static/js/timepicker.js?v=14.10.10"></script> <script src="/static/admin/timepicker.js"></script>
<script src="/static/js/tokeninput.js?v=14.10.10"></script> <script src="/static/admin/tokeninput.js"></script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
// 日期时间控件 // 日期时间控件
@@ -343,7 +343,6 @@ $(document).ready(function() {
$('#visibility').change(function() { $('#visibility').change(function() {
var val = $(this).val(), var val = $(this).val(),
password = $('#post-password'); password = $('#post-password');
console.log(val);
if ('password' == val) { if ('password' == val) {
password.removeClass('hidden'); password.removeClass('hidden');
@@ -362,9 +361,9 @@ $(document).ready(function() {
}); });
}); });
</script> </script>
<script src="/static/js/pagedown.js?v=14.10.10"></script> <script src="/static/admin/pagedown.js"></script>
<script src="/static/js/stmd.js?v=14.10.10"></script> <script src="/static/admin/stmd.js"></script>
<script src="/static/js/diff.js?v=14.10.10"></script> <script src="/static/admin/diff.js"></script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
var textarea = $('#text'), var textarea = $('#text'),
@@ -695,8 +694,8 @@ $(document).ready(function() {
} }
}); });
</script> </script>
<script src="/static/js/moxie.js?v=14.10.10"></script> <script src="/static/admin/moxie.js"></script>
<script src="/static/js/plupload.js?v=14.10.10"></script> <script src="/static/admin/plupload.js"></script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
function updateAttacmentNumber() { function updateAttacmentNumber() {

View File

@@ -1 +1 @@
<!DOCTYPE html><html lang="zh-cn"><head><meta charset="utf-8"><meta content="width=device-width,minimum-scale=1.0" name="viewport"><meta name="format-detection" content="telephone=no"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="referrer" content="always"><title>{{.Title}}</title><script>!function(n,t){function e(){o("nls",1)}function c(){t.documentElement.style.display="none",u(),location.reload()}function r(n){var t="";try{t=f[n]||"",t.length<99&&c()}catch(e){u()}return t}function i(n,t){try{f[n]=t,t!==f[n]&&u()}catch(e){u()}}function o(n,e){var c=999;e||(c=-1),c=new Date(+new Date+86400000*c).toGMTString();var r=n+"="+e+";path=/;expires="+c;t.cookie=r}function a(n){var e=t.getElementById(n).innerHTML;i(n,e)}function l(e,c){var i=r(e),o=t.createElement(c?"script":"style");return n.execScript&&c?n.execScript(i):(o.innerHTML=i,void t.head.appendChild(o))}function u(){o("v",0)}var f,h=function(){},d=n.L={h:h,l:h,c:h};try{f=localStorage,d.h=a,d.l=l,d.c=o}catch(p){e()}}(this,document);</script>{{if .Version}}<script>L.c('v', {{.Version}})</script>{{end}}<link rel="apple-touch-icon" href="{{.Favicon}}"><link rel="search" type="application/opensearchdescription+xml" href="//{{.Domain}}/opensearch.xml" title="{{.BTitle}}">{{if .Version}}<style id="blog_css">{{template "blog_css"}}</style><script>L.h('blog_css')</script>{{else}}<script>L.l("blog_css")</script>{{end}}<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="//{{.Domain}}/rss.html"><meta name="description" content="{{.Description}}"><style id="style-1-cropbar-clipper">.en-markup-crop-options{top:18px!important;left:50%!important;margin-left:-100px!important;width:200px!important;border:2px rgba(255,255,255,.38) solid!important;border-radius:4px!important}.en-markup-crop-options div div:first-of-type{margin-left:0!important}</style></head><body><div class="container"><div class="left-col"><div class="intrude-less"><header id="header" class="inner"><div class="profilepic"><a href="/"></a></div><h1><a href="/">{{.BlogName}}</a></h1><p class="subtitle">{{.SubTitle}}</p><nav id="main-nav"><ul><li {{if eq .Path "/"}}class="on" {{end}}><a href="/"><span>首页</span></a></li><li {{if eq .Path "/series.html"}}class="on" {{end}}><a href="/series.html"><span>专题</span></a></li><li {{if eq .Path "/archives.html"}}class="on" {{end}}><a href="/archives.html"><span>归档</span></a></li><li {{if eq .Path "/post/blogroll.html"}}class="on" {{end}}><a href="/post/blogroll.html"><span>友链</span></a></li><li {{if eq .Path "/post/about.html"}}class="on" {{end}}><a href="/post/about.html"><span>关于</span></a></li></ul></nav><nav id="sub-nav"><div class="social"><a target="_blank" class="twitter external" rel="nofollow" href="{{.Twitter}}" title="Twitter">Twitter</a><a target="_blank" class="rss" href="//{{.Domain}}{{.RSS}}" title="RSS 订阅">RSS</a><a class="search" href="{{.Search}}" title="站内搜索">Search</a></div></nav></header></div></div><div class="mid-col"><div class="mid-col-container">{{if .HomePage}} {{template "home" .}} {{else if .ArticlePage}} {{template "article" .}}{{else if .SeriesPage}}{{template "series" .}}{{else if .ArchivesPage}}{{template "archives" .}} {{else if .BlogrollPage}}{{template "blogroll" .}}{{else if .AboutPage}}{{template "about" .}}{{else if .SearchPage}} {{template "search" .}}{{else if .NotFoundPage}}{{template "notfound"}} {{end}}</div><footer id=footer class=inner>© {{.CopyYear}} - {{.BTitle}} - <a target="_blank" rel="nofollow designer" class="external beian" href="http://www.miitbeian.gov.cn/">{{.BeiAn}}</a><br>Powered by <a target=_blank href="//github.com/eiblog/eiblog">EiBlog</a> & <a target=_blank rel="nofollow designer" class=external href="//github.com/shashankmehta/greyshade">GreyShade</a></footer></div></div><input type=hidden id=CURRENT_PAGE value="{{.CurrentPage}}"><input type=hidden id=CDN_DOMAIN value="{{.Static}}"><!-- todo ana_js -->{{if .Version}}<script id="jq_js">{{template "jq_js"}}</script><script>L.h('jq_js')</script>{{else}}<script>L.l('jq_js', 1)</script>{{end}} {{if .Version}}<script id="hl_js">{{template "hl_js"}}</script><script>L.h('hl_js')</script>{{else}}<script>L.l('hl_js', 1)</script>{{end}}{{if .Version}}<script id="blog_js">{{template "blog_js"}}</script><script>L.h('blog_js')</script>{{else}}<script>L.l('blog_js', 1)</script>{{end}}</body></html> <!DOCTYPE html><html lang="zh-cn"><head><meta charset="utf-8"><meta content="width=device-width,minimum-scale=1.0" name="viewport"><meta name="format-detection" content="telephone=no"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="referrer" content="always"><title>{{.Title}}</title><script>!function(n,t){function e(){o("nls",1)}function c(){t.documentElement.style.display="none",u(),location.reload()}function r(n){var t="";try{t=f[n]||"",t.length<99&&c()}catch(e){u()}return t}function i(n,t){try{f[n]=t,t!==f[n]&&u()}catch(e){u()}}function o(n,e){var c=999;e||(c=-1),c=new Date(+new Date+86400000*c).toGMTString();var r=n+"="+e+";path=/;secure;expires="+c;t.cookie=r}function a(n){var e=t.getElementById(n).innerHTML;i(n,e)}function l(e,c){var i=r(e),o=t.createElement(c?"script":"style");return n.execScript&&c?n.execScript(i):(o.innerHTML=i,void t.head.appendChild(o))}function u(){o("v",0)}var f,h=function(){},d=n.L={h:h,l:h,c:h};try{f=localStorage,d.h=a,d.l=l,d.c=o}catch(p){e()}}(this,document);</script>{{if .Version}}<script>L.c('v', {{.Version}})</script>{{end}}<link rel="apple-touch-icon" href="{{.Favicon}}"><link rel="search" type="application/opensearchdescription+xml" href="//{{.Domain}}/opensearch.xml" title="{{.BTitle}}">{{if .Version}}<style id="blog_css">{{template "blog_css"}}</style><script>L.h('blog_css')</script>{{else}}<script>L.l("blog_css")</script>{{end}}<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="//{{.Domain}}/rss.html"><meta name="description" content="{{.Description}}"><style id="style-1-cropbar-clipper">.en-markup-crop-options{top:18px!important;left:50%!important;margin-left:-100px!important;width:200px!important;border:2px rgba(255,255,255,.38) solid!important;border-radius:4px!important}.en-markup-crop-options div div:first-of-type{margin-left:0!important}</style></head><body><div class="container"><div class="left-col"><div class="intrude-less"><header id="header" class="inner"><div class="profilepic"><a href="/"></a></div><h1><a href="/">{{.BlogName}}</a></h1><p class="subtitle">{{.SubTitle}}</p><nav id="main-nav"><ul><li {{if eq .Path "/"}}class="on" {{end}}><a href="/"><span>首页</span></a></li><li {{if eq .Path "/series.html"}}class="on" {{end}}><a href="/series.html"><span>专题</span></a></li><li {{if eq .Path "/archives.html"}}class="on" {{end}}><a href="/archives.html"><span>归档</span></a></li><li {{if eq .Path "/post/blogroll.html"}}class="on" {{end}}><a href="/post/blogroll.html"><span>友链</span></a></li><li {{if eq .Path "/post/about.html"}}class="on" {{end}}><a href="/post/about.html"><span>关于</span></a></li></ul></nav><nav id="sub-nav"><div class="social"><a target="_blank" class="twitter external" rel="nofollow" href="{{.Twitter}}" title="Twitter">Twitter</a><a target="_blank" class="rss" href="//{{.Domain}}{{.RSS}}" title="RSS 订阅">RSS</a><a class="search" href="{{.Search}}" title="站内搜索">Search</a></div></nav></header></div></div><div class="mid-col"><div class="mid-col-container">{{if .HomePage}} {{template "home" .}} {{else if .ArticlePage}} {{template "article" .}}{{else if .SeriesPage}}{{template "series" .}}{{else if .ArchivesPage}}{{template "archives" .}} {{else if .BlogrollPage}}{{template "blogroll" .}}{{else if .AboutPage}}{{template "about" .}}{{else if .SearchPage}} {{template "search" .}}{{else if .NotFoundPage}}{{template "notfound"}} {{end}}</div><footer id=footer class=inner>© {{.CopyYear}} - {{.BTitle}} - <a target="_blank" rel="nofollow designer" class="external beian" href="http://www.miitbeian.gov.cn/">{{.BeiAn}}</a><br>Powered by <a target=_blank href="//github.com/eiblog/eiblog">EiBlog</a> & <a target=_blank rel="nofollow designer" class=external href="//github.com/shashankmehta/greyshade">GreyShade</a></footer></div></div><input type=hidden id=CURRENT_PAGE value="{{.CurrentPage}}"><input type=hidden id=CDN_DOMAIN value="{{.Static}}">{{if .Version}}<script id="ana_js">{{template "ana_js"}}</script><script>L.h('ana_js')</script>{{else}}<script>L.l('ana_js', 1)</script>{{end}}{{if .Version}}<script id="jq_js">{{template "jq_js"}}</script><script>L.h('jq_js')</script>{{else}}<script>L.l('jq_js', 1)</script>{{end}}{{if .Version}}<script id="hl_js">{{template "hl_js"}}</script><script>L.h('hl_js')</script>{{else}}<script>L.l('hl_js', 1)</script>{{end}}{{if .Version}}<script id="blog_js">{{template "blog_js"}}</script><script>L.h('blog_js')</script>{{else}}<script>L.l('blog_js', 1)</script>{{end}}</body></html>

View File

@@ -1,23 +1,8 @@
{{define "ana_js"}} {{define "ana_js"}}
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://o7msui8ho.qnssl.com/js/analytics.js', 'ga');
ga('create', 'UA-77251712-1', 'auto');
ga('send', 'pageview');
! function(e, n, o, t) { ! function(e, n, o, t) {
var a = e.screen, var a = e.screen,
r = encodeURIComponent, r = encodeURIComponent,
i = ["tid=UA-5422922-2", "dl=" + r(n.URL), "dt=" + r(n.title), "dr=" + r(n.referrer), "dp=" + r(t.pathname), "ul=" + (o.language || o.browserLanguage).toLowerCase(), "sd=" + a.colorDepth + "-bit", "sr=" + a.width + "x" + a.height, "_=" + +new Date], i = ["tid=UA-77251712-1", "dl=" + r(n.URL), "dt=" + r(n.title), "dr=" + r(n.referrer), "dp=" + r(t.pathname), "ul=" + (o.language || o.browserLanguage).toLowerCase(), "sd=" + a.colorDepth + "-bit", "sr=" + a.width + "x" + a.height, "_=" + +new Date],
c = "?" + i.join("&"); c = "?" + i.join("&");
e.__beacon_img = new Image, e.__beacon_img.src = "/beacon.html" + c e.__beacon_img = new Image, e.__beacon_img.src = "/beacon.html" + c }(window, document, navigator, location);
}(window, document, navigator, location);
{{end}} {{end}}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

49
xml.go
View File

@@ -24,12 +24,17 @@ func init() {
if err != nil { if err != nil {
logd.Fatal(err) logd.Fatal(err)
} }
doOpensearch()
go doFeed() go doFeed()
go doSitemap() go doSitemap()
} }
func doFeed() { func doFeed() {
tpl := tpls.Lookup("feedTpl.xml")
if tpl == nil {
logd.Error("not found feedTpl.")
return
}
_, _, artcs := PageList(1, FEED_COUNT) _, _, artcs := PageList(1, FEED_COUNT)
buildDate := time.Now() buildDate := time.Now()
params := map[string]interface{}{ params := map[string]interface{}{
@@ -41,17 +46,12 @@ func doFeed() {
"Artcs": artcs, "Artcs": artcs,
} }
f, err := os.OpenFile("conf/feed.xml", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) f, err := os.OpenFile("static/feed.xml", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm)
if err != nil { if err != nil {
logd.Error(err) logd.Error(err)
return return
} }
defer f.Close() defer f.Close()
tpl := tpls.Lookup("feedTpl.xml")
if tpl == nil {
logd.Error(err)
return
}
err = tpl.Execute(f, params) err = tpl.Execute(f, params)
if err != nil { if err != nil {
logd.Error(err) logd.Error(err)
@@ -61,18 +61,18 @@ func doFeed() {
} }
func doSitemap() { func doSitemap() {
tpl := tpls.Lookup("sitemapTpl.xml")
if tpl == nil {
logd.Error("not found sitemapTpl.")
return
}
params := map[string]interface{}{"Artcs": Ei.Articles, "Domain": runmode.Domain, "Enablehttps": runmode.EnableHttps} params := map[string]interface{}{"Artcs": Ei.Articles, "Domain": runmode.Domain, "Enablehttps": runmode.EnableHttps}
f, err := os.OpenFile("conf/sitemap.xml", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) f, err := os.OpenFile("static/sitemap.xml", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm)
if err != nil { if err != nil {
logd.Error(err) logd.Error(err)
return return
} }
defer f.Close() defer f.Close()
tpl := tpls.Lookup("sitemapTpl.xml")
if tpl == nil {
logd.Error(err)
return
}
err = tpl.Execute(f, params) err = tpl.Execute(f, params)
if err != nil { if err != nil {
logd.Error(err) logd.Error(err)
@@ -80,3 +80,26 @@ func doSitemap() {
} }
time.AfterFunc(time.Hour*24, doFeed) time.AfterFunc(time.Hour*24, doFeed)
} }
func doOpensearch() {
tpl := tpls.Lookup("opensearchTpl.xml")
if tpl == nil {
logd.Error("not found opensearchTpl.")
return
}
params := map[string]string{
"BTitle": Ei.BTitle,
"SubTitle": Ei.SubTitle,
}
f, err := os.OpenFile("static/opensearch.xml", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm)
if err != nil {
logd.Error(err)
return
}
defer f.Close()
err = tpl.Execute(f, params)
if err != nil {
logd.Error(err)
return
}
}