Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2686e96046 | |||
| 213e2bb432 | |||
| 79bb5c10ab | |||
| 7ea012d786 | |||
| 43591f75de | |||
| 05d82c0569 | |||
| 76c8d3206c | |||
| 00751d05b4 | |||
| b5be5df11a | |||
| 7d159273fc | |||
| 70127922ab | |||
| b95df93775 | |||
| dc06edcf5b | |||
| fdc437dcd5 | |||
| f6873c9612 | |||
| 93754ab32d | |||
| 5759334635 | |||
| f2f543b72d | |||
| 598b052be3 | |||
| a746062422 | |||
| c8868d369f | |||
| 52c6e7474c | |||
| be81f09b0e | |||
| 6fa4504e31 | |||
| 992ba01a12 | |||
| 72c5a74cf1 | |||
| 919f41a0f1 | |||
| 785921cb0f | |||
| 8c8cda5e7d | |||
| 64ef74e7e9 | |||
| 776df4e6ee | |||
| 68465a8651 | |||
| fa16c8960c | |||
| 2c57915781 | |||
| d0527f1aeb | |||
| 75083c5b56 | |||
| 82526594db | |||
| 941d39800c | |||
| a1ae2e8bc0 | |||
| 4af6f366ca | |||
| c7a9534ed9 | |||
| 00bcbbf72b | |||
| ed2254ff9f | |||
| b6633f0ecb | |||
| e08d2d3052 | |||
| fbc0548b43 | |||
| a9807bd1e1 | |||
| 554b80b39d |
@@ -363,7 +363,17 @@ appropriately.
|
|||||||
|
|
||||||
## MATHEMATICAL EQUATIONS
|
## 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.
|
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.
|
||||||
|
|
||||||
|
Inline math:
|
||||||
|
|
||||||
|
- $2^2$
|
||||||
|
- `\\(2^2\\)`
|
||||||
|
|
||||||
|
Display math:
|
||||||
|
|
||||||
|
- $$2^2$$
|
||||||
|
- [2^2]
|
||||||
|
|
||||||
## SEQUENCE DIAGRAMS
|
## SEQUENCE DIAGRAMS
|
||||||
|
|
||||||
@@ -371,10 +381,10 @@ You may imbed sequence diagrams into your wiki page (rendered by
|
|||||||
[WebSequenceDiagrams](http://www.websequencediagrams.com) by using the
|
[WebSequenceDiagrams](http://www.websequencediagrams.com) by using the
|
||||||
following syntax:
|
following syntax:
|
||||||
|
|
||||||
{{{ blue-modern
|
{{{{{{ blue-modern
|
||||||
alice->bob: Test
|
alice->bob: Test
|
||||||
bob->alice: Test response
|
bob->alice: Test response
|
||||||
}}}
|
}}}}}}
|
||||||
|
|
||||||
You can replace the string "blue-modern" with any supported style.
|
You can replace the string "blue-modern" with any supported style.
|
||||||
|
|
||||||
@@ -522,9 +532,9 @@ Your Rack middleware can pass author details to Gollum in a Hash in the session
|
|||||||
## WINDOWS FILENAME VALIDATION
|
## 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.
|
Note that filenames on windows must not contain any of the following characters `\ / : * ? " < > |`. See [this support article](http://support.microsoft.com/kb/177506) for details.
|
||||||
|
|
||||||
## LIB.SO ERROR
|
## CONFIG FILE
|
||||||
|
|
||||||
`Could not open library 'lib.so'` may be solved by installing `python-devel` on Fedora or `python-dev` on Ubuntu. Gentoo requires a rubypython [patch](https://gist.github.com/2802480) to use python2.7.
|
Gollum optionaly takes a `--config file`. See [config.rb](https://github.com/github/gollum/blob/master/config.rb) for an example.
|
||||||
|
|
||||||
## CONTRIBUTE
|
## CONTRIBUTE
|
||||||
|
|
||||||
@@ -546,6 +556,8 @@ your changes merged back into core is as follows:
|
|||||||
1. Send a pull request to the github/gollum project.
|
1. Send a pull request to the github/gollum project.
|
||||||
|
|
||||||
## RELEASING
|
## RELEASING
|
||||||
|
x.y.z
|
||||||
|
|
||||||
For z releases:
|
For z releases:
|
||||||
$ rake bump
|
$ rake bump
|
||||||
$ rake release
|
$ rake release
|
||||||
|
|||||||
@@ -113,8 +113,8 @@ task :release => :build do
|
|||||||
puts "You must be on the master branch to release!"
|
puts "You must be on the master branch to release!"
|
||||||
exit!
|
exit!
|
||||||
end
|
end
|
||||||
sh "git pull"
|
|
||||||
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
||||||
|
sh "git pull"
|
||||||
sh "git tag v#{version}"
|
sh "git tag v#{version}"
|
||||||
sh "git push origin master"
|
sh "git push origin master"
|
||||||
sh "git push origin v#{version}"
|
sh "git push origin v#{version}"
|
||||||
|
|||||||
@@ -68,6 +68,14 @@ opts = OptionParser.new do |opts|
|
|||||||
opts.on("--mathjax", "Enables mathjax.") do
|
opts.on("--mathjax", "Enables mathjax.") do
|
||||||
wiki_options[:mathjax] = true
|
wiki_options[:mathjax] = true
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
# Read command line options into `options` hash
|
# Read command line options into `options` hash
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Example gollum config
|
||||||
|
# gollum ../wiki --config config.rb
|
||||||
|
#
|
||||||
|
# or run from source with
|
||||||
|
#
|
||||||
|
# bundle exec bin/gollum ../wiki/ --config config.rb
|
||||||
|
|
||||||
|
# Remove const to avoid
|
||||||
|
# warning: already initialized constant FORMAT_NAMES
|
||||||
|
#
|
||||||
|
# only remove if it's defined.
|
||||||
|
# constant Gollum::Page::FORMAT_NAMES not defined (NameError)
|
||||||
|
Gollum::Page.send :remove_const, :FORMAT_NAMES if defined? Gollum::Page::FORMAT_NAMES
|
||||||
|
# limit to one format
|
||||||
|
Gollum::Page::FORMAT_NAMES = { :markdown => "Markdown" }
|
||||||
|
|
||||||
|
=begin
|
||||||
|
Valid formats are:
|
||||||
|
{ :markdown => "Markdown",
|
||||||
|
:textile => "Textile",
|
||||||
|
:rdoc => "RDoc",
|
||||||
|
:org => "Org-mode",
|
||||||
|
:creole => "Creole",
|
||||||
|
:rest => "reStructuredText",
|
||||||
|
:asciidoc => "AsciiDoc",
|
||||||
|
:mediawiki => "MediaWiki",
|
||||||
|
:pod => "Pod" }
|
||||||
|
=end
|
||||||
+7
-2
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
|||||||
s.required_ruby_version = ">= 1.8.7"
|
s.required_ruby_version = ">= 1.8.7"
|
||||||
|
|
||||||
s.name = 'gollum'
|
s.name = 'gollum'
|
||||||
s.version = '2.3.1'
|
s.version = '2.3.8'
|
||||||
s.date = '2012-10-21'
|
s.date = '2012-11-07'
|
||||||
s.rubyforge_project = 'gollum'
|
s.rubyforge_project = 'gollum'
|
||||||
|
|
||||||
s.summary = "A simple, Git-powered wiki."
|
s.summary = "A simple, Git-powered wiki."
|
||||||
@@ -41,6 +41,9 @@ Gem::Specification.new do |s|
|
|||||||
s.add_development_dependency('rack-test', '~> 0.6.2')
|
s.add_development_dependency('rack-test', '~> 0.6.2')
|
||||||
s.add_development_dependency('wikicloth', '~> 0.8.0')
|
s.add_development_dependency('wikicloth', '~> 0.8.0')
|
||||||
s.add_development_dependency('rake', '~> 0.9')
|
s.add_development_dependency('rake', '~> 0.9')
|
||||||
|
s.add_development_dependency('pry', '~> 0.9.10')
|
||||||
|
# required by pry
|
||||||
|
s.add_development_dependency('rb-readline', '~> 0.4.2')
|
||||||
|
|
||||||
# = MANIFEST =
|
# = MANIFEST =
|
||||||
s.files = %w[
|
s.files = %w[
|
||||||
@@ -50,6 +53,7 @@ Gem::Specification.new do |s|
|
|||||||
README.md
|
README.md
|
||||||
Rakefile
|
Rakefile
|
||||||
bin/gollum
|
bin/gollum
|
||||||
|
config.rb
|
||||||
docs/sanitization.md
|
docs/sanitization.md
|
||||||
gollum.gemspec
|
gollum.gemspec
|
||||||
lib/gollum.rb
|
lib/gollum.rb
|
||||||
@@ -92,6 +96,7 @@ Gem::Specification.new do |s|
|
|||||||
lib/gollum/frontend/public/gollum/javascript/mousetrap.min.js
|
lib/gollum/frontend/public/gollum/javascript/mousetrap.min.js
|
||||||
lib/gollum/frontend/public/gollum/livepreview/css/custom.css
|
lib/gollum/frontend/public/gollum/livepreview/css/custom.css
|
||||||
lib/gollum/frontend/public/gollum/livepreview/images/cancel_24.png
|
lib/gollum/frontend/public/gollum/livepreview/images/cancel_24.png
|
||||||
|
lib/gollum/frontend/public/gollum/livepreview/images/globe_24.png
|
||||||
lib/gollum/frontend/public/gollum/livepreview/images/lr_24.png
|
lib/gollum/frontend/public/gollum/livepreview/images/lr_24.png
|
||||||
lib/gollum/frontend/public/gollum/livepreview/images/save_24.png
|
lib/gollum/frontend/public/gollum/livepreview/images/save_24.png
|
||||||
lib/gollum/frontend/public/gollum/livepreview/images/savecomment_24.png
|
lib/gollum/frontend/public/gollum/livepreview/images/savecomment_24.png
|
||||||
|
|||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
# stdlib
|
# stdlib
|
||||||
require 'digest/md5'
|
require 'digest/md5'
|
||||||
require 'ostruct'
|
require 'ostruct'
|
||||||
@@ -22,7 +23,7 @@ require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
|
|||||||
require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
|
require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
|
||||||
|
|
||||||
module Gollum
|
module Gollum
|
||||||
VERSION = '2.3.1'
|
VERSION = '2.3.8'
|
||||||
|
|
||||||
def self.assets_path
|
def self.assets_path
|
||||||
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
module Gollum
|
module Gollum
|
||||||
class BlobEntry
|
class BlobEntry
|
||||||
# Gets the String SHA for this blob.
|
# Gets the String SHA for this blob.
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
module Gollum
|
module Gollum
|
||||||
# Responsible for handling the commit process for a Wiki. It sets up the
|
# Responsible for handling the commit process for a Wiki. It sets up the
|
||||||
# Git index, provides methods for modifying the tree, and stores callbacks
|
# Git index, provides methods for modifying the tree, and stores callbacks
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
module Gollum
|
module Gollum
|
||||||
class File
|
class File
|
||||||
Wiki.file_class = self
|
Wiki.file_class = self
|
||||||
@@ -13,6 +14,22 @@ module Gollum
|
|||||||
@path = nil
|
@path = nil
|
||||||
end
|
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.
|
# Public: The on-disk filename of the file.
|
||||||
#
|
#
|
||||||
# Returns the String name.
|
# Returns the String name.
|
||||||
|
|||||||
+19
-4
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
module Gollum
|
module Gollum
|
||||||
=begin
|
=begin
|
||||||
FileView requires that:
|
FileView requires that:
|
||||||
@@ -5,8 +6,13 @@ module Gollum
|
|||||||
- Then all the folders are sorted and processed
|
- Then all the folders are sorted and processed
|
||||||
=end
|
=end
|
||||||
class FileView
|
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
|
@pages = pages
|
||||||
|
@show_all = options[:show_all] || false
|
||||||
|
@checked = options[:collapse_tree] ? '' : "checked"
|
||||||
end
|
end
|
||||||
|
|
||||||
def enclose_tree string
|
def enclose_tree string
|
||||||
@@ -26,7 +32,7 @@ module Gollum
|
|||||||
def new_sub_folder path
|
def new_sub_folder path
|
||||||
<<-HTML
|
<<-HTML
|
||||||
<li>
|
<li>
|
||||||
<label>#{path}</label> <input type="checkbox" checked />
|
<label>#{path}</label> <input type="checkbox" #{@checked} />
|
||||||
<ol>
|
<ol>
|
||||||
HTML
|
HTML
|
||||||
end
|
end
|
||||||
@@ -39,7 +45,16 @@ module Gollum
|
|||||||
end
|
end
|
||||||
|
|
||||||
def url_for_page page
|
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 = url[2..-1] if url[0,2] == './'
|
||||||
url
|
url
|
||||||
end
|
end
|
||||||
@@ -74,7 +89,7 @@ module Gollum
|
|||||||
url = url_for_page page
|
url = url_for_page page
|
||||||
html += <<-HTML
|
html += <<-HTML
|
||||||
<li>
|
<li>
|
||||||
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" checked />
|
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" #{@checked} />
|
||||||
<ol>
|
<ol>
|
||||||
<li class="file"><a href="#{url}">#{name}</a></li>
|
<li class="file"><a href="#{url}">#{name}</a></li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|||||||
+25
-17
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
require 'cgi'
|
require 'cgi'
|
||||||
require 'sinatra'
|
require 'sinatra'
|
||||||
require 'gollum'
|
require 'gollum'
|
||||||
@@ -82,11 +83,12 @@ module Precious
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
@base_url = url('/', false).chomp('/')
|
@base_url = url('/', false).chomp('/')
|
||||||
settings.wiki_options.merge!({ :base_path => @base_url }) unless settings.wiki_options.has_key? :base_path
|
# above will detect base_path when it's used with map in a config.ru
|
||||||
|
settings.wiki_options.merge!({ :base_path => @base_url })
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/' do
|
get '/' do
|
||||||
redirect File.join(settings.wiki_options[:page_file_dir].to_s,settings.wiki_options[:base_path].to_s, 'Home')
|
redirect ::File.join(@base_url, 'Home')
|
||||||
end
|
end
|
||||||
|
|
||||||
# path is set to name if path is nil.
|
# path is set to name if path is nil.
|
||||||
@@ -187,24 +189,20 @@ module Precious
|
|||||||
|
|
||||||
post '/create' do
|
post '/create' do
|
||||||
name = params[:page].to_url
|
name = params[:page].to_url
|
||||||
path = sanitize_empty_params(params[:path])
|
path = sanitize_empty_params(params[:path]) || ''
|
||||||
path = '' if path.nil?
|
|
||||||
format = params[:format].intern
|
format = params[:format].intern
|
||||||
|
|
||||||
page_dir = File.join(settings.wiki_options[:page_file_dir].to_s,
|
# ensure pages are created in page_file_dir
|
||||||
settings.wiki_options[:base_path].to_s)
|
page_dir = settings.wiki_options[:page_file_dir].to_s
|
||||||
# Home is a special case.
|
path = clean_url(::File.join(page_dir, path)) unless path.start_with?(page_dir)
|
||||||
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.
|
# write_page is not directory aware so use wiki_options to emulate dir support.
|
||||||
wiki_options = settings.wiki_options.merge({ :page_file_dir => page_dir })
|
wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
|
||||||
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
wiki.write_page(name, format, params[:content], commit_message)
|
wiki.write_page(name, format, params[:content], commit_message)
|
||||||
redirect to("/#{clean_url(CGI.escape(::File.join(page_dir,name)))}")
|
redirect to("/#{clean_url(::File.join(path,name))}")
|
||||||
rescue Gollum::DuplicatePageError => e
|
rescue Gollum::DuplicatePageError => e
|
||||||
@message = "Duplicate page: #{e.message}"
|
@message = "Duplicate page: #{e.message}"
|
||||||
mustache :error
|
mustache :error
|
||||||
@@ -308,7 +306,8 @@ module Precious
|
|||||||
get '/search' do
|
get '/search' do
|
||||||
@query = params[:q]
|
@query = params[:q]
|
||||||
wiki = wiki_new
|
wiki = wiki_new
|
||||||
@results = wiki.search @query
|
# Sort wiki search results by count (desc) and then by name (asc)
|
||||||
|
@results = wiki.search(@query).sort{ |a, b| (a[:count] <=> b[:count]).nonzero? || b[:name] <=> a[:name] }.reverse
|
||||||
@name = @query
|
@name = @query
|
||||||
mustache :search
|
mustache :search
|
||||||
end
|
end
|
||||||
@@ -323,13 +322,21 @@ module Precious
|
|||||||
wiki_options = settings.wiki_options.merge({ :page_file_dir => @path })
|
wiki_options = settings.wiki_options.merge({ :page_file_dir => @path })
|
||||||
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
||||||
@results = wiki.pages
|
@results = wiki.pages
|
||||||
|
@results += wiki.files if settings.wiki_options[:show_all]
|
||||||
@ref = wiki.ref
|
@ref = wiki.ref
|
||||||
mustache :pages
|
mustache :pages
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/fileview' do
|
get '/fileview' do
|
||||||
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
|
wiki = wiki_new
|
||||||
@results = Gollum::FileView.new(wiki.pages).render_files
|
options = settings.wiki_options
|
||||||
|
content = wiki.pages
|
||||||
|
# if showing all files include wiki.files
|
||||||
|
content += wiki.files if options[:show_all]
|
||||||
|
|
||||||
|
# must pass wiki_options to FileView
|
||||||
|
# --show-all and --collapse-tree can be set.
|
||||||
|
@results = Gollum::FileView.new(content, options).render_files
|
||||||
@ref = wiki.ref
|
@ref = wiki.ref
|
||||||
mustache :file_view, { :layout => false }
|
mustache :file_view, { :layout => false }
|
||||||
end
|
end
|
||||||
@@ -340,10 +347,11 @@ module Precious
|
|||||||
|
|
||||||
def show_page_or_file(fullpath)
|
def show_page_or_file(fullpath)
|
||||||
name = extract_name(fullpath)
|
name = extract_name(fullpath)
|
||||||
path = extract_path(fullpath)
|
path = extract_path(fullpath) || '/'
|
||||||
wiki = wiki_new
|
wiki = wiki_new
|
||||||
|
|
||||||
path = '/' if path.nil?
|
page_dir = settings.wiki_options[:page_file_dir].to_s
|
||||||
|
path = ::File.join(page_dir, path) unless path.start_with?(page_dir)
|
||||||
|
|
||||||
if page = wiki.paged(name, path, exact = true)
|
if page = wiki.paged(name, path, exact = true)
|
||||||
@page = page
|
@page = page
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
module Precious
|
module Precious
|
||||||
module Helpers
|
module Helpers
|
||||||
# Extract the path string that Gollum::Wiki expects
|
# Extract the path string that Gollum::Wiki expects
|
||||||
@@ -19,9 +20,10 @@ module Precious
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Remove all slashes from the start of string.
|
# Remove all slashes from the start of string.
|
||||||
|
# Remove all double slashes
|
||||||
def clean_url url
|
def clean_url url
|
||||||
return url if url.nil?
|
return url if url.nil?
|
||||||
url.gsub('%2F','/').gsub(/^\/+/,'')
|
url.gsub('%2F','/').gsub(/^\/+/,'').gsub('//','/')
|
||||||
end
|
end
|
||||||
|
|
||||||
def trim_leading_slash url
|
def trim_leading_slash url
|
||||||
|
|||||||
@@ -212,4 +212,20 @@ $(document).ready(function() {
|
|||||||
$('#gollum-revert-form').submit();
|
$('#gollum-revert-form').submit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( $('#wiki-wrapper.edit').length ){
|
||||||
|
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
|
||||||
|
$("#gollum-editor-body").one('change', function(){
|
||||||
|
window.onbeforeunload = function(){ return "Leaving will discard all edits!" };
|
||||||
|
});
|
||||||
|
$.GollumEditor();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $('#wiki-wrapper.create').length ){
|
||||||
|
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
|
||||||
|
$("#gollum-editor-body").one('change', function(){
|
||||||
|
window.onbeforeunload = function(){ return "Leaving will not create a new page!" };
|
||||||
|
)};
|
||||||
|
$.GollumEditor({ NewFile: true, MarkupType: '{{default_markup}}' });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 630 B |
@@ -11,6 +11,7 @@
|
|||||||
<div id='previewframe'><div id='contentframe' class='markdown-body'></div></div>
|
<div id='previewframe'><div id='contentframe' class='markdown-body'></div></div>
|
||||||
<!-- tool panel from notepage.es. save & savecomment icons from Retina Display Icon Set. -->
|
<!-- tool panel from notepage.es. save & savecomment icons from Retina Display Icon Set. -->
|
||||||
<div id='toolpanel' class='toolpanel edit' style='width: 500px; right: 0px; visibility: hidden;'>
|
<div id='toolpanel' class='toolpanel edit' style='width: 500px; right: 0px; visibility: hidden;'>
|
||||||
|
<a id='preview' class='edit'><img src='images/globe_24.png' alt='Preview' title='Preview'></a>
|
||||||
<a id='save' class='edit'><img src='images/save_24.png' alt='Save' title='Save'></a>
|
<a id='save' class='edit'><img src='images/save_24.png' alt='Save' title='Save'></a>
|
||||||
<a id='savecomment' class='edit'><img src='images/savecomment_24.png' alt='Save with comment' title='Save with comment'></a>
|
<a id='savecomment' class='edit'><img src='images/savecomment_24.png' alt='Save with comment' title='Save with comment'></a>
|
||||||
<a id='toggle' class='edit' href='javascript:void(0)' onclick='jsm.toggleLeftRight();'><img src='images/lr_24.png' alt='Toggle left to right' title='Toggle left to right'></a>
|
<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>
|
||||||
|
|||||||
@@ -87,6 +87,18 @@ defaultCommitMessage = function() {
|
|||||||
// Set comment using the default commit message.
|
// Set comment using the default commit message.
|
||||||
commentEditorSession.setValue( defaultCommitMessage() );
|
commentEditorSession.setValue( defaultCommitMessage() );
|
||||||
|
|
||||||
|
$.preview = function( previewWindow ) {
|
||||||
|
jQuery.ajax( {
|
||||||
|
type: 'POST',
|
||||||
|
url: baseUrl + '/preview',
|
||||||
|
data: { page: 'Preview: ' + pageName, format: 'markdown', content: editorSession.getValue() },
|
||||||
|
success: function( html ) {
|
||||||
|
previewWindow.document.write( html );
|
||||||
|
previewWindow.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$.save = function( commitMessage ) {
|
$.save = function( commitMessage ) {
|
||||||
win.onbeforeunload = null;
|
win.onbeforeunload = null;
|
||||||
|
|
||||||
@@ -96,8 +108,9 @@ $.save = function( commitMessage ) {
|
|||||||
var msg = defaultCommitMessage();
|
var msg = defaultCommitMessage();
|
||||||
var newLocation = baseUrl;
|
var newLocation = baseUrl;
|
||||||
|
|
||||||
|
// Remove all duplicate slashes
|
||||||
function clean( str ) {
|
function clean( str ) {
|
||||||
return str.replace(/^\/+/, '/');
|
return str.replace(/\/+/g, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'a%2Fb' => a/b
|
// 'a%2Fb' => a/b
|
||||||
@@ -377,8 +390,16 @@ var applyTimeout = function () {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$( '#preview' ).click( function() {
|
||||||
|
$(this).target = "_blank";
|
||||||
|
// pass window into preview
|
||||||
|
$.preview( window.open() );
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
$( '#save' ).click( function() {
|
$( '#save' ).click( function() {
|
||||||
$.save();
|
$.save();
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Hide dimmer, comment tool panel, and comment.
|
// Hide dimmer, comment tool panel, and comment.
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ CC BY-SA 3.0 Unported
|
|||||||
http://blog.twg.ca/2010/11/retina-display-icon-set/
|
http://blog.twg.ca/2010/11/retina-display-icon-set/
|
||||||
http://creativecommons.org/licenses/by-sa/3.0/legalcode.txt
|
http://creativecommons.org/licenses/by-sa/3.0/legalcode.txt
|
||||||
|
|
||||||
|
lib/gollum/frontend/public/images/savecomment_24.png
|
||||||
|
lib/gollum/frontend/public/images/cancel_24.png
|
||||||
lib/gollum/frontend/public/images/save_24.png
|
lib/gollum/frontend/public/images/save_24.png
|
||||||
|
lib/gollum/frontend/public/images/globe_24.png
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<div id="wiki-wrapper">
|
<div id="wiki-wrapper" class="create">
|
||||||
<div id="head">
|
<div id="head">
|
||||||
<h1>Create New Page</h1>
|
<h1>Create New Page</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -8,13 +8,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
|
||||||
window.onbeforeunload = function(){ return "Leaving will not create a new page!" };
|
|
||||||
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
|
|
||||||
|
|
||||||
jQuery(document).ready(function() {
|
|
||||||
$.GollumEditor({ NewFile: true, MarkupType: '{{default_markup}}' });
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{{something}}
|
{{something}}
|
||||||
|
|||||||
@@ -10,11 +10,3 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="wiki-content">{{>editor}}</div>
|
<div id="wiki-content">{{>editor}}</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
|
||||||
window.onbeforeunload = function(){ return "Leaving will discard all edits!" };
|
|
||||||
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
|
|
||||||
|
|
||||||
jQuery(document).ready(function() {
|
|
||||||
$.GollumEditor();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
module Gollum
|
module Gollum
|
||||||
# Controls all access to the Git objects from Gollum. Extend this class to
|
# Controls all access to the Git objects from Gollum. Extend this class to
|
||||||
# add custom caching for special cases.
|
# add custom caching for special cases.
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
require 'net/http'
|
require 'net/http'
|
||||||
require 'net/https' # ruby 1.8.7 fix, remove at upgrade
|
require 'net/https' # ruby 1.8.7 fix, remove at upgrade
|
||||||
require 'uri'
|
require 'uri'
|
||||||
|
|||||||
+16
-5
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
require 'digest/sha1'
|
require 'digest/sha1'
|
||||||
require 'cgi'
|
require 'cgi'
|
||||||
require 'pygments'
|
require 'pygments'
|
||||||
@@ -37,6 +38,7 @@ module Gollum
|
|||||||
@premap = {}
|
@premap = {}
|
||||||
@toc = nil
|
@toc = nil
|
||||||
@metadata = nil
|
@metadata = nil
|
||||||
|
@to_xml = { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML ^ 1, :indent => 0, :encoding => 'UTF-8' }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Render the content with Gollum wiki syntax on top of the file's own
|
# Render the content with Gollum wiki syntax on top of the file's own
|
||||||
@@ -74,13 +76,18 @@ module Gollum
|
|||||||
doc,toc = process_headers(doc)
|
doc,toc = process_headers(doc)
|
||||||
@toc = @sub_page ? ( @parent_page ? @parent_page.toc_data : "[[_TOC_]]" ) : toc
|
@toc = @sub_page ? ( @parent_page ? @parent_page.toc_data : "[[_TOC_]]" ) : toc
|
||||||
yield doc if block_given?
|
yield doc if block_given?
|
||||||
data = doc.to_xhtml
|
# nokogiri's save options are ored together. FORMAT has a value of 1 so ^ 1 removes it.
|
||||||
|
# formatting will create extra spaces in pre tags.
|
||||||
|
# https://github.com/sparklemotion/nokogiri/issues/782
|
||||||
|
# DEFAULT_HTML encodes unicode so XHTML is used for proper unicode support in href.
|
||||||
|
data = doc.to_xml( @to_xml )
|
||||||
|
|
||||||
data = process_toc_tags(data)
|
data = process_toc_tags(data)
|
||||||
data = process_wsd(data)
|
data = process_wsd(data)
|
||||||
data.gsub!(/<p><\/p>/) do
|
data.gsub!(/<p><\/p>/) do
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -119,7 +126,7 @@ module Gollum
|
|||||||
node.add_child(%Q{<a href="##{h_name}">#{h.content}</a>})
|
node.add_child(%Q{<a href="##{h_name}">#{h.content}</a>})
|
||||||
tail.add_child(node)
|
tail.add_child(node)
|
||||||
end
|
end
|
||||||
toc = toc.to_xhtml if toc != nil
|
toc = toc.to_xml(@to_xml) if toc != nil
|
||||||
[doc, toc]
|
[doc, toc]
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -481,8 +488,10 @@ module Gollum
|
|||||||
# extract lang from { .ruby } or { #stuff .ruby .indent }
|
# extract lang from { .ruby } or { #stuff .ruby .indent }
|
||||||
# see http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks
|
# see http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks
|
||||||
|
|
||||||
lang = lang.match(/\.([^}\s]+)/)
|
if lang
|
||||||
lang = lang[1] unless lang.nil?
|
lang = lang.match(/\.([^}\s]+)/)
|
||||||
|
lang = lang[1] unless lang.nil?
|
||||||
|
end
|
||||||
|
|
||||||
@codemap[id] = cached ?
|
@codemap[id] = cached ?
|
||||||
{ :output => cached } :
|
{ :output => cached } :
|
||||||
@@ -543,7 +552,9 @@ module Gollum
|
|||||||
blocks.each do |lang, code|
|
blocks.each do |lang, code|
|
||||||
encoding ||= 'utf-8'
|
encoding ||= 'utf-8'
|
||||||
begin
|
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
|
rescue
|
||||||
hl_code = code
|
hl_code = code
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
module Gollum
|
module Gollum
|
||||||
class Page
|
class Page
|
||||||
include Pagination
|
include Pagination
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
module Gollum
|
module Gollum
|
||||||
module Pagination
|
module Pagination
|
||||||
def self.included(klass)
|
def self.included(klass)
|
||||||
@@ -58,4 +59,4 @@ module Gollum
|
|||||||
self.class.log_pagination_options(options)
|
self.class.log_pagination_options(options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
module Gollum
|
module Gollum
|
||||||
# Encapsulate sanitization options.
|
# Encapsulate sanitization options.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
require 'net/http'
|
require 'net/http'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
|
|||||||
+15
-2
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
module Gollum
|
module Gollum
|
||||||
class Wiki
|
class Wiki
|
||||||
include Pagination
|
include Pagination
|
||||||
@@ -154,6 +155,9 @@ module Gollum
|
|||||||
# :ref - String the repository ref to retrieve pages from
|
# :ref - String the repository ref to retrieve pages from
|
||||||
# :ws_subs - Array of chars to sub for ws in filenames.
|
# :ws_subs - Array of chars to sub for ws in filenames.
|
||||||
# :mathjax - Set to false to disable mathjax.
|
# :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.
|
# Returns a fresh Gollum::Repo.
|
||||||
def initialize(path, options = {})
|
def initialize(path, options = {})
|
||||||
@@ -177,9 +181,11 @@ module Gollum
|
|||||||
self.class.default_ws_subs
|
self.class.default_ws_subs
|
||||||
@history_sanitization = options[:history_sanitization] ||
|
@history_sanitization = options[:history_sanitization] ||
|
||||||
self.class.history_sanitization
|
self.class.history_sanitization
|
||||||
@live_preview = options.fetch(:live_preview, true)
|
@live_preview = options[:live_preview] || true
|
||||||
@universal_toc = options.fetch(:universal_toc, false)
|
@universal_toc = options[:universal_toc] || false
|
||||||
@mathjax = options[:mathjax] || false
|
@mathjax = options[:mathjax] || false
|
||||||
|
@show_all = options[:show_all] || false
|
||||||
|
@collapse_tree = options[:collapse_tree] || false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: check whether the wiki's git repo exists on the filesystem.
|
# Public: check whether the wiki's git repo exists on the filesystem.
|
||||||
@@ -588,6 +594,13 @@ module Gollum
|
|||||||
# Toggles mathjax.
|
# Toggles mathjax.
|
||||||
attr_reader :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.
|
# Normalize the data.
|
||||||
#
|
#
|
||||||
# data - The String data to be normalized.
|
# data - The String data to be normalized.
|
||||||
|
|||||||
@@ -185,6 +185,8 @@ context "Frontend" do
|
|||||||
post "/create", :content => 'abc', :page => name,
|
post "/create", :content => 'abc', :page => name,
|
||||||
:format => 'markdown', :message => 'def'
|
:format => 'markdown', :message => 'def'
|
||||||
|
|
||||||
|
follow_redirect!
|
||||||
|
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
|
|
||||||
@wiki.clear_cache
|
@wiki.clear_cache
|
||||||
@@ -260,6 +262,9 @@ context "Frontend" do
|
|||||||
page2 = @wiki.page('A')
|
page2 = @wiki.page('A')
|
||||||
assert_equal page1.version.sha, page2.version.sha
|
assert_equal page1.version.sha, page2.version.sha
|
||||||
end
|
end
|
||||||
|
=begin
|
||||||
|
# redirects are now handled by class MapGollum in bin/gollum
|
||||||
|
# they should be set in config.ru
|
||||||
|
|
||||||
test "redirects from 'base_path' or 'base_path/' to 'base_path/Home'" do
|
test "redirects from 'base_path' or 'base_path/' to 'base_path/Home'" do
|
||||||
Precious::App.set(:wiki_options, {})
|
Precious::App.set(:wiki_options, {})
|
||||||
@@ -277,6 +282,7 @@ context "Frontend" do
|
|||||||
# Reset base path
|
# Reset base path
|
||||||
Precious::App.set(:wiki_options, { :base_path => nil })
|
Precious::App.set(:wiki_options, { :base_path => nil })
|
||||||
end
|
end
|
||||||
|
=end
|
||||||
|
|
||||||
test "author details in session are used" do
|
test "author details in session are used" do
|
||||||
page1 = @wiki.page('A')
|
page1 = @wiki.page('A')
|
||||||
@@ -363,6 +369,36 @@ context "Frontend with lotr" do
|
|||||||
assert body.include?("Eye Of Sauron"), "/pages/Mordor/ should include the page 'Eye Of Sauron'"
|
assert body.include?("Eye Of Sauron"), "/pages/Mordor/ should include the page 'Eye Of Sauron'"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# base path requires 'map' in a config.ru to work correctly.
|
||||||
|
test "create pages within sub-directories using base path" do
|
||||||
|
Precious::App.set(:wiki_options, { :base_path => 'wiki' })
|
||||||
|
page = 'path'
|
||||||
|
post "/create", :content => '123', :page => page,
|
||||||
|
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||||
|
# should be wiki/Mordor/path
|
||||||
|
assert_equal 'http://example.org/Mordor/' + page, last_response.headers['Location']
|
||||||
|
get '/Mordor/' + page
|
||||||
|
assert_match /123/, last_response.body
|
||||||
|
|
||||||
|
# Reset base path
|
||||||
|
Precious::App.set(:wiki_options, { :base_path => nil })
|
||||||
|
end
|
||||||
|
|
||||||
|
test "create pages within sub-directories using page file dir" do
|
||||||
|
Precious::App.set(:wiki_options, { :page_file_dir => 'wiki' })
|
||||||
|
|
||||||
|
post "/create", :content => 'one two', :page => 'base',
|
||||||
|
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||||
|
assert_equal 'http://example.org/wiki/Mordor/base', last_response.headers['Location']
|
||||||
|
get "/wiki/Mordor/base"
|
||||||
|
|
||||||
|
# Reset page_file_dir after request but before matching.
|
||||||
|
Precious::App.set(:wiki_options, { :page_file_dir => nil })
|
||||||
|
|
||||||
|
assert_match /one two/, last_response.body
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
test "create pages within sub-directories" do
|
test "create pages within sub-directories" do
|
||||||
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
||||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ class FakePage
|
|||||||
::File.basename(@filepath, ::File.extname(@filepath))
|
::File.basename(@filepath, ::File.extname(@filepath))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def filename
|
||||||
|
::File.basename(@filepath)
|
||||||
|
end
|
||||||
|
|
||||||
def path
|
def path
|
||||||
return @filepath
|
return @filepath
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ context "gitcode" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test 'that the rendered output is correctly fetched and rendered as html code' do
|
test 'that the rendered output is correctly fetched and rendered as html code' do
|
||||||
assert_equal %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"nt\"><ol</span> <span class=\"na\">class=</span><span class=\"s\">\"tree\"</span><span class=\"nt\">></span>\n <span class=\"nt\"><li</span> <span class=\"na\">class=</span><span class=\"s\">\"file\"</span><span class=\"nt\">><a</span> <span class=\"na\">href=</span><span class=\"s\">\"0\"</span><span class=\"nt\">></span>0<span class=\"nt\"></a></li></span>\n<span class=\"nt\"></ol></span>\n</pre>\n</div>\n\n<p>b</p>}, @rendered
|
assert_equal %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"nt\"><ol</span> <span class=\"na\">class=</span><span class=\"s\">\"tree\"</span><span class=\"nt\">></span>\n <span class=\"nt\"><li</span> <span class=\"na\">class=</span><span class=\"s\">\"file\"</span><span class=\"nt\">><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
|
end
|
||||||
|
|
||||||
test 'contents' do
|
test 'contents' do
|
||||||
|
|||||||
+42
-17
@@ -193,7 +193,7 @@ context "Markup" do
|
|||||||
test "wiki link within inline code block" do
|
test "wiki link within inline code block" do
|
||||||
@wiki.write_page("Potato", :markdown, "`sed -i '' 's/[[:space:]]*$//'`", commit_details)
|
@wiki.write_page("Potato", :markdown, "`sed -i '' 's/[[:space:]]*$//'`", commit_details)
|
||||||
page = @wiki.page("Potato")
|
page = @wiki.page("Potato")
|
||||||
assert_equal "<p>\n <code>sed -i '' 's/[[:space:]]*$//'</code>\n</p>", page.formatted_data
|
assert_equal "<p><code>sed -i '' 's/[[:space:]]*$//'</code></p>", page.formatted_data
|
||||||
end
|
end
|
||||||
|
|
||||||
test "regexp gsub! backref (#383)" do
|
test "regexp gsub! backref (#383)" do
|
||||||
@@ -208,11 +208,24 @@ context "Markup" do
|
|||||||
DATA
|
DATA
|
||||||
), commit_details)
|
), commit_details)
|
||||||
output = @wiki.page(page).formatted_data
|
output = @wiki.page(page).formatted_data
|
||||||
expected = %Q{<pre>\n <code> <div class=\"highlight\"><pre><span class=\"n\">rot13</span><span class=\"p\">=</span><span class=\"s\">'tr '</span><span class=\"o\">\\</span><span class=\"s\">''</span><span class=\"n\">A</span><span class=\"o\">-</span><span class=\"n\">Za</span><span class=\"o\">-</span><span class=\"n\">z</span><span class=\"o\">'\\</span><span class=\"s\">''</span> <span class=\"s\">'\\''N-ZA-Mn-za-m'</span><span class=\"o\">\\</span><span class=\"s\">'</span>\n</pre></div>\n</code>\n</pre>}
|
expected = %Q{<pre><code> <div class=\"highlight\"><pre><span class=\"n\">rot13</span><span class=\"p\">=</span><span class=\"s\">'tr '</span><span class=\"o\">\\</span><span class=\"s\">''</span><span class=\"n\">A</span><span class=\"o\">-</span><span class=\"n\">Za</span><span class=\"o\">-</span><span class=\"n\">z</span><span class=\"o\">'\\</span><span class=\"s\">''</span> <span class=\"s\">'\\''N-ZA-Mn-za-m'</span><span class=\"o\">\\</span><span class=\"s\">'</span>\n</pre></div>\n</code></pre>}
|
||||||
assert_equal expected, output
|
assert_equal expected, output
|
||||||
end
|
end
|
||||||
|
|
||||||
test "~~~ code blocks #537" do
|
# Issue #568
|
||||||
|
test "tilde code blocks without a language" do
|
||||||
|
page = 'test_rgx'
|
||||||
|
@wiki.write_page(page, :markdown,
|
||||||
|
%Q(~~~
|
||||||
|
'hi'
|
||||||
|
~~~
|
||||||
|
), commit_details)
|
||||||
|
output = @wiki.page(page).formatted_data
|
||||||
|
expected = %Q{<div class=\"highlight\"><pre><span class=\"s\">'hi'</span>\n</pre></div>}
|
||||||
|
assert_equal expected, output
|
||||||
|
end
|
||||||
|
|
||||||
|
test "tilde code blocks #537" do
|
||||||
page = 'test_rgx'
|
page = 'test_rgx'
|
||||||
@wiki.write_page(page, :markdown,
|
@wiki.write_page(page, :markdown,
|
||||||
%Q(~~~ {.ruby}
|
%Q(~~~ {.ruby}
|
||||||
@@ -220,11 +233,12 @@ context "Markup" do
|
|||||||
~~~
|
~~~
|
||||||
), commit_details)
|
), commit_details)
|
||||||
output = @wiki.page(page).formatted_data
|
output = @wiki.page(page).formatted_data
|
||||||
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"s1\">'hi'</span>\n</pre>\n</div>}
|
expected = %Q{<div class=\"highlight\"><pre><span class=\"s1\">'hi'</span>\n</pre></div>}
|
||||||
assert_equal expected, output
|
assert_equal expected, output
|
||||||
end
|
end
|
||||||
|
|
||||||
test "~~~ code blocks #537 with more than one class" do
|
# Issue #537
|
||||||
|
test "tilde code blocks with more than one class" do
|
||||||
page = 'test_rgx'
|
page = 'test_rgx'
|
||||||
@wiki.write_page(page, :markdown,
|
@wiki.write_page(page, :markdown,
|
||||||
%Q(~~~ {#hi .ruby .sauce}
|
%Q(~~~ {#hi .ruby .sauce}
|
||||||
@@ -232,11 +246,12 @@ context "Markup" do
|
|||||||
~~~
|
~~~
|
||||||
), commit_details)
|
), commit_details)
|
||||||
output = @wiki.page(page).formatted_data
|
output = @wiki.page(page).formatted_data
|
||||||
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"s1\">'hi'</span>\n</pre>\n</div>}
|
expected = %Q{<div class=\"highlight\"><pre><span class=\"s1\">'hi'</span>\n</pre></div>}
|
||||||
assert_equal expected, output
|
assert_equal expected, output
|
||||||
end
|
end
|
||||||
|
|
||||||
test "~~~ code blocks #537 with lots of tildes" do
|
# Issue #537
|
||||||
|
test "tilde code blocks with lots of tildes" do
|
||||||
page = 'test_rgx'
|
page = 'test_rgx'
|
||||||
@wiki.write_page(page, :markdown,
|
@wiki.write_page(page, :markdown,
|
||||||
%Q(~~~~~~ {#hi .ruby .sauce}
|
%Q(~~~~~~ {#hi .ruby .sauce}
|
||||||
@@ -245,20 +260,30 @@ context "Markup" do
|
|||||||
~~~~~~
|
~~~~~~
|
||||||
), commit_details)
|
), commit_details)
|
||||||
output = @wiki.page(page).formatted_data
|
output = @wiki.page(page).formatted_data
|
||||||
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"o\">~~</span>\n<span class=\"s1\">'hi'</span><span class=\"o\">~</span>\n</pre>\n</div>}
|
expected = %Q{<div class=\"highlight\"><pre><span class=\"o\">~~</span>\n<span class=\"s1\">'hi'</span><span class=\"o\">~</span>\n</pre></div>}
|
||||||
|
assert_equal expected, output
|
||||||
|
end
|
||||||
|
|
||||||
|
test "four space indented code block" do
|
||||||
|
page = 'test_four'
|
||||||
|
@wiki.write_page(page, :markdown,
|
||||||
|
%( test
|
||||||
|
test), commit_details)
|
||||||
|
output = @wiki.page(page).formatted_data
|
||||||
|
expected = %(<pre><code>test\ntest\n</code></pre>)
|
||||||
assert_equal expected, output
|
assert_equal expected, output
|
||||||
end
|
end
|
||||||
|
|
||||||
test "wiki link within code block" do
|
test "wiki link within code block" do
|
||||||
@wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details)
|
@wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details)
|
||||||
page = @wiki.page("Potato")
|
page = @wiki.page("Potato")
|
||||||
assert_equal "<pre>\n <code>sed -i '' 's/[[:space:]]*$//'\n</code>\n</pre>", page.formatted_data
|
assert_equal "<pre><code>sed -i '' 's/[[:space:]]*$//'\n</code></pre>", page.formatted_data
|
||||||
end
|
end
|
||||||
|
|
||||||
test "piped wiki link within code block" do
|
test "piped wiki link within code block" do
|
||||||
@wiki.write_page("Potato", :markdown, "`make a link [[home|sweet home]]`", commit_details)
|
@wiki.write_page("Potato", :markdown, "`make a link [[home|sweet home]]`", commit_details)
|
||||||
page = @wiki.page("Potato")
|
page = @wiki.page("Potato")
|
||||||
assert_equal "<p>\n <code>make a link [[home|sweet home]]</code>\n</p>", page.formatted_data
|
assert_equal "<p><code>make a link [[home|sweet home]]</code></p>", page.formatted_data
|
||||||
end
|
end
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
@@ -459,9 +484,9 @@ context "Markup" do
|
|||||||
#
|
#
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
|
||||||
test "code blocks" do
|
test "regular code blocks" do
|
||||||
content = "a\n\n```ruby\nx = 1\n```\n\nb"
|
content = "a\n\n```ruby\nx = 1\n```\n\nb"
|
||||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>}
|
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre></div>\n\n<p>b</p>}
|
||||||
|
|
||||||
index = @wiki.repo.index
|
index = @wiki.repo.index
|
||||||
index.add("Bilbo-Baggins.md", content)
|
index.add("Bilbo-Baggins.md", content)
|
||||||
@@ -474,7 +499,7 @@ context "Markup" do
|
|||||||
|
|
||||||
test "code blocks with carriage returns" do
|
test "code blocks with carriage returns" do
|
||||||
content = "a\r\n\r\n```ruby\r\nx = 1\r\n```\r\n\r\nb"
|
content = "a\r\n\r\n```ruby\r\nx = 1\r\n```\r\n\r\nb"
|
||||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>}
|
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre></div>\n\n<p>b</p>}
|
||||||
|
|
||||||
index = @wiki.repo.index
|
index = @wiki.repo.index
|
||||||
index.add("Bilbo-Baggins.md", content)
|
index.add("Bilbo-Baggins.md", content)
|
||||||
@@ -505,7 +530,7 @@ context "Markup" do
|
|||||||
|
|
||||||
test "code blocks with multibyte caracters indent" do
|
test "code blocks with multibyte caracters indent" do
|
||||||
content = "a\n\n```ruby\ns = 'やくしまるえつこ'\n```\n\nb"
|
content = "a\n\n```ruby\ns = 'やくしまるえつこ'\n```\n\nb"
|
||||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">s</span> <span class=\"o\">=</span> <span class=\"s1\">'やくしまるえつこ'</span>\n</pre>\n</div>\n\n<p>b</p>}
|
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">s</span> <span class=\"o\">=</span> <span class=\"s1\">'やくしまるえつこ'</span>\n</pre></div>\n\n<p>b</p>}
|
||||||
index = @wiki.repo.index
|
index = @wiki.repo.index
|
||||||
index.add("Bilbo-Baggins.md", content)
|
index.add("Bilbo-Baggins.md", content)
|
||||||
index.commit("Add alpha.jpg")
|
index.commit("Add alpha.jpg")
|
||||||
@@ -565,7 +590,7 @@ np.array([[2,2],[1,3]],np.float)
|
|||||||
output_page = @wiki.page("page").formatted_data
|
output_page = @wiki.page("page").formatted_data
|
||||||
|
|
||||||
assert_equal %Q{<p>a b</p>}, output_script
|
assert_equal %Q{<p>a b</p>}, output_script
|
||||||
assert_equal %Q{<div class=\"highlight\">\n <pre><span class=\"nt\"><p></span>a b<span class=\"nt\"></p></span>\n</pre>\n</div>}, output_page
|
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
|
end
|
||||||
|
|
||||||
test "embed code page absolute link" do
|
test "embed code page absolute link" do
|
||||||
@@ -574,7 +599,7 @@ np.array([[2,2],[1,3]],np.float)
|
|||||||
|
|
||||||
page = @wiki.page("a")
|
page = @wiki.page("a")
|
||||||
output = page.formatted_data
|
output = page.formatted_data
|
||||||
assert_equal %Q{<p>a\n</p><div class=\"highlight\">\n <pre><span class=\"nt\"><p></span>a\n!base<span class=\"nt\"></p></span>\n</pre>\n</div>\n}, output
|
assert_equal %Q{<p>a\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
|
end
|
||||||
|
|
||||||
test "embed code page relative link" do
|
test "embed code page relative link" do
|
||||||
@@ -583,7 +608,7 @@ np.array([[2,2],[1,3]],np.float)
|
|||||||
|
|
||||||
page = @wiki.page("a")
|
page = @wiki.page("a")
|
||||||
output = page.formatted_data
|
output = page.formatted_data
|
||||||
assert_equal %Q{<p>a\n</p><div class=\"highlight\">\n <pre><span class=\"nt\"><p></span>a\n!rel<span class=\"nt\"></p></span>\n</pre>\n</div>\n}, output
|
assert_equal %Q{<p>a\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
|
end
|
||||||
|
|
||||||
test "code block in unsupported language" do
|
test "code block in unsupported language" do
|
||||||
|
|||||||
Reference in New Issue
Block a user