BoPress,使用Python語言編寫的Web后臺(tái)框架,全插件式驅(qū)動(dòng),深度借鑒WordPress,但不致力博文開發(fā),更傾向于鍛造一個(gè)穩(wěn)固的通用后臺(tái),系統(tǒng)僅提供用戶,角色,權(quán)限,認(rèn)證,選項(xiàng),緩存,插件系統(tǒng)等基礎(chǔ)組件。 (對這個(gè)項(xiàng)目有興趣的朋友,可以關(guān)注,私信給我?。?/p>
BoPress 主要依賴以下開源項(xiàng)目
TornadoSQLAlchemyAdminLTE運(yùn)行安裝依賴
Python 2.7+
pip install -r requirements.txt
默認(rèn)使用SQLite數(shù)據(jù)庫,使用其它數(shù)據(jù)庫請修改plugins/bocore/meta.py內(nèi)的數(shù)據(jù)庫連接配置
運(yùn)行 bopress.py, super,super 登錄后臺(tái)
創(chuàng)建相冊插件示例 導(dǎo)出 MarkdownHTMLPDF插件最終效果圖
1.創(chuàng)建gallerydemo插件包
2.創(chuàng)建模板,從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.添加靜態(tài)資源路徑,下載相冊插件相冊插件并放置到靜態(tài)資源文件夾下,然后增加引入資源動(dòng)作
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.添加數(shù)據(jù)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掃描二維碼推送至手機(jī)訪問。
版權(quán)聲明:本文由信途科技轉(zhuǎn)載于網(wǎng)絡(luò),如有侵權(quán)聯(lián)系站長刪除。
轉(zhuǎn)載請注明出處http://macbookprostickers.com/xintu/15841.html