Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython

zcms is unavailable in PyPM, because there aren't any builds for it in the package repositories. Click the linked icons to find out why.

 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
Linux (64-bit)
 
Links
License
BSD-derived (http://www.repoze.org/LICENSE.txt)

厌倦了各种复杂的CMS建站系统?厌倦了升级,迁移,学习管理...

然而,Sphinx-doc太单调太简单了,Jekyll也还是太复杂...

那么zcms来了, 一个极简的CMS,都是你熟悉的:

  • 无需数据库, 每个页面是一个文本文件
  • 扩展reStructuredText指令(.rst),轻松实现博客、导航、新闻等动态内容
  • 支持Markdown格式(.md)编写页面
  • 当然支持html页面(.html)
  • 支持多站点

zcms吸取了Jekyll优点,使用python/pyramid开发完成,完全无需任何开发知识即可掌握.

欢迎微博传播,如有反馈,请微博联系: http://weibo.com/panjunyong

启动服务

准备运行环境:

python bootstrap.py bin/buildout

站点制作过程,启动:

./bin/pserve development.ini

正式使用(缓存加速),启动:

./bin/pserve production.ini

示例站点

我们易度的所有站点,都采用这个开发完成:

无阻力建站

  1. 创建站点文件夹

    站点默认放置在sites文件夹下,比如sites/demo

  2. 填充站点内容

    在站点文件夹下创建子文件夹和页面,子文件夹将自动成为子栏目, index.rst或index.md自动成为子栏目的首页:

    demo/

    index.rst tour/

    System Message: ERROR/3 (<string>, line 58)

    Unexpected indentation.

    index.rst install.rst sites.rst

    System Message: WARNING/2 (<string>, line 61)

    Block quote ends without a blank line; unexpected unindent.

    blog/

    index.rst post01.rst post02.rst

    System Message: WARNING/2 (<string>, line 65)

    Definition list ends without a blank line; unexpected unindent.

    about.rst img/

    System Message: ERROR/3 (<string>, line 67)

    Unexpected indentation.

    logo.png

  3. 完工,你也看到一个twitter bootstrap风格的站点!

    很不完美,后面来完善...

文件夹和页面属性

站点基本可以工作, 存在的问题:

  • 栏目顺序比较随机无序
  • 栏目标题是文件名,可能需要中文标题

每个文件夹下,可以放置一个 _config.yaml 的文件,在这里设置文件夹的属性:

title: 教程 # 标题 order: [index.rst, tour, blog, about.rst] # 显示顺序 exclude: [img] # 隐藏图片文件夹的显示

对于rst/md的页面文件, 可直接在文件头部指定这些信息:

--- title: 教程 # 标题 creator: 潘俊勇 # 创建人 created: 2010-12-12 9:12 # 创建时间,新闻根据这个时间排序 ---

页面文件的属性,必须以三个短横开始和结束

设置左右列以及头部信息

对整个文件夹下的页面模版,可以定制左侧、右侧和头部的显示信息,分别加入:

  1. _left.rst
  2. _right.rst
  3. _upper.rst

如果具体某个页面,需要定制,也可以单独设置,通过命名来区分:

  1. index.rst 页面的头部信息 _upper_index.rst
  2. about.rst 页面的左侧信息 _left_about.rst

动态内容

可在reST中使用如下指令即可:

  1. 最近新闻

    System Message: ERROR/3 (<string>, line 117)

    Unknown directive type "news".

    .. news::
       :size: 5
       :path: blog
    
    
  2. 博客页面

    System Message: ERROR/3 (<string>, line 123)

    Unknown directive type "blogs".

    .. blogs::
       :size: 20
    
    
  3. 导航树

    System Message: ERROR/3 (<string>, line 128)

    Unknown directive type "navtree".

    .. navtree::
       :root_depth: 2
    
    

外观模版的设置

在站点根文件夹下面的_config.yaml里面,定义了整个站点的皮肤

theme_base: http://localhost:6543/themes/bootstrap # 存放模版的基准位置,这里可能存放了多个模版 theme: default.html # 默认的模版

外观模版是通过一个网址来指定的,上面的完整外观模版地址是:

http://localhost:6543/themes/bootstrap/default.html

如果不想使用默认的外观模版,可文件夹或页面属性中,设置个性化的外观模版:

theme: home.html # 首页模版,可能没有左右列

这里会使用外观模版:

http://localhost:6543/themes/bootstrap/home.html

制作外观模版

可看看themes文件夹里面的文件,其实就是一个python的String Template.

这个文件里面可以包括如下变量:

  • site_title: 站点的标题
  • site_description: 当前内容的描述信息
  • nav: 站点的导航栏目
  • title: 当前内容的标题
  • description: 当前内容的描述信息
  • content: 当前内容正文
  • left: 左侧列显示的内容
  • right: 右侧列显示的内容
  • upper: 上方区域显示的内容
  • theme_base: 外观模版的所在的位置

一个最基础的外观模版可以是:

<html>
<head>
<title>$title - $site_title</title> <meta name="Description" content="$site_description"/>

System Message: WARNING/2 (<string>, line 174)

Definition list ends without a blank line; unexpected unindent.

</head> <body>

System Message: ERROR/3 (<string>, line 176)

Unexpected indentation.

<ul>$namv</ul> <div>$top</div> <table>

System Message: ERROR/3 (<string>, line 179)

Unexpected indentation.
<tr>
<td>$left</td> <td>$content</td> <td>$right</td>

System Message: WARNING/2 (<string>, line 183)

Definition list ends without a blank line; unexpected unindent.

</tr>

System Message: WARNING/2 (<string>, line 184)

Block quote ends without a blank line; unexpected unindent.

</table>

System Message: WARNING/2 (<string>, line 185)

Block quote ends without a blank line; unexpected unindent.

</body>

System Message: WARNING/2 (<string>, line 186)

Definition list ends without a blank line; unexpected unindent.

</html>

nginx虚拟主机

默认安装,我们得到的地址首页是

http://server.com:6543/site_name

如果我们希望实际类似这样访问

http://site_name.server.com

需要调整:

  1. nginx.conf里面,增加rewrite指令

    server{

    listen 80;

    location / {

    proxy_set_header HOST $host:$server_host;

    # 设置静态皮肤的访问,也可以改为直接由nginx提供下载 rewrite ^/themes/(.*) /themes/$1 break;

    # 访问viewer.example.com, 直接进入viewer站点 if ($host = viewer.example.com){

    System Message: ERROR/3 (<string>, line 213)

    Unexpected indentation.

    rewrite ^/(.*) /viewer/$1 break;

    System Message: WARNING/2 (<string>, line 214)

    Block quote ends without a blank line; unexpected unindent.

    }

    # 访问docs.example.com, 直接进入docs站点 if ($host = docs.example.com){

    System Message: ERROR/3 (<string>, line 218)

    Unexpected indentation.

    rewrite ^/(.*) /docs/$1 break;

    System Message: WARNING/2 (<string>, line 219)

    Block quote ends without a blank line; unexpected unindent.

    }

    # 根站点 if ($host = example.com){

    System Message: ERROR/3 (<string>, line 223)

    Unexpected indentation.

    rewrite ^/(.*) /example/$1 break;

    System Message: WARNING/2 (<string>, line 224)

    Block quote ends without a blank line; unexpected unindent.

    }

    proxy_pass http://localhost:6543; proxy_redirect off;

    System Message: WARNING/2 (<string>, line 228)

    Definition list ends without a blank line; unexpected unindent.

    }

    }

  2. 开启虚拟主机功能, 调整production.ini,设置use_vhm = true

