super-pro-rb 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. checksums.yaml +7 -0
  2. data/gollum-6.1.0/CONTRIBUTING.md +221 -0
  3. data/gollum-6.1.0/Dockerfile +57 -0
  4. data/gollum-6.1.0/Gemfile +30 -0
  5. data/gollum-6.1.0/HISTORY.md +229 -0
  6. data/gollum-6.1.0/LATEST_CHANGES.md +6 -0
  7. data/gollum-6.1.0/LICENSE +21 -0
  8. data/gollum-6.1.0/README.md +177 -0
  9. data/gollum-6.1.0/Rakefile +297 -0
  10. data/gollum-6.1.0/bin/gollum +301 -0
  11. data/gollum-6.1.0/bin/gollum-migrate-tags +283 -0
  12. data/gollum-6.1.0/config.rb +12 -0
  13. data/gollum-6.1.0/config.ru +12 -0
  14. data/gollum-6.1.0/contrib/automation/gollum-post +66 -0
  15. data/gollum-6.1.0/contrib/openrc/conf.d/gollum +3 -0
  16. data/gollum-6.1.0/contrib/openrc/init.d/gollum +36 -0
  17. data/gollum-6.1.0/contrib/systemd/gollum@.service +12 -0
  18. data/gollum-6.1.0/contrib/sysv-debian/init.d/gollum +79 -0
  19. data/gollum-6.1.0/docker-run.sh +24 -0
  20. data/gollum-6.1.0/gollum.gemspec +305 -0
  21. data/gollum-6.1.0/lib/gollum/app.rb +747 -0
  22. data/gollum-6.1.0/lib/gollum/assets.rb +33 -0
  23. data/gollum-6.1.0/lib/gollum/helpers.rb +74 -0
  24. data/gollum-6.1.0/lib/gollum/locales/cn.yml +103 -0
  25. data/gollum-6.1.0/lib/gollum/locales/en.yml +103 -0
  26. data/gollum-6.1.0/lib/gollum/public/assets/app-05adca32f8f4f3effe10f8f4cf26dfd6a419ba986bce60d3f51a97e4055d4113.js +30 -0
  27. data/gollum-6.1.0/lib/gollum/public/assets/app-05adca32f8f4f3effe10f8f4cf26dfd6a419ba986bce60d3f51a97e4055d4113.js.gz +0 -0
  28. data/gollum-6.1.0/lib/gollum/public/assets/app-e224b375d824f0171fc926d624dc0887bf453db83f485b1992bc0859c4110e3e.css +11 -0
  29. data/gollum-6.1.0/lib/gollum/public/assets/app-e224b375d824f0171fc926d624dc0887bf453db83f485b1992bc0859c4110e3e.css.gz +0 -0
  30. data/gollum-6.1.0/lib/gollum/public/assets/criticmarkup-7b66f7a53b854bc9e4168be5b4725ca38e2bc6e9c41d5c050a9f60d9a94cb405.css +1 -0
  31. data/gollum-6.1.0/lib/gollum/public/assets/criticmarkup-7b66f7a53b854bc9e4168be5b4725ca38e2bc6e9c41d5c050a9f60d9a94cb405.css.gz +0 -0
  32. data/gollum-6.1.0/lib/gollum/public/assets/editor-9bef5462bb5dae2db84d6d8d534b55c5bb5a430e11344b3c23f9ea4410312f52.js +165 -0
  33. data/gollum-6.1.0/lib/gollum/public/assets/editor-9bef5462bb5dae2db84d6d8d534b55c5bb5a430e11344b3c23f9ea4410312f52.js.gz +0 -0
  34. data/gollum-6.1.0/lib/gollum/public/assets/gollum.katex-e70c1d51a08ebfe759eecbb33fbed54f300ccd7fb8d0e86e251caaf4e50f6b68.js +9 -0
  35. data/gollum-6.1.0/lib/gollum/public/assets/gollum.katex-e70c1d51a08ebfe759eecbb33fbed54f300ccd7fb8d0e86e251caaf4e50f6b68.js.gz +0 -0
  36. data/gollum-6.1.0/lib/gollum/public/assets/gollum.mermaid-06fd2f5494199db250618043312c27770720504b50c3f6ca99d2d2df529c7da3.js +118 -0
  37. data/gollum-6.1.0/lib/gollum/public/assets/gollum.mermaid-06fd2f5494199db250618043312c27770720504b50c3f6ca99d2d2df529c7da3.js.gz +0 -0
  38. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  39. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  40. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  41. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  42. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  43. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
  44. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  45. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
  46. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
  47. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  48. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
  49. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  50. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  51. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  52. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
  53. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  54. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  55. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  56. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  57. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  58. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/katex-709d4191c4f005516a709377f79e468d343f4e6c91a29a6ff188d13d124ba55f.css +1 -0
  59. data/gollum-6.1.0/lib/gollum/public/assets/katex/dist/katex-709d4191c4f005516a709377f79e468d343f4e6c91a29a6ff188d13d124ba55f.css.gz +0 -0
  60. data/gollum-6.1.0/lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css +1 -0
  61. data/gollum-6.1.0/lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css.gz +0 -0
  62. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/HOWTO_UPDATE_MATHJAX.md +21 -0
  63. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/a11y/assistive-mml.js +1 -0
  64. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/a11y/complexity.js +1 -0
  65. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/a11y/explorer.js +1 -0
  66. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/a11y/semantic-enrich.js +1 -0
  67. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/a11y/sre.js +1 -0
  68. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/adaptors/liteDOM.js +1 -0
  69. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/core.js +1 -0
  70. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/asciimath.js +1 -0
  71. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/mml/entities.js +1 -0
  72. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/mml/extensions/mml3.js +1 -0
  73. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/mml/extensions/mml3.sef.json +1 -0
  74. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/mml.js +1 -0
  75. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/action.js +1 -0
  76. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/all-packages.js +34 -0
  77. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/ams.js +1 -0
  78. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/amscd.js +1 -0
  79. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/autoload.js +1 -0
  80. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/bbox.js +1 -0
  81. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/boldsymbol.js +1 -0
  82. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/braket.js +1 -0
  83. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/bussproofs.js +1 -0
  84. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/cancel.js +1 -0
  85. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/cases.js +1 -0
  86. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/centernot.js +1 -0
  87. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/color.js +1 -0
  88. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/colortbl.js +1 -0
  89. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/colorv2.js +1 -0
  90. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/configmacros.js +1 -0
  91. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/empheq.js +1 -0
  92. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/enclose.js +1 -0
  93. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/extpfeil.js +1 -0
  94. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/gensymb.js +1 -0
  95. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/html.js +1 -0
  96. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/mathtools.js +1 -0
  97. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/mhchem.js +34 -0
  98. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/newcommand.js +1 -0
  99. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/noerrors.js +1 -0
  100. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/noundefined.js +1 -0
  101. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/physics.js +1 -0
  102. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/require.js +1 -0
  103. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/setoptions.js +1 -0
  104. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/tagformat.js +1 -0
  105. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/textcomp.js +1 -0
  106. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/textmacros.js +1 -0
  107. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/unicode.js +1 -0
  108. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/upgreek.js +1 -0
  109. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex/extensions/verb.js +1 -0
  110. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex-base.js +1 -0
  111. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex-full.js +34 -0
  112. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/input/tex.js +1 -0
  113. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/latest.js +1 -0
  114. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/loader.js +1 -0
  115. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/node-main.js +1 -0
  116. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/tex.js +1 -0
  117. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff +0 -0
  118. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff +0 -0
  119. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff +0 -0
  120. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff +0 -0
  121. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff +0 -0
  122. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff +0 -0
  123. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff +0 -0
  124. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff +0 -0
  125. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff +0 -0
  126. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff +0 -0
  127. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff +0 -0
  128. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff +0 -0
  129. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff +0 -0
  130. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff +0 -0
  131. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff +0 -0
  132. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff +0 -0
  133. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff +0 -0
  134. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff +0 -0
  135. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff +0 -0
  136. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff +0 -0
  137. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff +0 -0
  138. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff +0 -0
  139. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml/fonts/woff-v2/MathJax_Zero.woff +0 -0
  140. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/chtml.js +1 -0
  141. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/svg/fonts/tex.js +1 -0
  142. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/output/svg.js +1 -0
  143. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/sre/mathmaps/base.json +29 -0
  144. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/sre/mathmaps/ca.json +140 -0
  145. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/sre/mathmaps/da.json +140 -0
  146. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/sre/mathmaps/de.json +146 -0
  147. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/sre/mathmaps/en.json +158 -0
  148. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/sre/mathmaps/es.json +140 -0
  149. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/sre/mathmaps/fr.json +146 -0
  150. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/sre/mathmaps/hi.json +146 -0
  151. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/sre/mathmaps/it.json +146 -0
  152. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/sre/mathmaps/nb.json +146 -0
  153. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/sre/mathmaps/nemeth.json +125 -0
  154. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/sre/mathmaps/nn.json +146 -0
  155. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/sre/mathmaps/sv.json +146 -0
  156. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/startup.js +1 -0
  157. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/tex-chtml-full-speech.js +34 -0
  158. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/tex-mml-chtml.js +1 -0
  159. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/ui/lazy.js +1 -0
  160. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/ui/menu.js +1 -0
  161. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/MathJax/ui/safe.js +1 -0
  162. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/app.js +15 -0
  163. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/clipboard.min.js +7 -0
  164. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/date.min.js +123 -0
  165. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/gollum.editor.js +1277 -0
  166. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/langs/asciidoc.js +117 -0
  167. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/langs/bib.js +8 -0
  168. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/langs/creole.js +70 -0
  169. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/langs/default.js +201 -0
  170. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/langs/markdown.js +119 -0
  171. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/langs/mediawiki.js +122 -0
  172. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/langs/org.js +128 -0
  173. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/langs/plaintext.js +8 -0
  174. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/langs/pod.js +93 -0
  175. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/langs/rdoc.js +23 -0
  176. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/langs/rest.js +187 -0
  177. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/langs/textile.js +133 -0
  178. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/modes.js.erb +252 -0
  179. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor/sections.js +87 -0
  180. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/editor.js +30 -0
  181. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/gollum.behaviors.js +40 -0
  182. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/gollum.dialog.js +263 -0
  183. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/gollum.js.erb +814 -0
  184. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/gollum.katex.js +3 -0
  185. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/gollum.mermaid.js +2 -0
  186. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/gollum.placeholder.js +54 -0
  187. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/identicon.js +205 -0
  188. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/jquery-1.9.1.min.js +5 -0
  189. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/jquery.resize.js +164 -0
  190. data/gollum-6.1.0/lib/gollum/public/gollum/javascript/polyfills.js +6 -0
  191. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/_base.scss +13 -0
  192. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/_breakpoint.scss +22 -0
  193. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/_features.scss +84 -0
  194. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/_spinners.scss +245 -0
  195. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/app.scss +16 -0
  196. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/criticmarkup.scss +42 -0
  197. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/dialog.scss +140 -0
  198. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/editor.scss +217 -0
  199. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/emoji.scss +5 -0
  200. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/highlights.scss +196 -0
  201. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/print.scss +16 -0
  202. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/spinner.scss +9 -0
  203. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/tables.scss +47 -0
  204. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/template.scss.erb +204 -0
  205. data/gollum-6.1.0/lib/gollum/public/gollum/stylesheets/wiki_content.scss +144 -0
  206. data/gollum-6.1.0/lib/gollum/templates/commit.mustache +29 -0
  207. data/gollum-6.1.0/lib/gollum/templates/compare.mustache +84 -0
  208. data/gollum-6.1.0/lib/gollum/templates/create.mustache +26 -0
  209. data/gollum-6.1.0/lib/gollum/templates/edit.mustache +24 -0
  210. data/gollum-6.1.0/lib/gollum/templates/editor.mustache +215 -0
  211. data/gollum-6.1.0/lib/gollum/templates/error.mustache +8 -0
  212. data/gollum-6.1.0/lib/gollum/templates/history.mustache +51 -0
  213. data/gollum-6.1.0/lib/gollum/templates/history_authors/gravatar.mustache +2 -0
  214. data/gollum-6.1.0/lib/gollum/templates/history_authors/identicon.mustache +2 -0
  215. data/gollum-6.1.0/lib/gollum/templates/history_authors/none.mustache +2 -0
  216. data/gollum-6.1.0/lib/gollum/templates/latest_changes.mustache +36 -0
  217. data/gollum-6.1.0/lib/gollum/templates/layout.mustache +140 -0
  218. data/gollum-6.1.0/lib/gollum/templates/mobilenav.mustache +72 -0
  219. data/gollum-6.1.0/lib/gollum/templates/navbar.mustache +110 -0
  220. data/gollum-6.1.0/lib/gollum/templates/overview.mustache +55 -0
  221. data/gollum-6.1.0/lib/gollum/templates/page.mustache +13 -0
  222. data/gollum-6.1.0/lib/gollum/templates/pagination.mustache +23 -0
  223. data/gollum-6.1.0/lib/gollum/templates/search.mustache +51 -0
  224. data/gollum-6.1.0/lib/gollum/templates/searchbar.mustache +3 -0
  225. data/gollum-6.1.0/lib/gollum/templates/wiki_content.mustache +64 -0
  226. data/gollum-6.1.0/lib/gollum/uri_encode_component.rb +212 -0
  227. data/gollum-6.1.0/lib/gollum/views/commit.rb +49 -0
  228. data/gollum-6.1.0/lib/gollum/views/compare.rb +109 -0
  229. data/gollum-6.1.0/lib/gollum/views/create.rb +53 -0
  230. data/gollum-6.1.0/lib/gollum/views/edit.rb +78 -0
  231. data/gollum-6.1.0/lib/gollum/views/editable.rb +31 -0
  232. data/gollum-6.1.0/lib/gollum/views/error.rb +7 -0
  233. data/gollum-6.1.0/lib/gollum/views/has_math.rb +15 -0
  234. data/gollum-6.1.0/lib/gollum/views/has_page.rb +19 -0
  235. data/gollum-6.1.0/lib/gollum/views/has_user_icons.rb +15 -0
  236. data/gollum-6.1.0/lib/gollum/views/helpers/locale_helpers.rb +89 -0
  237. data/gollum-6.1.0/lib/gollum/views/helpers.rb +132 -0
  238. data/gollum-6.1.0/lib/gollum/views/history.rb +56 -0
  239. data/gollum-6.1.0/lib/gollum/views/latest_changes.rb +44 -0
  240. data/gollum-6.1.0/lib/gollum/views/layout.rb +103 -0
  241. data/gollum-6.1.0/lib/gollum/views/overview.rb +81 -0
  242. data/gollum-6.1.0/lib/gollum/views/page.rb +277 -0
  243. data/gollum-6.1.0/lib/gollum/views/pagination.rb +13 -0
  244. data/gollum-6.1.0/lib/gollum/views/rss.rb +84 -0
  245. data/gollum-6.1.0/lib/gollum/views/search.rb +47 -0
  246. data/gollum-6.1.0/lib/gollum/views/template_cascade.rb +29 -0
  247. data/gollum-6.1.0/lib/gollum.rb +42 -0
  248. data/gollum-6.1.0/licenses/licenses.txt +31 -0
  249. data/gollum-6.1.0/package.json +12 -0
  250. data/gollum-6.1.0/yarn.lock +1025 -0
  251. data/super-pro-rb.gemspec +11 -0
  252. metadata +290 -0
