+

+eBlog

+ +

A simple blog system based on Flask

+ +

+Quick Start

+ +
$ git clone https://github.com/ghostrong/weblog.git
+$ cd weblog
+$ pip install -r requirements.txt
+$ python create_db.py
+$ python run.py (also you can run shell with: sh start.sh)
+
+ +

Now, visit http://127.0.0.1:5000 in a browser.

+ +

+Database with MySQL

+ +

If you use MySQL ,create weblog database before python create_db.py:

+ + + +

+Requirements

+ +

+For the server-side

+ + + +

+For the cline-side (for publishing articles automatically)

+ + + +

+Writing blogs

+ +

You should write articles in markdown, and provide the meta information such as title, tags in YAML. You should put the meta data in the header lines of the markdown file. Here is an example.

+ +

+Meta Data

+ + + +

+The boundry of meta

+ +

The meta data should be located between '---' and '...'. +The following is an example of meta infomration:

+ +
---
+title: The Zen of Python
+summary:
+  Long time Pythoneer Tim Peters succinctly channels the BDFL's
+  guiding principles for Python's design into 20 aphorisms, only 19
+  of which have been written down.
+tags:
+  - python
+  - programming
+...
+
+You should write the body content from here...
+
+ +

+Publishing blogs

+ +

We provide a simple script to make the publishing work easy. Run publish.py to check the help message.

+ +
$ python publish
+
+usage: publish.py [-h] [-p PATH] [-a API] [-t TOKEN]
+
+optional arguments:
+  -h, --help            show this help message and exit
+  -p PATH, --path PATH  markdown file path/url
+  -a API, --api API     api address
+  -t TOKEN, --token TOKEN
+                        access token
+
+ +

You should provide the markdown file(either file-path or raw-url), the target api, and the access token. In this blog system, the publish url is /publish. The access token is the value of TOKEN in config.py. +Anyone who know the token could publish articles to your blog system, so keep it secret!!

+ +

After starting the web server locally, you can publish an article like this: +*You should be change your token in config.py file.

+ +
$ python publish.py -a http://127.0.0.1:5000/publish -p example.md -t your_token_in_config
+
+ +

+Deploy application

+ +

gunicorn -w 4 -b 0.0.0.0:5000 run:app

+ +

+Delete blogs

+ +
from weblog import database,models
+db = database.db
+articles=models.Article
+articles.query.filter_by(id=1).delete()
+db.session.commit()
+
+ +

+Features

+ + + +

+TODO

+ + + + + +