Compare commits
114 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| be9907a0cc | |||
| 30f42c50a9 | |||
| 7cba65b138 | |||
| f34a78b336 | |||
| e1942dda03 | |||
| 7142e284fa | |||
| 3c1c588953 | |||
| 52cc6bae34 | |||
| 955c608115 | |||
| 2e00cf312c | |||
| 09bbc144d1 | |||
| d02b63a434 | |||
| 9b63c67d8c | |||
| 05c4bf3374 | |||
| 424b4d3f4e | |||
| f9a6187fab | |||
| d406472882 | |||
| 749b5a5ff8 | |||
| 091d5fe750 | |||
| c8894fb465 | |||
| 2dd41cbfac | |||
| 1f2165e68b | |||
| e9b6bdbdd7 | |||
| c0c77c5ba7 | |||
| 12403172ac | |||
| 3b41ab8d75 | |||
| 7bcf35f5b1 | |||
| 9a7e1c94c7 | |||
| 30c2e675da | |||
| ac405803e8 | |||
| 7dee787a92 | |||
| ae4b1cdeca | |||
| 572982cbf9 | |||
| 74290874f9 | |||
| 847f08d952 | |||
| 0bcd616668 | |||
| 9dd701ccc4 | |||
| 56a5a7d92b | |||
| 0cf0fad50e | |||
| 5f9e91656e | |||
| a7a2479f85 | |||
| a8b230a490 | |||
| 041b01f171 | |||
| 1c475f3215 | |||
| ab699d94b0 | |||
| 942d32c9b6 | |||
| 97f15f0b18 | |||
| ed49358c50 | |||
| 85eeecd140 | |||
| 30fd40fbe5 | |||
| 2ed262cacd | |||
| 29a1ef8f8a | |||
| 772d18ee62 | |||
| dd604d9942 | |||
| 85abc83427 | |||
| 6d8220629c | |||
| 6ff7ada096 | |||
| 8575049de5 | |||
| bb6fb0c253 | |||
| eb2ad9f840 | |||
| d0dd23fc11 | |||
| 7ae4acbdb0 | |||
| 881590ab37 | |||
| 5e479dc5d9 | |||
| 7db9c2e762 | |||
| ce6b0ac095 | |||
| 420bb06988 | |||
| 20566f8acf | |||
| 1d5f69704a | |||
| 0da664299e | |||
| 6e8fb2b457 | |||
| d1c72a4ff3 | |||
| 0bf05392e4 | |||
| 7ecef0c045 | |||
| 33ca329253 | |||
| 01fa4770cb | |||
| b76257c49c | |||
| e2fbf22f38 | |||
| 134432d029 | |||
| 8d4d6e80b8 | |||
| 85e6ef3dca | |||
| 60f1467229 | |||
| 1757242382 | |||
| 55df7bb9c4 | |||
| 686b8acd38 | |||
| a5f9df6170 | |||
| 27f61a870a | |||
| a48e8d1c5c | |||
| b80f74bccd | |||
| 1e768734ef | |||
| 11c9cabeb3 | |||
| 3a14ab92f0 | |||
| 62d5f52398 | |||
| 2b4848566c | |||
| 7c825e877c | |||
| 8417c277e6 | |||
| 9cef423908 | |||
| e73c84490e | |||
| 6cfc807db0 | |||
| be366f8103 | |||
| 2d13bd796f | |||
| 523f8f80ca | |||
| b76fef9143 | |||
| e935af83d5 | |||
| d4e019ef42 | |||
| 2e738828c6 | |||
| fd7dc93778 | |||
| 3df407d9ee | |||
| 6fbba84725 | |||
| 37d20fa9cc | |||
| 410cd912ac | |||
| d234bbd861 | |||
| 3767a11d21 | |||
| 43d2143506 |
@@ -4,3 +4,4 @@ pkg
|
||||
.bundle
|
||||
Gemfile.lock
|
||||
*.gem
|
||||
*.swp
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
source "http://rubygems.org"
|
||||
|
||||
gemspec
|
||||
gem "rake", "~> 0.9.2"
|
||||
gem "rake", "~> 0.9.2.2"
|
||||
|
||||
@@ -334,6 +334,27 @@ then that whitespace will be ignored (this makes the blocks easier to read in pl
|
||||
The block must end with three backticks indented at the same level than the opening
|
||||
backticks.
|
||||
|
||||
### GITHUB SYNTAX HIGHLIGHTING
|
||||
|
||||
As an extra feature, you can syntax highlight a file from your repository, allowing
|
||||
you keep some of your sample code in the main repository. The code-snippet is
|
||||
updated when the wiki is rebuilt. You include github code like this:
|
||||
|
||||
```html:github/gollum/master/test/file_view/1_file.txt```
|
||||
|
||||
This will make the builder look at the **github user**, in the **gollum project**,
|
||||
in the **master branch**, at path **test/file_view/1_file.txt**. It will be
|
||||
rewritten to:
|
||||
|
||||
```html
|
||||
<ol class="tree">
|
||||
<li class="file"><a href="0">0</a></li>
|
||||
</ol>
|
||||
```
|
||||
|
||||
Which will be parsed as HTML code during the Pygments run, and thereby coloured
|
||||
appropriately.
|
||||
|
||||
## MATHEMATICAL EQUATIONS
|
||||
|
||||
|
||||
@@ -497,9 +518,15 @@ like Rack::Auth, OmniAuth, etc.
|
||||
Precious::App.set(:wiki_options, {:universal_toc => false})
|
||||
run Precious::App
|
||||
|
||||
## Windows Filename Validation
|
||||
Your Rack middleware can pass author details to Gollum in a Hash in the session under the 'gollum.author' key.
|
||||
|
||||
## 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
|
||||
|
||||
`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.
|
||||
|
||||
## CONTRIBUTE
|
||||
|
||||
If you'd like to hack on Gollum, start by forking my repo on GitHub:
|
||||
@@ -520,14 +547,16 @@ your changes merged back into core is as follows:
|
||||
1. Send a pull request to the github/gollum project.
|
||||
|
||||
## RELEASING
|
||||
|
||||
Update VERSION in lib/gollum.rb
|
||||
$ rake gemspec
|
||||
$ git tag vX.Y.Z
|
||||
$ git push origin vX.Y.Z
|
||||
$ gem build gollum.gemspec
|
||||
$ gem push gollum-X.Y.Z.gem
|
||||
|
||||
## BUILDING THE GEM FROM MASTER
|
||||
$ gem uninstall -aix gollum
|
||||
$ gem uninstall -aIx gollum
|
||||
$ git clone https://github.com/github/gollum.git
|
||||
$ cd gollum
|
||||
gollum$ rake build
|
||||
gollum$ gem install pkg/gollum*.gem
|
||||
gollum$ gem install --no-ri --no-rdoc pkg/gollum*.gem
|
||||
|
||||
@@ -117,7 +117,7 @@ task :gemspec => :validate do
|
||||
split("\n").
|
||||
sort.
|
||||
reject { |file| file =~ /^\./ }.
|
||||
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
||||
reject { |file| file =~ /^(rdoc|pkg|test)/ }.
|
||||
map { |file| " #{file}" }.
|
||||
join("\n")
|
||||
|
||||
@@ -139,4 +139,4 @@ task :validate do
|
||||
puts "A `VERSION` file at root level violates Gem best practices."
|
||||
exit!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+2
-2
@@ -65,8 +65,8 @@ opts = OptionParser.new do |opts|
|
||||
wiki_options[:live_preview] = false
|
||||
end
|
||||
|
||||
opts.on("--no-mathjax", "Disables mathjax.") do
|
||||
options['mathjax'] = false
|
||||
opts.on("--mathjax", "Enables mathjax.") do
|
||||
wiki_options[:mathjax] = true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+24
-169
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
||||
s.required_ruby_version = ">= 1.8.7"
|
||||
|
||||
s.name = 'gollum'
|
||||
s.version = '2.1.2'
|
||||
s.date = '2012-08-06'
|
||||
s.version = '2.2.2'
|
||||
s.date = '2012-10-04'
|
||||
s.rubyforge_project = 'gollum'
|
||||
|
||||
s.summary = "A simple, Git-powered wiki."
|
||||
@@ -23,25 +23,25 @@ Gem::Specification.new do |s|
|
||||
s.rdoc_options = ["--charset=UTF-8"]
|
||||
s.extra_rdoc_files = %w[README.md LICENSE]
|
||||
|
||||
s.add_dependency('grit', "~> 2.5.0")
|
||||
s.add_dependency('github-markup', [">= 0.7.0", "< 1.0.0"])
|
||||
s.add_dependency('github-markdown')
|
||||
s.add_dependency('pygments.rb', "~> 0.2.0")
|
||||
s.add_dependency('posix-spawn', "~> 0.3.0")
|
||||
s.add_dependency('sinatra', "~> 1.0")
|
||||
s.add_dependency('mustache', [">= 0.11.2", "< 1.0.0"])
|
||||
s.add_dependency('sanitize', "~> 2.0.0")
|
||||
s.add_dependency('nokogiri', "~> 1.4")
|
||||
s.add_dependency('useragent', "~> 0.4.9")
|
||||
s.add_dependency('stringex', "~> 1.4.0")
|
||||
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('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_development_dependency('RedCloth')
|
||||
s.add_development_dependency('mocha')
|
||||
s.add_development_dependency('org-ruby', '~> 0.7.0')
|
||||
s.add_development_dependency('shoulda')
|
||||
s.add_development_dependency('rack-test')
|
||||
s.add_development_dependency('wikicloth', '~>0.8.0')
|
||||
s.add_development_dependency('rake', '~> 0.9.2')
|
||||
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('rack-test', '~> 0.6.2')
|
||||
s.add_development_dependency('wikicloth', '~> 0.8.0')
|
||||
s.add_development_dependency('rake', '~> 0.9.2.2')
|
||||
|
||||
# = MANIFEST =
|
||||
s.files = %w[
|
||||
@@ -426,6 +426,7 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/frontend/public/gollum/livepreview/licenses/retina_display_icon_set/by_sa_3.0_unported_legalcode.txt
|
||||
lib/gollum/frontend/public/gollum/livepreview/licenses/sizzle/LICENSE.txt
|
||||
lib/gollum/frontend/public/gollum/livepreview/licenses/sundown/sundown.txt
|
||||
lib/gollum/frontend/public/gollum/livepreview/licenses/templarian_windowsicons/license.txt
|
||||
lib/gollum/frontend/public/gollum/livepreview/readme.md
|
||||
lib/gollum/frontend/templates/compare.mustache
|
||||
lib/gollum/frontend/templates/create.mustache
|
||||
@@ -453,6 +454,7 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/frontend/views/pages.rb
|
||||
lib/gollum/frontend/views/search.rb
|
||||
lib/gollum/git_access.rb
|
||||
lib/gollum/gitcode.rb
|
||||
lib/gollum/markup.rb
|
||||
lib/gollum/page.rb
|
||||
lib/gollum/pagination.rb
|
||||
@@ -464,156 +466,9 @@ Gem::Specification.new do |s|
|
||||
licenses/licenses.txt
|
||||
licenses/unity_asset_pool/COPYRIGHT
|
||||
templates/formatting.html
|
||||
test/examples/empty.git/HEAD
|
||||
test/examples/empty.git/config
|
||||
test/examples/empty.git/description
|
||||
test/examples/empty.git/hooks/applypatch-msg.sample
|
||||
test/examples/empty.git/hooks/commit-msg.sample
|
||||
test/examples/empty.git/hooks/post-commit.sample
|
||||
test/examples/empty.git/hooks/post-receive.sample
|
||||
test/examples/empty.git/hooks/post-update.sample
|
||||
test/examples/empty.git/hooks/pre-applypatch.sample
|
||||
test/examples/empty.git/hooks/pre-commit.sample
|
||||
test/examples/empty.git/hooks/pre-rebase.sample
|
||||
test/examples/empty.git/hooks/prepare-commit-msg.sample
|
||||
test/examples/empty.git/hooks/update.sample
|
||||
test/examples/empty.git/info/exclude
|
||||
test/examples/empty.git/objects/info/.gitkeep
|
||||
test/examples/empty.git/objects/pack/.gitkeep
|
||||
test/examples/empty.git/refs/heads/.gitkeep
|
||||
test/examples/lotr.git/COMMIT_EDITMSG
|
||||
test/examples/lotr.git/HEAD
|
||||
test/examples/lotr.git/ORIG_HEAD
|
||||
test/examples/lotr.git/config
|
||||
test/examples/lotr.git/description
|
||||
test/examples/lotr.git/index
|
||||
test/examples/lotr.git/info/exclude
|
||||
test/examples/lotr.git/logs/HEAD
|
||||
test/examples/lotr.git/logs/refs/heads/master
|
||||
test/examples/lotr.git/objects/06/131480411710c92a82fe2d1e76932c70feb2e5
|
||||
test/examples/lotr.git/objects/0a/de1e2916346d4c1f2fb63b863fd3c16808fe44
|
||||
test/examples/lotr.git/objects/0d/c9016ca928c78d5421a99a53b379b53929221e
|
||||
test/examples/lotr.git/objects/0e/d8cbe0a25235bd867e65193c7d837c66b328ef
|
||||
test/examples/lotr.git/objects/12/629d666c5e3178f82f533f543d61b53dc78c0b
|
||||
test/examples/lotr.git/objects/1c/79ddc69707f7b164bc2ea58beb5d8965ff6bd0
|
||||
test/examples/lotr.git/objects/1d/b89ebba7e2c14d93b94ff98cfa3708a4f0d4e3
|
||||
test/examples/lotr.git/objects/24/49c2681badfd3c189e8ed658dacffe8ba48fe5
|
||||
test/examples/lotr.git/objects/25/4bdc1ba27d8b8a794538a8522d9a2b56ec2dd9
|
||||
test/examples/lotr.git/objects/27/680b0fce1abfbc528e7aa53d92645852d52eb6
|
||||
test/examples/lotr.git/objects/2c/b9156ad383914561a8502fc70f5a1d887e48ad
|
||||
test/examples/lotr.git/objects/45/3b250f979c7bd6dfb62640c944c982ae6721ee
|
||||
test/examples/lotr.git/objects/45/f319ee12f2b551b901b22e72602963c366fff1
|
||||
test/examples/lotr.git/objects/46/a697caf435815bb07bbce947fc2d58be15f087
|
||||
test/examples/lotr.git/objects/4c/45c2b4e297a726c3d3f66886f35373e48fe1c5
|
||||
test/examples/lotr.git/objects/4e/023f460ce466e154ca09d8774c79ad5a53fc15
|
||||
test/examples/lotr.git/objects/5d/cac289a8603188d2c5caf481dcba2985126aaa
|
||||
test/examples/lotr.git/objects/60/f12f4254f58801b9ee7db7bca5fa8aeefaa56b
|
||||
test/examples/lotr.git/objects/62/9aa678272b017a4d136d35e77ac94d80b08dc2
|
||||
test/examples/lotr.git/objects/6e/48abfc56565574859e081ee58eae655d48cf71
|
||||
test/examples/lotr.git/objects/71/4323c104239440a5c66ab12a67ed07a83c404f
|
||||
test/examples/lotr.git/objects/7b/60c5a20a501a70f2317fa0ef763e1e2ce22d6b
|
||||
test/examples/lotr.git/objects/7d/981cd984ad589e3cf00d8122170c6f7d685979
|
||||
test/examples/lotr.git/objects/84/0ec5b1ba1320e8ec443f28f99566f615d5af10
|
||||
test/examples/lotr.git/objects/93/6b83ee0dd8837adb82511e40d5e4ebe59bb675
|
||||
test/examples/lotr.git/objects/94/523d7ae48aeba575099dd12926420d8fd0425d
|
||||
test/examples/lotr.git/objects/94/9a9cc3119b9c98817f375e976d2bb5e2a42809
|
||||
test/examples/lotr.git/objects/96/97dc65e095658bbd1b8e8678e08881e86d32f1
|
||||
test/examples/lotr.git/objects/9b/e95b960ac388d4e7db55f610f828e9c31344e6
|
||||
test/examples/lotr.git/objects/a3/1ca2a7c352c92531a8b99815d15843b259e814
|
||||
test/examples/lotr.git/objects/a6/59b3763b822dd97544621fd0beef162ea37b14
|
||||
test/examples/lotr.git/objects/a8/ad3c09dd842a3517085bfadd37718856dee813
|
||||
test/examples/lotr.git/objects/aa/b61fe89d56f8614c0a8151da34f939dcedfa68
|
||||
test/examples/lotr.git/objects/b0/de6e794dfdc7ef3400e894225bfe23308aae5c
|
||||
test/examples/lotr.git/objects/b1/6b3d9fad9d78e5a669e7f33d94c96da374eccd
|
||||
test/examples/lotr.git/objects/bc/4b5fc0ce2c2ba3acef6647e4f67256ee45ab60
|
||||
test/examples/lotr.git/objects/c3/b43e9f08966b088e7a0192e436b7a884542e05
|
||||
test/examples/lotr.git/objects/c9/6a7645db5d4c76389e77cd103ef3ed77d81e4c
|
||||
test/examples/lotr.git/objects/ca/7355dc497e9729fbaf0c0e3f424b86afef5614
|
||||
test/examples/lotr.git/objects/cf/ea406f5f77afc7fb673a43e97721234385b1bd
|
||||
test/examples/lotr.git/objects/d5/29304506d37f544675244c335d85cab5d29966
|
||||
test/examples/lotr.git/objects/dc/596d6b2dd89ab05c66f4abd7d5eb706bc17f19
|
||||
test/examples/lotr.git/objects/ec/da3205bee14520aab5a7bb307392064b938e83
|
||||
test/examples/lotr.git/objects/f4/84ebb1f40f8eb20d1bcd8d1d71934d2b8ae961
|
||||
test/examples/lotr.git/objects/fa/e7ef5344202bba4129abdc13060d9297d99465
|
||||
test/examples/lotr.git/objects/fb/c5dd7d807707b4a0a97c1182fecfef1eced5df
|
||||
test/examples/lotr.git/objects/fc/3eee516ff72dc9099ba00d4611eb02e5c9e634
|
||||
test/examples/lotr.git/objects/ff/6f7de62644369380ba73b4e4297c1a2d6f0b66
|
||||
test/examples/lotr.git/objects/info/packs
|
||||
test/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.idx
|
||||
test/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.pack
|
||||
test/examples/lotr.git/packed-refs
|
||||
test/examples/lotr.git/refs/heads/master
|
||||
test/examples/lotr.git/refs/remotes/origin/HEAD
|
||||
test/examples/page_file_dir.git/COMMIT_EDITMSG
|
||||
test/examples/page_file_dir.git/HEAD
|
||||
test/examples/page_file_dir.git/config
|
||||
test/examples/page_file_dir.git/description
|
||||
test/examples/page_file_dir.git/index
|
||||
test/examples/page_file_dir.git/info/exclude
|
||||
test/examples/page_file_dir.git/logs/HEAD
|
||||
test/examples/page_file_dir.git/logs/refs/heads/master
|
||||
test/examples/page_file_dir.git/objects/0c/7d27db1f575263efdcab3dc650f4502a2dbcbf
|
||||
test/examples/page_file_dir.git/objects/22/b404803c966dd92865614d86ff22ca12e50c1e
|
||||
test/examples/page_file_dir.git/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99
|
||||
test/examples/page_file_dir.git/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6
|
||||
test/examples/page_file_dir.git/objects/5b/43e14e0a15fb6f08feab1773d1c0991e9f71e2
|
||||
test/examples/page_file_dir.git/refs/heads/master
|
||||
test/examples/revert.git/COMMIT_EDITMSG
|
||||
test/examples/revert.git/HEAD
|
||||
test/examples/revert.git/config
|
||||
test/examples/revert.git/description
|
||||
test/examples/revert.git/index
|
||||
test/examples/revert.git/info/exclude
|
||||
test/examples/revert.git/logs/HEAD
|
||||
test/examples/revert.git/logs/refs/heads/master
|
||||
test/examples/revert.git/objects/10/2685c42018f802557f05db171f44443e8dacab
|
||||
test/examples/revert.git/objects/20/2ced67cea93c7b6bd2928aa1daef8d1d55a20d
|
||||
test/examples/revert.git/objects/41/76394bfa11222363c66ce7e84b5f154095b6d9
|
||||
test/examples/revert.git/objects/6a/69f92020f5df77af6e8813ff1232493383b708
|
||||
test/examples/revert.git/objects/8e/83f898e5e16ae400db59dda1017acad540f3aa
|
||||
test/examples/revert.git/objects/b4/785957bc986dc39c629de9fac9df46972c00fc
|
||||
test/examples/revert.git/objects/ed/6c9f63b98acf73c25b5ffbb38da557d3682023
|
||||
test/examples/revert.git/objects/f4/03b791119f8232b7cb0ba455c624ac6435f433
|
||||
test/examples/revert.git/objects/info/packs
|
||||
test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.idx
|
||||
test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.pack
|
||||
test/examples/revert.git/packed-refs
|
||||
test/examples/revert.git/refs/heads/master
|
||||
test/examples/revert.git/refs/remotes/origin/HEAD
|
||||
test/examples/yubiwa.git/HEAD
|
||||
test/examples/yubiwa.git/config
|
||||
test/examples/yubiwa.git/description
|
||||
test/examples/yubiwa.git/info/exclude
|
||||
test/examples/yubiwa.git/objects/10/fa2ddc4e3b4009d8a453aace10bd6148c1ad00
|
||||
test/examples/yubiwa.git/objects/52/4b82874327ea7cbf730389964ba7cb3de966de
|
||||
test/examples/yubiwa.git/objects/58/3fc201cb457fb3f1480f3e1e5999b119633835
|
||||
test/examples/yubiwa.git/objects/87/bc1dd46ab3d3874d4e898d45dd512cc20a7cc8
|
||||
test/examples/yubiwa.git/objects/89/64ed1b4e21aa90e831763bbce9034bfda81b70
|
||||
test/examples/yubiwa.git/objects/9f/f6dd0660da5fba2d3374adb2b84fa653bb538b
|
||||
test/examples/yubiwa.git/objects/ac/e97abf2b177815a1972d7db22f229f58c83309
|
||||
test/examples/yubiwa.git/objects/b1/f443863a4816628807fbf86141ebef055dda34
|
||||
test/examples/yubiwa.git/refs/heads/master
|
||||
test/file_view/1_file.txt
|
||||
test/file_view/1_file_1_folder.txt
|
||||
test/file_view/1_folder.txt
|
||||
test/file_view/2_files_2_folders.txt
|
||||
test/file_view/2_files_2_folders_1_root.txt
|
||||
test/file_view/nested_folders.txt
|
||||
test/helper.rb
|
||||
test/test_app.rb
|
||||
test/test_app_helpers.rb
|
||||
test/test_committer.rb
|
||||
test/test_file.rb
|
||||
test/test_file_view.rb
|
||||
test/test_git_access.rb
|
||||
test/test_markup.rb
|
||||
test/test_page.rb
|
||||
test/test_page_revert.rb
|
||||
test/test_pages_view.rb
|
||||
test/test_unicode.rb
|
||||
test/test_wiki.rb
|
||||
templates/helper_wiki.rb
|
||||
]
|
||||
# = MANIFEST =
|
||||
|
||||
s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
|
||||
end
|
||||
end
|
||||
+2
-1
@@ -20,9 +20,10 @@ 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__)
|
||||
|
||||
module Gollum
|
||||
VERSION = '2.1.2'
|
||||
VERSION = '2.2.2'
|
||||
|
||||
def self.assets_path
|
||||
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
||||
|
||||
@@ -100,9 +100,13 @@ module Gollum
|
||||
|
||||
tree.blobs.each do |blob|
|
||||
next if page_path_scheduled_for_deletion?(index.tree, fullpath)
|
||||
file = blob.name.downcase.sub(/\.\w+$/, '')
|
||||
file_ext = ::File.extname(blob.name).sub(/^\./, '')
|
||||
if downpath == file && !(allow_same_ext && file_ext == ext)
|
||||
|
||||
existing_file = blob.name.downcase.sub(/\.\w+$/, '')
|
||||
existing_file_ext = ::File.extname(blob.name).sub(/^\./, '')
|
||||
|
||||
new_file_ext = ::File.extname(path).sub(/^\./, '')
|
||||
|
||||
if downpath == existing_file && !(allow_same_ext && new_file_ext == existing_file_ext)
|
||||
raise DuplicatePageError.new(dir, blob.name, path)
|
||||
end
|
||||
end
|
||||
|
||||
+33
-26
@@ -9,7 +9,6 @@ require 'gollum/frontend/views/layout'
|
||||
require 'gollum/frontend/views/editable'
|
||||
require 'gollum/frontend/views/has_page'
|
||||
|
||||
require File.expand_path '../uri_encode_component', __FILE__
|
||||
require File.expand_path '../helpers', __FILE__
|
||||
|
||||
# Fix to_url
|
||||
@@ -82,12 +81,12 @@ module Precious
|
||||
end
|
||||
|
||||
before do
|
||||
@base_url = url('/', false)
|
||||
@base_url = url('/', false).chomp('/')
|
||||
settings.wiki_options.merge!({ :base_path => @base_url }) unless settings.wiki_options.has_key? :base_path
|
||||
end
|
||||
|
||||
get '/' do
|
||||
show_page_or_file('Home')
|
||||
redirect File.join(settings.wiki_options[:base_path].to_s, 'Home')
|
||||
end
|
||||
|
||||
# path is set to name if path is nil.
|
||||
@@ -95,14 +94,15 @@ module Precious
|
||||
# path must have a trailing slash 'a/b/' or
|
||||
# extract_path will trim path to 'a'
|
||||
# name, path, version
|
||||
def wiki_page( name, path = nil, version = nil)
|
||||
def wiki_page(name, path = nil, version = nil, exact = true)
|
||||
path = name if path.nil?
|
||||
name = extract_name(name)
|
||||
path = extract_path(path)
|
||||
path = '/' if exact && path.nil?
|
||||
|
||||
wiki = wiki_new
|
||||
|
||||
OpenStruct.new(:wiki => wiki, :page => wiki.paged(name, path, version),
|
||||
OpenStruct.new(:wiki => wiki, :page => wiki.paged(name, path, exact, version),
|
||||
:name => name, :path => path)
|
||||
end
|
||||
|
||||
@@ -136,19 +136,19 @@ module Precious
|
||||
mustache :edit
|
||||
end
|
||||
else
|
||||
redirect to("/create/#{CGI.escape(@name)}")
|
||||
redirect to("/create/#{encodeURIComponent(@name)}")
|
||||
end
|
||||
end
|
||||
|
||||
post '/edit/*' do
|
||||
wikip = wiki_page(CGI.unescape(params[:page]), sanitize_empty_params(params[:path]))
|
||||
path = wikip.path
|
||||
wiki = wikip.wiki
|
||||
page = wikip.page
|
||||
rename = params[:rename].to_url if params[:rename]
|
||||
name = rename || page.name
|
||||
committer = Gollum::Committer.new(wiki, commit_message)
|
||||
commit = {:committer => committer}
|
||||
path = '/' + clean_url(sanitize_empty_params(params[:path])).to_s
|
||||
page_name = CGI.unescape(params[:page])
|
||||
wiki = wiki_new
|
||||
page = wiki.paged(page_name, path, exact = true)
|
||||
rename = params[:rename].to_url if params[:rename]
|
||||
name = rename || page.name
|
||||
committer = Gollum::Committer.new(wiki, commit_message)
|
||||
commit = {:committer => committer}
|
||||
|
||||
update_wiki_page(wiki, page, params[:content], commit, name, params[:format])
|
||||
update_wiki_page(wiki, page.header, params[:header], commit) if params[:header]
|
||||
@@ -172,7 +172,7 @@ module Precious
|
||||
end
|
||||
|
||||
get '/create/*' do
|
||||
wikip = wiki_page(params[:splat].first)
|
||||
wikip = wiki_page(params[:splat].first.gsub('+', '-'))
|
||||
@name = wikip.name.to_url
|
||||
@path = wikip.path
|
||||
|
||||
@@ -187,6 +187,7 @@ module Precious
|
||||
post '/create' do
|
||||
name = params[:page].to_url
|
||||
path = sanitize_empty_params(params[:path])
|
||||
path = '' if path.nil?
|
||||
format = params[:format].intern
|
||||
|
||||
# write_page is not directory aware so use wiki_options to emulate dir support.
|
||||
@@ -195,8 +196,7 @@ module Precious
|
||||
|
||||
begin
|
||||
wiki.write_page(name, format, params[:content], commit_message)
|
||||
page = wiki.page(name)
|
||||
redirect to("/#{page.escaped_url_path}") unless page.nil?
|
||||
redirect to("/#{clean_url(CGI.escape(::File.join(path,name)))}")
|
||||
rescue Gollum::DuplicatePageError => e
|
||||
@message = "Duplicate page: #{e.message}"
|
||||
mustache :error
|
||||
@@ -276,12 +276,6 @@ module Precious
|
||||
mustache :compare
|
||||
end
|
||||
|
||||
get '/_tex.png' do
|
||||
content_type 'image/png'
|
||||
formula = Base64.decode64(params[:data])
|
||||
Gollum::Tex.render_formula(formula)
|
||||
end
|
||||
|
||||
get %r{^/(javascript|css|images)} do
|
||||
halt 404
|
||||
end
|
||||
@@ -341,7 +335,9 @@ module Precious
|
||||
path = extract_path(fullpath)
|
||||
wiki = wiki_new
|
||||
|
||||
if page = wiki.paged(name, path)
|
||||
path = '/' if path.nil?
|
||||
|
||||
if page = wiki.paged(name, path, exact = true)
|
||||
@page = page
|
||||
@name = name
|
||||
@editable = true
|
||||
@@ -354,7 +350,7 @@ module Precious
|
||||
file.raw_data
|
||||
else
|
||||
page_path = [path, name].compact.join('/')
|
||||
redirect to("/create/#{CGI.escape(page_path).gsub('%2F','/')}")
|
||||
redirect to("/create/#{clean_url(encodeURIComponent(page_path))}")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -367,8 +363,19 @@ module Precious
|
||||
wiki.update_page(page, name, format, content.to_s, commit)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Options parameter to Gollum::Committer#initialize
|
||||
# :message - The String commit message.
|
||||
# :name - The String author full name.
|
||||
# :email - The String email address.
|
||||
# message is sourced from the incoming request parameters
|
||||
# author details are sourced from the session, to be populated by rack middleware ahead of us
|
||||
def commit_message
|
||||
{ :message => params[:message] }
|
||||
commit_message = { :message => params[:message] }
|
||||
author_parameters = session['gollum.author']
|
||||
commit_message.merge! author_parameters unless author_parameters.nil?
|
||||
commit_message
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,5 +17,11 @@ module Precious
|
||||
def sanitize_empty_params(param)
|
||||
[nil,''].include?(param) ? nil : CGI.unescape(param)
|
||||
end
|
||||
|
||||
# Remove all slashes from the start of string.
|
||||
def clean_url url
|
||||
return url if url.nil?
|
||||
url.gsub('%2F','/').gsub(/^\/+/,'')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -196,7 +196,9 @@
|
||||
LanguageDefinition.getHookFunctionFor("activate")();
|
||||
}
|
||||
|
||||
function hotkey( cmd ) {
|
||||
function hotkey( e, cmd ) {
|
||||
e.preventDefault();
|
||||
|
||||
var def = LanguageDefinition.getDefinitionFor( cmd );
|
||||
if ( typeof def == 'object' ) {
|
||||
FunctionBar.executeAction( def );
|
||||
@@ -205,8 +207,17 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
Mousetrap.bind(['command+b', 'ctrl+b'], function(){ hotkey('function-bold'); });
|
||||
Mousetrap.bind(['command+i', 'ctrl+i'], function(){ hotkey('function-italic'); });
|
||||
Mousetrap.bind(['command+1', 'ctrl+1'], function( e ){ hotkey( e, 'function-h1' ); });
|
||||
Mousetrap.bind(['command+2', 'ctrl+2'], function( e ){ hotkey( e, 'function-h2' ); });
|
||||
Mousetrap.bind(['command+3', 'ctrl+3'], function( e ){ hotkey( e, 'function-h3' ); });
|
||||
Mousetrap.bind(['command+b', 'ctrl+b'], function( e ){ hotkey( e, 'function-bold' ); });
|
||||
Mousetrap.bind(['command+i', 'ctrl+i'], function( e ){ hotkey( e, 'function-italic' ); });
|
||||
Mousetrap.bind(['command+s', 'ctrl+s'], function( e ){
|
||||
e.preventDefault();
|
||||
$("#gollum-editor-submit").trigger("click");
|
||||
return false;
|
||||
});
|
||||
|
||||
} );
|
||||
} else {
|
||||
LanguageDefinition._ACTIVE_LANG = name;
|
||||
@@ -277,7 +288,7 @@
|
||||
}
|
||||
|
||||
// attempt to load the definition for this language
|
||||
var script_uri = '.' + baseUrl + '/javascript/editor/langs/' + markup_name + '.js';
|
||||
var script_uri = baseUrl + '/javascript/editor/langs/' + markup_name + '.js';
|
||||
$.ajax({
|
||||
url: script_uri,
|
||||
dataType: 'script',
|
||||
|
||||
@@ -4,7 +4,7 @@ $(document).ready(function() {
|
||||
var ok = confirm($(this).data('confirm'));
|
||||
if ( ok ) {
|
||||
var loc = window.location;
|
||||
loc = baseUrl + 'delete' + loc.pathname
|
||||
loc = baseUrl + '/delete' + loc.pathname.replace(baseUrl,'');
|
||||
window.location = loc;
|
||||
}
|
||||
// Don't navigate on cancel.
|
||||
@@ -138,10 +138,10 @@ $(document).ready(function() {
|
||||
var msg = 'Renamed ' + oldName + ' to ' + newName;
|
||||
jQuery.ajax( {
|
||||
type: 'POST',
|
||||
url: baseUrl + 'edit/' + oldName,
|
||||
url: baseUrl + '/edit/' + oldName,
|
||||
data: { path: path, rename: newName, page: oldName, message: msg },
|
||||
success: function() {
|
||||
window.location = baseUrl + encodeURIComponent(newName);
|
||||
window.location = baseUrl + '/' + encodeURIComponent(newName);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -154,14 +154,6 @@ $(document).ready(function() {
|
||||
$('#minibutton-new-page').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var path = location.pathname;
|
||||
// ensure there's more than one slash in pathname.
|
||||
if (path.split('/').length > 2) {
|
||||
path = path.substr(0, path.lastIndexOf('/') + 1);
|
||||
} else {
|
||||
path = '';
|
||||
}
|
||||
|
||||
$.GollumDialog.init({
|
||||
title: 'Create New Page',
|
||||
fields: [
|
||||
@@ -169,7 +161,7 @@ $(document).ready(function() {
|
||||
id: 'name',
|
||||
name: 'Page Name',
|
||||
type: 'text',
|
||||
defaultValue: path || ''
|
||||
defaultValue: ''
|
||||
}
|
||||
],
|
||||
OK: function( res ) {
|
||||
@@ -177,7 +169,7 @@ $(document).ready(function() {
|
||||
if ( res['name'] ) {
|
||||
name = res['name'];
|
||||
}
|
||||
window.location = baseUrl + encodeURIComponent(name);
|
||||
window.location = baseUrl + '/' + encodeURIComponent(name);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,6 +2,10 @@ body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#editor .ace_sb {
|
||||
overflow-y: auto !important;
|
||||
}
|
||||
|
||||
#darkness {
|
||||
visibility: hidden;
|
||||
position: absolute;
|
||||
@@ -49,7 +53,7 @@ so editor doesn't display in the background. */
|
||||
#contentframe {
|
||||
margin: 0 auto;
|
||||
overflow: visible;
|
||||
width: 80%;
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
#previewframe {
|
||||
@@ -63,14 +67,35 @@ so editor doesn't display in the background. */
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.editor_bg {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: black;
|
||||
width: 50%;
|
||||
height: 100%;
|
||||
z-index: -2;
|
||||
}
|
||||
|
||||
.toolpanel_bg {
|
||||
position: fixed;
|
||||
background: #666;
|
||||
top: 0;
|
||||
height: 30px;
|
||||
width: 100%;
|
||||
padding: 5px 0;
|
||||
margin: 0;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
/* -- Start from notepag.es -- */
|
||||
.toolpanel {
|
||||
position: fixed;
|
||||
background: #666;
|
||||
top: 0;
|
||||
height: 30px;
|
||||
right: 20px;
|
||||
width: 80px;
|
||||
width: 50%;
|
||||
vertical-align: middle;
|
||||
padding: 5px 0;
|
||||
margin: 0;
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 757 B After Width: | Height: | Size: 919 B |
@@ -16,6 +16,9 @@
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<div id='editor_bg' class='editor_bg'></div>
|
||||
<div class='toolpanel_bg'></div>
|
||||
|
||||
<div id='commenttoolpanel' class='toolpanel edit' style='width: 500px; right: 0px; '>
|
||||
<a id='savecommentconfirm' class='edit'><img src='images/savecomment_24.png' alt='Confirm save with comment' title='Confirm save with comment'></a>
|
||||
<a id='commentcancel' class='edit'><img src='images/cancel_24.png' alt='Cancel save with comment' title='Cancel save with comment'></a>
|
||||
@@ -36,11 +39,5 @@ var require = {
|
||||
<script src='js/sundown.js'></script>
|
||||
<script src='js/md_sundown.js'></script>
|
||||
<script src='js/livepreview.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);
|
||||
}(document));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -62,9 +62,10 @@ initAce( commentEditor, commentEditorSession );
|
||||
var baseUrl = location.pathname.split('/').slice(0,-2).join('/');
|
||||
|
||||
// RegExp from http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript
|
||||
// Returns value on success and undefined on failure.
|
||||
$.key = function( key ) {
|
||||
var value = new RegExp( '[\\?&]' + key + '=([^&#]*)' ).exec( location.href );
|
||||
return ( !value ) ? 0 : value[ 1 ] || 0;
|
||||
return ( !value ) ? undefined : value[ 1 ] || undefined;
|
||||
}
|
||||
|
||||
// True if &create=true
|
||||
@@ -73,10 +74,6 @@ var create = $.key( 'create' );
|
||||
var pageName = $.key( 'page' );
|
||||
var pathName = $.key( 'path' );
|
||||
|
||||
if ( pathName === 0 ) {
|
||||
pathName = undefined;
|
||||
}
|
||||
|
||||
defaultCommitMessage = function() {
|
||||
var msg = pageName + ' (markdown)';
|
||||
|
||||
@@ -97,15 +94,23 @@ $.save = function( commitMessage ) {
|
||||
var markdown = 'markdown';
|
||||
var txt = editorSession.getValue();
|
||||
var msg = defaultCommitMessage();
|
||||
var newLocation = location.protocol + '//' + location.host + baseUrl;
|
||||
var newLocation = baseUrl;
|
||||
|
||||
function clean( str ) {
|
||||
return str.replace(/^\/+/, '/');
|
||||
}
|
||||
|
||||
// 'a%2Fb' => a/b
|
||||
if (pathName) {
|
||||
newLocation += '/' + unescape(pathName);
|
||||
if ( pathName ) {
|
||||
pathName = unescape( pathName );
|
||||
newLocation += '/' + pathName;
|
||||
pathName = pathName + '/'; // pathName must end with /
|
||||
|
||||
pathName = clean( pathName );
|
||||
}
|
||||
|
||||
newLocation += '/' + pageName;
|
||||
newLocation = clean( newLocation );
|
||||
|
||||
// if &create=true then handle create instead of edit.
|
||||
if ( create ) {
|
||||
@@ -264,8 +269,6 @@ var makePreviewHtml = function () {
|
||||
// Update the text using feature detection to support IE.
|
||||
// preview.innerHTML = text; // this doesn't work on IE.
|
||||
previewSet( text );
|
||||
// MathJax is loaded asynchronously.
|
||||
if (typeof MathJax != 'undefined') { MathJax.Hub.Typeset( content ); }
|
||||
|
||||
// highlight code blocks.
|
||||
var codeElements = preview.getElementsByTagName( 'pre' );
|
||||
@@ -333,10 +336,23 @@ var applyTimeout = function () {
|
||||
/* Load markdown from /data/page into the ace editor.
|
||||
~-1 == false; !~-1 == true;
|
||||
*/
|
||||
if ( !~location.host.indexOf('github.com') ) {
|
||||
if ( !~ location.host.indexOf( 'github.com' ) ) {
|
||||
|
||||
// returns unescaped key with leading slashes removed
|
||||
function key_no_leading_slash( key ) {
|
||||
return unescape( $.key( key ) || '' ).replace( /^\/+/, '' );
|
||||
}
|
||||
|
||||
// ensure leading / is removed from path and that it ends with /
|
||||
var path = key_no_leading_slash( 'path' );
|
||||
// don't append '/' if path is empty from removing leading slash
|
||||
if ( path !== '' && path.charAt( path.length - 1 ) !== '/' ) {
|
||||
path += '/';
|
||||
}
|
||||
|
||||
jQuery.ajax( {
|
||||
type: 'GET',
|
||||
url: baseUrl + '/data/' + $.key( 'page' ),
|
||||
url: baseUrl + '/data/' + path + key_no_leading_slash( 'page' ),
|
||||
success: function( data ) {
|
||||
editorSession.setValue( data );
|
||||
}
|
||||
@@ -397,7 +413,8 @@ var applyTimeout = function () {
|
||||
var heightHalf = height / 2;
|
||||
|
||||
// height minus 50 so the end of document text doesn't flow off the page.
|
||||
var editorContainerStyle = 'width:' + widthHalf + 'px;' +
|
||||
// + 15 for scroll bar
|
||||
var editorContainerStyle = 'width:' + (widthHalf + 15) + 'px;' +
|
||||
'height:' + (height - 50) + 'px;' +
|
||||
'left:' + (leftRight === false ? widthHalf + 'px;' : '0px;') +
|
||||
'top:' + '40px;'; // use 40px for tool menu
|
||||
@@ -408,12 +425,12 @@ var applyTimeout = function () {
|
||||
var previewStyle = 'width:' + (widthHalf - 2 - 10) + 'px;' +
|
||||
'height:' + height + 'px;' +
|
||||
'left:' + (leftRight === false ? '10px;' : widthHalf + 'px;') +
|
||||
'top:' + '0px;';
|
||||
// preview panel top is equal to height of comment tool panel (40px) + 1
|
||||
'top:41px;';
|
||||
cssSet( preview, previewStyle );
|
||||
|
||||
// Resize tool panel
|
||||
var toolPanelStyle = 'width:' + widthHalf + 'px;' +
|
||||
'left:' + (leftRight === false ? widthHalf + 'px;' : '0px;');
|
||||
var toolPanelStyle = 'width:50%;';
|
||||
cssSet( toolPanel, toolPanelStyle );
|
||||
|
||||
// Resize comment related elements.
|
||||
@@ -428,10 +445,12 @@ var applyTimeout = function () {
|
||||
cssSet( commentEditorContainer, commentEditorContainerStyle );
|
||||
commentEditor.resize();
|
||||
|
||||
var commentToolPanelHeight = height / 4 - 40;
|
||||
|
||||
// In top subtract height (40px) of comment tool panel.
|
||||
var commentToolPanelStyle = 'width:' + widthHalf + 'px;' +
|
||||
'left:' + widthFourth + 'px;' +
|
||||
'top:' + (height / 4 - 40) + 'px;' +
|
||||
'top:' + commentToolPanelHeight + 'px;' +
|
||||
commentHidden;
|
||||
cssSet( commentToolPanel, commentToolPanelStyle );
|
||||
|
||||
@@ -444,6 +463,11 @@ var applyTimeout = function () {
|
||||
|
||||
win.jsm.resize = resize;
|
||||
|
||||
// remove editor_bg after loading because
|
||||
// it'll cause problems if toggle left right is used
|
||||
var ebg = doc.getElementById('editor_bg');
|
||||
ebg.parentNode.removeChild(ebg);
|
||||
|
||||
/*
|
||||
Resize can be called an absurd amount of times
|
||||
and will crash the page without debouncing.
|
||||
|
||||
@@ -57,3 +57,10 @@ http://www.thecssninja.com/css/css-tree-menu
|
||||
http://www.thecssninja.com/demo/license.txt
|
||||
|
||||
lib/gollum/frontend/public/css/_styles.css
|
||||
|
||||
---
|
||||
|
||||
`lr_24.png` is a modified version of http://templarian.com/files/wp_icons/icons/light/appbar.arrow.right.left.png
|
||||
|
||||
https://github.com/Templarian/WindowsIcons/blob/21189bffeb17237d444419ef43ed1b49e9f4e9f8/WindowsPhone/license.txt
|
||||
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
Read the license:
|
||||
http://creativecommons.org/licenses/by/3.0/ **
|
||||
|
||||
Basicaly, use it anyway you want but include this license file in the source if your project is open source. Nothing is needed in the front facing project. Commercial use is not only allowed but encouraged. This pack was made to promote consistency in applications.
|
||||
|
||||
Creator
|
||||
- Austin Andrews (@templarian)
|
||||
|
||||
Contributor*
|
||||
- Oren Nachman
|
||||
- appbar.chevron.down
|
||||
- appbar.chevron.up
|
||||
- appbar.chevron.left
|
||||
- appbar.chevron.right
|
||||
- Kris Vandermotten (@kvandermotten)
|
||||
- appbar.medical.pulse
|
||||
- Constantin Kichinsky (@kichinsky)
|
||||
- appbar.currency.rubles
|
||||
- appbar.currency.grivna
|
||||
- Massimo Savazzi (@msavazzi)
|
||||
- List of missing exported icons
|
||||
- Proletkult Graphik, from The Noun Project
|
||||
- appbar.draw.pen (inspired)
|
||||
- Olivier Guin, from The Noun Project
|
||||
- appbar.draw.marker
|
||||
- Gibran Bisio, from The Noun Project
|
||||
- appbar.draw.bucket
|
||||
|
||||
* Developers and designers that emailed Templarian the source .design icons to be added into the package. PNGs also accepted, but may take longer to be added.
|
||||
|
||||
|
||||
Contact
|
||||
- http://templarian.com/
|
||||
- admin[@]templarian[.]com
|
||||
|
||||
** Does not apply to copyrighted logos
|
||||
- Skype
|
||||
- Facebook
|
||||
- Twitter
|
||||
- etc...
|
||||
@@ -6,11 +6,11 @@
|
||||
<li class="minibutton">
|
||||
{{>searchbar}}
|
||||
</li>
|
||||
<li class="minibutton"><a href="{{base_url}}{{escaped_url_path}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
|
||||
class="action-view-page">View Page</a></li>
|
||||
<li class="minibutton"><a href="{{base_url}}edit/{{escaped_url_path}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
|
||||
class="action-edit-page">Edit Page</a></li>
|
||||
<li class="minibutton"><a href="{{base_url}}history/{{escaped_url_path}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
|
||||
class="action-page-history">Page History</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -23,10 +23,10 @@
|
||||
|
||||
{{#show_revert}}
|
||||
<ul class="actions">
|
||||
<li class="minibutton"><a href="{{base_url}}history/{{escaped_url_path}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
|
||||
class="action-page-history">Back to Page History</a></li>
|
||||
<li class="minibutton">
|
||||
<form name="gollum-revert" action="{{base_url}}revert/{{escaped_url_path}}/{{before}}/{{after}}" method="post" id="gollum-revert-form">
|
||||
<form name="gollum-revert" action="{{base_url}}/revert/{{escaped_url_path}}/{{before}}/{{after}}" method="post" id="gollum-revert-form">
|
||||
<a href="#" class="gollum-revert-button">Revert Changes</a>
|
||||
</form>
|
||||
</li>
|
||||
@@ -49,7 +49,7 @@
|
||||
</div>
|
||||
<div id="footer">
|
||||
<ul class="actions">
|
||||
<li class="minibutton"><a href="{{base_url}}history/{{escaped_url_path}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
|
||||
class="action-page-history">Back to Page History</a></li>
|
||||
{{#show_revert}}
|
||||
<li class="minibutton">
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<div id="head">
|
||||
<h1>Editing <strong>{{title}}</strong></h1>
|
||||
<ul class="actions">
|
||||
<li class="minibutton"><a href="{{base_url}}{{escaped_url_path}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
|
||||
class="action-view-page">View Page</a></li>
|
||||
<li class="minibutton"><a href="{{base_url}}history/{{escaped_url_path}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
|
||||
class="action-page-history">Page History</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<div id="gollum-editor" data-escaped-name="{{escaped_name}}" class="{{#is_create_page}}create{{/is_create_page}}{{#is_edit_page}}edit{{/is_edit_page}}">
|
||||
{{#is_create_page}}
|
||||
<form name="gollum-editor" action="{{base_url}}create" method="post">
|
||||
<form name="gollum-editor" action="{{base_url}}/create" method="post">
|
||||
{{/is_create_page}}
|
||||
{{#is_edit_page}}
|
||||
<form name="gollum-editor" action="{{base_url}}edit/{{escaped_name}}" method="post">
|
||||
<form name="gollum-editor" action="{{base_url}}/edit/{{escaped_name}}" method="post">
|
||||
{{/is_edit_page}}
|
||||
<fieldset id="gollum-editor-fields">
|
||||
{{#is_create_page}}
|
||||
@@ -126,7 +126,7 @@
|
||||
|
||||
<span class="jaws"><br></span>
|
||||
<input type="submit" id="gollum-editor-submit" value="Save" title="Save current changes">
|
||||
<a href="{{base_url}}preview" id="gollum-editor-preview" class="minibutton" title="Preview this Page">Preview</a>
|
||||
<a href="{{base_url}}/preview" id="gollum-editor-preview" class="minibutton" title="Preview this Page">Preview</a>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=utf-8">
|
||||
<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">
|
||||
<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">
|
||||
<title>{{title}}</title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -12,7 +12,7 @@
|
||||
<div id="home_button">
|
||||
<ul class="actions">
|
||||
<li class="minibutton">
|
||||
<a href="{{base_url}}" class="action-edit-page">Home</a>
|
||||
<a href="{{base_url}}/" class="action-edit-page">Home</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
<li class="minibutton">
|
||||
{{>searchbar}}
|
||||
</li>
|
||||
<li class="minibutton"><a href="{{base_url}}{{escaped_url_path}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
|
||||
class="action-view-page">View Page</a></li>
|
||||
<li class="minibutton"><a href="{{base_url}}edit/{{escaped_url_path}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
|
||||
class="action-edit-page">Edit Page</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -19,7 +19,7 @@
|
||||
</ul>
|
||||
|
||||
<form name="compare-versions" id="version-form" method="post"
|
||||
action="{{base_url}}compare/{{escaped_url_path}}">
|
||||
action="{{base_url}}/compare/{{escaped_url_path}}">
|
||||
<fieldset>
|
||||
<table>
|
||||
<tbody>
|
||||
@@ -39,7 +39,7 @@
|
||||
<td class="commit-name">
|
||||
<span class="time-elapsed">{{date}}:</span>
|
||||
{{message}}
|
||||
[<a href="{{base_url}}{{escaped_url_path}}/{{id}}" title="View commit">{{id7}}</a>]
|
||||
[<a href="{{base_url}}/{{escaped_url_path}}/{{id}}" title="View commit">{{id7}}</a>]
|
||||
</td>
|
||||
</tr>
|
||||
{{/versions}}
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}css/gollum.css" media="all">
|
||||
<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">
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/gollum.css" media="all">
|
||||
<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">
|
||||
|
||||
<!--[if IE 7]>
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}css/ie7.css" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/ie7.css" media="all">
|
||||
<![endif]-->
|
||||
|
||||
<script>var baseUrl = '{{base_url}}'</script>
|
||||
<script type="text/javascript" src="{{base_url}}javascript/jquery-1.7.2.min.js"></script>
|
||||
<script type="text/javascript" src="{{base_url}}javascript/mousetrap.min.js"></script>
|
||||
<script type="text/javascript" src="{{base_url}}javascript/gollum.js"></script>
|
||||
<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>
|
||||
<script type="text/javascript" src="{{base_url}}/javascript/jquery-1.7.2.min.js"></script>
|
||||
<script type="text/javascript" src="{{base_url}}/javascript/mousetrap.min.js"></script>
|
||||
<script type="text/javascript" src="{{base_url}}/javascript/gollum.js"></script>
|
||||
<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){
|
||||
j = d.createElement('script');
|
||||
j.src = 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
<script>
|
||||
Mousetrap.bind(['e'], function( e ) {
|
||||
e.preventDefault();
|
||||
window.location = "/edit" + window.location.pathname;
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
<div id="wiki-wrapper" class="page">
|
||||
<div id="head">
|
||||
<h1>{{title}}</h1>
|
||||
@@ -5,21 +12,21 @@
|
||||
<li class="minibutton">
|
||||
{{>searchbar}}
|
||||
</li>
|
||||
<li class="minibutton"><a href="{{base_url}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/"
|
||||
class="action-edit-page">Home</a></li>
|
||||
<li class="minibutton"><a href="{{base_url}}pages"
|
||||
<li class="minibutton"><a href="{{base_url}}/pages"
|
||||
class="action-all-pages">All</a></li>
|
||||
<li class="minibutton"><a href="{{base_url}}fileview"
|
||||
<li class="minibutton"><a href="{{base_url}}/fileview"
|
||||
class="action-all-pages">Files</a></li>
|
||||
<li class="minibutton" class="jaws">
|
||||
<a href="#" id="minibutton-new-page">New</a></li>
|
||||
<li class="minibutton" class="jaws">
|
||||
<a href="#" id="minibutton-rename-page">Rename</a></li>
|
||||
{{#editable}}
|
||||
<li class="minibutton"><a href="{{base_url}}edit/{{escaped_url_path}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
|
||||
class="action-edit-page">Edit</a></li>
|
||||
{{/editable}}
|
||||
<li class="minibutton"><a href="{{base_url}}history/{{escaped_url_path}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
|
||||
class="action-page-history">History</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -62,7 +69,7 @@
|
||||
<div id="footer">
|
||||
<p id="last-edit">Last edited by <b>{{author}}</b>, {{date}}</p>
|
||||
<p>
|
||||
<a id="delete-link" href="{{base_url}}{{escaped_url_path}}" data-confirm="Are you sure you want to delete this page?"><span>Delete this Page</span></a>
|
||||
<a id="delete-link" href="{{base_url}}/{{escaped_url_path}}" data-confirm="Are you sure you want to delete this page?"><span>Delete this Page</span></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<li class="minibutton">
|
||||
{{>searchbar}}
|
||||
</li>
|
||||
<li class="minibutton"><a href="{{base_url}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/"
|
||||
class="action-edit-page">Home</a></li>
|
||||
<li class="minibutton" class="jaws">
|
||||
<a href="#" id="minibutton-new-page">New</a>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<li class="minibutton">
|
||||
{{>searchbar}}
|
||||
</li>
|
||||
<li class="minibutton"><a href="{{base_url}}"
|
||||
<li class="minibutton"><a href="{{base_url}}/"
|
||||
class="action-edit-page">Home</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -15,7 +15,7 @@
|
||||
<ul>
|
||||
{{#results}}
|
||||
<li>
|
||||
<a href="{{base_url}}{{name}}">{{name}}</a>
|
||||
<a href="{{base_url}}/{{name}}">{{name}}</a>
|
||||
<span class="count">({{count}} matches)</span>
|
||||
</li>
|
||||
{{/results}}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div id="searchbar">
|
||||
<form action="{{base_url}}search" method="get" id="search-form">
|
||||
<form action="{{base_url}}/search" method="get" id="search-form">
|
||||
<div id="searchbar-fauxtext">
|
||||
<input type="text" name="q" id="search-query" value="Search…" autocomplete="off">
|
||||
<a href="#" id="search-submit" title="Search this wiki">
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
=begin
|
||||
Copyright 2006-2008 the V8 project authors. All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@@ -39,7 +40,12 @@ end
|
||||
# define charCodeAt on String
|
||||
class String
|
||||
def charCodeAt(k)
|
||||
return self[k].ord
|
||||
# use scan, nil check, and unpack instead of ord for 1.8
|
||||
# 1.9 can simply use self[k].ord
|
||||
# http://stackoverflow.com/questions/7793177/split-utf8-string-regardless-of-ruby-version
|
||||
c = self.scan(/./mu)[k]
|
||||
return nil if c.nil?
|
||||
c.unpack('U')[0]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -147,6 +153,7 @@ def Encode(uri, unescape)
|
||||
k = -1;
|
||||
while ((k+=1) < uriLength) do
|
||||
cc1 = uri.charCodeAt(k);
|
||||
next if cc1.nil?
|
||||
if (self.send(unescape, cc1))
|
||||
result[index] = cc1;
|
||||
index += 1
|
||||
@@ -163,10 +170,11 @@ def Encode(uri, unescape)
|
||||
end
|
||||
end
|
||||
end
|
||||
# use .compact to get rid of nils from charCodeAt
|
||||
# return %StringFromCharCodeArray(result);
|
||||
# 'c' = 8 bit signed char
|
||||
# http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-pack
|
||||
return result.pack 'c*'
|
||||
return result.compact.pack 'c*'
|
||||
end
|
||||
end # class << self
|
||||
end # module
|
||||
|
||||
@@ -6,6 +6,11 @@ module Precious
|
||||
|
||||
attr_reader :page, :content
|
||||
|
||||
# return path set in app.rb not @page.path
|
||||
def path
|
||||
@path
|
||||
end
|
||||
|
||||
def title
|
||||
"#{@page.title}"
|
||||
end
|
||||
|
||||
@@ -12,14 +12,14 @@ module Precious
|
||||
def breadcrumb
|
||||
if @path
|
||||
path = Pathname.new(@path)
|
||||
breadcrumb = [%{<a href="#{@base_url}pages/">Home</a>}]
|
||||
breadcrumb = [%{<a href="#{@base_url}/pages/">Home</a>}]
|
||||
path.descend do |crumb|
|
||||
title = crumb.basename
|
||||
|
||||
if title == path.basename
|
||||
breadcrumb << title
|
||||
else
|
||||
breadcrumb << %{<a href="#{@base_url}pages/#{crumb}/">#{title}</a>}
|
||||
breadcrumb << %{<a href="#{@base_url}/pages/#{crumb}/">#{title}</a>}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ module Precious
|
||||
if page_path.include?('/')
|
||||
folder = page_path.split('/').first
|
||||
folder_path = @path ? "#{@path}/#{folder}" : folder
|
||||
folder_link = %{<li><a href="#{@base_url}pages/#{folder_path}/" class="folder">#{folder}</a></li>}
|
||||
folder_link = %{<li><a href="#{@base_url}/pages/#{folder_path}/" class="folder">#{folder}</a></li>}
|
||||
|
||||
unless folder_links.include?(folder_link)
|
||||
folder_links << folder_link
|
||||
@@ -47,7 +47,7 @@ module Precious
|
||||
folder_link
|
||||
end
|
||||
elsif page_path != ".gitkeep"
|
||||
%{<li><a href="#{@base_url}#{page.escaped_url_path}" class="file">#{page.name}</a></li>}
|
||||
%{<li><a href="#{@base_url}/#{page.escaped_url_path}" class="file">#{page.name}</a></li>}
|
||||
end
|
||||
}.compact.join("\n")
|
||||
else
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
require 'net/http'
|
||||
require 'net/https' # ruby 1.8.7 fix, remove at upgrade
|
||||
require 'uri'
|
||||
require 'open-uri'
|
||||
|
||||
module Gollum
|
||||
class Gitcode
|
||||
def initialize path
|
||||
raise(ArgumentError, 'path is nil or empty') if path.nil? or path.empty?
|
||||
|
||||
@uri = URI::HTTP.build({
|
||||
:path => self.unchomp(path),
|
||||
:host => 'raw.github.com',
|
||||
:scheme => 'https',
|
||||
:port => 443 })
|
||||
end
|
||||
|
||||
def contents
|
||||
@contents ||= self.req @uri
|
||||
end
|
||||
|
||||
def unchomp p
|
||||
return p if p.nil?
|
||||
p[0] == '/' ? p : ('/' + p)
|
||||
end
|
||||
|
||||
def req uri, cut = 1
|
||||
return "Too many redirects or retries" if cut >= 10
|
||||
http = Net::HTTP.new uri.host, uri.port
|
||||
http.use_ssl = true
|
||||
resp = http.get uri.path, {
|
||||
'Accept' => 'text/plain',
|
||||
'Cache-Control' => 'no-cache',
|
||||
'Connection' => 'keep-alive',
|
||||
'Host' => uri.host,
|
||||
'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0'
|
||||
}
|
||||
code = resp.code.to_i
|
||||
return resp.body if code == 200
|
||||
return "Not Found" if code == 404
|
||||
return "Unhandled Response Code #{code}" unless code == 304 or not resp.header['location'].nil?
|
||||
loc = URI.parse resp.header['location']
|
||||
uri2 = loc.relative?() ? (uri + loc) : loc # overloads (+)
|
||||
return req uri2, (cut + 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
+84
-29
@@ -3,9 +3,17 @@ require 'cgi'
|
||||
require 'pygments'
|
||||
require 'base64'
|
||||
|
||||
require File.expand_path '../frontend/helpers', __FILE__
|
||||
require File.expand_path '../gitcode', __FILE__
|
||||
|
||||
# initialize Pygments
|
||||
Pygments.start
|
||||
|
||||
module Gollum
|
||||
|
||||
class Markup
|
||||
include Precious::Helpers
|
||||
|
||||
attr_accessor :toc
|
||||
attr_reader :metadata
|
||||
|
||||
@@ -47,6 +55,7 @@ module Gollum
|
||||
|
||||
data = @data.dup
|
||||
data = extract_metadata(data)
|
||||
data = extract_gitcode(data)
|
||||
data = extract_code(data)
|
||||
data = extract_tex(data)
|
||||
data = extract_wsd(data)
|
||||
@@ -72,7 +81,9 @@ module Gollum
|
||||
data = process_toc_tags(data)
|
||||
data = process_tex(data)
|
||||
data = process_wsd(data)
|
||||
data.gsub!(/<p><\/p>/, '')
|
||||
data.gsub!(/<p><\/p>/) do
|
||||
''
|
||||
end
|
||||
data
|
||||
end
|
||||
|
||||
@@ -84,14 +95,15 @@ module Gollum
|
||||
def process_headers(doc)
|
||||
toc = nil
|
||||
doc.css('h1,h2,h3,h4,h5,h6').each do |h|
|
||||
id = CGI::escape(h.content.gsub(' ','-'))
|
||||
id = encodeURIComponent(h.content.gsub(' ','-'))
|
||||
level = h.name.gsub(/[hH]/,'').to_i
|
||||
|
||||
# Add anchors
|
||||
anchor = Nokogiri::XML::Node.new('a', doc)
|
||||
anchor['class'] = 'anchor'
|
||||
anchor['id'] = id
|
||||
anchor['href'] = '#' + id
|
||||
# % -> %25 so anchors work on Firefox. See issue #475
|
||||
anchor['href'] = '#' + id.gsub('%', '%25')
|
||||
h.add_child(anchor)
|
||||
|
||||
# Build TOC
|
||||
@@ -109,7 +121,8 @@ module Gollum
|
||||
tail_level -= 1
|
||||
end
|
||||
node = Nokogiri::XML::Node.new('li', doc)
|
||||
node.add_child("<a href='##{id}'>#{h.content}</a>")
|
||||
# % -> %25 so anchors work on Firefox. See issue #475
|
||||
node.add_child("<a href='##{id.gsub('%', '%25')}'>#{h.content}</a>")
|
||||
tail.add_child(node)
|
||||
end
|
||||
toc = toc.to_xhtml if toc != nil
|
||||
@@ -150,23 +163,9 @@ module Gollum
|
||||
def process_tex(data)
|
||||
@texmap.each do |id, spec|
|
||||
type, tex = *spec
|
||||
|
||||
# Obtain the formula with parameters
|
||||
out = nil
|
||||
begin
|
||||
width, height, align, base64 = Gollum::Tex.render_formula(tex, true)
|
||||
|
||||
# TODO: Should we load the binary inside the html?
|
||||
#out = %{<img width="#{width}" height="#{height}" style="vertical-align: #{align}px;" src="data:image/png;base64,\n#{base64}" alt="#{CGI.escapeHTML(tex)}" />}
|
||||
|
||||
# Use the alignment values from the formula rendering but still use the call to '_tex.png'. Although it will call render_formula()
|
||||
# again, it will use the already cached formula and it might have some advantages from the point of view of browser caching (really not sure here).
|
||||
out = %{<img width="#{width}" height="#{height}" style="vertical-align: #{align}px;" src="#{::File.join(@wiki.base_path, '_tex.png')}?type=#{type}&data=#{Base64.encode64(tex).chomp}" alt="#{CGI.escapeHTML(tex)}" />}
|
||||
rescue # In case of error
|
||||
out = CGI.escapeHTML(tex)
|
||||
data.gsub!(id) do
|
||||
Gollum::Tex.to_html(tex, type)
|
||||
end
|
||||
|
||||
data.gsub!(id, out)
|
||||
end
|
||||
data
|
||||
end
|
||||
@@ -221,9 +220,13 @@ module Gollum
|
||||
@tagmap.each do |id, tag|
|
||||
# If it's preformatted, just put the tag back
|
||||
if is_preformatted?(data, id)
|
||||
data.gsub!(id, "[[#{tag}]]")
|
||||
data.gsub!(id) do
|
||||
"[[#{tag}]]"
|
||||
end
|
||||
else
|
||||
data.gsub!(id, process_tag(tag))
|
||||
data.gsub!(id) do
|
||||
process_tag(tag).gsub('%2F', '/')
|
||||
end
|
||||
end
|
||||
end
|
||||
data
|
||||
@@ -415,7 +418,9 @@ module Gollum
|
||||
#
|
||||
# Returns the marked up String data.
|
||||
def process_toc_tags(data)
|
||||
data.gsub!("[[_TOC_]]", @toc.nil? ? '' : @toc)
|
||||
data.gsub!("[[_TOC_]]") do
|
||||
@toc.nil? ? '' : @toc
|
||||
end
|
||||
data
|
||||
end
|
||||
|
||||
@@ -436,13 +441,23 @@ module Gollum
|
||||
# Find a page from a given cname. If the page has an anchor (#) and has
|
||||
# no match, strip the anchor and try again.
|
||||
#
|
||||
# cname - The String canonical page name.
|
||||
# cname - The String canonical page name including path.
|
||||
#
|
||||
# Returns a Gollum::Page instance if a page is found, or an Array of
|
||||
# [Gollum::Page, String extra] if a page without the extra anchor data
|
||||
# is found.
|
||||
def find_page_from_name(cname)
|
||||
if page = @wiki.page(cname)
|
||||
slash = cname.rindex('/')
|
||||
|
||||
unless slash.nil?
|
||||
name = cname[slash+1..-1]
|
||||
path = cname[0..slash]
|
||||
page = @wiki.paged(name, path)
|
||||
else
|
||||
page = @wiki.paged(cname, '/')
|
||||
end
|
||||
|
||||
if page
|
||||
return page
|
||||
end
|
||||
if pos = cname.index('#')
|
||||
@@ -450,6 +465,34 @@ module Gollum
|
||||
end
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
# Gitcode - fetch code from github search path and replace the contents
|
||||
# to a code-block that gets run the next parse.
|
||||
#
|
||||
#########################################################################
|
||||
|
||||
def extract_gitcode data
|
||||
data.gsub /^[ \t]*``` ?([^:\n\r]+):([^`\n\r]+)```/ do
|
||||
contents = ''
|
||||
# Use empty string if $2 is nil.
|
||||
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
|
||||
else
|
||||
contents = Gollum::Gitcode.new(uri).contents
|
||||
end
|
||||
|
||||
"```#{$1}\n#{contents}\n```\n"
|
||||
end
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
# Code
|
||||
@@ -482,7 +525,9 @@ module Gollum
|
||||
# regex - A regex to match whitespace
|
||||
def remove_leading_space(code, regex)
|
||||
if code.lines.all? { |line| line =~ /\A\r?\n\Z/ || line =~ regex }
|
||||
code.gsub!(regex, '')
|
||||
code.gsub!(regex) do
|
||||
''
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -528,7 +573,9 @@ module Gollum
|
||||
"<pre><code>#{CGI.escapeHTML(spec[:code])}</code></pre>"
|
||||
end
|
||||
end
|
||||
data.gsub!(id, body)
|
||||
data.gsub!(id) do
|
||||
body
|
||||
end
|
||||
end
|
||||
|
||||
data
|
||||
@@ -564,7 +611,9 @@ module Gollum
|
||||
@wsdmap.each do |id, spec|
|
||||
style = spec[:style]
|
||||
code = spec[:code]
|
||||
data.gsub!(id, Gollum::WebSequenceDiagram.new(code, style).to_tag)
|
||||
data.gsub!(id) do
|
||||
Gollum::WebSequenceDiagram.new(code, style).to_tag
|
||||
end
|
||||
end
|
||||
data
|
||||
end
|
||||
@@ -576,12 +625,18 @@ module Gollum
|
||||
#########################################################################
|
||||
|
||||
# Extract metadata for data and build metadata table. Metadata
|
||||
# is content found between `<!-- ---` and `-->` markers, and must
|
||||
# is content found between markers, and must
|
||||
# be a valid YAML mapping.
|
||||
#
|
||||
# Because ri and ruby 1.8.7 are awesome, the markers can't
|
||||
# be included in this documentation without triggering
|
||||
# `Unhandled special: Special: type=17`
|
||||
# Please read the source code for the exact markers
|
||||
#
|
||||
# Returns the String of formatted data with metadata removed.
|
||||
def extract_metadata(data)
|
||||
@metadata ||= {}
|
||||
# The markers are `<!-- ---` and `-->`
|
||||
data.gsub(/\<\!--+\s+---(.*?)--+\>/m) do
|
||||
yaml = @wiki.sanitizer.clean($1)
|
||||
hash = YAML.load(yaml)
|
||||
|
||||
+6
-4
@@ -327,7 +327,7 @@ module Gollum
|
||||
# Returns the String canonical name.
|
||||
def self.cname(name, char_white_sub = '-', char_other_sub = '-')
|
||||
name.respond_to?(:gsub) ?
|
||||
name.gsub(%r{\s},char_white_sub).gsub(%r{[/<>+]}, char_other_sub) :
|
||||
name.gsub(%r{\s},char_white_sub).gsub(%r{[<>+]}, char_other_sub) :
|
||||
''
|
||||
end
|
||||
|
||||
@@ -372,9 +372,9 @@ module Gollum
|
||||
# version - The String version ID to find.
|
||||
#
|
||||
# Returns a Gollum::Page or nil if the page could not be found.
|
||||
def find(name, version, dir = nil)
|
||||
def find(name, version, dir = nil, exact = false)
|
||||
map = @wiki.tree_map_for(version.to_s)
|
||||
if page = find_page_in_tree(map, name, dir)
|
||||
if page = find_page_in_tree(map, name, dir, exact)
|
||||
page.version = version.is_a?(Grit::Commit) ?
|
||||
version : @wiki.commit_for(version)
|
||||
page.historical = page.version.to_s == version.to_s
|
||||
@@ -391,12 +391,14 @@ module Gollum
|
||||
# to be in. The string should
|
||||
#
|
||||
# Returns a Gollum::Page or nil if the page could not be found.
|
||||
def find_page_in_tree(map, name, checked_dir = nil)
|
||||
def find_page_in_tree(map, name, checked_dir = nil, exact = false)
|
||||
return nil if !map || name.to_s.empty?
|
||||
if checked_dir = BlobEntry.normalize_dir(checked_dir)
|
||||
checked_dir.downcase!
|
||||
end
|
||||
|
||||
checked_dir = '' if exact && checked_dir.nil?
|
||||
|
||||
map.each do |entry|
|
||||
next if entry.name.to_s.empty?
|
||||
next unless checked_dir.nil? || entry.dir.downcase == checked_dir
|
||||
|
||||
+7
-359
@@ -1,366 +1,14 @@
|
||||
require 'fileutils'
|
||||
require 'shellwords'
|
||||
require 'tmpdir'
|
||||
require 'posix/spawn'
|
||||
require 'base64'
|
||||
require 'escape_utils'
|
||||
|
||||
module Gollum
|
||||
module Tex
|
||||
class Error < StandardError; end
|
||||
TEX_URL = "http://www.mathtran.org/cgi-bin/toy/"
|
||||
TEX_SIZES = { :inline => 2, :block => 4 }
|
||||
|
||||
extend POSIX::Spawn
|
||||
|
||||
Template = <<-EOS
|
||||
\\documentclass[11pt]{article}
|
||||
\\pagestyle{empty}
|
||||
\\setlength{\\topskip}{0pt}
|
||||
\\setlength{\\parindent}{0pt}
|
||||
\\setlength{\\abovedisplayskip}{0pt}
|
||||
\\setlength{\\belowdisplayskip}{0pt}
|
||||
|
||||
\\usepackage{geometry}
|
||||
|
||||
\\usepackage{amsfonts}
|
||||
\\usepackage{amsmath}
|
||||
|
||||
\\newsavebox{\\snippetbox}
|
||||
\\newlength{\\snippetwidth}
|
||||
\\newlength{\\snippetheight}
|
||||
\\newlength{\\snippetdepth}
|
||||
\\newlength{\\pagewidth}
|
||||
\\newlength{\\pageheight}
|
||||
\\newlength{\\pagemargin}
|
||||
|
||||
\\begin{lrbox}{\\snippetbox}%
|
||||
\$%s\$
|
||||
\\end{lrbox}
|
||||
|
||||
\\settowidth{\\snippetwidth}{\\usebox{\\snippetbox}}
|
||||
\\settoheight{\\snippetheight}{\\usebox{\\snippetbox}}
|
||||
\\settodepth{\\snippetdepth}{\\usebox{\\snippetbox}}
|
||||
|
||||
\\setlength\\pagemargin{4pt}
|
||||
|
||||
\\setlength\\pagewidth\\snippetwidth
|
||||
\\addtolength\\pagewidth\\pagemargin
|
||||
\\addtolength\\pagewidth\\pagemargin
|
||||
|
||||
\\setlength\\pageheight\\snippetheight
|
||||
\\addtolength{\\pageheight}{\\snippetdepth}
|
||||
\\addtolength\\pageheight\\pagemargin
|
||||
\\addtolength\\pageheight\\pagemargin
|
||||
|
||||
\\newwrite\\foo
|
||||
\\immediate\\openout\\foo=\\jobname.dimensions
|
||||
\\immediate\\write\\foo{snippetdepth = \\the\\snippetdepth}
|
||||
\\immediate\\write\\foo{snippetheight = \\the\\snippetheight}
|
||||
\\immediate\\write\\foo{snippetwidth = \\the\\snippetwidth}
|
||||
\\immediate\\write\\foo{pagewidth = \\the\\pagewidth}
|
||||
\\immediate\\write\\foo{pageheight = \\the\\pageheight}
|
||||
\\immediate\\write\\foo{pagemargin = \\the\\pagemargin}
|
||||
\\closeout\\foo
|
||||
|
||||
\\geometry{paperwidth=\\pagewidth,paperheight=\\pageheight,margin=\\pagemargin}
|
||||
|
||||
\\begin{document}%
|
||||
\\usebox{\\snippetbox}%
|
||||
\\end{document}
|
||||
EOS
|
||||
|
||||
class << self
|
||||
attr_accessor :latex_path
|
||||
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
|
||||
|
||||
self.latex_path = 'pdflatex'
|
||||
|
||||
def self.check_dependencies!
|
||||
return if @dependencies_available
|
||||
|
||||
if `which pdflatex` == ""
|
||||
raise Error, "`pdflatex` command not found"
|
||||
end
|
||||
|
||||
if `which gs` == ""
|
||||
raise Error, "`gs` command not found"
|
||||
end
|
||||
|
||||
if `which pnmcrop` == ""
|
||||
raise Error, "`pnmcrop` command not found"
|
||||
end
|
||||
|
||||
if `which pnmpad` == ""
|
||||
raise Error, "`pnmpad` command not found"
|
||||
end
|
||||
|
||||
if `which pnmscale` == ""
|
||||
raise Error, "`pnmscale` command not found"
|
||||
end
|
||||
|
||||
if `which ppmtopgm` == ""
|
||||
raise Error, "`ppmtopgm` command not found"
|
||||
end
|
||||
|
||||
if `which pnmgamma` == ""
|
||||
raise Error, "`pnmgamma` command not found"
|
||||
end
|
||||
|
||||
if `which pnmtopng` == ""
|
||||
raise Error, "`pnmtopng` command not found"
|
||||
end
|
||||
|
||||
@dependencies_available = true
|
||||
end
|
||||
|
||||
# Render the formula and calculate the correct alignment
|
||||
# for the image in the html.
|
||||
#
|
||||
# This is a ruby implementation of the Perl version described
|
||||
# at http://tex.stackexchange.com/questions/44486/pixel-perfect-vertical-alignment-of-image-rendered-tex-snippets
|
||||
#
|
||||
# The main caveat is that rendering takes quite a bit of processing power,
|
||||
# which can make the page load slowly if it has to render each time.
|
||||
# For this reason, the method caches the rendered formula in `/tmp` for reduced
|
||||
# loading time in subsequent loads.
|
||||
#
|
||||
# @param formula the tex formula to render
|
||||
# @param with_properties, if true it returns an array with a base64
|
||||
# string with the image, and the alignment values for the image.
|
||||
# Otherwise it returns the binary image.
|
||||
def self.render_formula(formula, with_properties=false)
|
||||
check_dependencies!
|
||||
|
||||
render_antialias_bits = 4
|
||||
render_oversample = 4
|
||||
display_oversample = 4
|
||||
gamma = 0.3
|
||||
if !with_properties
|
||||
display_oversample = 1
|
||||
gamma = 0.5
|
||||
end
|
||||
|
||||
oversample = render_oversample * display_oversample
|
||||
render_dpi = 96*1.2 * 72.27/72 * oversample # This is 1850.112 dpi.
|
||||
|
||||
|
||||
# Cache rendered formula and returned cached version if it exists
|
||||
|
||||
# First look for the .cache directory in the home folder
|
||||
cache_dir = ::File.expand_path("~/.cache")
|
||||
if not ::File.exists?(cache_dir) or not ::File.directory?(cache_dir)
|
||||
::Dir.mkdir(cache_dir)
|
||||
end
|
||||
|
||||
# Check that the gollum directory exists inside the cache dir
|
||||
cache_dir = ::File.join(cache_dir, "gollum")
|
||||
if not ::File.exists?(cache_dir) or not ::File.directory?(cache_dir)
|
||||
::Dir.mkdir(cache_dir)
|
||||
end
|
||||
|
||||
# Check for the formula in the cache dir
|
||||
hash = Digest::SHA1.hexdigest(formula)
|
||||
cache_file = ::File.join(cache_dir, "tex-#{hash}")
|
||||
|
||||
if ::File.exists?(cache_file)
|
||||
width, height, align, base64 = ::File.open(cache_file, 'rb') { |io| io.read }.split(",")
|
||||
|
||||
if with_properties
|
||||
return width, height, align, base64
|
||||
else
|
||||
return Base64.decode64(base64)
|
||||
end
|
||||
end
|
||||
|
||||
Dir.mktmpdir('tex') do |path|
|
||||
file = ::File.join(path, "formula")
|
||||
|
||||
# --- Write TeX source and compile to PDF.Write snippet into template
|
||||
::File.open(file + ".tex", 'w') { |f| f.write(Template % formula) }
|
||||
|
||||
result = sh_chdir path, "pdflatex",
|
||||
"-halt-on-error",
|
||||
"-output-directory=#{path}",
|
||||
"-output-format=pdf",
|
||||
"#{file}.tex",
|
||||
">#{file}.err 2>&1"
|
||||
|
||||
|
||||
|
||||
# --- Convert PDF to PNM using Ghostscript.
|
||||
sh "gs",
|
||||
"-q -dNOPAUSE -dBATCH",
|
||||
"-dTextAlphaBits=#{render_antialias_bits}",
|
||||
"-dGraphicsAlphaBits=#{render_antialias_bits}",
|
||||
"-r#{render_dpi}",
|
||||
"-sDEVICE=pnmraw",
|
||||
"-sOutputFile=#{file}.pnm",
|
||||
"#{file}.pdf"
|
||||
|
||||
|
||||
img_width, img_height = pnm_width_height(file + ".pnm")
|
||||
|
||||
|
||||
# --- Read dimensions file written by TeX during processing.
|
||||
#
|
||||
# Example of file contents:
|
||||
# snippetdepth = 6.50009pt
|
||||
# snippetheight = 13.53899pt
|
||||
# snippetwidth = 145.4777pt
|
||||
# pagewidth = 153.4777pt
|
||||
# pageheight = 28.03908pt
|
||||
# pagemargin = 4.0pt
|
||||
dimensions = {}
|
||||
::File.open(file + ".dimensions").readlines.each_with_index do |line, i|
|
||||
if line =~ /^(\S+)\s+=\s+(-?[0-9\.]+)pt$/
|
||||
dimensions[$1] = Float($2) / 72.27 * render_dpi
|
||||
else
|
||||
raise Error, "#{file}.dimensions: invalid line: #{i}"
|
||||
end
|
||||
end
|
||||
|
||||
# --- Crop bottom, then measure how much was cropped.
|
||||
sh "pnmcrop -white -bottom #{file}.pnm >#{file}.bottomcrop.pnm"
|
||||
#raise Error, "`pnmcrop` command failed: #{result}" unless ::File.exist?(file + ".bottomcrop.pnm")
|
||||
|
||||
img_width_bottomcrop, img_height_bottomcrop = pnm_width_height("#{file}.bottomcrop.pnm")
|
||||
bottomcrop = img_height - img_height_bottomcrop
|
||||
|
||||
# --- Crop top and sides, then measure how much was cropped from the top.
|
||||
sh "pnmcrop -white #{file}.bottomcrop.pnm > #{file}.crop.pnm"
|
||||
#raise Error, "`pnmcrop` command failed: #{result}" unless ::File.exist?(file + ".crop.pnm")
|
||||
|
||||
cropped_img_width, cropped_img_height = pnm_width_height("#{file}.crop.pnm")
|
||||
topcrop = img_height_bottomcrop - cropped_img_height
|
||||
|
||||
# --- Pad image with specific values on all four sides, in preparation for
|
||||
# downsampling.
|
||||
|
||||
# Calculate bottom padding.
|
||||
snippet_depth = Integer(dimensions["snippetdepth"] + dimensions["pagemargin"] + 0.5) - bottomcrop
|
||||
padded_snippet_depth = round_up(snippet_depth, oversample)
|
||||
increase_snippet_depth = padded_snippet_depth - snippet_depth
|
||||
bottom_padding = increase_snippet_depth
|
||||
|
||||
# --- Next calculate top padding, which depends on bottom padding.
|
||||
|
||||
padded_img_height = round_up(cropped_img_height + bottom_padding,
|
||||
oversample)
|
||||
top_padding = padded_img_height - (cropped_img_height + bottom_padding)
|
||||
|
||||
|
||||
# --- Calculate left and right side padding. Distribute padding evenly.
|
||||
|
||||
padded_img_width = round_up(cropped_img_width, oversample)
|
||||
left_padding = Integer((padded_img_width - cropped_img_width) / 2.0)
|
||||
right_padding = (padded_img_width - cropped_img_width) - left_padding
|
||||
|
||||
|
||||
# --- Pad the final image.
|
||||
result = sh "pnmpad",
|
||||
"-white",
|
||||
"-bottom=#{bottom_padding}",
|
||||
"-top=#{top_padding}",
|
||||
"-left=#{left_padding}",
|
||||
"-right=#{right_padding}",
|
||||
"#{file}.crop.pnm",
|
||||
">#{file}.pad.pnm"
|
||||
|
||||
# --- Sanity check of final size.
|
||||
final_pnm_width, final_pnm_height = pnm_width_height(file + ".pad.pnm")
|
||||
raise Error, "#{final_pnm_width} is not a multiple of #{oversample}" unless final_pnm_width % oversample == 0
|
||||
|
||||
raise "#{final_pnm_height} is not a multiple of #{oversample}" unless final_pnm_height % oversample == 0
|
||||
|
||||
# --- Convert PNM to PNG.
|
||||
|
||||
final_png_width = final_pnm_width / render_oversample
|
||||
final_png_height = final_pnm_height / render_oversample
|
||||
|
||||
result = sh "cat #{file}.pad.pnm",
|
||||
"| ppmtopgm",
|
||||
"| pnmscale -reduce #{render_oversample}",
|
||||
"| pnmgamma #{gamma}",
|
||||
"| pnmtopng -compression 9",
|
||||
"> #{file}.png"
|
||||
|
||||
raise Error, "Conversion to png failed: #{result}" unless ::File.exist?(file + ".png")
|
||||
|
||||
# Calculate html properties
|
||||
html_img_width = final_png_width / display_oversample
|
||||
html_img_height = final_png_height / display_oversample
|
||||
html_img_vertical_align = sprintf("%.0f", -padded_snippet_depth / oversample)
|
||||
png_data_base64 = Base64.encode64(::File.open("#{file}.png") { |io| io.read }).chomp
|
||||
|
||||
::File.open(cache_file, 'w') { |f| f.write(%{#{html_img_width},#{html_img_height},#{html_img_vertical_align},#{png_data_base64}}) }
|
||||
if with_properties
|
||||
return html_img_width, html_img_height, html_img_vertical_align, png_data_base64
|
||||
else
|
||||
::File.read(file + ".png")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def self.sh_chdir(path, *args)
|
||||
origcommand = args * " "
|
||||
return if origcommand == ""
|
||||
|
||||
command = origcommand
|
||||
command.gsub! /(["\\])/, "\\$1"
|
||||
command = %{/bin/sh -c "(#{command}) 2>&1"}
|
||||
|
||||
pid = spawn command, :chdir => path
|
||||
|
||||
result = Process::waitpid(pid)
|
||||
exit_value = Integer($? >> 8), signal_num = Integer($? & 127), dumped_core = Integer($? & 128)
|
||||
raise Error, "Failed #{result}: #{origcommand}. Exit value = #{exit_value}. Signal Num = #{signal_num}. Dumped core = #{dumped_core}" unless $?.success?
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
def self.sh(*args)
|
||||
origcommand = args * " "
|
||||
return if origcommand == ""
|
||||
|
||||
command = origcommand
|
||||
command.gsub! /(["\\])/, "\\$1"
|
||||
command = %{/bin/sh -c "(#{command}) 2>&1"}
|
||||
|
||||
pid = spawn command
|
||||
#pid = spawn *args
|
||||
result = Process::waitpid(pid)
|
||||
exit_value = $? >> 8, signal_num = $? & 127, dumped_core = $? & 128
|
||||
raise Error, "Failed #{result}: #{origcommand}. Exit value = #{exit_value}. Signal Num = #{signal_num}. Dumped core = #{dumped_core}" unless $?.success?
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
def self.round_up(num, mod)
|
||||
num + (num % mod == 0 ? 0 : (mod - (num % mod)))
|
||||
end
|
||||
|
||||
def self.pnm_width_height(filename)
|
||||
raise Error, "#{filename} is not a .pnm file" if filename !~ /\.pnm$/
|
||||
|
||||
width = nil, height = nil
|
||||
::File.open(filename) do |file|
|
||||
# Read first line
|
||||
line = file.gets
|
||||
begin
|
||||
line = file.gets # Read next line, skipping comments
|
||||
end while line && line =~ /^#/
|
||||
|
||||
if line =~ /^(\d+)\s+(\d+)$/
|
||||
width = Integer($1)
|
||||
height = Integer($2)
|
||||
else
|
||||
raise Error, "#{filename}: couldn't read image size"
|
||||
end
|
||||
end
|
||||
|
||||
raise Error, "#{filename}: couldn't read image size" unless width && height
|
||||
|
||||
return width, height
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
+12
-7
@@ -179,7 +179,7 @@ module Gollum
|
||||
self.class.history_sanitization
|
||||
@live_preview = options.fetch(:live_preview, true)
|
||||
@universal_toc = options.fetch(:universal_toc, false)
|
||||
@mathjax = options[:mathjax] || true
|
||||
@mathjax = options[:mathjax] || false
|
||||
end
|
||||
|
||||
# Public: check whether the wiki's git repo exists on the filesystem.
|
||||
@@ -196,9 +196,9 @@ module Gollum
|
||||
# dir - The directory String relative to the repo.
|
||||
#
|
||||
# Returns a Gollum::Page or nil if no matching page was found.
|
||||
def page(name, version = @ref, dir = nil)
|
||||
def page(name, version = @ref, dir = nil, exact = false)
|
||||
version = @ref if version.nil?
|
||||
@page_class.new(self).find(name, version, dir)
|
||||
@page_class.new(self).find(name, version, dir, exact)
|
||||
end
|
||||
|
||||
# Public: Convenience method instead of calling page(name, nil, dir).
|
||||
@@ -208,8 +208,8 @@ module Gollum
|
||||
# dir - The directory String relative to the repo.
|
||||
#
|
||||
# Returns a Gollum::Page or nil if no matching page was found.
|
||||
def paged(name, dir = nil, version = @ref)
|
||||
page(name, version, dir)
|
||||
def paged(name, dir = nil, exact = false, version = @ref)
|
||||
page(name, version, dir, exact)
|
||||
end
|
||||
|
||||
# Public: Get the static file for a given name.
|
||||
@@ -495,14 +495,19 @@ module Gollum
|
||||
@repo.git.grep(*args).split("\n").each do |line|
|
||||
result = line.split(':')
|
||||
result_1 = result[1]
|
||||
file_name = result_1.chomp(::File.extname(result_1))
|
||||
# Remove ext only from known extensions.
|
||||
# test.pdf => test.pdf, test.md => test
|
||||
file_name = Page::valid_page_name?(result_1) ? result_1.chomp(::File.extname(result_1)) :
|
||||
result_1
|
||||
results[file_name] = result[2].to_i
|
||||
end
|
||||
|
||||
# Use git ls-files '*query*' to search for file names. Grep only searches file content.
|
||||
# Spaces are converted to dashes when saving pages to disk.
|
||||
@repo.git.ls_files({}, "*#{ query.gsub(' ', '-') }*").split("\n").each do |line|
|
||||
file_name = line.chomp(::File.extname(line))
|
||||
# Remove ext only from known extensions.
|
||||
file_name = Page::valid_page_name?(line) ? line.chomp(::File.extname(line)) :
|
||||
line
|
||||
# If there's not already a result for file_name then
|
||||
# the value is nil and nil.to_i is 0.
|
||||
results[file_name] = results[file_name].to_i + 1;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class WikiFactory
|
||||
def self.create p
|
||||
path = testpath "examples/test.git"
|
||||
Grit::Repo.init_bare(@path)
|
||||
Gollum::Wiki.default_options = {:universal_toc => false}
|
||||
cleanup = Proc.new { FileUtils.rm_r File.join(File.dirname(__FILE__), *%w[examples test.git]) }
|
||||
Gollum::Wiki.new(@path), @path, cleanup
|
||||
end
|
||||
end
|
||||
+60
-3
@@ -50,6 +50,14 @@ context "Frontend" do
|
||||
assert_not_equal page_1.version.sha, page_2.version.sha
|
||||
end
|
||||
|
||||
test "edit page with slash" do
|
||||
page_1 = @wiki.page('A')
|
||||
post "/edit/A", :content => 'abc', :page => 'A', :path => '/////',
|
||||
:format => page_1.format, :message => 'def'
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
end
|
||||
|
||||
test "edits page header footer and sidebar" do
|
||||
commits = @wiki.repo.commits('master').size
|
||||
page_1 = @wiki.page('A')
|
||||
@@ -142,13 +150,14 @@ context "Frontend" do
|
||||
assert last_response.ok?
|
||||
end
|
||||
|
||||
test "page create and edit with dash" do
|
||||
test "page create and edit with dash & page rev" do
|
||||
page = 'c-d-e'
|
||||
path = 'a/b/' # path must end with /
|
||||
|
||||
post '/create', :content => 'create_msg', :page => page,
|
||||
:path => path, :format => 'markdown', :message => ''
|
||||
assert_equal 'create_msg', @wiki.paged(page, path).raw_data
|
||||
page_c = @wiki.paged(page, path)
|
||||
assert_equal 'create_msg', page_c.raw_data
|
||||
|
||||
# must clear or create_msg will be returned
|
||||
@wiki.clear_cache
|
||||
@@ -156,13 +165,26 @@ context "Frontend" do
|
||||
# post '/edit' fails. post '/edit/' works.
|
||||
post '/edit/', :content => 'edit_msg',
|
||||
:page => page, :path => path, :message => ''
|
||||
assert_equal 'edit_msg', @wiki.paged(page, path).raw_data
|
||||
page_e = @wiki.paged(page, path)
|
||||
assert_equal 'edit_msg', page_e.raw_data
|
||||
|
||||
@wiki.clear_cache
|
||||
|
||||
# test `get %r{/(.+?)/([0-9a-f]{40})} do` in app.rb
|
||||
get '/' + page_c.escaped_url_path + '/' + page_c.version.to_s
|
||||
assert last_response.ok?
|
||||
assert_match /create_msg/, last_response.body
|
||||
|
||||
get '/' + page_e.escaped_url_path + '/' + page_e.version.to_s
|
||||
assert last_response.ok?
|
||||
assert_match /edit_msg/, last_response.body
|
||||
end
|
||||
|
||||
test "guards against creation of existing page" do
|
||||
name = "A"
|
||||
post "/create", :content => 'abc', :page => name,
|
||||
:format => 'markdown', :message => 'def'
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
|
||||
@wiki.clear_cache
|
||||
@@ -199,6 +221,8 @@ context "Frontend" do
|
||||
assert last_response.ok?
|
||||
end
|
||||
|
||||
=begin
|
||||
# Grit is broken.
|
||||
test "reverts single commit" do
|
||||
page1 = @wiki.page('B')
|
||||
|
||||
@@ -224,6 +248,7 @@ context "Frontend" do
|
||||
assert_not_equal page1.version.sha, page2.version.sha
|
||||
assert_equal "INITIAL", page2.raw_data.strip
|
||||
end
|
||||
=end
|
||||
|
||||
test "cannot revert conflicting commit" do
|
||||
page1 = @wiki.page('A')
|
||||
@@ -236,6 +261,38 @@ context "Frontend" do
|
||||
assert_equal page1.version.sha, page2.version.sha
|
||||
end
|
||||
|
||||
test "redirects from 'base_path' or 'base_path/' to 'base_path/Home'" do
|
||||
Precious::App.set(:wiki_options, {})
|
||||
get "/"
|
||||
assert_match "http://example.org/Home", last_response.headers['Location']
|
||||
|
||||
Precious::App.set(:wiki_options, { :base_path => '/wiki' })
|
||||
get "/"
|
||||
assert_match "http://example.org/wiki/Home", last_response.headers['Location']
|
||||
|
||||
Precious::App.set(:wiki_options, { :base_path => '/wiki/' })
|
||||
get "/"
|
||||
assert_match "http://example.org/wiki/Home", last_response.headers['Location']
|
||||
end
|
||||
|
||||
test "author details in session are used" do
|
||||
page1 = @wiki.page('A')
|
||||
|
||||
gollum_author = { :name => 'ghi', :email => 'jkl' }
|
||||
session = { 'gollum.author' => gollum_author }
|
||||
|
||||
post "/edit/A", { :content => 'abc', :page => 'A', :format => page1.format, :message => 'def' }, { 'rack.session' => session }
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
|
||||
@wiki.clear_cache
|
||||
page2 = @wiki.page(page1.name)
|
||||
|
||||
author = page2.version.author
|
||||
assert_equal 'ghi', author.name
|
||||
assert_equal 'jkl', author.email
|
||||
end
|
||||
|
||||
def app
|
||||
Precious::App
|
||||
end
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
require File.expand_path( '../helper', __FILE__ )
|
||||
require File.expand_path( '../wiki_factory', __FILE__ )
|
||||
|
||||
context "gitcode" do
|
||||
|
||||
def page_with_content c
|
||||
index = @wiki.repo.index
|
||||
index.add 'Sample-Html.md', c
|
||||
index.commit 'adding file html sample'
|
||||
|
||||
page = @wiki.page 'Sample Html'
|
||||
page
|
||||
end
|
||||
|
||||
setup do
|
||||
# context
|
||||
@wiki, @path, @cleanup = WikiFactory.create 'examples/test.git'
|
||||
|
||||
# given
|
||||
p = page_with_content "a\n\n```html:github/gollum/master/test/file_view/1_file.txt```\n\nb"
|
||||
|
||||
# when rendering the page
|
||||
@rendered = Gollum::Markup.new(p).render
|
||||
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\"><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></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>}
|
||||
end
|
||||
|
||||
teardown do
|
||||
@cleanup.call
|
||||
end
|
||||
end
|
||||
+54
-18
@@ -1,17 +1,14 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
||||
require File.expand_path( "../helper", __FILE__ )
|
||||
require File.expand_path( "../wiki_factory", __FILE__ )
|
||||
|
||||
context "Markup" do
|
||||
setup do
|
||||
@path = testpath("examples/test.git")
|
||||
FileUtils.rm_rf(@path)
|
||||
Grit::Repo.init_bare(@path)
|
||||
Gollum::Wiki.default_options = {:universal_toc => false}
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
@wiki, @path, @teardown = WikiFactory.create 'examples/test.git'
|
||||
end
|
||||
|
||||
teardown do
|
||||
FileUtils.rm_r(File.join(File.dirname(__FILE__), *%w[examples test.git]))
|
||||
@teardown.call
|
||||
end
|
||||
|
||||
test "formats page from Wiki#pages" do
|
||||
@@ -184,6 +181,22 @@ context "Markup" do
|
||||
assert_equal "<p><code>sed -i '' 's/[[:space:]]*$//'</code></p>", page.formatted_data
|
||||
end
|
||||
|
||||
test "regexp gsub! backref (#383)" do
|
||||
# bug only triggers on "```" syntax
|
||||
# not `code`
|
||||
page = 'test_rgx'
|
||||
@wiki.write_page(page, :markdown,
|
||||
(<<-'DATA'
|
||||
```
|
||||
rot13='tr '\''A-Za-z'\'' '\''N-ZA-Mn-za-m'\'
|
||||
```
|
||||
DATA
|
||||
), commit_details)
|
||||
output = @wiki.page(page).formatted_data
|
||||
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>}.strip # remove trailing \n
|
||||
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")
|
||||
@@ -396,9 +409,7 @@ context "Markup" do
|
||||
|
||||
test "code blocks" do
|
||||
content = "a\n\n```ruby\nx = 1\n```\n\nb"
|
||||
output = "<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\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)
|
||||
@@ -411,9 +422,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 = "<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\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)
|
||||
@@ -444,9 +453,7 @@ context "Markup" do
|
||||
|
||||
test "code blocks with multibyte caracters indent" do
|
||||
content = "a\n\n```ruby\ns = 'やくしまるえつこ'\n```\n\nb"
|
||||
output = "<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\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")
|
||||
@@ -498,6 +505,35 @@ 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\"><pre><span class=\"nt\"><p></span>a b<span class=\"nt\"></p></span>\n</pre></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\"><pre><span class=\"nt\"><p></span>a\n!base<span class=\"nt\"></p></span>\n</pre></div>\n}, output
|
||||
end
|
||||
|
||||
test "embed code page relative link" do
|
||||
@wiki.write_page("base", :markdown, "a\n!rel\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\"><pre><span class=\"nt\"><p></span>a\n!rel<span class=\"nt\"></p></span>\n</pre></div>\n}, output
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
# Web Sequence Diagrams
|
||||
@@ -670,13 +706,13 @@ end
|
||||
|
||||
test "TeX block syntax" do
|
||||
content = 'a \[ a^2 \] b'
|
||||
output = "<p>a<imgwidth=\"15\"height=\"16\"style=\"vertical-align:-1px;\"src=\"/_tex.png?type=block&data=YV4y\"alt=\"a^2\"/>b</p>"
|
||||
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<imgwidth=\"15\"height=\"16\"style=\"vertical-align:-1px;\"src=\"/_tex.png?type=inline&data=YV4y\"alt=\"a^2\"/>b</p>"
|
||||
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
|
||||
|
||||
|
||||
+2
-1
@@ -99,7 +99,8 @@ context "Page" do
|
||||
test "cname" do
|
||||
assert_equal "Foo", Gollum::Page.cname("Foo")
|
||||
assert_equal "Foo-Bar", Gollum::Page.cname("Foo Bar")
|
||||
assert_equal "Foo---Bar", Gollum::Page.cname("Foo / Bar")
|
||||
# / is now a directory delimiter so it must be preserved
|
||||
assert_equal "Foo-/-Bar", Gollum::Page.cname("Foo / Bar")
|
||||
assert_equal "José", Gollum::Page.cname("José")
|
||||
assert_equal "モルドール", Gollum::Page.cname("モルドール")
|
||||
end
|
||||
|
||||
@@ -39,7 +39,6 @@ context "Page Reverting" do
|
||||
assert_equal "INITIAL", body=page2.raw_data.strip
|
||||
assert_equal body, File.read(File.join(@path, "B.md")).strip
|
||||
end
|
||||
=end
|
||||
|
||||
test "reverts multiple commits for a page" do
|
||||
page1 = @wiki.page('A')
|
||||
@@ -49,6 +48,7 @@ context "Page Reverting" do
|
||||
assert_equal "INITIAL", body=page2.raw_data.strip
|
||||
assert_equal body, File.read(File.join(@path, "A.md")).strip
|
||||
end
|
||||
=end
|
||||
|
||||
test "cannot revert conflicting commit" do
|
||||
page1 = @wiki.page('A')
|
||||
|
||||
+11
-2
@@ -19,7 +19,7 @@ context "Precious::Views::Pages" do
|
||||
|
||||
test "breadcrumb" do
|
||||
@page.instance_variable_set("@path", "Mordor/Eye-Of-Sauron/Saruman")
|
||||
@page.instance_variable_set("@base_url", "/")
|
||||
@page.instance_variable_set("@base_url", "")
|
||||
assert_equal '<a href="/pages/">Home</a> / <a href="/pages/Mordor/">Mordor</a> / <a href="/pages/Mordor/Eye-Of-Sauron/">Eye-Of-Sauron</a> / Saruman', @page.breadcrumb
|
||||
end
|
||||
|
||||
@@ -29,9 +29,18 @@ context "Precious::Views::Pages" do
|
||||
|
||||
test "files_folders" do
|
||||
@page.instance_variable_set("@path", "Mordor")
|
||||
@page.instance_variable_set("@base_url", "/")
|
||||
@page.instance_variable_set("@base_url", "")
|
||||
results = [FakeResult.new("Mordor/Eye-Of-Sauron.md"), FakeResult.new("Mordor/Orc/Saruman.md"), FakeResult.new("Mordor/.gitkeep")]
|
||||
@page.instance_variable_set("@results", results)
|
||||
assert_equal %{<li><a href="/Mordor/Eye-Of-Sauron" class="file">Eye Of Sauron</a></li>\n<li><a href="/pages/Mordor/Orc/" class="folder">Orc</a></li>}, @page.files_folders
|
||||
end
|
||||
|
||||
test "base url" do
|
||||
# based on test "files_folders"
|
||||
@page.instance_variable_set("@path", "Mordor")
|
||||
@page.instance_variable_set("@base_url", "/wiki")
|
||||
results = [FakeResult.new("Mordor/Eye-Of-Sauron.md"), FakeResult.new("Mordor/Orc/Saruman.md"), FakeResult.new("Mordor/.gitkeep")]
|
||||
@page.instance_variable_set("@results", results)
|
||||
assert_equal %{<li><a href="/wiki/Mordor/Eye-Of-Sauron" class="file">Eye Of Sauron</a></li>\n<li><a href="/wiki/pages/Mordor/Orc/" class="folder">Orc</a></li>}, @page.files_folders
|
||||
end
|
||||
end
|
||||
|
||||
+22
-1
@@ -15,12 +15,33 @@ context "Unicode Support" do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
|
||||
test "create and read non-latin page" do
|
||||
test "uri encode" do
|
||||
c = '한글'
|
||||
assert_equal '%ED%95%9C%EA%B8%80', encodeURIComponent(c)
|
||||
assert_equal '%ED%95%9C%EA%B8%80', CGI::escape(c)
|
||||
end
|
||||
|
||||
test "create and read non-latin page with anchor" do
|
||||
@wiki.write_page("test", :markdown, "# 한글")
|
||||
|
||||
page = @wiki.page("test")
|
||||
assert_equal Gollum::Page, page.class
|
||||
assert_equal "# 한글", utf8(page.raw_data)
|
||||
|
||||
# markup.rb
|
||||
# #简介
|
||||
# href.gsub('%', '%25') so the anchor works in Firefox.
|
||||
# <a href="#%25ED%2595%259C%25EA%25B8%2580" id="%ED%95%9C%EA%B8%80" class="anchor"></a>
|
||||
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 '#%25ED%2595%259C%25EA%25B8%2580', anchors[0]['href']
|
||||
assert_equal '%ED%95%9C%EA%B8%80', anchors[0]['id']
|
||||
assert_equal 'anchor', anchors[0]['class']
|
||||
assert_equal '', anchors[0].text
|
||||
end
|
||||
|
||||
test "unicode with existing format rules" do
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class WikiFactory
|
||||
def self.create p
|
||||
path = testpath "examples/test.git"
|
||||
Grit::Repo.init_bare(path)
|
||||
Gollum::Wiki.default_options = {:universal_toc => false}
|
||||
cleanup = Proc.new { FileUtils.rm_r File.join(File.dirname(__FILE__), *%w[examples test.git]) }
|
||||
wiki = Gollum::Wiki.new(path)
|
||||
return wiki, path, cleanup
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user