HowTo Upgrade Your Ghost Version


1. 下载最新版的Ghost

1
curl -LOk https://ghost.org/zip/ghost-latest.zip

2. 创建临时目录,并解压ghost-latest.zip到此

1
2
mkdir /usr/ghost-tmp
unzip ghost-latest.zip -d /usr/ghost-tmp

3. 进入到原ghost目录,删除core

1
2
cd  /usr/ghost
rm -rf core

4.进入到新版本的ghost临时目录

1
cd /usr/ghost-tmp

5. 拷贝所需文件到ghost升级目录

1
2
cp -R core /usr/ghost
cp index.js *.json /usr/ghost

6. (可选)升级casper,ghost默认主题

1
cp -R content/themes/casper /usr/ghost/content/themes/

7. 切换回到ghost安装目录

1
cd /usr/ghost

8. 修改文件目录所有者和所属组为ghost

1
chown -R ghost:ghost ./*

9. 重新安装环境

1
npm install --production

10. 重启Ghost

1
pm2 restart ghost

Ghost(2) 增加评论模块

Ghost作为一个更加纯粹的博客平台,并没有打算为其开发内置的文章评论功能。而是将评论功能托管给第三方,好处也是让用户更有精力集中于网站内容的建设。实现的办法也很简单,只需要向Ghost主题的模板Handlebars(.hbs)插入第三方评论组件的JavaScript代码来为Ghost博客增加评论功能。


国内最常用的多说评论框,支持国内常见的社交网络一键注册登录、盖楼讨论和分享而且对新用户上手简单。而Disqus功能强大、完善的社交网络和多国语言支持并且为其插件启用全球CDN加速。总的来说两个插件各有所长。


基于默认主题Casper的安装指南:





创建一个模板


为了在需要评论框代码的时候方便引用,我选择事先在主题文件夹content\themes\casper\partials下面创建一个叫做comments.hbs的模板文件,也就是评论框的专属模板。


现在我只需要在我的Casper主题下面的post.hbs模板中的


            </section>

</footer>
</article>
</main>

前面部分添加一句{{> comments}}就可以展示评论框了。


添加后就像这样:


            </section>
{{> comments}}
</footer>
</article>
</main>

这样以来的好处就可以在任何主题中轻松移植评论框代码。


开始之前:对评论框Html代码进行简要说明。



  • <section class=”post-comments”>…</section>用于展示评论框

  • <script type=”text/javascript”>…</script>评论框公共代码

  • {{slug}} 引用文章短名作为第三方社交平台识别文章的特征标志

  • {{title}} 引用文章标题

  • {{url absolute="true"}} 获取永久链接




安装多说评论框


1.将下面的评论框代码插入comments.hbs文件。

多说评论框:


<section class=”post-comments”>
<div class=”ds-thread” data-thread-key=”{{slug}}“ data-title=”{{title}}“ data-url=”{{url absolute="true"}}“></div>
<!– 务必插入多说公共JS代码 –>
</section>

2.如何获取多说公共JS代码?


登录多说 > 点击“我要安装”> 创建站点 > 获取公共代码(如图)


多说公共JS代码




安装Disqus评论框


1.将下面的评论框代码插入comments.hbs文件。

Disqus评论框评论框:


  <section class=”post-comments”><div id=”disqus_thread”></div>
<!– 务必插入Disqus公共JS代码 –>
</section>

2.获取Disqus的公共JS代码


注册Disqus > 安装平台选则 Universal Code > 直接复制代码


3.添加完毕后,重新启动Ghost博客。


4.Disqus不能成功加载的时候可以在JavaScript中强制使用HTTPS以链接Disqus服务器。具体方法就是在s.src的提供的URL中加入https://

在网页中插入歌曲

纠正下,在下面博文中的错误,关于单曲不能生成外链的问题,现已经纠正。

我试过百度音乐、QQ音乐、虾米音乐和网易云音乐,目前只有网易云音乐有此功能,先在网易云音乐选择歌曲即可:

分享单曲

分享专辑,歌单



       选定歌单之后,在歌单页面有个生成外链播放器的按钮






       然后,根据页面提示信息,生成你要的html代码,并嵌入到你的页面之中。


HowTo Add Piwik Tracking to Ghost

This is what about piwik on wiki. goto

Step 1 - Getting your Piwik Tracking code

The first step to having Piwik tracking your Ghost blog will be to add a new website in Piwik, if you are unfamiliar with this process you can checkout the Piwik documention on Managing Websites. With your Ghost blog added into Piwik you will end up with tracking code that will look similar to the following:

1
2
3
4
5
6
7
8
9
10
11
12
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
(function(){ var u=(("https:" == document.location.protocol) ? "https://{$PIWIK_URL}/" : "http://{$PIWIK_URL}/");
_paq.push(['setSiteId', {$IDSITE}]);
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js';
s.parentNode.insertBefore(g,s); })();
</script>
<!-- End Piwik Code -->

Where $PIWIK_URL will be the domain name you have setup for Piwik.

Step 2 - Adding Piwik Tracking Code To Ghost Theme File

Piwik recommends that you add the tracking code right above the </body> tag, which you can find in your Ghost’s default.hbs theme file. You will find the default.hbs file in /path/to/ghost/content/themes/your-theme/default.hbs
How you add the tracking code to your default.hbs will depend on if you are editing the file on your local computer or directly on the server. If you are editing your theme locally you can edit this file in any text editor and when you are finished upload this file to your server. Otherwise if you are editing this file directly on the server you can use the command line editor, vim, to add the tracking code.

Step 3 - Restart Ghost

For the changes in your theme to take effect you will need to restart Ghost. Restarting Ghost will load up a fresh copy of your theme files, with your Piwik tracking code. How you restart Ghost depends on how you started Ghost. If you followed our Keep Ghost Running with forever, then you can restart Ghost with forever restart ghost.
Within a few moments you will start to see data coming in for your Ghost blog!
If you have any questions about setting this up or run into any issues please leave us a comment below and we will do what we can to help.

HowTo Install piwik with nginx on centos 6.x

This is my nginx config.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
server {
listen blog.ultraera.org:80;
server_name blog.ultraera.org;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
}

server {
listen piwik.ultraera.org:80;
server_name piwik.ultraera.org;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2080;
}
}
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×