settings.py 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #coding:utf-8
  2. from django.conf import settings as gSettings #全局设置
  3. #工具栏样式,可以添加任意多的模式
  4. TOOLBARS_SETTINGS={
  5. "besttome":[['source','undo', 'redo','bold', 'italic', 'underline','forecolor', 'backcolor','superscript','subscript',"justifyleft","justifycenter","justifyright","insertorderedlist","insertunorderedlist","blockquote",'formatmatch',"removeformat",'autotypeset','inserttable',"pasteplain","wordimage","searchreplace","map","preview","fullscreen"], ['insertcode','paragraph',"fontfamily","fontsize",'link', 'unlink','insertimage','insertvideo','attachment','emotion',"date","time"]],
  6. "mini":[['source','|','undo', 'redo', '|','bold', 'italic', 'underline','formatmatch','autotypeset', '|', 'forecolor', 'backcolor','|', 'link', 'unlink','|','simpleupload','attachment']],
  7. "normal":[['source','|','undo', 'redo', '|','bold', 'italic', 'underline','removeformat', 'formatmatch','autotypeset', '|', 'forecolor', 'backcolor','|', 'link', 'unlink','|','simpleupload', 'emotion','attachment', '|','inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols']]
  8. }
  9. #默认的Ueditor设置,请参见ueditor.config.js
  10. UEditorSettings={
  11. "toolbars":TOOLBARS_SETTINGS["normal"],
  12. "autoFloatEnabled":False,
  13. "defaultPathFormat":"%(basename)s_%(datetime)s_%(rnd)s.%(extname)s" #默认保存上传文件的命名方式
  14. }
  15. #请参阅php文件夹里面的config.json进行配置
  16. UEditorUploadSettings={
  17. #上传图片配置项
  18. "imageActionName": "uploadimage", #执行上传图片的action名称
  19. "imageMaxSize": 10485760, #上传大小限制,单位B,10M
  20. "imageFieldName": "upfile", #* 提交的图片表单名称 */
  21. "imageUrlPrefix":"",
  22. "imagePathFormat":"",
  23. "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], #上传图片格式显示
  24. #涂鸦图片上传配置项 */
  25. "scrawlActionName": "uploadscrawl", #执行上传涂鸦的action名称 */
  26. "scrawlFieldName": "upfile", #提交的图片表单名称 */
  27. "scrawlMaxSize": 10485760, #上传大小限制,单位B 10M
  28. "scrawlUrlPrefix":"",
  29. "scrawlPathFormat":"",
  30. #截图工具上传 */
  31. "snapscreenActionName": "uploadimage", #执行上传截图的action名称 */
  32. "snapscreenPathFormat":"",
  33. "snapscreenUrlPrefix":"",
  34. #抓取远程图片配置 */
  35. "catcherLocalDomain": ["127.0.0.1", "localhost", "img.baidu.com"],
  36. "catcherPathFormat":"",
  37. "catcherActionName": "catchimage", #执行抓取远程图片的action名称 */
  38. "catcherFieldName": "source", #提交的图片列表表单名称 */
  39. "catcherMaxSize": 10485760, #上传大小限制,单位B */
  40. "catcherAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], #抓取图片格式显示 */
  41. "catcherUrlPrefix":"",
  42. #上传视频配置 */
  43. "videoActionName": "uploadvideo", #执行上传视频的action名称 */
  44. "videoPathFormat":"",
  45. "videoFieldName": "upfile", # 提交的视频表单名称 */
  46. "videoMaxSize": 102400000, #上传大小限制,单位B,默认100MB */
  47. "videoUrlPrefix":"",
  48. "videoAllowFiles": [
  49. ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
  50. ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"], #上传视频格式显示 */
  51. #上传文件配置 */
  52. "fileActionName": "uploadfile", #controller里,执行上传视频的action名称 */
  53. "filePathFormat":"",
  54. "fileFieldName": "upfile",#提交的文件表单名称 */
  55. "fileMaxSize": 204800000, #上传大小限制,单位B,200MB */
  56. "fileUrlPrefix": "",#文件访问路径前缀 */
  57. "fileAllowFiles": [
  58. ".png", ".jpg", ".jpeg", ".gif", ".bmp",
  59. ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
  60. ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
  61. ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
  62. ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
  63. ], #上传文件格式显示 */
  64. #列出指定目录下的图片 */
  65. "imageManagerActionName": "listimage", #执行图片管理的action名称 */
  66. "imageManagerListPath":"",
  67. "imageManagerListSize": 30, #每次列出文件数量 */
  68. "imageManagerAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], #列出的文件类型 */
  69. "imageManagerUrlPrefix": "",#图片访问路径前缀 */
  70. #列出指定目录下的文件 */
  71. "fileManagerActionName": "listfile", #执行文件管理的action名称 */
  72. "fileManagerListPath":"",
  73. "fileManagerUrlPrefix": "",
  74. "fileManagerListSize": 30, #每次列出文件数量 */
  75. "fileManagerAllowFiles": [
  76. ".png", ".jpg", ".jpeg", ".gif", ".bmp",".tif",".psd"
  77. ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
  78. ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
  79. ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
  80. ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml",
  81. ".exe",".com",".dll",".msi"
  82. ] #列出的文件类型 */
  83. }
  84. #更新配置:从用户配置文件settings.py重新读入配置UEDITOR_SETTINGS,覆盖默认
  85. def UpdateUserSettings():
  86. UserSettings=getattr(gSettings,"UEDITOR_SETTINGS",{}).copy()
  87. if "config" in UserSettings: UEditorSettings.update(UserSettings["config"])
  88. if "upload" in UserSettings: UEditorUploadSettings.update(UserSettings["upload"])
  89. #读取用户Settings文件并覆盖默认配置
  90. UpdateUserSettings()
  91. #取得配置项参数
  92. def GetUeditorSettings(key,default=None):
  93. if UEditorSettings.has_key(key):
  94. return UEditorSettings[key]
  95. else:
  96. return default