Total Pageviews

Wednesday, 5 February 2025

基于 php的静态博客程序gitblog-by-jockchou

 

一. 简介

GitBlog是一个简单易用的Markdown博客系统,它不需要数据库,没有管理后台功能,更新博客只需要添加你写好的Markdown文件即可。它摆脱了在线编辑器排版困难,无法实时预览的缺点,一切都交给Markdown来完成,一篇博客就是一个Markdown文件。同时也支持评论,代码高亮,数学公式,页面PV统计等常用功能。GitBlog提供了不同的主题样式,你可以根据自己的喜好配置,如果你想自己制作博客主题,也是非常容易的。GitBlog还支持整站静态导出,你完全可以导出整站静态网页部署到Github Pages。

预览

screenshot

二. 功能特点

  1. 使用Markdown
  2. 评论框
  3. 代码高亮
  4. PV统计
  5. Latex数学公式
  6. 自制主题
  7. 响应式
  8. 全站静态导出
  9. 良好的SEO

三. GitBlog优势

  1. 无需数据库,系统更轻量,移植更方便
  2. 使用Markdown编写,摆脱后台编辑排版困难,无法实时预览的缺点
  3. 可全站静态导出
  4. 配置灵活,可自由开关某些功能
  5. 多主题支持,可自制主题
  6. 博客,分类,标签,归档

四. 环境要求

  • PHP 5.2.4+
  • mbstring扩展支持
  • php.ini开启short_open_tag = On

五. 安装步骤

  1. 下载GitBlog源代码
  2. 解压上传到你的PHP网站根目录
  3. 打开浏览器,访问网站首页
  4. 上传Markdown文件到posts文件夹

六. 详细说明

1. 安装
2. 目录结构
3. 配置说明
4. 编写博客
5. 评论,订阅,统计等
6. 缓存机制
7. 全站静态导出
8. 主题制作
9. 在Nginx上运行GitBlog
10. 在Apache上运行GitBlog
11. 在SAE上运行GitBlog
12. 使用GitBlog和Github Pages搭建博客
13. Gitblog升级
14. 从wordpress导入

七. 问题及bug反馈

如果在实际使用过程中对GitBlog有新的功能需求,或者在使用GitBlog的过程中发现了Bug,欢迎反馈给我。可以直接在Github上提交,也可以发邮件至164068300[AT]qq.com与我取得联系,我将及时回复。如果你自己制作了漂亮好用的主题,也非常欢迎你提交给我,我会在这里展示你的主题链接。如果你正在使用GitBlog,也可以告诉我,我将也会在这里列出使用者名单。如果你想和其他GitBlog使用者讨论交流,欢迎加入QQ群84692078

from https://github.com/jockchou/gitblog 