@@ -0,0 +1,747 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'cgi'
4
+ require 'sinatra'
5
+ require 'sinatra/namespace'
6
+ require 'gollum-lib'
7
+ require 'mustache/sinatra'
8
+ require 'json'
9
+ require 'sprockets'
10
+ require 'sprockets-helpers'
11
+ require 'octicons'
12
+ require 'pathname'
13
+
14
+ require 'gollum'
15
+ require 'gollum/assets'
16
+
17
+ # Requirements for loading the layout view:
18
+ require 'gollum/views/helpers'
19
+ require 'gollum/views/helpers/locale_helpers'
20
+ require 'gollum/views/template_cascade'
21
+
22
+ require 'gollum/views/layout'
23
+ require 'gollum/views/editable'
24
+ require 'gollum/views/has_page'
25
+ require 'gollum/views/has_user_icons'
26
+ require 'gollum/views/has_math'
27
+ require 'gollum/views/pagination'
28
+ require 'gollum/views/rss.rb'
29
+
30
+ ['sassc', 'sassc-embedded'].each do |gem|
31
+ require gem if Gem::Specification.find {|spec| spec.name == gem}
32
+ end
33
+
34
+ require File.expand_path '../helpers', __FILE__
35
+
36
+ #required to upload bigger binary files
37
+ Gollum::set_git_timeout(120)
38
+ Gollum::set_git_max_filesize(190 * 10**6)
39
+
40
+ Gollum::Filter::Code.language_handlers[/mermaid/] = Proc.new { |lang, code| "<div class=\"mermaid\">\n#{code}\n</div>" }
41
+
42
+ # Run the frontend, based on Sinatra
43
+ #
44
+ # There are a number of wiki options that can be set for the frontend
45
+ #
46
+ # Example
47
+ # require 'gollum/app'
48
+ # Precious::App.set(:wiki_options, {
49
+ # :universal_toc => false,
50
+ # }
51
+ #
52
+ # See the wiki.rb file for more details on wiki options
53
+
54
+ module Precious
55
+
56
+ # For use with the --base-path option.
57
+ class MapGollum
58
+ include Precious::Helpers
59
+ def initialize(base_path)
60
+ base_route = "/#{remove_leading_and_trailing_slashes(base_path)}"
61
+ @mg = Rack::Builder.new do
62
+
63
+ map base_route do
64
+ run Precious::App
65
+ end
66
+ map '/' do
67
+ run Proc.new { [302, { 'Location' => base_route }, []] }
68
+ end
69
+ map '/*' do
70
+ run Proc.new { [302, { 'Location' => base_route }, []] }
71
+ end
72
+
73
+ end
74
+ end
75
+
76
+ def call(env)
77
+ @mg.call(env)
78
+ end
79
+ end
80
+
81
+ class App < Sinatra::Base
82
+ register Mustache::Sinatra
83
+ register Sinatra::Namespace
84
+ include Precious::Helpers
85
+
86
+ Encoding.default_external = "UTF-8"
87
+
88
+ dir = File.dirname(File.expand_path(__FILE__))
89
+
90
+ set :sprockets, ::Precious::Assets.sprockets(dir)
91
+
92
+ set :default_markup, :markdown
93
+
94
+ set :mustache, {
95
+ # Tell mustache where the Views constant lives
96
+ :namespace => Precious,
97
+
98
+ # Mustache templates live here
99
+ :templates => "#{dir}/templates",
100
+
101
+ # Tell mustache where the views are
102
+ :views => "#{dir}/views"
103
+ }
104
+
105
+ # Sinatra error handling
106
+ configure :development, :staging, :gollum_development do
107
+ enable :show_exceptions, :dump_errors
108
+ disable :raise_errors, :clean_trace
109
+ end
110
+
111
+ configure :test do
112
+ enable :logging, :raise_errors, :dump_errors
113
+ end
114
+
115
+ before do
116
+ @allow_editing = settings.wiki_options.fetch(:allow_editing, true)
117
+ @critic_markup = settings.wiki_options[:critic_markup]
118
+ @redirects_enabled = settings.wiki_options.fetch(:redirects_enabled, true)
119
+ @per_page_uploads = settings.wiki_options[:per_page_uploads]
120
+ @show_local_time = settings.wiki_options.fetch(:show_local_time, false)
121
+
122
+ @wiki_title = settings.wiki_options.fetch(:title, 'Gollum Wiki')
123
+ @default_keybinding = settings.wiki_options.fetch(:default_keybinding, 'default')
124
+
125
+ if settings.wiki_options[:template_dir]
126
+ Precious::Views::Layout.template_priority_path = settings.wiki_options[:template_dir]
127
+ end
128
+
129
+ @base_url = url('/', false).chomp('/').force_encoding('utf-8')
130
+ @page_dir = settings.wiki_options[:page_file_dir].to_s
131
+
132
+ # above will detect base_path when it's used with map in a config.ru
133
+ settings.wiki_options.merge!({ :base_path => @base_url })
134
+ @css = settings.wiki_options[:css]
135
+ @js = settings.wiki_options[:js]
136
+ @math = settings.wiki_options[:math]
137
+ @math_config = settings.wiki_options.fetch(:math_config, false)
138
+ @mermaid = settings.wiki_options.fetch(:mermaid, true)
139
+ Gollum::Filter::Code.language_handlers.delete(/mermaid/) unless @mermaid
140
+
141
+ @use_static_assets = settings.wiki_options.fetch(:static, settings.environment != :gollum_development)
142
+ @static_assets_path = settings.wiki_options.fetch(:static_assets_path, ::File.join(File.dirname(__FILE__), 'public/assets'))
143
+ @mathjax_path = ::File.join(File.dirname(__FILE__), 'public/gollum/javascript/MathJax')
144
+
145
+ Sprockets::Helpers.configure do |config|
146
+ config.environment = settings.sprockets
147
+ config.environment.context_class.class_variable_set(:@@base_url, @base_url)
148
+ config.prefix = "#{@base_url}/#{Precious::Assets::ASSET_URL}"
149
+ config.digest = @use_static_assets
150
+ if @use_static_assets
151
+ config.public_path = @static_assets_path
152
+ config.manifest = Sprockets::Manifest.new(settings.sprockets, @static_assets_path)
153
+ end
154
+ end
155
+
156
+ forbid unless @allow_editing || request.request_method == 'GET'
157
+ end
158
+
159
+ get '/' do
160
+ redirect clean_url(::File.join(@base_url, wiki_new.index_page))
161
+ end
162
+
163
+ namespace '/gollum' do
164
+ get '/feed/' do
165
+ url = "#{env['rack.url_scheme']}://#{env['HTTP_HOST']}"
166
+ changes = wiki_new.latest_changes(::Gollum::Page.log_pagination_options(
167
+ per_page: settings.wiki_options.fetch(:pagination_count, 10),
168
+ page_num: 0)
169
+ )
170
+ content_type :rss
171
+ RSSView.new(@base_url, @wiki_title, url, changes).render
172
+ end
173
+
174
+ get '/assets/mathjax/*' do
175
+ env['PATH_INFO'].sub!('/gollum/assets/mathjax', '')
176
+ Rack::Static.new(not_found_proc, {:root => @mathjax_path, :urls => ['']}).call(env)
177
+ end
178
+
179
+ get '/assets/*' do
180
+ env['PATH_INFO'].sub!("/#{Precious::Assets::ASSET_URL}", '')
181
+ if @use_static_assets
182
+ env['PATH_INFO'].sub!(Sprockets::Helpers.prefix, '') if @base_url
183
+ Rack::Static.new(not_found_proc, {:root => @static_assets_path, :urls => ['']}).call(env)
184
+ else
185
+ settings.sprockets.call(env)
186
+ end
187
+ end
188
+
189
+ get '/last_commit_info' do
190
+ content_type :json
191
+ if page = wiki_page(params[:path]).page
192
+ version = page.last_version
193
+ authored_date = version.authored_date
194
+ authored_date = authored_date.utc.iso8601 if @show_local_time
195
+ {:author => version.author.name, :date => authored_date}.to_json
196
+ end
197
+ end
198
+
199
+ include Precious::Views::OcticonHelpers
200
+ get '/octicon/:name' do
201
+ begin
202
+ [200, {'Content-Type' => 'image/svg'}, rocticon_css(params['name'])]
203
+ rescue RuntimeError
204
+ not_found
205
+ end
206
+ end
207
+
208
+ get '/emoji/:name' do
209
+ begin
210
+ [200, {'Content-Type' => 'image/png'}, emoji(params['name'])]
211
+ rescue ArgumentError
212
+ not_found
213
+ end
214
+ end
215
+
216
+ get '/data/*' do
217
+ if page = wiki_page(params[:splat].first).page
218
+ page.raw_data
219
+ end
220
+ end
221
+
222
+ get %r{/(edit|create)/(\.redirects.gollum|(custom|math\.config)\.(js|css))} do
223
+ forbid('Changing this resource is not allowed.')
224
+ end
225
+
226
+ post %r{/(delete|rename|edit|create)/(\.redirects.gollum|(custom|math\.config)\.(js|css))} do
227
+ forbid('Changing this resource is not allowed.')
228
+ end
229
+
230
+ post %r{/revert/(\.redirects.gollum|(custom|math\.config\.)\.(js|css)/.*/.*)} do
231
+ forbid('Changing this resource is not allowed.')
232
+ end
233
+
234
+ get '/edit/*' do
235
+ forbid unless @allow_editing
236
+ wikip = wiki_page(params[:splat].first)
237
+ @name = wikip.fullname
238
+ @path = wikip.path
239
+ @upload_dest = find_upload_dest(wikip.fullpath)
240
+ wiki = wikip.wiki
241
+ @allow_uploads = wiki.allow_uploads
242
+ if page = wikip.page
243
+ @page = page
244
+ @content = page.text_data
245
+ @etag = page.sha
246
+ mustache :edit
247
+ else
248
+ path = ::File.join('gollum/create', @path, @name)
249
+ redirect to(clean_url(encodeURIComponent(path)))
250
+ end
251
+ end
252
+
253
+ # AJAX calls only
254
+ post '/upload_file' do
255
+
256
+ wiki = wiki_new
257
+ halt 405 unless wiki.allow_uploads
258
+
259
+ if params[:file]
260
+ fullname = params[:file][:filename]
261
+ tempfile = params[:file][:tempfile]
262
+ end
263
+ halt 500 unless tempfile.is_a? Tempfile
264
+
265
+ dir = wiki.per_page_uploads ? find_per_page_upload_subdir(request.referer, request.host_with_port, wiki.base_path) : 'uploads'
266
+
267
+ halt 500 if dir.include?('..')
268
+ halt 500 unless Pathname(dir).relative?
269
+
270
+ ext = ::File.extname(fullname)
271
+ format = ext.split('.').last || 'txt'
272
+ filename = ::File.basename(fullname, ext)
273
+ contents = ::File.read(tempfile)
274
+ reponame = "#{dir}/#{filename}.#{format}"
275
+
276
+ options = { :message => "Uploaded file to #{reponame}" }
277
+ options[:parent] = wiki.repo.head.commit if wiki.repo.head
278
+
279
+ author = session['gollum.author']
280
+ unless author.nil?
281
+ options.merge! author
282
+ end
283
+
284
+ options[:normalize] = Gollum::Page.valid_extension?(fullname)
285
+
286
+ begin
287
+ wiki.write_file(reponame, contents, options)
288
+ redirect to(request.referer)
289
+ rescue Gollum::IllegalDirectoryPath => e
290
+ @message = e.message
291
+ mustache :error
292
+ rescue Gollum::DuplicatePageError
293
+ halt 409, "The file you are trying to upload already exists." # Signal conflict
294
+ end
295
+ end
296
+
297
+
298
+ post '/rename/*' do
299
+ wikip = wiki_page(params[:splat].first)
300
+ halt 500 if wikip.nil?
301
+ wiki = wikip.wiki
302
+ page = wikip.page
303
+ rename = params[:rename]
304
+ halt 500 if page.nil?
305
+ halt 500 if rename.nil? or rename.empty?
306
+
307
+ # Fixup the rename if it is a relative path
308
+ # In 1.8.7 rename[0] != rename[0..0]
309
+ if rename[0..0] != '/'
310
+ source_dir = ::File.dirname(page.path)
311
+ source_dir = '' if source_dir == '.'
312
+ (target_dir, target_name) = ::File.split(rename)
313
+ target_dir = target_dir == '' ? source_dir : "#{source_dir}/#{target_dir}"
314
+ rename = "#{target_dir}/#{target_name}"
315
+ end
316
+
317
+ committer = Gollum::Committer.new(wiki, commit_options)
318
+ commit = { :committer => committer }
319
+
320
+ success = wiki.rename_page(page, rename, commit)
321
+ if !success
322
+ # This occurs on NOOPs, for example renaming A => A
323
+ redirect to("/#{page.escaped_url_path}")
324
+ return
325
+ end
326
+
327
+ # Renaming preserves format, so add the page's format to the renamed path to retrieve the renamed page
328
+ new_path = "#{rename}.#{Gollum::Page.format_to_ext(page.format)}"
329
+ # Add a redirect from the old page to the new
330
+ wiki.add_redirect(page.url_path, clean_url(new_path), commit) if @redirects_enabled
331
+
332
+ committer.commit
333
+
334
+ page = wiki_page(new_path).page
335
+ return if page.nil?
336
+ redirect to("/#{page.escaped_url_path}")
337
+ end
338
+
339
+ post '/edit/*' do
340
+ etag = params[:etag]
341
+ path = "/#{clean_url(sanitize_empty_params(params[:path]))}"
342
+ wiki = wiki_new
343
+ page = wiki.page(::File.join(path, params[:page]))
344
+
345
+ return if page.nil?
346
+ if etag != page.sha
347
+ # Signal edit collision and return the page's most recent version
348
+ halt 412, {etag: page.sha, text_data: page.text_data}.to_json
349
+ end
350
+
351
+ begin
352
+ committer = Gollum::Committer.new(wiki, commit_options)
353
+ commit = { :committer => committer }
354
+
355
+ update_wiki_page(wiki, page, params[:content], commit, page.name, params[:format])
356
+ update_wiki_page(wiki, page.header, params[:header], commit) if params[:header]
357
+ update_wiki_page(wiki, page.footer, params[:footer], commit) if params[:footer]
358
+ update_wiki_page(wiki, page.sidebar, params[:sidebar], commit) if params[:sidebar]
359
+ committer.commit
360
+ rescue Gollum::DuplicatePageError
361
+ halt 409, "You are trying to save this page under a path (#{page.escaped_url_path}) that already exists." # Signal conflict
362
+ end
363
+
364
+ end
365
+
366
+ post '/delete/*' do
367
+ forbid unless @allow_editing
368
+ wiki = wiki_new
369
+ filepath = params[:splat].first
370
+ unless filepath.nil?
371
+ commit = commit_options
372
+ commit[:message] = "Deleted #{filepath}"
373
+ wiki.delete_file(filepath, commit)
374
+ end
375
+ end
376
+
377
+ get '/create/*' do
378
+ forbid unless @allow_editing
379
+ wikip = wiki_page(params[:splat].first)
380
+ @name = wikip.name
381
+ @ext = wikip.ext
382
+ @path = wikip.path
383
+ @template_page = load_template(wikip, @path) if settings.wiki_options[:template_page]
384
+ @allow_uploads = wikip.wiki.allow_uploads
385
+ @upload_dest = find_upload_dest(wikip.fullpath)
386
+
387
+ page = wikip.page
388
+ if page
389
+ redirect to("/#{clean_url(page.escaped_url_path)}")
390
+ else
391
+ unless Gollum::Page.format_for("#{@name}#{@ext}")
392
+ @name = "#{@name}#{@ext}"
393
+ @ext = nil
394
+ end
395
+ mustache :create
396
+ end
397
+ end
398
+
399
+ post '/create' do
400
+ name = params[:page]
401
+ path = sanitize_empty_params(params[:path]) || ''
402
+ format = params[:format].intern
403
+ wiki = wiki_new
404
+
405
+ path.gsub!(/^\//, '')
406
+
407
+ begin
408
+ wiki.write_page(::File.join(path, name), format, params[:content], commit_options)
409
+
410
+ redirect to("/#{clean_url(::File.join(encodeURIComponent(path), encodeURIComponent(wiki.page_file_name(name, format))))}")
411
+ rescue Gollum::DuplicatePageError, Gollum::IllegalDirectoryPath => e
412
+ @message = e.message
413
+ mustache :error
414
+ end
415
+ end
416
+
417
+ post '/revert/*/:sha1/:sha2' do
418
+ wikip = wiki_page(params[:splat].first)
419
+ @path = wikip.path
420
+ @name = wikip.fullname
421
+ wiki = wikip.wiki
422
+ @page = wikip.page
423
+ sha1 = params[:sha1]
424
+ sha2 = params[:sha2]
425
+
426
+ commit = commit_options
427
+ commit[:message] = "Revert commit #{sha2.chars.take(7).join}"
428
+ if wiki.revert_page(@page, sha1, sha2, commit)
429
+ redirect to("/#{@page.escaped_url_path}")
430
+ else
431
+ sha2, sha1 = sha1, "#{sha1}^" if !sha2
432
+ @versions = [sha1, sha2]
433
+ @diff = wiki.repo.diff(@versions.first, @versions.last, @page.path)
434
+ @message = 'The patch does not apply.'
435
+ mustache :compare
436
+ end
437
+ end
438
+
439
+ post '/preview' do
440
+ wiki = wiki_new
441
+ @name = params[:page] ? strip_page_name(params[:page]) : 'Preview'
442
+ @page = wiki.preview_page(@name, params[:content], params[:format])
443
+ ['sidebar', 'header', 'footer'].each do |subpage|
444
+ @page.send("set_#{subpage}".to_sym, params[subpage]) if params[subpage]
445
+ end
446
+ @content = @page.formatted_data
447
+ @toc_content = wiki.universal_toc ? @page.toc_data : nil
448
+ @h1_title = wiki.h1_title
449
+ @editable = false
450
+ @bar_side = wiki.bar_side
451
+ @allow_uploads = false
452
+ @navbar = false
453
+ @preview = true
454
+ mustache :page
455
+ end
456
+
457
+ get %r{
458
+ /history/ # match any URL beginning with /history/
459
+ (.+?) # extract the full path (including any directories)
460
+ /
461
+ ([0-9a-f]{40}) # match SHA
462
+ }x do |path, version|
463
+ wiki = wiki_new
464
+ show_history wiki_page(path, version, wiki)
465
+ end
466
+
467
+ get '/history/*' do
468
+ show_history wiki_page(params[:splat].first)
469
+ end
470
+
471
+ get '/latest_changes' do
472
+ @wiki = wiki_new
473
+ @page_num = [params[:page_num].to_i, 1].max
474
+ @max_count = settings.wiki_options.fetch(:pagination_count, 10)
475
+ @versions = @wiki.latest_changes(::Gollum::Page.log_pagination_options(per_page: @max_count, page_num: @page_num))
476
+ mustache :latest_changes
477
+ end
478
+
479
+ get %r{
480
+ /compare/ # match any URL beginning with /compare/
481
+ (.+) # extract the full path (including any directories)
482
+ / # match the final slash
483
+ ([^.]+) # match the first SHA1
484
+ \.{2,3} # match .. or ...
485
+ (.+) # match the second SHA1
486
+ }x do |path, start_version, end_version|
487
+ wikip = wiki_page(path)
488
+ @path = wikip.path
489
+ @name = wikip.fullname
490
+ @versions = [start_version, end_version]
491
+ wiki = wikip.wiki
492
+ @page = wikip.page
493
+ @diff = wiki.repo.diff(@versions.first, @versions.last, @page.path)
494
+ if @diff.empty?
495
+ @message = 'Could not compare these two revisions, no differences were found.'
496
+ mustache :error
497
+ else
498
+ mustache :compare
499
+ end
500
+ end
501
+
502
+ get '/compare/*' do
503
+ @file = clean_url(encodeURIComponent(params[:splat].first))
504
+ @versions = params[:versions] || []
505
+ if @versions.size == 1
506
+ wikip = wiki_page(params[:splat].first)
507
+ commit = wikip.wiki.repo.commit(@versions.first)
508
+ parent = commit.parent
509
+ if parent.nil?
510
+ redirect to("#{@file}/#{@commit.id}")
511
+ else
512
+ @versions.push(parent.id)
513
+ end
514
+ end
515
+ if @versions.empty?
516
+ redirect to("gollum/history/#{@file}")
517
+ else
518
+ redirect to("gollum/compare/%s/%s...%s" % [
519
+ @file,
520
+ @versions.last,
521
+ @versions.first]
522
+ )
523
+ end
524
+ end
525
+
526
+
527
+ get %r{
528
+ /commit/ # match any URL beginning with /show/
529
+ (\w+) # match the SHA1
530
+ }x do |version|
531
+ @version = version
532
+ wiki = wiki_new
533
+ begin
534
+ @commit = wiki.repo.commit(version)
535
+ parent = @commit.parent
536
+ parent_id = parent.nil? ? nil : parent.id
537
+ @diff = wiki.repo.diff(parent_id, version)
538
+ mustache :commit
539
+ rescue Gollum::Git::NoSuchShaFound
540
+ @message = "Invalid commit: #{@version}"
541
+ mustache :error
542
+ end
543
+ end
544
+
545
+ get '/search' do
546
+ @query = params[:q] || ''
547
+ @name = @query
548
+ if @query.empty?
549
+ @results = []
550
+ @search_terms = []
551
+ else
552
+ @page_num = [params[:page_num].to_i, 1].max
553
+ @max_count = 10
554
+ wiki = wiki_new
555
+ @results, @search_terms = wiki.search(@query)
556
+ end
557
+ mustache :search
558
+ end
559
+
560
+ get %r{
561
+ /overview # match any URL beginning with /overview
562
+ (?: # begin an optional non-capturing group
563
+ /(.+) # capture any path after the "/overview" excluding the leading slash
564
+ )? # end the optional non-capturing group
565
+ }x do |path|
566
+ wiki = wiki_new
567
+ @results = wiki.tree_list
568
+
569
+ if path
570
+ @path = Pathname.new(path).cleanpath.to_s
571
+ check_path = wiki.page_file_dir ? ::File.join(wiki.page_file_dir, @path, '/') : "#{@path}/"
572
+ @results.select! {|result| result.path.start_with?(check_path) }
573
+ end
574
+
575
+ @results.sort_by! {|result| result.name.downcase}
576
+
577
+ @ref = wiki.ref
578
+ @newable = true
579
+ mustache :overview
580
+ end
581
+ end # gollum namespace
582
+
583
+ get %r{/(.+?)/([0-9a-f]{40})} do
584
+ file_path = params[:captures][0]
585
+ version = params[:captures][1]
586
+ wikip = wiki_page(file_path, version)
587
+ name = wikip.fullname
588
+ path = wikip.path
589
+ if page = wikip.page
590
+ @page = page
591
+ @name = name
592
+ @content = page.formatted_data
593
+ @version = version
594
+ @historical = true
595
+ @bar_side = wikip.wiki.bar_side
596
+ @navbar = true
597
+ mustache :page
598
+ elsif file = wikip.wiki.file(file_path, version, true)
599
+ show_file(file)
600
+ else
601
+ halt 404
602
+ end
603
+ end
604
+
605
+ get '/\.redirects\.gollum' do
606
+ forbid('Accessing this resource is not allowed.')
607
+ end
608
+
609
+ get '/*' do
610
+ fullpath = params[:splat].first
611
+ if params.has_key?("raw")
612
+ show_raw_page(fullpath)
613
+ else
614
+ show_page_or_file(fullpath)
615
+ end
616
+ end
617
+
618
+ private
619
+
620
+ def redirect_to(redirect_path, fullpath, query_params)
621
+ redirect to("#{encodeURI(redirect_path)}?redirected_from=#{encodeURI(fullpath)}#{query_params}")
622
+ end
623
+
624
+ def page_does_not_exist()
625
+ @message = "The requested page does not exist."
626
+ status 404
627
+ return mustache :error
628
+ end
629
+
630
+ def show_history(wikip)
631
+ @name = wikip.fullname
632
+ @page = wikip.page
633
+ @page_num = [params[:page_num].to_i, 1].max
634
+ @max_count = settings.wiki_options.fetch(:pagination_count, 10)
635
+ unless @page.nil?
636
+ @wiki = @page.wiki
637
+ @versions = @page.versions(
638
+ per_page: @max_count,
639
+ page_num: @page_num,
640
+ follow: settings.wiki_options.fetch(:follow_renames, true)
641
+ )
642
+ mustache :history
643
+ else
644
+ redirect to("/")
645
+ end
646
+ end
647
+
648
+ def show_page_or_file(fullpath)
649
+ wiki = wiki_new
650
+ if page = wiki.page(fullpath)
651
+ @page = page
652
+ @name = page.filename_stripped
653
+ @content = page.formatted_data
654
+ @upload_dest = find_upload_dest(Pathname.new(fullpath).cleanpath.to_s)
655
+
656
+ # Extensions and layout data
657
+ @editable = true
658
+ @toc_content = wiki.universal_toc ? @page.toc_data : nil
659
+ @h1_title = wiki.h1_title
660
+ @bar_side = wiki.bar_side
661
+ @allow_uploads = wiki.allow_uploads
662
+ @navbar = true
663
+ mustache :page
664
+ elsif file = wiki.file(fullpath, wiki.ref, true)
665
+ show_file(file)
666
+ elsif @redirects_enabled && redirect_path = wiki.redirects[fullpath]
667
+ redirect_to(redirect_path, fullpath, "")
668
+ else
669
+ if @allow_editing
670
+ path = fullpath[-1] == '/' ? "#{fullpath}#{wiki.index_page}" : fullpath # Append default index page if no page name is supplied
671
+ redirect to("/gollum/create/#{clean_url(encodeURIComponent(path))}")
672
+ else
673
+ return page_does_not_exist
674
+ end
675
+ end
676
+ end
677
+
678
+ def show_raw_page(fullpath)
679
+ wiki = wiki_new
680
+ if @redirects_enabled && redirect_path = wiki.redirects[fullpath]
681
+ redirect_to(redirect_path, fullpath, "&raw")
682
+ elsif page = wiki.page(fullpath) and file = wiki.file(fullpath, wiki.ref, true)
683
+ show_file(file)
684
+ else
685
+ return page_does_not_exist
686
+ end
687
+ end
688
+
689
+ def show_file(file)
690
+ return unless file
691
+ content_type file.mime_type
692
+ if file.on_disk?
693
+ send_file file.on_disk_path, :disposition => 'inline'
694
+ else
695
+ file.raw_data
696
+ end
697
+ end
698
+
699
+ def load_template(wiki_page, path)
700
+ template_page = wiki_page(::File.join(path, '_Template')).page || wiki_page('/_Template').page
701
+ template_page ? Gollum::TemplateFilter.apply_filters(wiki_page, template_page.text_data) : nil
702
+ end
703
+
704
+ def update_wiki_page(wiki, page, content, commit, name = nil, format = nil)
705
+ return if !page ||
706
+ ((!content || page.raw_data == content) && page.format == format)
707
+ name ||= page.name
708
+ format = (format || page.format).to_sym
709
+ content ||= page.raw_data
710
+ wiki.update_page(page, name, format, content.to_s, commit)
711
+ end
712
+
713
+ def wiki_page(path, version = nil, wiki = nil)
714
+ pathname = (Pathname.new('/') + path).cleanpath
715
+ wiki = wiki_new if wiki.nil?
716
+ OpenStruct.new(:wiki => wiki, :page => wiki.page(pathname.to_s, version = version),
717
+ :name => pathname.basename.sub_ext('').to_s, :path => pathname.dirname.to_s, :ext => pathname.extname, :fullname => pathname.basename.to_s, :fullpath => pathname.to_s)
718
+ end
719
+
720
+ def wiki_new
721
+ Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
722
+ end
723
+
724
+ # Options parameter to Gollum::Committer#initialize
725
+ # :message - The String commit message.
726
+ # :name - The String author full name.
727
+ # :email - The String email address.
728
+ # message is sourced from the incoming request parameters
729
+ # optional author details are sourced from the session, to be populated by rack middleware ahead of us.
730
+ # optional note is equally sourced from the session.
731
+ def commit_options
732
+ msg = (params[:message].nil? or params[:message].empty?) ? "[no message]" : params[:message]
733
+ commit_options = { message: msg, note: session['gollum.note'] }
734
+ author_parameters = session['gollum.author']
735
+ commit_options.merge! author_parameters unless author_parameters.nil?
736
+ commit_options
737
+ end
738
+
739
+ def find_upload_dest(path)
740
+ settings.wiki_options[:allow_uploads] ?
741
+ (settings.wiki_options[:per_page_uploads] ?
742
+ path : 'uploads'
743
+ ) : ''
744
+ end
745
+
746
+ end
747
+ end