BoPress,使用Python语言编写的Web后台框架,全插件式驱动,深度借鉴WordPress,但不致力博文开发,更倾向于锻造一个稳固的通用后台,系统仅提供用户,角色,权限,认证,选项,缓存,插件系统等基础组件。 (对这个项目有兴趣的朋友,可以关注,私信给我!)
BoPress 主要依赖以下开源项目
TornadoSQLAlchemyAdminLTE运行安装依赖
Python 2.7+
pip install -r requirements.txt
默认使用SQLite数据库,使用其它数据库请修改plugins/bocore/meta.py内的数据库连接配置
运行 bopress.py, super,super 登录后台
创建相册插件示例 导出 MarkdownHTMLPDF插件最终效果图
1.创建gallerydemo插件包
2.创建模板,从bocore/admin/下拷贝blank.html到gallerydemo/tpl/目录下,改名为gallery.html,记得修改继承的母版路径。plugins/为根目录,相对路径以此展开。
{% extends "../../bocore/admin/master.html" %}3.添加菜单
add_menu_page("Gallery Demo", "Gallery Demo", "gallery-demo", ["read"], "gallerydemo/tpl/gallery.html")4.添加静态资源路径,下载相册插件相册插件并放置到静态资源文件夹下,然后增加引入资源动作
add_static_path("gallerydemo/static")def scripts(res, current_screen): if current_screen.id == "gallery-demo": res.enqueue_plugin_script(src="gallerydemo/static/js/jquery.justifiedGallery.min.js", ver="3.6.3")def styles(res, current_screen): if current_screen.id == "gallery-demo": res.enqueue_plugin_style(src="gallerydemo/static/css/justifiedGallery.min.css", ver="3.6.3")add_action("bo_enqueue_styles", styles)add_action("bo_enqueue_scripts", scripts)5.添加数据API
def data(handler): items = [ "http://img.pconline.com.cn/images/upload/upc/tx/ladyproduct/1702/22/c0/37883495_1487730822580.ajpg", ... "http://img.pconline.com.cn/images/upload/upc/tx/ladyproduct/1702/22/c0/37883495_1487730864497.jpg" ] html = list() for v in items: h = """ <a href="{0}"><img alt="相册样例" src="{0}"/></a> """.format(v, v) html.append(h) handler.render_json("".join(html))add_action("bo_api_get_gallery_demo_data", data)6.修改 gallery.html 模板文件
{% block content_body%}<div id="demo-gallery" ></div>{% end %}{% block footer%}<script type="text/javascript"> $(function(){ $.get("{{api('gallery_demo_data')}}", {}, function(rsp){ console.log(rsp); $("#demo-gallery").html(rsp.data); $("#demo-gallery").justifiedGallery(); }, "json"); });</script>{% end %}screenshots