Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d0527f1aeb | |||
| 75083c5b56 | |||
| 82526594db | |||
| 941d39800c | |||
| a1ae2e8bc0 | |||
| 4af6f366ca | |||
| c7a9534ed9 | |||
| 00bcbbf72b | |||
| ed2254ff9f | |||
| b6633f0ecb | |||
| e08d2d3052 | |||
| fbc0548b43 | |||
| a9807bd1e1 | |||
| 554b80b39d | |||
| 99e74bf00b | |||
| f48e923f28 | |||
| 5400b4bfdd | |||
| f68bebe0f6 | |||
| 4c6019b439 | |||
| 66e08a6b17 | |||
| 7898db70ed | |||
| 7c357116ff | |||
| 69ce0eb0d0 | |||
| 4db31a297b | |||
| e1fca457e4 | |||
| 7f8485ce80 | |||
| 290061fd11 | |||
| a507836936 | |||
| 6524d20a96 | |||
| f1c523aa30 | |||
| 87c08f5613 | |||
| 82913cea20 | |||
| 2ad743e4bd | |||
| fa97b57a96 | |||
| 1b952b6d56 | |||
| 90cc512bd1 | |||
| b82556c9c0 | |||
| fbe3b4bb3b | |||
| 5ffd98ad31 | |||
| cb9dd4d228 | |||
| cd823bf10c | |||
| 5560ec52c2 | |||
| 065151a77f | |||
| 23454f556c | |||
| a2b3ddf931 | |||
| 44b0d2fcfc | |||
| aed4cc590a |
@@ -1,4 +1,4 @@
|
||||
source "http://rubygems.org"
|
||||
source 'http://rubygems.org'
|
||||
|
||||
gemspec
|
||||
gem "rake", "~> 0.9.2.2"
|
||||
gem 'rake', '~> 0.9'
|
||||
@@ -2,6 +2,7 @@ gollum -- A wiki built on top of Git
|
||||
====================================
|
||||
|
||||
[](http://travis-ci.org/github/gollum)
|
||||
[](https://gemnasium.com/github/gollum)
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
@@ -18,6 +19,11 @@ number of ways depending on your needs. You can edit your wiki locally:
|
||||
Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses
|
||||
[TomDoc](http://tomdoc.org/) for inline documentation.
|
||||
|
||||
## SYSTEM REQUIREMENTS
|
||||
- Python 2.5+ (2.7.3 recommended)
|
||||
- Ruby 1.8.7+ (1.9.3 recommended)
|
||||
- Unix like operating system (OS X, Ubuntu, Debian, and more)
|
||||
- Will not work on Windows (because of [grit](https://github.com/github/grit))
|
||||
|
||||
## INSTALLATION
|
||||
|
||||
@@ -357,25 +363,17 @@ appropriately.
|
||||
|
||||
## MATHEMATICAL EQUATIONS
|
||||
|
||||
Start gollum with the `--mathjax` flag. Read more about [MathJax](http://docs.mathjax.org/en/latest/index.html) on the web. Gollum uses the `TeX-AMS-MML_HTMLorMML` config with the `autoload-all` extension.
|
||||
|
||||
Page files may contain mathematic equations in TeX syntax that will be nicely
|
||||
typeset into the expected output. A block-style equation is delimited by `\[`
|
||||
and `\]`. For example:
|
||||
Inline math:
|
||||
|
||||
\[ P(E) = {n \choose k} p^k (1-p)^{ n-k} \]
|
||||
- $2^2$
|
||||
- `\\(2^2\\)`
|
||||
|
||||
Inline equations are delimited by `\(` and `\)`. These equations will appear
|
||||
inline with regular text. For example:
|
||||
Display math:
|
||||
|
||||
The Pythagorean theorem is \( a^2 + b^2 = c^2 \).
|
||||
|
||||
### INSTALLATION REQUIREMENTS
|
||||
|
||||
In order to get the mathematical equations rendering to work, you need the following binaries:
|
||||
|
||||
* LaTex, TeTex or MacTex/BasicTeX (pdflatex)
|
||||
* Netpbm (pnmcrop, pnmpad, pnmscale, ppmtopgm, pnmgamma, pnmtopng)
|
||||
* Ghostscript (gs)
|
||||
- $$2^2$$
|
||||
- [2^2]
|
||||
|
||||
## SEQUENCE DIAGRAMS
|
||||
|
||||
@@ -413,6 +411,17 @@ By default, internal wiki links are all absolute from the root. To specify a dif
|
||||
|
||||
wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
|
||||
|
||||
Note that base_path just modifies the links. To map gollum to a non-root location:
|
||||
|
||||
- Use the gollum binary: `gollum path/to/wiki --base-path mywiki`
|
||||
- Define config.ru with `map`. See [#532](https://github.com/github/gollum/issues/532) for an example.
|
||||
|
||||
> :base_path - String base path for all Wiki links.
|
||||
>
|
||||
> The String base path to prefix to internal links. For example, when set
|
||||
> to "/wiki", the page "Hobbit" will be linked as "/wiki/Hobbit". Defaults
|
||||
> to "/".
|
||||
|
||||
Get the latest version of the given human or canonical page name:
|
||||
|
||||
page = wiki.page('page-name')
|
||||
|
||||
@@ -114,6 +114,7 @@ task :release => :build do
|
||||
exit!
|
||||
end
|
||||
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
||||
sh "git pull"
|
||||
sh "git tag v#{version}"
|
||||
sh "git push origin master"
|
||||
sh "git push origin v#{version}"
|
||||
|
||||
+35
-1
@@ -68,6 +68,14 @@ opts = OptionParser.new do |opts|
|
||||
opts.on("--mathjax", "Enables mathjax.") do
|
||||
wiki_options[:mathjax] = true
|
||||
end
|
||||
|
||||
opts.on("--show-all", "Shows all files in file view. By default only valid pages are shown.") do
|
||||
wiki_options[:show_all] = true
|
||||
end
|
||||
|
||||
opts.on("--collapse-tree", "Collapse file view tree. By default, expanded tree is shown.") do
|
||||
wiki_options[:collapse_tree] = true
|
||||
end
|
||||
end
|
||||
|
||||
# Read command line options into `options` hash
|
||||
@@ -141,5 +149,31 @@ else
|
||||
require cfg
|
||||
end
|
||||
|
||||
Precious::App.run!(options)
|
||||
base_path = wiki_options[:base_path]
|
||||
|
||||
if wiki_options[:base_path].nil?
|
||||
Precious::App.run!(options)
|
||||
else
|
||||
require 'rack'
|
||||
|
||||
class MapGollum
|
||||
def initialize base_path
|
||||
@mg = Rack::Builder.new do
|
||||
map '/' do
|
||||
run Proc.new { [ 302, {'Location'=> "/#{base_path}" }, [] ] }
|
||||
end
|
||||
|
||||
map "/#{base_path}" do
|
||||
run Precious::App
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def call(env)
|
||||
@mg.call(env)
|
||||
end
|
||||
end
|
||||
# Rack::Handler does not work with Ctrl + C. Use Rack::Server instead.
|
||||
Rack::Server.new(:app => MapGollum.new(base_path), :Port => options['port']).start
|
||||
end
|
||||
end
|
||||
|
||||
+9
-11
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
||||
s.required_ruby_version = ">= 1.8.7"
|
||||
|
||||
s.name = 'gollum'
|
||||
s.version = '2.2.5'
|
||||
s.date = '2012-10-14'
|
||||
s.version = '2.3.3'
|
||||
s.date = '2012-10-23'
|
||||
s.rubyforge_project = 'gollum'
|
||||
|
||||
s.summary = "A simple, Git-powered wiki."
|
||||
@@ -26,22 +26,21 @@ Gem::Specification.new do |s|
|
||||
s.add_dependency('grit', '~> 2.5.0')
|
||||
s.add_dependency('github-markup', ['>= 0.7.4', '< 1.0.0'])
|
||||
s.add_dependency('github-markdown', '~> 0.5.1')
|
||||
s.add_dependency('pygments.rb', '~> 0.3.1')
|
||||
s.add_dependency('escape_utils', '0.2.4')
|
||||
s.add_dependency('pygments.rb', '~> 0.3.2')
|
||||
s.add_dependency('sinatra', '~> 1.3.3')
|
||||
s.add_dependency('mustache', ['>= 0.99.4', '< 1.0.0'])
|
||||
s.add_dependency('sanitize', '~> 2.0.3')
|
||||
s.add_dependency('nokogiri', '~> 1.5.5')
|
||||
s.add_dependency('useragent', '~> 0.4.10')
|
||||
s.add_dependency('useragent', '~> 0.4.12')
|
||||
s.add_dependency('stringex', '~> 1.4.0')
|
||||
|
||||
s.add_development_dependency('RedCloth', '~> 4.2.9')
|
||||
s.add_development_dependency('mocha', '~> 0.12.6')
|
||||
s.add_development_dependency('org-ruby', '~> 0.7.1')
|
||||
s.add_development_dependency('shoulda', '~> 3.1.1')
|
||||
s.add_development_dependency('mocha', '~> 0.12.7')
|
||||
s.add_development_dependency('org-ruby', '~> 0.7.2')
|
||||
s.add_development_dependency('shoulda', '~> 3.3.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')
|
||||
s.add_development_dependency('rake', '~> 0.9')
|
||||
|
||||
# = MANIFEST =
|
||||
s.files = %w[
|
||||
@@ -458,7 +457,6 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/page.rb
|
||||
lib/gollum/pagination.rb
|
||||
lib/gollum/sanitization.rb
|
||||
lib/gollum/tex.rb
|
||||
lib/gollum/web_sequence_diagram.rb
|
||||
lib/gollum/wiki.rb
|
||||
licenses/css_tree_menu_thecssninja/license.txt
|
||||
@@ -470,4 +468,4 @@ Gem::Specification.new do |s|
|
||||
# = MANIFEST =
|
||||
|
||||
s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
|
||||
end
|
||||
end
|
||||
|
||||
+1
-2
@@ -18,12 +18,11 @@ require File.expand_path('../gollum/file', __FILE__)
|
||||
require File.expand_path('../gollum/file_view', __FILE__)
|
||||
require File.expand_path('../gollum/markup', __FILE__)
|
||||
require File.expand_path('../gollum/sanitization', __FILE__)
|
||||
require File.expand_path('../gollum/tex', __FILE__)
|
||||
require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
|
||||
require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
|
||||
|
||||
module Gollum
|
||||
VERSION = '2.2.5'
|
||||
VERSION = '2.3.3'
|
||||
|
||||
def self.assets_path
|
||||
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
||||
|
||||
@@ -13,6 +13,22 @@ module Gollum
|
||||
@path = nil
|
||||
end
|
||||
|
||||
# Public: The url path required to reach this page within the repo.
|
||||
#
|
||||
# Returns the String url_path
|
||||
def url_path
|
||||
path = self.path
|
||||
path = path.sub(/\/[^\/]+$/, '/') if path.include?('/')
|
||||
path
|
||||
end
|
||||
|
||||
# Public: The url_path, but CGI escaped.
|
||||
#
|
||||
# Returns the String url_path
|
||||
def escaped_url_path
|
||||
CGI.escape(self.url_path).gsub('%2F','/')
|
||||
end
|
||||
|
||||
# Public: The on-disk filename of the file.
|
||||
#
|
||||
# Returns the String name.
|
||||
|
||||
+18
-4
@@ -5,8 +5,13 @@ module Gollum
|
||||
- Then all the folders are sorted and processed
|
||||
=end
|
||||
class FileView
|
||||
def initialize pages
|
||||
# common use cases:
|
||||
# set pages to wiki.pages and show_all to false
|
||||
# set pages to wiki.pages + wiki.files and show_all to true
|
||||
def initialize pages, options = {}
|
||||
@pages = pages
|
||||
@show_all = options[:show_all] || false
|
||||
@checked = options[:collapse_tree] ? '' : "checked"
|
||||
end
|
||||
|
||||
def enclose_tree string
|
||||
@@ -26,7 +31,7 @@ module Gollum
|
||||
def new_sub_folder path
|
||||
<<-HTML
|
||||
<li>
|
||||
<label>#{path}</label> <input type="checkbox" checked />
|
||||
<label>#{path}</label> <input type="checkbox" #{@checked} />
|
||||
<ol>
|
||||
HTML
|
||||
end
|
||||
@@ -39,7 +44,16 @@ module Gollum
|
||||
end
|
||||
|
||||
def url_for_page page
|
||||
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
|
||||
url = ''
|
||||
if @show_all
|
||||
# Remove ext for valid pages.
|
||||
filename = page.filename
|
||||
filename = Page::valid_page_name?(filename) ? filename.chomp(::File.extname(filename)) : filename
|
||||
|
||||
url = ::File.join(::File.dirname(page.path), filename)
|
||||
else
|
||||
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
|
||||
end
|
||||
url = url[2..-1] if url[0,2] == './'
|
||||
url
|
||||
end
|
||||
@@ -74,7 +88,7 @@ module Gollum
|
||||
url = url_for_page page
|
||||
html += <<-HTML
|
||||
<li>
|
||||
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" checked />
|
||||
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" #{@checked} />
|
||||
<ol>
|
||||
<li class="file"><a href="#{url}">#{name}</a></li>
|
||||
</ol>
|
||||
|
||||
@@ -86,7 +86,7 @@ module Precious
|
||||
end
|
||||
|
||||
get '/' do
|
||||
redirect File.join(settings.wiki_options[:base_path].to_s, 'Home')
|
||||
redirect File.join(settings.wiki_options[:page_file_dir].to_s,settings.wiki_options[:base_path].to_s, 'Home')
|
||||
end
|
||||
|
||||
# path is set to name if path is nil.
|
||||
@@ -145,6 +145,7 @@ module Precious
|
||||
page_name = CGI.unescape(params[:page])
|
||||
wiki = wiki_new
|
||||
page = wiki.paged(page_name, path, exact = true)
|
||||
return if page.nil?
|
||||
rename = params[:rename].to_url if params[:rename]
|
||||
name = rename || page.name
|
||||
committer = Gollum::Committer.new(wiki, commit_message)
|
||||
@@ -190,13 +191,20 @@ module Precious
|
||||
path = '' if path.nil?
|
||||
format = params[:format].intern
|
||||
|
||||
page_dir = File.join(settings.wiki_options[:page_file_dir].to_s,
|
||||
settings.wiki_options[:base_path].to_s)
|
||||
# Home is a special case.
|
||||
path = '' if name.downcase == 'home'
|
||||
|
||||
page_dir = File.join(page_dir, path)
|
||||
|
||||
# write_page is not directory aware so use wiki_options to emulate dir support.
|
||||
wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
|
||||
wiki_options = settings.wiki_options.merge({ :page_file_dir => page_dir })
|
||||
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
||||
|
||||
begin
|
||||
wiki.write_page(name, format, params[:content], commit_message)
|
||||
redirect to("/#{clean_url(CGI.escape(::File.join(path,name)))}")
|
||||
redirect to("/#{clean_url(CGI.escape(::File.join(page_dir,name)))}")
|
||||
rescue Gollum::DuplicatePageError => e
|
||||
@message = "Duplicate page: #{e.message}"
|
||||
mustache :error
|
||||
@@ -315,13 +323,19 @@ module Precious
|
||||
wiki_options = settings.wiki_options.merge({ :page_file_dir => @path })
|
||||
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
||||
@results = wiki.pages
|
||||
@results += wiki.files if settings.wiki_options[:show_all]
|
||||
@ref = wiki.ref
|
||||
mustache :pages
|
||||
end
|
||||
|
||||
get '/fileview' do
|
||||
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
|
||||
@results = Gollum::FileView.new(wiki.pages).render_files
|
||||
show_all = settings.wiki_options[:show_all]
|
||||
# if showing all files include wiki.files
|
||||
# must pass wiki_options for both because
|
||||
# --show-all and --collapse-tree can be set.
|
||||
@results = show_all ? Gollum::FileView.new(wiki.pages + wiki.files, settings.wiki_options).render_files :
|
||||
Gollum::FileView.new(wiki.pages, settings.wiki_options).render_files
|
||||
@ref = wiki.ref
|
||||
mustache :file_view, { :layout => false }
|
||||
end
|
||||
|
||||
@@ -18,7 +18,17 @@
|
||||
<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){
|
||||
{{#mathjax}}
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
tex2jax: {
|
||||
inlineMath: [ ['$','$'], ['\\(','\\)']],
|
||||
displayMath: [ ['$$','$$'], ['\[','\]'] ],
|
||||
processEscapes: true
|
||||
},
|
||||
TeX: { extensions: ["autoload-all.js"] }});
|
||||
</script>
|
||||
<script>(function(d,j){
|
||||
j = d.createElement('script');
|
||||
j.src = 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
|
||||
(d.head || d.getElementsByTagName('head')[0]).appendChild(j);
|
||||
|
||||
+9
-54
@@ -33,7 +33,6 @@ module Gollum
|
||||
@dir = ::File.dirname(page.path)
|
||||
@tagmap = {}
|
||||
@codemap = {}
|
||||
@texmap = {}
|
||||
@wsdmap = {}
|
||||
@premap = {}
|
||||
@toc = nil
|
||||
@@ -57,7 +56,6 @@ module Gollum
|
||||
data = extract_metadata(data)
|
||||
data = extract_gitcode(data)
|
||||
data = extract_code(data)
|
||||
data = extract_tex(data)
|
||||
data = extract_wsd(data)
|
||||
data = extract_tags(data)
|
||||
begin
|
||||
@@ -76,10 +74,9 @@ module Gollum
|
||||
doc,toc = process_headers(doc)
|
||||
@toc = @sub_page ? ( @parent_page ? @parent_page.toc_data : "[[_TOC_]]" ) : toc
|
||||
yield doc if block_given?
|
||||
data = doc.to_html
|
||||
data = doc.to_xhtml
|
||||
|
||||
data = process_toc_tags(data)
|
||||
data = process_tex(data)
|
||||
data = process_wsd(data)
|
||||
data.gsub!(/<p><\/p>/) do
|
||||
''
|
||||
@@ -95,16 +92,13 @@ module Gollum
|
||||
def process_headers(doc)
|
||||
toc = nil
|
||||
doc.css('h1,h2,h3,h4,h5,h6').each do |h|
|
||||
id = encodeURIComponent(h.content.gsub(' ','-'))
|
||||
# must escape "
|
||||
h_name = h.content.gsub(' ','-').gsub('"','%22')
|
||||
|
||||
level = h.name.gsub(/[hH]/,'').to_i
|
||||
|
||||
# Add anchors
|
||||
anchor = Nokogiri::XML::Node.new('a', doc)
|
||||
anchor['class'] = 'anchor'
|
||||
anchor['id'] = id
|
||||
# % -> %25 so anchors work on Firefox. See issue #475
|
||||
anchor['href'] = '#' + id.gsub('%', '%25')
|
||||
h.add_child(anchor)
|
||||
h.add_child(%Q{<a class="anchor" id="#{h_name}" href="##{h_name}"></a>})
|
||||
|
||||
# Build TOC
|
||||
toc ||= Nokogiri::XML::DocumentFragment.parse('<div class="toc"><div class="toc-title">Table of Contents</div></div>')
|
||||
@@ -122,54 +116,13 @@ module Gollum
|
||||
end
|
||||
node = Nokogiri::XML::Node.new('li', doc)
|
||||
# % -> %25 so anchors work on Firefox. See issue #475
|
||||
node.add_child(%Q{<a href="##{id.gsub("%", "%25")}">#{h.content}</a>})
|
||||
node.add_child(%Q{<a href="##{h_name}">#{h.content}</a>})
|
||||
tail.add_child(node)
|
||||
end
|
||||
toc = toc.to_xhtml if toc != nil
|
||||
[doc, toc]
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
# TeX
|
||||
#
|
||||
#########################################################################
|
||||
|
||||
# Extract all TeX into the texmap and replace with placeholders.
|
||||
#
|
||||
# data - The raw String data.
|
||||
#
|
||||
# Returns the placeholder'd String data.
|
||||
def extract_tex(data)
|
||||
data.gsub(/\\\[\s*(.*?)\s*\\\]/m) do
|
||||
tag = CGI.escapeHTML($1)
|
||||
id = Digest::SHA1.hexdigest(tag)
|
||||
@texmap[id] = [:block, tag]
|
||||
id
|
||||
end.gsub(/\\\(\s*(.*?)\s*\\\)/m) do
|
||||
tag = CGI.escapeHTML($1)
|
||||
id = Digest::SHA1.hexdigest(tag)
|
||||
@texmap[id] = [:inline, tag]
|
||||
id
|
||||
end
|
||||
end
|
||||
|
||||
# Process all TeX from the texmap and replace the placeholders with the
|
||||
# final markup.
|
||||
#
|
||||
# data - The String data (with placeholders).
|
||||
#
|
||||
# Returns the marked up String data.
|
||||
def process_tex(data)
|
||||
@texmap.each do |id, spec|
|
||||
type, tex = *spec
|
||||
data.gsub!(id) do
|
||||
Gollum::Tex.to_html(tex, type)
|
||||
end
|
||||
end
|
||||
data
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
# Tags
|
||||
@@ -590,7 +543,9 @@ module Gollum
|
||||
blocks.each do |lang, code|
|
||||
encoding ||= 'utf-8'
|
||||
begin
|
||||
hl_code = Pygments.highlight(code, :lexer => lang, :options => {:encoding => encoding.to_s})
|
||||
# must set startinline to true for php to be highlighted without <?
|
||||
# http://pygments.org/docs/lexers/
|
||||
hl_code = Pygments.highlight(code, :lexer => lang, :options => {:encoding => encoding.to_s, :startinline => true})
|
||||
rescue
|
||||
hl_code = code
|
||||
end
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
require 'escape_utils'
|
||||
|
||||
module Gollum
|
||||
module Tex
|
||||
TEX_URL = "http://www.mathtran.org/cgi-bin/toy/"
|
||||
TEX_SIZES = { :inline => 2, :block => 4 }
|
||||
|
||||
def self.to_html(tex, type = :inline)
|
||||
tex_uri = EscapeUtils.escape_uri(tex)
|
||||
tex_alt = EscapeUtils.escape_html(tex)
|
||||
%{<img src="#{TEX_URL}?D=#{TEX_SIZES[type]};tex=#{tex_uri}" alt="#{tex_alt}">}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -154,6 +154,9 @@ module Gollum
|
||||
# :ref - String the repository ref to retrieve pages from
|
||||
# :ws_subs - Array of chars to sub for ws in filenames.
|
||||
# :mathjax - Set to false to disable mathjax.
|
||||
# :show_all - Show all files in file view, not just valid pages.
|
||||
# Default: false
|
||||
# :collapse_tree - Start with collapsed file view. Default: false
|
||||
#
|
||||
# Returns a fresh Gollum::Repo.
|
||||
def initialize(path, options = {})
|
||||
@@ -180,6 +183,8 @@ module Gollum
|
||||
@live_preview = options.fetch(:live_preview, true)
|
||||
@universal_toc = options.fetch(:universal_toc, false)
|
||||
@mathjax = options[:mathjax] || false
|
||||
@show_all = options[:show_all] || false
|
||||
@collapse_tree = options[:collapse_tree] || false
|
||||
end
|
||||
|
||||
# Public: check whether the wiki's git repo exists on the filesystem.
|
||||
@@ -588,6 +593,13 @@ module Gollum
|
||||
# Toggles mathjax.
|
||||
attr_reader :mathjax
|
||||
|
||||
# Toggles showing all files in files view. Default is false.
|
||||
# When false, only valid pages in the git repo are displayed.
|
||||
attr_reader :show_all
|
||||
|
||||
# Start with collapsed file view. Default: false
|
||||
attr_reader :collapse_tree
|
||||
|
||||
# Normalize the data.
|
||||
#
|
||||
# data - The String data to be normalized.
|
||||
|
||||
+5
-1
@@ -184,7 +184,7 @@ context "Frontend" do
|
||||
name = "A"
|
||||
post "/create", :content => 'abc', :page => name,
|
||||
:format => 'markdown', :message => 'def'
|
||||
follow_redirect!
|
||||
|
||||
assert last_response.ok?
|
||||
|
||||
@wiki.clear_cache
|
||||
@@ -273,6 +273,9 @@ context "Frontend" do
|
||||
Precious::App.set(:wiki_options, { :base_path => '/wiki/' })
|
||||
get "/"
|
||||
assert_match "http://example.org/wiki/Home", last_response.headers['Location']
|
||||
|
||||
# Reset base path
|
||||
Precious::App.set(:wiki_options, { :base_path => nil })
|
||||
end
|
||||
|
||||
test "author details in session are used" do
|
||||
@@ -377,6 +380,7 @@ context "Frontend with lotr" do
|
||||
test "edit pages within sub-directories" do
|
||||
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
|
||||
assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
|
||||
|
||||
post "/edit/Mordor/Orc", :content => 'not so big smelly creatures',
|
||||
|
||||
@@ -12,6 +12,10 @@ class FakePage
|
||||
::File.basename(@filepath, ::File.extname(@filepath))
|
||||
end
|
||||
|
||||
def filename
|
||||
::File.basename(@filepath)
|
||||
end
|
||||
|
||||
def path
|
||||
return @filepath
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ context "gitcode" do
|
||||
end
|
||||
|
||||
test 'that the rendered output is correctly fetched and rendered as html code' do
|
||||
assert_equal %Q{<p>a</p>\n\n<div class=\"highlight\"><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
|
||||
assert_equal %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"nt\"><ol</span> <span class=\"na\">class=</span><span class=\"s\">\"tree\"</span><span class=\"nt\">></span>\n <span class=\"nt\"><li</span> <span class=\"na\">class=</span><span class=\"s\">\"file\"</span><span class=\"nt\">><a</span> <span class=\"na\">href=</span><span class=\"s\">\"0\"</span><span class=\"nt\">></span>0<span class=\"nt\"></a></li></span>\n<span class=\"nt\"></ol></span>\n</pre>\n</div>\n\n<p>b</p>}, @rendered
|
||||
end
|
||||
|
||||
test 'contents' do
|
||||
|
||||
+30
-48
@@ -193,7 +193,7 @@ context "Markup" do
|
||||
test "wiki link within inline code block" do
|
||||
@wiki.write_page("Potato", :markdown, "`sed -i '' 's/[[:space:]]*$//'`", commit_details)
|
||||
page = @wiki.page("Potato")
|
||||
assert_equal "<p><code>sed -i '' 's/[[:space:]]*$//'</code></p>", page.formatted_data
|
||||
assert_equal "<p>\n <code>sed -i '' 's/[[:space:]]*$//'</code>\n</p>", page.formatted_data
|
||||
end
|
||||
|
||||
test "regexp gsub! backref (#383)" do
|
||||
@@ -208,7 +208,7 @@ context "Markup" do
|
||||
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
|
||||
expected = %Q{<pre>\n <code> <div class=\"highlight\"><pre><span class=\"n\">rot13</span><span class=\"p\">=</span><span class=\"s\">'tr '</span><span class=\"o\">\\</span><span class=\"s\">''</span><span class=\"n\">A</span><span class=\"o\">-</span><span class=\"n\">Za</span><span class=\"o\">-</span><span class=\"n\">z</span><span class=\"o\">'\\</span><span class=\"s\">''</span> <span class=\"s\">'\\''N-ZA-Mn-za-m'</span><span class=\"o\">\\</span><span class=\"s\">'</span>\n</pre></div>\n</code>\n</pre>}
|
||||
assert_equal expected, output
|
||||
end
|
||||
|
||||
@@ -220,7 +220,7 @@ context "Markup" do
|
||||
~~~
|
||||
), commit_details)
|
||||
output = @wiki.page(page).formatted_data
|
||||
expected = %Q{<div class=\"highlight\"><pre><span class=\"s1\">'hi'</span>\n</pre></div>}
|
||||
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"s1\">'hi'</span>\n</pre>\n</div>}
|
||||
assert_equal expected, output
|
||||
end
|
||||
|
||||
@@ -232,7 +232,7 @@ context "Markup" do
|
||||
~~~
|
||||
), commit_details)
|
||||
output = @wiki.page(page).formatted_data
|
||||
expected = %Q{<div class=\"highlight\"><pre><span class=\"s1\">'hi'</span>\n</pre></div>}
|
||||
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"s1\">'hi'</span>\n</pre>\n</div>}
|
||||
assert_equal expected, output
|
||||
end
|
||||
|
||||
@@ -245,20 +245,20 @@ context "Markup" do
|
||||
~~~~~~
|
||||
), commit_details)
|
||||
output = @wiki.page(page).formatted_data
|
||||
expected = %Q{<div class=\"highlight\"><pre><span class=\"o\">~~</span>\n<span class=\"s1\">'hi'</span><span class=\"o\">~</span>\n</pre></div>}
|
||||
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"o\">~~</span>\n<span class=\"s1\">'hi'</span><span class=\"o\">~</span>\n</pre>\n</div>}
|
||||
assert_equal expected, output
|
||||
end
|
||||
|
||||
test "wiki link within code block" do
|
||||
@wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details)
|
||||
page = @wiki.page("Potato")
|
||||
assert_equal "<pre><code>sed -i '' 's/[[:space:]]*$//'\n</code></pre>", page.formatted_data
|
||||
assert_equal "<pre>\n <code>sed -i '' 's/[[:space:]]*$//'\n</code>\n</pre>", page.formatted_data
|
||||
end
|
||||
|
||||
test "piped wiki link within code block" do
|
||||
@wiki.write_page("Potato", :markdown, "`make a link [[home|sweet home]]`", commit_details)
|
||||
page = @wiki.page("Potato")
|
||||
assert_equal "<p><code>make a link [[home|sweet home]]</code></p>", page.formatted_data
|
||||
assert_equal "<p>\n <code>make a link [[home|sweet home]]</code>\n</p>", page.formatted_data
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
@@ -274,7 +274,7 @@ context "Markup" do
|
||||
|
||||
page = @wiki.page(name)
|
||||
output = page.formatted_data
|
||||
assert_equal %{<p>a <img src="#{scheme}://example.com/bilbo.jpg"> b</p>}, output
|
||||
assert_equal %{<p>a <img src=\"#{scheme}://example.com/bilbo.jpg\" /> b</p>}, output
|
||||
end
|
||||
end
|
||||
|
||||
@@ -285,7 +285,7 @@ context "Markup" do
|
||||
|
||||
page = @wiki.page(name)
|
||||
output = page.formatted_data
|
||||
assert_equal %{<p>a <img src="#{scheme}://example.com/bilbo.JPG"> b</p>}, output
|
||||
assert_equal %{<p>a <img src=\"#{scheme}://example.com/bilbo.JPG\" /> b</p>}, output
|
||||
end
|
||||
end
|
||||
|
||||
@@ -297,7 +297,7 @@ context "Markup" do
|
||||
@wiki.write_page("Bilbo Baggins", :markdown, "a [[/alpha.jpg]] [[a | /alpha.jpg]] b", commit_details)
|
||||
|
||||
page = @wiki.page("Bilbo Baggins")
|
||||
assert_equal %{<p>a <img src="/wiki/alpha.jpg"><a href="/wiki/alpha.jpg">a</a> b</p>}, page.formatted_data
|
||||
assert_equal %{<p>a <img src=\"/wiki/alpha.jpg\" /><a href=\"/wiki/alpha.jpg\">a</a> b</p>}, page.formatted_data
|
||||
end
|
||||
|
||||
test "image with relative path on root" do
|
||||
@@ -308,7 +308,7 @@ context "Markup" do
|
||||
index.commit("Add alpha.jpg")
|
||||
|
||||
page = @wiki.page("Bilbo Baggins")
|
||||
assert_equal %{<p>a <img src="/wiki/alpha.jpg"><a href="/wiki/alpha.jpg">a</a> b</p>}, page.formatted_data
|
||||
assert_equal %Q{<p>a <img src=\"/wiki/alpha.jpg\" /><a href=\"/wiki/alpha.jpg\">a</a> b</p>}, page.formatted_data
|
||||
end
|
||||
|
||||
test "image with relative path" do
|
||||
@@ -320,7 +320,7 @@ context "Markup" do
|
||||
|
||||
page = @wiki.page("Bilbo Baggins")
|
||||
output = page.formatted_data
|
||||
assert_equal %{<p>a <img src="/wiki/greek/alpha.jpg"><a href="/wiki/greek/alpha.jpg">a</a> b</p>}, output
|
||||
assert_equal %{<p>a <img src=\"/wiki/greek/alpha.jpg\" /><a href=\"/wiki/greek/alpha.jpg\">a</a> b</p>}, output
|
||||
end
|
||||
|
||||
test "image with absolute path on a preview" do
|
||||
@@ -330,7 +330,7 @@ context "Markup" do
|
||||
index.commit("Add alpha.jpg")
|
||||
|
||||
page = @wiki.preview_page("Test", "a [[/alpha.jpg]] b", :markdown)
|
||||
assert_equal %{<p>a <img src="/wiki/alpha.jpg"> b</p>}, page.formatted_data
|
||||
assert_equal %{<p>a <img src=\"/wiki/alpha.jpg\" /> b</p>}, page.formatted_data
|
||||
end
|
||||
|
||||
test "image with relative path on a preview" do
|
||||
@@ -341,12 +341,12 @@ context "Markup" do
|
||||
index.commit("Add alpha.jpg")
|
||||
|
||||
page = @wiki.preview_page("Test", "a [[alpha.jpg]] [[greek/alpha.jpg]] b", :markdown)
|
||||
assert_equal %{<p>a <img src="/wiki/alpha.jpg"><img src="/wiki/greek/alpha.jpg"> b</p>}, page.formatted_data
|
||||
assert_equal %{<p>a <img src=\"/wiki/alpha.jpg\" /><img src=\"/wiki/greek/alpha.jpg\" /> b</p>}, page.formatted_data
|
||||
end
|
||||
|
||||
test "image with alt" do
|
||||
content = "a [[alpha.jpg|alt=Alpha Dog]] b"
|
||||
output = %{<p>a <img src="/greek/alpha.jpg" alt="Alpha Dog"> b</p>}
|
||||
output = %{<p>a<imgsrc=\"/greek/alpha.jpg\"alt=\"AlphaDog\"/>b</p>}
|
||||
relative_image(content, output)
|
||||
end
|
||||
|
||||
@@ -354,7 +354,7 @@ context "Markup" do
|
||||
%w{em px}.each do |unit|
|
||||
%w{width height}.each do |dim|
|
||||
content = "a [[alpha.jpg|#{dim}=100#{unit}]] b"
|
||||
output = "<p>a <img src=\"/greek/alpha.jpg\" #{dim}=\"100#{unit}\"> b</p>"
|
||||
output = "<p>a<imgsrc=\"/greek/alpha.jpg\"#{dim}=\"100#{unit}\"/>b</p>"
|
||||
relative_image(content, output)
|
||||
end
|
||||
end
|
||||
@@ -363,7 +363,7 @@ context "Markup" do
|
||||
test "image with bogus dimension" do
|
||||
%w{width height}.each do |dim|
|
||||
content = "a [[alpha.jpg|#{dim}=100]] b"
|
||||
output = "<p>a <img src=\"/greek/alpha.jpg\"> b</p>"
|
||||
output = "<p>a<imgsrc=\"/greek/alpha.jpg\"/>b</p>"
|
||||
relative_image(content, output)
|
||||
end
|
||||
end
|
||||
@@ -371,7 +371,7 @@ context "Markup" do
|
||||
test "image with vertical align" do
|
||||
%w{top texttop middle absmiddle bottom absbottom baseline}.each do |align|
|
||||
content = "a [[alpha.jpg|align=#{align}]] b"
|
||||
output = "<p>a <img src=\"/greek/alpha.jpg\" align=\"#{align}\"> b</p>"
|
||||
output = %Q{<p>a<imgsrc=\"/greek/alpha.jpg\"align=\"#{align}\"/>b</p>}
|
||||
relative_image(content, output)
|
||||
end
|
||||
end
|
||||
@@ -379,40 +379,40 @@ context "Markup" do
|
||||
test "image with horizontal align" do
|
||||
%w{left center right}.each do |align|
|
||||
content = "a [[alpha.jpg|align=#{align}]] b"
|
||||
output = "<p>a <span class=\"align-#{align}\"><span><img src=\"/greek/alpha.jpg\"></span></span> b</p>"
|
||||
output = "<p>a<spanclass=\"align-#{align}\"><span><imgsrc=\"/greek/alpha.jpg\"/></span></span>b</p>"
|
||||
relative_image(content, output)
|
||||
end
|
||||
end
|
||||
|
||||
test "image with float" do
|
||||
content = "a\n\n[[alpha.jpg|float]]\n\nb"
|
||||
output = "<p>a</p>\n\n<p><span class=\"float-left\"><span><img src=\"/greek/alpha.jpg\"></span></span></p>\n\n<p>b</p>"
|
||||
output = "<p>a</p><p><spanclass=\"float-left\"><span><imgsrc=\"/greek/alpha.jpg\"/></span></span></p><p>b</p>"
|
||||
relative_image(content, output)
|
||||
end
|
||||
|
||||
test "image with float and align" do
|
||||
%w{left right}.each do |align|
|
||||
content = "a\n\n[[alpha.jpg|float|align=#{align}]]\n\nb"
|
||||
output = "<p>a</p>\n\n<p><span class=\"float-#{align}\"><span><img src=\"/greek/alpha.jpg\"></span></span></p>\n\n<p>b</p>"
|
||||
output = "<p>a</p><p><spanclass=\"float-#{align}\"><span><imgsrc=\"/greek/alpha.jpg\"/></span></span></p><p>b</p>"
|
||||
relative_image(content, output)
|
||||
end
|
||||
end
|
||||
|
||||
test "image with frame" do
|
||||
content = "a\n\n[[alpha.jpg|frame]]\n\nb"
|
||||
output = "<p>a</p>\n\n<p><span class=\"frame\"><span><img src=\"/greek/alpha.jpg\"></span></span></p>\n\n<p>b</p>"
|
||||
output = "<p>a</p><p><spanclass=\"frame\"><span><imgsrc=\"/greek/alpha.jpg\"/></span></span></p><p>b</p>"
|
||||
relative_image(content, output)
|
||||
end
|
||||
|
||||
test "absolute image with frame" do
|
||||
content = "a\n\n[[http://example.com/bilbo.jpg|frame]]\n\nb"
|
||||
output = "<p>a</p>\n\n<p><span class=\"frame\"><span><img src=\"http://example.com/bilbo.jpg\"></span></span></p>\n\n<p>b</p>"
|
||||
output = "<p>a</p><p><spanclass=\"frame\"><span><imgsrc=\"http://example.com/bilbo.jpg\"/></span></span></p><p>b</p>"
|
||||
relative_image(content, output)
|
||||
end
|
||||
|
||||
test "image with frame and alt" do
|
||||
content = "a\n\n[[alpha.jpg|frame|alt=Alpha]]\n\nb"
|
||||
output = "<p>a</p>\n\n<p><span class=\"frame\"><span><img src=\"/greek/alpha.jpg\" alt=\"Alpha\"><span>Alpha</span></span></span></p>\n\n<p>b</p>"
|
||||
output = "<p>a</p><p><spanclass=\"frame\"><span><imgsrc=\"/greek/alpha.jpg\"alt=\"Alpha\"/><span>Alpha</span></span></span></p><p>b</p>"
|
||||
relative_image(content, output)
|
||||
end
|
||||
|
||||
@@ -461,7 +461,7 @@ context "Markup" do
|
||||
|
||||
test "code blocks" do
|
||||
content = "a\n\n```ruby\nx = 1\n```\n\nb"
|
||||
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>}
|
||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>}
|
||||
|
||||
index = @wiki.repo.index
|
||||
index.add("Bilbo-Baggins.md", content)
|
||||
@@ -474,7 +474,7 @@ context "Markup" do
|
||||
|
||||
test "code blocks with carriage returns" do
|
||||
content = "a\r\n\r\n```ruby\r\nx = 1\r\n```\r\n\r\nb"
|
||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre></div>\n\n<p>b</p>}
|
||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>}
|
||||
|
||||
index = @wiki.repo.index
|
||||
index.add("Bilbo-Baggins.md", content)
|
||||
@@ -505,7 +505,7 @@ context "Markup" do
|
||||
|
||||
test "code blocks with multibyte caracters indent" do
|
||||
content = "a\n\n```ruby\ns = 'やくしまるえつこ'\n```\n\nb"
|
||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">s</span> <span class=\"o\">=</span> <span class=\"s1\">'やくしまるえつこ'</span>\n</pre></div>\n\n<p>b</p>}
|
||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">s</span> <span class=\"o\">=</span> <span class=\"s1\">'やくしまるえつこ'</span>\n</pre>\n</div>\n\n<p>b</p>}
|
||||
index = @wiki.repo.index
|
||||
index.add("Bilbo-Baggins.md", content)
|
||||
index.commit("Add alpha.jpg")
|
||||
@@ -565,7 +565,7 @@ np.array([[2,2],[1,3]],np.float)
|
||||
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
|
||||
assert_equal %Q{<div class=\"highlight\">\n <pre><span class=\"nt\"><p></span>a b<span class=\"nt\"></p></span>\n</pre>\n</div>}, output_page
|
||||
end
|
||||
|
||||
test "embed code page absolute link" do
|
||||
@@ -574,7 +574,7 @@ np.array([[2,2],[1,3]],np.float)
|
||||
|
||||
page = @wiki.page("a")
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\n</p><div class=\"highlight\"><pre><span class=\"nt\"><p></span>a\n!base<span class=\"nt\"></p></span>\n</pre></div>\n}, output
|
||||
assert_equal %Q{<p>a\n</p><div class=\"highlight\">\n <pre><span class=\"nt\"><p></span>a\n!base<span class=\"nt\"></p></span>\n</pre>\n</div>\n}, output
|
||||
end
|
||||
|
||||
test "embed code page relative link" do
|
||||
@@ -583,7 +583,7 @@ np.array([[2,2],[1,3]],np.float)
|
||||
|
||||
page = @wiki.page("a")
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\n</p><div class=\"highlight\"><pre><span class=\"nt\"><p></span>a\n!rel<span class=\"nt\"></p></span>\n</pre></div>\n}, output
|
||||
assert_equal %Q{<p>a\n</p><div class=\"highlight\">\n <pre><span class=\"nt\"><p></span>a\n!rel<span class=\"nt\"></p></span>\n</pre>\n</div>\n}, output
|
||||
end
|
||||
|
||||
test "code block in unsupported language" do
|
||||
@@ -758,24 +758,6 @@ end
|
||||
]
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
# TeX
|
||||
#
|
||||
#########################################################################
|
||||
|
||||
test "TeX block syntax" do
|
||||
content = 'a \[ a^2 \] b'
|
||||
output = "<p>a<imgsrc=\"http://www.mathtran.org/cgi-bin/toy/?D=4;tex=a%5E2\"alt=\"a^2\">b</p>"
|
||||
compare(content, output, 'md')
|
||||
end
|
||||
|
||||
test "TeX inline syntax" do
|
||||
content = 'a \( a^2 \) b'
|
||||
output = "<p>a<imgsrc=\"http://www.mathtran.org/cgi-bin/toy/?D=2;tex=a%5E2\"alt=\"a^2\">b</p>"
|
||||
compare(content, output, 'md')
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
# Asciidoc
|
||||
#########################################################################
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ context "Page" do
|
||||
page = @wiki.page('Bilbo Baggins')
|
||||
assert_equal Gollum::Page, page.class
|
||||
assert page.raw_data =~ /^# Bilbo Baggins\n\nBilbo Baggins/
|
||||
assert page.formatted_data =~ %r{<h1>Bilbo Baggins<a class="anchor" id="Bilbo-Baggins" href="#Bilbo-Baggins"></a>\n</h1>\n\n<p>Bilbo Baggins}
|
||||
assert page.formatted_data =~ %r{<h1>Bilbo Baggins<a class="anchor" id="Bilbo-Baggins" href="#Bilbo-Baggins"></a></h1>\n\n<p>Bilbo Baggins}
|
||||
assert_equal 'Bilbo-Baggins.md', page.path
|
||||
assert_equal :markdown, page.format
|
||||
assert_equal @wiki.repo.commits.first.id, page.version.id
|
||||
|
||||
+24
-7
@@ -29,19 +29,36 @@ context "Unicode Support" do
|
||||
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
|
||||
assert_equal '#한글', anchors[0]['href']
|
||||
assert_equal '한글', anchors[0]['id']
|
||||
assert_equal 'anchor', anchors[0]['class']
|
||||
assert_equal '', anchors[0].text
|
||||
end
|
||||
|
||||
test "create and read non-latin page with anchor 2" do
|
||||
@wiki.write_page("test", :markdown, "# \"La\" faune d'Édiacara")
|
||||
|
||||
page = @wiki.page("test")
|
||||
assert_equal Gollum::Page, page.class
|
||||
assert_equal "# \"La\" faune d'Édiacara", utf8(page.raw_data)
|
||||
|
||||
# markup.rb test: ', ", É
|
||||
doc = Nokogiri::HTML page.formatted_data
|
||||
h1s = doc / :h1
|
||||
h1 = h1s.first
|
||||
anchors = h1 / :a
|
||||
assert_equal 1, h1s.size
|
||||
assert_equal 1, anchors.size
|
||||
assert_equal %q(#%22La%22-faune-d'Édiacara), anchors[0]['href']
|
||||
assert_equal %q(%22La%22-faune-d'Édiacara), anchors[0]['id']
|
||||
assert_equal 'anchor', anchors[0]['class']
|
||||
assert_equal '', anchors[0].text
|
||||
end
|
||||
|
||||
test "unicode with existing format rules" do
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ context "Wiki page previewing" do
|
||||
test "preview_page" do
|
||||
page = @wiki.preview_page("Test", "# Bilbo", :markdown)
|
||||
assert_equal "# Bilbo", page.raw_data
|
||||
assert_equal %Q{<h1>Bilbo<a class="anchor" id="Bilbo" href="#Bilbo"></a>\n</h1>}, page.formatted_data
|
||||
assert_equal %Q{<h1>Bilbo<a class=\"anchor\" id=\"Bilbo\" href=\"#Bilbo\"></a></h1>}, page.formatted_data
|
||||
assert_equal "Test.md", page.filename
|
||||
assert_equal "Test", page.name
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user