Gitit Bigger 相关设置

Gitit Bigger 提供一定程度的配置,你可以通过在 templates/page_more_scripts.st 里定义 BIGGER_SETTINGS_APPEND 对象来覆盖默认配置。

默认配置:

配置方式:

  1. 创建 templates/page_more_scripts.st 文件(该文件没有被加入到 gitit-bigger 的仓库里);
  2. templates/page_more_scripts.st 里的 JavaScript 里,按规则定义 BIGGER_SETTINGS_APPEND 以覆盖默认配置
  3. 重启 Gitit。对所有静态文件的更新,都必须要重启 gitit 服务才能看到效果;可运行 ./run/run.sh restart 来重启;
  4. 此外:
  5. templates/page_more_scripts.st 是一个 HTML 文件,你可以做其他任何能做的事情;

默认配置说明

主要内容:

  • ace 编辑器相关
    • 默认启用;
    • markdown 相关
      • 默认启用;
      • 快捷键:默认启用;
      • 快捷键函数:默认为 Gitit Bigger 提供的;
    • styles: 一个对象,键名都必须是 DOM 方法;
  • MathJax 数学公式插件相关
    • 默认启用;
    • 在 mathjax.exclude 数据组的页面,MathJax 插件将不会被引入;
  • highlightjs 代码高亮插件相关
    • 默认启用—因我发现 Gitit 自己的高亮机制需要不少其他处理, highlightjs 比较省事;
    • theme: 即 /static/js/highlight/styles/ 目录下的某个文件名,不带扩展。比如: monokai_sublime
  • 其他细节
    • google_analytics_id: 如果值不为空,将会引入 Google Analytics;值举例:UA-19890535-1
    • 新窗口打开 http 链接:默认关闭;

示例

  1. <script type="text/javascript" src="/path/to/js/file.js"></script>
  2. <style type="text/css">
  3. color: red;
  4. </style>
  5. <script>
  6. // more js scripts here
  7. BIGGER_SETTINGS_APPEND = {
  8. "ace":{
  9. "styles":{
  10. "fontSize":"15px"
  11. }
  12. },
  13. "mathjax":{
  14. "enable":false,
  15. }
  16. }
  17. </script>

默认配置源码

  1. // Base settings.
  2. // You can override base config by using a BIGGER_SETTINGS_APPEND object.
  3. // Waring, override by "BIGGER_SETTINGS_APPEND" object.
  4. BIGGER_SETTINGS_BASE = {
  5. // ace editor settings
  6. // more about ace editor: https://ace.c9.io
  7. "ace": {
  8. // switch
  9. "enable": true,
  10. // ace editor, core settings.
  11. "setTheme": "ace/theme/github", // theme, and below are ace settings
  12. "setMode": "ace/mode/markdown", // editor mode, default ,will be override by markdowns.enable
  13. "setShowPrintMargin": false,
  14. "setShowGutter": false,
  15. "setUseWrapMode": true,
  16. "setUseSoftTabs": true, // instend tabs with spaces
  17. // markdown reloadted,
  18. "markdowns": {
  19. "enable": true, // enable markdown mode
  20. "shortcuts": true, // enable markdown shortcuts
  21. "shortcutsFunc": setShortcuts // custome shortcut function
  22. },
  23. // styles: document.style.ATTRS, case-sensitive.
  24. "styles": {
  25. "fontSize": "13px",
  26. "fontWight": "normal",
  27. "fontColor": "#333"
  28. }
  29. },
  30. "mathjax": {
  31. "enable": true,
  32. // "path": "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML",
  33. "path": "http://cdn.bootcss.com/mathjax/2.5.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML",
  34. "exclude": ["/_search", "/_index", "/_category", "/_upload", "/_activity", "/_register", "/_login",
  35. "/_delete", "/_diff"
  36. ]
  37. },
  38. // highlightjs
  39. // If your server can't highlightjs the syntax, you can use highlightjs
  40. // default: false
  41. // more about highlightjs: https://highlightjs.org/
  42. "highlightjs": {
  43. "enable": true,
  44. "theme": "monokai_sublime"
  45. },
  46. "google_analytics_id": "",
  47. "target_blank": false,
  48. }