Git Product home page Git Product logo

octblog's Introduction

About OctBlog

Join the chat at https://gitter.im/flyhigher139/OctBlog Build Status

OctBlog is almost the same with MayBlog except that it is powered by Flask and MongoDB rather than Django and SQL Databases.

And as my customary, I named it OctBlog as OctBlog was started in October, 2015

OctBlog offers every function in MayBlog, and aims to do it better, its features are as follow:

  • Multiple user
  • OctBlog roles: su, admin, editor, writer, reader
  • Blog features: posts, pages, tags, and categories
  • Markdown support
  • Admin interface
  • Change configurations by configuration file or environment variable
  • Multiple comment plugin
  • User defined widgets
  • Deploy with docker
  • Sort posts by weight

Demo

Gevin's Blog is powered by OctBlog

Explanation

The weight is used to order articles, and if you want to hidden an article from the article list, weight is also qualified:

The default weight for each article is 10, if a article's weight is heavier than 10, it will be firstly displayed, and if the weight is negative, the article will be never displayed in the article list

Dependency

Backend

  • Flask
    • flask-script
    • flask-login
    • flask-admin
    • Flask-WTF
    • flask-principal
    • flask_mongoengine
  • WTForms
  • mongoengine
  • markdown2
  • bleach

Frontend

  • jQuery
  • BootStrap
  • Font Awesome
  • highlight.js

How to run OctBlog ?

Run from source code

If you want to see more about the source code, checkout the source code readme

Run by docker(recommended)

Run OctBlog by docker is recommended, here are some instruction:

First Run

1. Get your OctBlog image

In command line, switch to OctBlog root directory, and run the following command to build your own OctBlog image:

cd app
(sudo) docker build -t gevin/octblog:0.1 .

# Now you can take a cup of coffee and wait for a few minutes :)

Alternatively, pull Octblog image from DockerHub(recommended):

(sudo) docker pull gevin/octblog:0.1

2. Create your docker-compose.yml

You need to create a docker-compose file similar to the docker-compose_no_swarm.yml file

Replace /Users/gevin/projects/data/mongodb with a path on your machine

3. Run OctBlog

(sudo) docker-compose up -d

Then you can visit OctBlog in your brower at http://localhost

All environment variables can be found in /OctBlog/config.py

A .env file example:

DEBUG=false
config=prd
MONGO_HOST=mongo
allow_registration=true
allow_su_creation=true

name=Gevin's Blog
subtitle=技术、生活都要折腾
description=技术、生活都要折腾

wechat_name=GevinView @ <i class="fa fa-weixin" aria-hidden="true"></i>
wechat_subtitle=技术、生活都要折腾

copyright_msg=注:转载本文,请与Gevin联系
donation_msg=如果您觉得Gevin的文章有价值,就请Gevin喝杯茶吧!
wechat_msg=欢迎关注我的微信公众账号

google_site_verification=
allow_comment=true


allow_daovoice=true
daovoice_app_id=

3. Get into OctBlog container

Maybe you would like to dig into the container, the following command will help:

# Specify OctBlog container ID, eg:12345678
(sudo) docker ps

# Get into OctBlog container
(sudo) docker exec -it 12345678 bash

After first run

  • Start OctBlog
(sudo) docker-compose start
  • Stop OctBlog
(sudo) docker-compose stop

Run by docker with swarm mode

Preparation

If you want to use docker swarm mode, you need to activate this mode first:

docker swarm init

This command activates your docker swarm mode and make it as a swarm manager

Then you can join other swarm node to this manager with docker swarm join

Run OctBlog

You need to create a docker-compose file similar to the docker-compose.yml file.

Then, start your application:

docker stack deploy -c docker-compose.yml octblog

review your application:

docker stack ps octblog

remove your application:

docker stack rm octblog

You can refer to Docker Documentation for more docker swarm usages.

Get started with OctBlog

1. Create a superuser to administrate OctBlog

Visit the following url and create a superuser

http://localhost:8000/accounts/registration/su

If the url is forbidden, you need to modify your configurations to allow the creation.

2. Administrate OctBlog

The admin home is: http://localhost:8000/admin

You will be redirected to login page if you haven't logged in

3. Modify the default configurations

You either change settings in app/OctBlog/config.py file, or set environment variables defined in that file.

Setting environment variables is recommended, and once the configuration is changed, you need to restart the service.

License

OctBlog is under GPL2

What's more

If you find a bug or want to add a new feature, just issue me.

Want to contribute? Please fork OctBlog and pull request to me.

I'm not good at frontend development, so I used a free bootstrap blog theme. If you can redesign the blog theme and admin interface, I'll appriciate your work very much!

octblog's People

Contributors

flyhigher139 avatar gitter-badger avatar medyagh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

octblog's Issues

[Errno 111] Connection refused