uwsgi配置

zcms也可以在uwsgi下运行,配置方法与nginx虚拟主机类似。

需要调整:

  1. nginx.conf里面,增加rewrite指令

    server{

    listen 80;

    location / {

    # uwsgi设置 uwsgi_param SCRIPT_NAME ""; include uwsgi_params; uwsgi_pass 127.0.0.1:9010;

    # 设置静态皮肤的访问,也可以改为直接由nginx提供下载 rewrite ^/themes/(.*) /themes/$1 break;

    # 访问viewer.example.com, 直接进入viewer站点 if ($host = viewer.example.com){

    System Message: ERROR/3 (<string>, line 257)

    Unexpected indentation.

    rewrite ^/(.*) /viewer/$1 break;

    System Message: WARNING/2 (<string>, line 258)

    Block quote ends without a blank line; unexpected unindent.

    }

    # 访问docs.example.com, 直接进入docs站点 if ($host = docs.example.com){

    System Message: ERROR/3 (<string>, line 262)

    Unexpected indentation.

    rewrite ^/(.*) /docs/$1 break;

    System Message: WARNING/2 (<string>, line 263)

    Block quote ends without a blank line; unexpected unindent.

    }

    # 根站点 if ($host = example.com){

    System Message: ERROR/3 (<string>, line 267)

    Unexpected indentation.

    rewrite ^/(.*) /example/$1 break;

    System Message: WARNING/2 (<string>, line 268)

    Block quote ends without a blank line; unexpected unindent.

    }

    }

    }

  2. 开启虚拟主机功能, 调整production.ini,设置use_vhm = true

  3. 运行uwsgi --ini uwsgi.ini, uwsgi默认调用9010端口

TODO

  1. 默认的bootstrap风格皮肤还很弱,还没有支持right列
  2. production模式下,应该大量缓存加速,减少io
  3. 提供webdav api
  4. 提供RSS输出
  5. 使用zapian进行全文搜索、排序等

CHANGES

v1.0 - 2013.1.1

  • 借鉴Jekyll,简化配置
  • 大量简化从前的历史代码

v0.5 - 2012.12.30

  • 去除wsgi Theme Filter, 简化
  • 去除对themes文件夹的依赖,在站点metadata.json中可设置theme_url里面是皮肤的url地址,默认是自带的bootstrap风格皮肤
  • 支持markdown

v0.1 - 2012.12.14

  • 调整.json的位置,去除多余的文件夹
  • 调整.json的内容,简化

Subscribe to package updates

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.