Compare commits
152 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 404419d1c3 | |||
| 4ee94a6574 | |||
| f929df0419 | |||
| 57587dafbe | |||
| 31a95e81b3 | |||
| 70a4e9551b | |||
| e1a705f975 | |||
| 9057ec82d8 | |||
| 1b53e36666 | |||
| 10fa5c7bd2 | |||
| 06e72a5a60 | |||
| 8fa62fc300 | |||
| 6c345fc508 | |||
| a34eac4ecb | |||
| 10c121e603 | |||
| 2b910167f4 | |||
| 7d5311a075 | |||
| f5581c4b49 | |||
| e09f7cd49c | |||
| 4dab03b61b | |||
| 2b5e017aa1 | |||
| 8b3d944fd2 | |||
| 2d886fd38a | |||
| 80088832b9 | |||
| be1883f317 | |||
| 30119e0c77 | |||
| c90c3b1544 | |||
| 578386f083 | |||
| 3d21ed362e | |||
| 9cf469b035 | |||
| 462c93ae43 | |||
| bda3b7b24d | |||
| d861a22cdd | |||
| 0de1a182da | |||
| b030554348 | |||
| 858bfa9ccd | |||
| ee8ec78da7 | |||
| c8f684895c | |||
| 138a155ba4 | |||
| ad749bf345 | |||
| ff0d59c16b | |||
| df75d2d60c | |||
| 2713aabeaf | |||
| 796d1b44c2 | |||
| 470a7b8f52 | |||
| f699b82a9f | |||
| 44edb8c7da | |||
| bc4fc0edd9 | |||
| 6545fa691b | |||
| 4954553927 | |||
| 9c50ba9eeb | |||
| 9a67da145a | |||
| ca7d82278c | |||
| f6245c53dd | |||
| 6888420cc6 | |||
| c5631f5b7d | |||
| 34e0b49d72 | |||
| bd072264ef | |||
| cfb2d24c71 | |||
| fe0eb72fa3 | |||
| 2783257f06 | |||
| cc11cb866c | |||
| 6a02643bda | |||
| 7f269c8da3 | |||
| ef7f7cebd1 | |||
| 05c24fd5e3 | |||
| b08b97bd28 | |||
| dbb6ce2f71 | |||
| f66f14b593 | |||
| 8a52315dee | |||
| 7c4052906c | |||
| 3a56f39f6a | |||
| 6585ca5dd0 | |||
| 792abae07e | |||
| 74ce648c59 | |||
| 2686e96046 | |||
| 213e2bb432 | |||
| 79bb5c10ab | |||
| 7ea012d786 | |||
| 43591f75de | |||
| 05d82c0569 | |||
| 76c8d3206c | |||
| 00751d05b4 | |||
| b5be5df11a | |||
| 7d159273fc | |||
| 70127922ab | |||
| b95df93775 | |||
| dc06edcf5b | |||
| fdc437dcd5 | |||
| f6873c9612 | |||
| 93754ab32d | |||
| 5759334635 | |||
| f2f543b72d | |||
| 598b052be3 | |||
| a746062422 | |||
| c8868d369f | |||
| 52c6e7474c | |||
| be81f09b0e | |||
| 6fa4504e31 | |||
| 992ba01a12 | |||
| 72c5a74cf1 | |||
| 919f41a0f1 | |||
| 785921cb0f | |||
| 8c8cda5e7d | |||
| 64ef74e7e9 | |||
| 776df4e6ee | |||
| 68465a8651 | |||
| fa16c8960c | |||
| 2c57915781 | |||
| d0527f1aeb | |||
| 75083c5b56 | |||
| 82526594db | |||
| 941d39800c | |||
| a1ae2e8bc0 | |||
| 4af6f366ca | |||
| c7a9534ed9 | |||
| 00bcbbf72b | |||
| ed2254ff9f | |||
| b6633f0ecb | |||
| e08d2d3052 | |||
| fbc0548b43 | |||
| a9807bd1e1 | |||
| 554b80b39d | |||
| 99e74bf00b | |||
| f48e923f28 | |||
| 5400b4bfdd | |||
| f68bebe0f6 | |||
| 4c6019b439 | |||
| 66e08a6b17 | |||
| 7898db70ed | |||
| 7c357116ff | |||
| 69ce0eb0d0 | |||
| 4db31a297b | |||
| e1fca457e4 | |||
| 7f8485ce80 | |||
| 290061fd11 | |||
| a507836936 | |||
| 6524d20a96 | |||
| f1c523aa30 | |||
| 87c08f5613 | |||
| 82913cea20 | |||
| 2ad743e4bd | |||
| fa97b57a96 | |||
| 1b952b6d56 | |||
| 90cc512bd1 | |||
| b82556c9c0 | |||
| fbe3b4bb3b | |||
| 5ffd98ad31 | |||
| cb9dd4d228 | |||
| cd823bf10c | |||
| 5560ec52c2 | |||
| 065151a77f |
@@ -0,0 +1,32 @@
|
||||
# https://help.github.com/articles/dealing-with-line-endings
|
||||
#
|
||||
# For Mac & Linux
|
||||
# git config --global core.autocrlf input
|
||||
#
|
||||
# For windows
|
||||
# git config --global core.autocrlf true
|
||||
#
|
||||
# Set default behaviour, in case users don't have core.autocrlf set.
|
||||
* text=auto
|
||||
|
||||
# Explicitly declare text files we want to always be normalized and converted
|
||||
# to native line endings on checkout.
|
||||
*.txt text
|
||||
*.md text
|
||||
*.rb text
|
||||
*.js text
|
||||
*.html text
|
||||
*.yml text
|
||||
*.mustache text
|
||||
*.css text
|
||||
Rakefile text
|
||||
Gemfile text
|
||||
LICENSE text
|
||||
COPYRIGHT text
|
||||
gollum text
|
||||
.gitattributes text
|
||||
.gitignore text
|
||||
|
||||
# Denote all files that are truly binary and should not be modified.
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
+2
-1
@@ -5,4 +5,5 @@ notifications:
|
||||
disabled: true
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install -y --force-yes asciidoc
|
||||
- sudo apt-get install -y --force-yes asciidoc
|
||||
- ASCIIDOC=1; export ASCIIDOC
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
source "http://rubygems.org"
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gemspec
|
||||
gem "rake", "~> 0.9.2.2"
|
||||
gem 'rake', '~> 10.0.2'
|
||||
|
||||
@@ -2,6 +2,7 @@ gollum -- A wiki built on top of Git
|
||||
====================================
|
||||
|
||||
[](http://travis-ci.org/github/gollum)
|
||||
[](https://gemnasium.com/github/gollum)
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
@@ -18,6 +19,11 @@ number of ways depending on your needs. You can edit your wiki locally:
|
||||
Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses
|
||||
[TomDoc](http://tomdoc.org/) for inline documentation.
|
||||
|
||||
## SYSTEM REQUIREMENTS
|
||||
- Python 2.5+ (2.7.3 recommended)
|
||||
- Ruby 1.8.7+ (1.9.3 recommended)
|
||||
- Unix like operating system (OS X, Ubuntu, Debian, and more)
|
||||
- Will not work on Windows (because of [grit](https://github.com/github/grit))
|
||||
|
||||
## INSTALLATION
|
||||
|
||||
@@ -130,7 +136,13 @@ or JavaScript. These tags will be stripped from the converted HTML. See
|
||||
`docs/sanitization.md` for more details on what tags and attributes are
|
||||
allowed.
|
||||
|
||||
## TITLES
|
||||
|
||||
The first defined `h1` will override the default header on a page. There are two ways to set a page title. The metadata syntax:
|
||||
|
||||
`<!-- --- title: New Title -->`
|
||||
|
||||
The first `h1` tag can be set to always override the page title, without needing to use the metadata syntax. Start gollum with the `--h1-title` flag.
|
||||
## BRACKET TAGS
|
||||
|
||||
A variety of Gollum tags use a double bracket syntax. For example:
|
||||
@@ -357,25 +369,17 @@ appropriately.
|
||||
|
||||
## MATHEMATICAL EQUATIONS
|
||||
|
||||
Start gollum with the `--mathjax` flag. Read more about [MathJax](http://docs.mathjax.org/en/latest/index.html) on the web. Gollum uses the `TeX-AMS-MML_HTMLorMML` config with the `autoload-all` extension.
|
||||
|
||||
Page files may contain mathematic equations in TeX syntax that will be nicely
|
||||
typeset into the expected output. A block-style equation is delimited by `\[`
|
||||
and `\]`. For example:
|
||||
Inline math:
|
||||
|
||||
\[ P(E) = {n \choose k} p^k (1-p)^{ n-k} \]
|
||||
- $2^2$
|
||||
- `\\(2^2\\)`
|
||||
|
||||
Inline equations are delimited by `\(` and `\)`. These equations will appear
|
||||
inline with regular text. For example:
|
||||
Display math:
|
||||
|
||||
The Pythagorean theorem is \( a^2 + b^2 = c^2 \).
|
||||
|
||||
### INSTALLATION REQUIREMENTS
|
||||
|
||||
In order to get the mathematical equations rendering to work, you need the following binaries:
|
||||
|
||||
* LaTex, TeTex or MacTex/BasicTeX (pdflatex)
|
||||
* Netpbm (pnmcrop, pnmpad, pnmscale, ppmtopgm, pnmgamma, pnmtopng)
|
||||
* Ghostscript (gs)
|
||||
- $$2^2$$
|
||||
- [2^2]
|
||||
|
||||
## SEQUENCE DIAGRAMS
|
||||
|
||||
@@ -383,10 +387,10 @@ You may imbed sequence diagrams into your wiki page (rendered by
|
||||
[WebSequenceDiagrams](http://www.websequencediagrams.com) by using the
|
||||
following syntax:
|
||||
|
||||
{{{ blue-modern
|
||||
{{{{{{ blue-modern
|
||||
alice->bob: Test
|
||||
bob->alice: Test response
|
||||
}}}
|
||||
}}}}}}
|
||||
|
||||
You can replace the string "blue-modern" with any supported style.
|
||||
|
||||
@@ -413,6 +417,17 @@ By default, internal wiki links are all absolute from the root. To specify a dif
|
||||
|
||||
wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
|
||||
|
||||
Note that base_path just modifies the links. To map gollum to a non-root location:
|
||||
|
||||
- Use the gollum binary: `gollum path/to/wiki --base-path mywiki`
|
||||
- Define config.ru with `map`. See [#532](https://github.com/github/gollum/issues/532) for an example.
|
||||
|
||||
> :base_path - String base path for all Wiki links.
|
||||
>
|
||||
> The String base path to prefix to internal links. For example, when set
|
||||
> to "/wiki", the page "Hobbit" will be linked as "/wiki/Hobbit". Defaults
|
||||
> to "/".
|
||||
|
||||
Get the latest version of the given human or canonical page name:
|
||||
|
||||
page = wiki.page('page-name')
|
||||
@@ -523,9 +538,17 @@ Your Rack middleware can pass author details to Gollum in a Hash in the session
|
||||
## WINDOWS FILENAME VALIDATION
|
||||
Note that filenames on windows must not contain any of the following characters `\ / : * ? " < > |`. See [this support article](http://support.microsoft.com/kb/177506) for details.
|
||||
|
||||
## LIB.SO ERROR
|
||||
## CONFIG FILE
|
||||
|
||||
`Could not open library 'lib.so'` may be solved by installing `python-devel` on Fedora or `python-dev` on Ubuntu. Gentoo requires a rubypython [patch](https://gist.github.com/2802480) to use python2.7.
|
||||
Gollum optionally takes a `--config file`. See [config.rb](https://github.com/github/gollum/blob/master/config.rb) for an example.
|
||||
|
||||
## CUSTOM CSS
|
||||
|
||||
The `--css` flag will inject `custom.css` from the root of your git repository into each page. `custom.css` must be commited to git or you will get a 302 redirect to the create page. Here's an example of floating the sidebar to the left.
|
||||
|
||||
```css
|
||||
#wiki-rightbar { float: left !important; }
|
||||
```
|
||||
|
||||
## CONTRIBUTE
|
||||
|
||||
@@ -547,6 +570,8 @@ your changes merged back into core is as follows:
|
||||
1. Send a pull request to the github/gollum project.
|
||||
|
||||
## RELEASING
|
||||
x.y.z
|
||||
|
||||
For z releases:
|
||||
$ rake bump
|
||||
$ rake release
|
||||
|
||||
@@ -114,6 +114,7 @@ task :release => :build do
|
||||
exit!
|
||||
end
|
||||
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
||||
sh "git pull"
|
||||
sh "git tag v#{version}"
|
||||
sh "git push origin master"
|
||||
sh "git push origin v#{version}"
|
||||
@@ -145,7 +146,7 @@ task :gemspec => :validate do
|
||||
split("\n").
|
||||
sort.
|
||||
reject { |file| file =~ /^\./ }.
|
||||
reject { |file| file =~ /^(rdoc|pkg|test|Home\.md)/ }.
|
||||
reject { |file| file =~ /^(rdoc|pkg|test|Home\.md|\.gitattributes)/ }.
|
||||
map { |file| " #{file}" }.
|
||||
join("\n")
|
||||
|
||||
|
||||
+46
-1
@@ -45,6 +45,10 @@ opts = OptionParser.new do |opts|
|
||||
options['irb'] = true
|
||||
end
|
||||
|
||||
opts.on("--css", "Inject custom css. Uses custom.css from root repository") do
|
||||
wiki_options[:css] = true
|
||||
end
|
||||
|
||||
opts.on("--page-file-dir [PATH]", "Specify the sub directory for all page files (default: repository root).") do |path|
|
||||
wiki_options[:page_file_dir] = path
|
||||
end
|
||||
@@ -68,6 +72,21 @@ opts = OptionParser.new do |opts|
|
||||
opts.on("--mathjax", "Enables mathjax.") do
|
||||
wiki_options[:mathjax] = true
|
||||
end
|
||||
|
||||
opts.on("--user-icons [SOURCE]", "Set the history user icons. Valid values: gravatar, identicon, none. Default: none.") do |source|
|
||||
wiki_options[:user_icons] = source
|
||||
end
|
||||
|
||||
opts.on("--show-all", "Shows all files in file view. By default only valid pages are shown.") do
|
||||
wiki_options[:show_all] = true
|
||||
end
|
||||
|
||||
opts.on("--collapse-tree", "Collapse file view tree. By default, expanded tree is shown.") do
|
||||
wiki_options[:collapse_tree] = true
|
||||
end
|
||||
opts.on("--h1-title", "Sets page title to value of first h1") do
|
||||
wiki_options[:h1_title] = true
|
||||
end
|
||||
end
|
||||
|
||||
# Read command line options into `options` hash
|
||||
@@ -141,5 +160,31 @@ else
|
||||
require cfg
|
||||
end
|
||||
|
||||
Precious::App.run!(options)
|
||||
base_path = wiki_options[:base_path]
|
||||
|
||||
if wiki_options[:base_path].nil?
|
||||
Precious::App.run!(options)
|
||||
else
|
||||
require 'rack'
|
||||
|
||||
class MapGollum
|
||||
def initialize base_path
|
||||
@mg = Rack::Builder.new do
|
||||
map '/' do
|
||||
run Proc.new { [ 302, {'Location'=> "/#{base_path}" }, [] ] }
|
||||
end
|
||||
|
||||
map "/#{base_path}" do
|
||||
run Precious::App
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def call(env)
|
||||
@mg.call(env)
|
||||
end
|
||||
end
|
||||
# Rack::Handler does not work with Ctrl + C. Use Rack::Server instead.
|
||||
Rack::Server.new(:app => MapGollum.new(base_path), :Port => options['port'], :Host => options['bind']).start
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# Example gollum config
|
||||
# gollum ../wiki --config config.rb
|
||||
#
|
||||
# or run from source with
|
||||
#
|
||||
# bundle exec bin/gollum ../wiki/ --config config.rb
|
||||
|
||||
# Remove const to avoid
|
||||
# warning: already initialized constant FORMAT_NAMES
|
||||
#
|
||||
# only remove if it's defined.
|
||||
# constant Gollum::Page::FORMAT_NAMES not defined (NameError)
|
||||
Gollum::Page.send :remove_const, :FORMAT_NAMES if defined? Gollum::Page::FORMAT_NAMES
|
||||
# limit to one format
|
||||
Gollum::Page::FORMAT_NAMES = { :markdown => "Markdown" }
|
||||
|
||||
=begin
|
||||
Valid formats are:
|
||||
{ :markdown => "Markdown",
|
||||
:textile => "Textile",
|
||||
:rdoc => "RDoc",
|
||||
:org => "Org-mode",
|
||||
:creole => "Creole",
|
||||
:rest => "reStructuredText",
|
||||
:asciidoc => "AsciiDoc",
|
||||
:mediawiki => "MediaWiki",
|
||||
:pod => "Pod" }
|
||||
=end
|
||||
+21
-13
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
||||
s.required_ruby_version = ">= 1.8.7"
|
||||
|
||||
s.name = 'gollum'
|
||||
s.version = '2.2.6'
|
||||
s.date = '2012-10-14'
|
||||
s.version = '2.4.3'
|
||||
s.date = '2012-11-29'
|
||||
s.rubyforge_project = 'gollum'
|
||||
|
||||
s.summary = "A simple, Git-powered wiki."
|
||||
@@ -25,23 +25,25 @@ Gem::Specification.new do |s|
|
||||
|
||||
s.add_dependency('grit', '~> 2.5.0')
|
||||
s.add_dependency('github-markup', ['>= 0.7.4', '< 1.0.0'])
|
||||
s.add_dependency('github-markdown', '~> 0.5.1')
|
||||
s.add_dependency('pygments.rb', '~> 0.3.1')
|
||||
s.add_dependency('escape_utils', '0.2.4')
|
||||
s.add_dependency('github-markdown', '~> 0.5.3')
|
||||
s.add_dependency('pygments.rb', '~> 0.3.2')
|
||||
s.add_dependency('sinatra', '~> 1.3.3')
|
||||
s.add_dependency('mustache', ['>= 0.99.4', '< 1.0.0'])
|
||||
s.add_dependency('sanitize', '~> 2.0.3')
|
||||
s.add_dependency('nokogiri', '~> 1.5.5')
|
||||
s.add_dependency('useragent', '~> 0.4.10')
|
||||
s.add_dependency('stringex', '~> 1.4.0')
|
||||
s.add_dependency('useragent', '~> 0.4.13')
|
||||
s.add_dependency('stringex', '~> 1.5.0')
|
||||
|
||||
s.add_development_dependency('RedCloth', '~> 4.2.9')
|
||||
s.add_development_dependency('mocha', '~> 0.12.6')
|
||||
s.add_development_dependency('org-ruby', '~> 0.7.1')
|
||||
s.add_development_dependency('shoulda', '~> 3.1.1')
|
||||
s.add_development_dependency('mocha', '~> 0.13.0')
|
||||
s.add_development_dependency('org-ruby', '~> 0.7.2')
|
||||
s.add_development_dependency('shoulda', '~> 3.3.2')
|
||||
s.add_development_dependency('rack-test', '~> 0.6.2')
|
||||
s.add_development_dependency('wikicloth', '~> 0.8.0')
|
||||
s.add_development_dependency('rake', '~> 0.9.2.2')
|
||||
s.add_development_dependency('rake', '~> 10.0.2')
|
||||
s.add_development_dependency('pry', '~> 0.9.10')
|
||||
# required by pry
|
||||
s.add_development_dependency('rb-readline', '~> 0.4.2')
|
||||
|
||||
# = MANIFEST =
|
||||
s.files = %w[
|
||||
@@ -51,6 +53,7 @@ Gem::Specification.new do |s|
|
||||
README.md
|
||||
Rakefile
|
||||
bin/gollum
|
||||
config.rb
|
||||
docs/sanitization.md
|
||||
gollum.gemspec
|
||||
lib/gollum.rb
|
||||
@@ -72,6 +75,7 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/frontend/public/gollum/images/fileview/toggle-small-expand.png
|
||||
lib/gollum/frontend/public/gollum/images/fileview/toggle-small.png
|
||||
lib/gollum/frontend/public/gollum/images/icon-sprite.png
|
||||
lib/gollum/frontend/public/gollum/images/man_24.png
|
||||
lib/gollum/frontend/public/gollum/images/para.png
|
||||
lib/gollum/frontend/public/gollum/images/pin-16.png
|
||||
lib/gollum/frontend/public/gollum/images/pin-20.png
|
||||
@@ -88,11 +92,13 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/frontend/public/gollum/javascript/gollum.dialog.js
|
||||
lib/gollum/frontend/public/gollum/javascript/gollum.js
|
||||
lib/gollum/frontend/public/gollum/javascript/gollum.placeholder.js
|
||||
lib/gollum/frontend/public/gollum/javascript/identicon_canvas.js
|
||||
lib/gollum/frontend/public/gollum/javascript/jquery-1.7.2.min.js
|
||||
lib/gollum/frontend/public/gollum/javascript/jquery.color.js
|
||||
lib/gollum/frontend/public/gollum/javascript/mousetrap.min.js
|
||||
lib/gollum/frontend/public/gollum/livepreview/css/custom.css
|
||||
lib/gollum/frontend/public/gollum/livepreview/images/cancel_24.png
|
||||
lib/gollum/frontend/public/gollum/livepreview/images/globe_24.png
|
||||
lib/gollum/frontend/public/gollum/livepreview/images/lr_24.png
|
||||
lib/gollum/frontend/public/gollum/livepreview/images/save_24.png
|
||||
lib/gollum/frontend/public/gollum/livepreview/images/savecomment_24.png
|
||||
@@ -434,6 +440,9 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/frontend/templates/error.mustache
|
||||
lib/gollum/frontend/templates/file_view.mustache
|
||||
lib/gollum/frontend/templates/history.mustache
|
||||
lib/gollum/frontend/templates/history_authors/gravatar.mustache
|
||||
lib/gollum/frontend/templates/history_authors/identicon.mustache
|
||||
lib/gollum/frontend/templates/history_authors/none.mustache
|
||||
lib/gollum/frontend/templates/layout.mustache
|
||||
lib/gollum/frontend/templates/page.mustache
|
||||
lib/gollum/frontend/templates/pages.mustache
|
||||
@@ -458,7 +467,6 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/page.rb
|
||||
lib/gollum/pagination.rb
|
||||
lib/gollum/sanitization.rb
|
||||
lib/gollum/tex.rb
|
||||
lib/gollum/web_sequence_diagram.rb
|
||||
lib/gollum/wiki.rb
|
||||
licenses/css_tree_menu_thecssninja/license.txt
|
||||
@@ -470,4 +478,4 @@ Gem::Specification.new do |s|
|
||||
# = MANIFEST =
|
||||
|
||||
s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
|
||||
end
|
||||
end
|
||||
|
||||
+8
-2
@@ -1,5 +1,7 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
# stdlib
|
||||
require 'digest/md5'
|
||||
require 'digest/sha1'
|
||||
require 'ostruct'
|
||||
|
||||
# external
|
||||
@@ -18,12 +20,16 @@ require File.expand_path('../gollum/file', __FILE__)
|
||||
require File.expand_path('../gollum/file_view', __FILE__)
|
||||
require File.expand_path('../gollum/markup', __FILE__)
|
||||
require File.expand_path('../gollum/sanitization', __FILE__)
|
||||
require File.expand_path('../gollum/tex', __FILE__)
|
||||
require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
|
||||
require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
|
||||
|
||||
# Set ruby to UTF-8 mode
|
||||
# Do not remove because of warning.
|
||||
# This is required for Ruby 1.8.7 which gollum still supports.
|
||||
$KCODE = 'U'
|
||||
|
||||
module Gollum
|
||||
VERSION = '2.2.6'
|
||||
VERSION = '2.4.3'
|
||||
|
||||
def self.assets_path
|
||||
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
module Gollum
|
||||
class BlobEntry
|
||||
# Gets the String SHA for this blob.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
module Gollum
|
||||
# Responsible for handling the commit process for a Wiki. It sets up the
|
||||
# Git index, provides methods for modifying the tree, and stores callbacks
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
module Gollum
|
||||
class File
|
||||
Wiki.file_class = self
|
||||
@@ -13,6 +14,22 @@ module Gollum
|
||||
@path = nil
|
||||
end
|
||||
|
||||
# Public: The url path required to reach this page within the repo.
|
||||
#
|
||||
# Returns the String url_path
|
||||
def url_path
|
||||
path = self.path
|
||||
path = path.sub(/\/[^\/]+$/, '/') if path.include?('/')
|
||||
path
|
||||
end
|
||||
|
||||
# Public: The url_path, but CGI escaped.
|
||||
#
|
||||
# Returns the String url_path
|
||||
def escaped_url_path
|
||||
CGI.escape(self.url_path).gsub('%2F','/')
|
||||
end
|
||||
|
||||
# Public: The on-disk filename of the file.
|
||||
#
|
||||
# Returns the String name.
|
||||
|
||||
+22
-12
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
module Gollum
|
||||
=begin
|
||||
FileView requires that:
|
||||
@@ -5,8 +6,13 @@ module Gollum
|
||||
- Then all the folders are sorted and processed
|
||||
=end
|
||||
class FileView
|
||||
def initialize pages
|
||||
# common use cases:
|
||||
# set pages to wiki.pages and show_all to false
|
||||
# set pages to wiki.pages + wiki.files and show_all to true
|
||||
def initialize pages, options = {}
|
||||
@pages = pages
|
||||
@show_all = options[:show_all] || false
|
||||
@checked = options[:collapse_tree] ? '' : "checked"
|
||||
end
|
||||
|
||||
def enclose_tree string
|
||||
@@ -16,7 +22,7 @@ module Gollum
|
||||
def new_page page
|
||||
name = page.name
|
||||
url = url_for_page page
|
||||
%Q( <li class="file"><a href="#{url}">#{name}</a></li>\n)
|
||||
%Q( <li class="file"><a href="#{url}"><span class="icon"></span>#{name}</a></li>)
|
||||
end
|
||||
|
||||
def new_folder folder_path
|
||||
@@ -26,20 +32,26 @@ module Gollum
|
||||
def new_sub_folder path
|
||||
<<-HTML
|
||||
<li>
|
||||
<label>#{path}</label> <input type="checkbox" checked />
|
||||
<label>#{path}</label> <input type="checkbox" #{@checked} />
|
||||
<ol>
|
||||
HTML
|
||||
end
|
||||
|
||||
def end_folder
|
||||
<<-HTML
|
||||
</ol>
|
||||
</li>
|
||||
HTML
|
||||
"</ol></li>\n"
|
||||
end
|
||||
|
||||
def url_for_page page
|
||||
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
|
||||
url = ''
|
||||
if @show_all
|
||||
# Remove ext for valid pages.
|
||||
filename = page.filename
|
||||
filename = Page::valid_page_name?(filename) ? filename.chomp(::File.extname(filename)) : filename
|
||||
|
||||
url = ::File.join(::File.dirname(page.path), filename)
|
||||
else
|
||||
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
|
||||
end
|
||||
url = url[2..-1] if url[0,2] == './'
|
||||
url
|
||||
end
|
||||
@@ -70,13 +82,11 @@ module Gollum
|
||||
# Handle special case of only one folder.
|
||||
if (count - folder_start == 1)
|
||||
page = @pages[ folder_start ]
|
||||
name = page.name
|
||||
url = url_for_page page
|
||||
html += <<-HTML
|
||||
<li>
|
||||
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" checked />
|
||||
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" #{@checked} />
|
||||
<ol>
|
||||
<li class="file"><a href="#{url}">#{name}</a></li>
|
||||
#{new_page page}
|
||||
</ol>
|
||||
</li>
|
||||
HTML
|
||||
|
||||
+32
-20
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
require 'cgi'
|
||||
require 'sinatra'
|
||||
require 'gollum'
|
||||
@@ -17,8 +18,7 @@ class String
|
||||
# _Header => header which causes errors
|
||||
def to_url
|
||||
return nil if self.nil?
|
||||
return self if ['_Header', '_Footer', '_Sidebar'].include? self
|
||||
upstream_to_url
|
||||
upstream_to_url :exclude => ['_Header', '_Footer', '_Sidebar']
|
||||
end
|
||||
end
|
||||
|
||||
@@ -82,11 +82,13 @@ module Precious
|
||||
|
||||
before do
|
||||
@base_url = url('/', false).chomp('/')
|
||||
settings.wiki_options.merge!({ :base_path => @base_url }) unless settings.wiki_options.has_key? :base_path
|
||||
# above will detect base_path when it's used with map in a config.ru
|
||||
settings.wiki_options.merge!({ :base_path => @base_url })
|
||||
@css = settings.wiki_options[:css]
|
||||
end
|
||||
|
||||
get '/' do
|
||||
redirect File.join(settings.wiki_options[:base_path].to_s, 'Home')
|
||||
redirect ::File.join(@base_url, 'Home')
|
||||
end
|
||||
|
||||
# path is set to name if path is nil.
|
||||
@@ -145,6 +147,7 @@ module Precious
|
||||
page_name = CGI.unescape(params[:page])
|
||||
wiki = wiki_new
|
||||
page = wiki.paged(page_name, path, exact = true)
|
||||
return if page.nil?
|
||||
rename = params[:rename].to_url if params[:rename]
|
||||
name = rename || page.name
|
||||
committer = Gollum::Committer.new(wiki, commit_message)
|
||||
@@ -186,17 +189,18 @@ module Precious
|
||||
|
||||
post '/create' do
|
||||
name = params[:page].to_url
|
||||
path = sanitize_empty_params(params[:path])
|
||||
path = '' if path.nil?
|
||||
path = sanitize_empty_params(params[:path]) || ''
|
||||
format = params[:format].intern
|
||||
|
||||
# write_page is not directory aware so use wiki_options to emulate dir support.
|
||||
wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
|
||||
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
||||
# ensure pages are created in page_file_dir
|
||||
page_dir = settings.wiki_options[:page_file_dir].to_s
|
||||
path = clean_url(::File.join(page_dir, path)) unless path.start_with?(page_dir)
|
||||
|
||||
wiki = wiki_new
|
||||
|
||||
begin
|
||||
wiki.write_page(name, format, params[:content], commit_message)
|
||||
redirect to("/#{clean_url(CGI.escape(::File.join(path,name)))}")
|
||||
wiki.write_page(name, format, params[:content], commit_message, path)
|
||||
redirect to("/#{clean_url(::File.join(path,name))}")
|
||||
rescue Gollum::DuplicatePageError => e
|
||||
@message = "Duplicate page: #{e.message}"
|
||||
mustache :error
|
||||
@@ -232,6 +236,7 @@ module Precious
|
||||
@content = @page.formatted_data
|
||||
@toc_content = wiki.universal_toc ? @page.toc_data : nil
|
||||
@mathjax = wiki.mathjax
|
||||
@h1_title = wiki.h1_title
|
||||
@editable = false
|
||||
mustache :page
|
||||
end
|
||||
@@ -276,10 +281,6 @@ module Precious
|
||||
mustache :compare
|
||||
end
|
||||
|
||||
get %r{^/(javascript|css|images)} do
|
||||
halt 404
|
||||
end
|
||||
|
||||
get %r{/(.+?)/([0-9a-f]{40})} do
|
||||
file_path = params[:captures][0]
|
||||
version = params[:captures][1]
|
||||
@@ -300,7 +301,8 @@ module Precious
|
||||
get '/search' do
|
||||
@query = params[:q]
|
||||
wiki = wiki_new
|
||||
@results = wiki.search @query
|
||||
# Sort wiki search results by count (desc) and then by name (asc)
|
||||
@results = wiki.search(@query).sort{ |a, b| (a[:count] <=> b[:count]).nonzero? || b[:name] <=> a[:name] }.reverse
|
||||
@name = @query
|
||||
mustache :search
|
||||
end
|
||||
@@ -315,13 +317,21 @@ module Precious
|
||||
wiki_options = settings.wiki_options.merge({ :page_file_dir => @path })
|
||||
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
||||
@results = wiki.pages
|
||||
@results += wiki.files if settings.wiki_options[:show_all]
|
||||
@ref = wiki.ref
|
||||
mustache :pages
|
||||
end
|
||||
|
||||
get '/fileview' do
|
||||
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
|
||||
@results = Gollum::FileView.new(wiki.pages).render_files
|
||||
wiki = wiki_new
|
||||
options = settings.wiki_options
|
||||
content = wiki.pages
|
||||
# if showing all files include wiki.files
|
||||
content += wiki.files if options[:show_all]
|
||||
|
||||
# must pass wiki_options to FileView
|
||||
# --show-all and --collapse-tree can be set.
|
||||
@results = Gollum::FileView.new(content, options).render_files
|
||||
@ref = wiki.ref
|
||||
mustache :file_view, { :layout => false }
|
||||
end
|
||||
@@ -332,10 +342,11 @@ module Precious
|
||||
|
||||
def show_page_or_file(fullpath)
|
||||
name = extract_name(fullpath)
|
||||
path = extract_path(fullpath)
|
||||
path = extract_path(fullpath) || '/'
|
||||
wiki = wiki_new
|
||||
|
||||
path = '/' if path.nil?
|
||||
page_dir = settings.wiki_options[:page_file_dir].to_s
|
||||
path = ::File.join(page_dir, path) unless path.start_with?(page_dir)
|
||||
|
||||
if page = wiki.paged(name, path, exact = true)
|
||||
@page = page
|
||||
@@ -344,6 +355,7 @@ module Precious
|
||||
@content = page.formatted_data
|
||||
@toc_content = wiki.universal_toc ? @page.toc_data : nil
|
||||
@mathjax = wiki.mathjax
|
||||
@h1_title = wiki.h1_title
|
||||
mustache :page
|
||||
elsif file = wiki.file(fullpath)
|
||||
content_type file.mime_type
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
module Precious
|
||||
module Helpers
|
||||
# Extract the path string that Gollum::Wiki expects
|
||||
@@ -19,9 +20,10 @@ module Precious
|
||||
end
|
||||
|
||||
# Remove all slashes from the start of string.
|
||||
# Remove all double slashes
|
||||
def clean_url url
|
||||
return url if url.nil?
|
||||
url.gsub('%2F','/').gsub(/^\/+/,'')
|
||||
url.gsub('%2F','/').gsub(/^\/+/,'').gsub('//','/')
|
||||
end
|
||||
|
||||
def trim_leading_slash url
|
||||
|
||||
@@ -1,121 +1,128 @@
|
||||
*, html {
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
#results a:hover {
|
||||
background-color: #4c4c4c;
|
||||
}
|
||||
|
||||
#home_button {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 50%;
|
||||
}
|
||||
|
||||
#home_button .minibutton {
|
||||
font-size: 1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#results {
|
||||
position: absolute;
|
||||
top: 60px;
|
||||
left: 10px;
|
||||
}
|
||||
|
||||
body, form, ul, li, p, h1, h2, h3, h4, h5 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #606061;
|
||||
color: #ffffff;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
img {
|
||||
border: none;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1em;
|
||||
margin: 0 0 1em 0;
|
||||
}
|
||||
|
||||
html { font-size: 100%; /* IE hack */ }
|
||||
body { font-size: 1em; /* Sets base font size to 16px */ }
|
||||
table { font-size: 100%; /* IE hack */ }
|
||||
input, select, textarea, th, td { font-size: 1em; }
|
||||
|
||||
/* Prevent wrapping on large file names. */
|
||||
li.file {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* CSS Tree menu styles */
|
||||
ol.tree
|
||||
{
|
||||
padding: 0 0 0 30px;
|
||||
width: 300px;
|
||||
}
|
||||
li
|
||||
{
|
||||
position: relative;
|
||||
margin-left: -15px;
|
||||
list-style: none;
|
||||
}
|
||||
li.file
|
||||
{
|
||||
margin-left: -1px !important;
|
||||
height: 1.5em;
|
||||
}
|
||||
li.file a
|
||||
{
|
||||
background: url(../images/fileview/document.png) 0 0 no-repeat;
|
||||
color: #fff;
|
||||
padding-left: 21px;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
}
|
||||
li.file a[href *= '.pdf'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
|
||||
li.file a[href *= '.html'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
|
||||
li.file a[href $= '.css'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
|
||||
li.file a[href $= '.js'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
|
||||
li input
|
||||
{
|
||||
position: absolute;
|
||||
left: 0;
|
||||
margin-left: 0;
|
||||
opacity: 0;
|
||||
z-index: 2;
|
||||
cursor: pointer;
|
||||
height: 1em;
|
||||
width: 1em;
|
||||
top: 0;
|
||||
}
|
||||
li input + ol
|
||||
{
|
||||
background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat;
|
||||
margin: -1.188em 0 0 -44px; /* 15px */
|
||||
height: 1.5em;
|
||||
}
|
||||
li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; }
|
||||
li label
|
||||
{
|
||||
background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
padding-left: 37px;
|
||||
}
|
||||
|
||||
li input:checked + ol
|
||||
{
|
||||
background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat;
|
||||
margin: -1.5em 0 0 -44px; /* 20px */
|
||||
padding: 1.563em 0 0 80px;
|
||||
height: auto;
|
||||
}
|
||||
li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */}
|
||||
li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ }
|
||||
|
||||
*, html {
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
#results a:hover {
|
||||
background-color: #4c4c4c;
|
||||
}
|
||||
|
||||
#home_button {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 50%;
|
||||
}
|
||||
|
||||
#home_button .minibutton {
|
||||
font-size: 1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#results {
|
||||
position: absolute;
|
||||
top: 60px;
|
||||
left: 10px;
|
||||
}
|
||||
|
||||
body, form, ul, li, p, h1, h2, h3, h4, h5 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #606061;
|
||||
color: #ffffff;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
img {
|
||||
border: none;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1em;
|
||||
margin: 0 0 1em 0;
|
||||
}
|
||||
|
||||
html { font-size: 100%; /* IE hack */ }
|
||||
body { font-size: 1em; /* Sets base font size to 16px */ }
|
||||
table { font-size: 100%; /* IE hack */ }
|
||||
input, select, textarea, th, td { font-size: 1em; }
|
||||
|
||||
/* Prevent wrapping on large file names. */
|
||||
li.file {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* CSS Tree menu styles */
|
||||
ol.tree
|
||||
{
|
||||
padding: 0 0 0 30px;
|
||||
width: 300px;
|
||||
}
|
||||
li
|
||||
{
|
||||
position: relative;
|
||||
margin-left: -15px;
|
||||
list-style: none;
|
||||
}
|
||||
li.file
|
||||
{
|
||||
margin-left: -1px !important;
|
||||
height: 1.5em;
|
||||
}
|
||||
li.file a
|
||||
{
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
}
|
||||
li.file a span.icon
|
||||
{
|
||||
width: 14px;
|
||||
height: 18px;
|
||||
background: url(../images/fileview/document.png) 0 0 no-repeat;
|
||||
display: inline-block;
|
||||
margin-right: 7px;
|
||||
vertical-align: text-top;
|
||||
}
|
||||
li.file a[href *= '.pdf'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
|
||||
li.file a[href *= '.html'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
|
||||
li.file a[href $= '.css'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
|
||||
li.file a[href $= '.js'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
|
||||
li input
|
||||
{
|
||||
position: absolute;
|
||||
left: 0;
|
||||
margin-left: 0;
|
||||
opacity: 0;
|
||||
z-index: 2;
|
||||
cursor: pointer;
|
||||
height: 1em;
|
||||
width: 1em;
|
||||
top: 0;
|
||||
}
|
||||
li input + ol
|
||||
{
|
||||
background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat;
|
||||
margin: -1.188em 0 0 -44px; /* 15px */
|
||||
height: 1.5em;
|
||||
}
|
||||
li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; }
|
||||
li label
|
||||
{
|
||||
background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
padding-left: 37px;
|
||||
}
|
||||
|
||||
li input:checked + ol
|
||||
{
|
||||
background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat;
|
||||
margin: -1.5em 0 0 -44px; /* 20px */
|
||||
padding: 1.563em 0 0 80px;
|
||||
height: auto;
|
||||
}
|
||||
li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */}
|
||||
li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ }
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 376 B |
@@ -233,6 +233,7 @@
|
||||
$('#gollum-dialog-dialog').animate({ opacity: 1 }, {
|
||||
duration: 500
|
||||
});
|
||||
$($('#gollum-dialog-dialog input[type="text"]').get(0)).focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -212,4 +212,37 @@ $(document).ready(function() {
|
||||
$('#gollum-revert-form').submit();
|
||||
});
|
||||
}
|
||||
|
||||
if( $('#wiki-wrapper.edit').length ){
|
||||
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
|
||||
$("#gollum-editor-body").one('change', function(){
|
||||
window.onbeforeunload = function(){ return "Leaving will discard all edits!" };
|
||||
});
|
||||
$.GollumEditor();
|
||||
}
|
||||
|
||||
if( $('#wiki-wrapper.create').length ){
|
||||
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
|
||||
$("#gollum-editor-body").one('change', function(){
|
||||
window.onbeforeunload = function(){ return "Leaving will not create a new page!" };
|
||||
});
|
||||
$.GollumEditor({ NewFile: true, MarkupType: default_markup });
|
||||
}
|
||||
|
||||
if( $('#wiki-history').length ){
|
||||
var lookup = {};
|
||||
$('img.identicon').each(function(index, element){
|
||||
var $item = $(element);
|
||||
var code = parseInt($item.data('identicon'), 10);
|
||||
var img_bin = lookup[code];
|
||||
if( img_bin === undefined ){
|
||||
var size = 16;
|
||||
var canvas = $('<canvas width=16 height=16/>').get(0);
|
||||
render_identicon(canvas, code, 16);
|
||||
img_bin = canvas.toDataURL("image/png");
|
||||
lookup[code] = img_bin;
|
||||
}
|
||||
$item.attr('src', img_bin);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
Client-side Canvas tag based Identicon rendering code
|
||||
|
||||
@author Don Park
|
||||
@version 0.2
|
||||
@date January 21th, 2007
|
||||
*/
|
||||
|
||||
var patch0 = new Array( 0, 4, 24, 20 );
|
||||
var patch1 = new Array( 0, 4, 20 );
|
||||
var patch2 = new Array( 2, 24, 20 );
|
||||
var patch3 = new Array( 0, 2, 20, 22 );
|
||||
var patch4 = new Array( 2, 14, 22, 10 );
|
||||
var patch5 = new Array( 0, 14, 24, 22 );
|
||||
var patch6 = new Array( 2, 24, 22, 13, 11, 22, 20 );
|
||||
var patch7 = new Array( 0, 14, 22 );
|
||||
var patch8 = new Array( 6, 8, 18, 16 );
|
||||
var patch9 = new Array( 4, 20, 10, 12, 2 );
|
||||
var patch10 = new Array( 0, 2, 12, 10 );
|
||||
var patch11 = new Array( 10, 14, 22 );
|
||||
var patch12 = new Array( 20, 12, 24 );
|
||||
var patch13 = new Array( 10, 2, 12 );
|
||||
var patch14 = new Array( 0, 2, 10 );
|
||||
var patchTypes = new Array( patch0, patch1, patch2, patch3, patch4,
|
||||
patch5, patch6, patch7, patch8, patch9, patch10, patch11,
|
||||
patch12, patch13, patch14, patch0 );
|
||||
var centerPatchTypes = new Array(0, 4, 8, 15);
|
||||
|
||||
function render_identicon_patch(ctx, x, y, size, patch, turn, invert, foreColor, backColor) {
|
||||
patch %= patchTypes.length;
|
||||
turn %= 4;
|
||||
if (patch == 15)
|
||||
invert = !invert;
|
||||
|
||||
var vertices = patchTypes[patch];
|
||||
var offset = size / 2;
|
||||
var scale = size / 4;
|
||||
|
||||
ctx.save();
|
||||
|
||||
// paint background
|
||||
ctx.fillStyle = invert ? foreColor : backColor;
|
||||
ctx.fillRect(x, y, size, size);
|
||||
|
||||
// build patch path
|
||||
ctx.translate(x + offset, y + offset);
|
||||
ctx.rotate(turn * Math.PI / 2);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo((vertices[0] % 5 * scale - offset), (Math.floor(vertices[0] / 5) * scale - offset));
|
||||
for (var i = 1; i < vertices.length; i++)
|
||||
ctx.lineTo((vertices[i] % 5 * scale - offset), (Math.floor(vertices[i] / 5) * scale - offset));
|
||||
ctx.closePath();
|
||||
|
||||
// offset and rotate coordinate space by patch position (x, y) and
|
||||
// 'turn' before rendering patch shape
|
||||
|
||||
// render rotated patch using fore color (back color if inverted)
|
||||
ctx.fillStyle = invert ? backColor : foreColor;
|
||||
ctx.fill();
|
||||
|
||||
// restore rotation
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
function render_identicon(node, code, size) {
|
||||
if (!node || !code || !size) return;
|
||||
|
||||
var patchSize = size / 3;
|
||||
var middleType = centerPatchTypes[code & 3];
|
||||
var middleInvert = ((code >> 2) & 1) != 0;
|
||||
var cornerType = (code >> 3) & 15;
|
||||
var cornerInvert = ((code >> 7) & 1) != 0;
|
||||
var cornerTurn = (code >> 8) & 3;
|
||||
var sideType = (code >> 10) & 15;
|
||||
var sideInvert = ((code >> 14) & 1) != 0;
|
||||
var sideTurn = (code >> 15) & 3;
|
||||
var blue = (code >> 16) & 31;
|
||||
var green = (code >> 21) & 31;
|
||||
var red = (code >> 27) & 31;
|
||||
var foreColor = "rgb(" + (red << 3) + "," + (green << 3) + "," + (blue << 3) + ")";
|
||||
var backColor = "rgb(255,255,255)";
|
||||
|
||||
var ctx = node.getContext("2d");
|
||||
|
||||
// middle patch
|
||||
render_identicon_patch(ctx, patchSize, patchSize, patchSize, middleType, 0, middleInvert, foreColor, backColor);
|
||||
// side patchs, starting from top and moving clock-wise
|
||||
render_identicon_patch(ctx, patchSize, 0, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
|
||||
render_identicon_patch(ctx, patchSize * 2, patchSize, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
|
||||
render_identicon_patch(ctx, patchSize, patchSize * 2, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
|
||||
render_identicon_patch(ctx, 0, patchSize, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
|
||||
// corner patchs, starting from top left and moving clock-wise
|
||||
render_identicon_patch(ctx, 0, 0, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
|
||||
render_identicon_patch(ctx, patchSize * 2, 0, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
|
||||
render_identicon_patch(ctx, patchSize * 2, patchSize * 2, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
|
||||
render_identicon_patch(ctx, 0, patchSize * 2, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
|
||||
}
|
||||
|
||||
function render_identicon_canvases(prefix) {
|
||||
var canvases = document.getElementsByTagName("canvas");
|
||||
var n = canvases.length;
|
||||
for (var i = 0; i < n; i++) {
|
||||
var node = canvases[i];
|
||||
if (node.title && node.title.indexOf(prefix) == 0) {
|
||||
if (node.style.display == 'none') node.style.display = "inline";
|
||||
var code = node.title.substring(prefix.length) * 1;
|
||||
var size = node.width;
|
||||
render_identicon(node, code, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 630 B |
@@ -11,6 +11,7 @@
|
||||
<div id='previewframe'><div id='contentframe' class='markdown-body'></div></div>
|
||||
<!-- tool panel from notepage.es. save & savecomment icons from Retina Display Icon Set. -->
|
||||
<div id='toolpanel' class='toolpanel edit' style='width: 500px; right: 0px; visibility: hidden;'>
|
||||
<a id='preview' class='edit'><img src='images/globe_24.png' alt='Preview' title='Preview'></a>
|
||||
<a id='save' class='edit'><img src='images/save_24.png' alt='Save' title='Save'></a>
|
||||
<a id='savecomment' class='edit'><img src='images/savecomment_24.png' alt='Save with comment' title='Save with comment'></a>
|
||||
<a id='toggle' class='edit' href='javascript:void(0)' onclick='jsm.toggleLeftRight();'><img src='images/lr_24.png' alt='Toggle left to right' title='Toggle left to right'></a>
|
||||
|
||||
@@ -1,58 +1,58 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var HighlightRules = require("./diff_highlight_rules").DiffHighlightRules;
|
||||
var FoldMode = require("./folding/diff").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new HighlightRules().getRules(), "i");
|
||||
this.foldingRules = new FoldMode(["diff", "index", "\\+{3}", "@@|\\*{5}"], "i");
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
||||
});
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var HighlightRules = require("./diff_highlight_rules").DiffHighlightRules;
|
||||
var FoldMode = require("./folding/diff").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new HighlightRules().getRules(), "i");
|
||||
this.foldingRules = new FoldMode(["diff", "index", "\\+{3}", "@@|\\*{5}"], "i");
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
||||
});
|
||||
|
||||
+108
-108
@@ -1,108 +1,108 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var DiffHighlightRules = function() {
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this.$rules = {
|
||||
"start" : [{
|
||||
"regex": "^(?:\\*{15}|={67}|-{3}|\\+{3})$",
|
||||
"token": "punctuation.definition.separator.diff",
|
||||
"name": "keyword"
|
||||
}, { //diff.range.unified
|
||||
"regex": "^(@@)(\\s*.+?\\s*)(@@)(.*)$",
|
||||
"token": [
|
||||
"constant",
|
||||
"constant.numeric",
|
||||
"constant",
|
||||
"comment.doc.tag"
|
||||
]
|
||||
}, { //diff.range.normal
|
||||
"regex": "^(\\d+)([,\\d]+)(a|d|c)(\\d+)([,\\d]+)(.*)$",
|
||||
"token": [
|
||||
"constant.numeric",
|
||||
"punctuation.definition.range.diff",
|
||||
"constant.function",
|
||||
"constant.numeric",
|
||||
"punctuation.definition.range.diff",
|
||||
"invalid"
|
||||
],
|
||||
"name": "meta."
|
||||
}, {
|
||||
"regex": "^(?:(\\-{3}|\\+{3}|\\*{3})( .+))$",
|
||||
"token": [
|
||||
"constant.numeric",
|
||||
"meta.tag"
|
||||
]
|
||||
}, { // added
|
||||
"regex": "^([!+>])(.*?)(\\s*)$",
|
||||
"token": [
|
||||
"support.constant",
|
||||
"text",
|
||||
"invalid"
|
||||
],
|
||||
}, { // removed
|
||||
"regex": "^([<\\-])(.*?)(\\s*)$",
|
||||
"token": [
|
||||
"support.function",
|
||||
"string",
|
||||
"invalid"
|
||||
],
|
||||
}, {
|
||||
"regex": "^(diff)(\\s+--\\w+)?(.+?)( .+)?$",
|
||||
"token": ["variable", "variable", "keyword", "variable"]
|
||||
}, {
|
||||
"regex": "^Index.+$",
|
||||
"token": "variable"
|
||||
}, {
|
||||
"regex": "^(.*?)(\\s*)$",
|
||||
"token": ["invisible", "invalid"]
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(DiffHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.DiffHighlightRules = DiffHighlightRules;
|
||||
});
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var DiffHighlightRules = function() {
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this.$rules = {
|
||||
"start" : [{
|
||||
"regex": "^(?:\\*{15}|={67}|-{3}|\\+{3})$",
|
||||
"token": "punctuation.definition.separator.diff",
|
||||
"name": "keyword"
|
||||
}, { //diff.range.unified
|
||||
"regex": "^(@@)(\\s*.+?\\s*)(@@)(.*)$",
|
||||
"token": [
|
||||
"constant",
|
||||
"constant.numeric",
|
||||
"constant",
|
||||
"comment.doc.tag"
|
||||
]
|
||||
}, { //diff.range.normal
|
||||
"regex": "^(\\d+)([,\\d]+)(a|d|c)(\\d+)([,\\d]+)(.*)$",
|
||||
"token": [
|
||||
"constant.numeric",
|
||||
"punctuation.definition.range.diff",
|
||||
"constant.function",
|
||||
"constant.numeric",
|
||||
"punctuation.definition.range.diff",
|
||||
"invalid"
|
||||
],
|
||||
"name": "meta."
|
||||
}, {
|
||||
"regex": "^(?:(\\-{3}|\\+{3}|\\*{3})( .+))$",
|
||||
"token": [
|
||||
"constant.numeric",
|
||||
"meta.tag"
|
||||
]
|
||||
}, { // added
|
||||
"regex": "^([!+>])(.*?)(\\s*)$",
|
||||
"token": [
|
||||
"support.constant",
|
||||
"text",
|
||||
"invalid"
|
||||
],
|
||||
}, { // removed
|
||||
"regex": "^([<\\-])(.*?)(\\s*)$",
|
||||
"token": [
|
||||
"support.function",
|
||||
"string",
|
||||
"invalid"
|
||||
],
|
||||
}, {
|
||||
"regex": "^(diff)(\\s+--\\w+)?(.+?)( .+)?$",
|
||||
"token": ["variable", "variable", "keyword", "variable"]
|
||||
}, {
|
||||
"regex": "^Index.+$",
|
||||
"token": "variable"
|
||||
}, {
|
||||
"regex": "^(.*?)(\\s*)$",
|
||||
"token": ["invisible", "invalid"]
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(DiffHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.DiffHighlightRules = DiffHighlightRules;
|
||||
});
|
||||
|
||||
@@ -87,6 +87,18 @@ defaultCommitMessage = function() {
|
||||
// Set comment using the default commit message.
|
||||
commentEditorSession.setValue( defaultCommitMessage() );
|
||||
|
||||
$.preview = function( previewWindow ) {
|
||||
jQuery.ajax( {
|
||||
type: 'POST',
|
||||
url: baseUrl + '/preview',
|
||||
data: { page: 'Preview: ' + pageName, format: 'markdown', content: editorSession.getValue() },
|
||||
success: function( html ) {
|
||||
previewWindow.document.write( html );
|
||||
previewWindow.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$.save = function( commitMessage ) {
|
||||
win.onbeforeunload = null;
|
||||
|
||||
@@ -96,8 +108,9 @@ $.save = function( commitMessage ) {
|
||||
var msg = defaultCommitMessage();
|
||||
var newLocation = baseUrl;
|
||||
|
||||
// Remove all duplicate slashes
|
||||
function clean( str ) {
|
||||
return str.replace(/^\/+/, '/');
|
||||
return str.replace(/\/+/g, '/');
|
||||
}
|
||||
|
||||
// 'a%2Fb' => a/b
|
||||
@@ -285,6 +298,8 @@ var makePreviewHtml = function () {
|
||||
}
|
||||
|
||||
var prevTime = new Date().getTime();
|
||||
// Handle gollum file code insertion syntax.
|
||||
text = text.replace(/^[ \t]*``` ?([^:\n\r]+:[^`\n\r]+)```/gm, '``$1``');
|
||||
text = md_to_html( text );
|
||||
|
||||
// Calculate the processing time of the HTML creation.
|
||||
@@ -377,8 +392,16 @@ var applyTimeout = function () {
|
||||
});
|
||||
}
|
||||
|
||||
$( '#preview' ).click( function() {
|
||||
$(this).target = "_blank";
|
||||
// pass window into preview
|
||||
$.preview( window.open() );
|
||||
return false;
|
||||
});
|
||||
|
||||
$( '#save' ).click( function() {
|
||||
$.save();
|
||||
return false;
|
||||
});
|
||||
|
||||
// Hide dimmer, comment tool panel, and comment.
|
||||
|
||||
@@ -15,7 +15,10 @@ CC BY-SA 3.0 Unported
|
||||
http://blog.twg.ca/2010/11/retina-display-icon-set/
|
||||
http://creativecommons.org/licenses/by-sa/3.0/legalcode.txt
|
||||
|
||||
lib/gollum/frontend/public/images/savecomment_24.png
|
||||
lib/gollum/frontend/public/images/cancel_24.png
|
||||
lib/gollum/frontend/public/images/save_24.png
|
||||
lib/gollum/frontend/public/images/globe_24.png
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div id="wiki-wrapper">
|
||||
<div id="wiki-wrapper" class="create">
|
||||
<div id="head">
|
||||
<h1>Create New Page</h1>
|
||||
</div>
|
||||
@@ -9,12 +9,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
window.onbeforeunload = function(){ return "Leaving will not create a new page!" };
|
||||
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
$.GollumEditor({ NewFile: true, MarkupType: '{{default_markup}}' });
|
||||
});
|
||||
var default_markup = '{{default_markup}}';
|
||||
</script>
|
||||
|
||||
{{something}}
|
||||
|
||||
@@ -10,11 +10,3 @@
|
||||
</div>
|
||||
<div id="wiki-content">{{>editor}}</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
window.onbeforeunload = function(){ return "Leaving will discard all edits!" };
|
||||
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
$.GollumEditor();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/gollum.css" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/template.css" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/_styles.css" media="all">
|
||||
{{#css}}<link rel="stylesheet" type="text/css" href="{{base_url}}/custom.css" media="all">{{/css}}
|
||||
<title>{{title}}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -30,11 +30,7 @@
|
||||
<input type="checkbox" name="versions[]" value="{{id}}">
|
||||
</td>
|
||||
<td class="author">
|
||||
<a href="javascript:void(0)">
|
||||
<img src="https://secure.gravatar.com/avatar/{{gravatar}}?s=16"
|
||||
alt="avatar: {{author}}" class="mini-gravatar">
|
||||
<span class="username">{{author}}</span>
|
||||
</a>
|
||||
{{>author_template}}
|
||||
</td>
|
||||
<td class="commit-name">
|
||||
<span class="time-elapsed">{{date}}:</span>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<a href="javascript:void(0)">
|
||||
<img src="https://secure.gravatar.com/avatar/{{gravatar}}?s=16"
|
||||
alt="avatar: {{author}}" class="mini-gravatar"/>
|
||||
<span class="username">{{author}}</span>
|
||||
</a>
|
||||
@@ -0,0 +1,5 @@
|
||||
<a href="javascript:void(0)">
|
||||
<img src="{{base_url}}/images/man_24.png" alt="avatar: {{author}}"
|
||||
class="mini-gravatar identicon" data-identicon="{{identicon}}"/>
|
||||
<span class="username">{{author}}</span>
|
||||
</a>
|
||||
@@ -0,0 +1,3 @@
|
||||
<a href="javascript:void(0)">
|
||||
<span class="username">{{author}}</span>
|
||||
</a>
|
||||
@@ -6,6 +6,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/editor.css" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/dialog.css" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/template.css" media="all">
|
||||
{{#css}}<link rel="stylesheet" type="text/css" href="{{base_url}}/custom.css" media="all">{{/css}}
|
||||
|
||||
<!--[if IE 7]>
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/ie7.css" media="all">
|
||||
@@ -18,7 +19,20 @@
|
||||
<script type="text/javascript" src="{{base_url}}/javascript/gollum.dialog.js"></script>
|
||||
<script type="text/javascript" src="{{base_url}}/javascript/gollum.placeholder.js"></script>
|
||||
<script type="text/javascript" src="{{base_url}}/javascript/editor/gollum.editor.js"></script>
|
||||
{{#mathjax}}<script>(function(d,j){
|
||||
{{#use_identicon}}
|
||||
<script type="text/javascript" src="{{base_url}}/javascript/identicon_canvas.js"></script>
|
||||
{{/use_identicon}}
|
||||
{{#mathjax}}
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
tex2jax: {
|
||||
inlineMath: [ ['$','$'], ['\\(','\\)']],
|
||||
displayMath: [ ['$$','$$'], ['\[','\]'] ],
|
||||
processEscapes: true
|
||||
},
|
||||
TeX: { extensions: ["autoload-all.js"] }});
|
||||
</script>
|
||||
<script>(function(d,j){
|
||||
j = d.createElement('script');
|
||||
j.src = 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
|
||||
(d.head || d.getElementsByTagName('head')[0]).appendChild(j);
|
||||
|
||||
@@ -7,7 +7,7 @@ Mousetrap.bind(['e'], function( e ) {
|
||||
</script>
|
||||
<div id="wiki-wrapper" class="page">
|
||||
<div id="head">
|
||||
<h1>{{title}}</h1>
|
||||
<h1>{{page_header}}</h1>
|
||||
<ul class="actions">
|
||||
<li class="minibutton">
|
||||
{{>searchbar}}
|
||||
|
||||
@@ -19,8 +19,47 @@ module Precious
|
||||
:selected => @page.version.id == v.id,
|
||||
:author => v.author.name.respond_to?(:force_encoding) ? v.author.name.force_encoding('UTF-8') : v.author.name,
|
||||
:message => v.message.respond_to?(:force_encoding) ? v.message.force_encoding('UTF-8') : v.message,
|
||||
:date => v.committed_date.strftime("%B %d, %Y"),
|
||||
:gravatar => Digest::MD5.hexdigest(v.author.email) }
|
||||
:date => v.authored_date.strftime("%B %d, %Y"),
|
||||
:gravatar => Digest::MD5.hexdigest(v.author.email),
|
||||
:identicon => self._identicon_code(v.author.email),
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# http://stackoverflow.com/questions/9445760/bit-shifting-in-ruby
|
||||
def left_shift int, shift
|
||||
r = ((int & 0xFF) << (shift & 0x1F)) & 0xFFFFFFFF
|
||||
# 1>>31, 2**32
|
||||
(r & 2147483648) == 0 ? r : r - 4294967296
|
||||
end
|
||||
|
||||
def string_to_code string
|
||||
# sha bytes
|
||||
b = [Digest::SHA1.hexdigest(string)[0,20]].pack('H*').bytes.to_a
|
||||
# Thanks donpark's IdenticonUtil.java for this.
|
||||
# Match the following Java code
|
||||
# ((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16) |
|
||||
# ((b[2] & 0xFF) << 8) | (b[3] & 0xFF)
|
||||
|
||||
return left_shift(b[0], 24) |
|
||||
left_shift(b[1], 16) |
|
||||
left_shift(b[2], 8) |
|
||||
b[3] & 0xFF
|
||||
end
|
||||
|
||||
def _identicon_code(blob)
|
||||
string_to_code blob + @request.host
|
||||
end
|
||||
|
||||
def use_identicon
|
||||
@page.wiki.user_icons == 'identicon'
|
||||
end
|
||||
|
||||
def partial(name)
|
||||
if name == :author_template
|
||||
self.class.partial("history_authors/#{@page.wiki.user_icons}")
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@ module Precious
|
||||
def base_url
|
||||
@base_url
|
||||
end
|
||||
|
||||
def css # custom css
|
||||
@css
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,16 @@ module Precious
|
||||
DEFAULT_AUTHOR = 'you'
|
||||
|
||||
def title
|
||||
@page.url_path.gsub("-", " ")
|
||||
h1 = @h1_title ? page_header_from_content(@content) : false
|
||||
h1 || @page.url_path_title
|
||||
end
|
||||
|
||||
def page_header
|
||||
page_header_from_content(@content) || title
|
||||
end
|
||||
|
||||
def content
|
||||
content_without_page_header(@content)
|
||||
end
|
||||
|
||||
def author
|
||||
@@ -80,6 +89,10 @@ module Precious
|
||||
@mathjax
|
||||
end
|
||||
|
||||
def use_identicon
|
||||
@page.wiki.user_icons == 'identicon'
|
||||
end
|
||||
|
||||
# Access to embedded metadata.
|
||||
#
|
||||
# Examples
|
||||
@@ -90,6 +103,49 @@ module Precious
|
||||
def metadata
|
||||
@page.metadata
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Wraps page formatted data to Nokogiri::HTML document.
|
||||
#
|
||||
def build_document(content)
|
||||
Nokogiri::HTML::fragment(%{<div id="gollum-root">} + content.to_s + %{</div>}, 'UTF-8')
|
||||
end
|
||||
|
||||
# Finds header node inside Nokogiri::HTML document.
|
||||
#
|
||||
def find_header_node(doc)
|
||||
case self.format
|
||||
when :asciidoc
|
||||
doc.css("div#gollum-root > div#header > h1:first-child")
|
||||
when :org
|
||||
doc.css("div#gollum-root > p.title:first-child")
|
||||
when :pod
|
||||
doc.css("div#gollum-root > a.dummyTopAnchor:first-child + h1")
|
||||
when :rest
|
||||
doc.css("div#gollum-root > div > div > h1:first-child")
|
||||
else
|
||||
doc.css("div#gollum-root > h1:first-child")
|
||||
end
|
||||
end
|
||||
|
||||
# Extracts title from page if present.
|
||||
#
|
||||
def page_header_from_content(content)
|
||||
doc = build_document(content)
|
||||
title = find_header_node(doc)
|
||||
Sanitize.clean(title.to_xhtml(:encoding => 'UTF-8')).strip unless title.empty?
|
||||
end
|
||||
|
||||
# Returns page content without title if it was extracted.
|
||||
#
|
||||
def content_without_page_header(content)
|
||||
doc = build_document(content)
|
||||
title = find_header_node(doc)
|
||||
title.remove unless title.empty?
|
||||
# .inner_html will cause href escaping on UTF-8
|
||||
doc.css("div#gollum-root").children.to_xhtml(:encoding => 'UTF-8')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
module Gollum
|
||||
# Controls all access to the Git objects from Gollum. Extend this class to
|
||||
# add custom caching for special cases.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
require 'net/http'
|
||||
require 'net/https' # ruby 1.8.7 fix, remove at upgrade
|
||||
require 'uri'
|
||||
|
||||
+35
-59
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
require 'digest/sha1'
|
||||
require 'cgi'
|
||||
require 'pygments'
|
||||
@@ -33,11 +34,11 @@ module Gollum
|
||||
@dir = ::File.dirname(page.path)
|
||||
@tagmap = {}
|
||||
@codemap = {}
|
||||
@texmap = {}
|
||||
@wsdmap = {}
|
||||
@premap = {}
|
||||
@toc = nil
|
||||
@metadata = nil
|
||||
@to_xml = { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML ^ 1, :indent => 0, :encoding => 'UTF-8' }
|
||||
end
|
||||
|
||||
# Render the content with Gollum wiki syntax on top of the file's own
|
||||
@@ -57,7 +58,6 @@ module Gollum
|
||||
data = extract_metadata(data)
|
||||
data = extract_gitcode(data)
|
||||
data = extract_code(data)
|
||||
data = extract_tex(data)
|
||||
data = extract_wsd(data)
|
||||
data = extract_tags(data)
|
||||
begin
|
||||
@@ -76,14 +76,18 @@ module Gollum
|
||||
doc,toc = process_headers(doc)
|
||||
@toc = @sub_page ? ( @parent_page ? @parent_page.toc_data : "[[_TOC_]]" ) : toc
|
||||
yield doc if block_given?
|
||||
data = doc.to_xhtml
|
||||
# nokogiri's save options are ored together. FORMAT has a value of 1 so ^ 1 removes it.
|
||||
# formatting will create extra spaces in pre tags.
|
||||
# https://github.com/sparklemotion/nokogiri/issues/782
|
||||
# DEFAULT_HTML encodes unicode so XHTML is used for proper unicode support in href.
|
||||
data = doc.to_xml( @to_xml )
|
||||
|
||||
data = process_toc_tags(data)
|
||||
data = process_tex(data)
|
||||
data = process_wsd(data)
|
||||
data.gsub!(/<p><\/p>/) do
|
||||
''
|
||||
end
|
||||
|
||||
data
|
||||
end
|
||||
|
||||
@@ -95,7 +99,8 @@ module Gollum
|
||||
def process_headers(doc)
|
||||
toc = nil
|
||||
doc.css('h1,h2,h3,h4,h5,h6').each do |h|
|
||||
h_name = h.content.gsub(' ','-')
|
||||
# must escape "
|
||||
h_name = h.content.gsub(' ','-').gsub('"','%22')
|
||||
|
||||
level = h.name.gsub(/[hH]/,'').to_i
|
||||
|
||||
@@ -121,51 +126,14 @@ module Gollum
|
||||
node.add_child(%Q{<a href="##{h_name}">#{h.content}</a>})
|
||||
tail.add_child(node)
|
||||
end
|
||||
toc = toc.to_xhtml if toc != nil
|
||||
if toc != nil
|
||||
# convert to HTML first before XHTML
|
||||
toc = Nokogiri::HTML::fragment toc.to_s
|
||||
toc = toc.to_xhtml(:encoding => 'UTF-8')
|
||||
end
|
||||
[doc, toc]
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
# TeX
|
||||
#
|
||||
#########################################################################
|
||||
|
||||
# Extract all TeX into the texmap and replace with placeholders.
|
||||
#
|
||||
# data - The raw String data.
|
||||
#
|
||||
# Returns the placeholder'd String data.
|
||||
def extract_tex(data)
|
||||
data.gsub(/\\\[\s*(.*?)\s*\\\]/m) do
|
||||
tag = CGI.escapeHTML($1)
|
||||
id = Digest::SHA1.hexdigest(tag)
|
||||
@texmap[id] = [:block, tag]
|
||||
id
|
||||
end.gsub(/\\\(\s*(.*?)\s*\\\)/m) do
|
||||
tag = CGI.escapeHTML($1)
|
||||
id = Digest::SHA1.hexdigest(tag)
|
||||
@texmap[id] = [:inline, tag]
|
||||
id
|
||||
end
|
||||
end
|
||||
|
||||
# Process all TeX from the texmap and replace the placeholders with the
|
||||
# final markup.
|
||||
#
|
||||
# data - The String data (with placeholders).
|
||||
#
|
||||
# Returns the marked up String data.
|
||||
def process_tex(data)
|
||||
@texmap.each do |id, spec|
|
||||
type, tex = *spec
|
||||
data.gsub!(id) do
|
||||
Gollum::Tex.to_html(tex, type)
|
||||
end
|
||||
end
|
||||
data
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
# Tags
|
||||
@@ -431,12 +399,12 @@ module Gollum
|
||||
# name - The String absolute or relative path of the file.
|
||||
#
|
||||
# Returns the Gollum::File or nil if none was found.
|
||||
def find_file(name)
|
||||
def find_file(name, version=@version)
|
||||
if name =~ /^\//
|
||||
@wiki.file(name[1..-1], @version)
|
||||
@wiki.file(name[1..-1], version)
|
||||
else
|
||||
path = @dir == '.' ? name : ::File.join(@dir, name)
|
||||
@wiki.file(path, @version)
|
||||
@wiki.file(path, version)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -471,6 +439,10 @@ module Gollum
|
||||
#
|
||||
# Gitcode - fetch code from github search path and replace the contents
|
||||
# to a code-block that gets run the next parse.
|
||||
# Acceptable formats:
|
||||
# ```language:local-file.ext```
|
||||
# ```language:/abs/other-file.ext```
|
||||
# ```language:github/gollum/master/somefile.txt```
|
||||
#
|
||||
#########################################################################
|
||||
|
||||
@@ -481,12 +453,12 @@ module Gollum
|
||||
uri = $2 || ''
|
||||
# Detect local file.
|
||||
if uri[0..6] != 'github/'
|
||||
if uri[0..0] != '/' # relative file
|
||||
contents = @wiki.page(uri).formatted_data
|
||||
else # use full path
|
||||
contents = @wiki.paged( extract_name( clean_url( uri ) ),
|
||||
'/' + clean_url( extract_path( uri ) ) ).formatted_data
|
||||
end
|
||||
if file = self.find_file(uri, @wiki.ref)
|
||||
contents = file.raw_data
|
||||
else
|
||||
# How do we communicate a render error?
|
||||
next "File not found: #{Rack::Utils::escape_html(uri)}"
|
||||
end
|
||||
else
|
||||
contents = Gollum::Gitcode.new(uri).contents
|
||||
end
|
||||
@@ -524,8 +496,10 @@ module Gollum
|
||||
# extract lang from { .ruby } or { #stuff .ruby .indent }
|
||||
# see http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks
|
||||
|
||||
lang = lang.match(/\.([^}\s]+)/)
|
||||
lang = lang[1] unless lang.nil?
|
||||
if lang
|
||||
lang = lang.match(/\.([^}\s]+)/)
|
||||
lang = lang[1] unless lang.nil?
|
||||
end
|
||||
|
||||
@codemap[id] = cached ?
|
||||
{ :output => cached } :
|
||||
@@ -586,7 +560,9 @@ module Gollum
|
||||
blocks.each do |lang, code|
|
||||
encoding ||= 'utf-8'
|
||||
begin
|
||||
hl_code = Pygments.highlight(code, :lexer => lang, :options => {:encoding => encoding.to_s})
|
||||
# must set startinline to true for php to be highlighted without <?
|
||||
# http://pygments.org/docs/lexers/
|
||||
hl_code = Pygments.highlight(code, :lexer => lang, :options => {:encoding => encoding.to_s, :startinline => true})
|
||||
rescue
|
||||
hl_code = code
|
||||
end
|
||||
|
||||
+23
-1
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
module Gollum
|
||||
class Page
|
||||
include Pagination
|
||||
@@ -167,6 +168,27 @@ module Gollum
|
||||
path
|
||||
end
|
||||
|
||||
# Public: Defines title for page.rb
|
||||
#
|
||||
# Returns the String title
|
||||
def url_path_title
|
||||
metadata_title || url_path.gsub("-", " ")
|
||||
end
|
||||
|
||||
# Public: Metadata title
|
||||
#
|
||||
# Set with <!-- --- title: New Title --> in page content
|
||||
#
|
||||
# Returns the String title or nil if not defined
|
||||
def metadata_title
|
||||
if metadata
|
||||
title = metadata['title']
|
||||
return title unless title.nil?
|
||||
end
|
||||
|
||||
nil
|
||||
end
|
||||
|
||||
# Public: The url_path, but CGI escaped.
|
||||
#
|
||||
# Returns the String url_path
|
||||
@@ -220,7 +242,7 @@ module Gollum
|
||||
# Public: Embedded metadata.
|
||||
#
|
||||
# Returns Hash of metadata.
|
||||
def meta_data()
|
||||
def metadata()
|
||||
formatted_data if markup_class.metadata == nil
|
||||
markup_class.metadata
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
module Gollum
|
||||
module Pagination
|
||||
def self.included(klass)
|
||||
@@ -58,4 +59,4 @@ module Gollum
|
||||
self.class.log_pagination_options(options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
module Gollum
|
||||
# Encapsulate sanitization options.
|
||||
#
|
||||
@@ -104,7 +105,7 @@ module Gollum
|
||||
attr_reader :transformers
|
||||
|
||||
# Gets or sets a String prefix which is added to ID attributes.
|
||||
# Default: 'wiki-'
|
||||
# Default: ''
|
||||
attr_accessor :id_prefix
|
||||
|
||||
# Gets a Hash describing HTML attributes that Sanitize should add.
|
||||
@@ -127,7 +128,7 @@ module Gollum
|
||||
@add_attributes = {}
|
||||
@remove_contents = REMOVE_CONTENTS.dup
|
||||
@allow_comments = false
|
||||
@id_prefix = 'wiki-'
|
||||
@id_prefix = ''
|
||||
yield self if block_given?
|
||||
end
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
require 'escape_utils'
|
||||
|
||||
module Gollum
|
||||
module Tex
|
||||
TEX_URL = "http://www.mathtran.org/cgi-bin/toy/"
|
||||
TEX_SIZES = { :inline => 2, :block => 4 }
|
||||
|
||||
def self.to_html(tex, type = :inline)
|
||||
tex_uri = EscapeUtils.escape_uri(tex)
|
||||
tex_alt = EscapeUtils.escape_html(tex)
|
||||
%{<img src="#{TEX_URL}?D=#{TEX_SIZES[type]};tex=#{tex_uri}" alt="#{tex_alt}">}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
require 'net/http'
|
||||
require 'uri'
|
||||
require 'open-uri'
|
||||
|
||||
+58
-21
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
module Gollum
|
||||
class Wiki
|
||||
include Pagination
|
||||
@@ -136,6 +137,14 @@ module Gollum
|
||||
# Gets the boolean live preview value.
|
||||
attr_reader :live_preview
|
||||
|
||||
# Injects custom css from custom.css in root repo.
|
||||
# Defaults to false
|
||||
attr_reader :css
|
||||
|
||||
# Sets page title to value of first h1
|
||||
# Defaults to false
|
||||
attr_reader :h1_title
|
||||
|
||||
# Public: Initialize a new Gollum Repo.
|
||||
#
|
||||
# path - The String path to the Git repository that holds the Gollum
|
||||
@@ -154,6 +163,11 @@ module Gollum
|
||||
# :ref - String the repository ref to retrieve pages from
|
||||
# :ws_subs - Array of chars to sub for ws in filenames.
|
||||
# :mathjax - Set to false to disable mathjax.
|
||||
# :user_icons - Enable user icons on the history page. [gravatar, identicon, none].
|
||||
# Default: none
|
||||
# :show_all - Show all files in file view, not just valid pages.
|
||||
# Default: false
|
||||
# :collapse_tree - Start with collapsed file view. Default: false
|
||||
#
|
||||
# Returns a fresh Gollum::Repo.
|
||||
def initialize(path, options = {})
|
||||
@@ -162,24 +176,36 @@ module Gollum
|
||||
options[:access] = path
|
||||
path = path.path
|
||||
end
|
||||
@path = path
|
||||
@repo_is_bare = options[:repo_is_bare]
|
||||
@page_file_dir = options[:page_file_dir]
|
||||
@access = options[:access] || GitAccess.new(path, @page_file_dir, @repo_is_bare)
|
||||
@base_path = options[:base_path] || "/"
|
||||
@page_class = options[:page_class] || self.class.page_class
|
||||
@file_class = options[:file_class] || self.class.file_class
|
||||
@markup_classes = options[:markup_classes] || self.class.markup_classes
|
||||
@repo = @access.repo
|
||||
@ref = options[:ref] || self.class.default_ref
|
||||
@sanitization = options[:sanitization] || self.class.sanitization
|
||||
@ws_subs = options[:ws_subs] ||
|
||||
self.class.default_ws_subs
|
||||
@history_sanitization = options[:history_sanitization] ||
|
||||
self.class.history_sanitization
|
||||
@live_preview = options.fetch(:live_preview, true)
|
||||
@universal_toc = options.fetch(:universal_toc, false)
|
||||
@mathjax = options[:mathjax] || false
|
||||
|
||||
# Use .fetch instead of ||
|
||||
#
|
||||
# o = { :a => false }
|
||||
# o[:a] || true # => true
|
||||
# o.fetch :a, true # => false
|
||||
|
||||
@path = path
|
||||
@repo_is_bare = options.fetch :repo_is_bare, nil
|
||||
@page_file_dir = options.fetch :page_file_dir, nil
|
||||
@access = options.fetch :access, GitAccess.new(path, @page_file_dir, @repo_is_bare)
|
||||
@base_path = options.fetch :base_path, "/"
|
||||
@page_class = options.fetch :page_class, self.class.page_class
|
||||
@file_class = options.fetch :file_class, self.class.file_class
|
||||
@markup_classes = options.fetch :markup_classes, self.class.markup_classes
|
||||
@repo = @access.repo
|
||||
@ref = options.fetch :ref, self.class.default_ref
|
||||
@sanitization = options.fetch :sanitization, self.class.sanitization
|
||||
@ws_subs = options.fetch :ws_subs, self.class.default_ws_subs
|
||||
@history_sanitization = options.fetch :history_sanitization, self.class.history_sanitization
|
||||
@live_preview = options.fetch :live_preview, true
|
||||
@universal_toc = options.fetch :universal_toc, false
|
||||
@mathjax = options.fetch :mathjax, false
|
||||
@show_all = options.fetch :show_all, false
|
||||
@collapse_tree = options.fetch :collapse_tree, false
|
||||
@css = options.fetch :css, false
|
||||
@h1_title = options.fetch :h1_title, false
|
||||
|
||||
@user_icons = ['gravatar', 'identicon'].include?( options[:user_icons] ) ?
|
||||
options[:user_icons] : 'none'
|
||||
end
|
||||
|
||||
# Public: check whether the wiki's git repo exists on the filesystem.
|
||||
@@ -256,10 +282,11 @@ module Gollum
|
||||
# :committer - Optional Gollum::Committer instance. If provided,
|
||||
# assume that this operation is part of batch of
|
||||
# updates and the commit happens later.
|
||||
#
|
||||
# dir - The String subdirectory of the Gollum::Page without any
|
||||
# prefix or suffix slashes (e.g. "foo/bar").
|
||||
# Returns the String SHA1 of the newly written version, or the
|
||||
# Gollum::Committer instance if this is part of a batch update.
|
||||
def write_page(name, format, data, commit = {})
|
||||
def write_page(name, format, data, commit = {}, dir = '')
|
||||
multi_commit = false
|
||||
|
||||
committer = if obj = commit[:committer]
|
||||
@@ -271,7 +298,7 @@ module Gollum
|
||||
|
||||
filename = Gollum::Page.cname(name)
|
||||
|
||||
committer.add_to_index('', filename, format, data)
|
||||
committer.add_to_index(dir, filename, format, data)
|
||||
|
||||
committer.after_commit do |index, sha|
|
||||
@access.refresh
|
||||
@@ -588,6 +615,16 @@ module Gollum
|
||||
# Toggles mathjax.
|
||||
attr_reader :mathjax
|
||||
|
||||
# Toggles user icons. Default: 'none'
|
||||
attr_reader :user_icons
|
||||
|
||||
# Toggles showing all files in files view. Default is false.
|
||||
# When false, only valid pages in the git repo are displayed.
|
||||
attr_reader :show_all
|
||||
|
||||
# Start with collapsed file view. Default: false
|
||||
attr_reader :collapse_tree
|
||||
|
||||
# Normalize the data.
|
||||
#
|
||||
# data - The String data to be normalized.
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
For gollum code, everything should fall under the existing MIT License.
|
||||
Alternative permissive licenses (such as BSD) for 3rd party dependencies are
|
||||
acceptable. For image assets in Gollum, CC BY or CC BY-SA is fine. Anything
|
||||
released under a copyleft license (for example GPL, AGPL, LGPL, MPL, EPL,
|
||||
etc.) is not permitted in gollum. Public domain, CC BY or CC BY-SA for code in
|
||||
gollum is not permitted.
|
||||
|
||||
---
|
||||
|
||||
The following PNGs are based on Ubuntu 11.10 SVG files located in /usr/share/icons/unity-icon-theme/places/svg/
|
||||
- group-folders.svg
|
||||
- group-files.svg
|
||||
@@ -21,3 +30,23 @@ http://www.thecssninja.com/css/css-tree-menu
|
||||
http://www.thecssninja.com/demo/license.txt
|
||||
|
||||
lib/gollum/frontend/public/css/_styles.css
|
||||
|
||||
---
|
||||
|
||||
Default profile image (man_24.png) is used under the CC BY-SA 3.0 Unported license.
|
||||
|
||||
CC BY-SA 3.0 Unported
|
||||
http://blog.twg.ca/2010/11/retina-display-icon-set/
|
||||
http://creativecommons.org/licenses/by-sa/3.0/legalcode.txt
|
||||
|
||||
lib/gollum/frontend/public/images/man_24.png
|
||||
|
||||
---
|
||||
|
||||
The canvas_identicon code is used under the MIT license.
|
||||
|
||||
https://github.com/donpark/identicon/blob/master/identicon-canvas/identicon_canvas.js
|
||||
https://github.com/donpark/identicon/blob/master/README
|
||||
|
||||
lib/gollum/frontend/public/gollum/javascript/identicon_canvas.js
|
||||
|
||||
|
||||
@@ -5,3 +5,4 @@ a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e
|
||||
b16b3d9fad9d78e5a669e7f33d94c96da374eccd b0de6e794dfdc7ef3400e894225bfe23308aae5c kristi <kristi.dev@gmail.com> 1336984025 -0700 push
|
||||
b0de6e794dfdc7ef3400e894225bfe23308aae5c cfea406f5f77afc7fb673a43e97721234385b1bd Darren Oakley <daz.oakley@gmail.com> 1341830099 +0100 push
|
||||
cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc2 Darren Oakley <daz.oakley@gmail.com> 1341830833 +0100 push
|
||||
629aa678272b017a4d136d35e77ac94d80b08dc2 7d6aeab8b84c895f21f6c66b84a457b0fced9693 Daniel Kimsey <dekimsey@ufl.edu> 1352501984 -0500 push
|
||||
|
||||
@@ -5,3 +5,4 @@ a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e
|
||||
b16b3d9fad9d78e5a669e7f33d94c96da374eccd b0de6e794dfdc7ef3400e894225bfe23308aae5c kristi <kristi.dev@gmail.com> 1336984025 -0700 push
|
||||
b0de6e794dfdc7ef3400e894225bfe23308aae5c cfea406f5f77afc7fb673a43e97721234385b1bd Darren Oakley <daz.oakley@gmail.com> 1341830099 +0100 push
|
||||
cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc2 Darren Oakley <daz.oakley@gmail.com> 1341830833 +0100 push
|
||||
629aa678272b017a4d136d35e77ac94d80b08dc2 7d6aeab8b84c895f21f6c66b84a457b0fced9693 Daniel Kimsey <dekimsey@ufl.edu> 1352501984 -0500 push
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
xE�OK1Å=÷S<ëEaºz’EYð ]¼g·™™`¦•´3ê··ã<åù½—4ps}{¶=!gtä;°ö.„{w��ZNѹSÄ<g‹È=^eáYµCN¼vêȘdëlV¶²6³Æ6
|
||||
ã‰$q„$÷"1*&«c«!µ`?J?¼Á“$š�)øwšµ®°·JV|¿&!æ‰}ç²Áï´)�<Ò—«þ¦cýƒHÐ s:²Õf£C»dŸõC8ah.Jß³qªˆl²P•ܤ›·ÿÁ§¶ï”«�s¿³6gú
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
x�Î=j1@áÔ:Åt®ô?cC\ù³šY¼Ú
ZmáÛ|„t¯ùà•µy€õþct>èDh*q0Á°ËÅŠµbLbı+è²%õG]ÖÑf¢ˆÉ¢�´Aòl\d‘Jöœô¤«è¿[‡ZgYà>·]žðÍòx×å¨Ë—ðqã‚
ÚdÌð©ƒÖª¼‡üǪ+³0Ü–¾|Ú¡S šb¤^í/M1
|
||||
@@ -1 +1 @@
|
||||
629aa678272b017a4d136d35e77ac94d80b08dc2
|
||||
7d6aeab8b84c895f21f6c66b84a457b0fced9693
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<ol class="tree">
|
||||
<li class="file"><a href="0">0</a></li>
|
||||
</ol>
|
||||
<li class="file">
|
||||
<a href="0"><span class="icon"></span>0</a>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<ol class="tree">
|
||||
<li>
|
||||
<label>folder0</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder0/0">0</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
<li>
|
||||
<label>folder0</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder0/0"><span class="icon"></span>0</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<ol class="tree">
|
||||
<li>
|
||||
<label>.</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder0">folder0</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
<li>
|
||||
<label>.</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder0"><span class="icon"></span>folder0</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
<ol class="tree">
|
||||
<li>
|
||||
<label>folder0</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder0/0">0</a></li>
|
||||
</ol>
|
||||
<li>
|
||||
<label>folder0</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder0/0"><span class="icon"></span>0</a>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder1</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder1/1">1</a></li>
|
||||
</ol>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder1</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder1/1"><span class="icon"></span>1</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
<ol class="tree">
|
||||
<li class="file"><a href="root">root</a></li>
|
||||
<li>
|
||||
<label>folder0</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder0/0">0</a></li>
|
||||
</ol>
|
||||
<li class="file">
|
||||
<a href="root"><span class="icon"></span>root</a>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder0</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder0/0"><span class="icon"></span>0</a>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder1</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder1/1">1</a></li>
|
||||
</ol>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder1</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder1/1"><span class="icon"></span>1</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
@@ -1,28 +1,41 @@
|
||||
<ol class="tree">
|
||||
<li>
|
||||
<label>folder0</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li>
|
||||
<label>folder0</label> <input type="checkbox" checked />
|
||||
<label>folder1</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li>
|
||||
<label>folder1</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li>
|
||||
<label>folder2</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder0/folder1/folder2/0">0</a></li>
|
||||
<li>
|
||||
<label>folder2</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder0/folder1/folder2/0"><span class="icon"></span>0</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder3</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder0/folder1/folder3/1"><span class="icon"></span>1</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder3</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder0/folder1/folder3/1">1</a></li>
|
||||
</ol>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder4</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder4/2"><span class="icon"></span>2</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder4</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder4/2">2</a></li>
|
||||
</ol>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ require 'rubygems'
|
||||
require 'rack/test'
|
||||
require 'test/unit'
|
||||
require 'shoulda'
|
||||
require 'mocha'
|
||||
require 'mocha/setup'
|
||||
require 'fileutils'
|
||||
|
||||
dir = File.dirname(File.expand_path(__FILE__))
|
||||
|
||||
+75
-1
@@ -15,6 +15,47 @@ context "Frontend" do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
|
||||
test "urls transform unicode" do
|
||||
header = '_Header'
|
||||
footer = '_Footer'
|
||||
sidebar = '_Sidebar'
|
||||
|
||||
# header, footer, and sidebar must be preserved
|
||||
# or gollum will not recognize them
|
||||
assert_equal header, header.to_url
|
||||
assert_equal footer, footer.to_url
|
||||
assert_equal sidebar, sidebar.to_url
|
||||
|
||||
# spaces are converted to dashes in URLs
|
||||
# and in file names saved to disk
|
||||
# urls are not case sensitive
|
||||
assert_equal 'title-space', 'Title Space'.to_url
|
||||
|
||||
# ascii only file names prevent UTF8 issues
|
||||
# when using git repos across operating systems
|
||||
# as this test demonstrates, translation is not
|
||||
# great
|
||||
assert_equal 'm-plus-f', 'μ†ℱ'.to_url
|
||||
end
|
||||
|
||||
test "utf-8 kcode" do
|
||||
assert_equal 'μ†ℱ'.scan(/./), ["μ", "†", "ℱ"]
|
||||
end
|
||||
|
||||
test "UTF-8 headers href preserved" do
|
||||
page = 'utfh1'
|
||||
text = '한글'
|
||||
|
||||
# don't use h1 or it will be promoted to replace file name
|
||||
# which doesn't generate a normal header link
|
||||
@wiki.write_page(page, :markdown, '## ' + text,
|
||||
{ :name => 'user1', :email => 'user1' });
|
||||
|
||||
get page
|
||||
|
||||
assert_match /<h2>#{text}<a class="anchor" id="#{text}" href="##{text}"><\/a><\/h2>/, last_response.body
|
||||
end
|
||||
|
||||
test "retain edit information" do
|
||||
page1 = 'page1'
|
||||
user1 = 'user1'
|
||||
@@ -184,7 +225,7 @@ context "Frontend" do
|
||||
name = "A"
|
||||
post "/create", :content => 'abc', :page => name,
|
||||
:format => 'markdown', :message => 'def'
|
||||
follow_redirect!
|
||||
|
||||
assert last_response.ok?
|
||||
|
||||
@wiki.clear_cache
|
||||
@@ -260,6 +301,9 @@ context "Frontend" do
|
||||
page2 = @wiki.page('A')
|
||||
assert_equal page1.version.sha, page2.version.sha
|
||||
end
|
||||
=begin
|
||||
# redirects are now handled by class MapGollum in bin/gollum
|
||||
# they should be set in config.ru
|
||||
|
||||
test "redirects from 'base_path' or 'base_path/' to 'base_path/Home'" do
|
||||
Precious::App.set(:wiki_options, {})
|
||||
@@ -273,7 +317,11 @@ context "Frontend" do
|
||||
Precious::App.set(:wiki_options, { :base_path => '/wiki/' })
|
||||
get "/"
|
||||
assert_match "http://example.org/wiki/Home", last_response.headers['Location']
|
||||
|
||||
# Reset base path
|
||||
Precious::App.set(:wiki_options, { :base_path => nil })
|
||||
end
|
||||
=end
|
||||
|
||||
test "author details in session are used" do
|
||||
page1 = @wiki.page('A')
|
||||
@@ -360,6 +408,31 @@ context "Frontend with lotr" do
|
||||
assert body.include?("Eye Of Sauron"), "/pages/Mordor/ should include the page 'Eye Of Sauron'"
|
||||
end
|
||||
|
||||
# base path requires 'map' in a config.ru to work correctly.
|
||||
test "create pages within sub-directories using base path" do
|
||||
Precious::App.set(:wiki_options, { :base_path => 'wiki' })
|
||||
page = 'path'
|
||||
post "/create", :content => '123', :page => page,
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
# should be wiki/Mordor/path
|
||||
assert_equal 'http://example.org/Mordor/' + page, last_response.headers['Location']
|
||||
get '/Mordor/' + page
|
||||
assert_match /123/, last_response.body
|
||||
|
||||
# Reset base path
|
||||
Precious::App.set(:wiki_options, { :base_path => nil })
|
||||
end
|
||||
|
||||
test "create pages within sub-directories using page file dir" do
|
||||
post "/create", :content => 'one two', :page => 'base',
|
||||
:path => 'wiki/Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
assert_equal 'http://example.org/wiki/Mordor/base', last_response.headers['Location']
|
||||
get "/wiki/Mordor/base"
|
||||
|
||||
assert_match /one two/, last_response.body
|
||||
end
|
||||
|
||||
|
||||
test "create pages within sub-directories" do
|
||||
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
@@ -377,6 +450,7 @@ context "Frontend with lotr" do
|
||||
test "edit pages within sub-directories" do
|
||||
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
|
||||
assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
|
||||
|
||||
post "/edit/Mordor/Orc", :content => 'not so big smelly creatures',
|
||||
|
||||
@@ -50,7 +50,7 @@ context "Wiki" do
|
||||
end
|
||||
|
||||
test "parents with default master ref" do
|
||||
ref = '629aa678272b017a4d136d35e77ac94d80b08dc2'
|
||||
ref = '7d6aeab8b84c895f21f6c66b84a457b0fced9693'
|
||||
committer = Gollum::Committer.new(@wiki)
|
||||
assert_equal ref, committer.parents.first.sha
|
||||
end
|
||||
|
||||
+19
-1
@@ -12,6 +12,10 @@ class FakePage
|
||||
::File.basename(@filepath, ::File.extname(@filepath))
|
||||
end
|
||||
|
||||
def filename
|
||||
::File.basename(@filepath)
|
||||
end
|
||||
|
||||
def path
|
||||
return @filepath
|
||||
end
|
||||
@@ -64,10 +68,24 @@ def write file, content
|
||||
end
|
||||
end
|
||||
|
||||
def to_html html
|
||||
# Remove blank nodes for proper formatting
|
||||
doc = Nokogiri.XML(html) do |cfg|
|
||||
cfg.default_xml.noblanks
|
||||
end
|
||||
|
||||
# Save as XHTML
|
||||
doc.to_xml( { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML, :indent => 2, :encoding => 'UTF-8' } )
|
||||
end
|
||||
|
||||
def check name, pages_array
|
||||
pages = FakePages.new pages_array
|
||||
expected = read name
|
||||
actual = view pages
|
||||
actual = to_html view pages
|
||||
|
||||
# Uncomment when updating tests
|
||||
# write name, actual
|
||||
|
||||
assert_equal expected, actual
|
||||
end
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ context "GitAccess" do
|
||||
assert @access.ref_map.empty?
|
||||
assert @access.tree_map.empty?
|
||||
@access.tree 'master'
|
||||
assert_equal({"master"=>"629aa678272b017a4d136d35e77ac94d80b08dc2"}, @access.ref_map)
|
||||
assert_equal({"master"=>"7d6aeab8b84c895f21f6c66b84a457b0fced9693"}, @access.ref_map)
|
||||
|
||||
@access.tree '1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3'
|
||||
map = @access.tree_map['1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3']
|
||||
|
||||
+62
-4
@@ -25,15 +25,73 @@ context "gitcode" do
|
||||
end
|
||||
|
||||
test 'that the rendered output is correctly fetched and rendered as html code' do
|
||||
assert_equal %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"nt\"><ol</span> <span class=\"na\">class=</span><span class=\"s\">\"tree\"</span><span class=\"nt\">></span>\n <span class=\"nt\"><li</span> <span class=\"na\">class=</span><span class=\"s\">\"file\"</span><span class=\"nt\">><a</span> <span class=\"na\">href=</span><span class=\"s\">\"0\"</span><span class=\"nt\">></span>0<span class=\"nt\"></a></li></span>\n<span class=\"nt\"></ol></span>\n</pre>\n</div>\n\n<p>b</p>}, @rendered
|
||||
assert_equal %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"nt\"><ol</span> <span class=\"na\">class=</span><span class=\"s\">\"tree\"</span><span class=\"nt\">></span>\n <span class=\"nt\"><li</span> <span class=\"na\">class=</span><span class=\"s\">\"file\"</span><span class=\"nt\">></span>\n <span class=\"nt\"><a</span> <span class=\"na\">href=</span><span class=\"s\">\"0\"</span><span class=\"nt\">><span</span> <span class=\"na\">class=</span><span class=\"s\">\"icon\"</span><span class=\"nt\">></span></span>0<span class=\"nt\"></a></span>\n <span class=\"nt\"></li></span>\n<span class=\"nt\"></ol></span>\n</pre></div>\n\n<p>b</p>}, @rendered
|
||||
end
|
||||
|
||||
test 'contents' do
|
||||
g = Gollum::Gitcode.new 'github/gollum/master/test/file_view/1_file.txt'
|
||||
|
||||
assert_equal g.contents, %{<ol class="tree">
|
||||
<li class="file"><a href="0">0</a></li>
|
||||
</ol>}
|
||||
assert_equal g.contents, %{<ol class=\"tree\">\n <li class=\"file\">\n <a href=\"0\"><span class=\"icon\"></span>0</a>\n </li>\n</ol>\n}
|
||||
end
|
||||
|
||||
test "gitcode relative local file" do
|
||||
@wiki.write_page("Bilbo Baggins", :markdown, "a\n```python:file-exists.py```\nb", commit_details)
|
||||
page = @wiki.page('Bilbo Baggins')
|
||||
|
||||
index = @wiki.repo.index
|
||||
index.add("file-exists.py", "import sys\n\nprint sys.maxint\n")
|
||||
index.commit("Add file-exists.py")
|
||||
|
||||
@wiki.clear_cache
|
||||
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\n</p><div class="highlight"><pre><span class="kn">import</span> <span class="nn">sys</span>\n\n<span class="k">print</span> <span class="n">sys</span><span class="o">.</span><span class="n">maxint</span>\n</pre></div>\n\n<p>b</p>}, output
|
||||
end
|
||||
|
||||
test "gitcode relative local file in subdir" do
|
||||
index = @wiki.repo.index
|
||||
index.add("foo/file-exists.py", "import sys\n\nprint sys.maxint\n")
|
||||
index.commit("Add file-exists.py")
|
||||
|
||||
@wiki.write_page("Pippin", :markdown, "a\n```python:file-exists.py```\nb", commit_details, 'foo')
|
||||
|
||||
page = @wiki.paged('Pippin', 'foo')
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\n</p><div class="highlight"><pre><span class="kn">import</span> <span class="nn">sys</span>\n\n<span class="k">print</span> <span class="n">sys</span><span class="o">.</span><span class="n">maxint</span>\n</pre></div>\n\n<p>b</p>}, output
|
||||
end
|
||||
|
||||
test "gitcode relative no file" do
|
||||
@wiki.write_page("Bilbo Baggins", :markdown, "a\n```python:no-file-exists.py```\nb", commit_details)
|
||||
page = @wiki.page('Bilbo Baggins')
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\nFile not found: no-file-exists.py\nb</p>}, output
|
||||
end
|
||||
|
||||
test "gitcode absolute local file" do
|
||||
@wiki.write_page("Bilbo Baggins", :markdown, "a\n```python:/monkey/file-exists.py```\nb", commit_details)
|
||||
page = @wiki.page('Bilbo Baggins')
|
||||
|
||||
index = @wiki.repo.index
|
||||
index.add("monkey/file-exists.py", "import sys\n\nprint sys.platform\n")
|
||||
index.commit("Add monkey/file-exists.py")
|
||||
@wiki.clear_cache
|
||||
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\n</p><div class="highlight"><pre><span class="kn">import</span> <span class="nn">sys</span>\n\n<span class="k">print</span> <span class="n">sys</span><span class="o">.</span><span class="n">platform</span>\n</pre></div>\n\n<p>b</p>}, output
|
||||
end
|
||||
|
||||
test "gitcode absolute no file" do
|
||||
@wiki.write_page("Bilbo Baggins", :markdown, "a\n```python:/monkey/no-file-exists.py```\nb", commit_details)
|
||||
page = @wiki.page('Bilbo Baggins')
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\nFile not found: /monkey/no-file-exists.py\nb</p>}, output
|
||||
end
|
||||
|
||||
test "gitcode error generates santized html" do
|
||||
@wiki.write_page("Bilbo Baggins", :markdown, "a\n```python:<script>foo</script>```\nb", commit_details)
|
||||
page = @wiki.page('Bilbo Baggins')
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\nFile not found: <script>foo</script>\nb</p>}, output
|
||||
end
|
||||
|
||||
teardown do
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
require File.expand_path '../../lib/gollum/frontend/views/history', __FILE__
|
||||
|
||||
context "Precious::Views::History" do
|
||||
setup do
|
||||
@history = Precious::Views::History.new
|
||||
end
|
||||
|
||||
test "string_to_code" do
|
||||
# Result must match the following Java code.
|
||||
=begin
|
||||
public static void main(String[] args) throws Exception {
|
||||
final String s = "code@example.com";
|
||||
final byte[] b = MessageDigest.getInstance("SHA1").digest(s.toString().getBytes("UTF-8"));
|
||||
final int c = ((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16)
|
||||
| ((b[2] & 0xFF) << 8) | (b[3] & 0xFF);
|
||||
// 143327882
|
||||
System.out.println(c);
|
||||
}
|
||||
=end
|
||||
actual = @history.string_to_code 'code@example.com'
|
||||
assert_equal 143327882, actual
|
||||
end
|
||||
end
|
||||
+46
-48
@@ -193,7 +193,7 @@ context "Markup" do
|
||||
test "wiki link within inline code block" do
|
||||
@wiki.write_page("Potato", :markdown, "`sed -i '' 's/[[:space:]]*$//'`", commit_details)
|
||||
page = @wiki.page("Potato")
|
||||
assert_equal "<p>\n <code>sed -i '' 's/[[:space:]]*$//'</code>\n</p>", page.formatted_data
|
||||
assert_equal "<p><code>sed -i '' 's/[[:space:]]*$//'</code></p>", page.formatted_data
|
||||
end
|
||||
|
||||
test "regexp gsub! backref (#383)" do
|
||||
@@ -208,11 +208,24 @@ context "Markup" do
|
||||
DATA
|
||||
), commit_details)
|
||||
output = @wiki.page(page).formatted_data
|
||||
expected = %Q{<pre>\n <code> <div class=\"highlight\"><pre><span class=\"n\">rot13</span><span class=\"p\">=</span><span class=\"s\">'tr '</span><span class=\"o\">\\</span><span class=\"s\">''</span><span class=\"n\">A</span><span class=\"o\">-</span><span class=\"n\">Za</span><span class=\"o\">-</span><span class=\"n\">z</span><span class=\"o\">'\\</span><span class=\"s\">''</span> <span class=\"s\">'\\''N-ZA-Mn-za-m'</span><span class=\"o\">\\</span><span class=\"s\">'</span>\n</pre></div>\n</code>\n</pre>}
|
||||
expected = %Q{<pre><code> <div class=\"highlight\"><pre><span class=\"n\">rot13</span><span class=\"p\">=</span><span class=\"s\">'tr '</span><span class=\"o\">\\</span><span class=\"s\">''</span><span class=\"n\">A</span><span class=\"o\">-</span><span class=\"n\">Za</span><span class=\"o\">-</span><span class=\"n\">z</span><span class=\"o\">'\\</span><span class=\"s\">''</span> <span class=\"s\">'\\''N-ZA-Mn-za-m'</span><span class=\"o\">\\</span><span class=\"s\">'</span>\n</pre></div>\n</code></pre>}
|
||||
assert_equal expected, output
|
||||
end
|
||||
|
||||
test "~~~ code blocks #537" do
|
||||
# Issue #568
|
||||
test "tilde code blocks without a language" do
|
||||
page = 'test_rgx'
|
||||
@wiki.write_page(page, :markdown,
|
||||
%Q(~~~
|
||||
'hi'
|
||||
~~~
|
||||
), commit_details)
|
||||
output = @wiki.page(page).formatted_data
|
||||
expected = %Q{<div class=\"highlight\"><pre><span class=\"s\">'hi'</span>\n</pre></div>}
|
||||
assert_equal expected, output
|
||||
end
|
||||
|
||||
test "tilde code blocks #537" do
|
||||
page = 'test_rgx'
|
||||
@wiki.write_page(page, :markdown,
|
||||
%Q(~~~ {.ruby}
|
||||
@@ -220,11 +233,12 @@ context "Markup" do
|
||||
~~~
|
||||
), commit_details)
|
||||
output = @wiki.page(page).formatted_data
|
||||
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"s1\">'hi'</span>\n</pre>\n</div>}
|
||||
expected = %Q{<div class=\"highlight\"><pre><span class=\"s1\">'hi'</span>\n</pre></div>}
|
||||
assert_equal expected, output
|
||||
end
|
||||
|
||||
test "~~~ code blocks #537 with more than one class" do
|
||||
# Issue #537
|
||||
test "tilde code blocks with more than one class" do
|
||||
page = 'test_rgx'
|
||||
@wiki.write_page(page, :markdown,
|
||||
%Q(~~~ {#hi .ruby .sauce}
|
||||
@@ -232,11 +246,12 @@ context "Markup" do
|
||||
~~~
|
||||
), commit_details)
|
||||
output = @wiki.page(page).formatted_data
|
||||
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"s1\">'hi'</span>\n</pre>\n</div>}
|
||||
expected = %Q{<div class=\"highlight\"><pre><span class=\"s1\">'hi'</span>\n</pre></div>}
|
||||
assert_equal expected, output
|
||||
end
|
||||
|
||||
test "~~~ code blocks #537 with lots of tildes" do
|
||||
# Issue #537
|
||||
test "tilde code blocks with lots of tildes" do
|
||||
page = 'test_rgx'
|
||||
@wiki.write_page(page, :markdown,
|
||||
%Q(~~~~~~ {#hi .ruby .sauce}
|
||||
@@ -245,20 +260,30 @@ context "Markup" do
|
||||
~~~~~~
|
||||
), commit_details)
|
||||
output = @wiki.page(page).formatted_data
|
||||
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"o\">~~</span>\n<span class=\"s1\">'hi'</span><span class=\"o\">~</span>\n</pre>\n</div>}
|
||||
expected = %Q{<div class=\"highlight\"><pre><span class=\"o\">~~</span>\n<span class=\"s1\">'hi'</span><span class=\"o\">~</span>\n</pre></div>}
|
||||
assert_equal expected, output
|
||||
end
|
||||
|
||||
test "four space indented code block" do
|
||||
page = 'test_four'
|
||||
@wiki.write_page(page, :markdown,
|
||||
%( test
|
||||
test), commit_details)
|
||||
output = @wiki.page(page).formatted_data
|
||||
expected = %(<pre><code>test\ntest\n</code></pre>)
|
||||
assert_equal expected, output
|
||||
end
|
||||
|
||||
test "wiki link within code block" do
|
||||
@wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details)
|
||||
page = @wiki.page("Potato")
|
||||
assert_equal "<pre>\n <code>sed -i '' 's/[[:space:]]*$//'\n</code>\n</pre>", page.formatted_data
|
||||
assert_equal "<pre><code>sed -i '' 's/[[:space:]]*$//'\n</code></pre>", page.formatted_data
|
||||
end
|
||||
|
||||
test "piped wiki link within code block" do
|
||||
@wiki.write_page("Potato", :markdown, "`make a link [[home|sweet home]]`", commit_details)
|
||||
page = @wiki.page("Potato")
|
||||
assert_equal "<p>\n <code>make a link [[home|sweet home]]</code>\n</p>", page.formatted_data
|
||||
assert_equal "<p><code>make a link [[home|sweet home]]</code></p>", page.formatted_data
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
@@ -459,9 +484,9 @@ context "Markup" do
|
||||
#
|
||||
#########################################################################
|
||||
|
||||
test "code blocks" do
|
||||
test "regular code blocks" do
|
||||
content = "a\n\n```ruby\nx = 1\n```\n\nb"
|
||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>}
|
||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre></div>\n\n<p>b</p>}
|
||||
|
||||
index = @wiki.repo.index
|
||||
index.add("Bilbo-Baggins.md", content)
|
||||
@@ -474,7 +499,7 @@ context "Markup" do
|
||||
|
||||
test "code blocks with carriage returns" do
|
||||
content = "a\r\n\r\n```ruby\r\nx = 1\r\n```\r\n\r\nb"
|
||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>}
|
||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre></div>\n\n<p>b</p>}
|
||||
|
||||
index = @wiki.repo.index
|
||||
index.add("Bilbo-Baggins.md", content)
|
||||
@@ -505,7 +530,7 @@ context "Markup" do
|
||||
|
||||
test "code blocks with multibyte caracters indent" do
|
||||
content = "a\n\n```ruby\ns = 'やくしまるえつこ'\n```\n\nb"
|
||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">s</span> <span class=\"o\">=</span> <span class=\"s1\">'やくしまるえつこ'</span>\n</pre>\n</div>\n\n<p>b</p>}
|
||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">s</span> <span class=\"o\">=</span> <span class=\"s1\">'やくしまるえつこ'</span>\n</pre></div>\n\n<p>b</p>}
|
||||
index = @wiki.repo.index
|
||||
index.add("Bilbo-Baggins.md", content)
|
||||
index.commit("Add alpha.jpg")
|
||||
@@ -557,24 +582,13 @@ np.array([[2,2],[1,3]],np.float)
|
||||
assert_match /\(\[\[/, rendered, "#{markup_class} parses out wiki links\n#{rendered}"
|
||||
end
|
||||
|
||||
test "embed code is escaped" do
|
||||
@wiki.write_page("script", :markdown, "a <script></script> b", commit_details)
|
||||
@wiki.write_page("page", :markdown, "```html:script```", commit_details)
|
||||
|
||||
output_script = @wiki.page("script").formatted_data
|
||||
output_page = @wiki.page("page").formatted_data
|
||||
|
||||
assert_equal %Q{<p>a b</p>}, output_script
|
||||
assert_equal %Q{<div class=\"highlight\">\n <pre><span class=\"nt\"><p></span>a b<span class=\"nt\"></p></span>\n</pre>\n</div>}, output_page
|
||||
end
|
||||
|
||||
test "embed code page absolute link" do
|
||||
@wiki.write_page("base", :markdown, "a\n!base\b", commit_details)
|
||||
@wiki.write_page("a", :markdown, "a\n```html:/base```\b", commit_details)
|
||||
|
||||
page = @wiki.page("a")
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\n</p><div class=\"highlight\">\n <pre><span class=\"nt\"><p></span>a\n!base<span class=\"nt\"></p></span>\n</pre>\n</div>\n}, output
|
||||
assert_equal %Q{<p>a\nFile not found: /base</p>}, output
|
||||
end
|
||||
|
||||
test "embed code page relative link" do
|
||||
@@ -583,7 +597,7 @@ np.array([[2,2],[1,3]],np.float)
|
||||
|
||||
page = @wiki.page("a")
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\n</p><div class=\"highlight\">\n <pre><span class=\"nt\"><p></span>a\n!rel<span class=\"nt\"></p></span>\n</pre>\n</div>\n}, output
|
||||
assert_equal %Q{<p>a\nFile not found: base</p>}, output
|
||||
end
|
||||
|
||||
test "code block in unsupported language" do
|
||||
@@ -631,7 +645,7 @@ np.array([[2,2],[1,3]],np.float)
|
||||
page = @wiki.page("Bilbo Baggins")
|
||||
rendered = Gollum::Markup.new(page).render
|
||||
assert_equal output, rendered
|
||||
assert_equal result, page.meta_data
|
||||
assert_equal result, page.metadata
|
||||
end
|
||||
|
||||
test "metadata blocks with newline" do
|
||||
@@ -646,7 +660,7 @@ np.array([[2,2],[1,3]],np.float)
|
||||
page = @wiki.page("Bilbo Baggins")
|
||||
rendered = Gollum::Markup.new(page).render
|
||||
assert_equal output, rendered
|
||||
assert_equal result, page.meta_data
|
||||
assert_equal result, page.metadata
|
||||
end
|
||||
|
||||
test "metadata sanitation" do
|
||||
@@ -661,7 +675,7 @@ np.array([[2,2],[1,3]],np.float)
|
||||
page = @wiki.page("Bilbo Baggins")
|
||||
rendered = Gollum::Markup.new(page).render
|
||||
assert_equal output, rendered
|
||||
assert_equal result, page.meta_data
|
||||
assert_equal result, page.metadata
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
@@ -758,24 +772,7 @@ end
|
||||
]
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
# TeX
|
||||
#
|
||||
#########################################################################
|
||||
|
||||
test "TeX block syntax" do
|
||||
content = 'a \[ a^2 \] b'
|
||||
output = "<p>a<imgsrc=\"http://www.mathtran.org/cgi-bin/toy/?D=4;tex=a%5E2\"alt=\"a^2\">b</p>"
|
||||
compare(content, output, 'md')
|
||||
end
|
||||
|
||||
test "TeX inline syntax" do
|
||||
content = 'a \( a^2 \) b'
|
||||
output = "<p>a<imgsrc=\"http://www.mathtran.org/cgi-bin/toy/?D=2;tex=a%5E2\"alt=\"a^2\">b</p>"
|
||||
compare(content, output, 'md')
|
||||
end
|
||||
|
||||
if ENV['ASCIIDOC']
|
||||
#########################################################################
|
||||
# Asciidoc
|
||||
#########################################################################
|
||||
@@ -787,6 +784,7 @@ end
|
||||
test "internal links with asciidoc" do
|
||||
compare("= Book Title\n\n[[anid]]\n== Heading", '<div class="sect1"><h2 id="wiki-anid">Heading<a class="anchor" id="Heading" href="#Heading"></a></h2><div class="sectionbody"></div></div>', 'asciidoc')
|
||||
end
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
|
||||
@@ -227,5 +227,12 @@ context "within a sub-directory" do
|
||||
assert page.header.raw_data =~ /^Hobbits/
|
||||
assert page.footer.raw_data =~ /^Lord of the Rings/
|
||||
end
|
||||
|
||||
test "get metadata on page" do
|
||||
page = @wiki.page('Elrond')
|
||||
assert_equal Gollum::Page, page.class
|
||||
assert_equal 'elf', page.metadata['race']
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
+27
-5
@@ -41,22 +41,44 @@ context "Unicode Support" do
|
||||
assert_equal '', anchors[0].text
|
||||
end
|
||||
|
||||
def check_h1 text, page
|
||||
@wiki.write_page(page, :markdown, "# " + text)
|
||||
|
||||
page = @wiki.page(page)
|
||||
assert_equal Gollum::Page, page.class
|
||||
assert_equal '# ' + text, utf8(page.raw_data)
|
||||
|
||||
output = page.formatted_data
|
||||
|
||||
# UTF-8 headers should not be encoded.
|
||||
assert_match /<h1>#{text}<a class="anchor" id="#{text}" href="##{text}"><\/a><\/h1>/, output
|
||||
end
|
||||
|
||||
test "create and read non-latin page with anchor" do
|
||||
# href="#한글"
|
||||
# href="#%ED%95%9C%EA%B8%80"
|
||||
check_h1 '한글', '1'
|
||||
# href="#한글"
|
||||
# href="#Synht%C3%A8se"
|
||||
check_h1 'Synhtèse', '2'
|
||||
end
|
||||
|
||||
test "create and read non-latin page with anchor 2" do
|
||||
@wiki.write_page("test", :markdown, "# La faune d'Édiacara")
|
||||
@wiki.write_page("test", :markdown, "# \"La\" faune d'Édiacara")
|
||||
|
||||
page = @wiki.page("test")
|
||||
assert_equal Gollum::Page, page.class
|
||||
assert_equal "# La faune d'Édiacara", utf8(page.raw_data)
|
||||
assert_equal "# \"La\" faune d'Édiacara", utf8(page.raw_data)
|
||||
|
||||
# markup.rb
|
||||
# markup.rb test: ', ", É
|
||||
doc = Nokogiri::HTML page.formatted_data
|
||||
h1s = doc / :h1
|
||||
h1 = h1s.first
|
||||
anchors = h1 / :a
|
||||
assert_equal 1, h1s.size
|
||||
assert_equal 1, anchors.size
|
||||
assert_equal %q(#La-faune-d'Édiacara), anchors[0]['href']
|
||||
assert_equal %q(La-faune-d'Édiacara), anchors[0]['id']
|
||||
assert_equal %q(#%22La%22-faune-d'Édiacara), anchors[0]['href']
|
||||
assert_equal %q(%22La%22-faune-d'Édiacara), anchors[0]['id']
|
||||
assert_equal 'anchor', anchors[0]['class']
|
||||
assert_equal '', anchors[0].text
|
||||
end
|
||||
|
||||
@@ -198,6 +198,14 @@ context "Wiki page writing" do
|
||||
assert_equal cd[:email], @wiki.repo.commits.first.author.email
|
||||
end
|
||||
|
||||
test "page title override with metadata" do
|
||||
@wiki.write_page("Gollum", :markdown, "<!-- --- title: Over -->", commit_details)
|
||||
|
||||
page = @wiki.page("Gollum")
|
||||
|
||||
assert_equal 'Over', page.url_path_title
|
||||
end
|
||||
|
||||
test "update page with format change" do
|
||||
@wiki.write_page("Gollum", :markdown, "# Gollum", commit_details)
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
class WikiFactory
|
||||
def self.create p
|
||||
def self.create p, opt={}
|
||||
path = testpath "examples/test.git"
|
||||
Grit::Repo.init_bare(path)
|
||||
Gollum::Wiki.default_options = {:universal_toc => false}
|
||||
Gollum::Wiki.default_options = {:universal_toc => false}.merge(opt)
|
||||
cleanup = Proc.new { FileUtils.rm_r File.join(File.dirname(__FILE__), *%w[examples test.git]) }
|
||||
wiki = Gollum::Wiki.new(path)
|
||||
# set 'wiki-' prefix on ids for tests
|
||||
wiki.sanitization.id_prefix = 'wiki-'
|
||||
return wiki, path, cleanup
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user