├── logs └── .gitignore ├── .gitignore ├── extends ├── __init__.py ├── time_task.py ├── utils.py ├── session_redis.py ├── cache_tornadis.py ├── session_tornadis.py └── pub_sub_tornadis.py ├── model ├── __init__.py ├── search_params │ ├── __init__.py │ ├── menu_params.py │ ├── plugin_params.py │ ├── article_type_params.py │ ├── comment_params.py │ └── article_params.py ├── constants.py ├── site_info.py ├── logined_user.py └── pager.py ├── controller ├── __init__.py ├── super.py └── admin.py ├── alembic ├── README ├── script.py.mako └── env.py ├── static ├── favicon.ico ├── images │ ├── background.jpg │ └── loading154.gif ├── tinymce │ └── js │ │ └── tinymce │ │ ├── skins │ │ ├── myskin │ │ │ ├── fonts │ │ │ │ ├── readme.md │ │ │ │ ├── tinymce.eot │ │ │ │ ├── tinymce.ttf │ │ │ │ ├── tinymce.woff │ │ │ │ ├── tinymce-small.eot │ │ │ │ ├── tinymce-small.ttf │ │ │ │ └── tinymce-small.woff │ │ │ ├── img │ │ │ │ ├── anchor.gif │ │ │ │ ├── loader.gif │ │ │ │ ├── object.gif │ │ │ │ └── trans.gif │ │ │ ├── content.min.css │ │ │ ├── content.inline.min.css │ │ │ └── skin.json │ │ └── lightgray │ │ │ ├── img │ │ │ ├── anchor.gif │ │ │ ├── loader.gif │ │ │ ├── object.gif │ │ │ └── trans.gif │ │ │ ├── fonts │ │ │ ├── tinymce.eot │ │ │ ├── tinymce.ttf │ │ │ ├── tinymce.woff │ │ │ ├── tinymce-small.eot │ │ │ ├── tinymce-small.ttf │ │ │ └── tinymce-small.woff │ │ │ ├── content.inline.min.css │ │ │ └── content.min.css │ │ ├── plugins │ │ ├── example_dependency │ │ │ └── plugin.min.js │ │ ├── media │ │ │ └── moxieplayer.swf │ │ ├── emoticons │ │ │ ├── img │ │ │ │ ├── smiley-cool.gif │ │ │ │ ├── smiley-cry.gif │ │ │ │ ├── smiley-kiss.gif │ │ │ │ ├── smiley-wink.gif │ │ │ │ ├── smiley-yell.gif │ │ │ │ ├── smiley-frown.gif │ │ │ │ ├── smiley-sealed.gif │ │ │ │ ├── smiley-smile.gif │ │ │ │ ├── smiley-innocent.gif │ │ │ │ ├── smiley-laughing.gif │ │ │ │ ├── smiley-surprised.gif │ │ │ │ ├── smiley-undecided.gif │ │ │ │ ├── smiley-embarassed.gif │ │ │ │ ├── smiley-money-mouth.gif │ │ │ │ ├── smiley-tongue-out.gif │ │ │ │ └── smiley-foot-in-mouth.gif │ │ │ └── plugin.min.js │ │ ├── example │ │ │ ├── dialog.html │ │ │ └── plugin.min.js │ │ ├── print │ │ │ └── plugin.min.js │ │ ├── hr │ │ │ └── plugin.min.js │ │ ├── anchor │ │ │ └── plugin.min.js │ │ ├── nonbreaking │ │ │ └── plugin.min.js │ │ ├── code │ │ │ └── plugin.min.js │ │ ├── directionality │ │ │ └── plugin.min.js │ │ ├── contextmenu │ │ │ └── plugin.min.js │ │ ├── wordcount │ │ │ └── plugin.min.js │ │ ├── noneditable │ │ │ └── plugin.min.js │ │ ├── save │ │ │ └── plugin.min.js │ │ ├── visualblocks │ │ │ ├── plugin.min.js │ │ │ └── css │ │ │ │ └── visualblocks.css │ │ ├── colorpicker │ │ │ └── plugin.min.js │ │ ├── pagebreak │ │ │ └── plugin.min.js │ │ ├── visualchars │ │ │ └── plugin.min.js │ │ ├── tabfocus │ │ │ └── plugin.min.js │ │ ├── advlist │ │ │ └── plugin.min.js │ │ ├── preview │ │ │ └── plugin.min.js │ │ ├── fullscreen │ │ │ └── plugin.min.js │ │ ├── autoresize │ │ │ └── plugin.min.js │ │ ├── autolink │ │ │ └── plugin.min.js │ │ ├── insertdatetime │ │ │ └── plugin.min.js │ │ ├── autosave │ │ │ └── plugin.min.js │ │ ├── importcss │ │ │ └── plugin.min.js │ │ ├── textpattern │ │ │ └── plugin.min.js │ │ ├── layer │ │ │ └── plugin.min.js │ │ ├── codesample │ │ │ └── css │ │ │ │ └── prism.css │ │ ├── bbcode │ │ │ └── plugin.min.js │ │ ├── legacyoutput │ │ │ └── plugin.min.js │ │ ├── textcolor │ │ │ └── plugin.min.js │ │ ├── template │ │ │ └── plugin.min.js │ │ └── link │ │ │ └── plugin.min.js │ │ ├── langs │ │ └── readme.md │ │ └── jquery.tinymce.min.js ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── js │ ├── super.js │ ├── npm.js │ ├── markdownEdit.js │ ├── markdown │ │ └── locale │ │ │ └── bootstrap-markdown.zh.js │ ├── floatButton.js │ ├── tinymce_setup.js │ └── articleDetail.js └── css │ ├── highlight │ └── default.min.css │ ├── bootstrap-markdown.min.css │ └── prism.css ├── docker ├── entrypoint.sh └── nginx.conf ├── requirements.txt ├── template ├── 403.html ├── 404.html ├── 500.html ├── admin │ ├── blog_plugin_add.html │ ├── blog_plugin_edit.html │ ├── help_page.html │ ├── admin_base.html │ ├── submit_articles.html │ ├── custom_blog_info.html │ ├── admin_account.html │ └── custom_blog_plugin.html ├── index.html ├── super │ └── init.html ├── _macros.html ├── auth │ └── login.html ├── article_detials.html └── _article_comments.html ├── service ├── __init__.py ├── custom_service.py ├── blog_view_service.py ├── pubsub_service.py ├── user_service.py ├── menu_service.py ├── comment_service.py ├── plugin_service.py └── article_type_service.py ├── log_config.py ├── alembic.ini ├── config.py ├── url_mapping.py └── README.md /logs/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | logs 2 | -------------------------------------------------------------------------------- /extends/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | -------------------------------------------------------------------------------- /model/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | -------------------------------------------------------------------------------- /controller/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | -------------------------------------------------------------------------------- /alembic/README: -------------------------------------------------------------------------------- 1 | Generic single-database configuration. -------------------------------------------------------------------------------- /model/search_params/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | -------------------------------------------------------------------------------- /static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/favicon.ico -------------------------------------------------------------------------------- /static/images/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/images/background.jpg -------------------------------------------------------------------------------- /static/images/loading154.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/images/loading154.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/myskin/fonts/readme.md: -------------------------------------------------------------------------------- 1 | Icons are generated and provided by the http://icomoon.io service. 2 | -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/example_dependency/plugin.min.js: -------------------------------------------------------------------------------- 1 | tinymce.PluginManager.add("example_dependency",function(){},["example"]); -------------------------------------------------------------------------------- /static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /docker/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | if [ "$1" == "upgradedb" ] 5 | then 6 | python main.py upgradedb 7 | fi 8 | exec supervisord -n 9 | -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/myskin/img/anchor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/myskin/img/anchor.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/myskin/img/loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/myskin/img/loader.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/myskin/img/object.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/myskin/img/object.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/myskin/img/trans.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/myskin/img/trans.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/media/moxieplayer.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/media/moxieplayer.swf -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/lightgray/img/anchor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/lightgray/img/anchor.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/lightgray/img/loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/lightgray/img/loader.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/lightgray/img/object.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/lightgray/img/object.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/lightgray/img/trans.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/lightgray/img/trans.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/myskin/fonts/tinymce.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/myskin/fonts/tinymce.eot -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/myskin/fonts/tinymce.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/myskin/fonts/tinymce.ttf -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | tornado==4.4.2 2 | sqlalchemy==1.0.15 3 | tornadis==0.8.0 4 | futures==3.0.5 5 | alembic==0.9.1 6 | apscheduler==3.3.1 7 | mysql-connector-python==8.0.23 -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/myskin/fonts/tinymce.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/myskin/fonts/tinymce.woff -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.eot -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.ttf -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/lightgray/fonts/tinymce.woff -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-cool.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-cool.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-cry.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-cry.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-kiss.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-kiss.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-wink.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-wink.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-yell.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-yell.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/myskin/fonts/tinymce-small.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/myskin/fonts/tinymce-small.eot -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/myskin/fonts/tinymce-small.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/myskin/fonts/tinymce-small.ttf -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/myskin/fonts/tinymce-small.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/myskin/fonts/tinymce-small.woff -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-frown.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-frown.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-sealed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-sealed.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-smile.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-smile.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/lightgray/fonts/tinymce-small.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/lightgray/fonts/tinymce-small.eot -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/lightgray/fonts/tinymce-small.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/lightgray/fonts/tinymce-small.ttf -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/skins/lightgray/fonts/tinymce-small.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/skins/lightgray/fonts/tinymce-small.woff -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-innocent.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-innocent.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-laughing.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-laughing.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-surprised.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-surprised.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-undecided.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-undecided.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-embarassed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-embarassed.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-money-mouth.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-money-mouth.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-tongue-out.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-tongue-out.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/emoticons/img/smiley-foot-in-mouth.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xtg20121013/blog_xtg/HEAD/static/tinymce/js/tinymce/plugins/emoticons/img/smiley-foot-in-mouth.gif -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/langs/readme.md: -------------------------------------------------------------------------------- 1 | This is where language files should be placed. 2 | 3 | Please DO NOT translate these directly use this service: https://www.transifex.com/projects/p/tinymce/ 4 | -------------------------------------------------------------------------------- /template/403.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %} 4 | 禁止访问 5 | {% end %} 6 | {% block content %} 7 |
"+e+"
"):a.insertContent(e)}),a.addButton("pagebreak",{title:"Page break",cmd:"mcePageBreak"}),a.addMenuItem("pagebreak",{text:"Page break",icon:"pagebreak",cmd:"mcePageBreak",context:"insert"}),a.on("ResolveName",function(c){"IMG"==c.target.nodeName&&a.dom.hasClass(c.target,b)&&(c.name="pagebreak")}),a.on("click",function(c){c=c.target,"IMG"===c.nodeName&&a.dom.hasClass(c,b)&&a.selection.select(c)}),a.on("BeforeSetContent",function(a){a.content=a.content.replace(d,e)}),a.on("PreInit",function(){a.serializer.addNodeFilter("img",function(b){for(var d,e,f=b.length;f--;)if(d=b[f],e=d.attr("class"),e&&-1!==e.indexOf("mce-pagebreak")){var g=d.parent;if(a.schema.getBlockElements()[g.name]&&a.settings.pagebreak_split_block){g.type=3,g.value=c,g.raw=!0,d.remove();continue}d.type=3,d.value=c,d.raw=!0}})})}); -------------------------------------------------------------------------------- /template/admin/blog_plugin_add.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin_base.html' %} 2 | 3 | {% block title2 %} 4 | 添加插件 5 | {% end %} 6 | 7 | {% block admin_content %} 8 |{{ article.summary }}{% if len(article.summary) >= 100 %}...... {%end%}
34 |blog_xtg 是作者xiaotaogou基于Blog_mini重构的个人分布式博客系统。
由于不太擅长前端,所以基本照搬Blog_mini的页面,但是整个后端逻辑都是重写的,以下是与Blog_mini的主要区别:
18 | 19 |如果你有任何疑问,可以给作者留言:
42 | 43 |附:
44 | 45 |blog_xtg的github地址:https://github.com/xtg20121013/blog_xtg 49 |
]*>/gi,"[quote]"),b(/<\/blockquote>/gi,"[/quote]"),b(/
/gi,"\n"),b(/
/gi,"\n"),b(/
/gi,"\n"),b(//gi,""),b(/<\/p>/gi,"\n"),b(/ |\u00a0/gi," "),b(/"/gi,'"'),b(/</gi,"<"),b(/>/gi,">"),b(/&/gi,"&"),a},_punbb_bbcode2html:function(a){function b(b,c){a=a.replace(b,c)}return a=tinymce.trim(a),b(/\n/gi,"
"),b(/\[b\]/gi,""),b(/\[\/b\]/gi,""),b(/\[i\]/gi,""),b(/\[\/i\]/gi,""),b(/\[u\]/gi,""),b(/\[\/u\]/gi,""),b(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,'$2'),b(/\[url\](.*?)\[\/url\]/gi,'$1'),b(/\[img\](.*?)\[\/img\]/gi,''),b(/\[color=(.*?)\](.*?)\[\/color\]/gi,'$2'),b(/\[code\](.*?)\[\/code\]/gi,'$1 '),b(/\[quote.*?\](.*?)\[\/quote\]/gi,'$1 '),a}}),tinymce.PluginManager.add("bbcode",tinymce.plugins.BBCodePlugin)}(); -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/legacyoutput/plugin.min.js: -------------------------------------------------------------------------------- 1 | !function(a){a.on("AddEditor",function(a){a.editor.settings.inline_styles=!1}),a.PluginManager.add("legacyoutput",function(b,c,d){b.on("init",function(){var c="p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",d=a.explode(b.settings.font_size_style_values),e=b.schema;b.formatter.register({alignleft:{selector:c,attributes:{align:"left"}},aligncenter:{selector:c,attributes:{align:"center"}},alignright:{selector:c,attributes:{align:"right"}},alignjustify:{selector:c,attributes:{align:"justify"}},bold:[{inline:"b",remove:"all"},{inline:"strong",remove:"all"},{inline:"span",styles:{fontWeight:"bold"}}],italic:[{inline:"i",remove:"all"},{inline:"em",remove:"all"},{inline:"span",styles:{fontStyle:"italic"}}],underline:[{inline:"u",remove:"all"},{inline:"span",styles:{textDecoration:"underline"},exact:!0}],strikethrough:[{inline:"strike",remove:"all"},{inline:"span",styles:{textDecoration:"line-through"},exact:!0}],fontname:{inline:"font",attributes:{face:"%value"}},fontsize:{inline:"font",attributes:{size:function(b){return a.inArray(d,b.value)+1}}},forecolor:{inline:"font",attributes:{color:"%value"}},hilitecolor:{inline:"font",styles:{backgroundColor:"%value"}}}),a.each("b,i,u,strike".split(","),function(a){e.addValidElements(a+"[*]")}),e.getElementRule("font")||e.addValidElements("font[face|size|color|style]"),a.each(c.split(","),function(a){var b=e.getElementRule(a);b&&(b.attributes.align||(b.attributes.align={},b.attributesOrder.push("align")))})}),b.addButton("fontsizeselect",function(){var a=[],c="8pt=1 10pt=2 12pt=3 14pt=4 18pt=5 24pt=6 36pt=7",d=b.settings.fontsize_formats||c;return b.$.each(d.split(" "),function(b,c){var d=c,e=c,f=c.split("=");f.length>1&&(d=f[0],e=f[1]),a.push({text:d,value:e})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:a,fixedWidth:!0,onPostRender:function(){var a=this;b.on("NodeChange",function(){var c;c=b.dom.getParent(b.selection.getNode(),"font"),c?a.value(c.size):a.value("")})},onclick:function(a){a.control.settings.value&&b.execCommand("FontSize",!1,a.control.settings.value)}}}),b.addButton("fontselect",function(){function a(a){a=a.replace(/;$/,"").split(";");for(var b=a.length;b--;)a[b]=a[b].split("=");return a}var c="Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats",e=[],f=a(b.settings.font_formats||c);return d.each(f,function(a,b){e.push({text:{raw:b[0]},value:b[1],textStyle:-1==b[1].indexOf("dings")?"font-family:"+b[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:e,fixedWidth:!0,onPostRender:function(){var a=this;b.on("NodeChange",function(){var c;c=b.dom.getParent(b.selection.getNode(),"font"),c?a.value(c.face):a.value("")})},onselect:function(a){a.control.settings.value&&b.execCommand("FontName",!1,a.control.settings.value)}}})})}(tinymce); -------------------------------------------------------------------------------- /extends/session_tornadis.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | import uuid 3 | import json 4 | import tornadis 5 | import tornado.gen 6 | import logging 7 | 8 | logger = logging.getLogger(__name__) 9 | 10 | 11 | class Session(dict): 12 | def __init__(self, request_handler): 13 | super(Session, self).__init__() 14 | self.session_id = None 15 | self.session_manager = request_handler.application.session_manager 16 | self.request_handler = request_handler 17 | self.client = None 18 | 19 | @tornado.gen.coroutine 20 | def init_fetch(self): 21 | self.client = yield self.session_manager.get_redis_client() 22 | yield self.fetch_client() 23 | 24 | def get_session_id(self): 25 | if not self.session_id: 26 | self.session_id = self.request_handler.get_secure_cookie(self.session_manager.session_key_name) 27 | return self.session_id 28 | 29 | def generate_session_id(self): 30 | if not self.get_session_id(): 31 | self.session_id = str(uuid.uuid1()) 32 | self.request_handler.set_secure_cookie(self.session_manager.session_key_name, self.session_id, 33 | expires_days=self.session_manager.session_expires_days) 34 | return self.session_id 35 | 36 | @tornado.gen.coroutine 37 | def fetch_client(self): 38 | if self.get_session_id(): 39 | data = yield self.call_client("GET", self.session_id) 40 | if data: 41 | self.update(json.loads(data)) 42 | 43 | @tornado.gen.coroutine 44 | def save(self, expire_time=None): 45 | session_id = self.generate_session_id() 46 | data_json = json.dumps(self) 47 | yield self.call_client("SET", session_id, data_json) 48 | if expire_time: 49 | yield self.call_client("EXPIRE", session_id, expire_time) 50 | 51 | @tornado.gen.coroutine 52 | def call_client(self, *args, **kwargs): 53 | if self.client: 54 | reply = yield self.client.call(*args, **kwargs) 55 | if isinstance(reply, tornadis.TornadisException): 56 | logger.error(reply.message) 57 | else: 58 | raise tornado.gen.Return(reply) 59 | 60 | 61 | class SessionManager(object): 62 | def __init__(self, options): 63 | self.connection_pool = None 64 | self.options = options 65 | self.session_key_name = options['session_key_name'] 66 | self.session_expires_days = options['session_expires_days'] 67 | 68 | def get_connection_pool(self): 69 | if not self.connection_pool: 70 | self.connection_pool = tornadis.ClientPool(host=self.options['host'],port=self.options['port'], 71 | password=self.options['password'], db=self.options['db_no'], 72 | max_size=self.options['max_connections']) 73 | return self.connection_pool 74 | 75 | @tornado.gen.coroutine 76 | def get_redis_client(self): 77 | connection_pool = self.get_connection_pool() 78 | with (yield connection_pool.connected_client()) as client: 79 | if isinstance(client, tornadis.TornadisException): 80 | logger.error(client.message) 81 | else: 82 | raise tornado.gen.Return(client) 83 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | from urllib import quote_plus as urlquote 3 | 4 | cookie_keys = dict( 5 | session_key_name="TR_SESSION_ID", 6 | uv_key_name="uv_tag", 7 | ) 8 | 9 | # session相关配置(redis实现) 10 | redis_session_config = dict( 11 | db_no=0, 12 | host="127.0.0.1", 13 | port=6379, 14 | password=None, 15 | max_connections=10, 16 | session_key_name=cookie_keys['session_key_name'], 17 | session_expires_days=7, 18 | ) 19 | 20 | # 站点缓存(redis) 21 | site_cache_config = dict( 22 | db_no=1, 23 | host="127.0.0.1", 24 | port=6379, 25 | password=None, 26 | max_connections=10, 27 | ) 28 | 29 | # 基于redis的消息订阅(发布接收缓存更新消息) 30 | redis_pub_sub_channels = dict( 31 | cache_message_channel="site_cache_message_channel", 32 | ) 33 | 34 | # 消息订阅(基于redis)配置 35 | redis_pub_sub_config = dict( 36 | host="127.0.0.1", 37 | port=6379, 38 | password=None, 39 | autoconnect=True, 40 | channels=[redis_pub_sub_channels['cache_message_channel'],], 41 | ) 42 | 43 | # 数据库配置 44 | database_config = dict( 45 | engine=None, 46 | # engine_url='postgresql+psycopg2://mhq:1qaz2wsx@localhost:5432/blog', 47 | # 如果是使用mysql+mysqldb,在确认所有的库表列都是uft8编码后,依然有字符编码报错, 48 | # 可以尝试在该url末尾加上queryString charset=utf8 49 | engine_url='mysql+mysqlconnector://root:%s@localhost:3306/blog_xtg?charset=utf8' % urlquote('MyPass@123'), 50 | engine_setting=dict( 51 | echo=False, # print sql 52 | echo_pool=False, 53 | # 设置7*60*60秒后回收连接池,默认-1,从不重置 54 | # 该参数会在每个session调用执行sql前校验当前时间与上一次连接时间间隔是否超过pool_recycle,如果超过就会重置。 55 | # 这里设置7小时是为了避免mysql默认会断开超过8小时未活跃过的连接,避免"MySQL server has gone away”错误 56 | # 如果mysql重启或断开过连接,那么依然会在第一次时报"MySQL server has gone away", 57 | # 假如需要非常严格的mysql断线重连策略,可以设置心跳。 58 | # 心跳设置参考https://stackoverflow.com/questions/18054224/python-sqlalchemy-mysql-server-has-gone-away 59 | pool_recycle=25200, 60 | pool_size=20, 61 | max_overflow=20, 62 | ), 63 | ) 64 | 65 | session_keys = dict( 66 | login_user="login_user", 67 | messages="messages", 68 | article_draft="article_draft", 69 | ) 70 | 71 | # 关联model.site_info中的字段 72 | site_cache_keys = dict( 73 | title="title", 74 | signature="signature", 75 | navbar="navbar", 76 | menus="menus", 77 | article_types_not_under_menu="article_types_not_under_menu", 78 | plugins="plugins", 79 | pv="pv", 80 | uv="uv", 81 | article_count="article_count", 82 | comment_count="comment_count", 83 | article_sources="article_sources", 84 | source_articles_count="source_{}_articles_count", 85 | ) 86 | 87 | # 站点相关配置以及tornado的相关参数 88 | config = dict( 89 | debug=False, 90 | log_level="INFO", 91 | log_console=True, 92 | log_file=False, 93 | log_file_path="logs/log", # 末尾自动添加 @端口号.txt_日期 94 | compress_response=True, 95 | xsrf_cookies=True, 96 | cookie_secret="kjsdhfweiofjhewnfiwehfneiwuhniu", 97 | login_url="/auth/login", 98 | port=8888, 99 | max_threads_num=500, 100 | database=database_config, 101 | redis_session=redis_session_config, 102 | session_keys=session_keys, 103 | master=True, # 是否为主从节点中的master节点, 整个集群有且仅有一个,(要提高可用性的话可以用zookeeper来选主,该项目就暂时不做了) 104 | navbar_styles={"inverse": "魅力黑", "default": "优雅白"}, # 导航栏样式 105 | default_avatar_url="identicon", 106 | application=None, # 项目启动后会在这里注册整个server,以便在需要的地方调用,勿修改 107 | ) -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/jquery.tinymce.min.js: -------------------------------------------------------------------------------- 1 | !function(a){function b(){function b(a){"remove"===a&&this.each(function(a,b){var c=e(b);c&&c.remove()}),this.find("span.mceEditor,div.mceEditor").each(function(a,b){var c=tinymce.get(b.id.replace(/_parent$/,""));c&&c.remove()})}function d(a){var c,d=this;if(null!=a)b.call(d),d.each(function(b,c){var d;(d=tinymce.get(c.id))&&d.setContent(a)});else if(d.length>0&&(c=tinymce.get(d[0].id)))return c.getContent()}function e(a){var b=null;return a&&a.id&&g.tinymce&&(b=tinymce.get(a.id)),b}function f(a){return!!(a&&a.length&&g.tinymce&&a.is(":tinymce"))}var h={};a.each(["text","html","val"],function(b,g){var i=h[g]=a.fn[g],j="text"===g;a.fn[g]=function(b){var g=this;if(!f(g))return i.apply(g,arguments);if(b!==c)return d.call(g.filter(":tinymce"),b),i.apply(g.not(":tinymce"),arguments),g;var h="",k=arguments;return(j?g:g.eq(0)).each(function(b,c){var d=e(c);h+=d?j?d.getContent().replace(/<(?:"[^"]*"|'[^']*'|[^'">])*>/g,""):d.getContent({save:!0}):i.apply(a(c),k)}),h}}),a.each(["append","prepend"],function(b,d){var g=h[d]=a.fn[d],i="prepend"===d;a.fn[d]=function(a){var b=this;return f(b)?a!==c?("string"==typeof a&&b.filter(":tinymce").each(function(b,c){var d=e(c);d&&d.setContent(i?a+d.getContent():d.getContent()+a)}),g.apply(b.not(":tinymce"),arguments),b):void 0:g.apply(b,arguments)}}),a.each(["remove","replaceWith","replaceAll","empty"],function(c,d){var e=h[d]=a.fn[d];a.fn[d]=function(){return b.call(this,d),e.apply(this,arguments)}}),h.attr=a.fn.attr,a.fn.attr=function(b,g){var i=this,j=arguments;if(!b||"value"!==b||!f(i))return g!==c?h.attr.apply(i,j):h.attr.apply(i,j);if(g!==c)return d.call(i.filter(":tinymce"),g),h.attr.apply(i.not(":tinymce"),j),i;var k=i[0],l=e(k);return l?l.getContent({save:!0}):h.attr.apply(a(k),j)}}var c,d,e,f=[],g=window;a.fn.tinymce=function(c){function h(){var d=[],f=0;e||(b(),e=!0),l.each(function(a,b){var e,g=b.id,h=c.oninit;g||(b.id=g=tinymce.DOM.uniqueId()),tinymce.get(g)||(e=new tinymce.Editor(g,c,tinymce.EditorManager),d.push(e),e.on("init",function(){var a,b=h;l.css("visibility",""),h&&++f==d.length&&("string"==typeof b&&(a=-1===b.indexOf(".")?null:tinymce.resolve(b.replace(/\.\w+$/,"")),b=tinymce.resolve(b)),b.apply(a||tinymce,d))}))}),a.each(d,function(a,b){b.render()})}var i,j,k,l=this,m="";if(!l.length)return l;if(!c)return window.tinymce?tinymce.get(l[0].id):null;if(l.css("visibility","hidden"),g.tinymce||d||!(i=c.script_url))1===d?f.push(h):h();else{d=1,j=i.substring(0,i.lastIndexOf("/")),-1!=i.indexOf(".min")&&(m=".min"),g.tinymce=g.tinyMCEPreInit||{base:j,suffix:m},-1!=i.indexOf("gzip")&&(k=c.language||"en",i=i+(/\?/.test(i)?"&":"?")+"js=true&core=true&suffix="+escape(m)+"&themes="+escape(c.theme||"modern")+"&plugins="+escape(c.plugins||"")+"&languages="+(k||""),g.tinyMCE_GZ||(g.tinyMCE_GZ={start:function(){function b(a){tinymce.ScriptLoader.markDone(tinymce.baseURI.toAbsolute(a))}b("langs/"+k+".js"),b("themes/"+c.theme+"/theme"+m+".js"),b("themes/"+c.theme+"/langs/"+k+".js"),a.each(c.plugins.split(","),function(a,c){c&&(b("plugins/"+c+"/plugin"+m+".js"),b("plugins/"+c+"/langs/"+k+".js"))})},end:function(){}}));var n=document.createElement("script");n.type="text/javascript",n.onload=n.onreadystatechange=function(b){b=b||window.event,2===d||"load"!=b.type&&!/complete|loaded/.test(n.readyState)||(tinymce.dom.Event.domLoaded=1,d=2,c.script_loaded&&c.script_loaded(),h(),a.each(f,function(a,b){b()}))},n.src=i,document.body.appendChild(n)}return l},a.extend(a.expr[":"],{tinymce:function(a){var b;return a.id&&"tinymce"in window&&(b=tinymce.get(a.id),b&&b.editorManager===tinymce)?!0:!1}})}(jQuery); -------------------------------------------------------------------------------- /extends/pub_sub_tornadis.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import tornado.ioloop 3 | import tornado.gen 4 | import tornadis 5 | import logging 6 | 7 | logger = logging.getLogger(__name__) 8 | 9 | 10 | class PubSubTornadis(object): 11 | 12 | def __init__(self, redis_pub_sub_config, loop=None): 13 | self.redis_pub_sub_config = redis_pub_sub_config 14 | if not loop: 15 | loop = tornado.ioloop.IOLoop.current() 16 | self.loop = loop 17 | self.autoconnect = self.redis_pub_sub_config['autoconnect'] 18 | self.client = self.get_client() 19 | self.pub_client = None 20 | self.connect_times = 0 21 | self.max_connect_wait_time = 10 22 | 23 | def get_client(self): 24 | client = tornadis.PubSubClient(host=self.redis_pub_sub_config['host'], port=self.redis_pub_sub_config['port'], 25 | password=self.redis_pub_sub_config['password'], 26 | autoconnect=self.autoconnect) 27 | return client 28 | 29 | def get_pub_client(self): 30 | if not self.pub_client: 31 | self.pub_client = tornadis.Client(host=self.redis_pub_sub_config['host'], 32 | port=self.redis_pub_sub_config['port'], 33 | password=self.redis_pub_sub_config['password'], 34 | autoconnect=self.autoconnect) 35 | return self.pub_client 36 | 37 | @tornado.gen.coroutine 38 | def pub_call(self, msg, *channels): 39 | pub_client = self.get_pub_client() 40 | if not pub_client.is_connected(): 41 | yield pub_client.connect() 42 | if not channels: 43 | channels = self.redis_pub_sub_config['channels'] 44 | for channel in channels: 45 | yield pub_client.call("PUBLISH", channel, msg) 46 | 47 | def long_listen(self): 48 | self.loop.add_callback(self.connect_and_listen, self.redis_pub_sub_config['channels']) 49 | 50 | @tornado.gen.coroutine 51 | def connect_and_listen(self, channels): 52 | connected = yield self.client.connect() 53 | if connected: 54 | subscribed = yield self.client.pubsub_subscribe(*channels) 55 | if subscribed: 56 | self.connect_times = 0 57 | yield self.first_do_after_subscribed() 58 | while True: 59 | msgs = yield self.client.pubsub_pop_message() 60 | try: 61 | yield self.do_msg(msgs) 62 | if isinstance(msgs, tornadis.TornadisException): 63 | # closed connection by the server 64 | break 65 | except Exception, e: 66 | logger.exception(e) 67 | self.client.disconnect() 68 | if self.autoconnect: 69 | wait_time = self.connect_times \ 70 | if self.connect_times < self.max_connect_wait_time else self.max_connect_wait_time 71 | logger.warn("等待{}s,重新连接redis消息订阅服务".format(wait_time)) 72 | yield tornado.gen.sleep(wait_time) 73 | self.long_listen() 74 | self.connect_times += 1 75 | 76 | # override 77 | @tornado.gen.coroutine 78 | def first_do_after_subscribed(self): 79 | logger.info("订阅成功") 80 | 81 | # override 82 | @tornado.gen.coroutine 83 | def do_msg(self, msgs): 84 | logger.info("收到订阅消息"+ str(msgs)) 85 | -------------------------------------------------------------------------------- /template/admin/custom_blog_info.html: -------------------------------------------------------------------------------- 1 | {% from model.site_info import SiteCollection %} 2 | {% extends 'admin_base.html' %} 3 | 4 | {% block title2 %} 5 | 基本信息 6 | {% end %} 7 | 8 | {% block admin_content %} 9 |
10 |34 | 35 | 36 |基本信息
11 |
12 |13 |33 |博客标题:
14 | {{ SiteCollection.title }} 15 |个性签名:
16 | {{ SiteCollection.signature }} 17 |导航样式:
18 | 19 | {% if SiteCollection.navbar in navbar_styles %} 20 | {{ navbar_styles[SiteCollection.navbar] }} 21 | {% else %} 22 | {{ navbar_styles['default'] }} 23 | {% end %} 24 | 25 |26 | 28 | 29 | 修改 30 | 31 |32 |37 |72 | {% end %} -------------------------------------------------------------------------------- /url_mapping.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import controller.home 3 | import controller.admin 4 | import controller.admin_custom 5 | import controller.admin_article_type 6 | import controller.admin_article 7 | import controller.super 8 | from tornado.web import url 9 | 10 | 11 | # url映射 12 | handlers = [ 13 | url(r"/", controller.home.HomeHandler, name="index"), 14 | url(r"/auth/login", controller.home.LoginHandler, name="login"), 15 | url(r"/auth/logout", controller.home.LogoutHandler, name="logout"), 16 | # articleSource 17 | url(r"/source/([0-9]+)/articles", controller.home.articleSourceHandler, name="articleSource"), 18 | # articleType 19 | url(r"/type/([0-9]+)/articles", controller.home.ArticleTypeHandler, name="articleType"), 20 | # article 21 | url(r"/article/([0-9]+)", controller.home.ArticleHandler, name="article"), 22 | url(r"/article/([0-9]+)/comment", controller.home.ArticleCommentHandler, name="articleComment"), 23 | # admin 24 | url(r"/admin/account", controller.admin.AdminAccountHandler, name="admin.account"), 25 | url(r"/admin/help", controller.admin.AdminHelpHandler, name="admin.help"), 26 | url(r"/admin/account/(change-password|edit-user-info)", 27 | controller.admin.AdminAccountHandler, name="admin.account.update"), 28 | # admin.custom 29 | url(r"/admin/custom/blog-info", 30 | controller.admin_custom.AdminCustomBlogInfoHandler, name="admin.custom.blog_info"), 31 | url(r"/admin/custom/blog-plugin", 32 | controller.admin_custom.AdminCustomBlogPluginHandler, name="admin.custom.blog_plugin"), 33 | url(r"/admin/custom/blog-plugin/(add)", 34 | controller.admin_custom.AdminCustomBlogPluginHandler, name="admin.custom.plugin.action"), 35 | url(r"/admin/custom/blog-plugin/([0-9]+)/(sort-down|sort-up|disable|enable|edit|delete)", 36 | controller.admin_custom.AdminCustomBlogPluginHandler, name="admin.custom.plugin.update"), 37 | # admin.article_type 38 | url(r"/admin/articleType", controller.admin_article_type.AdminArticleTypeHandler, name="admin.articleTypes"), 39 | url(r"/admin/articleType/(add)", 40 | controller.admin_article_type.AdminArticleTypeHandler, name="admin.articleType.action"), 41 | url(r"/admin/articleType/([0-9]+)/(delete|update)", 42 | controller.admin_article_type.AdminArticleTypeHandler, name="admin.articleType.update"), 43 | # admin.article_type_nav (menu) 44 | url(r"/admin/articleType/nav", 45 | controller.admin_article_type.AdminArticleTypeNavHandler, name="admin.articleTypeNavs"), 46 | url(r"/admin/articleType/nav/(add)", 47 | controller.admin_article_type.AdminArticleTypeNavHandler, name="admin.articleTypeNav.action"), 48 | url(r"/admin/articleType/nav/([0-9]+)/(sort-down|sort-up|delete|update)", 49 | controller.admin_article_type.AdminArticleTypeNavHandler, name="admin.articleTypeNav.update"), 50 | # admin.article 51 | url(r"/admin/article/(submit)", controller.admin_article.AdminArticleHandler, name="admin.article.action"), 52 | url(r"/admin/article", controller.admin_article.AdminArticleHandler, name="admin.articles"), 53 | url(r"/admin/article/([0-9]+)", controller.admin_article.AdminArticleHandler, name="admin.article"), 54 | url(r"/admin/article/([0-9]+)/(delete)", controller.admin_article.AdminArticleHandler, name="admin.article.update"), 55 | 56 | url(r"/admin/comment", controller.admin_article.AdminArticleCommentHandler, name="admin.comments"), 57 | url(r"/admin/article/([0-9]+)/comment/([0-9]+)/(disable|enable|delete)", 58 | controller.admin_article.AdminArticleCommentHandler, name="admin.comment.update"), 59 | # super.init 60 | url(r"/super/init", controller.super.SuperHandler, name="super.init"), 61 | ] -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/textcolor/plugin.min.js: -------------------------------------------------------------------------------- 1 | tinymce.PluginManager.add("textcolor",function(a){function b(b){var c;return a.dom.getParents(a.selection.getStart(),function(a){var d;(d=a.style["forecolor"==b?"color":"background-color"])&&(c=d)}),c}function c(){var b,c,d=[];for(c=a.settings.textcolor_map||["000000","Black","993300","Burnt orange","333300","Dark olive","003300","Dark green","003366","Dark azure","000080","Navy Blue","333399","Indigo","333333","Very dark gray","800000","Maroon","FF6600","Orange","808000","Olive","008000","Green","008080","Teal","0000FF","Blue","666699","Grayish blue","808080","Gray","FF0000","Red","FF9900","Amber","99CC00","Yellow green","339966","Sea green","33CCCC","Turquoise","3366FF","Royal blue","800080","Purple","999999","Medium gray","FF00FF","Magenta","FFCC00","Gold","FFFF00","Yellow","00FF00","Lime","00FFFF","Aqua","00CCFF","Sky blue","993366","Red violet","FFFFFF","White","FF99CC","Pink","FFCC99","Peach","FFFF99","Light yellow","CCFFCC","Pale green","CCFFFF","Pale cyan","99CCFF","Light sky blue","CC99FF","Plum"],b=0;b38 | 70 |71 | '+(c?"×":"")+""}var d,e,f,g,h,k,l,m=this,n=m._id,o=0;for(d=c(),d.push({text:tinymce.translate("No color"),color:"transparent"}),f='',g=d.length-1,k=0;j>k;k++){for(f+="
"}function e(b,c){a.undoManager.transact(function(){a.focus(),a.formatter.apply(b,{value:c}),a.nodeChanged()})}function f(b){a.undoManager.transact(function(){a.focus(),a.formatter.remove(b,{value:null},null,!0),a.nodeChanged()})}function g(c){function d(a){k.hidePanel(),k.color(a),e(k.settings.format,a)}function g(){k.hidePanel(),k.resetColor(),f(k.settings.format)}function h(a,b){a.style.background=b,a.setAttribute("data-mce-color",b)}var j,k=this.parent();tinymce.DOM.getParent(c.target,".mce-custom-color-btn")&&(k.hidePanel(),a.settings.color_picker_callback.call(a,function(a){var b,c,e,f=k.panel.getEl().getElementsByTagName("table")[0];for(b=tinymce.map(f.rows[f.rows.length-1].childNodes,function(a){return a.firstChild}),e=0;e",h=0;i>h;h++)l=k*i+h,l>g?f+=" "}if(a.settings.color_picker_callback){for(f+='":(e=d[l],f+=b(e.color,e.text));f+=" ",f+=" ",h=0;i>h;h++)f+=b("","Custom color");f+=" "}return f+="e;e++)h(b[e],b[e+1].getAttribute("data-mce-color"));h(c,a),d(a)},b(k.settings.format))),j=c.target.getAttribute("data-mce-color"),j?(this.lastId&&document.getElementById(this.lastId).setAttribute("aria-selected",!1),c.target.setAttribute("aria-selected",!0),this.lastId=c.target.id,"transparent"==j?g():d(j)):null!==j&&k.hidePanel()}function h(){var a=this;a._color?e(a.settings.format,a._color):f(a.settings.format)}var i,j;j=a.settings.textcolor_rows||5,i=a.settings.textcolor_cols||8,a.addButton("forecolor",{type:"colorbutton",tooltip:"Text color",format:"forecolor",panel:{role:"application",ariaRemember:!0,html:d,onclick:g},onclick:h}),a.addButton("backcolor",{type:"colorbutton",tooltip:"Background color",format:"hilitecolor",panel:{role:"application",ariaRemember:!0,html:d,onclick:g},onclick:h})}); -------------------------------------------------------------------------------- /static/css/prism.css: -------------------------------------------------------------------------------- 1 | /* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+abap+actionscript+apacheconf+apl+applescript+asciidoc+aspnet+autoit+autohotkey+bash+basic+batch+c+brainfuck+bison+csharp+cpp+coffeescript+ruby+css-extras+d+dart+diff+docker+eiffel+elixir+erlang+fsharp+fortran+gherkin+git+glsl+go+groovy+haml+handlebars+haskell+haxe+http+icon+inform7+ini+j+jade+java+json+julia+keyman+kotlin+latex+less+lolcode+lua+makefile+markdown+matlab+mel+mizar+monkey+nasm+nginx+nim+nix+nsis+objectivec+ocaml+oz+parigp+parser+pascal+perl+php+php-extras+powershell+processing+prolog+puppet+pure+python+q+qore+r+jsx+rest+rip+roboconf+crystal+rust+sas+sass+scss+scala+scheme+smalltalk+smarty+sql+stylus+swift+tcl+textile+twig+typescript+verilog+vhdl+vim+wiki+yaml */ 2 | /** 3 | * prism.js default theme for JavaScript, CSS and HTML 4 | * Based on dabblet (http://dabblet.com) 5 | * @author Lea Verou 6 | */ 7 | 8 | code[class*="language-"], 9 | pre[class*="language-"] { 10 | color: black; 11 | background: none; 12 | text-shadow: 0 1px white; 13 | font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; 14 | direction: ltr; 15 | text-align: left; 16 | white-space: pre; 17 | word-spacing: normal; 18 | word-break: normal; 19 | word-wrap: normal; 20 | line-height: 1.5; 21 | 22 | -moz-tab-size: 4; 23 | -o-tab-size: 4; 24 | tab-size: 4; 25 | 26 | -webkit-hyphens: none; 27 | -moz-hyphens: none; 28 | -ms-hyphens: none; 29 | hyphens: none; 30 | } 31 | 32 | pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection, 33 | code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection { 34 | text-shadow: none; 35 | background: #b3d4fc; 36 | } 37 | 38 | pre[class*="language-"]::selection, pre[class*="language-"] ::selection, 39 | code[class*="language-"]::selection, code[class*="language-"] ::selection { 40 | text-shadow: none; 41 | background: #b3d4fc; 42 | } 43 | 44 | @media print { 45 | code[class*="language-"], 46 | pre[class*="language-"] { 47 | text-shadow: none; 48 | } 49 | } 50 | 51 | /* Code blocks */ 52 | pre[class*="language-"] { 53 | padding: 1em; 54 | margin: .5em 0; 55 | overflow: auto; 56 | } 57 | 58 | :not(pre) > code[class*="language-"], 59 | pre[class*="language-"] { 60 | background: #f5f2f0; 61 | } 62 | 63 | /* Inline code */ 64 | :not(pre) > code[class*="language-"] { 65 | padding: .1em; 66 | border-radius: .3em; 67 | white-space: normal; 68 | } 69 | 70 | .token.comment, 71 | .token.prolog, 72 | .token.doctype, 73 | .token.cdata { 74 | color: slategray; 75 | } 76 | 77 | .token.punctuation { 78 | color: #999; 79 | } 80 | 81 | .namespace { 82 | opacity: .7; 83 | } 84 | 85 | .token.property, 86 | .token.tag, 87 | .token.boolean, 88 | .token.number, 89 | .token.constant, 90 | .token.symbol, 91 | .token.deleted { 92 | color: #905; 93 | } 94 | 95 | .token.selector, 96 | .token.attr-name, 97 | .token.string, 98 | .token.char, 99 | .token.builtin, 100 | .token.inserted { 101 | color: #690; 102 | } 103 | 104 | .token.operator, 105 | .token.entity, 106 | .token.url, 107 | .language-css .token.string, 108 | .style .token.string { 109 | color: #a67f59; 110 | background: hsla(0, 0%, 100%, .5); 111 | } 112 | 113 | .token.atrule, 114 | .token.attr-value, 115 | .token.keyword { 116 | color: #07a; 117 | } 118 | 119 | .token.function { 120 | color: #DD4A68; 121 | } 122 | 123 | .token.regex, 124 | .token.important, 125 | .token.variable { 126 | color: #e90; 127 | } 128 | 129 | .token.important, 130 | .token.bold { 131 | font-weight: bold; 132 | } 133 | .token.italic { 134 | font-style: italic; 135 | } 136 | 137 | .token.entity { 138 | cursor: help; 139 | } 140 | 141 | -------------------------------------------------------------------------------- /service/menu_service.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import logging 3 | 4 | from sqlalchemy import func 5 | 6 | from article_type_service import ArticleTypeService 7 | from model.models import Menu 8 | from model.search_params.menu_params import MenuSearchParams 9 | from . import BaseService 10 | 11 | logger = logging.getLogger(__name__) 12 | 13 | 14 | class MenuService(object): 15 | @staticmethod 16 | def page_menus(db_session, pager, search_params): 17 | query = db_session.query(Menu) 18 | if search_params: 19 | if search_params.order_mode == MenuSearchParams.ORDER_MODE_ORDER_ASC: 20 | query = query.order_by(Menu.order.asc()) 21 | pager = BaseService.query_pager(query, pager) 22 | if pager.result: 23 | for menu in pager.result: 24 | menu.fetch_all_types() 25 | return pager 26 | 27 | @staticmethod 28 | def add_menu(db_session, menu): 29 | try: 30 | menu_to_save = Menu(**menu) 31 | menu_to_save.order = MenuService.get_max_order(db_session) + 1 32 | db_session.add(menu_to_save) 33 | db_session.commit() 34 | return menu_to_save 35 | except Exception, e: 36 | logger.exception(e) 37 | return None 38 | 39 | @staticmethod 40 | def get_max_order(db_session): 41 | max_order = db_session.query(func.max(Menu.order)).scalar() 42 | if max_order is None: 43 | max_order = 0 44 | return max_order 45 | 46 | @staticmethod 47 | def list_menus(db_session, show_types=False): 48 | menus = db_session.query(Menu).order_by(Menu.order.asc()).all() 49 | if not menus: 50 | menus = [] 51 | else: 52 | if show_types: 53 | for menu in menus: 54 | menu.fetch_all_types(only_show_not_hide=True) 55 | return menus 56 | 57 | @staticmethod 58 | def sort_up(db_session, menu_id): 59 | menu = db_session.query(Menu).get(menu_id) 60 | if menu: 61 | menu_up = db_session.query(Menu). \ 62 | filter(Menu.order < menu.order).order_by(Menu.order.desc()).first() 63 | if menu_up: 64 | order_tmp = menu.order 65 | menu.order = menu_up.order 66 | menu_up.order = order_tmp 67 | db_session.commit() 68 | return True 69 | return False 70 | 71 | @staticmethod 72 | def sort_down(db_session, menu_id): 73 | menu = db_session.query(Menu).get(menu_id) 74 | if menu: 75 | menu_up = db_session.query(Menu). \ 76 | filter(Menu.order > menu.order).order_by(Menu.order.asc()).first() 77 | if menu_up: 78 | order_tmp = menu.order 79 | menu.order = menu_up.order 80 | menu_up.order = order_tmp 81 | db_session.commit() 82 | return True 83 | return False 84 | 85 | @staticmethod 86 | def update(db_session, menu_id, menu_to_update): 87 | count = 0 88 | if menu_to_update: 89 | if "id" in menu_to_update: 90 | menu_to_update.remove("id") 91 | count = db_session.query(Menu).filter(Menu.id == menu_id).update(menu_to_update) 92 | if count: 93 | db_session.commit() 94 | return count 95 | 96 | @staticmethod 97 | def delete(db_session, menu_id): 98 | ArticleTypeService.set_article_type_menu_id_none(db_session, menu_id, auto_commit=False) 99 | count = db_session.query(Menu).filter(Menu.id == menu_id).delete() 100 | if count: 101 | db_session.commit() 102 | return count 103 | -------------------------------------------------------------------------------- /service/comment_service.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import logging 3 | 4 | from model.models import Comment 5 | from sqlalchemy.sql import func 6 | from sqlalchemy.orm import joinedload 7 | from model.search_params.comment_params import CommentSearchParams 8 | from . import BaseService 9 | 10 | logger = logging.getLogger(__name__) 11 | 12 | 13 | class CommentService(object): 14 | @staticmethod 15 | def get_comment(db_session, comment_id): 16 | return db_session.query(Comment).get(comment_id) 17 | 18 | @staticmethod 19 | def get_max_floor(db_session, article_id): 20 | max_floor = db_session.query(func.max(Comment.floor)).filter(Comment.article_id == article_id).scalar() 21 | return max_floor if max_floor else 0; 22 | 23 | @staticmethod 24 | def add_comment(db_session, article_id, comment): 25 | max_floor = CommentService.get_max_floor(db_session, article_id) 26 | floor = max_floor + 1 27 | comment_to_add = Comment(content=comment['content'], author_name=comment['author_name'], 28 | author_email=comment['author_email'], article_id=article_id, 29 | comment_type=comment['comment_type'], rank=comment['rank'], floor=floor, 30 | reply_to_id=comment['reply_to_id'], reply_to_floor=comment['reply_to_floor']) 31 | db_session.add(comment_to_add) 32 | db_session.commit() 33 | return comment_to_add 34 | 35 | @staticmethod 36 | def update_comment_disabled(db_session, article_id, comment_id, disabled): 37 | updated = db_session.query(Comment).filter(Comment.article_id == article_id, Comment.id == comment_id).\ 38 | update({Comment.disabled: disabled}) 39 | db_session.commit() 40 | return updated 41 | 42 | @staticmethod 43 | def delete_comment(db_session, article_id, comment_id): 44 | comment = CommentService.get_comment(db_session, comment_id); 45 | if comment and comment.article_id == int(article_id): 46 | db_session.delete(comment) 47 | db_session.commit() 48 | return comment 49 | return None 50 | 51 | @staticmethod 52 | def page_comments(db_session, pager, params): 53 | query = db_session.query(Comment) 54 | if params: 55 | if params.article_id: 56 | query = query.filter(Comment.article_id == params.article_id) 57 | if params.show_article_id_title: 58 | query = query.options(joinedload(Comment.article).load_only("id", "title")) 59 | if params.order_mode == CommentSearchParams.ORDER_MODE_CREATE_TIME_ASC: 60 | query = query.order_by(Comment.create_time.asc()) 61 | elif params.order_mode == CommentSearchParams.ORDER_MODE_CREATE_TIME_DESC: 62 | query = query.order_by(Comment.create_time.desc()) 63 | pager = BaseService.query_pager(query, pager) 64 | return pager 65 | 66 | @staticmethod 67 | def remove_by_article_id(db_session, article_id, commit=True): 68 | try: 69 | comments = db_session.query(Comment).filter(Comment.article_id == article_id).all() 70 | db_session.query(Comment).filter(Comment.article_id == article_id).delete() 71 | if commit: 72 | db_session.commit() 73 | return comments 74 | except Exception, e: 75 | logger.exception(e) 76 | return None 77 | 78 | @staticmethod 79 | def get_comment_count(db_session): 80 | comment_count = db_session.query(Comment).count() 81 | return comment_count 82 | 83 | @staticmethod 84 | def get_comments_count_subquery(db_session): 85 | stmt = db_session.query(Comment.article_id, func.count('*').label('comments_count')). \ 86 | group_by(Comment.article_id).subquery() 87 | return stmt -------------------------------------------------------------------------------- /template/article_detials.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %} 4 | {{ article.title }} 5 | {% end %} 6 | {% block private_stylesheet %} 7 | 8 | {% end %} 9 | {% block content %} 10 | 11 |89 | {% end %} 90 | 91 | {% block script %} 92 | 93 | 94 | 95 | {% end %} 96 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [blog_xtg](https://github.com/xtg20121013/blog_xtg)是我个人写的一个开源分布式博客,其web框架使用的是tornado(一个基于异步IO的python web框架)。同时我把它设计成一个可以多进程多主机部署的分布式架构,如果你对异步IO的web框架感兴趣,或者对高并发分布式的架构感兴趣并处于入门阶段,那么很希望你来尝试blog_xtg,一定会有所收获。 2 | 3 | ### 一、为什么写blog_xtg 4 | 作为一个码农怎么能没有一个属于自己的个人博客呢?即便没人看,作为日记来记录编码生涯也是很有必要。其实开源的blog有很多,比如WordPress、LifeType等等,但是There are a thousand Hamlets in a thousand people's eyes(一千个读者眼里有一千个哈姆雷特),所以我还是喜欢自己写属于自己的"哈姆雷特"。既然要做新项目,那不用点新东西就会觉得没有意义。恰逢当时淘宝双11,双11会场的页面都是由node.js支撑,node.js做web项目最大的特点就是异步IO,我js不怎么熟,我就选择了python的异步IO框架tornado。但是单个tornado实例无法充分利用多核CPU的资源,所以就实现了blog_xtg这样一个简单的基于tornado的分布式架构博客。 5 | 6 | ### 二、blog_xtg简介 7 | 首先非常感谢开源博客[Blog_mini](https://github.com/xpleaf/Blog_mini),因为整个blog_xtg是基于[Blog_mini](https://github.com/xpleaf/Blog_mini)重构的。 8 | 9 | 我不太擅长前端,所以基本照搬[Blog_mini](https://github.com/xpleaf/Blog_mini)的页面,但是整个后端逻辑都是重写的,以下是与[Blog_mini](https://github.com/xpleaf/Blog_mini)的主要区别: 10 | 11 | 1. 改用tornado框架,是个基于异步IO的web server。 12 | 2. 分布式架构,可以多进程多主机启动server实例,再通过nginx等代理服务器做负载均衡,实现横向扩展提高并发性能。 13 | 3. 提高多数主要页面访问性能。对频繁查询的组件(例如博客标题、菜单、公告、访问统计)进行缓存,优化sql查询(多条sql语句合并一次执行、仅查需要的字段,例如搜索博文列表不查博文的具体内容)以提高首页博文等主要页面访问性能。 14 | 4. 访问统计改为日pv和日uv。 15 | 5. 博文编辑器改为markdown编辑器。 16 | 6. 引入alembic管理数据库版本。 17 | 7. 可使用docker快速部署。 18 | 19 | 但是,作为一个个人blog,其实并不需要分布式的架构,即便引入了这样的架构,我依然希望其他开发者能够快捷的搭建环境并上手使用,因此blog_xtg只是简单的实现了分布式,并不能保证绝对的高可用,主从需要启动实例时手动指定,存在单点故障的可能,如果有开发者希望以此架构扩展到大型生产环境请自行配合zookeeper等实现动态选主+完整的日志分析、性能监控以及完善报警机制来保证高可用。 20 | 21 | **注:** blog_xtg目前架构并不需要考虑线程安全问题,因为tornado是单线程的,仅用到多线程的地方只有通过线程池访问数据库,数据库连接session是线程局部变量,其他并无线程间共享的变量,不会带来线程安全问题。 22 | 23 | ### 三、blog_xtg部署与开发环境搭建 24 | #### 1. 如果你熟悉docker,那么可以用docker来快速部署。 25 | 26 | #新建数据库(理论上支持sqlalchemy支持的所有数据库,表会自动创建更新) 27 | #搭建redis 28 | #下载config.py并编辑相关配置(修改数据库、redis、日志等) 29 | curl -o xxx/config.py https://raw.githubusercontent.com/xtg20121013/blog_xtg/master/config.py 30 | #通过docker启动后即可访问 31 | docker run -d -p 80:80 --restart=always --name blog_xtg -v xxx/config.py:/home/xtg/blog-xtg/config.py daocloud.io/xtg20121013/blog_xtg:latest 32 | 这个镜像启动时包含两个server实例(一主一从)+nginx(动静分离、负载均衡)+supervisor(进程管理),当然你也可以根据自己的需求构建镜像,Dockerfile在项目/docker目录下。 33 | #### 2. 构建运行环境 34 | ###### 需要安装以下组件: 35 | 36 | 1. python2.7(python3 没试过,不知道行不行) 37 | 2. mysql(或者其他sqlalchemy支持的数据库) 38 | 3. redis 39 | 40 | ###### clone项目,安装依赖: 41 | 42 | git clone https://github.com/xtg20121013/blog_xtg.git 43 | #项目依赖(如果用的不是mysql可以将MySQL-python替换使用的数据库成所对应的依赖包) 44 | pip install -r requirements.txt 45 | ###### 创建数据库(注意使用utf-8编码) 46 | ###### 启动redis 47 | ###### 修改config.py,配置数据库、redis、日志等 48 | ###### 创建数据库或更新表 49 | python main.py upgradedb 50 | ###### 启动server 51 | python main.py --master=true --port=8888 52 | 53 | ###### 初始化管理员账户 54 | 访问http://[host]:[port]/super/init注册管理员账号。 55 | 56 | 注:仅没有任何管理员时才可以访问到该页面。 57 | 58 | ### 四、开发注意事项 59 | #### 1.blog_xtg是个异步IO的架构,相对于常见的同步IO框架,需要注意以下几点: 60 | 61 | - IO密集型的操作请务必使用异步的client,否则无法利用到异步的优势 62 | - 由于多数异步IO的框架都是单线程的,所以对于CPU密集型的操作最好交由外部系统处理,防止阻塞,大型项目可以配合消息队列使用更佳 63 | - 如果必须用同步的IO组件,可以配合线程池使用(blog_xtg中使用了sqlalchemy就是配合线程池使用的) 64 | - 如果你是ORM+线程池使用(blog_xtg中就是sqlalchemy+线程池),一般的ORM都有lazy load的机制,在异步框架中请勿使用,因为lazy load的执行在主线程中,很可能会阻塞主线程,影响别的请求。 65 | 66 | #### 2.blog_xtg是分布式的架构,相对于单进程的项目一般需要注意以下几点: 67 | 68 | - 多实例间的日志冲突。 69 | - 多实例间的缓存同步。 70 | - 多实例间的session同步。 71 | - 多实例间主从关系,例如一些定时任务可能主需要集群中一个节点处理。 72 | 73 | 当然以上几点都可以从blog_xtg的源代码中找到至少一种解决方案。 74 | 75 | 如果你对异步IO的web框架、分布式的架构感兴趣,或者想对blog_xtg做二次开发,那么你可以阅读以下blog_xtg的其他相关博文,并配合源代码学习,一定会很快掌握。 76 | 77 | 1. [开源博客blog_xtg技术架构-非阻塞IO web框架tornado](http://blog.52xtg.com/article/10) 78 | 79 | 80 | #### 3.对于博文编辑的markdown的问题: 81 | 82 | 我用的是[Bootstrap Markdown](http://www.codingdrama.com/bootstrap-markdown),好像只支持标准的markdown语法,可能大家对代码段的标注语法只知道```的形式,而真正的标准语法是代码段的每一行开头添加4个空格,如果大家不喜欢的话可以尝试更换为[marked](https://github.com/chjj/marked),参见:[修复markdown编辑器无法编写多行code的问题 #2](https://github.com/xtg20121013/blog_xtg/pull/2) 83 | 84 | ### 五、技术支持 85 | 如果你有任何疑问,可以给我留言: 86 | 87 | 附: 88 | 89 | - 个人博客:[http://blog.52xtg.com](http://blog.52xtg.com) 90 | 91 | - 简书博客:[http://www.jianshu.com/u/dfb6bf87c35e](http://www.jianshu.com/u/dfb6bf87c35e) 92 | 93 | - 试用博客:[http://blogdemo.52xtg.com](http://blogdemo.52xtg.com) 94 | 95 | - blog_xtg的github地址:[https://github.com/xtg20121013/blog_xtg](https://github.com/xtg20121013/blog_xtg) 96 | -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/template/plugin.min.js: -------------------------------------------------------------------------------- 1 | tinymce.PluginManager.add("template",function(a){function b(b){return function(){var c=a.settings.templates;return"function"==typeof c?void c(b):void("string"==typeof c?tinymce.util.XHR.send({url:c,success:function(a){b(tinymce.util.JSON.parse(a))}}):b(c))}}function c(b){function c(b){function c(b){if(-1==b.indexOf("")){var c="";tinymce.each(a.contentCSS,function(b){c+=''}),b=""+c+""+b+""}b=f(b,"template_preview_replace_values");var e=d.find("iframe")[0].getEl().contentWindow.document;e.open(),e.write(b),e.close()}var g=b.control.value();g.url?tinymce.util.XHR.send({url:g.url,success:function(a){e=a,c(e)}}):(e=g.content,c(e)),d.find("#description")[0].text(b.control.value().description)}var d,e,h=[];if(!b||0===b.length){var i=a.translate("No templates defined.");return void a.notificationManager.open({text:i,type:"info"})}tinymce.each(b,function(a){h.push({selected:!h.length,text:a.title,value:{url:a.url,content:a.content,description:a.description}})}),d=a.windowManager.open({title:"Insert template",layout:"flex",direction:"column",align:"stretch",padding:15,spacing:10,items:[{type:"form",flex:0,padding:0,items:[{type:"container",label:"Templates",items:{type:"listbox",label:"Templates",name:"template",values:h,onselect:c}}]},{type:"label",name:"description",label:"Description",text:"\xa0"},{type:"iframe",flex:1,border:1}],onsubmit:function(){g(!1,e)},width:a.getParam("template_popup_width",600),height:a.getParam("template_popup_height",500)}),d.find("listbox")[0].fire("select")}function d(b,c){function d(a,b){if(a=""+a,a.length0&&(i=k.create("div",null),i.appendChild(j[0].cloneNode(!0))),h(k.select("*",i),function(b){g(b,a.getParam("template_cdate_classes","cdate").replace(/\s+/g,"|"))&&(b.innerHTML=d(a.getParam("template_cdate_format",a.getLang("template.cdate_format")))),g(b,a.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(b.innerHTML=d(a.getParam("template_mdate_format",a.getLang("template.mdate_format")))),g(b,a.getParam("template_selected_content_classes","selcontent").replace(/\s+/g,"|"))&&(b.innerHTML=l)}),e(i),a.execCommand("mceInsertContent",!1,i.innerHTML),a.addVisual()}var h=tinymce.each;a.addCommand("mceInsertTemplate",g),a.addButton("template",{title:"Insert template",onclick:b(c)}),a.addMenuItem("template",{text:"Insert template",onclick:b(c),context:"insert"}),a.on("PreProcess",function(b){var c=a.dom;h(c.select("div",b.node),function(b){c.hasClass(b,"mceTmpl")&&(h(c.select("*",b),function(b){c.hasClass(b,a.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(b.innerHTML=d(a.getParam("template_mdate_format",a.getLang("template.mdate_format"))))}),e(b))})})}); -------------------------------------------------------------------------------- /service/plugin_service.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import logging 3 | from sqlalchemy import func 4 | from model.models import Plugin 5 | from model.search_params.plugin_params import PluginSearchParams 6 | from . import BaseService 7 | 8 | logger = logging.getLogger(__name__) 9 | 10 | 11 | class PluginService(object): 12 | 13 | @staticmethod 14 | def get(db_session, plugin_id): 15 | plugin = db_session.query(Plugin).get(plugin_id) 16 | return plugin 17 | 18 | @staticmethod 19 | def get_editable(db_session, plugin_id): 20 | plugin = db_session.query(Plugin).get(plugin_id) 21 | if plugin: 22 | plugin = plugin if plugin.content != 'system_plugin' else None 23 | return plugin 24 | 25 | @staticmethod 26 | def list_plugins(db_session): 27 | plugins = db_session.query(Plugin).order_by(Plugin.order.asc()).all() 28 | return plugins 29 | 30 | @staticmethod 31 | def page_plugins(db_session, pager, search_params): 32 | query = db_session.query(Plugin) 33 | if search_params: 34 | if search_params.order_mode == PluginSearchParams.ORDER_MODE_ORDER_ASC: 35 | query = query.order_by(Plugin.order.asc()) 36 | pager = BaseService.query_pager(query, pager) 37 | return pager 38 | 39 | @staticmethod 40 | def save(db_session, plugin): 41 | try: 42 | plugin_to_save = Plugin(**plugin) 43 | plugin_to_save.order = PluginService.get_max_order(db_session) + 1 44 | db_session.add(plugin_to_save) 45 | db_session.commit() 46 | return plugin_to_save 47 | except Exception, e: 48 | logger.exception(e) 49 | return None 50 | 51 | @staticmethod 52 | def get_max_order(db_session): 53 | max_order = db_session.query(func.max(Plugin.order)).scalar() 54 | if max_order is None: 55 | max_order = 0 56 | return max_order 57 | 58 | @staticmethod 59 | def sort_up(db_session, plugin_id): 60 | plugin = db_session.query(Plugin).get(plugin_id) 61 | if plugin: 62 | plugin_up = db_session.query(Plugin).\ 63 | filter(Plugin.order < plugin.order).order_by(Plugin.order.desc()).first() 64 | if plugin_up: 65 | order_tmp = plugin.order 66 | plugin.order = plugin_up.order 67 | plugin_up.order = order_tmp 68 | db_session.commit() 69 | return True 70 | return False 71 | 72 | @staticmethod 73 | def sort_down(db_session, plugin_id): 74 | plugin = db_session.query(Plugin).get(plugin_id) 75 | if plugin: 76 | plugin_up = db_session.query(Plugin).\ 77 | filter(Plugin.order > plugin.order).order_by(Plugin.order.asc()).first() 78 | if plugin_up: 79 | order_tmp = plugin.order 80 | plugin.order = plugin_up.order 81 | plugin_up.order = order_tmp 82 | db_session.commit() 83 | return True 84 | return False 85 | 86 | @staticmethod 87 | def update_disabled(db_session, plugin_id, disabled): 88 | update_count = db_session.query(Plugin).filter(Plugin.id == plugin_id).update({Plugin.disabled:disabled}) 89 | if update_count: 90 | db_session.commit() 91 | return update_count 92 | 93 | @staticmethod 94 | def delete(db_session, plugin_id): 95 | plugin = PluginService.get_editable(db_session, plugin_id) 96 | if plugin: 97 | db_session.delete(plugin) 98 | db_session.commit() 99 | return True 100 | return False 101 | 102 | @staticmethod 103 | def update(db_session, plugin_id, plugin_to_update): 104 | plugin = PluginService.get_editable(db_session, plugin_id) 105 | if plugin: 106 | plugin.title = plugin_to_update['title'] 107 | plugin.note = plugin_to_update['note'] 108 | plugin.content = plugin_to_update['content'] 109 | db_session.commit() 110 | return True 111 | return False 112 | 113 | -------------------------------------------------------------------------------- /service/article_type_service.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import logging 3 | from sqlalchemy.orm import contains_eager, joinedload 4 | from model.models import ArticleType, ArticleTypeSetting 5 | from model.search_params.article_type_params import ArticleTypeSearchParams 6 | from . import BaseService 7 | from article_service import ArticleService 8 | 9 | logger = logging.getLogger(__name__) 10 | 11 | 12 | class ArticleTypeService(object): 13 | @staticmethod 14 | def page_article_types(db_session, pager, search_params): 15 | query = db_session.query(ArticleType) 16 | if search_params: 17 | if search_params.order_mode == ArticleTypeSearchParams.ORDER_MODE_ID_DESC: 18 | query = query.order_by(ArticleType.id.desc()) 19 | if search_params.show_setting: 20 | query = query.options(joinedload(ArticleType.setting)) 21 | pager = BaseService.query_pager(query, pager) 22 | if pager.result: 23 | if search_params.show_articles_count: 24 | for article_type in pager.result: 25 | article_type.fetch_articles_count() 26 | return pager 27 | 28 | @staticmethod 29 | def list_article_types_not_under_menu(db_session): 30 | article_types_not_under_menu = db_session.query(ArticleType).join(ArticleType.setting).\ 31 | filter(ArticleType.menu_id.is_(None), ArticleTypeSetting.hide.isnot(True)).\ 32 | options(contains_eager(ArticleType.setting)).all() 33 | return article_types_not_under_menu 34 | 35 | @staticmethod 36 | def add_article_type(db_session, article_type): 37 | try: 38 | article_type_to_add = ArticleType(name=article_type["name"], introduction=article_type["introduction"], 39 | menu_id=article_type["menu_id"], 40 | setting=ArticleTypeSetting(name=article_type["name"], 41 | hide=article_type["setting_hide"],),) 42 | db_session.add(article_type_to_add) 43 | db_session.commit() 44 | return article_type_to_add 45 | except Exception, e: 46 | logger.exception(e) 47 | return None 48 | 49 | @staticmethod 50 | def update_article_type(db_session, article_type_id, article_type): 51 | try: 52 | article_type_to_update=db_session.query(ArticleType).get(article_type_id) 53 | if article_type_to_update and not article_type_to_update.is_protected: 54 | article_type_to_update.name=article_type['name'] 55 | article_type_to_update.introduction = article_type['introduction'] 56 | article_type_to_update.menu_id = article_type['menu_id'] 57 | if not article_type_to_update.setting: 58 | article_type_to_update.setting = ArticleTypeSetting(name=article_type["name"], 59 | hide=article_type["setting_hide"],) 60 | else: 61 | article_type_to_update.setting.hide = article_type['setting_hide'] 62 | db_session.commit() 63 | return True 64 | except Exception, e: 65 | logger.exception(e) 66 | return False 67 | 68 | @staticmethod 69 | def delete(db_session, article_type_id): 70 | article_type_to_delete = db_session.query(ArticleType).get(article_type_id) 71 | if article_type_to_delete and not article_type_to_delete.is_protected: 72 | # 未将文章分类移除到未分类 73 | ArticleService.set_article_type_default_by_article_type_id(db_session, article_type_id, False) 74 | db_session.delete(article_type_to_delete.setting) 75 | db_session.delete(article_type_to_delete) 76 | db_session.commit() 77 | return 1 78 | return 0 79 | 80 | @staticmethod 81 | def set_article_type_menu_id_none(db_session, menu_id, auto_commit=True): 82 | db_session.query(ArticleType).filter(ArticleType.menu_id == menu_id).update({"menu_id": None}) 83 | if auto_commit: 84 | db_session.commit() 85 | 86 | @staticmethod 87 | def list_simple(db_session): 88 | article_types = db_session.query(ArticleType.id, ArticleType.name).all() 89 | return article_types 90 | -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/link/plugin.min.js: -------------------------------------------------------------------------------- 1 | tinymce.PluginManager.add("link",function(a){function b(b){return function(){var c=a.settings.link_list;"string"==typeof c?tinymce.util.XHR.send({url:c,success:function(a){b(tinymce.util.JSON.parse(a))}}):"function"==typeof c?c(b):b(c)}}function c(a,b,c){function d(a,c){return c=c||[],tinymce.each(a,function(a){var e={text:a.text||a.title};a.menu?e.menu=d(a.menu):(e.value=a.value,b&&b(e)),c.push(e)}),c}return d(a,c||[])}function d(b){function d(a){var b=l.find("#text");(!b.value()||a.lastControl&&b.value()==a.lastControl.text())&&b.value(a.control.text()),l.find("#href").value(a.control.value())}function e(b){var c=[];return tinymce.each(a.dom.select("a:not([href])"),function(a){var d=a.name||a.id;d&&c.push({text:d,value:"#"+d,selected:-1!=b.indexOf("#"+d)})}),c.length?(c.unshift({text:"None",value:""}),{name:"anchor",type:"listbox",label:"Anchors",values:c,onselect:d}):void 0}function f(){!k&&0===u.text.length&&m&&this.parent().parent().find("#text")[0].value(this.value())}function g(b){var c=b.meta||{};o&&o.value(a.convertURL(this.value(),"href")),tinymce.each(b.meta,function(a,b){l.find("#"+b).value(a)}),c.text||f.call(this)}function h(a){var b=v.getContent();if(/]+>[^<]+<\/a>$/.test(b)||-1==b.indexOf("href=")))return!1;if(a){var c,d=a.childNodes;if(0===d.length)return!1;for(c=d.length-1;c>=0;c--)if(3!=d[c].nodeType)return!1}return!0}var i,j,k,l,m,n,o,p,q,r,s,t,u={},v=a.selection,w=a.dom;i=v.getNode(),j=w.getParent(i,"a[href]"),m=h(),u.text=k=j?j.innerText||j.textContent:v.getContent({format:"text"}),u.href=j?w.getAttrib(j,"href"):"",j?u.target=w.getAttrib(j,"target"):a.settings.default_link_target&&(u.target=a.settings.default_link_target),(t=w.getAttrib(j,"rel"))&&(u.rel=t),(t=w.getAttrib(j,"class"))&&(u["class"]=t),(t=w.getAttrib(j,"title"))&&(u.title=t),m&&(n={name:"text",type:"textbox",size:40,label:"Text to display",onchange:function(){u.text=this.value()}}),b&&(o={type:"listbox",label:"Link list",values:c(b,function(b){b.value=a.convertURL(b.value||b.url,"href")},[{text:"None",value:""}]),onselect:d,value:a.convertURL(u.href,"href"),onPostRender:function(){o=this}}),a.settings.target_list!==!1&&(a.settings.target_list||(a.settings.target_list=[{text:"None",value:""},{text:"New window",value:"_blank"}]),q={name:"target",type:"listbox",label:"Target",values:c(a.settings.target_list)}),a.settings.rel_list&&(p={name:"rel",type:"listbox",label:"Rel",values:c(a.settings.rel_list)}),a.settings.link_class_list&&(r={name:"class",type:"listbox",label:"Class",values:c(a.settings.link_class_list,function(b){b.value&&(b.textStyle=function(){return a.formatter.getCssText({inline:"a",classes:[b.value]})})})}),a.settings.link_title!==!1&&(s={name:"title",type:"textbox",label:"Title",value:u.title}),l=a.windowManager.open({title:"Insert link",data:u,body:[{name:"href",type:"filepicker",filetype:"file",size:40,autofocus:!0,label:"Url",onchange:g,onkeyup:f},n,s,e(u.href),o,p,q,r],onSubmit:function(b){function c(b,c){var d=a.selection.getRng();tinymce.util.Delay.setEditorTimeout(a,function(){a.windowManager.confirm(b,function(b){a.selection.setRng(d),c(b)})})}function d(){var b={href:e,target:u.target?u.target:null,rel:u.rel?u.rel:null,"class":u["class"]?u["class"]:null,title:u.title?u.title:null};j?(a.focus(),m&&u.text!=k&&("innerText"in j?j.innerText=u.text:j.textContent=u.text),w.setAttribs(j,b),v.select(j),a.undoManager.add()):m?a.insertContent(w.createHTML("a",b,w.encode(u.text))):a.execCommand("mceInsertLink",!1,b)}var e;return u=tinymce.extend(u,b.data),(e=u.href)?e.indexOf("@")>0&&-1==e.indexOf("//")&&-1==e.indexOf("mailto:")?void c("The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",function(a){a&&(e="mailto:"+e),d()}):a.settings.link_assume_external_targets&&!/^\w+:/i.test(e)||!a.settings.link_assume_external_targets&&/^\s*www[\.|\d\.]/i.test(e)?void c("The URL you entered seems to be an external link. Do you want to add the required http:// prefix?",function(a){a&&(e="http://"+e),d()}):void d():void a.execCommand("unlink")}})}a.addButton("link",{icon:"link",tooltip:"Insert/edit link",shortcut:"Meta+K",onclick:b(d),stateSelector:"a[href]"}),a.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink",stateSelector:"a[href]"}),a.addShortcut("Meta+K","",b(d)),a.addCommand("mceLink",b(d)),this.showDialog=d,a.addMenuItem("link",{icon:"link",text:"Insert/edit link",shortcut:"Meta+K",onclick:b(d),stateSelector:"a[href]",context:"insert",prependToContext:!0})}); -------------------------------------------------------------------------------- /template/admin/admin_account.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin_base.html' %} 2 | 3 | {% block admin_content %} 4 |12 |16 |13 | {{ article.title }} 14 |
15 |17 |35 | 36 |18 | {{ article.create_time.strftime("%Y年%m月%d日") }} 19 | 20 | 21 | {{ article.source.name }} 22 | 23 | 24 | 25 | 26 | {{ article.articleType.name }} 27 | 28 | 29 |30 |31 | 浏览 {{ article.num_of_view }} 32 | 评论 {{ comments_pager.totalCount }} 33 |34 |
37 |38 |43 |39 | 42 |
44 |45 |52 | {% if current_user %} 53 |46 | 47 | 博文最后更新时间: 48 | 49 | {{ article.create_time.strftime("%Y年%m月%d日 %H:%M:%S") }} 50 |
51 |54 | 55 | 59 | 60 |61 | {% end %} 62 |
63 | 64 |评论
65 | {% include "_article_comments.html" %} 66 | {% module Template("_macros.html", pager=comments_pager, url=reverse_url('article', article.id), params="#comments") %} 67 | 68 |发表评论
69 |70 |87 | 88 |71 | 85 |86 |5 |23 | 24 | 25 |{{ current_user.name }},欢迎来到blog_xtg管理平台!
6 |
7 | 22 |26 |57 | 58 | 59 |27 | 55 |56 |60 |88 | {% end %} 89 | -------------------------------------------------------------------------------- /template/_article_comments.html: -------------------------------------------------------------------------------- 1 |61 | 86 |87 |78 |-------------------------------------------------------------------------------- /template/admin/custom_blog_plugin.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin_base.html' %} 2 | 3 | {% block title2 %} 4 | 插件管理 5 | {% end %} 6 | 7 | {% block admin_content %} 8 |79 | 98 |99 |9 |82 | 83 | 84 |插件管理
10 |
11 |插件总数:{{ pager.totalCount }}
12 |13 |80 | {% module Template("_macros.html", pager=pager, url=reverse_url('admin.custom.blog_plugin'), params=None) %} 81 |14 |79 |15 | 16 |
78 |17 | 25 | 26 | 27 | {% for plugin in pager.result %} 28 |序号 18 |插件名称 19 |备注 20 |排序 21 |启用 22 |修改 23 |删除 24 |29 | 75 | {% end %} 76 | 77 |{{ plugin.order }} 30 |{{ plugin.title }} 31 |{{ plugin.note }} 32 |33 | 35 | 36 | 37 | 39 | 40 | 41 | 42 |43 | {% if plugin.disabled %} 44 | 47 | 48 | 49 | {% else %} 50 | 53 | 54 | 55 | {% end %} 56 | 57 | {% if plugin.content != 'system_plugin' %} 58 |59 | 61 | 62 | 63 | 64 |65 | 67 | 68 | 69 | 70 | {% else %} 71 |72 | 73 | {% end %} 74 | 85 |107 | {% end %} 108 | -------------------------------------------------------------------------------- /static/tinymce/js/tinymce/plugins/visualblocks/css/visualblocks.css: -------------------------------------------------------------------------------- 1 | .mce-visualblocks p { 2 | padding-top: 10px; 3 | border: 1px dashed #BBB; 4 | margin-left: 3px; 5 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhCQAJAJEAAAAAAP///7u7u////yH5BAEAAAMALAAAAAAJAAkAAAIQnG+CqCN/mlyvsRUpThG6AgA7); 6 | } 7 | 8 | .mce-visualblocks h1 { 9 | padding-top: 10px; 10 | border: 1px dashed #BBB; 11 | margin-left: 3px; 12 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDQAKAIABALu7u////yH5BAEAAAEALAAAAAANAAoAAAIXjI8GybGu1JuxHoAfRNRW3TWXyF2YiRUAOw==); 13 | } 14 | 15 | .mce-visualblocks h2 { 16 | padding-top: 10px; 17 | border: 1px dashed #BBB; 18 | margin-left: 3px; 19 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDgAKAIABALu7u////yH5BAEAAAEALAAAAAAOAAoAAAIajI8Hybbx4oOuqgTynJd6bGlWg3DkJzoaUAAAOw==); 20 | } 21 | 22 | .mce-visualblocks h3 { 23 | padding-top: 10px; 24 | border: 1px dashed #BBB; 25 | margin-left: 3px; 26 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDgAKAIABALu7u////yH5BAEAAAEALAAAAAAOAAoAAAIZjI8Hybbx4oOuqgTynJf2Ln2NOHpQpmhAAQA7); 27 | } 28 | 29 | .mce-visualblocks h4 { 30 | padding-top: 10px; 31 | border: 1px dashed #BBB; 32 | margin-left: 3px; 33 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDgAKAIABALu7u////yH5BAEAAAEALAAAAAAOAAoAAAIajI8HybbxInR0zqeAdhtJlXwV1oCll2HaWgAAOw==); 34 | } 35 | 36 | .mce-visualblocks h5 { 37 | padding-top: 10px; 38 | border: 1px dashed #BBB; 39 | margin-left: 3px; 40 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDgAKAIABALu7u////yH5BAEAAAEALAAAAAAOAAoAAAIajI8HybbxIoiuwjane4iq5GlW05GgIkIZUAAAOw==); 41 | } 42 | 43 | .mce-visualblocks h6 { 44 | padding-top: 10px; 45 | border: 1px dashed #BBB; 46 | margin-left: 3px; 47 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDgAKAIABALu7u////yH5BAEAAAEALAAAAAAOAAoAAAIajI8HybbxIoiuwjan04jep1iZ1XRlAo5bVgAAOw==); 48 | } 49 | 50 | .mce-visualblocks div { 51 | padding-top: 10px; 52 | border: 1px dashed #BBB; 53 | margin-left: 3px; 54 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhEgAKAIABALu7u////yH5BAEAAAEALAAAAAASAAoAAAIfjI9poI0cgDywrhuxfbrzDEbQM2Ei5aRjmoySW4pAAQA7); 55 | } 56 | 57 | .mce-visualblocks section { 58 | padding-top: 10px; 59 | border: 1px dashed #BBB; 60 | margin: 0 0 1em 3px; 61 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhKAAKAIABALu7u////yH5BAEAAAEALAAAAAAoAAoAAAI5jI+pywcNY3sBWHdNrplytD2ellDeSVbp+GmWqaDqDMepc8t17Y4vBsK5hDyJMcI6KkuYU+jpjLoKADs=); 62 | } 63 | 64 | .mce-visualblocks article { 65 | padding-top: 10px; 66 | border: 1px dashed #BBB; 67 | margin: 0 0 1em 3px; 68 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhKgAKAIABALu7u////yH5BAEAAAEALAAAAAAqAAoAAAI6jI+pywkNY3wG0GBvrsd2tXGYSGnfiF7ikpXemTpOiJScasYoDJJrjsG9gkCJ0ag6KhmaIe3pjDYBBQA7); 69 | } 70 | 71 | .mce-visualblocks blockquote { 72 | padding-top: 10px; 73 | border: 1px dashed #BBB; 74 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhPgAKAIABALu7u////yH5BAEAAAEALAAAAAA+AAoAAAJPjI+py+0Knpz0xQDyuUhvfoGgIX5iSKZYgq5uNL5q69asZ8s5rrf0yZmpNkJZzFesBTu8TOlDVAabUyatguVhWduud3EyiUk45xhTTgMBBQA7); 75 | } 76 | 77 | .mce-visualblocks address { 78 | padding-top: 10px; 79 | border: 1px dashed #BBB; 80 | margin: 0 0 1em 3px; 81 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhLQAKAIABALu7u////yH5BAEAAAEALAAAAAAtAAoAAAI/jI+pywwNozSP1gDyyZcjb3UaRpXkWaXmZW4OqKLhBmLs+K263DkJK7OJeifh7FicKD9A1/IpGdKkyFpNmCkAADs=); 82 | } 83 | 84 | .mce-visualblocks pre { 85 | padding-top: 10px; 86 | border: 1px dashed #BBB; 87 | margin-left: 3px; 88 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhFQAKAIABALu7uwAAACH5BAEAAAEALAAAAAAVAAoAAAIjjI+ZoN0cgDwSmnpz1NCueYERhnibZVKLNnbOq8IvKpJtVQAAOw==); 89 | } 90 | 91 | .mce-visualblocks figure { 92 | padding-top: 10px; 93 | border: 1px dashed #BBB; 94 | margin: 0 0 1em 3px; 95 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhJAAKAIAAALu7u////yH5BAEAAAEALAAAAAAkAAoAAAI0jI+py+2fwAHUSFvD3RlvG4HIp4nX5JFSpnZUJ6LlrM52OE7uSWosBHScgkSZj7dDKnWAAgA7); 96 | } 97 | 98 | .mce-visualblocks hgroup { 99 | padding-top: 10px; 100 | border: 1px dashed #BBB; 101 | margin: 0 0 1em 3px; 102 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhJwAKAIABALu7uwAAACH5BAEAAAEALAAAAAAnAAoAAAI3jI+pywYNI3uB0gpsRtt5fFnfNZaVSYJil4Wo03Hv6Z62uOCgiXH1kZIIJ8NiIxRrAZNMZAtQAAA7); 103 | } 104 | 105 | .mce-visualblocks aside { 106 | padding-top: 10px; 107 | border: 1px dashed #BBB; 108 | margin: 0 0 1em 3px; 109 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhHgAKAIABAKqqqv///yH5BAEAAAEALAAAAAAeAAoAAAItjI+pG8APjZOTzgtqy7I3f1yehmQcFY4WKZbqByutmW4aHUd6vfcVbgudgpYCADs=); 110 | } 111 | 112 | .mce-visualblocks figcaption { 113 | border: 1px dashed #BBB; 114 | } 115 | 116 | .mce-visualblocks ul { 117 | padding-top: 10px; 118 | border: 1px dashed #BBB; 119 | margin: 0 0 1em 3px; 120 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDQAKAIAAALu7u////yH5BAEAAAEALAAAAAANAAoAAAIXjI8GybGuYnqUVSjvw26DzzXiqIDlVwAAOw==) 121 | } 122 | 123 | .mce-visualblocks ol { 124 | padding-top: 10px; 125 | border: 1px dashed #BBB; 126 | margin: 0 0 1em 3px; 127 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDQAKAIABALu7u////yH5BAEAAAEALAAAAAANAAoAAAIXjI8GybH6HHt0qourxC6CvzXieHyeWQAAOw==); 128 | } 129 | 130 | .mce-visualblocks dl { 131 | padding-top: 10px; 132 | border: 1px dashed #BBB; 133 | margin: 0 0 1em 3px; 134 | background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDQAKAIABALu7u////yH5BAEAAAEALAAAAAANAAoAAAIXjI8GybEOnmOvUoWznTqeuEjNSCqeGRUAOw==); 135 | } 136 | --------------------------------------------------------------------------------86 | 105 |106 |
{{ comment.content }}
26 | {% end %} 27 | {% if comment.disabled and current_user %} 28 |29 | 30 | 该评论已经被管理员屏蔽!访客无法查看和回复此评论内容。 31 |
32 | {% elif comment.disabled %} 33 |34 | 35 | 该评论已经被管理员屏蔽! 36 |
37 | {% end %} 38 |