(https://github.com/jockchou/gitblogdoc)

------------------------------------------------------------------------------------------

 Git-based blog/cms for PHP, meant as a replacement for Wordpress .

gitblog

A git-based blog/cms platform for PHP, meant as a replacement for Wordpress.

Post-action hooks in git are used to manage an intermediate cache which consist only of structured data (no formatting), allowing dynamic presentation. This is one of the biggest differences tech-wise in comparison to Jekyll and similar tools.

Licensed under MIT means free to use for everyone. See LICENSE for more information.

Features

  • Fully git-based -- no mysql or similar involved
  • Everything is versioned
  • Themes
  • No custom file formats for content (only JSON, Markdown (with Markdown extra) and HTML)
  • High performance
  • Hierarchical comments with optional spam filtering based on Akismet
  • Remote editing (git push/pull)
  • Wordpress import
  • Plugins

(See section "Future features" for a list of possible future features)

Installing & Getting started

Clone a copy of gitblog:

$ cd /path/to/my-blog
$ git clone git://github.com/rsms/gitblog.git

If your web server is not running as yourself, your group, or the root user, you need to change owner. In this example www-data is the web server user. (You will still be able to edit the blog.)

$ chmod -R g+w .
$ sudo chown -R www-data .

Open a web browser and point it to your /my-blog/gitblog. Enter email and your real name -- these will be used for commit messages. Also choose a good pass phrase which in combination with your email will grant you administration privileges in the web administration interface.

When you're done you should see a single "Hello world" post. Okay, all good.

What did just happen? Gitblog initialized a git repository in /path/to/my-blog and added a few standard files and directories. If you ever would like to start over, just delete everything except the gitblog directory and visit /my-blog/gitblog in a browser again.

Let's try editing the hello world post:

$ $EDITOR content/posts/*/*-*-hello-world.html

Make some changes, be creative!

To demonstrate that the "working tree" is indeed a working area and not the live stage, reload your web browser and see that the "Hello world" post is still not modified.

Tip: You can view your work in progress by being signed in and appending ?preview to the url.

Now, let's commit the changes, pusing them live:

$ git commit -m 'Updated my awesome hello-world post' content

Reload your web browser and... voila!

Warnings when committing? If you see error: Could not access 'HEAD@{1}' on stderr when committing, do not worry. This is an issue that currently do not affect gitblog, but we're looking into what causes it.

Importing a Wordpress blog

If you have a Wordpress blog you would like to import, there is a built-in tool which does it for you! Just visit /my-blog/gitblog/admin/import-wordpress.php and follow the simple instructions.

Documentation

The docs directory contains a number of documents covering different parts of Gitblog.

Requirements

  • PHP 5.2 or newer (only standard modules are needed though)
  • Git 1.6 or newer
  • POSIX system

Further play

The gb-config.php file (present in your site root) contains site-specific configuration. A default gb-config.php file, as it looks just after a blog has been setup, contains only the minimum set of paramters. There are a bunch of other paramters which might do something you whish.

Have a look in the file gitblog/gitblog.php -- scroll down a few lines and you'll find a class called gb which houses documentation and a list of all available configuration parameters, as well as their default values.

Known bugs and issues

  • Post-hook system is a bit shaky because of the nature of itself. Running scripts directly instead of POSTing to a URL would be better but many systems does not have CLI PHP or have another version than the web PHP.

Future features

Work in progress

  • Web administration

Planned

  • Pingback
  • Search

Under consideration

  • Configure what parts are versioned (e.g. disable versioning of comments)
  • Alternate storage
  • Caching (memcached, redis, etc)

Authors

  • Rasmus Andersson <rasmus notion.se>

History

A strangely cold morning in june 2009 Mattias Arrelid pressed the "Yeah, upgrade Wordpress". What happened seconds later still brings me down sometimes... Every file on our server--removable by the web server--was deleted in an instant. Many years worth of photos, audio recordings and not to mention the 30+ web sites which disappeared into the void of an unrecoverable ext3 file system.

We swore to never again use Wordpress and to do backups.

As we all like Git--this pretty little creation of the open source community--the blog tool of our future was of course based on Git. But after giving a few days of research we had not found any tool that suited our taste. (The closest match was Jekyll, however we wanted something more flexible, like Word...euhm). So what the heck, after all we are software engineers so why not write something ourselves?

Gitblog was born.

from  https://github.com/rsms/gitblog

--------------------------------------------------

gitblog

doc:

 https://www.bookstack.cn/read/gitblog/README.md

install package:

 参考:
     yum|apt-get install
     
     nginx,php,php-mysql,php-fpm,php-mbstring

clone gitblog:

 cd /var/www/
 wget https://github.com/jockchou/gitblog/archive/v2.3.2.tar.gz
 tar zxvf v2.3.2.tar.gz
 mv gitblog-2.3.2 gitblog && rm -rf v2.3.2.tar.gz
 cd gitblog
 git clone https://github.com/hack0072008/my-gitblog
 mv my-gitblog/blog/* ./blog/
 
 cp gitblog.conf /etc/nginx/conf.d/
 cp conf.yaml /var/www/gitblog/
 cp index.php /var/www/
 rm -rf my-gitblog

modify config:

 #php.ini 中的short_open_tag = On:
 vim /etc/php/7.0/fpm/php.ini (ubuntu)
 vim /etc/php.ini             (centos)
 
 #apache中的端口(改成非80、443,停用,否则会导致nginx端口冲突):
 vim /etc/apache2/ports.conf     (ubuntu)
 vim /etc/http.d/conf/httpd.conf (centos)
 
 #停止apache
 systemctl stop httpd
 /etc/init.d/apache2 stop
 
 #修改nginx的gitblog.conf配置(hostname,port)
 vim gitblog.conf
 //注意:如果有域名需要修改域名对应的A记录的解析IP地址

start blog:

 /etc/init.d/nginx restart  or systemctl restart nginx
 /etc/inid./apache2 restart or systemctl stop httpd

open blog:

 http://hostname:port/ or https://www.xxx.com:port/

去掉原作者信息:

 在 gitblog/theme/xxxx/index.html 中找到对应的子文件,去掉即可,例如default主题:gitblog/theme/default/index.html 内容的 block/footer.html 中修改原作者信息. 

增加两大评论系统,disqus 和 gitalk:

 一.通过阅读gitblog源码发现,本身自带disqus解析,只是需要在conf.yaml中增加配置项:disqus,值为disqus的用户名即可,例如:
    conf.yaml:
        disqus: zhangyh
    如想取消disqus,disqus值留空即可
    
    参考:
        https://www.jianshu.com/p/7e4453421b8f
        
 二.gitalk评论系统,修改:theme/default/block/comments.html,增加相应代码
    a.github中增加oauth apps授权(对域名和主页授权,创建一个apps),得到ID和Secret
    b.github创建存放评论的仓库,比如myblog-issue
    c.修改以下代码中的参数gitalk的主要参数,然后贴到theme/default/block/comments.html中:
        <!-- Gitalk 评论 start  -->
        <!-- Link Gitalk 的支持文件  -->
        <link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
        <script src="https://unpkg.com/gitalk@latest/dist/gitalk.min.js"></script> 
        <div id="gitalk-container"></div>     <script type="text/javascript">
            var gitalk = new Gitalk({
        
            // gitalk的主要参数
        		clientID: `Github Application clientID`,
        		clientSecret: `Github Application clientSecret`,
        		repo: `存储你评论 issue 的 Github 仓库名`,
        		owner: 'Github 用户名',
        		admin: ['Github 用户名'],
        		id: '页面的唯一标识,gitalk会根据这个标识自动创建的issue的标签',
            
            });
            gitalk.render('gitalk-container');
        </script> 
        <!-- Gitalk end -->
    d.评论汇总在:https://github.com/hack0072008/myblog-issue/issues
    参考:
        http://qiubaiying.top/2017/12/19/%E4%B8%BA%E5%8D%9A%E5%AE%A2%E6%B7%BB%E5%8A%A0-Gitalk-%E8%AF%84%E8%AE%BA%E6%8F%92%E4%BB%B6/
路由标头信息:
 author: 博客作者名称 
 date: 博客时间,用于页面显示,通常来说你不需要填写这个字段,默认就是创建日期 
 title: 博客标题 
 tags: 博客里的标签,多个用逗号或空格分隔 
 category: 博客分类,多个用逗号或空格分隔 
 status: 博客状态,draft表示草稿,GitBlog解析时会忽略草稿;publish表示发表状态,默认为publish 
 summary: 博客摘要信息 以上所有信息都是独占一行,暂不支持写在多行。 
from  https://github.com/hack0072008/my-gitblog
-------------------------------------------------------

gitblog

A Git-based blog/cms writen in PHP, providing dynamic presentation of git repositories.

Requirements

  • PHP 5.3 or newer
  • Yii Framework 1.1.*

Installation

Clone a copy of gitblog:

  $ git clone https://github.com/bixuehujin/gitblog.git /path/to/gitblog

Run composer to install dependencies:

  $ composer install

Authors

from  https://github.com/bixuehujin/gitblog

 

 

 

 

 


 

No comments:

Post a Comment