Markdoc is a lightweight Markdown-based wiki system. It’s been designed to allow you to create and manage wikis as quickly and easily as possible.
Potential use cases for Markdoc include, but aren’t limited to:
rsync
) mean the server can keep running whilst Markdoc re-compiles the wiki. Just refresh your browser to see the changes.The minimum requirements to run the Markdoc utility are:
请保证您的操作系统上安装rsync并且在系统路径中,否则markdoc build时会报错,如下:
raise child_exception
OSError: [Errno 2] No such file or directory
$ pip install https://github.com/azhai/markdoc/tarball/master #OR
$ pip install https://gitcafe.com/azhai/markdoc/tarball/master #OR
$ pip install https://git.oschina.net/azhai/markdoc/tarball/master
markdoc init my-wiki
cd my-wiki/
vim wiki/somefile.md
# ... write some documentation ...
markdoc build
markdoc serve
# .. open http://localhost:8008/ in a browser ...
date: 2012-05-15
title: Python计算文件的MD5
category: Python
tag: python, md5, hash
下面两个函数,一个用于计算字符串的MD5,另一个用于计算指定文件的MD5
:::python
#-*- coding: utf-8 -*-
import hashlib
def md5hex(word):
""" MD5加密算法,返回32位小写16进制符号 """
if isinstance(word, unicode):
word = word.encode("utf-8")
elif not isinstance(word, str):
word = str(word)
m = hashlib.md5()
m.update(word)
return m.hexdigest()
def md5sum(fname):
""" 计算文件的MD5值 """
def read_chunks(fh):
fh.seek(0)
chunk = fh.read(8096)
while chunk:
yield chunk
chunk = fh.read(8096)
else: #最后要将游标放回文件开头
fh.seek(0)
m = hashlib.md5()
if isinstance(fname, basestring) \
and os.path.exists(fname):
with open(fname, "rb") as fh:
for chunk in read_chunks(fh):
m.update(chunk)
#上传的文件缓存 或 已打开的文件流
elif fname.__class__.__name__ in ["StringIO", "StringO"] \
or isinstance(fname, file):
for chunk in read_chunks(fname):
m.update(chunk)
else:
return ""
return m.hexdigest()
# Metadata
wiki-name: "xxx's Blog"
wiki-author: "xxx"
# Directories
hide-prefix: ""
wiki-dir: "content"
static-dir: "static"
html-dir: "html"
template-dir: ""
temp-dir: ".tmp"
cvs-exclude: true
# Building
document-extensions: [.md, .rst]
generate-listing: always
listing-filename: "default.html"
use-default-static: true
use-default-templates: true
disqus-sitename: "xxx-disqus"
# Rendering
markdown:
safe-mode: false
output-format: xhtml1
extensions: [meta, codehilite, def_list, sane_lists, toc]
extension-configs:
codehilite:
css_class: codehilite
force_linenos: true
# Serving
server:
bind: '192.168.0.1'
port: 8008
num-threads: 10
#name: 'myblog.github.com'
request-queue-size: 5
timeout: 10
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to http://unlicense.org/
原网址: 访问
创建于: 2024-03-07 16:51:49
目录: default
标签: 无
未标明原创文章均为采集,版权归作者所有,转载无需和我联系,请注明原出处,南摩阿彌陀佛,知识,不只知道,要得到
最新评论