Hi,
I tried to launch the server from code, and always encounter this error:
ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused
raised by mongo-engine, I would like to know if your code will create a database instance ?

Deploy OctBlog by debian8 mod_wsgi

环境

linux:debian 8
python:3.6

配置基础环境

  1. 更新软件源
    sudo apt-get update
  2. 安装apache2
    sudo apt-get install apache2
  3. 安装mod-wsgi
    sudo apt-get install libapache2-mod-wsgi-py3
    到这里基础环境的配置就完毕了

创建wsgi.py

Apache 使用 .wsgi 来启动 Flask 程序。使用以下命令打开 /var/www/projectapp 目录,创建一个 flaskapp.wsgi 文件。

    cd /var/www/projectapp
    sudo nano flaskapp.wsgi
    # 增加如下内容
    #!/usr/bin/python
    import sys
    import logging
    activate_this = '/var/www/OctBlog/venv/bin/activate_this.py'  # 这是虚拟环境路径
    with open(activate_this) as file_:                            # py3的调用
        exec(file_.read(), dict(__file__=activate_this))
    logging.basicConfig(stream=sys.stderr)
    sys.path.insert(0,"/var/www/projectapp/")  #你app的目录
    from OctBlog import app 
    application = app

Apache2配置文件

sudo nano /etc/apache2/sites-available/yoursite.conf

<VirtualHost *:80>
    ServerName www.xxx.com 
    #ServerAlias xxx.com
    #ServerAdmin [email protected] 
    # 存放用户上传图片等文件的位置,注意去掉#号
    # Alias /media/ /var/www/ProjectName/media/ 
    # 静态文件(js/css/images)的存放位置
    Alias /static/ /var/www/OctBlog/app/static/                
    # 允许通过网络获取static的内容
    <Directory /var/www/OctBlog/app/static/>                  
        Require all granted
    </Directory>
    # wsgi文件
    WSGIScriptAlias / /var/www/OctBlog/app/flaskapp.wsgi  
</VirtualHost>

应用配置文件sudo a2ensite projectapp

重启apache2sudo service apache2 restart

!!!遇到问题查看errorlog,/var/log/apache2/error.log

Here is my blog

博客上传图片的问题

感谢兄弟的开源博客,目前我改了下web ui,差不快改完了,三个问题请教一下:
1:老哥blog上线是用的阿云的哪个套餐啊?准备上线部署了,没找到合适的云主机
2:图片上传的url是别外生成的吗?flask-markdown好像没有这个功能,哥们有考虑在博客中实现直接上传图片文件吗?
3:域名绑定后,备案了吗?

先买了vultr一个月的套餐,域名还没有买绑定。
http://45.77.173.62/

Why I can't update my config.py?

I have deployed the blog on my service,and I want change the homepage of my blog and I have changed environments variables in config.py,but the homepage of my blog is still the default page,How to change the ? thx.

部署问题

你好,首先非常感谢你的分享。我想把你的代码部署到生产坏境去,采用nginx + gunicorn+centos,请问有详细的部署教程吗?我是Python新手,弄了两天也没有成功。需要你的帮助,万分感谢!

请问按照教程在服务器上部署了,为啥无法访问呢?

按照教程在docker上部署了
执行 docker -ps 可以看到

CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                                                      NAMES
049f3b122a91        gevin/octblog:0.1.2   "/usr/local/bin/super"   3 hours ago         Up About an hour    5000/tcp, 8000/tcp, 0.0.0.0:8005->8005/tcp                 octblogmaster_blog_1
ca27f94bc5cc        mongo:3.2             "docker-entrypoint.sh"   5 hours ago         Up About an hour    27017/tcp                                                  octb

但是在外网8005端口无法访问

关于多用户的疑问

很高兴楼主能开源这个项目,在些表示感谢。我现在想用这个来搭建一个个人博客,不过有一个疑问,就是系统中的多用户是个什么概念?

Docker Errors in Readme

the docker build command is wrong, and the docker-compose file only work on one machine.

ERROR: for mongo  Cannot start service mongo: error while creating mount source path '/Users/gevin/projects/data/mongodb': mkdir /Users/gevin: permission denied

How to make database fit to the new weight feature?

In commit 608df90d56462cdbedc60c3d9211c3ec0cedaaf0, I add weight feature to Post and Draft

And in commit 475032477fff25403e7f877f164d44be9c973f7e, I optimized the list_posts() function to make the new feature compatible to old database.

But you may still want the old database fitting to the new data model.
In order to make them fitting, just run the following snippet in mongodb:

For Posts:

db.getCollection('post').update({}, {$set: {weight: NumberInt(10)}}, {multi: 1})

For Drafts:

db.getCollection('draft').update({}, {$set: {weight: NumberInt(10)}}, {multi: 1})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.